Skip to content

Embed decision, spec and plan nodes as roots so semantic search finds them - #4242

Merged
malibio merged 1 commit into
mainfrom
issue-4241-embed-decisions
Nov 4, 2026
Merged

malibio merged 1 commit into
mainfrom
issue-4241-embed-decisions

Conversation

@malibio

@malibio malibio commented Nov 4, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • A decision, spec and plan are embedding roots. Their own content is the title (the default), and the root aggregates its subtree the way a text root does (aggregate_children_content, the helper text, header and schema already use).
  • The registry's participation rule (CoreNodeType) and the default Knowledge search scope (KNOWLEDGE_CORE_TYPES) list the three types too. Without the scope entry the types are embedded but a plain nodespace search still hides them; only --type decision finds them.
  • The shape change log records the participation change as migrate.

Kind/category: no new type, field, relationship or structural rule. The change is participation (embedded) and the behaviour's aggregation. Docs: node-types.md updated in the docs working tree (participation table plus the spec, plan and decision lines); not yet pushed.

Existing databases (measured on a scratch database, never Default)

Nothing marks an existing decision stale. Restarting the daemon queues nothing, and there is no sweep for unembedded roots. An untouched decision stays unembedded until one of these:

  • a content change to the decision root
  • an edit to a line of its body
  • nodespace import file|dir --replace on a decision that came from an import (the replace re-marks the kept root stale)
  • a database reset

A no-op update (identical content) bumps the version but queues nothing.

Test plan

  • test_all_behaviors_embeddable_content_decision states the three types as embeddable
  • body aggregation for all three types, and a nested decision's body appears once in its parent's text
  • queueing: a body edit queues the decision root; a decision under a parent queues the parent, not itself
  • knowledge scope admits the three types
  • the new tests fail with the fix reverted
  • bun run test:changed passes

🤖 Generated with Claude Code

@malibio

malibio commented Nov 4, 2026

Copy link
Copy Markdown
Collaborator Author

Review (Initial Review): PR #4242, embed decision/spec/plan as roots

Requirements Check

  • ✅ Decision, spec and plan embedded as roots: the registry EMBEDDED rule, KNOWLEDGE_CORE_TYPES, the default get_embeddable_content (title) and the new get_aggregated_content agree. The old None overrides are deleted.
  • ⚠️ nodespace search for a body phrase returns the decision: not proven end to end. The tests show the body is in the aggregated text and the root is queued, but nothing runs a search through the vector index.
  • ✅ A decision under a parent does not embed its body twice: the new integration test shows the parent is queued and the nested decision is not. The unit test counts the phrase once in the parent's aggregate.
  • ✅ Embeddable-content test states the three types, and a test covers body aggregation. The named test is test_all_behaviors_embeddable_content_decision, and the new asserts sit in the embeddable-content test around mod.rs:5200.
  • ⏳ quality:fix / test:changed: not re-run by me.

Findings

🟡 Important: packages/core/shape-record/change-log.json: classification looks wrong. built-in-shape-record.md defines rebuild as "the system regenerates it from what is stored. Derived data: search indexes, embeddings". Embedding rows are exactly that. A change here also spans two areas (the registry rule, and the embeddings it derives), and the doc says to split those into one entry each. migrate plus area: core_schema overstates the cost and puts the entry on the list a backward-compatibility decision would start from, and the release check will demand an adr / accepted_reset_required decision for it. The entry's own text ("no normal path creates one until the root or a line of its body is edited") also contradicts the issue ("embedded by the normal path for an unembedded root"). Verify which is true: if nothing sweeps unembedded roots, say so in the issue and choose the class on that basis. Otherwise use rebuild / derived data (plus an additive core_schema entry for the participation flag). Principle: the record is only useful if the hand-written class is accurate.

