Skip to content

Make one governance check decide whether an archived node participates anywhere - #3473

Merged
malibio merged 1 commit into
mainfrom
issue-3443-governance-participation
Oct 1, 2026
Merged

malibio merged 1 commit into
mainfrom
issue-3443-governance-participation

Conversation

@malibio

@malibio malibio commented Oct 1, 2026

Copy link
Copy Markdown
Collaborator

Closes #3443.

Implements ADR-087 §1, §2, §4 and §6: an archived node participates in nothing, and one governance check decides it for every surface.

What changed

The governance module (packages/core/src/governance.rs) is now the only code that reads lifecycle_status:

  • participates(&node) / is_visible(&node, include_archived) for decisions in memory.
  • participates_sql(alias) / default_query_conditions(alias, include_archived) for queries, so the database applies the rule.
  • The per-type rules from the registry: mentionable_sql (the @ picker) and in_default_queries_sql, both following extends.

Every surface asks it. include_archived (default off) is the only opt-in:

Surface Where
Queries and counts, by type / id set / keyword, and the title stem fallback NodeQuery / NodeFilter gain include_archived; applied in the store's shared condition builder
Saved queries (query nodes) QueryService (no opt-in)
Keyword and semantic search search_ops, bm25_search_titles; the post-search filter is now a database filter
Root list and count, collection members (direct and recursive), member counts, collection names and lookups store + CollectionService
Backlinks and related-node lists mentioned_by, mentioning containers, rel_ops
The @ picker registry mentionable rule + participation
Workspace context, agent guidance, skills, tools query_nodes_by_type(type, include_archived) replaces the Option<&str> status filter
Play engine archived plays aren't loaded or activated; no rule fires on an archived trigger node (event, scheduled, invariant, repair); no action touches an archived target

The vector index. Every store statement that archives a node deletes its embeddings in the same transaction (single update, version-checked update, in-tx variants, bulk update, merge). Unarchiving re-queues the node. An archived child is left out of its root's aggregate and the root is re-queued. An archived root is never queued or embedded.

Plays neither read nor write lifecycle_status (§5). It is gone from the CEL node map, is_core_key, the graph resolver's core fields and workflow-state evaluation. update_node no longer takes it. A play naming it in a condition or an update_node param fails validation with the new LifecycleReference error.

The importer no longer writes a stray properties.lifecycle_status; an archived document is created or updated archived through the generic write. SqliteStore::update_lifecycle_status is deleted.

Enforcement. scripts/check-lifecycle-reads.ts runs in the push check, the merge gate and bun run test:scripts. Interpreting the field (comparison, match, SQL filter, lookup by name) is banned everywhere but the governance module. A plain read is allowed only in the envelope/persistence files it lists.

Decisions worth a look

  • The check is about the node itself. A read that names a node (by id, or the children / subtree / parent under an id) returns it, archived or not. So an archived child still renders inside its parent's document. The ADR doesn't speak to descendants; I kept structural reads complete because sibling ordering and subtree writes need them.
  • nodespace playbook disable now also hides the play. It archives, as before, and an archived play is in no list, so playbook list no longer shows it. That is the consequence ADR-087 calls out; the play enabled switch that separates "off" from "archived" is the follow-up issue.
  • Seeding sees archived seeds. Seed reconciliation and seed reset opt in to archived nodes, so a seed a user archived is left archived instead of being re-created.
  • No include_archived on the wire except search, which already had it. The opt-in exists in core for the future unarchive surface.

Tests

  • packages/core/tests/it/participation_test.rs: 24 tests, one group per surface (absent by default, present with include_archived), the vector index, and the play engine's event and action paths. With the governance rule neutralised, 21 of them fail.
  • governance unit tests, a cron scan test, a seeding regression test, an importer test, and scripts/check-lifecycle-reads.test.ts (50 cases).
  • bun run test:changed: every tier passed. bun run quality:fix: clean.

Docs

components/participation.md and components/node-types.md §1.7 in nodespace-docs (commit 460833e).

Node type sequence: no type, field or relationship changed. The change is to participation rules only: the registry gains CoreNodeType::excluded_from_default_queries(); no core type sets that rule yet.

🤖 Generated with Claude Code

@malibio

malibio commented Oct 1, 2026

Copy link
Copy Markdown
Collaborator Author

Review Type: Initial Review

Code Review Summary

