Skip to content

Seed built-ins from fixed-UUID tables with Markdown bodies, order agent guidance, and link skills to their schemas (closes #3418) - #3495

Merged
malibio merged 2 commits into
mainfrom
issue-3418-seed-tables
Oct 2, 2026
Merged

malibio merged 2 commits into
mainfrom
issue-3418-seed-tables

Conversation

@malibio

@malibio malibio commented Oct 2, 2026 •

Copy link
Copy Markdown
Collaborator

Closes #3418.

Every built-in seeded node now comes from a const seed table with a fixed literal UUID, its text lives in plain .md files, seeding reconciles by id, the resident prompt is assembled in table order, and a skill links to the schemas it is about through a declared applies_to relationship.

What changed

Seed tables and Markdown bodies

  • GUIDANCE_SEEDS (prompt_assembler.rs), SKILL_SEEDS (skill_pipeline.rs), Tool::seed_id() (tools.rs) and each playbook's SKILLS / OVERVIEW tables hold the fixed ids and metadata. Core and playbook plays already had fixed UUIDs on main; CORE_PLAY_IDS names the core play table.
  • Guidance and skill bodies moved from Rust string literals to packages/agent/src/seeds/{guidance,skills}/*.md. The bundled playbook skill files lost their frontmatter, and the frontmatter parser is deleted.
  • NodeTemplate stays as the one input to seeding. It gained id and lost content and child_properties, which nothing but tests used.

Rule fragments

  • Each skill_rules constant now reads its text from .md fragments, and a body includes a rule by id with <!-- include: <rule-id> -->.
  • The generated schema-rules region of the shipped skill is laid out by seeds/skill-md/schema-rules.md, using the same markers.

Identity and reconciliation

  • seed_nodes_from_templates matches a seed by its root id, in one batched read. A deleted seed is created again under the same id; an archived one stays archived.
  • _seed.key stays as the handle nodespace skill reset <key> takes. The daemon resolves the key to the table row and the row's id to the node.
  • A config replace now also restores the root's name, so a retitled seed renames its node in place.

Agent guidance

  • PromptAssembler fetches the table's ids in table order. It no longer queries by type, so a user-created agent-guidance node is not in the prompt and an archived section is left out.
  • prompt_assembly_snapshot builds the resident prompt through PromptAssembler::assemble() over a freshly seeded database.

applies_to

  • skill declares applies_to (skill → schema node, Many/Many, reverse skills). SkillFields.node_types, with_node_types, the SkillNodeUpdate field and its flat-key read are deleted, and the generated TypeScript is regenerated.
  • find_skills reads every candidate's links in one query (get_edge_targets_by_source) and carries the linked schemas plus every schema extending them, core schemas included. An unlinked skill keeps the old fallback.
  • Bundled playbook skills create their edges at install, under the id a re-keyed schema landed on.
  • references/cli.md has a new "Authoring a skill" section, and each generated playbook reference lists the link commands.

Node type change (node type sequence)

  • Type: skill, a flat core type in the agent category.
  • Field removed: node_types.
  • Relationship added: applies_to → schema, direction out, Many/Many, optional, reverse skills.
  • Docs: the skill sheet in components/node-types.md already describes this shape. Companion changes in nodespace-docs (commits 4b683c3, 8e133ab): ADR-072 amended for id-keyed reconciliation, and components/seeded-nodes.md and components/typed-relationships.md updated.

Things a reviewer should know

  • A rule has two fragments, not one. The issue asks for one fragment per rule, but each rule already had two deliberately different texts: the local agent's form names tools (update_schema), the shipped skill's names CLI commands (schema update). They are seeds/rules/agent/<id>.md and seeds/rules/skill-md/<id>.md, and the existing anchor and JSON-example tests still tie them together.
  • No tool description includes a fragment. I checked every tool description and parameter description against every rule: the only shared text is one JSON example and one clause. Tool descriptions state argument shape (ADR-064), which the rules leave to them.
  • applies_to targets schema, which has no schema node. The declaration is stored as a self-edge on the skill schema, the same way an untyped declaration is, and the edge check lets a schema-targeted relationship reach a schema node. A link to any other node is refused.
  • Two model-facing changes, neither measured against the model.
    • The resident prompt's section order reverses in production. On main the live prompt ran "Tool Call Formatting" first and "Core Identity" last, because the sections were read newest-first. It now follows the table, which is the order the golden always pinned. This is the fix the issue asks for, but every eval baseline taken through the daemon was measured on the reversed prompt.
    • Spec-driven's two task skills link to core task. With that playbook installed, those skills carry task's definition in schema_metadata instead of the custom-type fallback. A linked type brings every type extending it, so in a workspace that also has the Linear or Jira playbook they carry issue, or epic, story and bug, as well.
  • The content move is lossless. I dumped every seed's title, properties, tier and body, and both forms of every rule, before and after: 78 rows, no differences beyond each file's trailing newline. The resident-prompt golden did not change, and skill:check reports the shipped skill up to date apart from the new section and link commands.
  • ADR-060 §5: every shipped invariant rule's only action is reject, and no two rules that write share a trigger, so no play depends on running before another.
  • Existing databases need a reset. Seeds created under random ids are not matched by the new ids, so an old database would get a second copy of every built-in.

Tests

  • Core: id-keyed reconciliation (unchanged template creates nothing, same title under another id is another seed, deleted seed recreated, archived seed stays archived, retitle renames in place), linked_schemas, skill_applies_to_test (both directions, non-schema target refused, per-playbook install links, re-keyed schema), find_skills with a linked custom type, a linked core type, a subtype of a linked type and the unlinked fallback.
  • Agent: table-order assembly with nodes created in reverse, a guidance node outside the table, an archived section, the emergency fallback, include resolution, and seed_tables (every id a UUID, unique across all tables).

🤖 Generated with Claude Code

@malibio

malibio commented Oct 2, 2026

Copy link
Copy Markdown
Collaborator Author

Pragmatic Code Review — PR #3495

Review Type: Initial Review

Summary

No blocking defects found. The seeding, assembly and applies_to changes are correct as far as I could verify by reading the code and running the targeted tests, and the change is a clear net improvement: identity moves to the node id, the resident prompt order stops depending on timestamps, and a list of ids on skill becomes a declared relationship.

What needs attention before merge is small: one new test does not discriminate the bug it is named for, the PR body understates the model-facing changes, and the companion docs still describe a function this PR deletes.

What I ran (all pass, 170 tests):

  • core it: skill_applies_to, methodology_linear_install, typed_flat_updates (39)
  • core unit: reseed*, reset_seed*, linked_schemas*, the_id_table_matches* (22)
  • core it with --features nlp: find_skills_schema_metadata (6)
  • agent: seed_tables, prompt_assembler, prompt_assembly_snapshot, skill_rules, skill_pipeline, agent_guidance (91)
  • cli it: skill_md_generation, including checked_in_skill_md_is_up_to_date (12)
  • scripts/check-node-type-literals.ts, scripts/check-lifecycle-reads.ts, scripts/check-pro-boundary.ts: all clean

I did not run bun run test:changed, quality:fix, types:check or the merge gate.

Requirements Check

# Criterion Notes
1 One const seed table per kind with fixed literal UUIDs; test for valid and unique ids ✅ Deviation: guidance and skills are real const tables. Tools are Tool::seed_id() (an exhaustive match), core plays are a CORE_PLAY_IDS id list beside core_plays(), and playbook plays stay PlaySteps built in functions from const ids. tests/it/seed_tables.rs covers every one, plus saved views. Acceptable.
2 Every seeded id passes is_valid_node_id; no slug play id ✅ Asserted in every_seeded_id_is_a_uuid.
3 Bodies and fragments are plain .md, no frontmatter; no seed body is a Rust literal ✅ The overview's "Installed in this workspace" section and the re-key note are still built in Rust at install, which is install-dependent text, not a seed body.
4 Each skill_rules constant becomes one fragment used by guidance, skills, tool descriptions and gen_skill_md; SKILL.md unchanged ✅ deviated Two fragments per rule (agent form, skill-md form); no tool description and no guidance body includes one. I think the deviation is sound, see "Deviations" below. Drift check passes.
5 Playbook skill files drop frontmatter; parser deleted ✅
6 skill declares applies_to; test resolves both directions ✅ a_skill_links_to_schema_nodes_and_the_edge_reads_from_both_ends.
7 find_skills scope: targets plus extends subtypes, core included, one batched query; four test cases ✅ get_edge_targets_by_source is one query per 900 sources. All four cases covered and passing with --features nlp.
8 node_types, with_node_types, flat-key fallback deleted ✅ Generated TypeScript regenerated; a closed-schema rejection test was added.
9 Playbook skills create applies_to edges at install (test per playbook) ✅ every_playbook_links_its_skills_to_their_schemas_at_install loops all_playbooks(); re-keyed schema covered.
10 Skill-authoring guidance teaches linking; drift check updated ✅ New "Authoring a skill" section in references/cli.md and link commands in each playbook reference. SKILL.md itself is unchanged.
11 Reconcile by id; unchanged database creates nothing; per-aspect guard kept ✅
12 Deleted seed recreated; archived stays archived ✅
13 Prompt in table order; test seeds in reverse creation order ✅ The test exists as specified, but it passes against the pre-fix code. See finding 1.
14 Root agent-guidance node outside the table is not in the prompt (test) ✅
15 Archived section omitted (test) ✅
16 Snapshot builds the prompt through production's path; golden regenerated ✅ Goes through PromptAssembler::assemble() over a seeded database. The golden has no diff, because it already pinned table order.
17 ADR-060 §5 ordering checked ✅ Play ids are unchanged by this PR (already UUIDs on main), so rule order does not move here. I did not independently audit every rule's actions.
18 Companion docs: ADR-072 amendment, prompt-skill-system.md rewritten ❌ partial ADR-072 amended, seeded-nodes.md, typed-relationships.md and the skill sheet match the code. prompt-skill-system.md still has two stale statements. See finding 3.
19 test:changed, quality:fix, Pro-boundary not verified Pro-boundary, literal-comparison and lifecycle checks are clean. The rest I did not run.

Node type sequence (skill): registry and closed schema updated, wire type changed once in nodespace-types, TypeScript regenerated, node-types.md sheet matches, tests for the relationship and the undeclared-key rejection. None of the Critical triggers apply: no literal node_type comparison, no lifecycle_status read (the assembler calls governance::participates), no id list where a relationship belongs, no compatibility code.

Code Review Findings

🟡 1. The table-order test passes against the bug it is named for

📁 packages/agent/src/prompt_assembler.rs:586-628

sections_are_assembled_in_table_order_not_creation_order seeds the sections last-first and asserts that table row 0 is the newest node:

assert!(
    created.windows(2).all(|pair| pair[0] > pair[1]),
    "the fixture must create the sections in reverse table order: {created:?}"
);

The pre-fix read was newest-first (origin/main packages/core/src/ops/node_ops.rs:562, OrderBy::CreatedDesc). Over this fixture a newest-first read returns row 0 first, which is table order, so the old assembler passes this test. The doc comment says the fixture's order "is the order a newest-first read would have assembled them in", which is the reverse of what happens.

The regression is still caught, but by a different test: resident_system_prompt_matches_golden seeds in table order, where a newest-first read reverses the prompt. So coverage exists across the two tests; this one only catches an oldest-first read.

Recommendation: create the sections in an order that is neither ascending nor descending (for example table indices [2, 0, 4, 1, 3]), so no read ordered by creation time in either direction can match the table, and correct the comment. I verified this by reading both orderings, not by running the old code.

Principle: a regression test should fail on the code it guards against; this is also the issue's own stated purpose for the test.

🟡 2. Two model-facing changes ship unmeasured, and the PR body names one

📁 packages/agent/src/prompt_assembler.rs:294-319, packages/core/src/ops/skill_ops.rs:368-385, packages/core/src/methodology/spec_driven.rs:117,129

The PR body says the spec-driven task link "is the one model-facing change in the PR". There is a second, larger one: the resident system prompt's section order reverses in production. On main the live prompt ran "Tool Call Formatting" first and "Core Identity" last; after this PR it is the table's order. The golden did not move only because it pinned an order production never produced. This is the intended fix, but every eval baseline taken through the daemon was measured on the reversed prompt.

On the first change, the linked branch is uncapped and follows extends to any depth. Linear's issue and Jira's epic, story and bug all extend task, so in a workspace with spec-driven plus either of those, "Completing a Spec-Driven Task" and "Creating Implementation Tasks" carry task plus every one of those subtypes' definitions. That matches the issue's spec; the cost and the effect on which type the model picks are what is unmeasured. I confirmed the expansion from linked_schemas and its unit test, not from a multi-playbook run.

Recommendation: correct the PR body, and run the matrix (several reps, given how noisy single runs are) before and after on a purged database with a rebuilt daemon. If the multi-playbook case is a concern, measure it before deciding whether a linked core type should bring its subtypes.

Principle: prompt changes are behaviour changes; a claim about what is model-facing should be complete so the reviewer knows what was and was not measured.

🟡 3. Companion docs and one comment still describe assemble_static(), which this PR deletes

📁 nodespace-docs/architecture/prompt-skill-system.md:277,281, packages/agent/src/local_agent/agent_loop.rs:5086

  • Line 281 of the doc says integration tests "use PromptAssembler::assemble_static(), which builds the base prompt from the same seed table". The function is removed in this PR and nothing replaces it.
  • Line 277 says a shared rule is a fragment that "the seed bodies, the tool descriptions and the SKILL.md generator all include". No tool description includes one, as the PR body and seeded-nodes.md both say.
  • agent_loop.rs:5086 documents set_system_prompt as taking a prompt "constructed via PromptAssembler::assemble_static". That comment predates the PR, but the PR is what makes it wrong. set_system_prompt has no caller anywhere in packages/.

Recommendation: fix the two doc sentences and the comment. Consider deleting set_system_prompt and its system_prompt_override plumbing, since it is unused and its only documented use is gone.

Principle: the issue lists the doc rewrite as an acceptance criterion; docs that name a deleted function send the next reader to code that is not there.

🟢 4. Three comments on declaration storage omit the schema-targeted case

📁 packages/core/src/db/sqlite_store/relationships.rs:2190-2192, packages/core/src/db/schema.rs:81-89, packages/core/src/models/schema.rs:18-20

Each says a declaration is a self-edge "when untyped" and that only an untyped relationship's instance edge may point at a schema node. declaration_out_node and the edge check now add a second case (target_type: "schema"). declaration_out_node's own comment is accurate; these three were not updated.

Recommendation: one clause in each, or point them at declaration_out_node.

🟢 5. Stale comment in the reinstall test, and what a second install does to links

📁 packages/core/tests/it/methodology_linear_install_test.rs:449-452, packages/core/src/methodology/install.rs:220-262

The comment says "skills reconcile by seed key rather than colliding"; they now reconcile by id. Related behaviour worth knowing, from reading seed_skill rather than running it: on a second install the same skill node keeps its edges to the first install's schemas and gains edges to the re-keyed ones, while its body is replaced with the second install's re-key note. The body overwrite is the same as on main; the accumulating edges are new. I think that outcome is acceptable, but nothing asserts it.

Recommendation: fix the comment; optionally add one assertion to installing_twice_re_keys_rather_than_failing_or_overwriting pinning the links after the second install.

🟢 6. guidance_sections reads the five sections one at a time

📁 packages/agent/src/prompt_assembler.rs:294-319

Five sequential get_node calls per assembled prompt, where seeding already uses get_nodes_by_ids for the same ids. Cheaper than main (one query plus a get_parent per node), so not a regression.

Recommendation: one get_nodes_by_ids read, then iterate GUIDANCE_SEEDS for order.

🟢 7. Nits

  • Nit: packages/proto/proto/node_service.proto:473 still lists "prompt" as a seeded node_type; the PR edits the neighbouring lines.
  • Nit: the hand-written "Authoring a skill" section in references/cli.md names applies_to and skills literally, with no test tying it to SKILL_APPLIES_TO (the generated playbook references do use the constant).
  • Nit: CORE_PLAY_IDS exists only for the two tests that read it. core_plays().map(|p| p.id) exported for the test would avoid a second list to keep in step.
  • Nit: ADR-086 §10 still lists "tool descriptions" among the consumers of shared fragments; seeded-nodes.md explains why none is. A one-line amendment would keep the ADR and the component doc in agreement.

Deviations listed in the PR body

  • Two fragments per rule: sound. The two surfaces name the same operation differently, the split predates this PR, and the anchor and JSON-example tests still tie the forms together.
  • No tool description includes a fragment: reasonable under ADR-064. I did not re-check every tool description against every rule, so the "one JSON example and one clause" claim is unverified.
  • applies_to targets schema via a self-edge: sound. It reuses the untyped-declaration storage, the instance edge is still told apart by its source, and a non-schema target is refused by the ordinary target-type check (tested). A user schema cannot declare targetType: "schema", because validate_relationship_targets requires the target to be an existing schema node, so the widened edge check is reachable only through the core declaration.
  • Content move is lossless: consistent with what I can see (golden unchanged, checked_in_skill_md_is_up_to_date passes). I did not reproduce the 78-row dump.
  • Existing databases need a reset: correct, and the right call under the no-migration rule.

Not verified

  • nodespace-docs/components/seeded-nodes.md and the skill sheet in node-types.md describe routed turns being "held to the linked set" (an enum on type parameters and a dispatch-time refusal). I found no such enforcement in this branch. I am assuming that is intended design tracked elsewhere, not part of this issue.

Recommendation: APPROVE — no blockers. Findings 1 to 3 are worth addressing before merge; none changes shipped behaviour.

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

@malibio

malibio commented Oct 2, 2026

Copy link
Copy Markdown
Collaborator Author

Review addressed (commit 6eb915a7)

Addressed

  • 1. Table-order test. The fixture now creates the sections in the order [2, 0, 4, 1, 3], so a read ordered by creation time assembles them wrongly in either direction, and the fixture asserts its own order is neither ascending nor descending. The comment is corrected.
  • 2. PR body. It now names both model-facing changes: the resident prompt's section order reversing in production, and the task links (including that a linked type brings its subtypes in a multi-playbook workspace).
  • 3. Stale docs and comment. prompt-skill-system.md no longer names assemble_static() or says tool descriptions include fragments (nodespace-docs 8e133ab), and the set_system_prompt comment is corrected.
  • 4. Declaration-storage comments. All three now cover a declaration that targets schema nodes.
  • 5. Reinstall test. The comment says skills reconcile by id, and the test now pins a skill's links after a second install: the first install's schema and the re-keyed one.
  • 6. One read for the guidance sections. guidance_sections uses get_nodes_by_ids, then iterates the table for order.
  • Nits. The proto comment no longer lists prompt as a seeded type, and ADR-086 §10 no longer lists tool descriptions among fragment consumers.

Skipped

  • Running the eval matrix before and after. It needs the generative model for several reps on a purged database with a rebuilt daemon. The order reversal is the issue's stated intent, so a measurement would inform prompt tuning rather than decide this change. Worth doing as its own eval run after merge.
  • Deleting set_system_prompt. It is unused, but it predates this PR and removing it is unrelated cleanup.
  • Replacing CORE_PLAY_IDS with an exported core_plays(). The id list is what the cross-table test needs, and the_id_table_matches_the_seeded_plays keeps it in step with the seeded plays.
  • A test tying the "Authoring a skill" prose to SKILL_APPLIES_TO. The relationship name is a stored, user-visible key; renaming it would already break the schema, the tests and the generated playbook references.

Tests: bun run test:changed passes on the pushed tree (frontend, scripts, skill, browser, types drift, Rust workspace).

Re-Review Decision

Decision: NO RE-REVIEW NEEDED

Rationale: The review approved with no blockers. The changes since are a test fixture, comments, docs, one PR-body correction and one small read-path change (five single reads replaced by one batched read of the same ids, covered by the existing assembly tests and the golden).

malibio and others added 2 commits October 2, 2026 17:05
…nt guidance, and link skills to their schemas (closes #3418)

Every seeded node comes from a const seed table with a fixed literal UUID:
agent guidance, the built-in skills and tools, and each bundled playbook's
skills. Guidance and skill bodies are plain .md files, and the shared rules
are .md fragments a body includes by id.

- Seeding reconciles by the root's id. A deleted seed is created again under
  the same id, an archived one stays archived, and a retitled seed renames
  its node in place. _seed.key stays as the handle `skill reset` takes.
- The resident prompt is assembled from the guidance table's ids in table
  order. A guidance node outside the table is not in the prompt, and an
  archived section is left out.
- skill declares applies_to (skill -> schema, Many/Many, reverse skills),
  replacing SkillFields.node_types. find_skills carries a linked skill's
  schemas and their subtypes, read in one query for all candidates.
- Bundled playbook skills drop their frontmatter and link to their schemas
  at install.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…read, and fix stale comments

- The table-order test created the sections last-first, which a
  newest-first read also assembles in table order. It now creates them in
  an order that is neither the table's nor its reverse.
- The assembler reads the guidance sections in one query.
- The reinstall test pins a skill's links after a second install.
- Comments on declaration storage cover a schema-targeted declaration, and
  comments that named assemble_static, the seed key and the retired prompt
  type are corrected.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@malibio
malibio force-pushed the issue-3418-seed-tables branch from 6eb915a to 28dee33 Compare October 2, 2026 15:05
@malibio
malibio merged commit d9f8974 into main Oct 2, 2026
@malibio
malibio deleted the issue-3418-seed-tables branch October 2, 2026 15:05
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.

Seed built-ins from fixed-UUID tables with Markdown bodies, order agent guidance, and link skills to their schemas

1 participant