Repository navigation
Bug bash round three: four fixes, two reframings and one answered question - #721
Merged
Merged
Conversation
Closes #716. TryWriteLock gated on the locked bit alone, so a node a concurrent merge had detached was acquirable for write. The OLC fast paths hid it: they follow the lock with ValidateVersionLocked, and MarkObsolete sets a bit inside the version word, so that comparison fails and the operation restarts. The pessimistic paths re-check business conditions instead — leaf not full, no right sibling, keys in order — and a detached leaf satisfies all three. The insert lands in a node unreachable from the root: counted, and lost. Refusing in TryWriteLock makes the invariant structural rather than something seventeen call sites must each remember. MarkObsolete requires the write lock, so a node not obsolete at the CAS cannot become obsolete while the acquisition holds. SpinWriteLock reports Obsolete instead of waiting — that node never becomes lockable, which is how #695 livelocked — and tests it inside the spin, not before: a node merely locked may be locked by the very merge about to detach it. Thirteen sites restart. Four cannot: the latch-coupled SMO sibling locks are mid-propagation with no restart point, and skipping a sibling is worse than admitting one, because HandleChildMerge resolves it again internally and its merge branch dereferences it. They hold the sibling's parent lock, so no merge can detach a TRUE sibling under them; a cousin is not covered by that argument, so it goes through TryWriteLockOnSmoPath and is counted rather than assumed away. MarkObsolete now publishes with release: a writer's acquisition decision depends on that bit. #297 and #679 are NOT this. Measured, 30 s x 3 of OlcRaceStress_FourScenariosUnderCpuNoise: before 18 / 25 / 24 failures after 26 / 15 / 30 failures Same band. The reason is structural, not statistical: the two Add scenarios that produce most of those failures never call Remove, so nothing is ever marked obsolete in them and this mechanism is excluded by construction. #716 is real on its own counters (2 obsolete acquisitions per 737k write locks over the full gate suite, all via the unvalidated path) — it is simply not what loses keys in the Add path. Both issues stay open, and the harness stays the metric. Suite 5054/0/14.
…ng it The harness reported "key 126 success=False" and nothing else. That message is compatible with all three hypotheses in #297's body, so five months of runs separated none of them. DescribeLostKey answers the one question that splits them in half: TryGet reaches a leaf by descending through separators, EnumerateLeaves reaches it by walking the sibling chain, and the two disagreeing IS the diagnosis. Present in the chain but absent by descent means the key landed in a real leaf the parent cannot route to — a separator problem, insert fine. Absent from both means the write went somewhere in neither structure. First run with it, both Add scenarios, unmodified otherwise: Add_Splits key 26 inLeafChain=False chainCount=1999 entryCount=2000 chainOrdered=True chainNeighbours=(25,27) consistency=[Right Node's key '26' should be greater than parent's key '32'] Add_Disjoint key 27 inLeafChain=False chainCount=799 entryCount=800 chainOrdered=True chainNeighbours=(26,28) consistency=[Right Node's key '27' should be greater than parent's key '204'] Neither hypothesis as stated. The leaf chain is intact, ordered, and holds both immediate neighbours of the lost key — it is short by exactly the one entry EntryCount says exists. Meanwhile CheckConsistency, which walks from the ROOT, finds a node carrying that key hanging to the right of a separator far above it. So the key is reachable from the root and absent from the chain, in a subtree whose ordering is violated. That is a structure-modification defect, not a lost write and not a stale separator on an otherwise-correct tree. Also recorded: hypothesis 2 from #297 ("stale separator in the OLC parent") predicts the opposite reading, inLeafChain=True. The Add scenarios call Add only. Nothing is removed, so nothing is ever marked obsolete, so #716 is excluded from these failures by construction rather than by measurement — which is why fixing it left the rate unmoved (18/25/24 before, 26/15/30 after). Both issues stay open. The harness now reports which of the two structures disagrees, on every failure, for whoever takes the next pass.
Part 1 of #648. The doc corrections it exists to prevent are the next commit. The enum controls three ACID properties and only one of them is durability: isolation none, visible immediately | read-committed Rollback reverts no | YES, O(1) durability <= 1 tick of loss | zero loss at commit It was named after its neighbour DurabilityMode (Deferred/GroupCommit/Immediate), which genuinely is durability-only, rather than after its function. ADR-057's own summary leads with "read-committed isolation, O(1) rollback, no revision chain" — durability is one clause of four. That name is not a cosmetic complaint, it is the cause of the documentation defect filed alongside it. Two guide pages state flatly that a SingleVersion write can never be rolled back, and one of them footnotes the exception on the DURABILITY row of the same table while omitting it from the rollback row. Rollback behaviour is not something a reader goes looking for on an enum whose name says durability. CommitDiscipline names the real distinction: does this write participate in the transaction, or bypass it and ride the tick fence? That is exactly why it moves three properties at once. The defence that does not survive: staging was not chosen to give you rollback — Variant B (in-place plus undo log) was rejected as crash-unsafe, rule CM-01, TLA-checked — so rollback is a side effect of a mechanism durability forced. True, and it is the implementer's motivation, not the caller's contract. Value names deliberately unchanged. CommitDiscipline.Commit reads tautologically and Fence/Transactional were on the table, but the value is what appears in every call site and every doc sample: a second source-breaking rename buys a nicer word, not a correction. Recorded on the enum so the question is closed rather than re-opened. 144 occurrences across 33 files, plus the prose that had copied the wrong noun into 10 more comments. Pre-alpha, no compat shim. Solution builds, suite 5054/0/14.
Closes #648. Part 2 — the user-visible half, and the reason part 1's rename was worth doing. Audited all nine /doc pages that compare Versioned / SingleVersion / Transient. Rollback under the Commit discipline is documented correctly in four and contradicted in two, and the two are the pages a new user reads first. guide/02-modeling.md, under the heading "Storage modes — the decision that matters most", had the row `Rollback` reverts it? | yes | no | no with no caveat and no forward reference, reinforced three lines later by "the wrong price for a position you overwrite 60 times a second and never need to roll back". Both corrected; the editorialising clause is gone rather than qualified. guide/03-transactions.md is subtler and worse. The DURABILITY row of that same table already footnoted the exception — "no, tick-fenced, unless Commit discipline (below)" — while the rollback row directly above it did not. The page demonstrates awareness of the exception and then omits it from the one row a reader would look at. Also corrected in the §2 prose, which said an in-place write "stays" full stop. Filled the three incomplete ones: storage-mode-singleversion.md now leads its escape hatch with rollback instead of selling "atomicity and zero loss"; storage-modes/README.md gains a Rollback column so the hub answers the question rather than deferring with "differs per mode — see each sub-feature"; key-concepts/storage-mode.md gains the row it never had. The two pages the issue names as correct are unchanged except for the rename, and the cheat sheet's own one-line definition is fixed: it described the enum as "how a SingleVersion write is made durable", which is the same error in miniature and would have re-seeded it. Mechanical half: identifier renamed across 22 pages, feature-set/Transactions/durability-discipline/ moved to commit-discipline/ with both sub-pages, uids and hrefs and the docfx toc updated, the ADR filename 057-committed-durability-discipline deliberately NOT swept. check-doc-links: 327 files, 1858 links, 0 broken, 0 missing anchors.
Partially addresses #718 — the issue stays open for direction 1, see below. ToView() has two modes and only one is live. With a WhereField predicate it takes the incremental path and subscribes to the ViewRegistry, so spawns and destroys arrive as deltas. Without one — the plain Query<T>().ToView() that every sample and every doc uses to mean "all entities of this archetype" — it takes the pull path, which registers nothing. Membership was frozen at construction, and a system declared with input: () => view ran against that snapshot for the life of the runtime. So no system ever processed an entity spawned after startup. Silently: the system ran every tick and reported a plausible count. The API rewards filtering with correctness — adding a WhereField, a NARROWING, is what silently switches you onto the live path. The mechanism to fix it already existed. EcsView.Refresh dispatches a pull view into RefreshPull — full re-query, diff, deltas. Nothing ever called it, because system-input views are consumed as cached entity sets rather than refreshed. This drives it once per tick, single-threaded at tick start, before the tier-index rebuild and before any dispatch: both read the entity set, and a set refreshed after them is a set they do not know about. Incremental views are skipped deliberately, not incidentally — draining their ring buffer here would consume entries the per-system path expects to still be there. A view shared by two systems refreshes once, guarded on the tick number. The cost is real and I am not going to bury it: one EcsQuery.Execute() plus a set diff per pull system input per tick, where the incremental path pays O(deltas). Execute() allocates its result set, so that is also per-tick garbage. Unmeasured against a real workload; the suite's wall time did not move, which is not a throughput claim. Correctness first — the alternative on the table was systems silently never seeing new entities — and the first optimisation available is letting Execute() fill a caller-owned set. This is direction 2 of the three #718 lists. Direction 1, a lifecycle-level notification channel views subscribe to by ARCHETYPE, is still the endpoint: it is the only one that keeps live membership AND the O(1) prepare. It needs a design doc, not a PR — ViewRegistry is keyed per indexed FIELD, and an unfiltered query has no field to register under. SystemInputView_SeesEntitiesSpawnedWhileTheRuntimeIsRunning is un-quarantined and green. Its sibling stays quarantined and its reason is rewritten: it pins the endpoint — a pull view nobody refreshes is still a snapshot — and rewriting it to call Refresh() first would only assert that RefreshPull works, which was never in doubt. Suite 5055/0/13.
The rebuild had three `continue`s and no voice. For each occupied cluster slot it resolves the entity in the EntityMap, reads the chain root, walks the chain, and copies the HEAD into the slot — and if any of those three fails it moves on, leaving the slot holding whatever it already held. On a fresh reopen that is zero. Which is exactly what the arm64 nightly reported: Health.Current == 0 where 500 was committed. IsValid passed. LastOpenVersionedHeadRebuildCount was non-zero. Every signal but the value read healthy, because nothing on that path was counting. The rebuild genuinely cannot repair these — the chain it needs is not reachable from where it stands — so this does not turn them into successes. It turns them from invisible into counted: VersionedHeadRebuildSkips breaks them down by cause (entityNotInMap / noChainRoot / chainWalkFailed), DatabaseEngine.LastOpenVersionedHeadRebuildSkips sums them across archetypes, and a non-zero total logs a warning naming the archetype. UncleanReopen_RebuildsVersionedHead_AndHeadsCorrect now asserts it is zero, so the nightly would have failed with the cause instead of "Expected: 500 / But was: 0". The fourth case is not counted, it throws. A live cluster slot always carries a non-zero entity id, so a zero at an OCCUPIED slot proves the geometry being read does not match the occupancy bitmap. ClusterMigration treats the same read as a benign race with a concurrent clear, correctly — that defence does not exist here, which runs single-threaded at open before any transaction. This is C3 from #680's own review, applied where that review said it should have been. Step 2 of the issue is ANSWERED, and the answer is no. I implemented it — WalFilesPresentAtOpen renamed to CrashWindowAtOpen and computed as `walSegmentsPresent && !_cleanShutdownAtOpen`, on the reasoning in the issue: segments survive a clean shutdown, so the flag was true on every reopen of every database with a WAL, buying an index rebuild, an EntityMap rebuild and torn-page tolerance on all of them. Three tests said no: TornClusterEntityMapPage_AfterPriorShutdown_RecoversViaRebuild failed TornFlatVersionedEntityMapPage_AfterPriorShutdown_RecoversViaRebuild HUNG MigratingReopen_OnDiskWal_PreservesEntities failed Read the names. They tear an EntityMap page AFTER a prior shutdown and recover via the rebuild. Since increment D deleted FPI, that rebuild is the only torn-page protection in the engine, and a torn page is not exclusively a crash artefact — so gating it on the clean-shutdown flag removes the net precisely where the net exists. One of the three did not even fail cleanly; it hung. So the conflation the issue objects to is load-bearing, and the four clean-reopen tests behind step 3 cannot be unblocked this way. Reverted; nothing of it is in this commit. The remaining route to step 3 is a separate flag for "trust the persisted index directory" that does not also govern torn-page tolerance. Suite 5055/0/13.
Three of #696's five deterministic failures share a message shaped like an index defect — "B=50196 entity has wrong B field: 40156" — and the issue groups them as "concurrent value correctness and indexes". The global verification that produces it does not touch an index: var comp = txn.Open(kvp.Value).Read(CompDArch.D); if (comp.B != kvp.Key) errors.Add(...) It opens by ENTITY ID. So the finding is that Open(id).Read() serves another entity's data, which is a different and worse claim than a stale index entry. Before reporting that, the cheaper explanation had to go: Spawn handing the same id to two entities. The verification now builds the reverse map and reports duplicates first, so a failure says which of the two it is. Measured, IndexSplit_CascadingSplitsUnderContention on main: no DUPLICATE ENTITY ID lines at all — every id is distinct valid=True on every mismatched entity Entity(Key=1112, Arch=6) B=20197 read 10160 Entity(Key=1113, Arch=6) B=20198 read 10161 Entity(Key=1114, Arch=6) B=20199 read 10162 Entity(Key=1147, Arch=6) B=50186 read 10195 ... Entity(Key=1151, Arch=6) B=50190 read 10199 Contiguous entity keys resolving to contiguous wrong values, offset by a constant, and the wrong values belong to a different thread's range. That is not a lost update and not a stale index entry — it is a block of surviving entities whose records resolve to slots now holding someone else's data. The workload that produces it is phase 2: destroy every third entity and immediately respawn, on several threads at once. Which puts the suspicion on slot reuse across a concurrent destroy — the same neighbourhood as #582 face 1, where a destroy frees a chunk with nothing excluding a concurrent reader or claimant. Stated as a direction, not a root cause: I have not traced it, and the contiguity could equally come from a swap-with-last compaction that moves a survivor without updating its record. Not fixed. What changes is that the next pass starts from "entity resolution returns another entity's data, ids are distinct, blocks are contiguous" instead of from three index-shaped error strings.
…age baseline Follows the rule text landing in typhon-claude. The audit reads 22 findings, 0 blocking; every finding is the same class — a [VerifiesRule] test with no [RuleMutant] companion — which the ratchet reports rather than blocks.
This was referenced Aug 8, 2026
nockawa
added a commit
that referenced
this pull request
Aug 8, 2026
Fixes main. The #703 suppression lint requires every [Ignore] to name an OPEN issue; PR #721 closed #718 while leaving ViewCreatedBeforeTheSpawns_ConvergesWithOneCreatedAfter quarantined against it, so the lint went red on main. The lint is right and its own message says what to do: this is a distinct defect and needs its own issue, not a stale reference. #718's headline was a SYSTEM never seeing entities spawned after startup, and that is fixed. What remains is a pull View held by user code that nobody refreshes, filed as #722 with the reason direction 1 is a design rather than a repair — ViewRegistry is keyed per indexed FIELD and an unfiltered query has no field to register under. Note the timing hole, because it will recur: the lint passed on the PR (#718 was open) and failed on main (the merge closed it). Any change that both closes an issue and leaves an [Ignore] pointing at it is green before merge and red after, so the closing-keyword check wants a companion that asks whether anything in the tree still cites what the message closes. Suite 5055/0/13. One run also lost ConcurrentAllocateAndFree_MaintainsConsistency, which is a named victim of #720; it passes in isolation and the re-run was clean.
nockawa
added a commit
that referenced
this pull request
Aug 8, 2026
IGNORE_CLOSED_ISSUE has a blind spot it cannot see out of. It asks whether a suppression's issue is closed RIGHT NOW. On a PR that closes #N and leaves an [Ignore("#N")] in the tree, #N is still open while the PR is open — so the check passes, the merge closes #N, and the identical check reddens main minutes later. Green before merge, red after, with no run in between that could have caught it.
Measured, not hypothetical: PR #721 shipped its #718 fix with ViewCreatedBeforeTheSpawns_ConvergesWithOneCreatedAfter still quarantined against it. invariants passed on the PR and failed on main at 22:32.
The merge gate's closing-keywords job already extracts the exact set GitHub will act on, from the two surfaces GitHub itself parses. It now hands that set to the lint, which rejects any [Ignore] citing one. Replayed against #721's actual tree it flags the real violation and nothing else; against today's tree with the same closing set it is clean.
The job gains a checkout, which it did not need before. This is the only place in CI holding both facts at once — the closing set, and the tree as it will be after the merge, since pull_request checks out the merge ref. invariants has neither: it runs on push too and has no PR to read a set from.
[Ignore] only, and the narrowing is the interesting part. Its #N lives in the reason string, one field whose reference IS the blocker. Quarantine records its issue in free prose that legitimately names several: CreateDeleteRecreate_RapidLifecycle is quarantined against #696 while its comment also names #695 (the livelock it was retargeted from) and #716 (a suspected mechanism). The first draft flagged that comment — which is the best-documented suppression in the suite — so the check covers the half it can be precise about. The gap that leaves is filed as #724: quarantine has no machine-readable target, which is also why nothing today catches a quarantine whose issue has closed.
Seven self-tests, including the two that keep it honest: without --closing the check must stay silent, and a suppression citing an unrelated issue must pass. Neutering the check turns three of them red. 39/39 green.
nockawa
added a commit
that referenced
this pull request
Aug 9, 2026
IGNORE_CLOSED_ISSUE has a blind spot it cannot see out of. It asks whether a suppression's issue is closed RIGHT NOW. On a PR that closes #N and leaves an [Ignore("#N")] in the tree, #N is still open while the PR is open — so the check passes, the merge closes #N, and the identical check reddens main minutes later. Green before merge, red after, with no run in between that could have caught it.
Measured, not hypothetical: PR #721 shipped its #718 fix with ViewCreatedBeforeTheSpawns_ConvergesWithOneCreatedAfter still quarantined against it. invariants passed on the PR and failed on main at 22:32.
The merge gate's closing-keywords job already extracts the exact set GitHub will act on, from the two surfaces GitHub itself parses. It now hands that set to the lint, which rejects any [Ignore] citing one. Replayed against #721's actual tree it flags the real violation and nothing else; against today's tree with the same closing set it is clean.
The job gains a checkout, which it did not need before. This is the only place in CI holding both facts at once — the closing set, and the tree as it will be after the merge, since pull_request checks out the merge ref. invariants has neither: it runs on push too and has no PR to read a set from.
[Ignore] only, and the narrowing is the interesting part. Its #N lives in the reason string, one field whose reference IS the blocker. Quarantine records its issue in free prose that legitimately names several: CreateDeleteRecreate_RapidLifecycle is quarantined against #696 while its comment also names #695 (the livelock it was retargeted from) and #716 (a suspected mechanism). The first draft flagged that comment — which is the best-documented suppression in the suite — so the check covers the half it can be precise about. The gap that leaves is filed as #724: quarantine has no machine-readable target, which is also why nothing today catches a quarantine whose issue has closed.
Seven self-tests, including the two that keep it honest: without --closing the check must stay silent, and a suppression citing an unrelated issue must pass. Neutering the check turns three of them red. 39/39 green.
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.
Depends on log2n-io/typhon-claude#71 — merge that first (
rule-coverageresolves[VerifiesRule]ids against the docs repo's main).One commit per issue. Suite 5055/0/13 on the final tree.
Fixed
#716 — an obsolete node is never a legal write target.
TryWriteLockgated on the locked bit alone, so a node a concurrent merge had detached was acquirable for write. The OLC fast paths hid it: they follow the lock withValidateVersionLocked, and the obsolete bit lives inside the version word, so that comparison fails and they restart. The pessimistic paths re-check business conditions instead — leaf not full, no right sibling, keys in order — every one of which a detached leaf satisfies. Refusing inTryWriteLockmakes it structural instead of something seventeen call sites must each remember. Thirteen restart; four cannot and are counted instead.#648 — the rename, and the two pages it exists to fix.
DurabilityDiscipline→CommitDiscipline: the enum moves isolation, rollback and durability, and was named after its neighbourDurabilityModerather than its function. That name is whyguide/02-modeling.mdstates flatly that aSingleVersionwrite can never be rolled back, and whyguide/03-transactions.mdfootnotes the exception on the durability row of a table while omitting it from the rollback row directly above. Both corrected, three incomplete pages filled, and the cheat sheet's own one-line definition fixed — it described the enum as "how a SingleVersion write is made durable", the same error in miniature.#718 — a system's pull-mode input View is re-queried every tick. Without a field predicate,
Query<T>().ToView()registers with nothing, so membership froze at construction and no system ever processed an entity spawned after startup. Silently.EcsView.Refreshalready did the right thing; nothing called it. Now driven once per tick at tick start, before the tier-index rebuild and before dispatch. The cost is stated in the commit rather than buried.#688 — the HEAD rebuild stops losing data quietly. Three
continues and no voice: a slot the rebuild skips keeps what it held, which on a fresh reopen is zero, and that is served as committed state whileIsValidand the rebuild count both read healthy. Now counted by cause and asserted zero. A fourth case throws: a live cluster slot always carries a non-zero entity id, so a zero at an occupied slot proves the geometry is wrong.Reframed
#297 / #679 — the harness now names the defect instead of counting it.
DescribeLostKeyanswers the one question that splits the hypotheses:TryGetdescends through separators,EnumerateLeaveswalks the sibling chain, and the two disagreeing is the diagnosis.Neither hypothesis as stated. The chain is intact, ordered, holds both immediate neighbours, and is short by exactly the one entry
EntryCountsays exists — whileCheckConsistency, walking from the root, finds a node carrying that key hanging to the right of a separator far above it. #297's hypothesis 2 predicts the opposite reading (inLeafChain=True).#696 — the chaos "index" failures are not index failures. The verification opens by entity id, not through an index. Ruled out the cheaper explanation first — no duplicate ids at all, every entity
valid=True— leaving contiguous entity keys resolving to contiguous wrong values from another thread's range. Not a lost update and not a stale index entry.Answered
#688 step 2 — should
WalFilesPresentAtOpenconsult the clean-shutdown flag? No. I implemented it, and three tests said no:TornClusterEntityMapPage_AfterPriorShutdown_RecoversViaRebuildTornFlatVersionedEntityMapPage_AfterPriorShutdown_RecoversViaRebuildMigratingReopen_OnDiskWal_PreservesEntitiesRead the names. They tear a page after a prior shutdown and recover via the rebuild — and since increment D deleted FPI, that rebuild is the engine's only torn-page protection. Gating it on the clean-shutdown flag removes the net exactly where the net exists. Reverted; none of it is in this PR.
#548 — is
SpatialMaintainerreachable at all after #629/#680? No. Instrumented over the full suite:Every entry point of the flat R-Tree home reads zero across 5054 tests, with a non-vacuous control. So the R5 double-insert is real code and unreachable code — but the deletion this argues for is not something 5054 tests can authorise on their own, since a user's reopen-then-update could still enter it. Recorded, not cut.
🤖 Generated with Claude Code
https://claude.ai/code/session_01FE5GUBSF5D1DhyPAuTBbYk