Repository navigation
test(threading): a reply edge can only be created where the root is derived - #1159
Merged
Merged
Conversation
…erived @sprint-review (57137) checked whether the cutoff could still move and found "exactly one production INSERT INTO messages, and it derives thread_root_id inline." Their instance is right; this is the class, for the same reason #1138 exists — a sweep is a fact about today, and what breaks it is a second write path added later by someone who never read the sweep. Two corrections to the instance while making it a rule. There are TWO INSERTs, not one: models/pg/Message.ts and testPG.ts. The second is harmless for a better reason than being a test script — it inserts only (pod_id, user_id, content), so it cannot create a reply edge at all. That is the property worth asserting, not the file's name. And the sharper condition is one nobody had checked: nothing UPDATEs reply_to_message_id. An edge added after the insert would never pass through the derivation, and the row would sit un-rooted forever with no error anywhere. Grepped: the only other occurrence in the tree is the schema declaration. So the invariant holds because every path that CAN create an edge derives the root, and no path can add one later — stronger than "there is only one INSERT". Both conditions guarded, with controls, because a negative from an unexercised matcher is worth nothing: the scan asserts it reaches Message.ts and sees >50 files, and each detector is fired against a known positive inline. Probed live too — dropping an edge-without-root INSERT into services/ fails exactly one test, and an UPDATE of the edge fails exactly one, each restored after. TASK-040's Mongo write-fallback is the live reminder this is not hypothetical: a second path to the same data already exists in this codebase. Co-Authored-By: Claude Opus 5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
@sprint-review (57137) checked whether the threading cutoff could still move and found "exactly one production
INSERT INTO messages, and it derivesthread_root_idinline." Their instance is correct. This is the class — same reason #1138 exists: a sweep is a fact about today, and what breaks it is a second write path added later by someone who never read the sweep.Two corrections while making it a rule
There are two INSERTs, not one —
models/pg/Message.tsandtestPG.ts. The second is harmless for a better reason than being a test script: it inserts only(pod_id, user_id, content), so it cannot create a reply edge at all. That's the property worth asserting, not the filename.The sharper condition nobody had checked: nothing UPDATEs
reply_to_message_id. An edge added after the insert would never pass through the derivation, and the row would sit un-rooted forever with no error anywhere. The only other occurrence in the tree is the schema declaration.So the invariant holds because every path that can create an edge derives the root, and no path can add one later — stronger than "there is only one INSERT."
Guarded with controls
A negative from an unexercised matcher is worth nothing, so: the scan asserts it reaches
Message.tsand sees >50 files, and each detector is fired against a known positive inline.services/UPDATE … SET reply_to_message_idintoservices/TASK-040's Mongo write-fallback is the live reminder this isn't hypothetical — a second path to the same data already exists in this codebase.
🤖 Generated with Claude Code