The design is right and the PR is a clear net improvement: one module owns the rule, the default flipped to "exclude", the opt-in is a single flag, and the push check keeps new surfaces from drifting. The SQL edits I traced are correct, handle_play_updated is logically equivalent to the old string matching, and the internal callers that must see archived nodes (singletons, seeding, seed reset) opt in.

What stands between this and merge is a short list of verified holes in two acceptance criteria ("plays neither read nor write lifecycle_status", "no action touches an archived node"), plus a few ungoverned surfaces and one race on the vector index. All are small fixes that belong in this PR.

Method: read-only review of git diff origin/main...HEAD, the issue, the PR description, ADR-087 and components/participation.md. I ran no builds or tests; I did run bun run scripts/check-lifecycle-reads.ts (passes). Every finding below was verified by reading the code unless it says otherwise.


Requirements Check

  • ✅ One predicate and SQL fragment; every listed surface uses them. governance.rs is the only reader, and queries, counts, saved queries, roots, collections, the @ picker, workspace context, guidance, skills, tools and the engine go through it. Gaps: incoming-mention ids and the search include_edges payload (finding 4).
  • ✅ A test fails on any read outside the governance module. scripts/check-lifecycle-reads.ts runs in the push check, the merge gate and test:scripts, with a real-repo case. Pattern gaps in finding 7.
  • ✅ Archiving deletes embeddings; unarchiving re-embeds (test). All six statements that write the lifecycle column call leave_vector_index_if_archiving on the writing connection. One race can put vectors back (finding 3).
  • ✅ @ picker and default queries use the registry rules, following extends (subtype test). mentionable_sql is tested with a subtype. excluded_from_default_queries is wired but no core type sets it, so it is covered only by a unit test on the SQL helper.
  • ❌ An archived play doesn't run; no rule fires on or acts on an archived node (event, scheduled, action paths, tests). Event, scheduled and startup paths are covered. remove_relationship in a transaction has no guard (finding 2), and the invariant, repair, in-transaction and relationship-action paths have no tests (finding 5).
  • ✅ Node type sequence; node-types.md updated. §1.7 and participation.md are in nodespace-docs commit 460833e. No type, field or relationship changed.
  • ✅ test:changed and quality:fix. Taken from the PR description; not re-run.
  • ✅ Importer writes no stray properties.lifecycle_status (test). Both import paths and --replace are covered; update_lifecycle_status is deleted.
  • ❌ Plays neither read nor write lifecycle_status. Conditions, .where() predicates, the CEL map, the resolver's core fields, workflow state and the update_node param are closed. An action binding still reads it (finding 1).
  • ✅ Skill and CLI guidance. packages/skill/references/cli.md no longer teaches it. I did not run the SKILL.md drift check.

Code Review Findings

1. 🔴 Critical: an action binding still reads the lifecycle

📁 packages/core/src/playbook/actions.rs:292-297, 674-678, 1317-1325; packages/core/src/playbook/validation.rs:698-712, 1404-1412

  • Failure scenario: BindingContext::new serializes the trigger node with serde_json::to_value, and Node is rename_all = "camelCase", so the JSON carries lifecycleStatus. navigate_json is a plain .get(segment). A play with "properties": { "note": "{trigger.node.lifecycleStatus}" } saves and resolves. So do {item.lifecycleStatus} inside a for_each over related nodes (which can be archived) and {actions[0].result.lifecycleStatus}.
  • Why validation misses it: is_lifecycle_field matches only the snake_case name, and it is applied only to condition paths and update_node param keys. Binding templates are collected only for the determinism and .where() checks.
  • Evidence the camelCase route is live: the shipped Jira methodology binds {trigger.node.modifiedAt} (packages/core/src/methodology/jira.rs:454).
  • Recommendation: make is_lifecycle_field accept both spellings, and reject any binding template or for_each path with a lifecycle segment as LifecycleReference. Better, drop the key from the JSON the binding context exposes (trigger node, items, action results), so the read is impossible, not just refused. Add a test beside a_condition_naming_the_lifecycle_fails_validation.
  • Principle: ADR-087 §5 and the project rule against lifecycle reads outside the governance check. A ban enforced on one of two spellings is not enforced.

2. 🟡 Important: remove_relationship in a transaction touches archived endpoints

📁 packages/core/src/playbook/actions.rs:2440-2485

  • Failure scenario: execute_update_node_in_tx and execute_add_relationship_in_tx got the archived-target guard, and so did the non-transactional execute_remove_relationship. execute_remove_relationship_in_tx did not. An invariant rule that fires on an active node and removes an edge to an archived node deletes that edge.
  • Recommendation: add the same has_archived_endpoint_in_tx early return, with a test.
  • Principle: the four relationship executors should apply one rule; the docs say "no action touches it".

