Repository navigation
Fix unique_case_insensitive wire-key doc mismatch in skill_rules.rs - #2800
Conversation
…loses #2788) SchemaField carries #[serde(rename_all = "camelCase", deny_unknown_fields)], so the accepted wire key is uniqueCaseInsensitive. UNIQUE_FIELD_FLAGS' imperative and prose text documented the Rust field name (unique_case_insensitive) instead, so its example was rejected as an unknown field when copied verbatim. Regenerated packages/skill/references/cli.md's generated schema-rules block from the corrected source, and fixed the same key in that file's hand-written schema create example, which isn't regenerated. Added unique_field_flags_example_matches_schema_field_wire_format, which extracts the JSON example from both doc forms and deserializes it as a real SchemaField, to catch this class of drift going forward. Co-Authored-By: Claude Sonnet 5 <[email protected]>
schema_creation_guidance_covers_unique_field_flags pinned the seeded prompt's substring on the old, incorrect unique_case_insensitive spelling; update it to match the corrected uniqueCaseInsensitive wire key. Co-Authored-By: Claude Sonnet 5 <[email protected]>
The assembled prompt snapshot changed only in the corrected uniqueCaseInsensitive spelling carried over from UNIQUE_FIELD_FLAGS. Co-Authored-By: Claude Sonnet 5 <[email protected]>
…ten example - extract_example_json now delegates brace-balancing to the existing local_agent::tools::extract_json_object, which tracks string-literal state, instead of a hand-rolled counter that would mis-extract an example whose JSON contains a brace inside a quoted string. - Added cli_md_unique_field_worked_example_matches_schema_field_wire_format, which deserializes the params blob out of packages/skill/references/cli.md's hand-written "Create a schema with a unique field" command — the artifact the tracking issue actually reported failing when copied verbatim, and one the generated-block staleness test (checked_in_skill_md_is_up_to_date) cannot cover since it isn't produced from source. Addresses reviewer recommendations from the pragmatic-code-review of PR #2800. Not addressed: generalizing coverage to every SCHEMA_RULES entry with an embedded JSON example — only UNIQUE_FIELD_FLAGS currently uses this "Example:" pattern, and the other rules' embedded JSON is shaped for different types (EnumValue, SchemaRelationship), so a single universal check doesn't fit; scope creep beyond the reported drift. Co-Authored-By: Claude Sonnet 5 <[email protected]>
Address ReviewAddressed both findings from the pragmatic-code-review:
Both new tests were mutation-tested (temporarily reverted the fix, confirmed each fails with a clear message, restored). Full pre-push gate ( Re-Review DecisionDecision: NO RE-REVIEW NEEDED Rationale: Both changes are localized to test-only code in a single file ( |
Summary
UNIQUE_FIELD_FLAGSinpackages/agent/src/skill_rules.rsdocumented the unique-field JSON key asunique_case_insensitive(the Rust struct field name), butSchemaFieldcarries#[serde(rename_all = "camelCase", deny_unknown_fields)](packages/nodespace-types/src/schema.rs), so the actual accepted wire key isuniqueCaseInsensitive. Copying the documented example verbatim intoschema create/schema updatewas rejected as an unknown field.Verified before changing anything that the struct really is the camelCase side (not the other way around):
SchemaField'srename_all = "camelCase"attribute is authoritative, and every other multi-word key in the same doc text (friendlyName,coreValues,userValues) is already correctly camelCase —unique_case_insensitivewas the sole outlier.Changes
packages/agent/src/skill_rules.rs: fixed both theimperativeandproseforms ofUNIQUE_FIELD_FLAGSto useuniqueCaseInsensitive.packages/skill/references/cli.md: regenerated theschema-rulesgenerated block (bun run skill:gen), and hand-fixed the same key in a separate, non-generated worked example ("Create a schema with a unique field") in the same file.unique_field_flags_example_matches_schema_field_wire_format(skill_rules.rs), which extracts the JSON example embedded in both the imperative and prose doc text and deserializes it through the realSchemaFieldtype — the same wire formatcreate_schema/update_schemaaccept — so this class of drift fails a test instead of a live call.schema_creation_guidance_covers_unique_field_flags(skill_pipeline.rs) and thestage2_candidate_blockprompt-assembly golden file, both regenerated/updated to assertuniqueCaseInsensitive.Out of scope, filed separately
While tracing every consumer of this doc text, I found the local agent's own native tool schema (
packages/agent/src/local_agent/tools.rs,def_create_schema/def_update_schema) declares the same wrong key (unique_case_insensitive) for the LLM to emit in a tool call — and that tool call is deserialized through the exact sameSchemaField(exec_create_schema/exec_update_schemapass the raw args straight tohandle_create_schema/handle_update_schema). That means the in-app agent's owncreate_schema/update_schematool calls are also rejected whenever the model sets this flag, which is a functional bug, not just a doc one. That file is Michael's lane (local-agent/skills), so I did not touch it here — filed as a separate issue for a maintainer to pick up.Test plan
bun run test(frontend baseline, unaffected): 260 files / 5240 tests passedcargo test -p nodespace-agent --lib(642 passed) — includes the new regression testcargo test -p nodespace-cli --test skill_md_generation(11 passed, includingchecked_in_skill_md_is_up_to_date)bun run test:all(full pyramid) passed locally before pushtest:all+cargo build --bin nodespaced+test:e2e+ Tauri-seam integration tests) passedCloses #2788
🤖 Generated with Claude Code