conductor(tier-setup): MANDATORY pre-action reading + pre-commit abort on leak

ROOT CAUSE (post-mortem at docs/reports/TIER2_MCP_REGRESSION_20260624.md):
- Tier 1 asserted claims from old reports without re-verifying (SSDL campaign
  was designed from a static text string '6 nil-check functions' in
  src/code_path_audit_gen.py:108 that was never a runtime measurement)
- Tier 2 (autonomous) made an empty fix commit (2b7e2de1) for the MCP
  regression; the pre-commit hook silently stripped opencode.json +
  mcp_paths.toml and the agent reported success without verifying with
  'git show HEAD --stat'
- Both happened because neither tier read the critical files before acting

THE FIX (this commit):

1. .agents/agents/tier1-orchestrator.md: add MANDATORY pre-action reading
   list (6 files: AGENTS.md, conductor/workflow.md, current track spec/plan,
   the 3 code_styleguides). Reference the 2026-06-24 SSDL failures.

2. .agents/agents/tier2-tech-lead.md: add MANDATORY pre-action reading list
   (8 files: AGENTS.md, workflow.md, edit_workflow.md, the githooks
   forbidden-files.txt, the tier2_leak_prevention spec, the 3 styleguides)
   + the MANDATORY pre-commit verification gate (3 checks per commit).

3. .agents/agents/tier3-worker.md: add 4-file read list (AGENTS.md, task
   spec, relevant styleguide, the actual code being modified). Tier 3 doesn't
   need the full 8-file list — Tier 2's task spec is the contract.

4. .agents/agents/tier4-qa.md: same 4-file read list (analysis context).

5. conductor/tier2/agents/tier2-autonomous.md: add the 8-file MANDATORY
   pre-action reading list + the MANDATORY pre-commit verification gate.

6. conductor/tier2/commands/tier-2-auto-execute.md: add the 8-file list
   to the pre-flight section (step 0).

7. conductor/tier2/githooks/pre-commit: change behavior from 'silent strip
   + commit anyway' to 'strip + ABORT commit with diagnostic message'.
   The previous behavior led to empty commits (the 2026-06-24 regression).
   The agent MUST investigate the leak before retrying the commit.

ENFORCEMENT (all tiers):
- First commit of any track must include 'TIER-N READ <list> before <task>'
  in the commit message. The failcount contract treats an unacknowledged
  first commit as a red-phase failure (per the error_handling.md Rule #0
  precedent).

NOT IN THIS COMMIT (deferred to followup tracks per the post-mortem):
- Rule 4 (CI gate for required files via scripts/audit_branch_required_files.py)
- AGENTS.md addition of the canonical 'MANDATORY Pre-Action Reading' section
  (separate track to ensure the project-root rules reflect the same list)
- Cross-platform agent files (.opencode/, .claude/, .gemini/) — those are
  generated from the canonical .agents/agents/ files; this commit updates
  the canonical sources.