3. 🟡 Important: an in-flight embed can put an archived node back in the vector index

📁 packages/core/src/services/embedding_service.rs:392-470; packages/core/src/db/sqlite_store/embeddings.rs:9-60, 398-440, 505-545

  • Failure scenario: embed_root_node reads the root, runs inference per chunk (seconds for a long document), then calls upsert_embeddings unconditionally. If the archive commits in between, its transaction deletes the vectors and the upsert writes them back. Nothing re-queues an archived root, so the vectors stay until it is unarchived.
  • Why it matters: neither KNN query filters on participation. search_ops has an in-memory backstop, but semantic_search_nodes_of_type_with_vector (skill routing) and context_assembly.rs:329 do not. An archived skill edited and archived within the window keeps being routed to.
  • Window: one root at a time, the one being embedded. Roots still queued are safe, because the archive deletes their marker and the worker re-reads the node.
  • Recommendation: check participation inside the upsert_embeddings transaction and write nothing for an archived node. As defence in depth, add participates_sql("n") to the typed KNN query, which already joins node n.
  • Principle: an invariant that readers depend on should be enforced at the write, not assumed from call order.

4. 🟡 Important: two list surfaces still return archived nodes

  • 📁 packages/core/src/db/sqlite_store/relationships.rs:324, packages/daemon/src/services/node_service.rs:1325-1336. The GetIncomingMentions RPC (CLI mention, desktop get_incoming_mentions) returns the ids of every mentioning node, archived included. The other two backlink forms (mentioned_by query, mentioning containers) are governed, so the three disagree.
  • 📁 packages/core/src/ops/search_ops.rs:787-795, 840-856. With include_edges, each search result's edges lists target_id and target_title from an unfiltered get_related_nodes(.., "mentions", "out"). An archived node's title reaches the agent through a search tool read. graph_boost also counts archived neighbours in the degree.
  • Recommendation: join node with the governance fragment in get_incoming_mentions, and filter the cached edge targets with governance::participates, as rel_ops now does.
  • Principle: the ADR's premise is that surfaces must not disagree.

5. 🟡 Important: the riskiest engine changes have no tests

📁 packages/core/tests/it/participation_test.rs:792-1043

  • Not covered: the invariant skip in execute_matched_invariant_rules_in_tx, the repair-and-log skip, the in-transaction action guards, and the add_relationship / remove_relationship guards. Finding 2 would have been caught by one of these.
  • Negative assertions rest on a fixed wait: SETTLE (400 ms) in an_archived_play_does_not_run and an_archived_play_is_not_loaded_at_startup. Under load these pass falsely; they don't flake. no_rule_fires_on_an_archived_node already has the better shape: raise the event that must not fire, then one that must, and wait for the second. The engine handles events in order, so that is deterministic.
  • Flake risk on the positive side: the 2 s wait_until bound and the 50 ms engine-start sleep match playbook_engine_integration_test.rs, so no new risk. The 100 ms sleeps after creating a play look unnecessary given ordered event handling.
  • Recommendation: add the four missing tests, and convert the two SETTLE tests to the sentinel pattern.

6. 🟡 Important: a disabled play can't be found again

📁 packages/cli/src/commands/playbook.rs:26-36, 85-100; packages/skill/references/cli.md

  • Failure scenario: nodespace playbook disable <id> archives the play. playbook list and nodespace query --type play no longer show it, and nothing on the wire lists archived nodes except search. A user who didn't keep the id has no supported way to run playbook enable.
  • On the PR's decision: hiding the play is the consequence ADR-087 names, and I agree with it. But playbook enable is an unarchive surface that exists today, and the ADR reserves include_archived for exactly that.
  • Recommendation: add playbook list --include-archived (the core opt-in already exists), or state in the PR and the CLI help that the id must be kept until the enabled follow-up lands.

7. 🟢 Suggestion: checker pattern gaps

