Repository navigation
Description
test/hits.test.ts > "a re-ingested row cannot inherit the reinforcement of the row that held its words" fails intermittently on an otherwise-green main. Found while pushing #24-area work: the pre-push gate failed on it, the same suite then passed 6× in a row, and unmodified main (61e01b0) failed the same test in 2 of 12 full-suite runs — so it is not caused by that change.
Evidence
| tree | runs | failures |
|---|---|---|
main @ 61e01b0 |
12 (full bun test ./test/) |
2 — always this one test |
| PR branch (path containment) | 10 | 2 — always this one test |
Nothing else flakes. The run reports 520 pass / 1 fail (or 548/1 on the branch), and the failing test is always:
(fail) use signals and the honest window > a re-ingested row cannot inherit the reinforcement of the row that held its words
Why it is timing-sensitive
The test derives row identity twice, back to back, and asserts they differ:
await appendMemory({ type: "learning", scope: "rev", content: "the vault rotates on the first monday" });
const [original] = await loadAll();
…
rmSync(memoryRoot(), { recursive: true, force: true });
mkdirSync(memoryRoot(), { recursive: true });
resetLedgerCache();
await appendMemory({ type: "learning", scope: "rev", content: "the vault rotates on the first monday" });
const [fresh] = await loadAll();
expect(fresh!.ts).not.toBe(original!.ts); // ← the flaky edgeRow identity is ts, and ts is a wall-clock ISO instant. The claim under test ("a re-ingested row is a new identity") is only observable when the two writes land in different milliseconds — on a warm cache they can land in the same one, and then the assertion that proves the invariant is the thing that fails. The expect(ledger.byRow.get(original!.ts)?.count).toBe(1) above it depends on the same clock.
What to decide
- Make the test deterministic. Inject the clock at the seam the test already reaches for (
resetLedgerCache()shows the seam exists), or advance a controllable clock between the twoappendMemorycalls, instead of hoping the millisecond rolls over. - Or make identity collision-proof at the source. If two rows in the same millisecond is a real possibility in production,
tsalone is not a safe row key and the collision needs handling there — which is a much bigger statement than a flaky test, so it should be a deliberate ruling rather than something a green suite hides.
Either way the suite should not depend on wall-clock luck: a gate that fails 1 run in 6 stops being trusted, and "rerun it, it's the hits test" is exactly the failure mode #68 exists to prevent.
Notes
- Not caused by memory_export/memory_import accept arbitrary paths outside the memory root #24; reported there because that push tripped it.
- Reproduced on macOS / Bun 1.4.3. CI runs Bun 1.4.4 on ubuntu-latest — unknown whether the same window exists there.
Activity
abogartz commentedon Oct 30, 2026
Fixed — the identity check no longer depends on the millisecond rolling over
test/hits.test.ts:151-164advances the clock deterministically between the two writes instead of hoping:Landed in
6bcd6a8("test: make the re-ingested-row identity check deterministic"). The suite is green end-to-end at525ed89.One thing to note about which option was taken. You offered two: make the test deterministic, or make identity collision-proof at the source, with the caveat that the second is "a much bigger statement than a flaky test, so it should be a deliberate ruling". The fix took option 1, which means the same-millisecond collision is still possible in principle —
tsis still the sole row key — and the test now works around it rather than the source handling it.That's a fine outcome, but it leaves "two rows in one millisecond is out of scope" as an unstated invariant. Since
tsis also the blocklist key and thesuperseded_bypointer, it is worth one line recording the ruling, or a ticket if you actually disagree with it. Flagging it because the green suite now hides the question that #144 originally surfaced.Severity triage 2026-10-30 — reviewed against
main@525ed89(v0.14.24). Labeledverified-on-main: the behavior this ticket describes no longer exists, so there is nothing to build. Full-suite baseline at that commit: 722 pass / 12 skip / 0 fail. Closing is your call; the evidence is here so the claim is checkable rather than asserted.abogartz commentedon Nov 4, 2026
Carried verified-on-main since the 2026-11-01 sweep; the last leftover of that batch (#137 #141 #146 already closed). Closing on the verified label.