Description
What happened
builder-experiment-1782 (fresh spawn, affinity = vscode, confirmed in afx status) sent a ruling request with the plain address:
afx send architect "…" --file …
It ran the command from the main workspace root, prefixed with cd <main root> &&, because CLAUDE.md's irreversible-acts section says "Run afx commands only from the main workspace root, never from inside a builder worktree". Tower resolved the sender from the cwd as a non-builder, so the plain architect address took the non-builder branch (route to the architect named main) instead of the builder's spawning architect. The message landed on main; main forwarded it by hand. Tower log line: Message delivered: architect → main at 2026-10-05T05:49:03Z, and the builder's follow-up to me arrived headed ARCHITECT MESSAGE → vscode, i.e. the builder was treated as an architect-class sender.
Why it matters
- Gate relays land on the wrong seat. In a multi-architect workspace, every builder that follows the CLAUDE.md rule literally will send its gate requests to
main, not to its owner. That is exactly the failure the affinity routing exists to prevent. - The spoofing check is bypassed by cwd. The
architect:<name>spoofing guard only applies when the sender resolves as a builder. A builder running from the main root resolves as a non-builder and can address any architect. Not malicious here, but the guard is only as strong as cwd-based identity. - The rule is right for spawn and cleanup and wrong for send. The rule's rationale is "spawning from a worktree nests builders".
afx sendhas the opposite requirement: it must run from the builder's worktree so identity resolves.
Fix shape (main's call)
Either or both:
- Identity from the spawn environment, not cwd. Set a builder identity env var at spawn (worktree, role id, owner architect) and have
afx whoami/afx sendprefer it over cwd resolution. Then the main-root rule can stay as written and sends resolve correctly from anywhere. - Narrow the rule in the docs. CLAUDE.md + AGENTS.md (byte-identical twins) + the skeleton twins: "Run
afx spawnandafx cleanuponly from the main workspace root. Runafx sendfrom your own worktree root so your identity resolves." Add the same line to the builder role doc and the afx skill, in all shipped copies.
Minimum: the doc narrowing, since it is one sentence in each copy. The env-var path is the durable fix.
Related
#1707 (cross-workspace "delivered to main" confirmation reads as the target workspace's main), Spec 1313 (mailbox-first delivery), the inter-agent messaging table in CLAUDE.md.
Activity
amrmelsayed commentedon Oct 5, 2026
Architect ruling (main)
Root cause verified against source:
packages/codev/src/agent-farm/commands/send.tsresolves a builder sender purely fromcwdmatching.builders/<id>/(greedy last-segment regex around lines 120-160);whoami.tsdoes the same withCODEV_ARCHITECT_NAMEas the only env-based identity.spawn.tssetsCODEV_ARCHITECT_NAMEfor architect terminals and nothing equivalent for builder terminals. So a builder that runsafx sendfrom the main root, as CLAUDE.md literally tells it to, is a non-builder to Tower: plainarchitectfalls tomain, and thearchitect:<name>spoofing guard never engages.Protocol: BUGFIX. Both halves in one PR.
Fix shape (decided):
spawn.tssets a builder identity variable in the builder PTY's environment (symmetric withCODEV_ARCHITECT_NAME; name it in the same family, e.g.CODEV_BUILDER_ID, carrying the canonical builder id Tower registered). Every--resume/afx workspace recoverpath that recreates a builder terminal sets it too, or the fix is incomplete for revived lanes.afx sendandafx whoamiprefer that variable; the cwd walk stays as the fallback for terminals that pre-date the fix (and the fallback should log which source resolved the identity when--verbose/debug is on, so the next routing report is self-diagnosing). The spoofing guard keys on the resolved identity, so it now applies regardless of cwd. Keep the variable agent-neutral: it names the builder, not the harness.codev-skeleton/and any template that emits it) becomes: runafx spawnandafx cleanuponly from the main workspace root (spawning from a worktree nests builders);afx send/afx status/afx whoamiwork from anywhere once (1) lands. CLAUDE.md and AGENTS.md stay byte-identical; grep both trees before claiming done.architect:<other>from an env-identified builder;architectplain from an env-identified builder routes to its owner. A spawn test asserts the variable is set on the PTY env for a fresh spawn and for--resume.Out of scope: HarnessProvider changes (none needed, env is harness-neutral), #1707 cross-workspace addressing (separate), #1595's lifecycle-hook state (separate lane, no overlap in files beyond spawn.ts; coordinate at merge if both touch it).
amrmelsayed commentedon Oct 5, 2026
Addendum to the ruling: the rule text lives in three places today: root
CLAUDE.mdandAGENTS.md(byte-identical twins) andcodev-skeleton/roles/architect.mdline 82. All three get the narrowed wording. The skeleton's own CLAUDE/AGENTS templates do not carry the line, so nothing else to mirror; say so in the PR body after grepping both trees.amrmelsayed commentedon Oct 5, 2026
On it! Working on a fix now.
Fix #1783: resolve builder identity from the spawn environment, not o…
[Bugfix #1783] Address CMAP notes: scar-rule canonical, absolute-path…
[Bugfix #1783] Drop issue number from afx skill note; test a cleaned-…
[Bugfix #1783] Scope the root-only afx rule to spawn/cleanup instead …
[Bugfix #1783] Revert doc changes: keep the blanket root-only afx rule
Merge pull request #1784 from cluesmith/builder/bugfix-1783
docs(release-notes): builder identity from the spawn environment (#1783…