📁 scripts/check-lifecycle-reads.ts:47-53, 59-82

  • SQL filter on a bound value passes everywhere: WHERE lifecycle_status = ?1 with "archived" bound. A pattern for filter position (WHERE|AND|OR before the column) would catch it without flagging UPDATE ... SET lifecycle_status = ?1.
  • Envelope files are broad: sqlite_store/nodes.rs and mod.rs hold most query logic, and plain reads are allowed there, so let s = node.lifecycle_status.clone(); followed by a comparison on s passes.
  • Destructure then match passes: let Node { lifecycle_status, .. } = n; match lifecycle_status.as_str() { ... }, because both match alternatives need a leading dot.
  • Case-sensitive SQL keywords: lowercase in / is and CASE lifecycle_status WHEN are missed.
  • False positives: I found none that would block legitimate code.

8. 🟢 Suggestion: invariants can be bypassed by archive, edit, unarchive

📁 packages/core/src/services/node_service/invariants.rs:267-272

  • Concern: skipping invariant rules for an archived node follows the ADR. The consequence: archive a node, edit it into a state a reject invariant forbids, unarchive it. A rule keyed on property_changed for that property doesn't match the unarchive write, so the violating state stands.
  • Recommendation: record this as a deliberate decision in participation.md next to the other four, or re-run the type's invariant rules on unarchive.

9. 🟢 Suggestion: play conditions and aggregates still see archived related nodes

📁 packages/core/src/playbook/graph_resolver.rs:507, 684

  • Concern: node.subtasks.all(s, s.status == 'done'), count(...), sum(...) and for_each resolve through an unfiltered get_related_nodes. An archived, unfinished subtask blocks a "parent completes when all children are done" rule indefinitely. for_each actions on archived items are skipped, but they still count.
  • Recommendation: decide whether "no scan selects it" covers these collections. If it does, filter in the resolver.

10. 🟢 Suggestion: dead participation check in update_node_unchecked

📁 packages/core/src/services/node_service/crud.rs:1184-1189

  • Concern: update.lifecycle_status is never applied to updated, and the store update is built with lifecycle_status: None. participation_changed(&existing, &updated) is therefore always false. The function also silently drops a lifecycle update passed to it.
  • Recommendation: remove the block, or apply the field.

Nitpicks

  • Nit: packages/core/src/db/sqlite_store/embeddings.rs:686. create_stale_embedding_markers_bulk lacks the participation guard the single-marker write has. import_service.rs:1542 queues an archived root; the worker deletes the marker on its next pass, so it only costs a cycle.
  • Nit: packages/core/src/playbook/actions.rs:1813-1822, 1895-1905. A skipped action logs at debug and returns the same shape as a real write. info would make "my play did nothing" diagnosable.
  • Nit: packages/daemon/src/services/local_agent_service.rs:1158-1165. recover_stuck_turns now skips archived chats, so one archived mid-turn stays in processing after a restart.
  • Nit: packages/cli/src/commands/diagnostics.rs:198-232. Node and root counts now exclude archived nodes, which understates the database for a diagnostics command.
  • Nit: packages/cli/src/commands/playbook.rs:60-61. "active" / "archived" literals; the governance constants are the one definition.

On the four stated decisions

  • Structural reads stay complete: agree. Sibling order and subtree writes need them, and the docs say so. Note the consequence in finding 9, and that include_markdown in search returns an archived child's text inside an active root's markdown.
  • playbook disable hides the play: agree with the consequence; finding 6 is about the way back.
  • Seeding sees archived seeds: agree, and the regression test is good.
  • No include_archived on the wire: agree as a default; finding 6 is the one place it is needed now.

Recommendation: REQUEST CHANGES

Required before merge: findings 1 and 2 (both are gaps in stated acceptance criteria, both small). Strongly recommended in the same PR: findings 3, 4 and 5. Findings 6, 8 and 9 need a decision from the author; the rest are optional.

@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: REQUEST CHANGES (posted as a comment — GitHub blocks self-approval). Full findings in the review comment above.

@malibio

malibio commented Oct 1, 2026

Copy link
Copy Markdown
Collaborator Author

Review addressed

Commits 40fd12f6..9f88fa74 (includes a merge of current main).

Addressed

  1. 🔴 Action binding reads the lifecycle. Closed at both ends. The JSON a binding navigates (trigger node, for_each item, action result) no longer carries the field (binding_value → governance::remove_lifecycle), and a {binding} or for_each path naming it in either spelling fails validation with LifecycleReference. Tests: a_binding_naming_the_lifecycle_fails_validation, a_binding_cannot_reach_the_lifecycle_at_run_time.
  2. 🟡 remove_relationship in a transaction. Now has the archived-endpoint guard, like the other three relationship executors.
  3. 🟡 Embed in flight during an archive. upsert_embeddings checks participation inside its own transaction and writes nothing for an archived node. The typed KNN query also filters on participation. Test: vectors_computed_before_an_archive_are_not_written_after_it.
  4. 🟡 Two ungoverned lists. get_incoming_mentions joins node with the governance fragment. Search include_edges and the graph boost count participating neighbours only.
  5. 🟡 Missing engine tests. Added no_invariant_rule_fires_on_an_archived_node, no_invariant_action_touches_an_archived_node (update, add and remove in a transaction), and relationship actions in the reactive no_action_touches_an_archived_node. Negative assertions now wait on a barrier (a probe the engine must mark) instead of a fixed sleep; the install sleeps are gone.
  6. 🟡 A disabled play can't be found. nodespace playbook list --include-archived. QueryNodesSimpleRequest carries include_archived.
  7. 🟢 Checker gaps. The SQL pattern is case-insensitive and catches a bound value in filter position (WHERE / AND / OR / ON) and CASE. The match pattern catches a destructured field.
  8. 🟢 Archived related nodes in play conditions. Filtered in the graph resolver: an archived related node is absent from the collections and paths a rule reads. Test: a_condition_sees_no_archived_related_node.
  9. 🟢 Dead check in update_node_unchecked. Removed.
  • Nits: a skipped action logs at info; stuck-turn recovery opts in to archived chats.

Documented, not changed

  1. Archive → edit → unarchive around an invariant. Skipping invariants on an archived node follows the ADR. The consequence is now stated in components/participation.md (nodespace-docs 3a51d6c), with the related-node and unarchive-surface rules.

Skipped

  • Participation guard on the bulk stale-marker write. The worker deletes the marker on its next pass and the upsert now refuses an archived node, so the guard would only save one cycle.
  • Governance constants in the CLI. The CLI doesn't depend on nodespace-core outside tests.
  • Diagnostics counts. Left excluding archived nodes: counts are a participation surface, and the root count has no opt-in on the wire. Revisit with the unarchive surface.
  • Envelope files are broad in the checker. Narrowing sqlite_store/nodes.rs needs the store split first; interpreting the field is still banned there.

Verification

With the governance rule neutralised, 24 of the 30 participation tests fail (the other six test validation and the type rule). bun run test:changed passed on every tier after merging main; quality:fix clean.

Re-Review Decision

Decision: RE-REVIEW NEEDED

Rationale: A critical finding was fixed with new code in the action path, and the fixes add behaviour (resolver filtering, the upsert guard, a wire field).

@malibio

malibio commented Oct 1, 2026

Copy link
Copy Markdown
Collaborator Author

Review Type: Re-Review

Code Review Summary

Both blocking findings from the initial review are fixed, and I found no new critical or important defect in the fixes. The binding read is closed at both ends (validation and the value itself), all four relationship executors now apply one rule, and the vector index is protected at the write. The merge of main (the task-types refactor) brought in no lifecycle read, no new lifecycle write statement, and no query caller that needs the opt-in.

What remains is a short list of optional items: one consequence of the resolver filter for the shipped spec-driven gates that deserves a sentence in the docs, one sibling list surface (outgoing mentions), and missing tests for two of the fixes.

Method: read-only review of git diff 6edac0c8..9d4e75b6, then the merge 9d4e75b6..HEAD. I ran no builds or tests. I ran bun run scripts/check-lifecycle-reads.ts at HEAD (passes). Everything below was verified by reading the code unless marked unconfirmed.

Previous Review Summary

  • Previous recommendations: 10 findings plus 5 nits.
  • Addressed in code: 9 findings (1, 2, 3, 4, 5, 6, 7, 9, 10) and 2 nits.
  • Documented, not changed: 1 finding (8). The reason is sound.
  • Skipped: 3 nits and one sub-point of finding 7. The reasons are sound.
  • New issues found: 0 critical, 0 important, 3 suggestions, 5 nits.

