beads/cmd
Rongjun GENG bf7c19ccc4
fix(wisp): bd mol wisp gc --age 0s no longer misses a just-created wisp (#7246)
* fix(wisp): --age 0s treats every wisp as abandoned, even one Dolt rounded into the future (#7236)

findAbandonedWisps compared now.Sub(issue.UpdatedAt) > ageThreshold
unconditionally. Dolt's DATETIME(0) column rounds fractional seconds
half-up on write rather than truncating: a wisp created in the second
half of a wall-clock second can read back with updated_at up to 0.5s
in the future, making the comparison negative and failing the check
for a wisp that is, by definition, not yet one second old.

--age 0s's own documented contract ("hasn't been updated in --age
duration") means every wisp qualifies trivially -- nothing has been
updated in the last zero seconds. Extracted the comparison into
wispIsAbandoned(now, updatedAt, ageThreshold), which short-circuits
true whenever ageThreshold <= 0, bypassing the clock comparison (and
its rounding exposure) entirely for that case.

New TestWispIsAbandoned is a pure, deterministic unit test -- the
original TestCLI_WispGCExcludeType needs a live Dolt test container
and the reporter's own 60 real runs against one could not reliably
reproduce the race, so a timing-dependent regression test would be
exactly as unreliable. Confirmed red against the old inline
comparison (the two age-0s cases failed) before extracting the fix,
green after. go build/vet/gofmt clean.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0185qSpS74AbkmHoKRPf2yDD

* chore: empty commit to retrigger mergeability recompute

GitHub's mergeStateStatus has shown DIRTY/CONFLICTING since 2026-10-06,
but a real `git merge --no-commit --no-ff` against current upstream/main
auto-merges cleanly on all 3 touched files -- no actual conflict. This
commit forces GitHub to recompute.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* test(wisp): pin the gc call site and drop the 1ms age from the embedded test

Folds the tests from #7472 into the #7236 fix.

TestWispIsAbandoned pins the predicate. It cannot see whether
findAbandonedWisps still decides age through it. TestFindAbandonedWisps
AgesAtStoragePrecision drives findAbandonedWisps through a new wispGCNow
clock seam with a wisp stored rounded into the future (written 12:00:00.7,
stored 12:00:01):
- --age 0s at 12:00:00.9 reclaims it. This fails against the old inline
  now.Sub(updated_at) > threshold.
- --age 1h leaves it alone at that instant and reclaims it two hours later.
- --age 1s at 12:00:01.5 leaves it alone: a positive threshold does not
  credit idle time that has not passed.

TestWispGCProtectsActiveWisps ran gc with --age 1ms and relied on creation
order to keep the most recently touched reclaimable wisp out of the
rounding window. --age 0s states the intent ("every wisp is old enough")
and is immune to the half-second rounding, so the ordering caveat goes.

Co-authored-by: Julian Knutsen <julianknutsen@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
Co-authored-by: Eddie the Engineer <bd-7x9c69@gascity.com>
Co-authored-by: Julian Knutsen <julianknutsen@users.noreply.github.com>
2026-10-12 05:37:54 +00:00
..
bd fix(wisp): bd mol wisp gc --age 0s no longer misses a just-created wisp (#7246) 2026-10-12 05:37:54 +00:00