Skip to content

Delete the create_schema description-inference route: an undocumented second meaning for the description parameter, with a 27% silent-wrong-type rate - #1833

Merged
malibio merged 2 commits into
mainfrom
worktree-issue-1800-delete-schema-inference
Jul 30, 2026
Merged

malibio merged 2 commits into
mainfrom
worktree-issue-1800-delete-schema-inference

Conversation

@malibio

@malibio malibio commented Jul 30, 2026

Copy link
Copy Markdown
Collaborator

Closes #1800

Removes the undocumented second meaning of create_schema's description
parameter: omitting fields used to parse description into a field list via
substring matching (contains_any), which mistyped 27% of realistic
descriptions (e.g. "notes" -> boolean, "summary" -> number). fields is now
required; the reserved-core-property shadowing warning moves to run over
explicit fields instead of being lost with the inference path.

Co-Authored-By: Claude <[email protected]>
@malibio

malibio commented Jul 30, 2026

Copy link
Copy Markdown
Collaborator Author

Code Review Summary

Clean, atomic deletion that does exactly what issue #1800 asked for and nothing else. create_schema's undocumented description→fields inference route (~450 lines of substring-matching heuristics with a measured 27% silent-mistype rate) is fully removed, fields is now required and validated with the correct None vs Some(vec![]) semantics, the reserved-property shadowing check was successfully relocated onto the explicit-fields path, and every deleted symbol's test coverage was deleted or replaced with tests of the new behavior — not weakened. Verified via rg across the whole worktree, cargo check --workspace (clean, no warnings), and cargo test -p nodespace-core --lib schema:: (46/46 passing) that there are no stale references and no regressions. This is a strict net positive: it removes a maintenance burden and a footgun, replaces it with a simpler and strictly more predictable contract, and loses no expressive capability (SchemaField already natively supports required and user_values/enum, so AdditionalConstraints was pure redundancy).

