Repository navigation
feat(threading): explicit thread_root_id, with derivation as the fallback - #1128
Conversation
Found by checking the seam between #1128 and #1120 rather than assuming it: the controller does `message = (populated || created)` and hands THAT to enqueueMentions, and `findById` projects an explicit column list that did not include thread_root_id. So the ambient scoping hook read undefined for EVERY message and silently never scoped. Not a bug #1128 introduced — 3/4's hook has never fired on a real message — but #1128 makes it matter, because an explicit root with no reply edge is now the primary in-thread shape. Every 3/4 test passed throughout, because they construct the message object directly with thread_root_id set and so never travel the create -> findById path. A test that builds the shape the code under test never receives cannot find a projection bug; only a round trip can. Three added, including the explicit-root shape and one asserting the KEY is present with a null value, since a missing key and a null read identically to a truthiness check but only one of them hides a dropped column. Both projections fixed: findById and findByPodId. Also teaches the schema-table helper about retrofits. `payload` and thread_root_id are added by ALTER, not inside the CREATE, so createTableFor alone was not the table — the fixture failed as "column payload does not exist" a long way from the cause. applyTable runs the CREATE plus its ALTERs, which is the two-declaration rule applied to fixtures. Co-Authored-By: Claude Opus 5 <[email protected]>
Found by checking the seam between #1128 and #1120 rather than assuming it: the controller does `message = (populated || created)` and hands THAT to enqueueMentions, and `findById` projects an explicit column list that did not include thread_root_id. So the ambient scoping hook read undefined for EVERY message and silently never scoped. Not a bug #1128 introduced — 3/4's hook has never fired on a real message — but #1128 makes it matter, because an explicit root with no reply edge is now the primary in-thread shape. Every 3/4 test passed throughout, because they construct the message object directly with thread_root_id set and so never travel the create -> findById path. A test that builds the shape the code under test never receives cannot find a projection bug; only a round trip can. Three added, including the explicit-root shape and one asserting the KEY is present with a null value, since a missing key and a null read identically to a truthiness check but only one of them hides a dropped column. Both projections fixed: findById and findByPodId. Also teaches the schema-table helper about retrofits. `payload` and thread_root_id are added by ALTER, not inside the CREATE, so createTableFor alone was not the table — the fixture failed as "column payload does not exist" a long way from the cause. applyTable runs the CREATE plus its ALTERs, which is the two-declaration rule applied to fixtures. Co-Authored-By: Claude Opus 5 <[email protected]>
ed4a954 to
0e1cc83
Compare
lilyshen0722
left a comment
There was a problem hiding this comment.
Small note on schemaTable.js, scoped carefully because my first version of it was wrong.
applyTable (CREATE + retrofits) is the right primitive and threadRootResolver.test.js uses it, with a comment saying why. The other two consumers still call createTableFor('messages'):
threadRootResolver.test.js applyTable('messages') ← retrofit-aware
threadFollowByParticipation.test.js createTableFor('messages')
threadStateReadContract.test.js createTableFor('messages')
What that actually costs today: one column, and it fails loudly. I checked the DDL rather than assuming symmetry — thread_root_id is declared in both the CREATE TABLE and an ALTER (the two-declaration rule this repo now enforces), so createTableFor does produce it. The only CREATE-absent column is payload JSONB, which exists solely as a retrofit. A fixture built with createTableFor therefore differs from the shipped table by payload alone, and since PGMessage.create names payload in its INSERT, any suite that reaches the real create against such a table errors on a missing column rather than passing quietly.
So this is not a live defect, and I want to be explicit that my first read of it — "two of three callers still use the pre-retrofit helper" — implied more than the evidence supports.
The reason it's still worth three characters: the next retrofitted column will not necessarily fail loudly. A column with a DEFAULT, or one that is only ever read, produces a fixture that diverges from shipped DDL and stays green — which is precisely the class applyTable was written to close, and the same shape as the silently-dropped FK found in these suites this morning. Two of the three call sites are still positioned to reproduce it.
Making all three use applyTable costs nothing and removes the choice from the next author.
Not verified: I did not run either suite, so I have not confirmed they currently pass — only that their fixture lacks payload and that create would surface it. Neither appears to exercise the production create path, which is why the gap is inert rather than red.
lilyshen0722
left a comment
There was a problem hiding this comment.
Re-verified at 18bdbaf0, as asked. All three findings hold; every line number in the discussion is stale, including the ones in the request to re-verify.
:221 INSERT INTO migration_records (zero-edges branch) threadingCutoff: null → :225
:307 INSERT INTO migration_records (normal branch) threadingCutoff: boundary.cutoff → :313
:141 export const CUTOFF_SQL = `SELECT MAX(created_at) …`
BEGIN / COMMIT / ROLLBACK: 0 occurrences
The request cited :162 and :241; they are now :221 and :307. That is the same property being described, demonstrated on the message describing it — which is the argument for citing a symbol and a sha rather than a line, since the symbol survives every push and the line survives none.
1. The normal branch still derives the cutoff from data, and that is now a contradiction with main rather than a design question. #1131 merged at 18:29:58 carrying:
The cutoff is never computed from the data …
MAX(created_at)over un-rooted edges is wrong as soon as a retention-orphaned descendant is recent … The cutoff is a known event, not a measurement.
:313 writes boundary.cutoff, which is exactly that MAX. The zero-edges branch you added at :221 is correct and was the harder case; the branch that runs on every real instance is the one still on the old rule.
2. CUTOFF_SQL is still exported at :141. Under the merged ruling this function computes a value the doc says must never be computed. Leaving it exported is the risk, not leaving it called — it is the only thing in the file that looks like it answers "what is the cutoff", so it will be reached for.
3. Still no transaction. Unchanged, and it now carries more weight than when I first raised it: with the probe retired, "the backfill always writes the ledger row" is the sole remaining guarantee between a partial run and a permanently unknown cutoff. Two independent statements, no atomicity, and the script's own comment says the boundary cannot be re-derived afterwards.
What survived that I would keep as-is: the boundary read at :212 genuinely precedes the UPDATE at :222, ON CONFLICT (name) DO NOTHING is on both inserts, and the zero-edges write closes the "fresh instance sits permanently expanded" hole. Those three were the substance of the original design and they are intact.
Not verified: I did not run the script or the suite at this head — these are reads of the source at 18bdbaf0, and the CI on that head is still pending as I write.
f94fdc6 to
1a0881d
Compare
…et (TASK-029 3/4) effective = (participants union explicitFollowers) minus muted, per fable's #1045 ambient-only ruling, ux-lead 56822 and sprint-review 56823. participants are derived at read from messages and never stored: it is a fact about the conversation, and materialising it would create a second writer that can disagree with the first. That is the tri-state's following IS NULL case. Mentions become explicit rows at the moment they happen (followByParticipation) rather than being re-derived from history forever. muted is subtracted LAST, because an explicit mute outranks participation. One query, not three — the terms are correlated and this path runs for every threaded reply. narrowToThread only ever NARROWS. Threading is additive and must not start delivering to seats that never opted in to anything. Two deliberate degradations, both toward today's behaviour rather than toward silence: a target whose user id cannot be resolved is KEPT, and a scoping query failure returns the unscoped list. A wake that vanishes because scoping could not classify it is the failure nobody reports. Not the addressing path — an explicit @mention wakes its target whether or not they follow or muted the thread. isRouted short-circuits before the ambient branch, so that path never reaches this service. 15 cases executed on pg-mem. Includes the root author (whose own thread_root_id is NULL, so the obvious query omits the person who started the thread) and a collapse-only row conferring nothing. Co-Authored-By: Claude Opus 5 <[email protected]>
… 3/4) enqueueWakeOnMessage narrows its opt-in list through narrowToThread when the message carries a thread root, keyed on installedBy — the bot User id thread_user_state holds. Writing the test corrected a belief I had stated twice in the pod: that isRouted short-circuits before any ambient fan-out, so a routed message never reaches scoping. It does reach it. There are TWO wake call sites — :1157 for unrouted messages and :1470 for routed ones, the latter waking opt-ins who were not mention targets. The code was right and the assumption was wrong, and the truth is the better invariant: an addressed message delivers its chat.mention unconditionally, while the AMBIENT fan-out accompanying it is scoped like any other ambient traffic. Addressing is untouchable; its ambient companion is not, and should not be — an opt-in who neither follows the thread nor was addressed has no claim on it. Ten cases, three of them controls, because every core assertion here is that something did NOT happen. Co-Authored-By: Claude Opus 5 <[email protected]>
I asserted twice in the pod that isRouted short-circuits before any ambient fan-out, so a routed message never reaches wake-on-message. It is false: enqueueWakeOnMessage has a second call site ~310 lines later, for routed messages, waking the opt-ins the mention path did not reach. An early return bounds the statements below it, never a helper a later call site re-enters. Both sites now name the other, and the correction is stated at the site that produced it — fixing the belief and not the surface is how a peer reproduces it next week. Co-Authored-By: Claude Opus 5 <[email protected]>
@ux-lead 56820 (doc 5e7060f on #1107): once rows exist for non-followers, every reader of follow state must filter on following, never on EXISTS(row). I had the two neighbours — muted with collapsed at its default, and collapse-only with following NULL — but not the combination they named. (following=false, collapsed=false) is the discriminating one precisely because it is the row most likely to be mistaken for engagement: it exists, and the user actively opened the thread. Neither fact is consent to be woken. Also covered with that user as the ONLY participant, so the empty set cannot be masked by someone else being in it. Two controls, because every assertion above is that a wake did not happen: the same row with following=true DOES wake, and with following=NULL falls back to participation. All three tri-state values are now exercised here rather than two. Plus a structural backstop asserting the query says `following IS TRUE` and contains no EXISTS over thread_user_state, so a rewrite that reintroduces row-presence is flagged even if it passes the cases. This suite also still hand-wrote its tables, which is the correction @sprint-review made on 2/4's suites (56811) and I had not carried across. Now built from schema.sql, which brought the real FK to messages with it — roots referenced by state have to be real rows. Co-Authored-By: Claude Opus 5 <[email protected]>
@ux-lead 56822 (392b86e on #1107): "a participant at (NULL, collapsed=false) is woken; the SAME participant at FALSE is not." Both halves existed but as separate cases with different users on different roots, so a difference in outcome could in principle have come from something other than `following`. These flip exactly one field on one row and assert the wake set changes by exactly that user, stated as a set difference so a change in the wrong direction or affecting someone else fails rather than passing on length. Three cases: NULL -> FALSE removes them, FALSE -> NULL restores them (a one-way test passes against code that simply stops waking people), and flipping `collapsed` with `following` held at NULL changes nothing — the field that must not matter, asserted as not mattering. Co-Authored-By: Claude Opus 5 <[email protected]>
Same correction as the 2/4 commit, for this branch's own suite. @ux-lead 56830: #1107 and #1112 were both squash-merged, so 5e7060f and 392b86e — which I cited here — are on neither main. They resolve in a clone that still has the branches and nowhere else. The rules themselves ARE on main; verified by content in docs/design/threading-surface-ruling.md, not by sha. Co-Authored-By: Claude Opus 5 <[email protected]>
Found by checking the seam between #1128 and #1120 rather than assuming it: the controller does `message = (populated || created)` and hands THAT to enqueueMentions, and `findById` projects an explicit column list that did not include thread_root_id. So the ambient scoping hook read undefined for EVERY message and silently never scoped. Not a bug #1128 introduced — 3/4's hook has never fired on a real message — but #1128 makes it matter, because an explicit root with no reply edge is now the primary in-thread shape. Every 3/4 test passed throughout, because they construct the message object directly with thread_root_id set and so never travel the create -> findById path. A test that builds the shape the code under test never receives cannot find a projection bug; only a round trip can. Three added, including the explicit-root shape and one asserting the KEY is present with a null value, since a missing key and a null read identically to a truthiness check but only one of them hides a dropped column. Both projections fixed: findById and findByPodId. Also teaches the schema-table helper about retrofits. `payload` and thread_root_id are added by ALTER, not inside the CREATE, so createTableFor alone was not the table — the fixture failed as "column payload does not exist" a long way from the cause. applyTable runs the CREATE plus its ALTERs, which is the two-declaration rule applied to fixtures. Co-Authored-By: Claude Opus 5 <[email protected]>
fa7b70d to
0297fe6
Compare
@sprint-review's blocker on this PR (57291): `m.thread_root_id` count 0. They were right, and it is 3/4's bug rather than 4/4's — this is the PR whose feature is inert without it, so the fix belongs here. The hook reads `message.thread_root_id`. The controller does `message = (populated || created)` and hands THAT to enqueueMentions, so the object the hook receives is findById's row, not create()'s RETURNING *. findById projects an explicit column list that did not name the column. Ambient scoping therefore read undefined for every message and silently never scoped — the feature has never fired on a real message. Every 3/4 test passed throughout, because they construct the message object directly with thread_root_id set and never travel create -> findById. A test that builds the shape the code under test never receives cannot find a projection bug; only a round trip can. Four round-trip tests, and the mutation probe is paired rather than wholesale: dropping BOTH projections kills 4 of 4, dropping only findByPodId's kills exactly 1. That second run is the one worth having — the column list is written twice, and fixing the copy a failing test names while leaving the other wrong is a mistake already made once here. The fixture builds pods, users and messages from schema.sql via applyTable rather than by hand. The first attempt typed VARCHAR(255) keys against schema.sql's VARCHAR(24) and died on a foreign-key type mismatch — a fixture drifting from the DDL is the same class of defect as the projection this file exists to catch. Co-Authored-By: Claude Opus 5 <[email protected]>
… User row @sprint-review's second blocker on this PR (57291). They were right, and the comment I had written above the call asserted the opposite: "Keyed on `installedBy` — the bot's User row id". `installedBy` holds two different identities depending on who installed the agent. The bot's own User row at agentAutoJoinService:80, podWriteAccessService:48 and three sites in agentsRuntime; the HUMAN caller at podController:119, personaHireService:93, podCurationService:147, authController:201 and agentProfile:259. AgentRun.ts:65 calls it "the hiring user" outright. The schema declares a bare ObjectId with no ref, so nothing at the type level separates the two, and the name reads like the second meaning while the comment claimed the first. thread_user_state.user_id is the BOT's User row id — the follow/mute routes are dualAuth, so an agent writing its own thread state writes under `req.agentUser._id`. Keying on installedBy would therefore have read a human-installed agent's thread state off its INSTALLER's row: the human's mute silences the agent, and the agent's own mute is ignored. Wrong in both directions, and invisible on any fixture where the two ids coincide — which is why the test I had written passed. Resolves the bot User row by (botMetadata.agentName, botMetadata.instanceId) instead. One query for the whole target list, not one per target. A failure returns an EMPTY map rather than throwing, so every identify() returns null, narrowToThread keeps every target, and scoping degrades to today's unscoped delivery — losing the narrowing is a noisier pod, losing the wake is a message nobody sees. The fixture now gives installedBy a DIFFERENT value from the bot user id, so the assertion can discriminate; with them equal it could not. Four tests: the correct key, the unresolvable install keying to null so it is kept, the lookup failing closed to unscoped delivery, and one query rather than N. Mutation probe: restoring the installedBy callback kills 3 of the 4. Co-Authored-By: Claude Opus 5 <[email protected]>
0297fe6 to
710de36
Compare
@sprint-review's third blocker on 3/4 (57306). The service header asserted "the mention writes the row at the moment it happens, via ThreadUserState.followByParticipation". Nothing calls it. The method shipped with passing tests and the only thing claiming it was wired was prose — which is why nobody noticed: a false comment reads exactly like a true one. Consequence, stated plainly rather than implied: a user @-mentioned in a thread who never posts is not an effective follower, so they stop receiving its ambient activity. A spec gap, not a regression — the mention itself still wakes them, because addressing never passes through this service. Not closing the gap here. A synchronous Postgres write on the mention hot path is a decision about where and how often, not a line to slot in wherever it compiles, and 3/4 is not the place to make it quietly. The guard is executable in BOTH directions, because a comment nobody can run is what produced this. It fails if a production caller appears while the header still says there is none, and fails if the header stops saying so while there is still no caller. Control run: dropping a fake caller into services/ turns it red, so the test can actually fail. Co-Authored-By: Claude Opus 5 <[email protected]>
710de36 to
32fca5a
Compare
…ne way @sprint-review (57311), both notes, and both were right about the thing I had just described as running in two directions. 1. Test 1 asserted `claimsUnwired === true`, which meant test 2's else could never execute. The second direction was carried entirely by test 1, and the branch I pointed at as the mechanism was decoration. Now test 1 asserts EXACTLY ONE of two markers is present, so swapping the marker makes the other branch live. Softening to unstructured prose matches neither and fails, so vagueness is still not a pass. 2. The marker ended a line, one reflow away from splitting across a newline and turning a true claim false. Collapsing whitespace was my first fix and it was insufficient: inside a block comment a reflow leaves the ` * ` gutter mid-phrase, so `NOTHING\n * CALLS IT` flattens to `NOTHING * CALLS IT` and still misses. Strip the gutter, then collapse. I only know that because the probe ran the scenario the fix existed for and it was the one scenario still red. A normalisation asserted rather than exercised would have shipped looking correct. Six probes, each restoring the file afterwards: reflow with gutter (pass), reflow without (pass), softened prose (fail), wired-claim-no-caller (fail — the branch that used to be dead), wired-claim-with-caller (pass), unwired-claim-with-stray-caller (fail). Both directions of test 2 now demonstrably fire. The service header tells whoever closes TASK-045 to swap the marker, and deliberately does NOT quote the other one — writing both out is how this commit first went red, which is the guard working on its own author. Co-Authored-By: Claude Opus 5 <[email protected]>
…back @ux-lead's 56879 amendment, which settles the constraint-4 question I raised at 12:22. An ordinary in-thread post carries NO reply edge — the composer names the root directly — so joining a thread never makes the message isRouted and never pings the root's author. Derivation from reply_to stays for explicit replies and for the backfill. services/threadRootResolver reconciles the two shapes in one place: explicit wins when present, derivation fills when absent, and a MISMATCH is a 400 rather than a silent preference. A caller who says "reply to X" and "this belongs to thread Y", where X is not in Y, holds a wrong belief about the conversation; picking a winner hides that from them. Validation is about the ROOT, not the poster — whether they may write here is pod membership, answered upstream. Rejected: a root that does not exist, a root in another pod (attaching to a conversation the caller may not be able to read, and the wake set comes from the thread, not the pod), a root that is itself inside a thread (two ids for one conversation splits every consumer that groups by root), a non-integer, and the mismatch. Each carries a code so the route need not parse text. The model takes an already-RESOLVED root and does not decide precedence: COALESCE($7, <derivation>) is the whole rule in the SQL. A resolver failure that is not a caller error re-throws rather than defaulting to null, since silently dropping a message into no thread is the data loss this column exists to prevent. 12 executed cases including a CONTROL that valid input still succeeds, without which every rejection could come from a resolver that rejects everything. Also fixes three of my own tests that were pinning implementation details rather than contracts: they asserted the local variable name feeding `expandedForRootsCreatedBefore` and the exact literal of a catch body, and broke on my own rename. They now assert the key and the degradation. Found because I ran the new suite and not the existing one — the same miss as earlier today. Co-Authored-By: Claude Opus 5 <[email protected]>
…s fixed The Message.ts half of this commit moved to 3/4 (#1120), where the bug it fixes actually lives: findById's projection dropped thread_root_id, so the ambient scoping hook read undefined for every message. 3/4 is the PR whose feature is inert without it, so the fix belongs there rather than here. What stays is the part specific to this PR: the resolver's own round trip through create -> findById, including the explicit-root shape that has no reply edge at all. That shape is why the projection bug matters more here — after @ux-lead's 56879 amendment an ordinary in-thread post carries only thread_root_id, so a dropped column is the whole signal rather than a redundant one. Co-Authored-By: Claude Opus 5 <[email protected]>
CI caught this: calling resolveThreadRoot unconditionally added a query the controller tests do not mock and broke seven of them. I had run the model suites on this branch and not the controller suite — the same miss as earlier today, and the reason the surrounding suites are worth running rather than the file just written. The redundancy is real independently of the breakage. With no explicit threadRootId the resolver only re-derives COALESCE(parent.thread_root_id, parent.id), which the INSERT already does — a query per message that changes nothing. There is nothing to reconcile until there are two claims about the same message. Gated on an explicit threadRootId. The no-root path still passes null through to create, so derivation continues to happen in SQL: "no explicit root" must mean "let the INSERT derive it", never "no thread root". Three cases pin it, including the behavioural half — a plain reply still gets its root with the resolver never called. Co-Authored-By: Claude Opus 5 <[email protected]>
CI caught the third instance of the same miss. Adding a 7th parameter to
PGMessage.create broke an argument-list assertion in
__tests__/service/messages.test.js; I had fixed the unit-tier one in
PgMessage.test.js and never ran the service tier.
Twice before today I ran the file I wrote and not its neighbours. This
time "neighbours" meant another TIER, which is a wider radius than I had
been applying — the unit and service suites assert the same call from
different directions and only one of them was in my habit.
Swept the whole tree for assertions on create's argument list. There are
THREE, not two:
__tests__/unit/models/PgMessage.test.js — updated earlier
__tests__/service/messages.test.js — updated here
__tests__/service/pgMessages.test.js:97 — unaffected, and checked
rather than assumed: the legacy route still calls create with three
arguments (pgMessageController:157), so an exact-match assertion of
three still holds. Confirmed PASS in CI run 32590924788, because
that suite cannot load locally under Node 26.
The null is commented as "let the INSERT derive one" rather than "no
thread" — the distinction that matters if anyone reads the fixture later
and decides the parameter is decorative.
Co-Authored-By: Claude Opus 5 <[email protected]>
32fca5a to
d5b8ef9
Compare
…en (#1135) * docs(ax): entry 41 — a conflicting PR loses its suite and renders green Three PRs reported as green at their heads. #1109 had squash-merged four minutes before I pushed two commits to its branch, so the PR reported a green rollup for the parent commit while the fix sat untested on a closed branch. #1120 and #1128 were CONFLICTING, which means no merge ref, which means tests.yml never dispatched — leaving only the push-triggered CodeQL jobs and a four-for-four green page. Both failures are absences, and the rollup folds over the checks that exist rather than the checks that should. Records the sha-level check instead, and the rule that a stack must be rebased the moment its base squash-merges. Co-Authored-By: Claude Opus 5 <[email protected]> * docs(ax): entry 41 was wrong about the mechanism — there are two @sprint-review falsified the sentence "a conflicting PR never dispatches tests" by finding eight green runs on 3f31d10, a conflicting head, Tier 1 among them. Their measurement was right and my sentence was wrong. Resolved by timestamps rather than by argument, and the answer is that both of us had half of it: 9366e11 pushed 18:53:21Z, conflict began 18:50:59Z but was not yet computed -> full 11-check dispatch 4942ad3 pushed 18:57:12Z, conflict known by then -> CodeQL only, no pull_request dispatch 3f31d10 pushed 19:38:29Z, became conflicting 19:44:07Z -> full dispatch, then the conflict arrived after So: push while KNOWN-conflicting and pull_request does not dispatch. Become conflicting AFTERWARDS and every check stays attached to the sha, still green, now describing a tree that no longer exists — nothing re-runs, because nothing was pushed. The second is the worse one and the entry did not have it. Mechanism 1 at least leaves a suspiciously thin check list. Mechanism 2 leaves a complete, genuinely-passing 11-check rollup on a PR that cannot be merged and whose tests never ran against the tree merging would produce. No artifact anywhere records that. It is also why mechanism 1 reads as false to anyone measuring after the fact — which is exactly what happened here. Row 1 is worth keeping for the window it exposes: a push 142 seconds after the merge that broke it still got a full dispatch, because mergeability had not been recomputed yet. Which side of that recomputation your push lands on decides which mechanism you get, and nothing in the UI marks the boundary. Title and rule updated: a COMPLETE green rollup on a conflicting PR is the worse signal, not the reassuring one. Co-Authored-By: Claude Opus 5 <[email protected]> * docs(ax): entry 41's own table carried a wrong count @sprint-review (57336): row 3 said "11 checks" for 3f31d10. Measured, it is 8 runs across 5 unique names. Re-derived rather than taken: 9366e11 total=11 unique=11 4942ad3 total=4 unique=4 3f31d10 total=8 unique=5 They are right, and the sting is that 8-across-5 is a number I had counted correctly myself an hour earlier, in this pod, before writing 11 into the table. The entry is about instruments whose output does not mean what it appears to; the table was mine and it did the same thing. Run count and name count disagree by three because sprint-impl's manual re-dispatch landed on the same sha as the automatic run, so the split is now stated explicitly: 5 pull_request + 3 workflow_dispatch. The mechanism claim is unaffected — pull_request DID dispatch at 19:38, while the PR was still mergeable — but "11 checks" was doing rhetorical work the evidence did not support. Also dropped "11-check rollup" from the mechanism-2 paragraph for the same reason. Added what I did NOT measure, because the difference is more interesting than the count: the two PRs' pull_request sets differ in MEMBERSHIP, 11 names against 5, not merely in size. #1120 targets main and #1136 targeted a feature branch, and several workflows filter on base — but that is a hypothesis about the difference and it is labelled as one rather than slipped in as a finding. Co-Authored-By: Claude Opus 5 <[email protected]> * docs(ax): the check-set denominator is a property of the base, not the repo @sprint-review (57341) settled the membership question I had labelled as an unchased hypothesis. Re-derived rather than accepted: the 5 names on 3f31d10 are a STRICT subset of the 11 on 9366e11, with exactly six extras — CodeQL plus its three Analyze jobs, the version-bump guard, and the stale-base guard. Two of those are merge-to-main guards and are correctly base-scoped: package-version-guard.yml and pr-base-freshness.yml both declare `pull_request: branches: [ main ]`, so a PR onto a feature branch is outside their remit by design. The other four are CodeQL's, and there is no codeql.yml in this repo at all — GitHub default setup, scoped somewhere our workflow files cannot show you. The consequence is bigger than the correction that prompted it, and it is now the paragraph's point: a PR's "full" check set is a property of its BASE. Eleven is complete onto main; five is complete onto a feature branch. There is no fixed denominator, so a check COUNT means nothing on its own — and a stacked PR retargeted to main at merge time will be judged by guards that never ran against it. That is the same error I made one paragraph earlier when I wrote "11 checks" for a row that had 8, inside an entry about instruments that report numbers meaning something other than they appear to. Co-Authored-By: Claude Opus 5 <[email protected]> * docs(ax): a base retarget fires nothing, and that is the worst of the three @sam (56969) named this mechanism in advance, from the 2026-08-04 incident, and it was missing from the entry. Confirmed against what actually happened: #1106 merged at 15:15:08Z, GitHub retargeted #1109 from the parent branch to main, and the next workflow run on that branch was 15:53:20Z — 38 minutes later, triggered by a push. Zero runs at 15:15. So mechanism 3: the base changes, no event fires, and every existing check silently becomes a check against a base the PR no longer has. It is the worst of the three because nothing about it looks wrong. No conflict, no thin list, no red. The PR is green and mergeable, and it now MEANS something different from what was tested — it merges into main rather than into its parent — while every check on it was computed against the old base. A green rollup is exactly what you would expect to see, and exactly what you get. Two rules added. Sam's press plan is the working mitigation and is recorded as such: merge the parent, verify the child's baseRefName flipped and the PR did not auto-close, then force a head event so CI runs against main. The second is a way to check it after the fact, which the entry needed and did not have. The base-scoped guards are the tell — Package Version Guard and PR Base Freshness both declare `pull_request: branches: [ main ]`, so their PRESENCE certifies a run happened with main as base. That is how #1109 is confirmed to have satisfied the rule before merging: both guards appear in its 18:30 run. Reading the check NAMES answers a question the check COUNT cannot — which is the same lesson as the denominator paragraph above, arrived at from the opposite direction. Co-Authored-By: Claude Opus 5 <[email protected]> * docs(ax): base is necessary and not sufficient — paths move the set too Found by applying this entry's own denominator paragraph to the PR carrying it. #1135 is docs-only, targets main, and reports 10 checks where #1120 reports 11. The missing one is E2E Tests: playwright.yml filters on frontend/**, backend/**, e2e/** and playwright.config.*, and a docs/** diff matches none, so the workflow never dispatches and the check never exists. I had written that the check set is a property of the BASE. That is true and incomplete — it is a function of (base, paths touched), and I only found the second half because the claim was sitting on a PR that contradicted it. The visible consequence is worth stating because it will be read wrong: a docs-only PR settles at MERGEABLE/UNSTABLE rather than CLEAN, permanently. No future event produces the absent check. UNSTABLE here means "a check you might expect is not present", not "something failed" — all ten that ran are green. A "merge only when CLEAN" rule waits forever on documentation, and anyone reading UNSTABLE as breakage goes hunting a failure that does not exist. Three of this entry's corrections have now come from treating a check count as comparable across PRs that were never comparable. Co-Authored-By: Claude Opus 5 <[email protected]> * docs(ax): I read a pending check as a missing one and built a theory on it Retracting a consequence I committed to this entry an hour ago and posted to the pod as actionable: that a docs-only PR settles at MERGEABLE/UNSTABLE permanently, because the paths-filtered E2E check never dispatches, and that a merge-only-when-CLEAN rule therefore deadlocks on documentation. False. Waited for the runs to finish instead of reading a snapshot: #1142 MERGEABLE/CLEAN checks=10 E2E absent #1143 MERGEABLE/CLEAN checks=10 E2E absent An absent E2E Tests does not prevent CLEAN — it is not required, so its non-existence costs nothing. The UNSTABLE I saw on #1135 was a check still PENDING, not a check MISSING, and it cleared by itself. The membership finding survives and is independently verified from playwright.yml and from E2E=0 on all three PRs. Only the consequence I hung off it was fabricated. Keeping the retraction in the entry rather than deleting the paragraph, because the failure mode is the entry's own subject. I read a transient as structural and then built a mechanism to explain it — paths filter, no dispatch, no check, never CLEAN. Every step of that chain is true in isolation. What made it convincing enough to commit and broadcast was the coherence, not the evidence, and none of it was ever connected to the observation it claimed to explain. Co-Authored-By: Claude Opus 5 <[email protected]> * docs(ax): why the base flip fires nothing, not just that it fired nothing @sprint-review (57010) supplied the cause behind the measurement. Re-derived rather than accepted, and every part holds: release-safety.yml [opened, synchronize, reopened, ready_for_review] package-version-guard.yml [opened, synchronize, reopened, ready_for_review] pr-base-freshness.yml [opened, synchronize, reopened] Four others on pull_request — tests, playwright, secret-scan, mintlify — take the default set, which is that list minus ready_for_review. `grep -rn edited .github/workflows/` returns nothing at all. So the retarget does fire an event. It fires one nothing is subscribed to, which is exactly why update-branch works where a base flip does not: it pushes a head commit and produces synchronize. Kept the two halves separate because their evidence differs. Zero runs at the retarget, and no subscriber to `edited`, are both measured here. That GitHub emits `edited` specifically on a base change is documentation, not an event payload I captured — consistent with the observation rather than demonstrated by it. That distinction is rule 16's, applied to my own addendum. Also recorded the fix that was considered and declined: adding `edited` to those types lists would make retargets re-run CI by themselves, and would also re-run CI on every title and body edit, which is a bad trade here. The mitigation stays a deliberate head event. Writing down the rejected option so the next reader does not re-derive it and reach the other conclusion. Co-Authored-By: Claude Opus 5 <[email protected]> * docs(ax): a push cadence under the suite's runtime never lands on the tip @sprint-review (57014): 3/4 took four heads in twelve minutes while tests.yml runs 5-6, so no run could ever cover the tip. Folded into the existing verify-by-sha rule rather than added as a fourth mechanism, because it is not one — it is the same "checks describe a superseded state", self-inflicted. What the rule did not carry is the difference between detecting it and escaping it: comparing sha-to-tip finds the mismatch every time and suggests re-dispatching, which reproduces it. Only noticing the RATE tells you the fix is to stop pushing. Co-Authored-By: Claude Opus 5 <[email protected]> * docs(ax): a workflow fix reaches a stacked PR through its BASE, not its head Fourth mechanism, found by chasing @sprint-review's #1132 measurement (57463): its entire check list is one skipped Release Branch Guard, and it reads CLEAN because nothing is failing because nothing ran. They measured the counts and declined to claim the cause. This is the cause. For a pull_request event GitHub reads the workflow definition from the MERGE REF — base + head — so the base branch's copy of the file decides whether the event matches at all. #1123 dropped `branches: [main]` from tests.yml on main at 15:20:27Z. #1132's head was pushed at 18:11:30Z, three hours later, and still got nothing, because its base `docs/ax-two-call-sites` was last touched at 06:52 and still carries the old filter. Read the file on that branch to confirm rather than inferring it. The general form is worth more than the instance: a workflow fix on main reaches a stacked PR only when that PR's BASE absorbs it. Not the head. So "we fixed CI for stacked PRs" is true of the repo and false of every PR already stacked on a stale branch, and nothing in the UI separates the two. Recorded both wrong guesses I made first, because the sequence is the point. I proposed "the head predated the fix" — refuted by timestamps, it postdates it by three hours — then "a paths filter" — refuted by reading tests.yml, which has none. Rule 16 killed both: make the mechanism predict something and go check. Co-Authored-By: Claude Opus 5 <[email protected]> * docs(ax): mechanism 4 is sprint-review's finding, not mine They established it at 15:25:50Z — "for pull_request, the trigger is read from the PR's own merge ref" — measured on #1120, whose head was pushed 15:22:21Z, two minutes after #1123 merged, and got zero runs because its base still carried the old filter. They also corrected their own earlier "merge #1123 first and the ordering stops mattering" in the same message. I derived the same thing nine hours later from #1132 and wrote it up as "@sprint-review measured the counts and explicitly declined to claim the cause; this is the cause." Both halves wrong: they did claim it, and they were first. Their message was unread in my redelivery queue while I re-derived it from a different PR. Corrected in place rather than quietly reworded, because the entry is about evidence and a provenance error inside it is the same defect. Two instances, two PRs, one mechanism — theirs is the finding, mine is the confirmation, and the independent second instance is worth keeping for exactly that reason. Co-Authored-By: Claude Opus 5 <[email protected]> * docs(ax): a hand-dispatch is the artifact that hides the bug it works around @sprint-review (57058) nearly retracted a correct finding. They measured zero runs on #1120's 0147fa2, then one run six minutes later — which reads as "my earlier claim was wrong, #1123 did reach it." The second run was my hand-dispatch landing between their two checks. The `event` field is the only discriminator. `workflow_dispatch` proves someone pushed a button; `pull_request` proves the trigger matched. Counting runs cannot tell those apart, and the count is what a reader reaches for. The general form is why it belongs in the entry rather than in the pod: a manual dispatch is the STANDARD response to noticing a PR has no checks. So the act of working around the bug manufactures the exact artifact that makes the bug look absent — and the person most likely to measure afterwards is the one who dispatched, comparing against their own memory of "it had nothing before." I am that person here. Every hand-dispatch I ran on this stack today is noise in anyone else's measurement of the same shas, which is a cost of the workaround I had not counted. The table earlier in this entry already splits its counts by event; this adds the rule that made the split necessary. Co-Authored-By: Claude Opus 5 <[email protected]> --------- Co-authored-by: Claude Opus 5 <[email protected]>
Implements @ux-lead's 56879 amendment, which settles the constraint-4 question I raised at 12:22 and unblocks 4/4. Stacked on #1109.
What changes
An ordinary in-thread post carries no reply edge — the composer names the root directly. That is the whole point:
reply_to_message_idis the addressing edge, so a threaded reply that set it would beisRouted, would ping the root's author, and would put the ambient path in #1120 out of reach from the UI.Derivation from
reply_tostays for explicit replies and for the backfill. Two shapes now coexist:threadRootIdCOALESCE(parent.thread_root_id, parent.id)Explicit wins when present, derivation fills when absent, and a mismatch is a 400.
Why mismatch is an error rather than a preference
A caller who says "reply to X" and "this belongs to thread Y", where X is not in Y, holds a wrong belief about the conversation. Picking a winner and proceeding hides that from them — and the two beliefs produce different wake sets.
Validation, all in
services/threadRootResolverAbout the root, not the poster — whether they may write here is pod membership, answered upstream.
Each carries a
code, so the route doesn't parse error text.Where the decision lives
The model takes an already-resolved root and does not decide precedence —
COALESCE($7, <derivation>)is the entire rule in SQL. Reconciliation happens once, before the insert.The controller returns 400 for
ThreadRootErrorand re-throws anything else. A resolver failure that isn't a caller error must not default tonull: silently dropping a message into no thread is exactly the data loss this column exists to prevent.Tests
12 executed cases on pg-mem against real rows, since the subject is what reconciliation does with two possibly-disagreeing inputs. Includes a CONTROL that valid input still succeeds — without it, every rejection above could come from a resolver that rejects everything.
Three of my own tests were wrong, and this caught them
They pinned implementation details rather than contracts: the local variable name feeding
expandedForRootsCreatedBefore, and the exact literal of acatchbody. My own rename in the three-state cutoff work broke them. They now assert the key and the degradation.I found them because this branch ran the existing suites, not just the new one — the same miss I made earlier today and the reason I now run the surrounding suites rather than the file I just wrote.
🤖 Generated with Claude Code