Skip to content

Teach the real relationship_type parameter name (core#2200) - #2362

Merged
mstomar125 merged 2 commits into
mainfrom
issue-2200-relationship-type-guidance
Sep 4, 2026
Merged

mstomar125 merged 2 commits into
mainfrom
issue-2200-relationship-type-guidance

Conversation

@mstomar125

Copy link
Copy Markdown
Contributor

Summary

  • The Relationship Management and Organization skill guidance instructed the model to pass `relation_type` at three call sites (creating a relationship, filtering `get_related_nodes` results, and adding a node to a collection), but `create_relationship`/`get_related_nodes` both require `relationship_type` and reject unknown fields via `#[serde(deny_unknown_fields)]` with no alias. A small local model, which reliably copies shapes it's shown, would follow the guidance verbatim and get rejected outright -- an error burns an iteration, and if the model trusts what it was just taught, the one permitted retry repeats the same wrong name and the turn fails.
  • Fixed the guidance text at all three call sites to say `relationship_type`, matching what the tools actually require.
  • Also added `#[serde(alias = "relation_type")]` to both `CreateRelationshipParams` and `GetRelatedNodesParams`, mirroring the existing `node_id`/`id` alias already on `GetRelatedNodesParams` for the analogous split. This is a defensive backstop, not the primary fix -- even with the corrected guidance, `relation_type` is arguably the more common general-knowledge-graph term, so a model could still drift toward it independent of what it was just shown.

Test plan

  • Two new tests confirming the alias accepts `relation_type` for both param structs (existing `rejects_unknown_field` tests already cover other wrong names like `relationshipType`/`reltype` and are unaffected).
  • A guidance-text regression test (`relationship_guidance_teaches_the_real_parameter_name`) that cross-checks the seeded skill text against `create_relationship`'s own required-parameters list -- mirroring the existing `both_surfaces_agree_on_the_undeclared_key_rule` pattern already used for Node Creation, so a future reword of either side that reintroduces the mismatch fails here instead of in an eval.
  • Verified the guidance-text test via mutation testing: reverted one occurrence back to `relation_type`, confirmed the test failed, restored it, confirmed it passed.
  • Left the ablation eval golden fixtures (`packages/agent/goldens/`) that also predate this fix untouched -- confirmed via grep no test reads them; they're frozen historical snapshots for an unrelated ablation study, out of scope for this issue.
  • `cargo test -p nodespace-agent --lib` -- 593/593 pass.
  • `cargo clippy -p nodespace-agent --all-targets -- -D warnings -D clippy::unused-async` clean.
  • `bun run test:all` -- full suite green (frontend + skill + Rust, workspace-wide).
  • `bun run quality:fix` -- clean.
  • Pre-push gate (`scripts/test-gate.ts`) passed.

Closes #2200

🤖 Generated with Claude Code

The Relationship Management and Organization skill guidance instructed
the model to pass relation_type at three call sites (creating a
relationship, filtering get_related_nodes results, and adding a node
to a collection), but create_relationship/get_related_nodes both
require relationship_type and reject unknown fields via
#[serde(deny_unknown_fields)] with no alias. A small local model,
which reliably copies shapes it's shown, would follow the guidance
verbatim and get rejected outright -- an error burns an iteration, and
if the model trusts what it was just taught, the one permitted retry
repeats the same wrong name and the turn fails.

Fixed the guidance text at all three call sites to say
relationship_type, matching what the tools actually require.

Also added #[serde(alias = "relation_type")] to both
CreateRelationshipParams and GetRelatedNodesParams, mirroring the
existing node_id/id alias already on GetRelatedNodesParams for the
analogous split. This is a defensive backstop, not the primary fix --
even with the corrected guidance, relation_type is arguably the more
common general-knowledge-graph term, so a model could still drift
toward it independent of what it was just shown.

Added 5 tests: two confirming the alias accepts relation_type for both
param structs (existing rejects_unknown_field tests already cover
other wrong names and are unaffected), and a guidance-text regression
test that cross-checks the seeded skill text against
create_relationship's own required-parameters list -- mirroring the
existing both_surfaces_agree_on_the_undeclared_key_rule pattern for
Node Creation, so a future reword of either side that reintroduces the
mismatch fails here instead of in an eval. Verified the guidance-text
test via mutation testing: reverted one occurrence back to
relation_type, confirmed the test failed, restored it, confirmed it
passed.

Left the ablation eval golden fixtures (packages/agent/goldens/) that
also predate this fix untouched -- confirmed via grep that no test
reads them; they're frozen historical snapshots for an unrelated
ablation study, out of scope for this issue.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
@mstomar125

Copy link
Copy Markdown
Contributor Author

Code Review Summary

Net positive, correctly scoped, and well-verified fix for core#2200. The guidance-text correction is the primary fix and is complete and accurate at all three call sites. The added serde(alias) backstop is reasonable, precedented (mirrors the existing node_id/id alias), and independently justified in the commit message rather than merely copying pattern for its own sake. Tests are meaningful, pass, and the "goldens are unused" claim was independently verified and holds. The one blocking issue is a repeat of a violation this same session has already been warned about twice: GitHub issue numbers embedded directly in code comments, which this repo's CLAUDE.md explicitly prohibits.

Findings

Critical Issues

  • [Blocker] packages/agent/src/local_agent/tools.rs:120, :3760, :3789 and packages/agent/src/skill_pipeline.rs:616: four doc/line comments embed core#2200 directly in code. CLAUDE.md's Documentation rule states plainly: "Do not embed GitHub issue numbers in documentation content or code comments — describe the behavior/constraint directly, and reference decisions by ADR." The commit message and PR title are exempt (that's "GitHub process mechanics," explicitly carved out), but these are Rust doc comments (///) and a line comment (//) inside source files, which are squarely covered. Two earlier PRs in this session were already sent back for exactly this. Fix: reword each comment to describe the constraint itself (e.g. "the seeded skill guidance previously taught relation_type, which this struct's deny_unknown_fields rejected outright") with no issue-number token.

Suggested Improvements

  • packages/agent/src/skill_pipeline.rs:645-649: the dynamic .find(|s| s.contains("relationship")) lookup of the "real" parameter name is a genuine strength, not over-engineering — verified against the intent of both_surfaces_agree_on_the_undeclared_key_rule, the point is to assert the pairing between guidance text and the live schema, not just presence of a fixed string. A hardcoded "relationship_type" literal would let the test keep passing even if the schema's required-field name changed and only the guidance text (or only the hardcoded test string) went stale — i.e., it would silently stop testing the actual property this bug was about. The dynamic lookup closes that gap.
  • Testing gap (minor, not blocking): there is no test that a full request payload containing relation_type (the pre-fix guidance's own broken example) succeeds through the actual tool executor (execute() -> exec_create_relationship/exec_get_related_nodes) rather than only through serde_json::from_value::<Params>() directly. In practice this gap is thin: exec_create_relationship/exec_get_related_nodes (tools.rs:2924, 2955) do nothing to args between dispatch and the identical serde_json::from_value call the new unit tests already exercise. It's also consistent with prior art — there is no equivalent end-to-end-through-executor test for the existing node_id/id alias either, so this PR isn't introducing a new gap relative to the established pattern, just inheriting it.

Nitpicks

  • Nit: packages/agent/src/skill_pipeline.rs:645-649: a one-line comment explaining why "relationship" is the chosen substring filter would help a future reader who doesn't reconstruct the reasoning from the doc comment above.
  • Nit: packages/agent/src/local_agent/tools.rs:117-129 / :3760-3781: the doc comments are a little verbose for what they explain (the alias mechanism is simple and the neighboring node_id/id alias is right there as a working example); worth tightening once the issue-number reference above is removed anyway.

Verification performed

  • Read CreateRelationshipParams/GetRelatedNodesParams in tools.rs: #[serde(alias = "relation_type")] is on the correct field in both structs, deny_unknown_fields is untouched, and exec_create_relationship/exec_get_related_nodes deserialize args directly into these structs with no intermediate normalization — so the alias is genuinely live on the same path the executor uses.
  • Ran cargo test -p nodespace-agent --lib scoped to the new tests and the existing rejects_unknown_field suite: all 2 new alias tests, the new guidance-text test, and all 10 rejects_unknown_field tests pass. Confirmed the two existing rejects_unknown_field tests for these structs use relationshipType/reltype (not relation_type), so they remain meaningful coverage of "genuinely unknown field" behavior, unaffected by the new alias.
  • Confirmed via grep -n "relation_type" packages/agent/src/skill_pipeline.rs that all three guidance call sites (CREATING A RELATIONSHIP, TRAVERSING RELATIONSHIPS, ADD TO COLLECTION) now say relationship_type, with zero stray occurrences of the wrong name left in guidance strings.
  • Independently verified the "goldens are unused" claim, not just trusted it: grep -rn "relation_type" packages/agent/goldens/ confirms the old wording is present in three ablation TOML files (fidelity-rank1-wrong-fetch.toml, minimal-at-fidelity.toml, production-baseline.toml). Grepped the entire packages/agent tree (src, tests, bin) for those three filenames and for any generic ablation-directory loader — no hits. Read packages/agent/src/bin/golden_runner.rs and src/golden/{mod,case}.rs: the only code that reads goldens/*.toml is the golden_runner bin, which per its own doc comment "sits outside cargo test entirely" (it loads a ~5GB GGUF) and requires an explicit case-file path argument — nothing in cargo test, tests/*.rs, or CI invokes it. Also checked the unrelated golden::assert_matches snapshot mechanism in tests/prompt_assembly_snapshot.rs (a different "golden" concept — tests/golden/prompt_assembly/*.golden snapshot files, not goldens/ablation/*.toml) and confirmed its stage2_tool_surface.golden snapshot only contains the correct relationship_type schema key, unaffected either way. The claim holds.

Recommendation: REQUEST CHANGES

@mstomar125 mstomar125 left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated pragmatic-code-review: REQUEST CHANGES (posted as a comment — GitHub blocks self-approval). Blocker: 4 doc/line comments embed the issue number (core#2200) directly in code, which this repo's CLAUDE.md documentation standard explicitly prohibits (two prior PRs this session were already sent back for the same violation). Everything else — the guidance-text fix itself, the serde alias backstop, and the new tests — is sound and independently verified. Full findings in the review comment above.

This repo's documentation standard prohibits embedding GitHub issue
numbers in code comments -- four new comments violated this. Reworded
all four to describe the fix's reasoning without the issue number.

Addresses reviewer recommendations from PR #2362 review.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
@mstomar125

Copy link
Copy Markdown
Contributor Author

Address Review Summary

Response to the pragmatic code review (REQUEST CHANGES, posted here).

✅ Addressed (the blocking finding):

  • [Critical] Four new comments (tools.rs:120, :3760, :3789, skill_pipeline.rs:616) embedded a GitHub issue number, violating this repo's documentation standard. Reworded all four to describe the fix's reasoning directly, without the issue reference.

⏭️ Acknowledged, no action needed (non-blocking):

  • [Improvement] The dynamic schema-lookup pattern in relationship_guidance_teaches_the_real_parameter_name was assessed as a genuine strength, not over-engineering — no change requested.
  • [Improvement] No end-to-end test through the real tool executor for the relation_type alias — reviewer characterized this as a thin gap matching existing precedent for the node_id/id alias, not something to add.

🧪 Tests: cargo test -p nodespace-agent --lib — 593/593 pass (unchanged, comment-only fix). bun run test:all green. bun run quality:fix clean.

📝 Commit: 003fcb3

Re-Review Decision

Decision: NO RE-REVIEW NEEDED

Rationale: Comment-only change, no logic touched. The fix's mechanism (guidance-text correction + defensive alias) was already reviewed and assessed as sound and proportionately scoped.

The PR is ready for merge.

@mstomar125
mstomar125 merged commit 7e401a9 into main Sep 4, 2026
@mstomar125
mstomar125 deleted the issue-2200-relationship-type-guidance branch September 4, 2026 06:46
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.

Seeded skill guidance teaches parameter name relation_type but the tool schema and executor require relationship_type

1 participant