Repository navigation
Fence JSON examples in skill guidance so they seed as code-block nodes (closes #1965) - #1972
Conversation
closes #1965) Skill guidance is seeded through a real markdown import (prepare_nodes_from_template -> prepare_nodes_from_markdown), which turns ``` fences into code-block nodes. The guidance source never used fences, so its worked JSON examples were absorbed into prose text nodes instead. That was not only a structural loss. Because an unfenced example lands in a text paragraph, whose continuation lines are trim_start()ed, the JSON came back from the round trip with all indentation stripped and every line flushed to column 0. Fencing restores the examples verbatim, indentation included, so the model-facing text is unchanged in content and strictly better formatted. - Fence the Node Creation call-shape example and both Schema Creation schema examples as ```json. - Use inline code spans for short inline call shapes (search_nodes(...), enum/relationship fragments), matching what the sibling `prose` variants of the same rules already do. - Widen seed_skill_children_are_real_markdown_types_not_prompt to admit code-block, and add a test asserting the expected code-block children appear, keep their ```json fence verbatim, and parse as valid JSON. SKILL.md is unaffected: gen_skill_md renders the `prose` variants, and `--check` reports it up to date. Co-Authored-By: Claude <[email protected]>
Code Review: PR #1972 — Fence JSON examples in skill guidanceReview Type: Initial review (no prior reviews/comments on this PR) SummaryThis is a tightly scoped, well-diagnosed fix. The issue framed it as a cosmetic markdown-hygiene problem; the author found the real defect underneath — unfenced JSON was not merely "unstructured", it was being corrupted on round-trip. I independently verified that claim rather than taking it on faith, and it holds (evidence below). The change is a net improvement to the model-facing prompt with no meaning change, verified test coverage, and no Verdict: APPROVE. No blocking findings. Two minor observations below, neither worth holding the merge. Requirements Check (issue #1965)AC 1 — "All JSON worked examples across the six guidance functions use proper I audited every
Nothing was missed. The four guidance functions with no JSON genuinely have none — they are prose-plus-interpolated-rules only. The single-line call shapes in Research & Search correctly got inline code spans rather than fences, which is the right call: a fenced block per bullet would have fragmented a list into eight The issue also asked to check that header-based visual grouping isn't accidentally converted into spurious child splits. The diff touches no AC 2 — " The author did both halves properly: widened the existing test to admit the new legitimate type, and added a dedicated positive assertion ( AC 3 — "No regression in how the guidance renders as LLM prompt text." — ✅ MET (verified empirically, not assumed) This is the AC that actually mattered, since this repo has hard-won memory that skill guidance wording is load-bearing and that prompt changes have measurably moved agent behavior. I did not take the commit message's claim on trust. I built a throwaway probe that drives the real Old (unfenced) — Node Creation, as the model actually received it: New (fenced): {
"node_type": "widget",
"content": "Shipment 24",
"properties": {
"label": "Shipment 24",
...
}
}The empirical claim is confirmed. Every line was previously flushed to column 0 — the paragraph parser Worth recording for future prompt-eval work: this is a case where the rendered prompt changed even though nobody edited the prose. Anyone re-baselining agent eval numbers against pre-#1965 runs should know the Node/Schema Creation prompts materially improved here. Code Review Findings🟢 Brace escaping is correct — verified by execution, not inspectionThe trap flagged in this area is real: 📁 🟢 New test is meaningful, not a restatement of the implementation — mutation-verified📁 That is a genuinely useful failure message — a future contributor who reflows this guidance and drops a fence gets told what broke and why it matters, not just a count mismatch. The test asserts three independent properties (count, fence preserved verbatim, body parses as JSON), each of which fails independently. This is real coverage. On the hardcoded counts ( 🟢 Widening
|
| Check | Result |
|---|---|
cargo test -p nodespace-agent (full crate) |
✅ 467 passed, 0 failed |
cargo test -p nodespace-agent --lib skill |
✅ 40 passed, incl. both changed/new tests |
| Mutation test: remove a fence → new test fails? | ✅ fails with a clear, causal message |
| Round-trip prompt diff, fenced vs unfenced | ✅ indentation-loss claim confirmed; no content change |
Fenced JSON validity post-format! |
✅ serde_json parses both blocks |
gen_skill_md -- --check |
✅ up to date |
cargo fmt --check / cargo clippy --all-targets |
✅ clean, no new warnings, no lint suppression |
Primary checkout + worktree git status |
✅ both clean (probe removed) |
Not attributed to this PR: the pty::manager and frontend architecture-benchmarks / navigation-service failures are known load-sensitive flakes in this repo and cannot be affected by a Rust-only change to two files in packages/agent.
Recommendation: ✅ APPROVE
Atomic, single-purpose, correctly diagnosed, and verified end-to-end. The author went past the issue's stated ask — which was essentially "make the markdown tidy" — and identified that the untidy markdown was actively corrupting the model-facing prompt, then proved it with a test that fails for the right reason. Both nits are optional and neither should block. Ship it.
malibio
left a comment
There was a problem hiding this comment.
Verdict: APPROVE (posted via --comment because GitHub blocks self-approval on your own PR.)
Full review: #1972 (comment)
All 3 acceptance criteria from #1965 are met. Completeness audited across all six *_guidance() functions plus both inline seed_skill_nodes() blocks — multi-line JSON exists in exactly two places and both are fenced; the other four functions genuinely contain no JSON.
AC #3 was verified empirically rather than assumed: I reconstructed the render_skill_instructions → flatten_subtree_content round trip for both the fenced and de-fenced sources and diffed the model-facing text. The indentation-loss finding is confirmed — unfenced JSON was previously reaching the model with every line flushed to column 0. This change is a strict improvement to the prompt, with no wording or semantic drift.
Also verified: brace escaping is correct in the format! block (proven by the new test's serde_json parse, not by inspection); the new test is mutation-sensitive (removing a fence fails it with a causal message); widening the not_prompt test does not weaken its guard, since the newly-admitted code-block type is now positively asserted elsewhere; and gen_skill_md --check confirms SKILL.md needed no regeneration.
cargo test -p nodespace-agent — 467 passed, 0 failed. fmt + clippy clean.
Two 🟡 nits only, neither blocking: a cosmetic blank-line inconsistency after one closing fence, and a pre-existing (not introduced here) list-bullet flattening loss in the same round-trip path that's worth its own follow-up issue rather than scope creep on this PR.
Address Review SummaryReview verdict was APPROVE with zero 🔴 Critical and zero blocking findings — five 🟢 confirmations and two 🟡 nits, both explicitly marked optional by the reviewer. Ran Result: no code changes. 0 commits. Both nits resolved as no-op, one by filing a follow-up issue. ⏭️ Skipped: 🟡 Nit — inconsistent blank line after closing fenceSkipped: the premise is incorrect — there is no inconsistency. The finding compares two fences that are in structurally different positions:
Each is already correct for its own context; they differ because the contexts differ, not because one is wrong. "Making them consistent" would mean making one of them worse. The reviewer reached the same practical conclusion ("purely source-file consistency... not worth a commit on its own") — I'm additionally noting the stated inconsistency isn't real. ⏭️ Skipped here → ✅ filed as #1974: 🟡 List bullets are lossy through the same round-tripVerified the claim before acting on it, rather than taking it on faith. Confirmed:
This is real and is the same root-cause family as the indentation loss this PR fixes: It is pre-existing, not introduced by this PR, affects every guidance block rather than anything this diff touched, and fixing it would change the model-facing prompt for all skills — which needs measurement, not a drive-by edit. Both the reviewer and I agree it should not expand this PR. Captured with full diagnosis as #1974, cross-referenced to #1958. VerificationNo code changed, so the pre-push gate result from the reviewed commit Re-Review DecisionNO RE-REVIEW NEEDED — zero lines of code changed since the review. The only action taken was filing a follow-up issue for an out-of-scope, pre-existing defect. There is no new diff for a reviewer to examine.
|
Closes #1965.
What
Skill guidance is seeded through a genuine markdown import (
prepare_nodes_from_template→prepare_nodes_from_markdown), which turns```fences intocode-blocknodes. The guidance source text never used fences, so its worked JSON examples were absorbed into prosetextnodes.The gap was worse than "flattened into prose"
Confirmed by dumping the rendered guidance before and after. Because an unfenced example lands in a
textparagraph — whose continuation lines aretrim_start()ed — the JSON came back from the round-trip with all indentation stripped, every line flushed to column 0:With fences, the block round-trips verbatim (
flatten_subtree_contentre-emits each node's content as stored):{ "node_type": "widget", "content": "Shipment 24", "properties": { "label": "Shipment 24",So AC #3 ("no regression in prompt rendering") is met with room to spare: same content, same tokens, correctly indented, plus explicit example boundaries.
Changes
```json.search_nodes(...), enum and relationship fragments) — matching what the siblingprosevariants of the sameskill_rulesconstants already do.seed_skill_children_are_real_markdown_types_not_promptto admitcode-block(it previously whitelisted onlyheader | textand would have failed).seed_skill_json_examples_produce_code_block_children, asserting the expectedcode-blockchildren appear, keep their```jsonfence verbatim, and parse as valid JSON viaserde_json.Verification
cargo test -p nodespace-agent --lib— 467 passed.cargo test -p nodespace-core --lib— 1133 passed.gen_skill_md --check— SKILL.md up to date. It renders theprosevariants; onlyimperativevariants were touched, so there is no drift.test:all+cargo build+ e2e) passed.architecture-benchmarks.test.tsandnavigation-service.test.tsflaked once under full-suite parallel load and both pass in isolation — this change is Rust-only and cannot affect them.Acceptance criteria
```jsonfences.code-blocknodes are produced where expected.🤖 Generated with Claude Code