Skip to content

[Spec 1940] Stage 1: named architects across workspaces on one Tower - #1957

Merged
waleedkadous merged 109 commits into
mainfrom
builder/spir-1940
Nov 24, 2026
Merged

waleedkadous merged 109 commits into
mainfrom
builder/spir-1940

Conversation

@waleedkadous

@waleedkadous waleedkadous commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Stage 1 of Tower-to-Tower messaging (issue #1940): an architect in one workspace can write to a named architect in another workspace on the same Tower, and the recipient can reply by pasting one command.

$ afx send codev-cloud:architect:tunnel "the relay contract changed"

### [ARCHITECT codev:architect:review MESSAGE → tunnel | <time>] ###
the relay contract changed
###############################  (reply: afx send codev:architect:review "…")

No second Tower, no transport and no Codev Cloud are involved. The spec designs all three stages (one Tower; my own Towers; another owner's Tower); the owner approved it with stage 1 as this project's scope. Stage 2 (between my own Towers, through Codev Cloud) is issue #1967 and stage 3 (another owner's Tower, by invitation) is issue #1968; each inherits the spec's checklist as written.

Closes #1940

Six plan phases are built and reviewed (Codex and Claude, every phase ending with both approving). No commit in any implement phase went unreviewed.

One commit no reviewer saw: 42f6d76c5, made in answer to the review phase's single round (porch went to the pr gate without a second). It adds one clause to the afx skill (four copies) and agent-farm.md (both trees) saying a builder may write its own workspace's name before its own spawning architect, regenerates the skill-hash list, and edits the review document. The round's verdicts were Codex REQUEST_CHANGES (three procedural points, no implementation defect) and Claude APPROVE; the responses are in the review.

The owner waived the Co-Authored-By trailer on d4cb7e648 (decision main-41): history is left as it is, with no rewrite and no force-push. That commit is the first of the spec and the only one with a trailer.

Changes

  • One address parser and formatter (@cluesmith/codev-sdk/address), with the structured AgentAddress wire type in codev-types. One table of cases is run by the SDK, packages/codev and the VS Code extension.
  • <workspace>:architect:<name> resolves against live terminals and against the registry, so mail to a named architect elsewhere is delivered, or held when it has no live terminal. Every address form valid before reaches the same recipient as before.
  • The builder rule. A builder may name only its own spawning architect, however the address is written. Naming an architect in another workspace is refused with that workspace's front door (<workspace>:architect), which stays open to every sender.
  • Workspace address names. afx workspace name <name> (and --clear) gives a workspace a name of its own. Two workspaces with the same directory name are ambiguous until one is named; the error lists both and the command.
  • Provenance and reply. A message from another workspace shows the sender's full address and a reply command the recipient is allowed to run. A builder that may not name the sender is told to reply through its own architect. Same-workspace frames are byte-identical to before.
  • Discovery. afx workspace list prints every workspace on the Tower and its agents as addresses ready to paste, marked for what the caller may send to. afx whoami prints the caller's own address.
  • afx:// addresses are parsed, so a malformed one says what is wrong, and then refused: cross-Tower messaging is not available until stage 2.
  • A CLI newer than the running Tower (the state right after an upgrade) says so and how to restart Tower, in afx workspace list, afx workspace name, afx whoami and afx send.
  • Docs in both trees: CLAUDE.md/AGENTS.md, the templates, the afx skill (four copies), agent-farm.md, the architect and builder role files, arch.md.
  • Database migration v20 adds known_workspaces.address_name.

Not built

  • The front-door-only setting per workspace (plan phase 7, one of the spec's stage 1 criteria) was cut by the owner at plan approval. Nothing in the code or docs mentions it. The issue asking for front-door-only routing to be made explicit (afx send: make front-door-only cross-workspace routing explicit (docs + error message) #1605) is superseded by this PR; the architect closes it at merge.
  • Three test scenarios in the spec have no test, each for a stated reason (the devvm hint; the "until it has an explicit name" half of two afx:// bullets; front door only). See the review.

Older bugs fixed in place

Both were found by review of phase 2.

  • The registry fallback could hold a builder's mail for an unrelated architect. For bare architect from a builder with no architect of its own, in a workspace with no main, the registry resolver answered "the first registered" where the live resolver refuses. The registry now refuses where the live resolver does.
  • Offline architect resolver picked alphabetically, live resolver picked first-registered (issue Offline architect resolver picks alphabetically, live resolver picks first-registered (getArchitects ORDER BY id) #1633). getArchitects now orders main first, then by start time. Side effect: sibling architects relaunch in registration order at workspace start (it was name order). The architect closes that issue at merge.

Found, not changed

Testing

  • New and extended unit and route tests across the parser, both resolvers, the naming rules, the frames, the listing, whoami and the CLI commands; the review maps every stage 1 test scenario in the spec to the tests that check it.
  • cross-workspace-addressing.e2e.test.ts (13 tests): a built Tower that has never connected to Codev Cloud, three workspaces, the CLI's own commands run as each agent.
  • Latency (spec bound: baseline + the larger of 5% and 1 ms). Baseline before any change 2.19 ms, bound 3.19 ms. After: median of five runs' medians 2.270 ms same-workspace, 2.215 ms cross-workspace to a named architect.
  • Windows: on-demand run https://github.com/cluesmith/codev/actions/runs/45314039137 green on its second attempt (the first attempt's two failures are in the review under Flaky Tests and are not in this branch's files). An earlier run was red on 30 of this branch's route tests because a fixture seeded workspaces under the short temp spelling; fixed in the fixture.

Porch's local tests check was skipped in phases 2 to 6

The local full suite fails under its own load on the development machine (issue #1956). On the owner's rulings, a green GitHub run on the same head stood in, and the architect checked each run before the skip:

Phase Local tests check GitHub run that stood in
2 Failed on unrelated timeouts (17 files, each passing alone); skipped (ruling main-32) green at 6804f57c7, 66ea5c747
3 Failed once on 5 unrelated files; skipped (main-32) green at 0a553e80b, 18a9c86a8, 4c9d9c967
4, 5, 6 Not run (ruling main-38, "ci-first") green at ba33ee37b, 6462b2563, ef6d5162c

Porch's build check ran every time. The review phase follows the same ruling.

For the verify phase

  • On a Tower of this version, send from one workspace's architect to a named architect in another with the installed afx send, and paste the reply command back. (No test can point the built binary at a test Tower: it always connects to port 4100.)
  • In a workspace with two sibling architects registered in non-alphabetical order, restart the workspace: they come back main first, then in registration order.
  • Tower must be restarted to pick up this version; until then the new commands say the Tower is older.

Notes

  • main was merged into the branch twice: at 6df1df753, so that GitHub would run checks (one conflict in packages/sdk/src/tower-client.ts, both sides kept), and at f163054c3 before merging this PR (71 commits, no conflict; the generated skill-hash list was regenerated and came out unchanged).

Spec

codev/specs/1940-tower-to-tower-messaging-proto.md

Plan

codev/plans/1940-tower-to-tower-messaging-proto.md

Review

codev/reviews/1940-tower-to-tower-messaging-proto.md

Builder's log: codev/state/spir-1940_thread.md

waleedkadous and others added 30 commits November 20, 2026 17:30
…builder rule, stage 2 walkthrough, connections per owner, existing code
…approval (main-31): front-door-only opt-in cut from stage 1
…istyped afx scheme fails with the shape meant
…der the canonical spelling Windows keys them by

The Spec 1940 block of tower-routes.test.ts made its workspaces under
os.tmpdir(), which Windows hands out in its short spelling (RUNNER~1), while
the routes key a workspace by workspaceKey(). Thirty tests failed on the
Windows run for looking up a workspace the fixture had seeded under another
spelling. The root now goes through workspaceKey(); no change on POSIX.
…st table; seven lessons routed to the cold tier
@waleedkadous waleedkadous changed the title [Spec 1940] Stage 1 (in progress): named architects across workspaces on one Tower [Spec 1940] Stage 1: named architects across workspaces on one Tower Nov 24, 2026
…ore its own architect (docs); review cites #1967 and #1968; rebuttal
@waleedkadous
waleedkadous marked this pull request as ready for review November 24, 2026 18:28
@waleedkadous
waleedkadous merged commit 707e0e9 into main Nov 24, 2026
8 checks passed
waleedkadous added a commit that referenced this pull request Nov 24, 2026
waleedkadous added a commit that referenced this pull request Nov 24, 2026
… worker cap (#1965)

One conflict, packages/sdk/src/tower-client.ts: both sides added names to the
same codev-types import; resolved as the union.
waleedkadous added a commit that referenced this pull request Nov 24, 2026
…r as a not-found; status --json tells busy from down

Architect round, after merging PR #1957 (Spec 1940, named architects):
- A <workspace>:architect:<name> send that came back NOT_FOUND asks the
  address book, to tell an older Tower. When Tower did not answer that
  check at all, the bare not-found was reported, though nobody could
  judge it. getAddressBook() now marks a failure with no HTTP answer as
  unanswered, and send says the check went unanswered and to retry. An
  answered failure of the check still leaves the not-found.
- checkTower() takes a retries option (default 1). send --retry N passes
  0, so its budget owns the retrying: N + 1 health probes instead of
  2(N + 1). Without --retry the gate's single retry still applies.
- status --json: tower is {running, state, error}. running is unchanged
  for existing scripts; state is running, not-running or unresponsive;
  error is the reason when unresponsive, otherwise null.
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.

Tower-to-Tower messaging protocol: afx:// addressing, remote workspace discovery, security model

1 participant