Repository navigation
test(threading): pin the two-target structure instead of citing line numbers - #1141
Conversation
…numbers @sprint-review (57333): the header warned about a fragile text anchor while citing `:110`/`:124`, which are themselves fragile text anchors. The joke writes itself, and they were right. Replaced with a description that survives reflow — the comment occurrence comes FIRST, the SELECT occurrence second — and then pinned executably, because the deeper point is that prose cannot notice when it stops being true. The header gives the next person directions; directions are only useful while the terrain matches. Two structural tests over Message.ts: - the expression appears exactly twice, one comment line and one code line. A third occurrence, or a deduped comment, changes which target a first-match edit lands on. - the COMMENT one comes first. If that order ever flips, a first-match mutation starts hitting real SQL and the warning becomes actively misleading rather than merely stale. Probed: deleting the comment occurrence fails both, leaving all five derivation tests green; adding a non-comment occurrence above it fails both the same way. Each mutation restored and the restore verified by re-count. Two probe failures worth recording, since this suite is about instruments that mislead: - a line-swap probe left the file unparseable, so jest reported "Tests: 0 total" rather than a failure. Zero tests is not a passing probe and is not a failing one either; it is the instrument declining to run. - a perl mutation died on an unescaped modifier, applied nothing, and the suite came back 7/7. A probe that silently does not mutate reports exactly like a mutation the tests cannot detect. That is the fourth instance of that shape today and it happened inside a probe about it. The rewrite asserts its anchor before editing. Co-Authored-By: Claude Opus 5 <[email protected]>
lilyshen0722
left a comment
There was a problem hiding this comment.
Gate: approve at 3aa07458. This is the right answer to my note and a better one than I proposed — I suggested content-addressing the prose; you made the claim executable instead.
The assertions pin the structure completely:
expect(lines).toHaveLength(2);
expect(lines.filter(isComment)).toHaveLength(1);
expect(lines.filter((l) => !isComment(l))).toHaveLength(1);
expect(isComment(lines[0])).toBe(true);A third occurrence, a deduped comment, or a flipped order each turns it red — and the second test names the reason the order matters: if code comes first, a first-match mutation starts hitting real SQL and the header stops being merely stale and becomes actively misleading. That is the failure worth guarding, and prose could not have noticed it.
Checked isComment against the two real lines on main: the comment at :110 matches /^\s*\/\//, the SQL line begins (SELECT and does not. filter preserves file order, so lines[0] is the positional claim it looks like. Sound.
The Tests: 0 total failure is worth its own line somewhere. A line-swap left the file unparseable and jest reported a count where a verdict belongs — not a pass, not a fail, the instrument declining to run, rendered in the same position a result occupies. That is a distinct variant from the ones already recorded: entries 34/35/41 are all absences read as success, but this is a count read as a verdict. 0 total and 5 passed occupy the same slot in the same output and mean entirely different things about whether you measured anything.
Paired with the perl mutation that applied nothing and returned 7/7, both failures came from writing a probe about probes failing silently — which is the strongest argument available for the rule the file now enforces: assert the anchor before reading the result.
Not verified: I did not run the suite at this head, and I did not reproduce either probe failure. The structural assertions I checked by reading the two lines they target on main.
… worse @sprint-review (56953): 3-of-5 reads like partial coverage and is not. The two survivors are the depth-1 and depth-2 cases, and under COALESCE(parent.id, parent.id) they return the identical answer BY CONSTRUCTION — a root has no parent to consult, and a direct reply's parent is itself a root whose thread_root_id is NULL, so both spellings yield the parent's id. Those tests cannot go red. A test that cannot go red under a given mutation is not weak; it is a test of a different depth. Their inversion is the useful half and it is now in the header: FIVE red would be the bad result. It would mean the shallow fixtures had stopped being shallow — that the suite had quietly deepened and lost the depth-1 and depth-2 cases. So nobody should "improve" this to a full kill. Pinned rather than asserted in prose: the depth-2 test now checks that its parent IS a root. That property is exactly what makes the case mutation-invariant, so deepening the fixture can no longer silently falsify the documented count. And a number I would have shipped wrong. Re-running the mutation with the structural guard in place reports FOUR failures, not three — the guard's "appears exactly twice" also fires, because replacing the expression drops the count to one. The 5-and-3 pair was measured before this file grew that guard. Recorded, so the extra red is not read as drift by the next person. Found only by re-running the probe after editing the file it documents, rather than trusting the numbers already written in it. Co-Authored-By: Claude Opus 5 <[email protected]>
…1161) TASK-043, @sprint-review 57204. `thread_root_id` is ON DELETE SET NULL, which is right for the row pointed at and wrong for everything under it. Delete R from R <- C <- G: C : reply_to -> NULL, thread_root_id -> NULL correct — C is now a root G : reply_to = C (ALIVE), thread_root_id -> NULL WRONG — root should be C G is not a dangling edge, so the reply_to FK cannot help, and no write path revisits it. It matches the un-rooted predicate permanently. That distinction is why "zero dangling edges on the live instance" did not close this. reRootOrphanedChains repairs it by applying the write path's own COALESCE-of-parent derivation repeatedly, guarded so it only reads from a parent that already knows its root — otherwise a pass copies one NULL onto another and reports progress forever. Called from deleteOlderThan rather than from the retention cron, so every caller gets it, and wrapped so a failed repair never fails the delete: the rows are already gone, and an un-repaired orphan costs an over-expand, which the reader treats as unknown and renders expanded. Noisy, not destructive. TWO CORRECTIONS TO HOW THIS GETS TESTED, and the second is the substantive one. `UPDATE ... FROM` with a self-join is the natural single statement and pg-mem rejects it ("Unknown alias"), which would push the repair's only coverage to tier 1 — the same trap the backfill's recursive CTE fell into. A JOINed SELECT plus keyed UPDATEs runs on both. And PG-MEM DOES NOT FIRE ON DELETE SET NULL AT ALL. Measured minimally: three rows, one delete, children still pointing at the deleted id. So @sprint-review's "threadFollowByParticipation.test.js:252 already does DELETE FROM messages under pg-mem, so FK actions are exercised at the unit tier" (57286) is not true — a DELETE running is not its FK action firing. My first draft of the unit suite had a test asserting the orphaning and it PASSED; it was not evidence and it is gone. So the split is now honest. The unit suite proves the repair against a state it constructs by hand, and says out loud that the fixture is a claim about what Postgres does. threading.retention.test.js proves at tier 1 that Postgres actually produces that state, and that deleteOlderThan repairs it end to end — including a control that an intact thread survives a delete that removes nothing, since a repair that rewrote healthy rows would pass everything else. My own #1141 guard caught this commit: the new comment quoted COALESCE-of-parent verbatim, making three occurrences where it pins two, which silently changes which one a first-match probe hits. Reworded rather than the guard loosened. 296 threading unit tests green; the 4 tier-1 cases skip without INTEGRATION_TEST and run in CI. Co-authored-by: Claude Opus 5 <[email protected]>
Follow-up to #1139, from @sprint-review's stamp note (57333): the header warned about a fragile text anchor while citing
:110/:124, which are themselves fragile text anchors. The joke writes itself, and they were right.Replaced with a description that survives reflow — the comment occurrence comes first, the SELECT occurrence second — and then pinned executably, because the deeper point is that prose cannot notice when it stops being true. The header gives the next person directions; directions are only useful while the terrain matches.
Two structural tests over
Message.tsProbed: deleting the comment occurrence fails both while all five derivation tests stay green; adding a non-comment occurrence above it fails both the same way. Each mutation restored, and the restore verified by re-count.
Two probe failures worth recording, since this suite is about misleading instruments
Tests: 0 totalrather than a failure. Zero tests is not a passing probe and not a failing one — it is the instrument declining to run, and it prints in the same place a result would.Note on provenance
This commit was first pushed to #1139's branch after #1139 merged at 20:23:24Z and its branch was deleted, so the push recreated the branch off the pre-merge head and the commit was not on
main. Same trap as #1109 → #1133 earlier today; caught this time from the* [new branch]in the push output. Rebased here onto currentmainand verified green there.🤖 Generated with Claude Code