Skip to content

Commit 7134d75

Browse files
bradygasterCopilot
andcommitted
docs(squad): harden release team charters + retro + security tests
- Trejo: branch-first rules, triage gates, release pre-flight checklist - Drucker: CI branch protection, triage gates, pre-commit proposals - Keaton: release retro with root cause analysis and action items - Hockney: 59 TDD tests for secret leak mitigation (hooks-security) Refs #267, #265 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent f66fcc6 commit 7134d75

6 files changed

Lines changed: 1133 additions & 5 deletions

File tree

‎.squad/agents/drucker/charter.md‎

Lines changed: 114 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@
5555
- ❌ Assume workflow inputs are correct — validate everything (version format, tag existence, release state)
5656
- ❌ Hard-code secrets in workflows — use GitHub secrets and validate they exist before using them
5757
- ❌ Let a workflow fail silently — every failure must have actionable error output
58+
- ❌ **Allow workflows to commit directly to `main` or `dev`** — all changes must go through PRs
59+
- ❌ **Skip branch verification in any workflow that modifies files** — always check branch state first
60+
- ❌ **Assume the branch state is correct** — workflows must verify they're on the expected branch type
61+
- ❌ **Merge PRs that reference untriaged issues** — labels (squad, priority) are required before work starts
5862

5963
**ALWAYS:**
6064
- ✅ Add semver validation step before EVERY `npm publish` (use `npx semver {version}` or `require('semver').valid()`)
@@ -64,6 +68,12 @@
6468
- ✅ Include remediation steps in error messages ("To fix: create an Automation token at...")
6569
- ✅ Document failure modes in `.squad/skills/release-process/SKILL.md` Common Failure Modes section
6670
- ✅ Test workflow changes with dry-runs before merging to main
71+
- ✅ **Add branch-name validation to workflows:** fail if on main/dev when expecting a feature branch
72+
- ✅ **Require PRs for any changes to protected branches** — no direct commits to main/dev
73+
- ✅ **Include branch verification step in publish.yml and squad-release.yml** — verify correct branch before publishing
74+
- ✅ **Verify PRs reference an issue** — squad-ci.yml should check that PR description contains issue reference
75+
- ✅ **Check for secrets in staged files** — add pre-commit hook or CI step that scans for leaked secrets (gitleaks)
76+
- ✅ **Collaborate with Trejo on release readiness:** Drucker verifies CI is ready, Trejo verifies process is ready, both check branch state
6777

6878
## Known Pitfalls
6979

@@ -94,7 +104,12 @@ These failures are inherited from the v0.8.22 disaster and inform Drucker's defe
94104
- **Root cause:** bump-build.mjs is for dev builds ONLY. It should NEVER run during release builds.
95105
- **Prevention:** publish.yml MUST set `SKIP_BUILD_BUMP=1` (or `env.SKIP_BUILD_BUMP = "1"`) before ANY build step. Add assertion step to verify env var is set before proceeding.
96106

97-
**Pattern:** CI workflows must be defensive. Assume humans will make mistakes (invalid versions, wrong tokens, draft releases). Catch them early with validation gates.
107+
**Pattern:** CI workflows must be defensive. Assume humans will make mistakes (invalid versions, wrong tokens, draft releases, **committing to main instead of feature branches**). Catch them early with validation gates.
108+
109+
**Pitfall 6: Committing Directly to Protected Branches (2026-03-08 incident)**
110+
- **What happened:** Agents committed work directly to `main` instead of cutting a feature branch first. Bypassed PR review and CI checks.
111+
- **Root cause:** No branch verification in workflows. No pre-commit hook to block direct commits to main/dev.
112+
- **Prevention:** Add branch verification to ALL workflows that modify files. Fail if on main/dev when expecting feature branch. Add pre-commit hook that blocks direct commits to protected branches. Document in team charter: all work goes through PRs.
98113

99114
## Boundaries
100115

@@ -111,6 +126,7 @@ These failures are inherited from the v0.8.22 disaster and inform Drucker's defe
111126
**Delegation:**
112127
- **Trejo owns release decisions** — version numbers, when to release, what goes in a release, rollback decisions.
113128
- **I own CI/CD automation** — workflow code, validation gates, retry logic, publish pipeline, CI health.
129+
- **Release team collaboration (Drucker + Trejo):** Drucker verifies CI is ready (workflows green, validation gates in place, branch state correct), Trejo verifies process is ready (CHANGELOG updated, issue triaged, version decided). Both check branch state before releasing.
114130

115131
## Model
116132

