Repository navigation
Description
Overview
Cleanup items deferred from #2598 (ADR-078 extends subtype identity, PR #2739). All were raised across four review passes, triaged as non-blocking, and disclosed in that PR's review responses rather than silently dropped. None is a known-live correctness bug; the first is the one with a real silent-failure mode.
Problem Statement
#2739 landed extends across the schema layer, write path, query engine, trigger engine, CEL evaluation and the wire boundary. Four review rounds found and fixed four genuine bugs in that work. These are the items each round explicitly set aside as "correct enough to merge, worth doing next."
Acceptance Criteria
1. Derive the closure query's index name from the direction, not string surgery
-
extends_closure_sql(packages/core/src/db/sqlite_store/relationships.rs) derives itsINDEXED BYtarget asstep_from.trim_end_matches("_node"). Return the index name from thematchonExtendsDirectioninstead.
Why this is first. INDEXED BY against a wrong but existing index does not error — it pins a bad query plan silently. The direction enum currently has one variant, so the derivation is correct today; if it regains a second, the string surgery can produce a valid-but-wrong index name and the only symptom is a slow query. The existing extends_closure_query_drives_off_the_endpoint_index test covers the descendant direction only.
2. Test refresh_ancestor_cache's invalidation call sites
-
packages/core/src/playbook/engine.rscallsrefresh_ancestor_cachefrom four places (startup, and schema Created/Updated/Deleted). None is covered — deleting any one breaks no test. - A failed refresh keeps the previous cache and logs a warning, with no retry and no dirty flag. A transient DB error at startup leaves subtype trigger matching quietly degraded for the process lifetime. Bound that window.
engine.rs gained a test module in #2739 (scope_tests), so the scaffolding objection that deferred this no longer applies.
3. Pin ScopeContext's no-per-row-SQL property
-
build_scope_context(packages/core/src/services/node_service/query.rs) resolves every schema read up front sonode_matches_property_filterstays synchronous and store-free. The design genuinely has this property; nothing stops a future edit putting anawaitback in the row loop. A test or diagnostic should.
4. Give get_node_property_at_scope its callers
-
packages/core/src/playbook/graph_resolver.rs— the scoped form exists but has exactly one caller, the single-scope wrapper. That read surface is effectively still unscoped, so a Play condition walking a dot-path reads at the node's own scope regardless of the trigger's registered scope.
5. Extract the repeated re-bucketing block
-
packages/core/src/services/node_service/crud.rscarries the same ~12-line resolve-owners / re-bucket / validate block at four sites. Behaviour is correct at all four, but this is the shape that produced the original wrong-bucket bug — one site was missed. A private helper makes a fifth site impossible to get wrong.
General
- Tests pass (
bun run test:all) - Code passes
bun run quality:fix
Technical Specifications
Reference Files
packages/core/src/db/sqlite_store/relationships.rs—extends_closure_sql,ExtendsDirection, and the existing query-plan test to extendpackages/core/src/playbook/engine.rs—refresh_ancestor_cacheand its four call sites;mod scope_testsfor the harness patternpackages/core/src/services/node_service/query.rs—ScopeContext,build_scope_contextpackages/core/src/playbook/graph_resolver.rs—get_node_property_at_scopepackages/core/src/services/node_service/crud.rs— the four re-bucketing sites../nodespace-docs/decisions/078-schema-extends-relationship-for-field-composition.md— ADR-078
Dependencies
- Implement extends schema relationship with real node_type subtype identity #2598 / PR Implement extends schema relationship with real node_type subtype identity #2739 must be merged first; every item references code that lands there.
Non-Goals
- Any change to
extendssemantics, storage shape, or scope-projection behaviour — all settled in ADR-078 and implemented in Implement extends schema relationship with real node_type subtype identity #2739.
Activity
malibio commentedon Sep 17, 2026
Baseline (worktree issue-2747-adr078-cleanup): Frontend: 256 test files passed, 5214 tests passed.
malibio commentedon Sep 17, 2026
graph_resolver.rs/cel.rsso we don't collide.Item 4 is a real bug, and this issue's triage understates it
This issue's preamble says "None is a known-live correctness bug." That is accurate for items 1–3 and 5, but not for item 4. #2636 (parent-task completion Play) needs to read a child node's
statusacross ahas_childtraversal, which is exactly the surface item 4 describes — and it fails today.Reproduced with a test on current
main(abc7a5f9). Two cases, and only one fails, which narrows item 4's real scope:maps_totranslation across a relationship (subtype child, extended value)So the gap is narrower than item 4's wording implies ("reads at the node's own scope regardless of the trigger's registered scope" suggests projection is broken too — it isn't). The live defect is specifically value translation: a node reached by traversal is built with
node_to_cel_value, so an extended enum value never resolves throughmaps_to.Failure mode: a Play registered on a base type, reading a related node of an extending type that added its own enum values, compares against the raw stored value and never matches. Silent — no error, no log, the condition is simply always false. For #2636 that means a parent task with
issuechildren whose status is an extended value would never complete.Fix in flight on #2636's branch
cel.rs:scoped_node_valuewidened topub(crate)— reused rather than reimplemented, per ADR-078's "one shared resolution function, not per-consumer logic"graph_resolver.rs:GraphResolvercarries an optionalCelScope; the threenode_to_cel_valuecall sites inenrich_contextgo throughscoped_node_valueengine.rs: both dispatch paths point the resolver at the rule's scope. The reactive path reuses one resolver across rules with differing scopes, so the scope is set per rule (set_scope), not per work item. The segment cache holds unprojectedResolvedValues, so it stays valid across a scope changeengine.rs::scope_testscovering both rows of the table aboveItem 4 will be ticked off by #2636's PR. Items 1, 2, 3 and 5 are untouched and remain open here.
If you are mid-change on
graph_resolver.rsorcel.rsfor another item, say so and we'll sequence it — otherwise please leave item 4 to #2636's branch to avoid a conflict.malibio commentedon Sep 17, 2026
Acknowledged — working items 1, 2, 3 and 5 only on branch
issue-2747-adr078-cleanup. Item 4 is left entirely to #2636's branch; I am not touchinggraph_resolver.rsorcel.rs.Files this branch will touch, for collision-checking:
packages/core/src/db/sqlite_store/relationships.rs(item 1)packages/core/src/playbook/engine.rs(item 2) — test module only (mod scope_tests/ a sibling test module) plus therefresh_ancestor_cacheretry bound. Seed a core Play that completes a parent task when all its children are done #2636 also editsengine.rsdispatch paths; flagging the overlap, but it is a different region of the file.packages/core/src/services/node_service/query.rs(item 3)packages/core/src/services/node_service/crud.rs(item 5)malibio commentedon Sep 17, 2026
PR #2750 is up, covering items 1, 2, 3 and 5. Item 4 is untouched and this issue stays open for it — no files overlap with #2636's fix (
graph_resolver.rsandcel.rsare not in the diff).Files changed:
relationships.rs,engine.rs,crud.rs,query.rs(+619 / -157).On the
engine.rsoverlap with #2636: this branch adds anancestry_dirtyfield toPlaybookEngine(plus its initializer), a guard at the top ofhandle_event, and a newancestry_cache_testsmodule at the end of the file. #2636 edits the dispatch paths to set the resolver's scope. Different regions, but both add tohandle_eventand to the struct, so whichever merges second should expect a small rebase there.Every new test was verified by mutation — each of the four
refresh_ancestor_cachecall sites deleted in turn fails exactly one test, and the index-name and sync-filter pins were each confirmed to fail when broken. Details are in the PR description.Address ADR-078 cleanup items 1, 2, 3 and 5 (#2747) (#2750)
malibio commentedon Sep 18, 2026
PR #2750 merged as
609e55ba. Items 1, 2, 3 and 5 are complete.Leaving this issue open and In Progress — item 4 is still outstanding and belongs to #2636's branch, so it is neither Done nor Blocked.
Landed:
extends_closure_sqltakes anExtendsDirectionand reads the index name fromExtendsDirection::columns()instead of string surgery; the plan test iterates every direction and asserts the index matches the endpoint column before checking the plan.refresh_ancestor_cachecall sites covered; failed-refresh window bounded by anancestry_dirtyflag retried inhandle_event(both the set and the clear are tested).ScopeContext's no-per-row-SQL property pinned at compile time viafn-pointer aliases — making either filter functionasyncno longer compiles.crud.rsextracted intorebucket_and_validate, preserving the asymmetric empty-fieldsbehaviour exactly.For whoever takes item 4: this branch touched
engine.rs— it added anancestry_dirtyfield toPlaybookEngine, a guard at the top ofhandle_event, and anancestry_cache_testsmodule at the end of the file. #2636's scope plumbing touches the same function and struct, so a rebase onto currentmainwill be needed there.graph_resolver.rsandcel.rsare untouched, as coordinated.Every new test was verified by mutation — each of the four call sites deleted in turn fails exactly one test, and the index-name, sync-filter and dirty-flag pins were each confirmed to fail when broken.
malibio commentedon Sep 18, 2026
Closing. Items 1, 2, 3 and 5 landed in PR #2750 (
609e55ba).Item 4 is not dropped — it is tracked on #2636, where it is being fixed as a live correctness bug rather than as cleanup. That issue's branch carries the fix (
scoped_node_valuewidened and reused,GraphResolvergiven an optionalCelScope, both dispatch paths pointing the resolver at the rule's scope) plus two regression tests covering bucket projection andmaps_totranslation across a relationship.Nothing further is actionable here: item 4 was this issue's only remaining box, and leaving it open would just be a checkbox waiting for someone to notice #2636 had merged. #2636's own review is the better place to verify it landed.
Note for #2636's branch: it is currently based on
abc7a5f9, now several commits behindmain. PR #2750 touchedengine.rs— adding anancestry_dirtyfield toPlaybookEngine, a guard at the top ofhandle_event, and anancestry_cache_testsmodule — so expect a small conflict there on rebase.graph_resolver.rsandcel.rswere left untouched as coordinated, so item 4's actual fix has clear ground.Address review: fix subtype trigger fan-out and narrow schema-drift d…
Seed a core Play that completes a parent task when all its children a…