🟡 Important: packages/core/src/services/embedding_service.rs:49 (shared with packages/core/src/db/sqlite_store/nodes.rs:35-100): side effect on listing and enumerate, untested. system_types() is CoreNodeType::ALL minus KNOWLEDGE_CORE_TYPES, so spec/plan/decision leave the system set. The default listing therefore changes in two ways:

  1. With scope_types_only, spec/plan/decision rows now appear in default enumerates.
  2. Fragments (header/text/checkbox) under a decision, spec or plan root were hidden by the root_is_system walk and are now returned as knowledge fragments.
    The second change is probably intended, since it matches how a text document root behaves, and it keeps the SQL in step with matches_scope. But no test in knowledge_listing_tests covers these types, so the behavior change is accidental as far as the suite is concerned. Add one listing test: a decision and a text child of it are both returned in the default scope. Principle: pin intended behavior changes in shared constants.

🟡 Important: tests do not exercise the issue's headline criterion. Add or extend an embedding test so a search for a body phrase returns the decision. A weaker alternative is asserting the embedded text produced for the root through the service, not only through the behavior with a mock accessor. As written, test_decision_spec_plan_aggregate_their_body uses MockNodeAccessor, which would still pass if the service's root resolution skipped these types. The integration queue test covers part of that.

🟢 Suggestion: packages/core/src/behaviors/mod.rs (three behaviors): the same ~8-line get_aggregated_content override is copied three times. Under DRY, a small shared helper or a default for "title + subtree" would be cleaner. The duplication is minor and the types are siblings, so it does not block.

🟢 Suggestion: the registry comment at packages/nodespace-types/src/core_type.rs:427 was updated. Check nearby comments and the sheet for "Not embedded" (node-types.md). The uncommitted nodespace-docs/components/node-types.md edit looks right: it moves the three types to Embedded and fixes the three per-type "Content" lines. It must be pushed just before bun run merge, since node-types:check reads the docs main.

Other lists of embedded types: a grep across the .rs/.ts/.svelte/skill sources found no other hand-maintained list. KNOWLEDGE_CORE_TYPES and the registry are the only two, and they now agree. search_ops and services/mod.rs doc comments refer to the constant, not to a list.

No node-type-sequence violations: no new field, no literal type comparisons, current.json is regenerated and matches the registry flag change, and no migration code was added.

Recommendation

COMMENT (leaning approve once the change-log class is justified or corrected and a listing test is added). The code change is small, correct and consistent. The open points are the shape-record classification, an unpinned listing side effect, and the missing end-to-end search assertion. Posted as a comment review because GitHub blocks self-approval.

@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.

Review posted above. Verdict: COMMENT (leaning approve): fix or justify the change-log class (rebuild vs migrate), and add a listing-scope test for spec/plan/decision.

@malibio

malibio commented Nov 4, 2026

Copy link
Copy Markdown
Collaborator Author

Address-review summary

Addressed

  • 🟡 Listing side effect untested: added knowledge_listing_returns_decision_spec_plan_roots_and_their_body (a decision, spec and plan root and the body line under each are listed; a system node is not). It fails with the three KNOWLEDGE_CORE_TYPES entries removed (checked), as does the scope test.

Skipped

  • 🟡 Change-log class migrate -> rebuild: kept. The review's condition applies: rebuild means the system regenerates the data from what is stored, and here nothing does. On a scratch database, restarting the daemon queued nothing and a no-op update queued nothing; only a content change, a body edit or import --replace queued an existing decision. The issue's line "a decision already present is embedded by the normal path for an unembedded root" does not match the code. The embeddings are not in the snapshot, so the only changed keys are the three registry participation keys, which is what the entry covers.
  • 🟡 Headline criterion not pinned by a test: kept as verified, not tested. A search needs the embedding model, which no test in this repo loads. Verified end to end on a scratch database: a plain nodespace search for a body phrase returned the decisions (before widening the default scope it returned none; only --type decision found them).
  • 🟢 Shared helper for the three get_aggregated_content overrides: skipped. Three one-line delegations, the same shape text, header and schema already use.