7 files modified, 109 insertions, 6 deletions.
This commit is contained in:
ed
2026-06-24 21:36:18 -04:00
parent 6ab637dfe3
commit eae758771f
7 changed files with 109 additions and 6 deletions
@@ -25,6 +25,31 @@ STRICT SYSTEM DIRECTIVE: You are a Tier 2 Tech Lead in AUTONOMOUS mode.
You are running inside a Windows restricted token. The OpenCode permission system, the Windows ACL subsystem, and the git hooks in the clone are all enforcing the hard-ban list. A bypass of one layer is caught by another.
## MANDATORY: Pre-Action Required Reading (added 2026-06-24 post-MCP-regression)
Before ANY action (reading files, writing files, running commands, planning, executing, committing), the agent MUST read these 8 files IN ORDER. Skipping any is grounds for aborting the work. This list exists because the 2026-06-24 MCP regression: Tier 2 made an empty fix commit, deleted `opencode.json` + `mcp_paths.toml`, and reported success without verifying — all because it did not read the prior `tier2_leak_prevention_20260620` track's spec.
1. `AGENTS.md` (project root) — the project operating rules + critical anti-patterns
2. `conductor/workflow.md` — the operational workflow + tier-specific conventions (TDD, per-task commits, failcount)
3. `conductor/edit_workflow.md` — the edit tool contract (MUST use `manual-slop_edit_file`, NEVER native `Edit`)
4. `conductor/tier2/githooks/forbidden-files.txt` — the file denylist (`opencode.json`, `mcp_paths.toml`, etc.)
5. `conductor/tracks/tier2_leak_prevention_20260620/spec.md` — the prior leak incident + 3-layer defense (DO NOT REPEAT IT)
6. `conductor/code_styleguides/data_oriented_design.md` — canonical DOD reference
7. `conductor/code_styleguides/error_handling.md` — the `Result[T]` convention (Rule #0: "READ THIS STYLEGUIDE FIRST")
8. `conductor/code_styleguides/type_aliases.md` — the 10 TypeAliases
**Enforcement:** the agent's first action in any new track must be to read all 8 files and acknowledge them in the commit message of the first commit (format: "TIER-2 READ <list> before <task>"). The failcount contract treats an unacknowledged first commit as a red-phase failure.
## MANDATORY: Pre-Commit Verification Gate (added 2026-06-24)
Before EVERY `git commit`, the agent MUST run all 3 of these checks:
1. `git diff --cached --stat` — review for deletions (`-N` lines). If any file shows `-N`, ABORT the commit. Investigate whether the deletion is intentional work or a sandbox file leak.
2. `uv run python scripts/audit_tier2_leaks.py --strict` — must exit 0. If it exits 1, the pre-commit hook should have caught the leak; investigate why it didn't.
3. After `git commit`, run `git show HEAD --stat` and confirm the diff is non-empty AND matches your intended changes. **If the diff is empty, the sandbox hook silently stripped your commit — treat this as a HARD ERROR.** Investigate and re-commit correctly. Do NOT report success on an empty commit.
This gate catches the failure mode in the 2026-06-24 MCP regression where Tier 2 made an empty fix commit (`2b7e2de1`) and reported success without verifying.
## Hard Bans (cannot run, enforced at 3 layers)
- `git push*` (any push) - the user pushes the branch after review
@@ -14,6 +14,18 @@ Optional flags: `--resume` (continue from last completed task), `--toast` (Windo
## Pre-flight
0. **MANDATORY: Read these 8 files IN ORDER before any other action** (added 2026-06-24 post-MCP-regression):
1. `AGENTS.md` (project root) — operating rules
1. `conductor/workflow.md` — workflow + tier conventions
1. `conductor/edit_workflow.md` — edit tool contract
1. `conductor/tier2/githooks/forbidden-files.txt` — file denylist
1. `conductor/tracks/tier2_leak_prevention_20260620/spec.md` — prior leak incident (DO NOT REPEAT)
1. `conductor/code_styleguides/data_oriented_design.md` — canonical DOD
1. `conductor/code_styleguides/error_handling.md``Result[T]` convention
1. `conductor/code_styleguides/type_aliases.md` — the 10 TypeAliases
The first commit of the track must include "TIER-2 READ <list> before <task>" in the commit message. The failcount contract treats an unacknowledged first commit as a red-phase failure.
1. **Verify sandbox is active.** This slash command must be invoked from a sandboxed OpenCode session. If `manual-slop_get_ui_performance` returns an error or the run_tier2_sandboxed.ps1 wrapper is not in the parent process, refuse to start.
2. **Load the track spec.** Read `conductor/tracks/<track-name>/spec.md` and `plan.md` from the current branch. If the track does not exist, abort.
3. **Check for a previous run.** If `tests/artifacts/tier2_state/<track-name>/state.json` exists AND `--resume` is NOT set, abort with: "Previous run found for this track. Use `--resume` to continue, or delete the state file to start fresh."
+17 -6
View File
@@ -73,11 +73,13 @@ if [ ! -s "$TMPFILE" ]; then
exit 0
fi
echo "Tier 2: removing sandbox-only files from staging" >&2
echo "(these files belong in the main repo, not in tier-2 commits):" >&2
# Auto-unstages the leak. Then ABORTS the commit so the agent MUST investigate
# before retrying. The previous behavior (silent strip + commit) led to the
# 2026-06-24 MCP regression where Tier 2 made an empty fix commit (2b7e2de1)
# and reported success without verifying.
while IFS= read -r f; do
[ -z "$f" ] && continue
echo " - $f" >&2
echo " - unstaging: $f" >&2
# `git rm --cached` works on tracked files (unstages modifications)
# AND on newly-added files (unstages the addition, file becomes
# untracked again). NOT `git restore` (banned in sandbox).
@@ -90,7 +92,16 @@ while IFS= read -r f; do
done < "$TMPFILE"
echo "" >&2
echo "Commit will proceed without these files. To inspect what was" >&2
echo "removed, run: git status" >&2
echo "Tier 2: COMMIT ABORTED — sandbox file leak detected." >&2
echo "" >&2
echo "The pre-commit hook auto-unstaged the leaked files (see list above)," >&2
echo "but the commit is aborted to prevent the 2026-06-24 empty-commit" >&2
echo "regression. Investigate why these files were staged:" >&2
echo " (1) Did you accidentally run \`git add .\`? Use \`git add <specific_files>\`" >&2
echo " (2) Did the files leak from setup_tier2_clone.ps1? Check \`git status\`." >&2
echo " (3) Are the files intentionally part of your work? Re-stage them with" >&2
echo " \`git add <path>\` after confirming they're NOT in forbidden-files.txt." >&2
echo "" >&2
echo "Re-attempt the commit after resolving the leak." >&2
exit 0
exit 1