Skip to content

Address ADR-078 cleanup items 1, 2, 3 and 5 (#2747) - #2750

Merged
malibio merged 2 commits into
mainfrom
issue-2747-adr078-cleanup
Sep 18, 2026
Merged

malibio merged 2 commits into
mainfrom
issue-2747-adr078-cleanup

Conversation

@malibio

@malibio malibio commented Sep 17, 2026 •

Copy link
Copy Markdown
Collaborator

Closes part of #2747 — items 1, 2, 3 and 5.

Item 4 is deliberately excluded

Per the coordination comment on #2747, item 4 is a live correctness bug, not cleanup, and is being fixed on #2636's branch. This PR does not touch graph_resolver.rs or cel.rs, so there is nothing to conflict with. #2747 stays open for item 4 to be ticked off by #2636's PR.

1. Derive the closure query's index name from the direction

extends_closure_sql derived its INDEXED BY target by string surgery on the endpoint column (out_node → out). That is correct for the one direction that exists today, but INDEXED BY against a wrong but existing index does not error — it silently pins a bad query plan, and the only symptom is a slow query.

The function now takes the whole ExtendsDirection and reads all three identifiers (step_from, step_to, index) from ExtendsDirection::columns(), so the index is named alongside the columns it belongs to rather than derived from one of them.

The query-plan test now iterates ALL_EXTENDS_DIRECTIONS — a const slice that fails to compile if a variant is added without listing it — and asserts the pinned index matches the endpoint column before running EXPLAIN QUERY PLAN. That first assertion is the one that matters: a mismatched-but-existing index still parses, still runs, and still returns correct rows, so the plan check alone cannot see it.

Verified by mutation

Changing index to idx_rel_in (an index that exists) fails with:

Descendants pins idx_rel_in but matches on out_node — INDEXED BY against a
wrong-but-existing index does not error, it silently pins a bad plan
  left: "idx_rel_in"
 right: "idx_rel_out"

2. Test refresh_ancestor_cache's call sites, and bound its failure window

Coverage. All four call sites — startup, and schema Created/Updated/Deleted — were uncovered; deleting any one broke no test. The new ancestry_cache_tests module covers each individually.

Verified by mutation — each call site deleted in turn
Call site removed Test that failed Others
load_active_plays startup_warms_the_cache_before_any_event 7 passed
NodeCreated{schema} a_created_schema_refreshes_the_cache 7 passed
NodeDeleted{schema} a_deleted_schema_refreshes_the_cache 7 passed
handle_schema_updated an_updated_schema_refreshes_before_the_drift_check_can_return 7 passed
dirty-flag retry a_dirty_cache_is_refreshed_before_the_next_event_is_matched 7 passed

Exactly one test fails per mutation — no test is standing in for another.

Bounding the failure window. A failed refresh kept the previous cache, with no retry and no dirty flag. Keeping the cache is right — stale ancestry beats dropping every Play's subtype matching — but on its own it is unbounded: a transient DB error at startup left subtype trigger matching quietly degraded for the whole process lifetime, after a single warning.

Added an ancestry_dirty flag: set when a refresh fails, checked at the top of handle_event, and cleared only once a new cache is actually installed. That turns "degraded forever" into "degraded until the next event", at the cost of one relaxed atomic load on the hot path in the common case.

The handle_schema_updated test passes an id that resolves to no schema node, which exercises the early-return path the refresh is deliberately ordered ahead of.

Note on the deleted-schema test: it deletes a schema outside the extends chain. schema_has_declarations refuses to delete either endpoint of an extends edge and update_schema has no way to clear one, so a schema that extends something cannot be deleted through the service at all. The test covers what is actually reachable — that the Deleted arm refreshes regardless of which schema went away.

3. Pin ScopeContext's no-per-row-SQL property

build_scope_context resolves every schema read up front so node_matches_property_filter stays synchronous and store-free. The design genuinely has this property; nothing stopped a future edit putting an await back in the row loop — which at the 10,000-row fetch cap means up to 10,000 round-trips.

Pinned at compile time: both filter functions are coerced to fn-pointer type aliases, so making either async changes its type from fn(..) -> bool to fn(..) -> impl Future and stops compiling. A runtime test cannot catch this — there is no store handle in scope to count queries against, which is precisely the property being asserted.

A second test reads every ScopeContext accessor off a fully-constructed context with no NodeService anywhere in scope, covering the likelier regression shape: a field changed to Option<_> and filled lazily on first use.

Verified by mutation

Making node_matches_property_filter async fails the coercion:

expected fn pointer `for<'a, 'b, 'c> fn(&'a Node, &'b PropertyFilter, Option<_>) -> bool`
   found fn item `fn(..., ..., ...) -> ... {node_matches_property_filter}`

5. Extract the repeated re-bucketing block

The same ~12-line resolve-owners / re-bucket / validate block sat at four sites in crud.rs. Behaviour was correct at all four, but this is the shape that produced the original wrong-bucket bug — one site was missed. Extracted as rebucket_and_validate(node, apply_defaults).

Behaviour is identical at all four sites, including the asymmetric empty-fields case: on a node-type change with no resolved fields the original validated nothing at all (there was no else branch), which the !apply_defaults guard reproduces exactly. The three load-bearing orderings — defaults before bucketing, bucketing before validation, and that empty-fields asymmetry — are now documented once on the helper rather than re-derived at each site.

Net: −157 lines of duplication at the call sites.

Testing

  • bun run rust:test:lib — 1576 passed, 0 failed
  • bun run rust:test:core — all suites green
  • bun run quality:fix — clean, no lint suppressions (clippy's type_complexity on the fn-pointer assertions was resolved with type aliases, not an #[allow])
  • Pre-push gate (test:all + cargo build + test:e2e) passed in full
  • Every new test verified to fail without its fix, as tabulated above

Non-goals

No change to extends semantics, storage shape, or scope-projection behaviour — all settled in ADR-078.

🤖 Generated with Claude Code

Item 4 is deliberately excluded — it is being fixed on #2636's branch,
where it is a live correctness bug rather than cleanup. This branch does
not touch graph_resolver.rs or cel.rs.

## 1. Derive the closure query's index from the direction

`extends_closure_sql` derived its `INDEXED BY` target by string surgery
on the endpoint column (`out_node` -> `out`). `INDEXED BY` against a
wrong-but-existing index does not error — it silently pins a bad plan,
and the only symptom is a slow query. The function now takes the whole
`ExtendsDirection` and reads all three identifiers from
`ExtendsDirection::columns`, so a second direction cannot produce a
valid-but-wrong index name.

The query-plan test now iterates every direction via
`ALL_EXTENDS_DIRECTIONS` (adding a variant without listing it fails to
compile) and asserts the pinned index matches the endpoint column
before checking the plan — the mismatch a plan assertion cannot see.

## 2. Test refresh_ancestor_cache's call sites, and bound its failure

All four call sites (startup, schema Created/Updated/Deleted) were
uncovered; deleting any one broke no test. New `ancestry_cache_tests`
module covers each one individually — verified by deleting each refresh
in turn and confirming exactly one test fails.

A failed refresh previously kept the previous cache with no retry and
no dirty flag, so a transient DB error at startup left subtype trigger
matching quietly degraded for the whole process lifetime. Added an
`ancestry_dirty` flag: set on a failed refresh, checked in
`handle_event`, cleared only once a new cache is installed. That bounds
the degraded window to one event instead of the process, at the cost of
one relaxed atomic load on the hot path.

## 3. Pin ScopeContext's no-per-row-SQL property

`build_scope_context` resolves every schema read up front so
`node_matches_property_filter` stays synchronous and store-free —
nothing stopped a future edit putting an `await` back in the row loop.

Pinned at compile time: the two filter functions are coerced to `fn`
pointer type aliases, so making either `async` changes its type and
stops compiling. Verified by making the filter `async` and watching the
assertion fail. A runtime test cannot catch this, since there is no
store handle in scope to count queries against — which is the property
being asserted. A second test reads every `ScopeContext` accessor off a
fully-constructed context with no `NodeService` in scope, covering the
likelier regression: a field turned `Option<_>` and lazily filled.

## 5. Extract the repeated re-bucketing block

The same ~12-line resolve-owners / re-bucket / validate block sat at
four sites in crud.rs — the shape that produced the original
wrong-bucket bug, where one site was missed. Extracted as
`rebucket_and_validate(node, apply_defaults)`.

Behaviour is identical at all four sites, including the asymmetric
empty-fields case: a type change with no resolved fields validates
nothing (no `else` branch in the original), which the `!apply_defaults`
guard reproduces. The three load-bearing orderings are documented on
the helper rather than re-derived per site.

Tests: 1576 core lib tests pass; full `rust:test:core` green;
`quality:fix` clean with no suppressions.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@malibio

malibio commented Sep 17, 2026

Copy link
Copy Markdown
Collaborator Author

Pragmatic Code Review — PR #2750

Review Type: Initial Review (0 prior reviews, 0 prior comments; single commit 83474c29)

Verification performed: this review did not take the PR description's mutation claims on trust. Each was independently re-run by mutating the source and observing the result, then reverting. Results are recorded per finding below. bun run rust:test:lib → 1576 passed, 0 failed. cargo clippy -p nodespace-core --lib --all-targets → zero warnings. Working tree confirmed clean after all mutations.


Requirements Check

# Acceptance criterion Status
1 extends_closure_sql derives INDEXED BY from the direction, not string surgery ✅ Met
2 Test refresh_ancestor_cache's four invalidation call sites ✅ Met
2b Bound the failed-refresh degraded window ✅ Met
3 Pin ScopeContext's no-per-row-SQL property ✅ Met
4 Give get_node_property_at_scope its callers ⬜ Deliberately deferred — correctly so
5 Extract the repeated re-bucketing block ✅ Met
— Tests pass ✅ 1576/1576
— quality:fix clean ✅ clippy silent, no suppressions

📝 On item 4 — deferral is correct and properly evidenced. Issue #2747's comment thread establishes that item 4 is a live correctness bug (maps_to translation failing across a relationship traversal) being fixed on #2636's branch, with a request not to touch graph_resolver.rs/cel.rs. The scoping was acknowledged in a follow-up comment before work began. I verified the diff honours it: git diff --name-only origin/main...HEAD returns exactly four files, and neither graph_resolver.rs nor cel.rs is among them. Nothing in the diff pre-empts the described fix — no CelScope plumbing, no node_to_cel_value call sites touched, no changes to the resolver's segment cache. This is correct engineering judgment: separating a cleanup PR from an in-flight correctness fix on shared files avoids a merge conflict on a bug fix, which is the more valuable change.

📝 On the flagged engine.rs overlap. The PR description honestly discloses that both branches add to handle_event and to the PlaybookEngine struct. Having read both regions, the overlap is genuinely small and textually separated (this branch's guard is the first statement in handle_event; #2636's change is in the dispatch arms further down). Whoever merges second should expect a trivial rebase. The disclosure is exactly right — flagging it beats discovering it.


Code Review Findings

Summary: no Critical findings, no Important findings. Three minor observations, all optional. This is unusually careful work — the comments explain why rather than what, every non-obvious ordering is documented at the point it matters, and the tests were built to fail for the right reason rather than to raise a coverage number.


✅ Item 5 — rebucket_and_validate equivalence verified line-by-line

📁 packages/core/src/services/node_service/crud.rs:2460-2513 (helper), call sites at :864, :977, :1094, :1364

This is the highest-risk change in the PR — a behaviour-preserving refactor across four write paths — so I traced equivalence exhaustively rather than sampling. It holds at all four sites.

The subtle case is the asymmetric empty-fields branch, and the helper reproduces it exactly. In the original, node_type_changed == true with empty fields fell through the inner if !fields.is_empty() with no else — validating nothing. The node_type_changed == false path with empty fields did call validate_node_against_schema. The helper's

if fields.is_empty() {
    if !apply_defaults { self.validate_node_against_schema(node).await?; }
    return Ok(());
}

maps apply_defaults == node_type_changed, so the true branch skips validation and the false branch performs it — precisely the original asymmetry. node_type_changed is passed correctly at the three update paths, and the fourth site (:1364) passes a hardcoded false, which is right: that path does not change the node's type, and its original code had no node_type_changed branch at all.

One further point worth recording, because it makes the asymmetry harmless rather than merely preserved: validate_node_against_schema (:2222-2236) itself calls resolve_field_owners and returns Ok(()) when the result is empty. Since the helper only reaches that call after observing fields.is_empty() on the same node_type, the fallback is provably a no-op — it re-resolves the identical chain and returns. So the two branches are not just faithfully copied, they are semantically equivalent for empty fields. The asymmetry preserved here is a redundant DB round-trip, not a validation gap, which is the reassuring answer.

Engineering principle (DRY, applied for the right reason): the doc comment justifies the extraction by noting the duplication itself caused the original wrong-bucket bug — one of four sites was missed. That is DRY motivated by demonstrated defect history rather than by aesthetics, which is the version of DRY worth enforcing. Documenting the three load-bearing orderings once on the helper, instead of re-deriving them in four comment blocks, is a real maintainability gain: the diff removes 157 lines and the surviving explanation is better than any of the four it replaces.


✅ Item 2 — Ordering::Relaxed is sound; all four call sites independently verified

📁 packages/core/src/playbook/engine.rs:52-62, :298-336, :399-410

On the memory-ordering question. Relaxed is correct here, and for a stronger reason than "it's probably fine". I traced the actual concurrency: handle_event is awaited sequentially inside the single-task loop { tokio::select! { ... } } at :119-124. The flag is written in refresh_ancestor_cache and read at the top of handle_event, both on that one task. The data the flag guards — the ancestry cache — is behind a separate RwLock, whose acquire/release already provides the happens-before edge for the cache contents. So the atomic carries no data dependency of its own; it is a pure advisory hint, which is the textbook case where Relaxed is the right choice rather than a shortcut. Upgrading to AcqRel would add no ordering that the RwLock does not already supply.

On the lost-update window. A concurrent failed refresh setting dirty while a concurrent successful one clears it is theoretically reachable via the pub(crate) visibility, but the store/clear ordering is chosen to make it benign: dirty is cleared only after set_ancestor_cache has installed the new cache (:328-335, with the explicit drop(lifecycle) before the store). The worst outcome is one redundant refresh on the next event — self-healing, not a stuck degraded state. Given that every call site today is on the event-loop task, this does not matter in practice, and the code is written so that it would not matter much even if that changed. Correctly judged.

Mutation verification — I re-ran all five independently:

Mutation Result
Delete the dirty-flag retry guard in handle_event ✅ exactly 1 failure — a_dirty_cache_is_refreshed_before_the_next_event_is_matched
Delete startup refresh (load_active_plays) ✅ exactly 1 failure — startup_warms_the_cache_before_any_event
Delete NodeCreated{schema} refresh ✅ exactly 1 failure — a_created_schema_refreshes_the_cache
Delete NodeDeleted{schema} refresh ✅ exactly 1 failure — a_deleted_schema_refreshes_the_cache
Delete handle_schema_updated refresh ✅ exactly 1 failure — an_updated_schema_refreshes_before_the_drift_check_can_return

Every claim in the PR description checks out. Each test fails for its own call site and no other — meaning these are four independent guards, not four tests coincidentally covered by one code path. That is the property that makes call-site coverage worth having, and it is rare to see it actually demonstrated.

The an_updated_schema_refreshes_before_the_drift_check_can_return test deserves specific credit: by passing an id resolving to no schema node, it pins the ordering (refresh precedes the drift check) rather than merely the presence of the call. Moving the refresh below the early return would fail it. That is testing the real invariant.


🟢 Suggestion: a_dirty_cache_is_refreshed_before_the_next_event_is_matched sets the flag directly — legitimate, and worth one added line

📁 packages/core/src/playbook/engine.rs:1856-1899

You asked whether setting ancestry_dirty directly, rather than inducing a real refresh failure, is "testing the test". It is not — but the reasoning is worth making explicit, because the distinction is genuinely fine.

The test would be circular if it asserted that the flag gets set on failure while setting the flag itself. It does not. It asserts the consumer behaviour: given a dirty flag and a cache known to be stale, the next unrelated event repairs it. The flag is the input to the behaviour under test, and constructing an input directly is ordinary arrange-phase work, not circularity. The producer side — that a successful refresh leaves the flag clear — is covered separately by a_successful_refresh_is_not_dirty. My mutation confirmed the consumer test genuinely bites: deleting the retry guard fails it and nothing else.

The test is also careful in a way that matters: it dispatches a task NodeCreated event, deliberately not a schema event, so none of the four schema call sites can fire. Only the dirty-flag retry can explain the recovery. Without that detail the test would prove nothing, and the inline comment says so.

What is not covered by any test is the producer half of the failure path: that refresh_ancestor_cache sets the flag when get_extends_parent_map returns Err. The doc comment reasonably argues that forcing a real I/O failure would test SQLite rather than this logic, and I agree that closing a DB handle mid-test is a poor trade. But there is a cheap middle path if you want it — assert the flag is still set after a failed refresh, i.e. that the early return at :313 does not fall through to the clear. As written, that guarantee rests on reading the control flow.

Nit / optional: this is a small gap in an otherwise thorough suite, and the existing tests cover the consequential half (recovery). Reasonable to leave. No change required.

Engineering principle: a test's value is what breaks it, not what it executes. Both of these break for the right reason.


✅ Item 1 — the index pin catches exactly the silent failure it names

📁 packages/core/src/db/sqlite_store/relationships.rs:32-60, :76-101, :2357-2435

Replacing step_from.trim_end_matches("_node") with an explicit index field on DirectionColumns removes a genuine silent-failure mode. The destructuring-bind of all three identifiers from one match means a future direction cannot supply columns without also supplying its index — the type system now enforces what a naming convention previously only suggested.

Mutation verification: I changed index: "idx_rel_out" to "idx_rel_in" — a wrong but existing index, the exact scenario the issue describes as undetectable. The test failed with the intended message. This is the finding worth highlighting, because it confirms the assertion ordering is deliberate and correct: the assert_eq! on the index name runs before the EXPLAIN QUERY PLAN check, catching a mismatch that the plan assertion structurally cannot see (a wrong-but-existing index still parses, still runs, and still returns correct rows — only slower). Had the assertions been ordered the other way, or had only the plan been checked, this mutation would have passed silently.

ALL_EXTENDS_DIRECTIONS as a const slice gives a compile-time nudge for new variants. Worth being precise about its strength: adding a variant does not by itself fail compilation, but columns()'s exhaustive match does force the author into this file, where the const sits adjacent. That is a reasonable ergonomic guard rather than an absolute one, and the comment's "fails to compile" phrasing is slightly stronger than the mechanism delivers.

🟢 Nit: consider softening that one phrase, or noting that the enforcement is the exhaustive match in columns() rather than the const itself. Purely a comment-accuracy point; the guard works.


✅ Item 3 — the compile-time pin is real, not ceremony

📁 packages/core/src/services/node_service/query.rs:666-746

You asked whether the fn-pointer aliases genuinely pin the property. They do, and I confirmed it rather than reasoning about it.

Mutation verification: I made node_matches_property_filter async. The crate failed to compile:

error[E0308]: mismatched types
706 |         let _matches: MatchesFilter = NodeService::node_matches_property_filter;
    |                       -------------   ^^^ expected fn pointer, found fn item
    = note: expected fn pointer `for<'a,'b,'c> fn(&Node, &PropertyFilter, Option<_>) -> bool`

That is exactly the claimed guard, firing at compile time. The doc comment's note that bare fn items are required — a closure would coerce around an added parameter — is the detail that makes this bite rather than merely look like it does, and it is correct.

The principle is sound: a property that cannot be observed at runtime should be asserted at compile time. A runtime test genuinely cannot catch per-row I/O here, because the absence of a store handle in the signature is the property — there is nothing to count queries against. That is the honest justification, and the comment states it plainly instead of hand-waving.

The second test (scope_context_answers_every_read_from_owned_data) targets the likelier regression — a field turned Option<_> and lazily filled — by exercising every accessor with no NodeService in scope. Good instinct: it covers the realistic failure mode, not just the dramatic one.

On type_complexity: the two aliases exist because clippy's type_complexity fires on the inline signatures. I confirmed this was resolved by introducing named types — the lint's intended remedy — and not by suppression. cargo clippy --all-targets is clean with no #[allow] anywhere in the diff.


✅ The deleted-schema test's constraint — claim verified against the guard

📁 packages/core/src/playbook/engine.rs:1750-1760 (doc), guard at packages/core/src/db/sqlite_store/relationships.rs:2264-2278

The test deletes a schema outside the extends chain and documents why. I verified the claim rather than accepting it:

assert_schema_deletable calls count_schema_declaration_edges, which counts rows where (in_node = ?1 OR out_node = ?1) with both endpoints of node_type = 'schema', filtered by builtin_exclusion_sql. That exclusion is built from BUILTIN_RELATIONSHIP_NAMES (models/schema.rs:80), a 4-element array derived from BUILTIN_RELATIONSHIPS — and extends is not among them. An extends edge is therefore schema→schema and non-builtin, so it is counted, and deleting either endpoint is refused. The doc comment is accurate.

Does the test still earn its place? Yes. Given that constraint, the only reachable behaviour is "the NodeDeleted{schema} arm refreshes regardless of which schema went away" — and that is what the test pins. My mutation confirmed it: deleting that arm fails this test and only this test. The comment explaining why the subject is a non-chain schema is what stops a future reader from "fixing" the test into something that cannot run. That comment is doing real work.


✅ Project standards — clean

  • No lint suppression: no #[allow], #[expect], #[deprecated], or #[allow(dead_code)] anywhere in the diff. type_complexity resolved via named types, which is the correct remedy.
  • No backward-compat / migration code: the refactor deletes the old duplicated blocks outright rather than keeping them alongside. No dual-mode paths, no feature flags, no DDL or data-shape migration.
  • No bare issue numbers in code comments: verified by grep over added comment lines — zero matches. Decisions are referenced as ADR-078 throughout, which is the required convention. The one #2739-style reference that existed in the old code (— see insert_node_in_tx_no_invariant_dispatch) was replaced with a symbol reference (— see rebucket_and_validate), which is an incidental improvement.
  • No raw logging: the one touched log line uses the existing warn! macro and was improved to inline formatting ({e}) plus a more actionable message ("...(will retry on next event)"). Good operational detail — the message now tells the reader the failure is bounded.
  • Docs: no .md files added to this repo, correct per the docs-live-in-nodespace-docs rule.

Recommendation: APPROVE

This is a clear net positive and I would merge it as-is. All four in-scope acceptance criteria are met, item 4's deferral is correct and well-evidenced, and 1576 tests pass with clippy silent.

What distinguishes this PR is that the tests were built to fail correctly rather than to execute code. I independently reproduced all seven mutation claims in the PR description and every one held, each failing exactly one test and no others. The two highest-value guards — the INDEXED BY mismatch and the async filter — both catch failure modes that are invisible to conventional runtime testing, which is precisely where a compile-time or plan-level assertion earns its keep.

The item 5 refactor, which carried the most risk, is equivalence-preserving at all four call sites including the asymmetric empty-fields case; and that asymmetry turns out to be a redundant round-trip rather than a validation gap, so the refactor is safe on a stronger basis than mere faithful copying.

The three 🟢 items are optional polish:

  1. A producer-side assertion that a failed refresh leaves the flag set (small, genuinely uncovered gap).
  2. ALL_EXTENDS_DIRECTIONS's "fails to compile" comment slightly overstates its mechanism.
  3. Nothing blocking.

None warrants another round. Merging is the author's call — this review does not merge.

@malibio malibio left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated pragmatic-code-review: APPROVE (posted as a comment — GitHub blocks self-approval). Full findings in the review comment above.

All 7 mutation claims in the PR description were independently re-verified: each of the four refresh_ancestor_cache call sites fails exactly one test when deleted, the wrong-but-existing index name fails the plan test, the async filter fails compilation, and the dirty-flag retry guard fails its own test. 1576 lib tests pass; clippy clean with no suppressions. No Critical or Important findings; three optional 🟢 nits, none warranting another round.

…comment

Both 🟢 nits from the review. No functional change.

## Test the producer side of the dirty flag

Only the recovery out of the degraded state was covered, not the
transition into it. A refresh that failed without setting the flag would
never be retried — precisely the unbounded-window bug the flag exists to
close — and no test would have noticed.

`a_failed_refresh_keeps_the_previous_cache_and_marks_it_dirty` induces a
real failure by dropping the `relationship` table, so
`get_extends_parent_map`'s SELECT fails the way genuine I/O or
corruption would, exercising the actual `Err` arm rather than a mock.

Verified by mutation: removing the `ancestry_dirty.store(true, ...)`
fails this test and only this test (8 others pass), which also confirms
the induced store failure is genuinely reached.

## Correct the ALL_EXTENDS_DIRECTIONS comment

The comment claimed adding a variant without listing it "fails to
compile". That is wrong — a `const` array does not force exhaustiveness,
and nothing rejects a missing variant. The real enforcement is the
exhaustive `match` in `ExtendsDirection::columns`, which fails to compile
on a new variant and lands the author in the right file to pick an index
name. The comment now says that, and says plainly that the list is a
checklist rather than the guard itself.

Worth correcting rather than leaving: a comment that overstates a
guarantee is worse than no comment, because a future reader may rely on
enforcement that does not exist.

Tests: 1577 core lib tests pass (up one). `quality:fix` clean, no
suppressions.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@malibio

malibio commented Sep 17, 2026

Copy link
Copy Markdown
Collaborator Author

Review addressed — commit 94acd08b

Both 🟢 nits addressed. No functional change; verdict was already APPROVE.

✅ Nit 1 — producer-side assertion that a failed refresh sets the flag

Agreed, and it was the more valuable of the two: only the recovery out of the degraded state was covered, never the transition into it. A refresh that failed without setting the flag would never be retried — exactly the unbounded-window bug the flag exists to close — and nothing would have caught it.

a_failed_refresh_keeps_the_previous_cache_and_marks_it_dirty induces a real failure by dropping the relationship table, so get_extends_parent_map's SELECT fails the way genuine I/O or corruption would. That exercises the actual Err arm rather than a mock or an injected fault.

Verified by mutation: removing ancestry_dirty.store(true, ...) fails this test and only this test (8 others pass). That also confirms the induced failure genuinely reaches the error path — otherwise the test would pass with the mutation applied.

✅ Nit 2 — ALL_EXTENDS_DIRECTIONS's overstated mechanism

You were right, and the distinction is real rather than pedantic. A const array does not force exhaustiveness — nothing rejects a variant missing from it, so the claim that omitting one "fails to compile" was simply false. The actual enforcement is the exhaustive match in ExtendsDirection::columns, which fails on a new variant and lands the author in the right file to pick an index name.

The comment now states that, and says plainly that the list is a checklist that gets you to the guard, not the guard itself. Worth fixing rather than leaving: a comment that overstates a guarantee is worse than no comment, because a future reader may rely on enforcement that isn't there.

Verification

  • bun run rust:test:lib — 1577 passed, 0 failed (up one)
  • bun run quality:fix — clean, no suppressions
  • Pre-push gate passed in full

Re-review

Not needed. One test added and one comment corrected, with no production logic touched — the only source change is the comment. The new test was mutation-verified in the same way as the original set.

@malibio
malibio merged commit 609e55b into main Sep 18, 2026
@malibio
malibio deleted the issue-2747-adr078-cleanup branch September 18, 2026 06:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant