Skip to content

Include existing schema's rendered definition in duplicate-type rejection - #2142

Merged
mstomar125 merged 2 commits into
mainfrom
worktree-issue-2134-schema-rejection-fidelity
Aug 18, 2026
Merged

mstomar125 merged 2 commits into
mainfrom
worktree-issue-2134-schema-rejection-fidelity

Conversation

@mstomar125

Copy link
Copy Markdown
Contributor

Summary

create_schema's duplicate-type rejection named the collision but never the existing type's actual fields. An agent consuming that error had no fact to report, so it filled the gap by describing the fields from its own (rejected) call and presenting them to the user as confirmed — a case of a missing fact producing confident fiction (ADR-064 rule 4).

Fix

  • Reuse the schema node the matches! check already fetches (previously discarded) in handle_create_schema (packages/core/src/schema/mod.rs).
  • Render its real definition via the existing EntityTypeDescriptor::render_line() (packages/core/src/ops/entity_types_block.rs) — no new formatting code.
  • New rejection message states the call was not applied, includes the existing type's real rendered definition, and instructs the caller to describe the type using only that definition.

Test plan

  • New regression test test_create_schema_duplicate_rejection_carries_existing_definition in packages/core/src/schema/schema_test.rs: seeds a ticket schema with one field set, then attempts to recreate it with an entirely different (invented) field set, and asserts the rejection message contains the existing type's real fields (title, owner, triage, shipped) and does not contain the invented ones (assignee, sprint, ready for dev); also asserts the message states the type was not modified and the call's fields were not applied.
  • cargo test -p nodespace-core — all suites pass (1155 lib tests + all integration test binaries), including the 57 schema-module tests.
  • cargo clippy -p nodespace-core --all-targets — clean.

Closes #2134

…tion

create_schema's duplicate-type check fetched the existing schema node
only to check its presence, then discarded it. The rejection message
named the collision but never the existing type's actual fields, so a
consuming agent had no fact to report and filled the gap by describing
the fields from its own (rejected) call instead.

Reuse the already-fetched schema node and render it through the
existing EntityTypeDescriptor::render_line() — the same renderer the
schema block already uses — so the rejection carries the type's real
definition, states plainly that the call was not applied, and points
the caller at create_node for instances.

Closes #2134

Co-Authored-By: Claude <[email protected]>
Multi-condition assert! chain wasn't rustfmt-clean.
@mstomar125

Copy link
Copy Markdown
Contributor Author

Independent re-verification complete (self-approval blocked by GitHub for own PRs — recording here instead):

  • Diff confined to packages/core/src/schema/mod.rs and packages/core/src/schema/schema_test.rs, matching the issue's prescribed fix exactly (message wording, arg order {name} → {render_line} → {schema_id}, single reuse of the already-fetched schema node via if let Ok(Some(existing_schema)), EntityTypeDescriptor::from_schema(&existing_schema).render_line()).
  • cargo test -p nodespace-core (all suites, 1155+ lib tests plus every integration binary) — all pass.
  • cargo clippy -p nodespace-core --all-targets — clean.
  • cargo fmt -p nodespace-core -- --check — clean.

Adversarial review sub-agent independently verified: no error-handling regression vs the original matches! check (Err/Ok(None) fallthrough behavior is unchanged), no other consumer in the repo asserts on the old message wording, and confirmed via revert-and-rerun that the new regression test actually catches the original bug. Its one finding (rustfmt formatting on the new test) is fixed in 41fb4e9.

Merging.

@mstomar125
mstomar125 merged commit d6bc849 into main Aug 18, 2026
@mstomar125
mstomar125 deleted the worktree-issue-2134-schema-rejection-fidelity branch August 18, 2026 10:42
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.

create_schema duplicate rejection omits the existing type's definition — agent invents its fields and reports them as confirmed

1 participant