Correction to the PR description: not every new test fails without the fix. With the behavior fix reverted, 3 of the 4 new behavior/queue tests fail; test_decision_under_a_parent_embeds_its_body_once is a guard that passes either way. The scope and listing tests fail without the scope entries.

Still open: the node-types.md edit is uncommitted in the docs working tree; it must be pushed just before bun run merge. A migrate entry blocks bun run release until it has a recorded decision (adr or accepted_reset_required).

quality:fix and test:changed pass (exit 0).

Re-Review Decision

Decision: NO RE-REVIEW NEEDED

Rationale: This round added one test and changed no production code. The two judgment calls the reviewer raised (change-log class, end-to-end proof) are answered above with evidence.

@malibio

malibio commented Nov 4, 2026

Copy link
Copy Markdown
Collaborator Author

Merge queue: #4242 was taken out of the queue — the merge gate failed on it, on top of main. Reproduce by merging or rebasing origin/main and running bun run test:changed, fix, push, and re-run bun run merge 4242.

▶ Merge gate: full pyramid on the rebased PR.
  stage logs: /var/folders/yj/_2dcl_l16cl6dr1bp7h1j6hw0000gn/T/nodespace-gate-logs/_gate-merge-2026-11-04T11-54-34-453Z

▶ quality:scripts:check (scripts/ lint + typecheck) (timeout 10m)

$ bunx eslint 'scripts/**/*.ts' && bunx tsc --noEmit -p scripts/tsconfig.json
There was a problem loading formatter: /Users/malibio/nodespace/nodespace-core/.claude/worktrees/_gate/node_modules/eslint/lib/cli-engine/formatters/stylish.js
Error: hasFlag is not a function
[stage exited with code 2]

  full output: /var/folders/yj/_2dcl_l16cl6dr1bp7h1j6hw0000gn/T/nodespace-gate-logs/_gate-merge-2026-11-04T11-54-34-453Z/quality-scripts-check-scripts-lint-typecheck.log

✗ quality:scripts:check (scripts/ lint + typecheck) failed — merge blocked.
  Fix the failure, push, and re-run: bun run merge <PR#>

@malibio

malibio commented Nov 4, 2026

Copy link
Copy Markdown
Collaborator Author

Merge queue: #4242 was taken out of the queue — the merge gate failed on it, on top of main. Reproduce by merging or rebasing origin/main and running bun run test:changed, fix, push, and re-run bun run merge 4242.

▶ Merge gate: full pyramid on the rebased PR.
  stage logs: /var/folders/yj/_2dcl_l16cl6dr1bp7h1j6hw0000gn/T/nodespace-gate-logs/_gate-merge-2026-11-04T11-55-51-100Z

▶ quality:scripts:check (scripts/ lint + typecheck) (timeout 10m)

$ bunx eslint 'scripts/**/*.ts' && bunx tsc --noEmit -p scripts/tsconfig.json
There was a problem loading formatter: /Users/malibio/nodespace/nodespace-core/.claude/worktrees/_gate/node_modules/eslint/lib/cli-engine/formatters/stylish.js
Error: hasFlag is not a function
[stage exited with code 2]

  full output: /var/folders/yj/_2dcl_l16cl6dr1bp7h1j6hw0000gn/T/nodespace-gate-logs/_gate-merge-2026-11-04T11-55-51-100Z/quality-scripts-check-scripts-lint-typecheck.log

✗ quality:scripts:check (scripts/ lint + typecheck) failed — merge blocked.
  Fix the failure, push, and re-run: bun run merge <PR#>

@malibio
malibio force-pushed the issue-4241-embed-decisions branch from 8f471be to 70ae0ef Compare November 4, 2026 12:25
@malibio
malibio merged commit c13bc16 into main Nov 4, 2026
@malibio
malibio deleted the issue-4241-embed-decisions branch November 4, 2026 12:25
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