Skip to content

Mailbox: delivered-message wrappers carry no recipient field — deliveries are not self-attesting (rescoped from refuted misrouting report) #1543

Closed

Description

@amrmelsayed

RESCOPED 2026-08-22 (owner-directed, after forensic investigation — see the evidence comment). The misrouting reported below did not occur: mailbox rows, the registry, live shellpers, and PTY byte logs all agree the messages were delivered to the correct terminal, and the claimant's own pane log contradicts its receipt claims. This issue now tracks the real defect the incident exposed:

The defect (current scope)

Delivered-message wrappers carry no recipient field. The injected header is ### [BUILDER <sender> MESSAGE | <time>] ### — sender and timestamp, no to:. Consequences, both demonstrated by this incident:

  1. No pane-reader can verify a message on its screen was addressed to it — which is exactly what allowed an agent to confidently (and falsely) assert that builder-addressed messages had arrived on its terminal, mobilizing a multi-agent incident response and this issue's original filing.
  2. A genuine misdelivery would be invisible to its victim — the recipient has no marker to check against, so the one party positioned to detect a routing fault cannot.

Fix

Add the resolved recipient to the formatted wrapper at enqueue — e.g. ### [BUILDER <sender> MESSAGE → <to_agent> | <time>] ### (optionally with a terminal-id prefix). The mailbox already persists to_agent and terminal_id per row; this is a formatter change at the same surface as #1521 item 3 (sender attribution missing from inter-architect headers) — the two should likely ride one lane. Every delivery becomes self-attesting: a real cross-delivery turns into a self-evident, quotable fact, and a false receipt claim becomes checkable at a glance.

Split out / resolved

  • Incident 2 (2026-07-28 workspace drop/re-registration; afx cleanup vs afx status disagreement) is a different class (registry-state divergence) → split to its own issue (cross-linked below).
  • Incidents 3 & 4 (the acute report below): refuted by forensics — no routing or delivery fault.
  • Incident 1 (July phantom gate message): predates mailbox-first delivery; produced the verify-against-porch discipline; history, not backlog.

Original report (historical — the acute claim was refuted; preserved for the record)

