Skip to content

Commit 1bba0a0

Browse files
committed
docs(run-store): correct two stale comments on the orphan-marker path
Both survived earlier revisions of the same change and now describe behaviour the code does not have. One claimed the marker has a TTL derived from the confirm window; it is a hash field with no TTL. The other claimed the marker is cleared only for terminal runs, when it is cleared for every run the lookup returned, which is what stops a live run's stale marker from pre-authorising a later deletion. Both sit on the path that deletes a keyspace, so a reader acting on either could reopen the hole the two-sighting rule closes.
1 parent 07c3398 commit 1bba0a0

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

internal-packages/run-store/src/snapshotOrphanSweeper.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -373,9 +373,6 @@ export class SnapshotOrphanSweeper {
373373

374374
if (markedAt === undefined || Number.isNaN(markedAt)) {
375375
if (!dryRun) {
376-
// The TTL is a multiple of the confirm window so a candidate gets several chances to be
377-
// sighted again, while a marker left behind by a run that turned out to be alive cannot
378-
// linger long enough to pre-authorise a later deletion.
379376
// The field carries no TTL of its own; it lives and dies with the seq hash, which the
380377
// keyspace's own completion expiry already governs. That removes the marker-lifetime knob
381378
// whose derivation was wrong in the first place.
@@ -403,9 +400,12 @@ export class SnapshotOrphanSweeper {
403400
* Clears a rule 2 marker for a keyspace whose run turned out to exist after all, so a later
404401
* genuine absence still needs its own two sightings rather than inheriting a stale one.
405402
*
406-
* Only called on a path that already found a run row, and only for terminal runs — a live run
407-
* never reaches rule 2, so it can never hold a marker, and charging every live keyspace a round
408-
* trip to prove that would cost more than the case is worth.
403+
* Called for EVERY run row the lookup returned, live ones included, and it has to be: a keyspace
404+
* marked by an earlier incomplete lookup can belong to a run that is perfectly alive, and a
405+
* SUSPENDED run can sit that way for weeks. Leaving the marker in place would let a later genuine
406+
* absence delete on what is really a first sighting, which is the hole the two-sighting rule
407+
* exists to close. It costs one DEL per existing run per pass; that is the price of the guard
408+
* being sound rather than nearly sound.
409409
*/
410410
async #clearOrphanMarker(runId: string): Promise<void> {
411411
try {

0 commit comments

Comments
 (0)