Skip to content

[Spec 1134] afx whoami + ship /arch-init command (multi-architect identity)#1136

Open
waleedkadous wants to merge 29 commits into
mainfrom
builder/spir-1134
Open

[Spec 1134] afx whoami + ship /arch-init command (multi-architect identity)#1136
waleedkadous wants to merge 29 commits into
mainfrom
builder/spir-1134

Conversation

@waleedkadous

Copy link
Copy Markdown
Contributor

Summary

Adds afx whoami — a fail-loud identity diagnostic reporting the current terminal's agent (workspace, type, name) from Tower/global.db's perspective — and ships the /arch-init architect identity-adoption command with codev via the skeleton, replacing the fragile personal ps -p $PPID ancestry-matching command.

Closes #1134

Changes

Testing

  • 20 new whoami unit tests (spec scenarios 1–8, 10, 11 + JSON shapes, fixture pattern from bugfix-774)
  • Skill-text assertion tests (cross-tree byte equality, required/forbidden content) + first-ever copySkills() regression tests (install path for scenario 9)
  • Full unit suite green: 3470 passed / 48 pre-existing skips
  • Manual smokes: afx whoami from this builder worktree → builder-spir-1134 + architect: main; from /tmp → exit 1 fail-loud; /arch-init skill confirmed loading in Claude Code
  • CMAP: all three implement phases unanimously approved (Gemini/Codex/Claude)

Spec

Link: codev/specs/1134-afx-whoami-ship-arch-init-comm.md

Review

Link: codev/reviews/1134-afx-whoami-ship-arch-init-comm.md

…nostic

Resolves identity per spec precedence (builder-worktree cwd match via
detectCurrentBuilderId -> CODEV_ARCHITECT_NAME -> fail loud, exit 1; no
implicit 'main'). Strictly read-only against global.db:
lookupBuilderSpawningArchitect gains an optional db handle so whoami can
pass its readonly connection. Workspace display name from known_workspaces
with basename fallback; best-effort architect-row cross-check warns on
stderr only. --json emits the documented schema, and failure emits
{ "error": ... } on stdout alongside the stderr explanation.
…th trees

Workspace-agnostic identity-adoption command for architect terminals:
explicit [name] argument (validated against the architect-name rule,
path-traversal guarded) or afx whoami resolution; STOP-and-ask when
neither resolves — never guess, never default to main. Reads
codev/state/<name>.md; missing-file flow excludes builder *_thread.md
files. Byte-identical in codev-skeleton/ and .claude/skills/ with a
drift-guard test, plus first copySkills() regression tests proving the
init/adopt/update install path.
…nce and afx skill

Adds the whoami section (syntax, precedence, output examples, --json,
exit codes) to agent-farm.md and the afx SKILL.md in BOTH trees, with
identical section content. Drive-by: three stale 'state.db' wordings in
send.ts user-facing/doc text now say global.db (post-#1118); historical
'state.db is retired' migration comments left as-is.
@waleedkadous

Copy link
Copy Markdown
Contributor Author

Architect Integration Review

Excellent work — this is a clean, well-composed change. Independent integration review (Claude): APPROVE / HIGH confidence, no key issues, on top of the unanimous CMAP at every phase.

Highlights from the integration pass:

  • Backward compatibility verified: all 8 existing callers of lookupBuilderSpawningArchitect (2 production in tower-messages.ts, 6 in tests) use 1–2 args — the optional db? param is fully additive.
  • Resource lifecycle correct: the read-only db handle closes on every return path; the BuilderIdResolutionError path never opens it at all.
  • Fail-loud semantics preserved end-to-end: no fallthrough from a builder worktree to the env check (afx send: detectCurrentBuilderId silently falls back to bare worktree name on state.db read failure → builder messages misroute to main #1094 rule), no implicit main anywhere.
  • The copySkills() regression tests are a gift beyond scope — first coverage for the whole skill-delivery pipeline, and the skill-text-assertion pattern (declarative artifact as the testable unit) is a reusable recipe.

Non-blocking notes for the record (both already scoped out deliberately, agreed):

  • describeStateDbOpenFailure name still says StateDb — future cosmetic drive-by.
  • whoami→send.ts command-to-command import — extract to a shared identity module when a third consumer appears.

@waleedkadous waleedkadous requested a review from amrmelsayed July 4, 2026 04:24
@waleedkadous

Copy link
Copy Markdown
Contributor Author

@amrmelsayed I've requested your review on this one as the final pass — would value your opinion, especially since afx whoami reads directly from the global.db layout your state-consolidation work (PR #1127) put in place. Areas where your eye would help most:

  • The read-only access pattern into global.db (openReadonlyGlobalDb + the optional db? handle on lookupBuilderSpawningArchitect) — does this fit how you'd want readers to consume the consolidated db?
  • The identity precedence (builder-worktree cwd → CODEV_ARCHITECT_NAME → fail loud) and whether any multi-workspace edge cases from the consolidation are missed.
  • Anything else that stands out.

No rush — the merge waits on your review. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

afx whoami + ship /arch-init command in codev (multi-architect identity)

1 participant