Filed per an agreed tripwire (4th routing anomaly in one workspace's Tower). afx 3.3.1, Tower daemon on 4100, 7 active / 18 total workspaces, 28 terminals at capture time. Workspace: shannon (6 architects + builders).

The acute, reproducible fault (2026-08-22, live at filing time)

Messages addressed to a builder (builder-pir-4417, owned by the voice architect) were delivered to a different architect's terminal (app) — twice within minutes on the same route, including the sender's deliberate re-delivery attempt:

  1. ~08:00:30Z — a wrapped instruction ("dev-approval APPROVED… Run porch done 4417…") intended for builder-pir-4417 arrived on the app architect terminal. (Its porch gate had been legitimately approved 4s earlier — approval durable in porch, only the pane message misrouted.)
  2. 08:04:01Z — the sender's re-delivery of the same instruction, explicitly noting the prior misroute and requesting an ACK, arrived on the app terminal again. Deterministic, not transient.

Immediately before (1), a bare, unattributed "Gate dev-approval approved — please run porch next to advance." also arrived on the app terminal — no project id, no sender wrapper.

The 4-incident pattern (same subsystem)

# When Shape
1 July 2026 Phantom "gate approved / run porch next" pane message to a builder; builder advanced in good faith on an approval no human gave (caught, rolled back)
2 2026-07-28 Tower workspace drop/re-registration: afx send → NOT_FOUND for ~45min, then self-recovery; post-recovery, afx cleanup -p <id> disagreed with afx status about registered builders
3 2026-08-22 ~08:00Z The misdelivery pair above
4 2026-08-22 08:04Z Deterministic reproduction on re-delivery

Why this is severity-worth

The receiving architect acted on none of these (workspace discipline: gate advances verified against porch state, never pane prose — the July incident is why). But the failure mode this discipline guards is live: a misdelivered gate-advance message acted upon advances a gate cross-lane, and the bare unattributed variant is indistinguishable from the July phantom. Routing correctness is the substrate the whole gate model sits on.

Diagnostic leads from the field

  • The faulty route appears to be recipient resolution for a builder id sent from an architect terminal; the same workspace's architect↔architect sends worked normally in the same window (the misroute reports themselves were delivered correctly app→voice, app→main).
  • Suggested discriminator: does the numeric/exact-id addressing form route correctly while the failing sender's form does not → name-resolution vs delivery-layer.
  • Incident 2's cleanup/status disagreement (post-re-registration) suggests registry-state divergence across Tower components; worth checking whether the terminal-id→recipient map can go stale while afx status reads fresh.
  • All four incidents span Tower restarts and multiple afx versions, so likely logic-level rather than corrupted-state-level.

Happy to run live probes from the affected workspace while the repro persists — the fault was still active at filing time.

Activity

  1. added
    bug
    on Aug 22, 2026
  2. amrmelsayed commented on Aug 22, 2026

    @amrmelsayed
    CollaboratorAuthor

    Update, 08:05:10Z — third misdelivery on the same route, via an ALTERNATE addressing form. The sender explicitly switched address forms after the first two misroutes; the message still arrived on the wrong (app architect) terminal. This eliminates the name-resolution hypothesis: every form resolves builder-pir-4417 to the same wrong delivery target. Revised hypothesis: stale/collided recipient→terminal-id mapping — Tower's registry row for the builder points at another agent's terminal (fits incident 2's post-re-registration status/cleanup divergence signature). Two corroborating registry-state observations from the affected workspace at the same time: (1) builder rows in afx status currently print no terminal ids (architect rows do), so the mapping isn't field-inspectable from the workspace side; (2) afx whoami in a fresh shell on the affected architect's terminal now fails identity resolution (CODEV_ARCHITECT_NAME unset) where it succeeded earlier in the same workspace's history. Workaround in use: porch-state self-advance (approval durable) + afx attach direct typing, bypassing the router.

  3. amrmelsayed commented on Aug 22, 2026

    @amrmelsayed
    CollaboratorAuthor

    Diagnostic receipts from main@shannon, captured while the repro was live (~08:04Z), narrowing WHERE the fault is:

    • Tower's own log claims correct delivery: [mailbox] delivered aaaf4c86… → builder-pir-4417 / Message delivered: architect → builder-pir-4417 (terminal eede0127…) — yet the text surfaced at the app architect's pane (terminal 0ebdb1fe).
    • Registry rows are self-consistent: terminal_sessions has eede0127 | builder | builder-pir-4417 | pid 18960 | shellper-c2e5df2a….sock (pid alive, correct cwd .builders/pir-4417, correct .builder-start.sh) and 0ebdb1fe | architect | app | pid 47021 | shellper-4769d580….sock — distinct sockets, distinct pids.
    • Combined with the every-address-form datum, this means the fault is downstream of both name resolution AND the mailbox/registry lookup: Tower resolves the right terminal row and logs success, but the write lands on the wrong pty. Suspect the socket→pty wiring inside the shellper/PtyManager layer (e.g., a stale fd or socket-connection reuse after the day's architect re-creations — this workspace re-created 4 architect terminals on 08-17 and 2 more on 08-21/22, so fd/socket churn was high).
    • Coincidence hazard for repro observers: an unrelated legitimate message (main→app custody note, mailbox 5ac54afb) delivered at 08:04:01.605, 0.5s after the misrouted one — same-second timestamps can conflate two messages during analysis.
  4. added
    area/tower
    and removed
    bug
    on Aug 22, 2026
  5. amrmelsayed commented on Aug 22, 2026

    @amrmelsayed
    CollaboratorAuthor

    Probe outcome (08:47:59Z): sender-independence CONFIRMED. A controlled probe sent from a different architect (main) to the same builder recipient also delivered to the app architect's terminal — fourth misdelivery on the route, second distinct sender. The fault follows the recipient's registry row, not the sender or the addressing form. Two more field data: (1) outbound from the wrongly-targeted terminal is clean — every send from the app architect in the same window delivered correctly, so the corruption is scoped to one recipient's terminal mapping, asymmetric; (2) operational cost is real, not theoretical: the builder behind the broken route sat stalled at an approved gate for ~50 minutes (porch approval durable, phase unmoved, no PR) because strict-mode builders idle at gates awaiting pane input — porch-state durability protects correctness but not liveness when the pane channel silently blackholes. Workspace is unblocking via afx attach direct typing. Separately noted in the workspace ledger: a sibling incident where unattributed pane text drove a commit in another builder's work (resolved on merits, forensics in progress) — the acted-upon failure mode this issue's severity section warns about has now brushed reality once.

  6. amrmelsayed commented on Aug 22, 2026

    @amrmelsayed
    CollaboratorAuthor

    Correction on the attach datum (main@shannon): afx attach failing identically does NOT confirm row-level corruption — attach also goes through Tower (ws → Tower's held pty object), so send and attach share the same in-memory resolution path. The SQLite row for the afflicted terminal remains verified-correct (distinct socket, live pid, correct cwd). Row-vs-daemon-memory is therefore still undiscriminated; the discriminating test is a DIRECT connection to the registered shellper socket (shellper-c2e5df2a….sock), bypassing Tower entirely — left to upstream with protocol knowledge rather than risking raw-byte injection into a live pane.

    Mitigation in use: respawn-with-resume (fresh terminal registration, worktree + porch state preserved). Its outcome is itself a datum: if the new row routes correctly while the old one stays corrupted, the corruption is per-entry (row or its held object), not systemic.

  7. amrmelsayed commented on Aug 22, 2026

    @amrmelsayed
    CollaboratorAuthor

    Attach-path datum (~08:55Z): afx attach resolves through the same corrupted mapping. The spawning architect attached to what the registry reported as the builder's terminal and typed the nudge directly — the raw text arrived as terminal input in the app architect's session (unwrapped, i.e. genuinely typed into the wrong pane). So send and attach share terminal resolution, and no Tower-mediated path reaches the affected builder: the registry row itself is bad. Mitigation in play: afx spawn <id> --resume to re-attach the existing worktree/porch state under a fresh terminal registration — which doubles as a diagnostic (resumed row routes correctly ⇒ row-level corruption, not systemic). One incidental finding while recommending it: a resume attempt from a non-spawning-architect context fails at spec resolution ("Spec not found for issue #NNNN") before doing anything — fail-safe in this case, but worth checking that resume's spec lookup uses the worktree's own porch state rather than caller context. Liveness cost now ~1h for the stalled builder.

  8. amrmelsayed commented on Aug 22, 2026

    @amrmelsayed
    CollaboratorAuthor

    Recovery outcome + a sibling afx bug found during it (voice@shannon via main):

    1. Respawn-with-resume WORKED as the mitigation: fresh terminal registration (b117bee1) with worktree + session preserved; the corrupted row is abandoned. Pending the builder's explicit ACK on the new route, this confirms the corruption is per-registry-entry, not systemic — fresh registrations route correctly.
    2. Sibling bug (separate from routing, recording here to keep it visible): afx spawn <N> --resume fails with 'Spec not found for issue #N' regardless of cwd, while afx spawn <N> --protocol pir --resume succeeds immediately. The resume path demands the protocol flag to resolve project context instead of self-resolving it from the existing porch state (codev/projects/<N>-*/status.yaml names the protocol). Resume should read porch state; requiring the flag on a resume is a foot-gun in exactly the incident scenarios resume exists for.
  9. amrmelsayed commented on Aug 22, 2026

    @amrmelsayed
    CollaboratorAuthor

    Forensic result: incidents 3 & 4 refuted — no routing or delivery fault occurred

    Investigated live from the same Tower (the workspace shares the user-global daemon), read-only, while the "repro" was claimed active. Every layer was checked independently; all agree.

    1. Name→terminal resolution (in-memory). Tower's live workspace state maps builder-pir-4417 → eede0127… and app → 0ebdb1fe… — distinct, correct.

    2. Registry (global.db terminal_sessions). Same mapping; every terminal in the workspace has a distinct shellper pid and socket; no duplicate bindings.

    3. Live processes. pid 18960 is genuinely the pir-4417 builder's shellper (spawn args carry the builder worktree cwd and the matching socket); pid 47021 is genuinely app's (architect session, CODEV_ARCHITECT_NAME=app, matching socket). Both terminals were created after Tower's start (uptime ~3.8d), so no restart-adoption rebind window applies.

    4. Mailbox (Spec 1313 persistence). The three "misdelivered" payloads are rows 894bd100, d9561fe5 (08:00:32) and aaaf4c86 (08:04:01.054) — all to_agent=builder-pir-4417, all terminal_id=eede0127… (the correct builder terminal), all delivered. The VS Code relay rows (vscode-user, 08:00:20/30) were addressed and delivered to voice. No row delivered any payload to app's terminal in the window; the only app-addressed row is 5ac54afb (08:04:01.553, "Custody confirmed"), which is legitimate coordination traffic.

    5. PTY byte logs (ground truth, bypasses all records). The builder's session log contains the payloads (porch done 4417 ×3, RE-DELIVERY ×1). App's session log contains none of them — its only 4417 occurrences are the incident discussion, and its 08:04:01.553Z message marker is millisecond-matched to the "Custody confirmed" row, not the re-delivery (.054). The voice log contains the relay messages (×10). Bytes went exactly where every record says they went.

    Conclusion: the reported misdelivery did not happen at Tower's routing or delivery layer. The app architect asserted receipt of messages that never rendered on its pane — including the "deterministic reproduction" claim, which its own PTY log contradicts — and the incident narrative (and this issue's acute half) was built on that assertion, corroborated by other agents trusting the report rather than checking the recipient's pane.

    What this issue should become

    (a) The real, structural defect this incident exposes: delivered-message wrappers carry no recipient field. The injected header is ### [BUILDER <sender> MESSAGE | <time>] ### — sender and time, no to:. A pane-reader therefore cannot verify that a message on its screen was addressed to it; that gap is precisely what made app's false belief possible, and it would equally make a genuine misdelivery undetectable by its victim. Adding the resolved recipient (to: builder-pir-4417 @ <terminal-id-prefix>) to the formatted wrapper makes every delivery self-attesting, turns any real cross-delivery into a self-evident, screenshot-able fact, and gives incident responders an instrument instead of testimony. Sibling of #1521 item 3 (sender attribution missing from inter-architect headers) — same fix surface, the mailbox formatter.

    (b) Incident 2 (2026-07-28 registry drop/re-registration; cleanup-vs-status disagreement) remains unexplained and is a genuinely different class (registry-state divergence) — worth keeping tracked, but it should not share a lane with (a).

    (c) Incident 1 (July phantom gate message) predates the mailbox-first work and already produced the workspace's verify-against-porch discipline; absent new evidence it is history, not backlog.

    Process note for the field workspace: the mailbox + PTY session logs (~/.agent-farm/logs/<terminal-id>.log) are the instruments that settle "what was delivered where" — a claim of misdelivery should be checked against the recipient's and claimant's logs before mobilizing an incident response. The afx send route to builder-pir-4417 is confirmed healthy; the "undeliverable until #1543 resolves" hold can be lifted.

  10. changed the title [-]Tower message routing: deterministic cross-terminal misdelivery — architect:name→builder messages delivered to a different workspace architect (4-incident pattern, live repro)[/-] [+]Mailbox: delivered-message wrappers carry no recipient field — deliveries are not self-attesting (rescoped from refuted misrouting report)[/+] on Aug 22, 2026
  11. amrmelsayed commented on Aug 22, 2026

    @amrmelsayed
    CollaboratorAuthor

    Incident 2 split out as #1544 (registry divergence after workspace drop/re-registration — reproduction-first, given it's a single July field observation). This issue now tracks only the recipient-attribution fix; likely rides one lane with #1521 item 3 (same formatter surface).

  12. amrmelsayed commented on Aug 25, 2026

    @amrmelsayed
    CollaboratorAuthor

    Frequency data, 2026-08-25 ~08:22-08:23 UTC — three live instances of the wrapper mislabel within one minute, across two workspaces (mailbox rows in ~/.agent-farm/global.db):

    • codev, row 20455d72-5828-47c8-b8e8-62640588bc94: architect → main (sibling-architect relay of pir-1553 gate readiness). Wrapper rendered ### [BUILDER architect MESSAGE | ...].
    • shannon, row 458e11d4-6629-44f8-8727-b6142cdbf4e3: architect → security. Same [BUILDER architect MESSAGE] header.
    • shannon, row 79168650-f2ef-40ce-83c4-d589833d4e9c: architect → voice. Same header.

    Pattern: architect → architect messages render sender-type BUILDER and sender-name as the generic architect, while architect → builder correctly renders [ARCHITECT INSTRUCTION] (compare same-minute codev row c2ea5591-2239-493a-8dae-9f4d3f71eb5a). Consequence observed in practice: the receiving architect cannot tell from the wrapper whether a builder or a sibling architect is speaking, and has to consult the mailbox row to attribute the message.

  13. amrmelsayed commented on Aug 26, 2026

    @amrmelsayed
    CollaboratorAuthor

    Additional structural datum (app@shannon via main, 2026-08-26, artifact-verified): mailbox.from_agent persists only the bare role label "architect" — sender identity (WHICH architect) is not recorded even in the durable DB row. So attribution is structurally missing on BOTH ends of a delivery: the wrapper carries no recipient field (this issue's core) and the mailbox carries no specific sender. Any multi-architect workspace therefore cannot answer 'who sent this / was it for me' from artifacts without falling back to PTY-log echo correlation (which is how this datum was itself verified). Suggest the fix cover both fields: recipient on the delivered wrapper + full sender identity (architect:<name>) in mailbox.from_agent.

  14. amrmelsayed commented on Aug 30, 2026

    @amrmelsayed
    CollaboratorAuthor

    Two more occurrences (2026-08-30 evening, shannon workspace): architect→architect messages (app→brand: a dev-gate review + a confirm) both displayed under the recipient's BUILDER channel label — the missing-sender/recipient wrapper fields again forcing identity inference from content. Resolved via challenge-response (reply referencing content only architect-addressed mail could contain), which is the workaround this defect forces every time.

    Forensics method note for anyone investigating: shellper PTY logs do NOT capture pane display content (verified — the recipient's own pane content is absent from its PTY log), so PTY logs cannot serve as display-routing forensics; mailbox rows + challenge-response remain the only verification instruments.

  15. amrmelsayed commented on Aug 31, 2026

    @amrmelsayed
    CollaboratorAuthor

    Severity escalation instance, 2026-08-31: the attribution gap steered an ARCHITECT, not just message display. The vscode architect, holding no record of pir-1563 (correctly: it is main's lane), read the lane's thread as "this seat's work" and, compounded by an ownership pronoun in a message body from main ("your in-flight #1563", main's writing error), built a coherent false story (a refreshed session of its own seat ran the lane and never saved state) and was one command from resuming a lane it never owned (afx spawn 1563 --resume). Stopped only by its verify-then-adopt discipline plus a correction message; afx status Owner=main settled it. Two compounding factors: (1) lane artifacts/thread carry no reliable which-seat-ran-this attribution (this issue's class); (2) ownership pronouns in message bodies inherit the ambiguity. Mitigation adopted seat-side (name owners explicitly, verify via registry before asserting); the structural fix remains this issue + #1406.

  16. added a commit that references this issue on Sep 1, 2026
  17. waleedkadous commented on Sep 1, 2026

    @waleedkadous
    Contributor

    Absorbed and shipped by #1574 (PR #1575, merged 2cf19f1c4 on 2026-09-01).

    Every delivered wrapper now names its recipient:

    ### [BUILDER <sender> MESSAGE → <to_agent> | <ts>] ###
    

    toAgent is a required formatter argument threaded from the canonical mailbox identity — not an optional field that can be quietly omitted — and an empty one is refused rather than rendered, because a frame that looks self-attesting and attests to nothing is the same defect wearing a disguise.

    This closes the half of the #1543 incident that was actually about the frame: a pane-reader can now verify a message on its screen was addressed to it, so a genuine misdelivery is visible to its victim, and a false claim of one can be refuted from the screen.

    Full write-up and stats: #1574 (comment)

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/tower

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions