Repository navigation
Conversation
"does not mark the narrative stale when no detection changed after generation" failed about one run in three against a local database: the detection's updatedAt is stamped with sub-millisecond precision and PostgreSQL rounds it to timestamp(3), up as often as down, while the test's `generatedAt: new Date()` truncates. Taken in the same millisecond, updatedAt came out 1 ms after it, so `stale` was true. Both staleness tests now put generatedAt a second away from the detection writes, on the side each one means. 10 runs out of 10 pass. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Jihair54 <[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.
tests/integration/cases-detail.test.ts› "does not mark the narrative stale when no detection changed after generation" fails about one run in three against a local PostgreSQL 15 (docker-compose.test.yml). I saw it while running the full suite for #101: it failed 1 run in 3 on main's code as well.Cause. The test creates a detection, then a narrative with
generatedAt: new Date(), and the API says stale whenupdatedAt > generatedAt.Detection.updatedAtis written with sub-millisecond precision, and PostgreSQL rounds it totimestamp(3), up as often as down:select '2026-01-01 00:00:00.0006'::timestamp(3)gives.001.new Date()truncates to the millisecond.So when both fall in the same millisecond,
updatedAtcan come out 1 ms after ageneratedAttaken later. A probe that created 20 detections saw the storedupdatedAt1 ms past anew Date()taken after the insert returned in 3 of them. The sibling test ("stale when a detection was attached after generation") can fail the other way, when the rounding goes down.Change. Test only. Both staleness tests put
generatedAtone second away from the detection writes, on the side each test means. The constant (NARRATIVE_CLOCK_MARGIN_MS) explains why. Production is unaffected: a narrative generated in the same millisecond as a detection write may at worst show as stale.Tested.
cases-detail.test.tspassed 10 runs out of 10 locally (9 tests each), against PostgreSQL 15.tscandeslintreport nothing on the file.🤖 Generated with Claude Code