Skip to content

docs(adr): ADR-018 D6.3 — a reply addresses its target regardless of species - #1205

Merged
lilyshen0722 merged 3 commits into
mainfrom
docs/adr018-d63-implicit-reply-addressing
Aug 25, 2026
Merged

lilyshen0722 merged 3 commits into
mainfrom
docs/adr018-d63-implicit-reply-addressing

Conversation

@lilyshen0722

Copy link
Copy Markdown
Contributor

Closes TASK-058.

The seam

D6.1 settled that targeting is respected and only broadcast gambles — a directly addressed seat proceeds peer-aware past a peer's claim. It did not say which messages count as targeting, and the implementation answered that with a species gate.

#703's implicit-reply path is gated on sender.isBot === false (agentMentionService.ts:1685), so a bot's reply to an agent never produces a chat.mention for the agent it answers. The author sees only ambient activity, is therefore not "addressed" in D6.1's sense, and has no standing to proceed past the replier's claim.

Observed live on the SEO squad, 2026-08-24: Anvil threaded on Sage's message, Sage got an ambient wake, Anvil claimed, and Sage stood down — twice, from a conversation about Sage's own message.

Each half is defensible alone. Together they produce a rule nobody wrote: bot-to-bot thread conversations are inert unless the replier repeats an @name, which is the one thing a reply edge already means.

The decision (Sam, 2026-08-24)

A reply or quote addresses its target, whoever sent it. The claim layer needs no change — addressed seats already proceed peer-aware, so restoring the addressing signal restores the behaviour through machinery that exists.

Anti-ping-pong moves to three bounded guards: the existing bot-to-bot wake dampener, a convergence rule (two consecutive NO_REPLYs mute further implicit wakes for that seat+thread; explicit @mentions always pass), and a frame that teaches the exit.

The principle, stated so the next widening inherits it: ping-pong is content-free reciprocity, work is substantive. A guard against ping-pong must key on evidence of a loop, never on who is speaking — a species gate cannot distinguish the two and will always suppress the wrong one.

What is built, which is less than what is decided

The amendment says this in place rather than leaving a reader to infer production from a ratified decision:

  • shipped — per-target evidence (repliesToYourMessage + the frame) on the existing message.posted fan-out. Does not widen ADDRESSED_EVENT_TYPES, adds no event type, needs no wrapper release.
  • shipped — guard 1 (dampener) and guard 3 (frame).
  • not implemented — guard 2, convergence. Until it exists the dampener is the only loop bound, and claim-standdown is improved by evidence rather than fixed by addressing.

The status line now carries that caveat, so Accepted cannot be read as having decided the unbuilt part. Same discipline as D4's 90s lease.

Also in this PR

  • The interim code comment pointed at TASK-058, a pod-local id that decays. It now points at ADR-018 D6.3 and states which guard is missing.
  • ADR-020 scope-boundary note. Wake policy has a regression history: #963 read ADR-020 D6 as governing and demoted every multi-agent workspace to mention-only. This amendment widens what D8's fan-out treats as addressing, so it lands in the same blast radius.
  • A Review-section note on the repeated pattern: both D6.1 and D6.3 were failures of composition between two individually defensible rules, with neither document owning the seam.

Verification

tsc --noEmit on Node 22: 51 errors before, 51 after, none in agentMentionService.ts (pre-existing, all in test-discord-interactions.ts). No behaviour change — docs plus two comment lines.

🤖 Generated with Claude Code

…species

D6.1 settled that targeting is respected and only broadcast gambles, but left
"what counts as targeting" to the implementation, which answered it with a
species gate: #703's implicit-reply path is gated on `sender.isBot === false`,
so a bot's reply to an agent never addresses that agent. Observed live on the
SEO squad 2026-08-24 — Sage stood down twice on Anvil's claim, from a thread
about Sage's own message.

Records Sam's ratified direction: a reply or quote addresses its target
whoever sent it, with anti-ping-pong moving to three bounded guards (wake
dampener, thread convergence, an exit-teaching frame). The principle the next
widening inherits: bound on evidence of a loop, never on who is speaking.

States plainly that this is less built than decided — the interim ship carries
per-target evidence on the existing message.posted fan-out and does not widen
ADDRESSED_EVENT_TYPES, and the convergence guard does not exist. Points the
interim code comment at the ADR rather than at a pod-local task id, and adds
the ADR-020 scope-boundary note that #963's regression earned.

Co-Authored-By: Claude Opus 5 <[email protected]>
D6.3 already records that the convergence guard is not implemented. What
it did not say is why, and the gap matters: the obvious implementation is
a countDocuments that always returns zero.

A total-match NO_REPLY takes the !sanitizedContent branch and persists no
message row, so "two consecutive silent turns" leaves nothing to count.
The only durable trace is a system_exchanges entry written solely in
agent-dm pods, which is the wrong population. And neither layer knows the
thread — postMessage never learns one, and AgentEvent has no thread
column, its payload being Mixed.

So a converged exchange is indistinguishable from one the instrument
cannot see, and guard 2 belongs in the ack path: a wake already knows its
thread at enqueue, and a seat that acks a thread-scoped wake and posts
nothing into that thread is the convergence event, keyed by (seat,
thread) where both are in hand.

Also records that guard 2 must state its own failure direction. Guard 1
fails open because dropping a genuine wake is the worse error; guard 2
failing open risks the unbounded reply chain the species gate existed to
prevent. Copying guard 1's shape would import an answer reasoned for a
different question.

Status line now names the two open items inside D6.3 — signal source and
threshold — so the ratified direction cannot be read as deciding them.

Co-Authored-By: Claude Opus 5 <[email protected]>
@lilyshen0722

Copy link
Copy Markdown
Contributor Author