Requirements Check (issue #3443)

  • ✅ One predicate and SQL fragment; every listed surface uses them. Incoming mentions and the search edge payload, the two gaps from the first review, now go through the module.
  • ✅ A test fails on any lifecycle_status read outside the governance module. The checker passes at HEAD, after the merge.
  • ✅ Archiving deletes embeddings; unarchiving re-embeds (test). The upsert now refuses an archived node inside its own transaction.
  • ✅ @ picker and default queries use the registry rules, following extends (subtype test). Unchanged since the first review.
  • ✅ An archived play doesn't run; no rule fires on or acts on an archived node (event, scheduled, action paths, tests). Previously ❌. execute_remove_relationship_in_tx has the guard, and the invariant and in-transaction paths have tests.
  • ✅ Node type sequence; node-types.md updated. participation.md now states the related-node rule, the invariant consequence and the unarchive surface.
  • ✅ test:changed and quality:fix. Taken from the author's report; not re-run.
  • ✅ Importer writes no stray properties.lifecycle_status (test). Unchanged.
  • ✅ Plays neither read nor write lifecycle_status. Previously ❌. A binding can no longer name the field or reach it.
  • ✅ Skill and CLI guidance. cli.md documents --include-archived. I did not run the SKILL.md drift check.

Code Review Findings

Status of the previous findings

  1. Action binding reads the lifecycle: fixed.
    • Every value a binding path navigates is built by binding_value (packages/core/src/playbook/actions.rs:1317): the trigger node (:298), graph-resolver nodes and collections (:721, :725), and every node-shaped action result (the eight create_node / update_node returns, reactive and in-transaction). for_each items come from those same values.
    • Relationship actions return ids only, and trigger.property is built from a diff of properties alone (compute_property_changes, packages/core/src/services/node_service/mod.rs:71), so neither can carry the field.
    • Stripping the key breaks nothing that reads these values back as a Node (actions.rs:590, :656, :892): the field has #[serde(default = "default_lifecycle_status")] (packages/nodespace-types/src/node.rs:43). The re-read node says active, and nothing asks it whether it participates; archived nodes were already filtered out of the collection.
    • After JSON navigation misses, the path falls through to the graph resolver, which reads properties only (get_node_property_at_scope), so the fallback can't reach the field either.
    • Validation refuses both spellings in for_each and in every {binding} (packages/core/src/playbook/validation.rs:630-639). It matches whole identifiers, so my_lifecycle_status_note passes. No shipped play or methodology names the field (packages/core/src/methodology/*.rs, core_plays.rs), so they still validate.
  2. remove_relationship in a transaction: fixed (actions.rs:2479-2489), with a test.
  3. In-flight embed: fixed. The check runs inside the upsert transaction after the deletes, the cursor is dropped before the early commit, and the commit keeps the deletes (packages/core/src/db/sqlite_store/embeddings.rs:42-65). The typed KNN query's format! interpolates a constant fragment only. All non-test callers upsert for a node row that exists, so the new check doesn't silently drop their vectors.
  4. Two ungoverned lists: fixed. get_incoming_mentions joins node with the default-query conditions; its only caller is the RPC, so no internal bookkeeping loses rows. Search edges and the boost degree count participating neighbours only. Neither fix has a test (new finding C).
  5. Missing engine tests: fixed. The four paths are covered and the fixed waits are gone. See "The barrier" below.
  6. A disabled play can't be found: fixed. playbook list --include-archived, carried by include_archived = 9 on QueryNodesSimpleRequest. Both handlers pass it through. Every request literal in the repo sets the field.
  7. Checker gaps: fixed, except the envelope-file breadth, which the author skipped with a sound reason (it needs the store split).
  8. Archive, edit, unarchive around an invariant: documented in participation.md. Sound: it follows the ADR, and the doc now states it.
  9. Archived related nodes in conditions: fixed in fetch_related_nodes (packages/core/src/playbook/graph_resolver.rs:505-515), with a test. See new finding A for a consequence.
  10. Dead check in update_node_unchecked: removed. Confirmed dead: the store update there is built with lifecycle_status: None.

Nits: the skipped-action log level and stuck-turn recovery are fixed. The three skipped nits (bulk stale-marker guard, CLI literals, diagnostics counts) have sound reasons. The CLI really has no nodespace-core dependency outside tests.

The merge of main

  • No new lifecycle_status read: the checker passes at HEAD.
  • No new statement writes the lifecycle column. The five existing ones still call leave_vector_index_if_archiving.
  • No new caller of query_nodes*, NodeFilter or NodeQuery in production code, and no struct literal misses include_archived.
  • The proto changes from main don't touch QueryNodesSimpleRequest; field 9 is free.

The barrier (seed_probe / settled)

The ordering assumption holds. The engine has one event loop that awaits handle_event for each event before taking the next (packages/core/src/playbook/engine.rs:116-121), work items go into one mpsc queue, and one rule_processor_loop task runs them in order (engine.rs:1297-1304). So once the probe is marked, every earlier event was handled and every earlier work item ran. With the governance check removed, the unwanted work item would be queued ahead of the probe's and the assertions would fail.

Two things would break it, neither reachable in these tests: a lagged broadcast receiver or a full execution queue drops events, and a dropped event reads as "did not happen".

New findings

A. 🟢 Suggestion: an archived plan takes its tasks out of the spec-driven gates

📁 packages/core/src/playbook/graph_resolver.rs:505-515; packages/core/src/methodology/spec_driven.rs:307, 400-406, 438-444

  • Failure scenario: a to-one path to an archived node now resolves as absent. task_lineage_gate and task_verification_gate are scoped by has(node.plan). Archive a draft plan, and its tasks can move to in_progress or done with no approved plan; unarchive the plan afterwards and nothing re-checks. The opposite guard fails closed: plan_approval_gate rejects approving a plan whose spec is archived, with a message that says to link a spec.
  • Recommendation: this follows the rule participation.md now states, so no code change is required. Add one sentence there: a has(node.<relationship>) guard reads an archived target as absent, so a guard that scopes a rule fails open and a guard that requires a link fails closed.
  • Principle: the same class as previous finding 8, a consequence that should be a recorded decision.

B. 🟢 Suggestion: outgoing mentions still list archived targets

📁 packages/core/src/db/sqlite_store/relationships.rs:305-322; packages/core/src/services/node_service/relationship.rs:353-358; packages/daemon/src/services/node_service.rs:1311-1323

  • Failure scenario: GetOutgoingMentions (CLI mention, desktop get_outgoing_mentions) returns the ids of every mentioned node, archived included, while GetIncomingMentions now leaves them out. Ids only, no content.
  • Recommendation: filter in NodeService::get_mentions, not in the store function. Mention sync diffs against the full set (relationship.rs:265) and must keep seeing archived targets.
  • Principle: the mirror of previous finding 4; the two directions of one list should agree. Not a regression, and not in the first review.

C. 🟢 Suggestion: three of the fixes have no test

📁 packages/core/tests/it/participation_test.rs:372-407

  • Gap: nothing asserts on get_mentioned_by, on the search edges payload or boost degree, or on the typed KNN filter. backlinks_leave_an_archived_node_out covers the query and the containers, not the id list.
  • Recommendation: one assertion in that test (get_mentioned_by(&target) returns only the live source) covers the join. The search and KNN filters are defence in depth and can stay untested.

Nitpicks

  • Nit: scripts/check-lifecycle-reads.ts:73-77. The i flag now applies to the whole SQL pattern, so a Rust message such as "lifecycle_status is required" or "lifecycle_status in the request" is flagged as SQL filtering. No current hit. Two gaps remain: match &*lifecycle_status { passes (the lookahead excludes a following brace), and a WHERE on one line with the column on the next passes.
  • Nit: packages/core/src/playbook/graph_resolver.rs:688-698. The untyped-relationship probe in inbound_candidate_applies is unfiltered. A reverse-many relationship reached only by archived nodes resolves as an empty collection, not as absent, so has() differs from the "as if the relationship were empty" rule. Reasoned from the code, not run.
  • Nit: packages/core/src/playbook/validation.rs:633. A user-defined field named lifecycle_status can't be bound in a play ({trigger.node.properties.<type>.lifecycle_status} is refused). Conditions already behaved this way. I did not check whether schema creation warns on that name.
  • Nit: packages/cli/src/commands/playbook.rs:71-85. playbook list moved from ExecuteQuery to QueryNodesSimple: the default cap goes from 50 to 100, the order is now creation-ascending, and the output shape is the same NodeListResponse. Past 100 plays the list still truncates with no notice.
  • Nit: packages/core/tests/it/participation_test.rs:994-1007. an_archived_play_is_not_loaded_at_startup rests on the 50 ms engine-start sleep. If the engine subscribed between the job's create and the probe's, the test would pass without having seen the job. The window is tiny and the sleep matches the existing engine tests.

Unconfirmed

  • upsert_embeddings deletes every embedding row for the node, stale markers included. If a child is archived while its root is being embedded, the re-queue marker the archive wrote may be deleted by the upsert, leaving the child's text in the root's vector until the next edit. This looks like the general "edited during inference" race and predates this PR; I did not trace whether the worker guards against it.

Recommendation: APPROVE

Findings 1 and 2, the two blockers, are fixed and tested. A, B and C are optional; A is a one-sentence doc addition, B and C are small enough to fold in here if wanted.

@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 (re-review): APPROVE (posted as a comment — GitHub blocks self-approval). Full findings in the review comment above.

@malibio

malibio commented Oct 1, 2026

Copy link
Copy Markdown
Collaborator Author

Re-review addressed

Addressed

  • A. has() guards and archived targets. Stated in components/participation.md (nodespace-docs 0e4e346): a guard that scopes a rule lets the node through, a guard that requires the link refuses it.
  • B. Outgoing mentions. NodeService::get_mentions leaves out archived targets, so both directions of the list agree. The store function still returns every edge, because mention sync diffs against it.
  • C. Missing assertion. backlinks_leave_an_archived_node_out now asserts on the incoming-mention id list and on the outgoing list, in both lifecycle states.
  • Checker nit. The IN / IS alternatives need SQL after them (IN (, IS [NOT] NULL), so a message that names the column isn't flagged. Two cases added.

Also in this push: a merge of current main, which now exports NodeQuery to TypeScript. includeArchived is optional in the generated type (node-query.ts regenerated), so existing frontend callers are unchanged.

Skipped

  • Untyped-relationship probe is unfiltered (inbound_candidate_applies). It answers "does this relationship apply to this node", a structural question; the nodes it then returns are filtered. The has() difference only shows for an untyped reverse relationship reached solely by archived nodes.
  • A user field named lifecycle_status can't be bound. Conditions already refused it, and schema creation warns on names that shadow core properties.
  • playbook list cap and order. The cap rose from 50 to 100; neither path paginates. Worth a flag when someone has that many plays.
  • Startup test's 50 ms engine-start sleep. Same as the existing engine tests; the window is tiny.
  • match &*lifecycle_status { and multi-line SQL in the checker. The plain-read tier still catches a read of node state outside the envelope files.
  • Unconfirmed upsert/marker race. Predates this PR (the general "edited during inference" case); not changed here.

Verification

bun run test:changed passed on every tier on the merged result, including the new generated-TypeScript drift check. quality:fix clean.

Re-Review Decision

Decision: NO RE-REVIEW NEEDED

Rationale: The re-review approved. The changes since are one small filter in a service method with a test, a test assertion, a checker pattern tightening with tests, a one-sentence docs addition, and a clean merge of main plus one regenerated type.

@malibio

malibio commented Oct 1, 2026

Copy link
Copy Markdown
Collaborator Author

Merge queue: #3473 was taken out of the queue — it conflicts with main in: packages/core/src/db/sqlite_store/relationships.rs. Rebase onto origin/main, push, and re-run bun run merge 3473.

1 similar comment
@malibio

malibio commented Oct 1, 2026

Copy link
Copy Markdown
Collaborator Author

Merge queue: #3473 was taken out of the queue — it conflicts with main in: packages/core/src/db/sqlite_store/relationships.rs. Rebase onto origin/main, push, and re-run bun run merge 3473.

@malibio
malibio force-pushed the issue-3443-governance-participation branch from 57c40d1 to 5daada6 Compare October 1, 2026 20:09
…s anywhere (closes #3443)

Implements ADR-087 §1, §2, §4 and §6. The governance module
(packages/core/src/governance.rs) is the only code that reads
lifecycle_status: a Rust predicate for decisions in memory and a SQL fragment
for queries, with include_archived as the only opt-in.

- Queries, counts, saved queries, keyword and semantic search, the root list,
  collection lists and counts, backlinks, related-node lists, the @ picker,
  workspace context, seeds and the play engine all ask it.
- Archiving a node deletes its vectors in the same transaction, on every
  write path; unarchiving re-queues it. An archived child leaves its root's
  aggregate, and an archived node is never queued or embedded.
- Plays neither read nor write the lifecycle: it is gone from conditions,
  bindings and the update_node action, and a play naming it fails validation.
  No rule fires on an archived node and no action touches one.
- The importer archives through the generic write and stores no
  lifecycle_status property.
- scripts/check-lifecycle-reads.ts fails the push check, the merge gate and
  test:scripts on a read of the field outside the governance module.
- nodespace playbook list --include-archived finds a disabled play.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@malibio
malibio force-pushed the issue-3443-governance-participation branch from 5daada6 to 06c9c77 Compare October 1, 2026 20:15
@malibio
malibio merged commit 322da9e into main Oct 1, 2026
@malibio
malibio deleted the issue-3443-governance-participation branch October 1, 2026 20:15
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.

Make one governance check decide whether an archived node participates anywhere

1 participant