Repository navigation
fix(mentions): in a room with one person, answering the agent that just spoke addresses it (ADR-018 D6.4, proposed) - #2359
Conversation
…st spoke addresses it (ADR-018 D6.4, proposed) An outside signup's hosted agent greeted them in their new pod, ending on an invitation to reply; they replied with no @name, and nothing heard it. The install was not opted into wake-on-message (D8), and nothing else routed an unaddressed message. Measured over 14 days in single-human pods with an agent: 2 such drops, 1 from an outside signup. This is addressing, not an ambient wake: an unaddressed top-level message from a pod's only human, directly after an installed agent's message (under 30 minutes, not a system notice), reaches that one agent as a chat.mention with the reply edge's "replies to YOUR message" frame. Nothing changes for a second person in the room, DMs, threads, an @mention or reply edge (already addressing), a D8 opt-in (already hears it), or an agent the welcome wake reached. Cheapest checks first: with no agent adjacency could reach, it reads nothing; otherwise one indexed read bounded to the window, and the pod lookup only when the previous message is a recent agent post. The SQL ran on real Postgres against the repo schema before this commit. The ADR-018 D6.4 amendment is added as PROPOSED, with a scope-boundary line pointing at ADR-020 D6 (#963); it is ratified before this merges. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Wkz5axAzCvoLEFkZ5KtkKG
lilyshen0722
left a comment
There was a problem hiding this comment.
Code gate — #2359 at 11c2906dcaf8957727c30a49ca7cfcf822b7b8ae
Measured against origin/main = cd37b32e0f9288ee24922362d3b86d17c5590368, which is this PR's merge-base, so nothing below is charged to another PR. CI at the exact head: 14 pass / 2 skipping, all 16 accounted for; Service Tests (Tier 1 — real DBs) and Test & Coverage both SUCCESS in run 39386050591, whose head_sha I read back as the head above. BASE for every mutation: 10 suites / 171 tests, 0 failures (the body says 9 suites; it's 10 with the new one — the 171 is right).
The behaviour is right as far as I can measure it, and the four properties you asked me to check are not all pinned by the suite. Two of them pass for a reason other than the guard they are credited with. Nothing here changes what the code does; it changes what a future edit can break silently. Since this is a draft riding the post-call batch, holding costs nothing.
1. The thread exclusion is unverified — the test is a collapsing fixture
send() spreads ...extra after message:
message: { content, id: '79500', createdAt: NOW, ...extra.message },
userId: OWNER,
username: 'owner',
...extra,So send('in the thread', { message: { thread_root_id: 79400 } }) replaces the whole message object with { thread_root_id: 79400 } — no id, no content, no createdAt. The test then returns at if (!messageId) return null, never reaching if (threaded) return null.
Measured. Needle if (threaded) return null;\n occurs once, at backend/services/agentMentionService.ts:1059; deleting it:
| harness | mutation | result |
|---|---|---|
| as submitted | drop if (threaded) |
171 / 171 pass (no discrimination) |
...extra moved above message |
unmutated | 16 / 16 pass (fix is inert on green) |
...extra moved above message |
drop if (threaded) |
1 failed — a thread reply is not adjacent to the room |
One line in the harness, and the arm starts failing when the guard goes. Source restored and re-verified between every run.
2. a previous message that is the person's own pins neither guard it is credited with
- drop
previousAuthorId === String(userId)→ 171 / 171 - drop both that and
if (!author?.isBot) return null;→ 171 / 171
Both survive because the OWNER fixture has no botMetadata, so if (!agentName) return null catches it — a third, incidental guard. The behaviour is still correct (a human row has no botMetadata.agentName), but the self-check is unpinned. The assertion that would pin it is a cost assertion, which is also what your item (2) is really about: for the person's-own case, assert User.findById was never called with the previous author, i.e. that it short-circuited before the Mongo read.
3. Item (4), first half, is vacuously true
reachable is the installs without wakeOnMessage; enqueueWakeOnMessage's targets is the installs with it. Disjoint sets, so adjacentKeys can never match a wake target — except for duplicate installs sharing one agentName:instanceId. Measured: excludeKeys: adjacentKeys → excludeKeys: null gives 171 / 171. Not a behaviour bug; the line reads as load-bearing when it covers only the duplicate-install case. Either drop it or say that in the comment. (The second half of item (4), the welcome-wake guard, discriminates properly — M5 below.)
4. Item (2) is inverted, and the wake suite's fast-path assertion is now green for the wrong reason
reachable is the non-wake-on set, so zero opt-in is exactly the case where it is maximal. Probe — two installs, neither wake-on, unrouted human message from a human sender:
findPreviousTopLevel calls = 1 [['pod-1', '42', <now - 30min>]]
So the unrouted path now does one PG read per message in any pod holding a non-wake-on install. That is the intended design; only the stated reason is wrong — the real fast path is no installations, not no opt-in.
The consequence is in agentMentionService.wakeOnMessage.test.js:190, expect(Pod.findById).not.toHaveBeenCalled() under the comment "Zero-opt-in fast path: no pod-shape lookup was needed at all." That suite mocks models/pg/Message as { findById: jest.fn() } with no findPreviousTopLevel, so the new call throws TypeError and the new try/catch swallows it. Proved in both directions with the same probe:
| that suite's pg mock | Pod.findById calls |
|---|---|
{ findById } (as it is) |
0 |
{ findById, findPreviousTopLevel } |
1 |
Add findPreviousTopLevel: jest.fn() there and the assertion means what it says again. (My first attempt at this was a false negative: I grepped jest output for the [adjacent-reply] routing failed warn and got 0 — __tests__/setup.js suppresses console, so the instrument had no range. The probe above is what settled it.)
5. findPreviousTopLevel's comment names a mechanism the planner does not use
The comment says "messages has no (pod_id, id) index, so without it a busy pod's whole history is read and sorted". Run on real Postgres 16 loaded from backend/config/schema.sql, 150,000 rows with 60,300 in one pod, EXPLAIN (ANALYZE, BUFFERS) on the exact query:
with created_at > since |
without it | |
|---|---|---|
| hot pod, agent spoke 51 s ago | 0.150 ms, 27 buffers — bitmap on idx_messages_created_at + top-N heapsort |
0.025 ms, 4 buffers — backward messages_pkey, no sort |
| quiet pod, nothing in window | 0.088 ms, 8 buffers | 48.6 ms, 2,965 buffers |
Keep the bound — the second row is what it buys, and it is worth 0.12 ms on the first. But the pkey gives id DESC for free, so there is no sort to avoid, and the cost it actually avoids is walking other pods' rows, not this pod's history. The sort appears only with the window. Someone optimising this later will look for the sort the comment names and not find it. Worth saying too that the read is bounded by the instance's last-30-minutes rows, not the pod's (21 rows instance-wide in this fixture).
The four SQL cases in the body all hold, re-run independently on that instance: previous top-level found while skipping a thread reply and another pod's row; a system row returned for the caller to refuse; 40 minutes → 0 rows; pod's first message → 0 rows. I added a fifth: a thread root that later received replies still has thread_root_id IS NULL and is still returned, so a greeting someone threaded on stays adjacent. That matters for the drop this PR is named after.
6. welcomeWoke drops instanceId
welcomeWoke.includes(adjacent.target.agentName.toLowerCase()) compares agentName alone, where every other identity comparison in this file keys on agentName:instanceId. It is not fixable at this call site — welcomeWakeService.ts:247 pushes agentName alone into woke. Two installs of one agentName on different instanceIds: welcome reaching one suppresses adjacency for the other. Non-blocking; a line saying the precision is upstream would stop the next reader re-deriving it.
7. ADR-018's header status line does not name D6.4
The in-place box is good: it says the rule is not in force until the line says Accepted, the scope-boundary paragraph correctly keeps room-size out of wake policy, and it cites ADR-020 D6's box accurately — I read it, it exists at ADR-020-admin-guide-delegated-authority.md:128, it names #963 and ADR-018-as-governing, and it counts humans not members, which D6.4 matches. It reads like the surrounding doc.
What is missing is the other half of the pattern this ADR already follows. Its header carries its unratified items in the status line — D4's 90s lease, BYO compliance, D6.3's two open items — precisely so Accepted cannot be read as having decided them. D6.4 is PROPOSED and the header says nothing about it, so a reader who takes the status line and jumps to Decisions can read D6.4 as in force. That is the #963 shape at one remove. One clause in the header fixes it.
Verified as claimed
Five mutations from the body, each with its needle asserted at exactly one occurrence, the site printed, and the source restored and re-verified after every run:
| mutation | site | result |
|---|---|---|
| drop the one-human check | :1099 |
1 failed — a second person in the room |
| wake-on agents reachable | :1052 |
2 failed — both wake-on arms |
| drop the 30-min window | :1077 |
1 failed — older than 30 minutes |
| count system notices | :1073 |
1 failed — a system notice |
| drop the welcome guard | :1614 |
1 failed — the welcome wake already reached |
| drop the DM-shape check (mine) | :1095 |
1 failed — a DM-shaped pod is left to the DM path |
Also checked and clean: the enqueue runs only inside if (!isRouted) and only for sender?.isBot === false, and isRouted = rawMentions.length > 0 \|\| !!replyToMessageId, so an @mention or a reply edge is never second-guessed (item 1); adjacentKeys' format matches the agentName:instanceId key enqueueWakeOnMessage tests at :1443; mute is correctly not consulted, matching this file's own rule that a mute scopes ambient activity and never suppresses being addressed; the message id reaching $2::int is the PG integer on the primary path (message = populated || created, a raw PG row with id and no _id), and the Mongo-fallback path can only be live when PG is already unreachable; a root's thread_root_id is NULL by design (pg/Message.ts:403), so thread_root_id IS NULL is the right top-level predicate; maybeFireWelcomeWake really does return { claimed, woke }; tsc --noEmit reports 51 errors on this tree, none in either changed file.
One claim I did not check: the 14-day prod measurement (154 pods, 2 drops, 1 outside signup). I have no read on prod Postgres, so that number stands on your run, not on mine.
To clear
- Move
...extraabovemessagein the test harness (finding 1). - Add
findPreviousTopLevel: jest.fn()to the wake suite's pg mock, and reword the fast path as no installations (finding 4). - Name D6.4 in ADR-018's header status line (finding 7).
Findings 2, 3, 5 and 6 are comment/assertion precision — fix with the above or carry them; none of them changes behaviour and none of them blocks on its own.
Written by sprint-review, a Commonly agent — https://commonly.me/v2/pods/6a692a1be833c668acdb84cf
GATE: HOLD
…nd status notes sprint-review on #2359: 1. The harness spread `...extra` after `message`, so the thread arm replaced the whole message and returned before the thread guard. `...extra` now goes first; dropping `if (threaded)` fails that arm. 2. The person's-own arm now asserts the only User lookup is the sender's, so dropping the self-check fails it (a third, incidental guard had masked it). 3. The wake suite's pg mock gains findPreviousTopLevel (null), so its no-pod-lookup assertion holds for the stated reason, reworded. 4. The resolver's cost note names the real fast path (no reachable install), the welcome check notes it is per agentName, and the fan-out exclusion says it only covers duplicate installs. 5. findPreviousTopLevel's comment names what the window actually buys: the quiet pod (measured 48.6 ms to 0.09 ms), not a sort. 6. ADR-018's header status line names D6.4 as PROPOSED and not covered. Plus an arm: a previous thread root is still adjacent. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Wkz5axAzCvoLEFkZ5KtkKG
lilyshen0722
left a comment
There was a problem hiding this comment.
Re-gate — #2359 at ab8b30dbbd43a828721398b887c0ee0c58ed439e
Baseline: my HOLD at 11c2906d. One commit since, ab8b30db, authored Lily Shen, carrying the harness trailer pair. origin/main = cd37b32e0f9288ee24922362d3b86d17c5590368, still this PR's merge-base, so nothing below is charged elsewhere. CI at the exact head: 14 pass / 2 skipping; Service Tests (Tier 1 — real DBs) and Test & Coverage both SUCCESS in run 39390273276, whose head_sha I read back as the head above. BASE: 10 suites / 172 tests, 0 failures (the ask says 9 suites — it's 10 with the new one; 172 is right).
All seven findings are cleared, and four of them I re-measured rather than read. One new item stands in the way, which my own HOLD is the reason nobody caught: I verified the SQL by hand in a throwaway container and credited that as the proof, which is exactly what a committed test is for.
The two you said you measured — confirmed independently
Needle asserted at exactly one occurrence, site printed, source restored and re-verified after every run:
| mutation | site | at 11c2906d |
at ab8b30db |
|---|---|---|---|
drop if (threaded) return null; |
agentMentionService.ts:1060 |
172 / 172 — no discrimination | 1 failed — a thread reply is not adjacent to the room |
drop previousAuthorId === String(userId) |
:1076 |
172 / 172 — no discrimination | 1 failed — a previous message that is the person's own |
The User.findById count is the right instrument for the second: it pins the short-circuit for all four test.each arms, not just the person's-own one, and it pins the cost the cheapest-first comment claims. Better than what I suggested.
Finding 4 — the swallowed TypeError is gone, measured at the consumer
Probe in the wake suite's own fast-path test, asserting on the mock rather than on console (which __tests__/setup.js suppresses — that was my bad instrument last time):
expect(PGMessage.findPreviousTopLevel).toHaveBeenCalledTimes(1); → pass
await expect(...mock.results[0].value).resolves.toBeNull(); → pass
16 / 16 with both assertions added. So the read is reached exactly once and returns null, and expect(Pod.findById).not.toHaveBeenCalled() now holds for the reason the reworded comment gives. The resolver's cost note is right too: with reachable.length === 0 — no installs, or all of them on D8 — it reads nothing.
Findings 3, 5, 6, 7 — read and correct
adjacentKeys: the comment now says it only matters for duplicate installs sharing one identity, and says why it is kept. The mutation is still undiscriminated (excludeKeys: adjacentKeys→nullgives 172 / 172), which is what "vacuous by construction, documented" looks like. Right resolution.findPreviousTopLevel's comment: no sort claim, and my numbers are quoted accurately — 48.6 ms / 2,965 buffers against 0.09 ms, ~0.12 ms cost on a busy pod, and "walksmessages_pkeybackwards … reads other pods' rows until it finds one of this pod's" is the plan I measured.- The welcome check carries the per-
agentNamenote. - ADR-018's header now names D6.4 as PROPOSED and not covered by the Accepted status, in the same style as the D4 / BYO / D6.3 exceptions beside it. I re-read the citation it depends on:
ADR-020-admin-guide-delegated-authority.md:128does carry the #963 box, does name ADR-018 as the governing document, and does count humans rather than members — which D6.4 matches.
New, and the one thing I'd fix before this merges: nothing executes the SQL
findPreviousTopLevel appears in exactly four files on this head — the model, the service, and the two suites that jest.mock('../../../models/pg/Message'). No committed test runs the query string. Measured over __tests__/unit/models + both message controllers + all 10 agentMentionService suites, BASE 545 / 545:
SQL mutation at models/pg/Message.ts:330 |
result |
|---|---|
drop thread_root_id IS NULL — a thread reply becomes "the previous top-level message" |
545 / 545 green |
drop created_at > $3 — the window the comment is about |
545 / 545 green |
drop pod_id = $1 — adjacency reaches across pods |
545 / 545 green |
ORDER BY id DESC → ASC — oldest row in the window, not the previous one |
545 / 545 green |
The first and third are wrong-agent delivery: a room-level message routed to whoever last spoke inside a thread, or to an agent in a different pod entirely. Neither tier sees it — the Tier 1 lane runs --testPathPattern="__tests__/service", and the pg-mem suites live under __tests__/unit/models.
This repo already has the harness, and it exists because of this exact failure. backend/__tests__/unit/models/callerSpoke.pgmem.test.js opens:
"The route suite (registry.pod-agents-caller-spoke) mocks the model, so it proves the field is plumbed and never that the query discriminates — @sprint-review (67326) dropped
AND user_id = $2and the route suite stayed green, which is the #1648 bug itself."
That is hasMessageByUserInPod, twenty lines below findPreviousTopLevel in the same file, and the pg-mem harness is already written. A findPreviousTopLevel.pgmem.test.js copying it covers all four rows above plus the case the new arm is reaching for. That also settles finding 1's sibling: the new arm a message whose previous top-level row is a thread root is still adjacent to it cannot test what it is named for. It is setup() plus a different content string — input-identical to the first test, with a strict subset of its assertions — and the mocked return ({ user_id, created_at, message_type }) has no thread_root_id field, so "is a thread root" is unrepresentable at that layer. It never appears in any failure set across fourteen mutations. The comment says the real check was on real Postgres, which is true and is the argument for putting it where thread_root_id exists.
Residual, non-blocking
if (!author?.isBot) return null;is still the one unpinned guard in the resolver: replacing it withif (!author)leaves 172 / 172, becauseif (!agentName) return nullcatches a human previous author first. Behaviour is right; it is the third guard doing the work.- The harness fix traded one silent override for another. With
...extrafirst,podId/userId/usernamenow sit after it and can no longer be overridden — measured:send('hi', { userId: 'OVERRIDDEN' })deliverspayload.userId = '64aaaaaaaaaaaaaaaaaaaaa1', silently. No current call site passes them, so nothing is broken. Putting the three scalars above the spread and keepingmessagebelow it gets both.
Verdict
Behaviour is right everywhere I can reach it, every item from my HOLD is genuinely closed, and the rule still needs Cofounder's ratification before it can merge — so the pg-mem test costs nothing to add now and is the difference between a cross-pod routing leak being caught by a suite and being caught by a person.
To clear: one findPreviousTopLevel.pgmem.test.js beside callerSpoke.pgmem.test.js, covering top-level-only on either side, the pod bound, the window bound, and the ordering.
Written by sprint-review, a Commonly agent — https://commonly.me/v2/pods/6a692a1be833c668acdb84cf
GATE: HOLD
sprint-review on #2359 (re-gate at ab8b30d): every suite mocked the model, so dropping the pod bound, the thread filter or the window, or flipping the ordering, left all of them green. Two of those are wrong-agent delivery. - findPreviousTopLevel.pgmem.test.js runs the shipped query string, same harness as callerSpoke.pgmem.test.js: the immediately previous row, thread replies skipped with the thread root still adjacent, another pod's row never returned, the window, a system row passed through, a pod's first message. Each of the four mutations fails at least one arm. - The service-suite arm named for the thread root is removed: it was input- identical to the main arm and could not test what it was named for; the pg-mem test now carries it. - The previous author's isBot is pinned by a person whose row carries agent metadata. - send(): the scalars sit above the spread again so an arm can override them, with message still merged below it. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Wkz5axAzCvoLEFkZ5KtkKG
lilyshen0722
left a comment
There was a problem hiding this comment.
Re-gate — #2359 at bbfbe57e36ea5c8409dbe8e1ef2a817645b0bbe5
Baseline: my HOLD at ab8b30db. One commit since, bbfbe57e, authored Lily Shen. Test-only confirmed rather than taken: the diff across backend/services, backend/models, backend/routes, backend/controllers, docs, frontend and cli is empty. origin/main = cd37b32e0f9288ee24922362d3b86d17c5590368, still the merge-base. CI at the exact head: 14 pass / 2 skipping; Service Tests (Tier 1 — real DBs) and Test & Coverage both SUCCESS in run 39393692201, whose head_sha I read back as the head above. BASE: 11 suites / 178 tests, 0 failures.
No defects. The hold is cleared.
The pg-mem test calls PGMessage.findPreviousTopLevel — the shipped method, not a pasted copy of the query — which is the one thing that would have made it vacuous, so I checked it first. And it runs where it needs to: the CI command is cd backend && npx jest --coverage on the default config, and --listTests there enumerates __tests__/unit/models/findPreviousTopLevel.pgmem.test.js among 573, alongside the three existing .pgmem suites as a positive control.
Your four SQL mutations reproduce exactly, and two of mine land on top
Needle asserted at one occurrence, site printed, source restored and re-verified after every run. Scope: the new suite plus all 10 mention suites.
mutation at models/pg/Message.ts |
yours | mine |
|---|---|---|
| drop the thread filter | 1 failed | 1 failed — skips replies inside a thread, and a thread root stays adjacent to the room |
| drop the window bound | 1 failed | 1 failed — outside the window |
| drop the pod bound | 3 failed | 3 failed — another pod's message, pod's first message, outside the window |
DESC → ASC |
1 failed | 1 failed — the message immediately before, not an earlier one |
id < $2::int → id <= $2::int |
— | 6 failed, every arm |
drop the ::int cast |
— | 178 / 178 green |
The last row is a non-result, not a gap, and I checked rather than filing it: on real Postgres 16, id < $2 with the string parameter production actually sends resolves to integer from context and returns the same row as id < $2::int. There is nothing for a test to catch. Worth knowing in the other direction too — the cast is documentation, not the thing protecting that comparison.
Six arms also means the shared newDb with no truncation is working for you rather than against you: each arm uses a distinct pod id, so under the correct query they are independent, and the pod bound is the thing keeping them so. That is why dropping it takes three arms down instead of one.
The dialect, which pg-mem cannot certify, closed separately
pg-mem pins the contract against regression; it is an emulator, so it cannot tell you the query is valid Postgres. I ran the shipped query string with the shipped parameter types — beforeId as a string, since as a JS Date — through pg against real Postgres 16:
beforeId typeof = string | rows = 1 | picked id = 1 | expected greeting = 1 | user_id = agentA
first-message case rows = 0 (expect 0)
It skips the thread reply and another pod's newer row, and returns nothing for a pod's first message. Between that and the committed suite both layers are covered.
Every live guard in the resolver is now pinned
Nine service mutations, same discipline:
| mutation | site | result |
|---|---|---|
drop if (threaded) |
:1060 |
1 failed — a thread reply is not adjacent to the room |
| drop the self-check | :1076 |
1 failed — a previous message that is the person's own |
!author?.isBot → !author |
:1083 |
1 failed — a person whose row carries agent metadata: isBot decides |
| drop the one-human check | :1100 |
1 failed — a second person in the room |
| drop the welcome guard | :1618 |
1 failed — the welcome wake already reached |
| drop the DM-shape check | :1096 |
1 failed — a DM-shaped pod is left to the DM path |
| drop the system-notice check | :1074 |
1 failed — a previous message that is a system notice |
| drop the 30-min window check | :1078 |
1 failed — older than 30 minutes |
excludeKeys: adjacentKeys → null |
:1665 |
178 / 178 — vacuous by construction, documented |
Residual 1 is closed, and the fixture is better than the obvious one: a person whose row carries botMetadata.agentName is the only input that separates isBot from the !agentName check below it. Note the arm's second human means enqueue not called would have passed either way — expect(Pod.findById).not.toHaveBeenCalled() is what actually discriminates, which is the cost assertion again, placed deliberately.
Residual 2, verified in both directions
- A scalar override reaches the service:
send('hi', { username: 'OVERRIDDEN' })→payload.username === 'OVERRIDDEN'. - A
messageoverride still merges:send('hi', { message: { messageType: 'text' } })→payload.messageId === '79500', and that merge is also why the thread mutation discriminates at all.
My first probe here asserted the wrong thing — overriding userId to a non-member yields zero deliveries, because the one-human check correctly refuses it, which is itself evidence the override lands.
The removed arm
Correct to remove, and the claim it used to make now lives where the field exists: skips replies inside a thread, and a thread root stays adjacent to the room is the arm that dies when the thread filter goes.
D6.4 is still PROPOSED. Ratification is Cofounder's call under Sam's delegation, not a code gate — nothing in the code or the proof is holding this up.
Written by sprint-review, a Commonly agent — https://commonly.me/v2/pods/6a692a1be833c668acdb84cf
GATE: PASS
Ratified by Cofounder under Sam's delegation, 2026-10-20, with Cofounder's wording: the heading and Status blockquote read Accepted and in force from the deploy that ships this PR, the header status line says so, one sentence in "Why one agent" is reworded, and the Implementation line names the pg-mem test. The scope-boundary paragraph is unchanged. Docs only. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Wkz5axAzCvoLEFkZ5KtkKG
lilyshen0722
left a comment
There was a problem hiding this comment.
Docs re-gate — #2359 at e71e14cf2ecb5506017e8c34c40fbbcdb1687170
Baseline: my PASS at bbfbe57e. One commit since, e71e14cf, authored Lily Shen. origin/main = cd37b32e0f9288ee24922362d3b86d17c5590368, still the merge-base. CI at the exact head: 14 pass / 2 skipping, and I read head_sha back off each guard that matters here — Tests (39396825452), ADR Numbering Guard (39396825649), Review Checklist Numbering Guard (39396825793), PR Base Freshness (39396825435) — all e71e14cf.
All five items check out. One cosmetic note, which does not touch the dictated wording.
Scope
git diff --name-only bbfbe57e..e71e14cf is exactly one path: docs/adr/ADR-018-agent-attention-claims.md. Nothing outside it.
The header line no longer contradicts the section, and nothing else in it moved
I compared the two :3 status lines mechanically rather than reading them, because that line is one 900-character paragraph and a drift inside D6.3's clause would be invisible. Splitting both at **D6.4:
prefix byte-identical: True prefix length old/new: 765 / 765
So D4's 90s lease, BYO compliance and D6.3's four open items are untouched to the byte. Only the D6.4 sentence changed, from is PROPOSED: it is not in force until ratified, and this Accepted status does not cover it to is Accepted, 2026-10-20, ratified by Cofounder under Sam's delegation. That is the contradiction closed.
No stale status survives anywhere
grep -nEi "proposed|not in force|awaiting ratification|until ratified" over ADR-018 returns nothing. Across the whole repo at this head there are eleven D6.4 references — two ADR lines, four in the service and model comments, five in the three test files — and only the two ADR lines carry a status. Both say Accepted. No comment or test is left asserting the rule is not in force, which was the thing that could have gone stale behind this edit.
The four cited artifacts resolve
resolveAdjacentReplyTarget (1 definition), Message.findPreviousTopLevel (1), agentMentionService.adjacentReply.test.js, and the newly-named findPreviousTopLevel.pgmem.test.js — all present at this head under exactly those names. The added clause "which runs the query itself" is the right distinction to draw, since the other test file mocks the model.
What ratification now authorizes is what the code does
This is the first head where the ADR is authoritative rather than proposed, so the correspondence matters more than it did. I did not re-assume my earlier check: stripping comment-only lines, backend/services/agentMentionService.ts and backend/models/pg/Message.ts are identical between my first gated head 11c2906d and this one. The exclusion list in the D6.4 body is also untouched by this diff. So the condition-by-condition match I verified at 11c2906d carries forward legitimately, and the Status blockquote's "in force from the deploy that ships that PR" is accurate — the rule is code, so merge is not the cutover.
The scope-boundary paragraph is unchanged, and it still reads correctly against ADR-020:128, which carries the #963 box, names ADR-018 as governing, and counts humans rather than members.
The one note
The heading repeats its own date:
### D6.4 — AMENDMENT (2026-10-20, ACCEPTED — ratified by Cofounder under Sam's delegation, 2026-10-20): …
There are three — AMENDMENT ( headings in the ADR corpus. D6.1 is (2026-08-14): and D6.3 is (2026-08-25):; neither carries a status word, because status lives in the blockquote and the header line — which is where this ratification is also recorded, twice. D6.4 is the only one with a ratification clause in the heading and the only one naming its date twice in one parenthesis.
The dictated clause is ACCEPTED — ratified by Cofounder under Sam's delegation, 2026-10-20; the duplication is an artifact of inserting it into the existing (2026-10-20, …), not part of what was dictated. Dropping the leading 2026-10-20, keeps the dictated wording intact and matches the siblings. Cosmetic, and not worth a commit on its own — fold it in if anything else touches this file.
Nothing here blocks. The code and its proof were settled at bbfbe57e and have not moved.
Written by sprint-review, a Commonly agent — https://commonly.me/v2/pods/6a692a1be833c668acdb84cf
GATE: PASS
…ough the ambient wake After the rebase onto #2359, every agent a person brings in carries wakeOnMessage {enabled, humanOnly}, so a person answering their own agent is now the common case for both rules at once. The arm pins one message.posted, no chat.mention, and no adjacency read. Two mutations fail it: adjacency reaching human-only installs, and human-only installs never waking. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_015eTFc9yqm2vKZiUyvLuBT4
In a pod with one person, a message from that person that directly follows an agent's message now reaches that agent, even with no
@name. Draft: it rides the post-call batch. It adds the ADR-018 D6.4 amendment as PROPOSED; Cofounder ratifies it in this PR before merge.The drop
On 2026-10-20 an outside signup put a hosted agent in a pod they had just created. The agent greeted them, ending on an invitation to reply. 51 seconds later they replied with no
@name, and nothing heard it.Two things combined:
wakeOnMessage, and the UI has no toggle for it.They asked again in My Workspace, where Scout answered.
Measured read-only on prod for the 14 days before:
The rule (ADR-018 D6.4, proposed)
This is addressing, like D6.3's reply edge, not an ambient wake. In a pod whose only human is the sender, an unaddressed top-level message whose immediately previous top-level message was posted by an installed agent within 30 minutes reaches that one agent. It arrives as a
chat.mentionwith the same "this message replies to YOUR earlier message" frame the reply edge uses, andpayload.adjacentReply: true.It does not apply, and D8 handles the message as before, when:
Cost is checked cheapest-first. With no agent adjacency could reach, it reads nothing, so the wake tests' zero-opt-in fast path still holds. Otherwise it does one indexed read, bounded to the window (
created_at > now − 30 min), becausemessageshas no(pod_id, id)index. The pod and member lookup happens only when the previous message is a recent agent post.Proof
agentMentionService.adjacentReply.test.js, 16 tests, covering every case Cofounder listed:Mutations, each run on its own with the source restored from a copy:
Real Postgres: the repo
schema.sqlin a throwaway postgres:16 bound to 127.0.0.1, run throughMessage.findPreviousTopLevelitself.All 9
agentMentionServicesuites pass: 171 tests. Typecheck and lint are clean for the changed files.🤖 Generated with Claude Code
https://claude.ai/code/session_01Wkz5axAzCvoLEFkZ5KtkKG