Skip to content

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

Draft
waleedkadous wants to merge 61 commits into
mainfrom
builder/spir-1940
Draft

waleedkadous wants to merge 61 commits into
mainfrom
builder/spir-1940

Conversation

@waleedkadous

@waleedkadous waleedkadous commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Draft, opened early for CI. This pull request is not ready for review. It was opened part-way through implementation so that GitHub runs the full test suite on a clean runner, under the owner's standing ruling main-32 (a green GitHub run may stand in for porch's local tests check when the local suite fails only under machine load). The review phase finishes this pull request: the description below will be replaced, and the review document added, before it is marked ready.

What this is

Stage 1 of issue #1940 (Tower-to-Tower messaging: addressing, discovery, security model): named architects addressable across workspaces on one Tower. No second Tower, no transport, no Codev Cloud.

Spec: codev/specs/1940-tower-to-tower-messaging-proto.md
Plan: codev/plans/1940-tower-to-tower-messaging-proto.md

Where it stands

Plan phase State
1. Shared address contract and parser Done, reviewed
2. Named architects across workspaces and the builder rule Built; in review (round 1 fix applied)
3. Explicit workspace names Not started
4. Qualified provenance and reply commands Not started
5. One-Tower discovery: workspace list and whoami Not started
6. Addressing docs in both trees and end-to-end verification Not started
7. Front-door-only workspace setting Cut by the owner (decision main-31)

In the branch so far

  • One address parser and formatter in @cluesmith/codev-sdk/address, with the structured AgentAddress wire type in codev-types, and one table of cases 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 in another workspace is delivered, or held when it has no live terminal.
  • A builder may name only its own spawning architect. Naming one in another workspace is refused with that workspace's front door.
  • Malformed addresses fail with the shape that was expected. Every afx:// address is refused as cross-Tower messaging not available.

Adjacent bugs fixed in place

Both are older than this branch and were found by review of phase 2.

  • The registry fallback could hold a builder's mail for an unrelated architect. For bare architect, the registry answered "the first registered" where the live resolver refuses (a builder whose spawning architect has gone, or a legacy builder, in a workspace with no main). The send route consults the registry on any not-found, so that mail was held for, and then delivered to, an architect the builder had nothing to do with. The registry now refuses exactly where the live resolver does.
  • Issue Offline architect resolver picks alphabetically, live resolver picks first-registered (getArchitects ORDER BY id) #1633 (offline architect resolver picks alphabetically, live resolver picks first-registered). getArchitects sorted by name, so with no main an offline hold named the alphabetically first architect where a live send reached the first registered. It now orders main first, then by start time, as loadState does. This also means a workspace's sibling architects are relaunched in registration order at workspace start.

Why the draft exists now, and the local check that was skipped

On d106d3984, porch's local tests check and one full local run failed with 92 timeouts in 17 test files, none touched by this branch, while the machine's load average was between 33 and 49. The same suite passed in full twice on the preceding commit.

Under the owner's ruling main-32, phase 2's local full-suite check was skipped (porch's build check still ran), on these grounds:

  • GitHub's run on this pull request was green, 8 of 8 checks, at 6804f57c7 (this branch with main merged in). The architect checked the run.
  • The 17 files that timed out pass when run alone in one vitest invocation: 586 passed, 1 skipped, at a load average of about 10.

main was merged into the branch (6df1df753) because the branch conflicted with it and GitHub runs no checks on a conflicting pull request. One conflict, packages/sdk/src/tower-client.ts: both sides added a field to the same two result shapes, and both are kept.

The details are in codev/state/spir-1940_thread.md.

waleedkadous and others added 30 commits November 20, 2026 17:30
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…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
…and the builder rule

<workspace>:architect:<name> resolves against live terminals and against the
registry, so mail to a named architect in another workspace is delivered, or
held when it has no live terminal.

- The two resolvers take the structured address and a sender context. They
  share one workspace lookup and one permission check.
- Permission is asked of the sender's workspace for every target. Affinity
  applies only inside the sender's own workspace.
- A builder may name only its own spawning architect. Naming one in another
  workspace is refused (403) with that workspace's front door.
- Malformed addresses are a 400 naming the expected shape. Every afx://
  address is refused as cross-Tower messaging not available, by Tower, the
  cron loader, afx interrupt and afx refresh.
- TowerClient.sendMessage's failure result carries Tower's error code.
- Carried from the phase 1 review: AgentAddress is a discriminated union,
  parse errors quote refused values safely, and an address has a length bound.
…live resolver does

For bare architect from a builder with no architect of its own, in a
workspace with no main, the live resolver refuses with the Spec 755 message
and the registry fallback answered 'the first registered'. The send route
goes to the registry on any NOT_FOUND, so the builder's mail was held for,
and delivered to, an unrelated architect.

The registry now gives the live resolver's answer. The starved-mail notice
keeps its own last step, the workspace's front door, with unchanged results.
One conflict, in packages/sdk/src/tower-client.ts: main added
connectionRefused (#1950) to the same two result shapes this branch added
errorCode to. Both fields are kept. One of this branch's SDK tests now
expects main's connectionRefused on a refused connection.
…n order (#1633)

getArchitects sorted by id, which is the architect's name. With no main, the
registry resolver took 'the first registered' off that list and got the
alphabetically first architect, where the live resolver reached the first
registered: one address, two recipients, depending on whether terminals
were up.

It now orders main first, then by started_at, as loadState does. The test
that pinned the old answer is flipped, as its comment asked.
…ce and asserts no shellper survives

The opt-in latency measurement stopped its Tower without deactivating the
workspace, and shellpers outlive Tower by design, so every run left its
architect and builder shellpers running. The teardown now deactivates the
workspace first, then polls and asserts that no process naming that Tower's
socket directory is alive. beforeAll asserts the same listing is non-empty
while the terminals are up, so the teardown assertion cannot pass vacuously.
A workspace can be given an address name of its own, the remedy for two
workspaces whose directories share a basename.

- Migration v20: nullable known_workspaces.address_name, stored lower-cased,
  with a partial unique index as a backstop.
- utils/workspace-address.ts holds every naming rule: which names may be set,
  which workspace a name refers to, and what a workspace's own name is. It
  takes the registered rows and the running workspaces as arguments.
- The resolvers' workspace lookup calls it in place of the basename match. An
  explicit name wins and belongs to its workspace whether or not it is
  running; a named workspace no longer answers to its basename; two unnamed
  workspaces with one basename fail as ambiguous, naming both paths and the
  command. The name table is read only for an address that names a workspace.
- PUT /api/workspaces/:encodedPath/address-name, TowerClient
  setWorkspaceAddressName, and afx workspace name <name> / --clear.
- The Windows path merge keeps the explicit name on the surviving row.
…d, five unrelated files pass alone; real-Tower transcript
- Remove the 64-character limit on a workspace name: the spec gives none.
- The name route answers 500 when the write stored nothing and 409 NAME_TAKEN
  when the unique index refuses it, where it used to answer 200 or throw.
- Errors about a workspace call it what the sender wrote, not its directory
  name, so they agree with the front-door hint beside them.
…be written in an address

A name is refused at set time when its front door, <name>:architect, would
not pass the shared parser. The check formats that address with the shared
formatter and reads it back, so the limit is the parser's own (the length of
an address) and the naming module holds no number.

tryFormatAddress is the formatter's answer as a value; formatAddress calls it
and throws exactly as before.
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.

1 participant