Skip to content

Fix unique_case_insensitive wire-key doc mismatch in skill_rules.rs - #2800

Merged
mstomar125 merged 4 commits into
mainfrom
issue-2788-skill-rules-key-mismatch
Sep 22, 2026
Merged

mstomar125 merged 4 commits into
mainfrom
issue-2788-skill-rules-key-mismatch

Conversation

@mstomar125

Copy link
Copy Markdown
Contributor

Summary

UNIQUE_FIELD_FLAGS in packages/agent/src/skill_rules.rs documented the unique-field JSON key as unique_case_insensitive (the Rust struct field name), but SchemaField carries #[serde(rename_all = "camelCase", deny_unknown_fields)] (packages/nodespace-types/src/schema.rs), so the actual accepted wire key is uniqueCaseInsensitive. Copying the documented example verbatim into schema create/schema update was rejected as an unknown field.

Verified before changing anything that the struct really is the camelCase side (not the other way around): SchemaField's rename_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_insensitive was the sole outlier.

Changes

  • packages/agent/src/skill_rules.rs: fixed both the imperative and prose forms of UNIQUE_FIELD_FLAGS to use uniqueCaseInsensitive.
  • packages/skill/references/cli.md: regenerated the schema-rules generated 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.
  • Added 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 real SchemaField type — the same wire format create_schema/update_schema accept — so this class of drift fails a test instead of a live call.
  • Updated two downstream tests whose fixed content was pinned to the old, incorrect spelling: schema_creation_guidance_covers_unique_field_flags (skill_pipeline.rs) and the stage2_candidate_block prompt-assembly golden file, both regenerated/updated to assert uniqueCaseInsensitive.

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 same SchemaField (exec_create_schema/exec_update_schema pass the raw args straight to handle_create_schema/handle_update_schema). That means the in-app agent's own create_schema/update_schema tool 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 passed
  • cargo test -p nodespace-agent --lib (642 passed) — includes the new regression test
  • cargo test -p nodespace-cli --test skill_md_generation (11 passed, including checked_in_skill_md_is_up_to_date)
  • bun run test:all (full pyramid) passed locally before push
  • Pre-push gate (test:all + cargo build --bin nodespaced + test:e2e + Tauri-seam integration tests) passed

Closes #2788

🤖 Generated with Claude Code

mstomar125 and others added 4 commits September 22, 2026 09:18
…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]>
@mstomar125

Copy link
Copy Markdown
Contributor Author

Address Review

Addressed both findings from the pragmatic-code-review:

  • ✅ Reused the existing robust JSON extractor — extract_example_json's hand-rolled brace counter is replaced with a call to local_agent::tools::extract_json_object, which already tracks string-literal state (so a {/} inside a quoted value in a future example won't mis-extract or panic with a misleading message).
  • ✅ Added coverage for the hand-written cli.md worked example — cli_md_unique_field_worked_example_matches_schema_field_wire_format deserializes the --params blob out of the "Create a schema with a unique field" command in packages/skill/references/cli.md and asserts uniqueCaseInsensitive round-trips. This is the exact artifact the original issue reported (a complete CLI command that fails if copied verbatim), and it sits outside the <!-- BEGIN GENERATED --> marker, so the existing checked_in_skill_md_is_up_to_date staleness test can't catch it drifting on its own.
  • ⏭️ Skipped: generalizing the regression test to every SCHEMA_RULES entry with an embedded JSON example. Only UNIQUE_FIELD_FLAGS currently uses the "Example: {...}" pattern this test keys on; the other rules' embedded JSON snippets are shaped for different types (EnumValue, SchemaRelationship, edge-field declarations), so a single universal deserialization check doesn't fit without meaningfully more machinery. Scope creep beyond the reported drift — flagged for a future PR if a second rule adopts this pattern.

Both new tests were mutation-tested (temporarily reverted the fix, confirmed each fails with a clear message, restored).

Full pre-push gate (test:all + cargo build --bin nodespaced + test:e2e + Tauri-seam integration tests) passed on the follow-up push.

Re-Review Decision

Decision: NO RE-REVIEW NEEDED

Rationale: Both changes are localized to test-only code in a single file (packages/agent/src/skill_rules.rs), with no change to production doc text or runtime behavior beyond what the initial review already verified. One change reduces duplication by calling an existing, already-reviewed helper; the other is a straightforward additive test following the exact pattern of the one the reviewer was evaluating. Low-risk, mechanical, and fully covered by tests that were run and mutation-verified.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant