refactor(harness): refit — cut always-loaded context 23%, resolve 7 contradictions, add client boundary guard - #9
Merged
Conversation
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
…ontradictions, add client boundary guard CLAUDE.md becomes a router: 10,390 -> 5,316 B (-49%). Team Structure was restating agent frontmatter that is already always-loaded (median 67% keyword overlap, 100% for backend-developer and innovation-lead); replaced with a council->slug routing table plus a Traps section covering what the file tree cannot show. Always-loaded surface 22,512 -> 17,438 B. Contradictions resolved: - PR ownership had three conflicting owners and the named one disclaimed the job. Now: developers open their own PRs, github-vc-specialist advises and never opens or merges, merging is a human decision. 10 restatements collapsed. - Council count said three in five files while four councils existed. - Deleted the stale .gemini mirror (15 of 25 agents, 2 orphans, divergent gate list), GEMINI.md and .geminiignore. - Removed the dead .pm session marker nothing read, and the dead .claude/active-client path pm.md still pointed at. Adds .claude/hooks/client-boundary-guard.sh as a PreToolUse guard on Write|Edit|NotebookEdit. Exits 2 on cross-client writes; fails open when no session lock is set. bash 3.2 safe, no set -u/-e. 23 test cases pass in both directions including two path-traversal escapes. Baseline, measurement commands and rationale in docs/refit-2026-08-10.md. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
- Add the PreToolUse client boundary guard to How It Works: it blocks cross-client writes (including ../ traversal) rather than relying on the agent to remember the rule, and is inactive without a session lock. - Add a Version control ownership note: developers open their own PRs, the GitHub & VC Specialist advises but never opens or merges, merging is a human decision. This rule had no home in the README before. - Mark GitHub & VC Specialist advisory in the roster table. - Update the directory tree: hooks now include the guard, CLAUDE.md is a routing table rather than a full operating model, docs/ holds refit records. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The pii-check workflow blocks any literal /Users/ path or username in a committed file. The transcript-dir measurement command embedded both. Derive the directory from cwd instead, which is PII-free and makes the command re-runnable in any checkout rather than only on one machine. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refit pass over the harness: remove scaffolding that costs baseline tokens or forces the model to reconcile contradictory instructions. Every number below was computed, not estimated. Full baseline, measurement commands, and rationale in
docs/refit-2026-08-10.md.Measured result
83 insertions, 1,748 deletions, 27 files removed.
The main cut
## Team Structurewas 30% of CLAUDE.md restating agent descriptions that are already always-loaded as frontmatter — measured median 67% keyword overlap, 100% forbackend-developerandinnovation-lead, 93–94% for the apple/blockchain/llm trio. A straight double charge.Replaced with a council→slug routing table (council membership is the one thing frontmatter genuinely lacks) plus a Traps section spending the reclaimed budget on what the file tree cannot show: no-lock disables scoping, a missing
.envsilently redirectsSOURCE_ROOT_BASEto the harness's parent directory, sprint files never live inspecs/,CURRENTis a symlink not a copy.Contradictions resolved (7)
backend/frontendnamed Account Lead or Architect;apple/blockchain/llmnamed the GitHub & VC Specialist; that agent's own file called PRs "the developer's responsibility". The named owner disclaimed the job. → Developers open their own PRs, VC Specialist advises and never opens or merges, merging is a human decision. Stated once, 10 restatements collapsed.docs/onboarding.mdomitted the Hardware Council entirely.tech-writer..gemini/was a stale mirror — 15 of 25 agents, missing every Hardware Council role,blockchain-engineerat 1,187 B vs 6,306 B, 2 orphan agents in no roster. Deleted withGEMINI.mdand.geminiignore.settings.jsonwrote.claude/sessions/<id>.pm; the reader hook reads.pm-mode. Nothing ever read.pm— a silent no-op on every/pm.pm.mdpointed at.claude/active-client, a file nothing writes, still allow-listed in settings.New mechanism: client boundary guard
The client workspace boundary was prose-only while
settings.jsonallowedWrite(clients/**)wholesale..claude/hooks/client-boundary-guard.shis aPreToolUseguard onWrite|Edit|NotebookEditthat exits 2 — the only code that blocks — on cross-client writes.Fails open by design when no session lock is set: a session that has not run
/use-clienthas no declared client, so there is no boundary to cross. Documented in CLAUDE.md § Traps.Written for bash 3.2 with no
set -u/set -e— an aborted PreToolUse hook reads as allow, so it must never abort early.23 test cases, both directions, all passing. Allow: same-client relative/absolute, outside
clients/,clients/root files, no lock, emptysession_id, non-path tools, sibling source repos, malformed JSON, empty stdin, nulltool_input. Block: other client relative/absolute, deep project paths,notebook_path, and two path-traversal escapes (clients/<active>/../<other>/...andpatterns/../clients/<other>/...).Not done
NEVERs in the apple/blockchain/llm/backend/frontend agents kept — hard-won knowledge, not backseat driving. Only the PR-ownership lines went..env.template:52still setsDEFAULT_MODEL=gemini-2.0-flashandsetup.sh:97prompts for a Gemini key. Possibly dead now, butGOOGLE_API_KEYmay serve client work and a default-model change is behavior-changing. Flagged, not changed.Caveat
n=1. The only transcript for this project directory is the session that ran the refit — no usage history, zero recorded subagent spawns or command invocations. Dormant-capability analysis was impossible, so nothing was retired on usage grounds. No capability-generation reference was consulted; every cut is justified by evidence internal to this harness, not by claims about what this model generation can infer.🤖 Generated with Claude Code