Requirements Check (issue #1800 acceptance criteria)

  1. Inference route gone; no fields → no silent property-less schema — ✅ PASS
    packages/core/src/schema/mod.rs:252-259: let Some(explicit_fields) = params.fields else { return Err(...) }. Confirmed by test test_create_schema_without_fields_key_is_rejected (schema_test.rs:16-43), which now asserts result.expect_err(...) where it previously asserted success. Ran and passing.

  2. Tool-schema description text matches exactly — ✅ PASS
    packages/agent/src/local_agent/tools.rs:644: "Brief prose summary of what this entity type represents. This is NOT parsed into fields — define every field explicitly in \"fields\"." — byte-for-byte match to the issue's required text.

  3. RESERVED_CORE_PROPERTIES warning fires on explicit fields, with a non-vacuous test — ✅ PASS
    New reject_reserved_property_names (mod.rs:113-127) runs on every create_schema call now (mod.rs:261). test_reject_reserved_property_names_warns_on_collision (mod.rs unit tests) asserts the warning fires for "status" and explicitly asserts it does not fire for "capacity" — a real negative case, not a vacuous "warnings is non-empty" check. Integration-level test_create_schema_reserved_property_warning_reaches_response (schema_test.rs:256-317) additionally confirms the warning survives serialization into the response JSON and that the field is still stored verbatim (not rewritten). This satisfies "a test that would fail without this check present" — deleting the reject_reserved_property_names call at mod.rs:261 would fail both tests.

  4. AdditionalConstraints / additional_constraints fully removed, CLI docstring updated — ✅ PASS
    Struct and field removed from mod.rs. packages/cli/src/commands/schema.rs:3-9 docstring no longer lists additional_constraints among the nested shape's fields. The only surviving references to the string additional_constraints in the worktree are in schema_test.rs, in a test (test_create_schema_rejects_additional_constraints_as_unknown_field) that positively asserts it is now rejected as an unknown field by #[serde(deny_unknown_fields)] — correct and intentional.

  5. No remaining references to deleted symbols anywhere in the workspace — ✅ PASS
    Ran the exact rg pattern from the review brief against the worktree root; zero matches for any of parse_field_descriptions|infer_field_type|AdditionalConstraints|normalize_inferred_fields|contains_any|STRIPPABLE_TYPE_KEYWORDS|INTRINSIC_KEYWORD_PREFIXES|InferredField|extract_field_name|extract_before_paren|extract_before_keyword|strip_trailing_type_keyword|extract_enum_values|is_field_required|apply_constraints outside of comment references in tests confirming rejection. normalize_field_name and to_title_case (helper functions only used by the deleted inference code) are also fully removed with no orphaned callers. cargo check --workspace is clean.

  6. Tests updated/deleted, not weakened; no .contains() reintroduced on field lists — ✅ PASS
    Reviewed all .contains() usages remaining in schema_test.rs (33 call sites). All are legitimate: error-message substring checks (msg.contains("fields")), or exact-set membership checks on a fully-enumerated, asserted-length field list (e.g. schema_test.rs:1388, names.contains(&"seats") && names.contains(&"address") where names.len() is asserted immediately above). None reintroduce the "fuzzy substring match used to validate inferred output" anti-pattern the issue is eliminating — that pattern doesn't exist anywhere in the surviving code since the inference engine that produced fuzzy output is gone. The deleted tests (test_parse_field_descriptions_*, test_infer_*, test_apply_constraints_*, test_integration_* inference tests, the two test_create_schema_paths_agree_on_stored_field_names* cross-path-parity tests) are all tests of the deleted code — correctly removed, not "weakened." New/renamed replacements (test_create_schema_with_explicit_empty_fields_succeeds, test_create_schema_without_fields_key_is_rejected) assert exact field-list length and exact stored names, which is strictly tighter than what they replaced.

  7. description parameter itself preserved (still stored via create_description_subtree) — ✅ PASS
    mod.rs:279-282 computes description_text from params.description (defaulting to "Schema for {name}" if absent — pre-existing behavior, unchanged by this PR) and mod.rs:319 still calls create_description_subtree(node_service, &created_schema_id, &description_text). CreateSchemaOutput.description also still round-trips it. Confirmed by passing test test_create_schema_stores_description_as_child_subtree. Only the parsing-into-fields behavior was deleted, exactly as scoped.

One thing to double-check very closely: None vs Some(empty)

Verified directly. CreateSchemaParams.fields is typed #[serde(default)] pub fields: Option<Vec<SchemaField>> (mod.rs:167-168) — #[serde(default)] on an Option<T> field resolves the absent-key case to Option::default() = None, and a present "fields": [] deserializes to Some(vec![]). No unwrap_or_default() or other collapsing operation is applied before the presence check — the handler does let Some(explicit_fields) = params.fields else { ... } (mod.rs:252), which correctly treats None as an error and Some(vec![]) as a valid zero-length Vec<SchemaField> that flows straight into reject_reserved_property_names.

Both required tests exist and pass:

  • test_create_schema_with_explicit_empty_fields_succeeds (schema_test.rs:60-118) — sends "fields": [] explicitly, asserts success and val["fields"].len() == 0, and additionally re-fetches the persisted schema from storage to confirm it's actually durable, not just returned.
  • test_create_schema_without_fields_key_is_rejected (schema_test.rs:16-43) — sends a payload with no fields key at all, asserts result.expect_err(...) and that the error message contains "fields".

The error message itself (mod.rs:253-258) names what's missing and gives a concrete example: "\"fields\" is required. List every field explicitly, e.g. [{\"name\":\"amount\",\"type\":\"number\"}]. \"description\" is a prose summary only and is not parsed into fields." — satisfies "actionable error naming what's missing" (criterion #2 sub-requirement) well beyond the bar.

Code Review Findings

Critical Issues

None found.

Suggested Improvements

  • packages/agent/src/local_agent/tools.rs:692: The JSON tool-schema now sets "required": ["name", "fields"]. This is correct per JSON Schema semantics — required only enforces key presence, not non-emptiness, so fields: [] still validates — but it's worth a moment's scrutiny given the None-vs-Some(empty) distinction is the crux of this PR. Confirmed no mismatch: the Rust-side validation error and the JSON-schema-side required constraint agree. No action needed, just flagging that this was checked since it's an easy place for a schema/implementation drift to hide.
  • packages/core/src/schema/mod.rs:113-127: reject_reserved_property_names is a misleading name — it doesn't reject anything; it warns and passes every field through unchanged (by design, per ADR-063: the caller keeps the final say). A name like warn_reserved_property_names or collect_reserved_property_warnings would match its actual behavior and avoid a future reader assuming it filters or errors. Minor, but the current name invites exactly the kind of "what does this actually do" bug-hunt this PR is designed to eliminate elsewhere.

Nitpicks

  • Nit: packages/core/src/schema/mod.rs:279-282 — the fallback description format!("Schema for {}", params.name) when description is omitted is unrelated pre-existing behavior, unchanged here, but since the PR just made description's contract stricter (prose-only, never parsed), it might be worth a follow-up (out of scope for this PR) to consider whether a generic fallback string is still the right default for the embedding/discovery use case it serves, versus surfacing to the caller that they should supply one. Not a blocker — just noting it while in the neighborhood.
  • Nit: mod.rs:249-251 comment above the let Some(explicit_fields) = params.fields else block is a good "why," but could make the None/Some(empty) distinction even more explicit for future readers by literally naming the two branches, e.g. "fields absent from the request (None) is always an error; fields: [] (Some(vec![])) is always valid." Current wording implies but doesn't spell out the type-level distinction as sharply as the PR's own commit message and this review needed to.

Recommendation: APPROVE

This is a textbook example of the kind of change CLAUDE.md's "no backward compatibility, delete old patterns immediately" philosophy is written for: a clearly-scoped, fully-verified deletion of an undocumented, measurably-defective code path, with the replacement behavior's trickiest edge case (None vs Some(empty)) explicitly tested in both directions. All 7 acceptance criteria are met with direct evidence, the workspace compiles clean with zero stale references, and the only findings are a naming nit and a follow-up-worthy (not blocking) observation. Net positive with no reservations.

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

Review complete — Recommendation: APPROVE (self-approval blocked by GitHub since PR author == reviewing account; see full report above for verified evidence on all 7 acceptance criteria, 46/46 tests passing, clean workspace build).

…ment

- reject_reserved_property_names -> warn_reserved_property_names: it warns
  and passes fields through unchanged, it never rejects (ADR-063 leaves the
  final call with the caller).
- Spell out the fields None-vs-Some(empty) distinction explicitly in the
  comment above the missing-fields check.

Both are non-functional naming/clarity fixes from PR #1833 review; no
re-review needed.

Co-Authored-By: Claude <[email protected]>
@malibio

malibio commented Jul 30, 2026

Copy link
Copy Markdown
Collaborator Author

Addressed review feedback

  • ✅ Renamed reject_reserved_property_names → warn_reserved_property_names — the function warns and passes fields through unchanged, it never rejects (ADR-063 leaves the final call with the caller). Matches actual behavior now.
  • ✅ Sharpened the comment above the fields None-vs-Some(empty) check to spell out the type-level distinction explicitly.
  • ⏭️ Skipped: the description-fallback-string follow-up — reviewer explicitly scoped it out as "not a blocker... out of scope for this PR."

Both changes are non-functional (rename + comment only, no logic change). Verified: cargo test -p nodespace-core --lib schema:: (46/46 passing), bun run quality:fix clean, pre-push gate (test:all + cargo build + e2e) passed.

Re-Review Decision

Decision: NO RE-REVIEW NEEDED

Rationale: Both changes are a rename and a comment clarification — no logic, control flow, or test behavior changed. All 46 schema tests still pass with identical assertions.

Ready for merge.

@malibio
malibio merged commit 7c87ac1 into main Jul 30, 2026
2 checks passed
@malibio
malibio deleted the worktree-issue-1800-delete-schema-inference branch July 30, 2026 23:02
malibio added a commit that referenced this pull request Jul 31, 2026
…superseding the pre-#1800 e4b-1775-r3 figure

Recorded against a purged, freshly-seeded isolated daemon (commit
57bf108) now that both remaining ADR-064 workstream gates have
closed: #1811 (already resolved as a side effect of #1820) and #1800
(create_schema description-inference deletion, merged as #1833). Ran
three full trials for variance characterization, as the issue requires,
plus two routing-eval trials.

Headline: 9/12 (median of 6/12, 9/12, 8/12 — mean 7.7/12), consistent
with this suite's previously-documented 10/9/8 variance band. The
committed file records run 2 with the other two summarized in
other_runs_this_session and full detail in caveats, per the issue's
"report enough repetitions to characterize variance, not a single
number" requirement.

Findings from reading the raw-output traces this issue's diagnostic
harness now captures, not just the aggregate:

- Scenario 6 (Update via indirect reference) failed in all three runs
  — the model asks the user for a node ID instead of calling
  resolve_query, despite resolve_query being confirmed present in the
  offered tool list every time. A genuine comprehension gap, not a
  routing or harness defect. Tracked by #1637.
- create_schema JSON-truncation errors recurred across scenarios
  3/8a/8b at 2/3 frequency each — the model emits genuinely malformed
  JSON on complex multi-field schemas ("EOF while parsing a value"),
  a real generation defect distinct from the #1800/coreValues class
  of prose-contradiction bug this suite previously found.
- Zero "widget" placeholder leakage across all three runs' raw output
  and the full daemon log, per the issue's specific ask. Scenarios
  4/8c/8d show no systematic INSTANCE-vs-TYPE regression.
- Zero empty-generation exclusions and no uniformity-guard trips in
  any run — nothing here reads as a harness artifact.
- Routing eval: 10/15 twice, with an IDENTICAL failure set both runs
  (not committed as a separate file here, but noted in caveats since
  the consistency across independent runs suggests systematic causes,
  and at least one failure looks like a scoring-heuristic gap rather
  than a model failure).

scripts/results-e4b.trace.jsonl is the raw-output trace for the
committed run, so any of the findings above can be re-verified from
the actual model text without re-running the eval.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_012qFMbS5rEGLQL6CCkg6Xjs
malibio added a commit that referenced this pull request Jul 31, 2026
…DR-056's Scenario 5 claim (#1831)

* Make the agent eval diagnostic: raw-output trace, uniformity guard, empty-generation exclusion, guidance provenance (closes #1764)

The eval could not tell "the model failed" from "the harness failed" —
both rendered as a low score, and the two known false results on record
(a contaminated 11/12 baseline, and "no tools called" scenarios passing
while every turn died on context overflow) were only caught by reading
raw model output. This makes the harness diagnostic before any future
baseline gets recorded against it:

- Raw generation per ReAct iteration is now captured to a .trace.jsonl
  file alongside the results JSON (agent_loop.rs logs it at debug level
  so production's default info verbosity is unaffected).
- A uniform 0%/100% pass rate across 4+ scored scenarios now aborts as
  an environment failure rather than writing a plausible results file.
- The documented degenerate-empty-generation failure mode (model emits
  neither text nor a tool call) is now excluded from the pass/fail
  denominator instead of silently scoring as a model failure.
- Provenance now records which seeded prompt/skill content a run
  actually measured (_seed.key/_seed.version read back via `node
  query`), since seeding only reseeds on daemon startup and a
  long-running daemon can silently serve stale guidance.
- Stage 1's routing decision (query/clarify/clarify_suppressed/none/
  unavailable/failed) and whether Stage 2's prompt actually carried a
  candidate block are now logged on every code path and surfaced per
  turn, closing the gap where a silently-skipped routing attempt looked
  identical to one that matched nothing.

Verified the tool-call-parsing regression flagged during scoping
(narrated JSON-array calls slipping past detection, per #1826) is
already fixed in the production loop with its own unit coverage;
no separate eval-side parsing gap exists since the eval only counts
executed-tool log lines, never re-parses raw text itself.

ADR-056's Scenario 5 claim and the honest 9/12 baseline were already
addressed in earlier sessions on this issue; recording a fresh baseline
remains gated on #1800 (create_schema description-inference deletion).

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_012qFMbS5rEGLQL6CCkg6Xjs

* Fix multiline/embedded-marker corruption in raw-output log scraping (review fixes for #1764)

Code review on PR #1831 caught two bugs in the raw-output-trace
plumbing added for #1764, both stemming from the same root cause:
treating a field that can contain arbitrary model text as if it were
bounded by ordinary line/marker delimiters.

1. scripts/aichat.ts split the daemon log slice on "\n" before scanning
   for the raw-generation marker. tracing's %-Display formatter writes
   the field verbatim, embedded newlines included, so any multiline
   generation was silently truncated at its first newline.

2. scripts/eval/runner.ts's regex used "\n[tool]" as a lookahead
   terminator, which broke if the model's own raw text happened to
   contain that literal substring (e.g. narrating "I'll use [tool]
   create_node...").

Fixed at the source: agent_loop.rs now JSON-encodes response_text
before logging it, so the field is guaranteed to be exactly one line
regardless of content. aichat.ts and runner.ts parse it back with
JSON.parse instead of fragile lookahead regexes.

While fixing this, found and fixed a related bug the review didn't
catch: the tool-call-counting regex in runner.ts wasn't anchored to
line start, so a [raw] line's embedded model text mentioning
"[tool] create_node" was miscounted as a real tool call. Same fix
applied to every other marker regex in parseTurnOutput for consistency,
since all of them now share stdout with arbitrary model text.

Extracted parseTurnOutput (runner.ts) and formatTurnLogLines
(aichat.ts) as pure, exported functions so this parsing logic — where
the bugs actually lived — is directly unit-testable without a daemon.
Added 21 regression tests across two new test files covering multiline
output, embedded markers, and the marker/tool-call interaction.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_012qFMbS5rEGLQL6CCkg6Xjs

* Rename seed_prompt_nodes to seed_agent_guidance_nodes; fix eval's stale seeded-type list

seed_prompt_nodes seeds nodes with root_node_type "agent-guidance", not
"prompt" — the type was renamed under ADR-064/#1699's markdown-children
refactor but the function name was never updated to match, which is
exactly what caused a real bug: scripts/eval/preflight.ts's
SEEDED_GUIDANCE_TYPES still listed "prompt" as a seeded type to verify
guidance provenance against, so readGuidanceProvenance silently found
zero prompt nodes on every run (the type genuinely doesn't exist
anymore) while correctly finding the 8 seeded skills. Caught while
running the actual Phase B baseline for #1764 against a fresh isolated
daemon, where zero results for a type that should exist is exactly the
"can't tell if this is the harness or reality" ambiguity #1764 exists
to eliminate.

Fixed both: the function now matches what it actually seeds, and the
eval now checks "agent-guidance" (verified against a live daemon —
5 nodes: Core Identity, Workspace Context Template, Tool Strategy
Guide, Response Formatting Rules, Tool Call Formatting) instead of a
type that seeds nothing.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_012qFMbS5rEGLQL6CCkg6Xjs

* Record the honest post-ADR-064 baseline: 9/12 (6/9/8 across 3 runs), superseding the pre-#1800 e4b-1775-r3 figure

Recorded against a purged, freshly-seeded isolated daemon (commit
57bf108) now that both remaining ADR-064 workstream gates have
closed: #1811 (already resolved as a side effect of #1820) and #1800
(create_schema description-inference deletion, merged as #1833). Ran
three full trials for variance characterization, as the issue requires,
plus two routing-eval trials.

Headline: 9/12 (median of 6/12, 9/12, 8/12 — mean 7.7/12), consistent
with this suite's previously-documented 10/9/8 variance band. The
committed file records run 2 with the other two summarized in
other_runs_this_session and full detail in caveats, per the issue's
"report enough repetitions to characterize variance, not a single
number" requirement.

Findings from reading the raw-output traces this issue's diagnostic
harness now captures, not just the aggregate:

- Scenario 6 (Update via indirect reference) failed in all three runs
  — the model asks the user for a node ID instead of calling
  resolve_query, despite resolve_query being confirmed present in the
  offered tool list every time. A genuine comprehension gap, not a
  routing or harness defect. Tracked by #1637.
- create_schema JSON-truncation errors recurred across scenarios
  3/8a/8b at 2/3 frequency each — the model emits genuinely malformed
  JSON on complex multi-field schemas ("EOF while parsing a value"),
  a real generation defect distinct from the #1800/coreValues class
  of prose-contradiction bug this suite previously found.
- Zero "widget" placeholder leakage across all three runs' raw output
  and the full daemon log, per the issue's specific ask. Scenarios
  4/8c/8d show no systematic INSTANCE-vs-TYPE regression.
- Zero empty-generation exclusions and no uniformity-guard trips in
  any run — nothing here reads as a harness artifact.
- Routing eval: 10/15 twice, with an IDENTICAL failure set both runs
  (not committed as a separate file here, but noted in caveats since
  the consistency across independent runs suggests systematic causes,
  and at least one failure looks like a scoring-heuristic gap rather
  than a model failure).

scripts/results-e4b.trace.jsonl is the raw-output trace for the
committed run, so any of the findings above can be re-verified from
the actual model text without re-running the eval.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_012qFMbS5rEGLQL6CCkg6Xjs

* Correct #1637 misattribution in the baseline; fix a stale doc-comment reference

results-e4b.json's scenario-6 caveat wrongly cited #1637 (closed) as
already tracking the model-never-calls-resolve_query failure. #1637
was about resolve_query's return contract once called (fixed,
confirmed working in this code — its own evidence cites 100% success
on this exact phrasing when the tool IS called); the failure this
baseline actually measured is the model not calling the tool at all,
which #1637 did not observe under its own measurement conditions.
Filed as its own issue, #1835, and corrected the caveat to explain the
distinction plus separate run 1 (a cascade from scenario 4, a
different failure) from runs 2-3 (the clean repro).

Also fixes a doc comment in preflight.ts left referencing the old
seed_prompt_nodes name after the prior commit renamed the function in
prompt_assembler.rs but missed this comment — caught in re-review.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_012qFMbS5rEGLQL6CCkg6Xjs

---------

Co-authored-by: Claude Sonnet 5 <[email protected]>
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.

Delete the create_schema description-inference route: an undocumented second meaning for the description parameter, with a 27% silent-wrong-type rate

1 participant