Repository navigation
Add a discoverable schema delete subcommand (closes #2397) - #2435
Conversation
Deleting a schema already worked — schemas are nodes, so `node delete <id>` removed one — but nothing in the CLI's own surface said so. `schema --help` listed four verbs, which reads as the complete set of operations on that noun, so an agent enumerating the group saw a deliberate omission rather than a redirect and reported the capability as missing. Since `schema create` is available to agents, that asymmetry let an agent add schemas to a workspace and then report the mess as unfixable. Adds a real `schema delete <id>` rather than documenting the `node delete` path, because the help output is what an agent enumerates: `references/cli.md` generates its "Complete command surface" by walking `Cli::command()`, so the new clap variant propagates into the shipped agent guidance automatically and cannot fall behind the binary. A prose redirect would have been cheaper but would live only where an agent has to already be reading. The subcommand dispatches to the same `DeleteNode` RPC, so the daemon's existing guard still applies: a schema carrying relationship declarations is rejected with `schema_has_declarations`, naming the count and the fix. That prerequisite is now stated in advance rather than discovered by hitting it. Guidance (a CLI capability agents don't know about is one that doesn't exist): - `skill_rules.rs` gains a DELETE_A_SCHEMA rule stating the recognition trigger — asked to remove/drop/undo/clean up a type, including a throwaway one the agent created itself — not just the conclusion, and naming the stripping-to-an-empty-shell workaround as the thing not to do. - The rule frames the prerequisite as the mirror of the existing targetType rule: a relationship's target must exist to declare it, and must be absent to delete the type it points at. - `SKILL.md`'s "Delete a node" section covers the type case alongside it. Two incidental trims keep the SKILL.md body within its 5000-token budget, which it was already within ~20 characters of: the ticket example's inline enum blob (duplicated in full in `references/cli.md`) is reduced to its shape, and the "Build a knowledge graph session" snippet is dropped as it only restated the Preflight Check and save-as-you-go guidance above it. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01KwcVcLdvBUjSkUFmtFNiTY
The delete rule was wired into the shipped SKILL.md but not into the local agent's seed prompt, so only the external shell agent got the fix. The in-app agent is the surface holding BOTH create_schema and delete_node, which means it reproduced the exact create/delete asymmetry this work exists to close: asked to drop a type it had just created, its prompt carried EDIT_DONT_RECREATE and RENAME_VS_RELABEL but nothing about deletion. `schema_creation_guidance()` is the sole renderer of `imperative` for this rule family, per the contract in skill_rules.rs, so DELETE_A_SCHEMA now interpolates there alongside the other procedure rules. The prompt-assembly golden is updated accordingly — the diff is exactly the new paragraph, which is the confirmation that the rule now reaches the model. Scoping corrections to the rule text, in both forms: - Only declarations BETWEEN SCHEMAS block the delete. The guard counts edges whose endpoints are both schema nodes, so instance edges are irrelevant; the previous "relationship declarations" phrasing was broad enough to send an agent unpicking instance data it never needed to touch. - Deleting a type does not delete its instances. Since the rule actively pushes agents toward deletion, saying so prevents both over-promising to the user and a needless refusal to delete. Also: name type deletion in the consent rule (it is strictly more destructive than node deletion, which was already named), assert the declaration count in the CLI test since the guidance tells agents to act on that count, and trim the delete fn doc to the part the clap variant doc does not already state. Skipped: a companion test asserting that every SchemaRule's `imperative` reaches the seed prompt. Five of the fifteen rules are prose-only by design — the argument-shape rules moved onto create_schema's own tool schema under ADR-064 — so such a test needs a hand-maintained exclusion list encoding that decision, which is a drift source of its own. The golden snapshot already fails loudly on any change to what the prompt sends, which covers the regression that matters. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01KwcVcLdvBUjSkUFmtFNiTY
Review addressed — c49c21bThanks for the verification pass; the Important finding was correct and is the substantive fix here. ✅ Addressed🟡 1 — Added 🟢 2 — Prerequisite framing narrower than the guard. Fixed in both
This costs nothing against the SKILL.md cap: the 🟢 3 — Consent discipline. 🟢 4 — Test assertion. Added a count assertion. Worth noting it caught a real error: I first asserted 🟢 5 — Redundant doc comment. Trimmed the ⏭️ Skipped (1)Companion test asserting every Also per your note, the Testing
🤖 Generated with Claude Code |
`main` is currently red: `object_property_round_trips_through_relationship_get` declares `held_at -> venue` with no `reverseName`/`reverseCardinality`, which the validation added in #2437 rejects, so the test fails at schema creation before reaching what it exists to verify. Neither PR's gate could have caught this. #2436 added the fixture and #2437 added the rule; each was validated against a base that predated the other, and the squash merges landed 33 minutes apart. This is the same collision #2437's review caught between #2435 and #2437 — the third instance of a green gate on a stale base proving nothing about the merge result. A concert is held at one venue and a venue hosts many concerts, so the inverse is `concerts`/`many`. Claude-Session: https://claude.ai/code/session_01KHdtH4eZHiU7RzhCuHArQX Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
…prompt (#2479) * Guard against a SCHEMA_RULES entry silently missing the in-app agent prompt (closes #2438) Adds schema_rules_are_wired_or_explicitly_excluded, a test that checks every SCHEMA_RULES entry is either interpolated into schema_creation_guidance() (the in-app agent's prompt) or named in the new SCHEMA_RULES_NOT_IN_PROMPT exclusion list, with the ADR-064 rationale recorded inline for the five field/enum shape rules that are deliberately prose-only. This closes the gap that let DELETE_A_SCHEMA (PR #2435) reach the shipped SKILL.md without ever being wired into the in-app prompt: the existing every_schema_rule_reaches_the_skill test only checks the SKILL.md renderer, and the prompt_assembly_snapshot golden cannot catch an unwired rule since it never changes the rendered output. Verified the new test actually fails on an unwired rule and on a wrongly-excluded one before finalizing the failure messages, which name the two concrete fixes (wire it, or exclude it with a reason) rather than just reporting a mismatch. Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01KwcVcLdvBUjSkUFmtFNiTY * Fix enum-edge-fields exclusion comment to state the truth Review of PR #2479 caught that the enum-edge-fields entry in SCHEMA_RULES_NOT_IN_PROMPT claimed enforcement via create_schema's edgeFields tool-schema description. Neither create_schema nor update_schema takes an edgeFields parameter (local_agent/tools.rs) -- the only enforcement is the post-hoc validator in packages/core/src/schema/mod.rs, which runs after the model has already committed to a shape. That's exactly the failure mode ADR-064 exists to prevent for this rule category. Rewrote the comment to say so plainly: the rule sits in the exclusion list per ADR-064's intent, but the tool-schema side that intent describes hasn't been built for this specific rule yet. Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01KwcVcLdvBUjSkUFmtFNiTY --------- Co-authored-by: Claude Sonnet 5 <[email protected]>
Closes #2397.
The defect
Deleting a schema already worked — schemas are nodes, so
node delete <id>removed one — but nothing in the CLI's own surface revealed it.nodespace schema --helplistedlist/get/create/update, and a subcommand group listing four verbs reads as the complete set of operations on that noun. An agent enumerating the group saw a deliberate omission rather than a redirect, told the user the capability did not exist, and proposed stripping the schema to an empty shell instead.Because
schema createis available to agents, that asymmetry meant an agent could add schemas to a user's workspace and then report the mess as unfixable.Decision: a real subcommand, not prose
The issue left this open. I added
nodespace schema delete <id>.The deciding factor is what an agent actually enumerates.
packages/skill/references/cli.mdgenerates its "Complete command surface" section by walkingCli::command()(packages/cli/examples/gen_skill_md.rs), so a new clap variant propagates into the shipped agent-facing guidance automatically and, per that generator's own contract, cannot fall behind the binary. A redirect line inschema --helpwould have been cheaper, but it lives only where an agent has to already be reading — and the failure mode here was precisely an agent trusting the verb list.The subcommand dispatches to the same
DeleteNodeRPC, so it is a discoverability fix rather than a new code path. The daemon's existing guard still applies unchanged: a schema still carrying relationship declarations is rejected withschema_has_declarations, naming the remaining count and the fix. That satisfies the issue's "handle the prerequisite itself, or fail with the same actionable message" criterion via the second branch.Guidance (same PR, per the standing rule)
A CLI capability agents don't know about is one that doesn't exist. Edited the sources of truth, not the generated output:
packages/agent/src/skill_rules.rs— newDELETE_A_SCHEMArule, added toSCHEMA_RULES. It states the recognition trigger rather than only the conclusion: asked to remove, drop, undo or clean up a node type — including a throwaway type you created yourself this session. It names the superseded workaround explicitly ("never propose stripping a schema to an empty shell"), so the pattern is removed rather than left standing alongside. The prerequisite is stated in advance, including the non-obvious half — a declaration on another type that targets this one blocks it too — and framed as the mirror of the existingtargetTyperule: a relationship's target must exist to declare it, and must be absent to delete the type it points at.packages/cli/examples/gen_skill_md.rs— renders the new rule into the generatedschema-rulesregion.packages/skill/SKILL.md— the "Delete a node" task now covers the type case alongside the node case, so the two deletion paths sit together rather than the type case being a footnote elsewhere.packages/skill/references/cli.mdis partly generated and was updated by runningbun run skill:gen, never by hand: three marker-delimited regions (schema-rules,cli-surface,builtin-relationships) come fromskill_rules.rs, the clap derive, andBUILTIN_RELATIONSHIP_NAMESrespectively. The surrounding worked-example prose is hand-maintained and outside the markers, so the delete sequence was added there directly. Thenodespace-skillrepo is published from these files byscripts/publish-skill-repo.tsand was not touched.Two incidental trims, flagged for review
skill_md_body_is_within_spec_size_recommendationscaps the SKILL.md body at ~5000 tokens, and the body was already within ~20 characters of that ceiling — so any addition overflowed it. The test's own instruction is to move detail intoreferences/. Rather than erode unrelated guidance, I cut duplication:references/cli.mdverbatim, which the comment now points at.Both are judgment calls beyond the strict scope of the issue, so they're worth a look.
Testing
schema_delete_requires_relationship_declarations_removed_firstinpackages/cli/tests/cli_integration.rscovers the full loop: a self-referential declaration blocks the delete, the rejection names both the guard and the fix, clearing the declaration unblocks it, and the deleted schema no longer resolves.bun run test:all— frontend 233 files / 4900 tests passed, identical to baseline; no new failures anywhere.cargo build --bin nodespaced+ full e2e) passed.🤖 Generated with Claude Code
https://claude.ai/code/session_01KwcVcLdvBUjSkUFmtFNiTY