Gated at 1b6ccedc. This PR had zero reviews and zero comments while sitting CLEAN and waiting on a merge press, so it was about to reach Sam ungated. Approving.

The backend change is provably inert. Every changed line in agentMentionService.ts is a // comment — filtering the diff for non-comment changes returns nothing:

git diff origin/main..pr1205 -- backend/services/agentMentionService.ts \
  | grep -E "^[-+]" | grep -vE "^[-+][-+]" | grep -vE "^[-+]\s*//"   →  (empty)

// line comments also can't hit the block-comment hazard where a stray */ in prose terminates early. So the ship is the ADR; the code change is documentation pointing at it.

The three things CLAUDE.md requires of a wake-policy ADR are all present, checked rather than taken on the description:

  1. ADR-020 scope boundary — present at :136, and it names the regression by number: "Wake policy has a production-regression history: #963 read ADR-020 D6 as governing…". That's the exact requirement fix: derive wake policy from pod shape #963 earned.
  2. Status line carries the unbuilt caveat — and goes further than required, naming both open items rather than gesturing at them: "D6.3 (2026-08-25) is ratified as a direction and only partly built: its convergence guard is not implemented — and … is specified against a signal that is not recorded, so two further items inside it are open: the signal source and the threshold." Accepted cannot be misread as having decided the unbuilt part.
  3. No D-number collision — D6.1 ×5, D6.2 ×1, D6.3 ×4. D6.3 is new.

One observation on the loop bound — non-blocking

D6.3 stakes its safety on the dampener being the sole loop bound, so it's worth stating what that bound actually is. MENTION_LOOP_MAX = 3 over MENTION_LOOP_WINDOW_MS = 5 min, and I confirmed the event types line up — enqueueWakeOnMessage enqueues type: 'message.posted' and isWakeLoopDampened counts exactly that, so the guard does cover the path D6.3 widens.

The asymmetry worth knowing: the gate is sender-scoped, the counter is not. Suppression only applies when senderKey is truthy (a bot sender), but the count is:

AgentEvent.countDocuments({
  agentName, instanceId, podId,
  type: 'message.posted',
  createdAt: { $gte: new Date(Date.now() - MENTION_LOOP_WINDOW_MS) },
})   // ← no sender field

Human-originated message.posted events for the same target in the same pod fill the same window. So in a pod with four human messages inside five minutes, a bot's first reply-wake to that target is suppressed with no loop present.

Direction of failure is the safe one — it errs toward silence, not toward unbounded reply chains, so it doesn't weaken what D6.3 relies on. But it does mean the sole loop bound is exhaustible by traffic unrelated to any loop, and that's worth knowing when guard 2 gets specified, since guard 2 is meant to be the thing that lets this one relax.

A correction to my own measurement

I first ran the two agentMentionService suites against the PR's file and got Tests: 0 total with both suites failing — and nearly reported this PR as breaking them. It was my harness. I spliced the PR's (main-based) file into a working tree on fix/poll-retry-backoff, whose copy of that file differs from origin/main by 334 insertions / 33 deletions; the drop-in deleted branch code the branch's tests need. Control on the unmodified tree: 70/70 passing. The PR is not implicated.

Not verified: I did not execute the suites against the PR's own tree (the comment-only proof is what stands in for that); I did not run the full backend suite; and I have not measured how often the dampener's window is actually consumed by human traffic in a live pod — the exhaustion path above is read from the query, not observed.

The comment called convergence "D6.3's third guard"; the ADR it points at
calls it guard 2 throughout (1 = dampener, 2 = convergence, 3 = frame).
The comment's whole job is to route a reader to the right section before
they widen this path, so a wrong guard number defeats it.

Comment-only; zero non-comment lines changed.

Co-Authored-By: Claude Opus 5 <[email protected]>
@lilyshen0722

Copy link
Copy Markdown
Contributor Author

Re-gated at 7c8f16fe — approved. Head re-resolved before checking; the previous gate was at 1b6ccedc.

Inertness reproduces. Three-dot diff against origin/main (merge-base 799e0d7d): 2 files, agentMentionService.ts and the ADR. Stripping +/- markers and every //-prefixed line leaves zero non-comment lines. Positive control on the same pipeline: 7 changed lines before filtering, so the filter ran and the empty result is a measurement rather than a broken grep.

I nearly filed the opposite. A two-dot origin/main..pr1205 shows frontend/nginx.conf, frontend/public/404.html and frontend/scripts/nginx-routing.test.mjs as deletions — 58 lines that look like a live-serving change inside a comment-only PR. They are main's commits since the branch point, rendered in reverse. Three-dot is the one that answers "what does this PR do".

The guard-number correction checks out exactly. At 7c8f16fe, counted over the ADR: guard 2 → 6, guard 1 → 4, guard 3 → 0, third guard → 0. Also 0 for second guard and first guard, so the document has exactly one naming convention and the comment now matches it. The comment reads D6.3's guard 2 (convergence).

One count to correct, since it will get quoted. The backend change is 5 insertions / 2 deletions, not 3/3 — git diff --numstat gives 5 2. It does not affect inertness: all seven lines are comments either way. Flagging it only because the surrounding claim was itself a count correction.

What I did not verify: that the convergence guard is genuinely absent from the codebase — I checked the comment against the ADR, not against an exhaustive search for an implementation under another name. And mergeStateStatus is BLOCKED as I write this, which on this repo has usually meant checks re-running rather than a missing gate; I did not wait it out.

@lilyshen0722
lilyshen0722 merged commit 734ef56 into main Aug 25, 2026
11 checks passed
@lilyshen0722
lilyshen0722 deleted the docs/adr018-d63-implicit-reply-addressing branch August 25, 2026 21:28
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