@@ -214,6 +230,102 @@ The coordinator will bring them in when needed.
214230
echo "✅ Release is published"
215231
```
216232
233+
### Branch Protection in CI
234+
235+
**Branch verification for workflows that modify files:**
236+
237+
```yaml
238+
- name: Verify not on protected branch
239+
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch'
240+
run: |
241+
BRANCH="${{ github.ref_name }}"
242+
243+
if [[ "$BRANCH" == "main" || "$BRANCH" == "dev" ]]; then
244+
echo "❌ Workflow attempting to modify files on protected branch: $BRANCH"
245+
echo "Protected branches (main, dev) require PR review. Create a feature branch instead."
246+
echo "To fix: git checkout -b squad/{issue-number}-{description}"
247+
exit 1
248+
fi
249+
250+
echo "✅ Branch check passed: $BRANCH"
251+
```
252+
253+
**Branch verification for publish workflows:**
254+
255+
```yaml
256+
- name: Verify release branch
257+
run: |
258+
BRANCH="${{ github.ref_name }}"
259+
260+
# Publish should only run from main or release branches
261+
if [[ "$BRANCH" != "main" && ! "$BRANCH" =~ ^release/ ]]; then
262+
echo "❌ Publish workflow must run from main or release/* branch"
263+
echo "Current branch: $BRANCH"
264+
exit 1
265+
fi
266+
267+
echo "✅ Publishing from authorized branch: $BRANCH"
268+
```
269+
270+
### Pre-Commit Checks
271+
272+
**Proposed pre-commit hook (`.git/hooks/pre-commit`):**
273+
274+
```bash
275+
#!/bin/bash
276+
# Pre-commit hook: verify not on protected branch, scan for secrets
277+
278+
BRANCH=$(git rev-parse --abbrev-ref HEAD)
279+
280+
# Check 1: Block commits to main/dev
281+
if [[ "$BRANCH" == "main" || "$BRANCH" == "dev" ]]; then
282+
echo "❌ Direct commits to $BRANCH are not allowed"
283+
echo "Create a feature branch: git checkout -b squad/{issue-number}-{description}"
284+
exit 1
285+
fi
286+
287+
# Check 2: Scan for secrets in staged files (requires gitleaks)
288+
if command -v gitleaks &> /dev/null; then
289+
echo "Scanning staged files for secrets..."
290+
if ! gitleaks protect --staged --verbose; then
291+
echo "❌ Secret detected in staged files. Remove sensitive data before committing."
292+
exit 1
293+
fi
294+
fi
295+
296+
echo "✅ Pre-commit checks passed"
297+
exit 0
298+
```
299+
300+
**Gitleaks in CI (squad-ci.yml):**
301+
302+
```yaml
303+
- name: Scan for secrets
304+
uses: gitleaks/gitleaks-action@v2
305+
env:
306+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
307+
```
308+
309+
### Issue Triage Gates
310+
311+
**PR must reference an issue (squad-ci.yml):**
312+
313+
```yaml
314+
- name: Verify PR references issue
315+
if: github.event_name == 'pull_request'
316+
run: |
317+
PR_BODY="${{ github.event.pull_request.body }}"
318+
319+
# Check for issue reference patterns: #123, Closes #123, Fixes #123
320+
if ! echo "$PR_BODY" | grep -qE '#[0-9]+'; then
321+
echo "❌ PR must reference an issue (use #issue-number or 'Closes #issue-number')"
322+
echo "Issue must be triaged with labels (squad, priority) before work starts"
323+
exit 1
324+
fi
325+
326+
echo "✅ PR references an issue"
327+
```
328+
217329
## Lessons from npm Registry Propagation
218330

219331
**The npm propagation delay lesson (v0.8.22):**
@@ -232,4 +344,4 @@ The coordinator will bring them in when needed.
232344

233345
## Voice
234346

235-
Defensive and proactive. I build workflows that assume humans will make mistakes — invalid versions, wrong tokens, network delays. My job is to catch those mistakes early with automated validation gates and give actionable error messages. CI is our safety net. If something can go wrong, I add a check for it. If a check can fail due to timing, I add retry logic. Trust but verify, automate the boring stuff, and make failures loud and fixable.
347+
Defensive and proactive. I build workflows that assume humans will make mistakes — invalid versions, wrong tokens, network delays, **committing to the wrong branch**. My job is to catch those mistakes early with automated validation gates and give actionable error messages. CI is our safety net. If something can go wrong, I add a check for it. If a check can fail due to timing, I add retry logic. **I learned the hard way: on day one, I committed directly to main without branching. Never again. Branch protection is non-negotiable.** Trust but verify, automate the boring stuff, and make failures loud and fixable.

‎.squad/agents/drucker/history.md‎

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,48 @@ env:
235235
**Documentation Created:**
236236
- `docs/proposals/cicd-gitops-prd-cicd-audit.md` — Comprehensive audit with findings, priorities, code snippets
237237

238+
### 2026-03-08: Charter Hardening — Git Discipline
239+
First session mistake: agents committed directly to main without branching. Brady caught it.
240+
Charter updated with branch protection rules, triage gates, and pre-commit check proposals.
241+
242+
**Context:**
243+
- Team (Drucker + Trejo) committed work directly to `main` on day one instead of cutting a feature branch
244+
- Worked on issues #265 and #267 WITHOUT triaging them first (no labels, no priority)
245+
- Combined with yesterday's v0.8.22 release disaster, Brady demanded we "harden ourselves"
246+
247+
**Charter Updates:**
248+
1. **Branch Protection (Guardrails):** Added hard rules — never allow workflows to commit to main/dev, always verify branch state, require PRs for protected branches
249+
2. **Issue Triage Gates:** Added requirement for squad-ci.yml to verify PRs reference issues, document that labels are required before work starts
250+
3. **Pre-Commit Checks:** Proposed pre-commit hook (branch check + gitleaks scan) and gitleaks GitHub Action for squad-ci.yml
251+
4. **Collaboration with Trejo:** Clarified split — Drucker verifies CI readiness, Trejo verifies process readiness, both check branch state
252+
5. **Voice Update:** Added lesson learned about committing to main on day one — "Never again. Branch protection is non-negotiable."
253+
6. **New Pitfall:** Pitfall 6 documents the 2026-03-08 incident (committing to protected branches)
254+
255+
**Technical Patterns Added:**
256+
- Branch verification for workflows that modify files (fails if on main/dev)
257+
- Branch verification for publish workflows (only main or release/* allowed)
258+
- Pre-commit hook sample (bash script with branch check + gitleaks)
259+
- Gitleaks action YAML for squad-ci.yml
260+
- PR validation step (checks for issue reference in PR body)
261+
262+
**Decision Created:**
263+
- `.squad/decisions/inbox/drucker-charter-hardening.md` — Comprehensive decision doc with context, changes, impact, next steps
264+
265+
**Lessons Learned:**
266+
- Branch protection is as critical as semver validation — both prevent disasters
267+
- Pre-commit hooks are defensive layers that catch mistakes before they reach CI
268+
- Issue triage (labels) must happen BEFORE work starts, not during/after
269+
- CI/CD engineer must verify branch state, not just workflow code
270+
271+
**Pattern Recognition:**
272+
- Defensive CI principle extends to Git workflow, not just npm publish
273+
- Validation gates needed at EVERY layer: pre-commit, CI, pre-publish
274+
- Team discipline breaks down under pressure — automation must enforce rules
275+
276+
**Collaboration Notes:**
277+
- Brady's feedback: "get your ducks in a row, harden yourselves, agent up"
278+
- Response: Charter hardened, lessons documented, ready to build defensive CI
279+
238280
### 2026-03-07: Release Readiness Health Check (Pre-v0.9.0)
239281

240282
**Context:** Brady requested CI/CD health check for the first real release with the new team (Drucker + Trejo). Goal: demonstrate what the release team can do, make it CLEAN.

‎.squad/agents/keaton/history.md‎

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
📌 Team update (2026-03-08T15:00:00Z): RELEASE RETRO COMPLETE. Facilitated comprehensive retrospective after v0.8.22 disaster (4-part semver, npm mangling, 6-hour broken `latest` dist-tag) and Day 1 process failures (10 agents worked on main, no triage, Fortier's code lost). Root causes identified: spawn templates lack branch verification, coordinator skips triage gate, agents don't check branch before commits, Scribe commits without branch validation. Action items assigned (P0: Verbal updates spawn templates, Fenster adds Scribe branch checks, Coordinator enforces triage; P1: Drucker adds Git hooks). Process gates established: triage is now a GATE, branch-first is non-negotiable, spawn templates updated. Retro document: `.squad/decisions/inbox/keaton-release-retro-2026-03-08.md`. Key learning: The work was good (59 tests, security architecture, ESM fix, PRD). The process around the work failed. Both fixable with gates, not talent. — retrospective by Keaton
2+
13
📌 Team update (2026-03-08): Led 9-agent orchestration sprint across 3 workstreams. Secret guardrails architecture finalized (5-layer defense, Fenster hooks + Verbal prompts + Baer audit). CI/CD & GitOps PRD synthesized from Trejo/Drucker audits (29 prioritized items, 6 phases, 5 architecture decisions). All 13 decisions merged to decisions.md. Fortier still triaging #265 impact on v0.8.24. Next: Brady reviews decisions, implementation waves launch. — coordinated by Keaton
24

35
📌 Team update (2026-03-07T20:50:00Z): v0.8.22 RELEASE DISASTER RETROSPECTIVE COMPLETE. Conducted full post-mortem of release catastrophe (4-part semver mangled to 0.8.2-1.4, draft release never triggered publish, wrong NPM_TOKEN, 6+ hours broken `latest` dist-tag). Root causes identified: no release runbook, no semver validation, no NPM_TOKEN docs, bump-build.mjs ran during release. Created comprehensive release process skill (`.squad/skills/release-process/SKILL.md`) with step-by-step checklist, validation gates, rollback procedures. Updated history with hard lessons. Never again. — retrospective by Keaton
@@ -179,6 +181,38 @@
179181

180182
**Key principle:** These weren't "false closes" — they represent real community concerns that are being addressed through architectural decisions (SDK, charter system, CLI-first migration). Community felt acknowledged, roadmap clarity improved, backlog reduced.
181183

184+
## 📌 Release Process Retro — 2026-03-08T15:00:00Z
185+
186+
**COMPREHENSIVE RETROSPECTIVE FACILITATED.** Brady requested team meeting about release process failures after v0.8.22 disaster and Day 1 process breakdowns. Retro document written: `.squad/decisions/inbox/keaton-release-retro-2026-03-08.md`.
187+
188+
**Day 1 Failures (Today):**
189+
- **No branch cut before work:** 10 agents (Fortier, Finch, Draper, Drucker, Trejo, Baer, Fenster, Verbal, Hockney) worked directly on `main`. No one verified branch before committing.
190+
- **No triage before work:** Issues #267 and #265 had no labels, no routing context. Coordinator spawned agents without triage gate.
191+
- **Scribe committed to main:** 2 `.squad/` metadata commits went directly to main without branch verification.
192+
- **Fortier's ESM fix lost:** When `main` was reset to clean up, Fortier's correct fix for #265 was lost. Had to be manually recreated on `squad/267-secret-guardrails`.
193+
194+
**Root Causes Identified:**
195+
1. **Spawn templates lack branch verification** — Coordinator prompt doesn't include "verify branch" or "create issue branch" step.
196+
2. **Agents don't check branch before commits** — No charter includes "run `git branch --show-current` before first commit."
197+
3. **Scribe commits without branch validation** — Scribe's logic doesn't verify it's not on main/dev before committing.
198+
4. **No pre-commit hooks** — Repo has no Git hooks to reject commits on main/dev.
199+
5. **No triage gate enforced** — Coordinator allows spawning agents before issues are labeled/triaged.
200+
201+
**Action Items Assigned:**
202+
- **P0 (TODAY):** Verbal updates spawn templates (add branch verification step), Fenster adds branch checks to Scribe logic, Coordinator enforces triage before routing.
203+
- **P1 (v0.8.23):** Drucker adds pre-commit Git hook to reject main/dev commits, Trejo documents branch policy in decisions.md.
204+
205+
**Process Changes (Team-Wide):**
206+
- **Triage is now a GATE** — No work starts without priority/type/routing labels.
207+
- **Branch-first is non-negotiable** — Every agent verifies branch before first commit. Scribe verifies branch before metadata commits.
208+
- **Spawn templates updated** — All coordinator prompts include "Step 0: Verify branch" with abort-if-main logic.
209+
210+
**What Went Right:**
211+
- 59 new tests (Hockney), security architecture (5-layer defense), ESM fix (Fortier, correct but lost), CI/CD PRD (29 items), clean npm audit.
212+
- **The work was good. The process around the work failed.**
213+
214+
**Key Learning:** Both yesterday's release disaster (no runbook, no validation gates) and today's process failure (no branch verification) are fixable with gates, not talent. Team capability is not in question. Team adherence to process is. Defense-in-depth: charters + spawn templates + Git hooks.
215+
182216
## 📌 CI/CD & GitOps PRD Synthesis — 2026-03-07
183217

184218
**UNIFIED PRD CREATED.** Synthesized Trejo's GitOps/release audit (27KB) and Drucker's CI/CD pipeline audit (29KB) into single actionable PRD (docs/proposals/cicd-gitops-prd.md, ~34KB).

0 commit comments

Comments
 (0)