Skip to content

Mirror #2383's relationship worked examples into skill_rules' imperative form - #2628

Merged
mstomar125 merged 1 commit into
mainfrom
worktree-issue-2467-relationship-imperative
Sep 15, 2026
Merged

mstomar125 merged 1 commit into
mainfrom
worktree-issue-2467-relationship-imperative

Conversation

@mstomar125

Copy link
Copy Markdown
Contributor

Summary

Closes #2467.

Test plan

  • cargo test -p nodespace-agent --test prompt_assembly_snapshot — 5/5 passed
  • cargo test -p nodespace-agent (full package) — all passed (only pre-existing #[ignore]d live-model tests skipped)
  • cargo test -p nodespace-cli --test skill_md_generation — 11/11 passed (confirms cli.md's already-fixed prose form stays untouched/in sync)
  • cargo fmt --all --check / cargo clippy -p nodespace-agent --all-targets -- -D warnings -D clippy::unused-async — clean
  • Full local pre-push gate (scripts/test-gate.ts: build:skill, quality:scripts:check, test:all [frontend+skill+rust], cargo build --bin nodespaced, test:e2e, cargo test -p nodespace-app --test "*") — green

🤖 Generated with Claude Code

…les' imperative form (#2467)

RELATIONSHIP_VS_FIELD's imperative field (read by the in-app local
agent via seed_skill_nodes()) still carried only the terse original
rule after #2383/#2466 added worked examples and a false-friends list
to cli.md's prose form for external PTY agents. The in-app agent got
none of that benefit and would still default fields like
deciders/assignee to text.

Port the same worked-examples + false-friends content into the
imperative field, mirroring how GROUPING_IS_COLLECTIONS already keeps
both forms in sync. Regenerate the affected prompt-assembly golden
(stage2_candidate_block) to match.

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

Copy link
Copy Markdown
Contributor Author

Code Review Summary

Net positive, low-risk, correctly-scoped fast-follow. This is a pure content change (+2/-2 across two files: packages/agent/src/skill_rules.rs and its regenerated golden fixture) that ports the already-reviewed and shipped RELATIONSHIP_VS_FIELD.prose content (#2466) into the parallel .imperative field consumed by the in-app agent's system prompt. I independently traced the diff against schema_creation_guidance()'s {relationship_vs_field} {target_type_must_exist} template, re-ran cargo test -p nodespace-agent --test prompt_assembly_snapshot (5/5 pass, including stage2_candidate_block_matches_golden), and grepped the tree for other embeddings of the old text.

Findings

Critical Issues

None.

Suggested Improvements

None blocking. One thing worth a follow-up sentence, not a fix: the new imperative text ends "...check whether the target type already exists in EXISTING SCHEMAS" without stating what to do if it doesn't — but the very next sentence (TARGET_TYPE_MUST_EXIST, immediately concatenated on the same template line) supplies exactly that: "If the target type doesn't exist yet, omit the relationship entirely." So in context the seam actually reads as complete, and this is inherited from cli.md's prose (already reviewed/shipped in #2466), not introduced here — flagging only as background, no action needed.

Nitpicks

  • Nit (skill_rules.rs): the two adjacent sentences at the RELATIONSHIP_VS_FIELD/TARGET_TYPE_MUST_EXIST seam both tell the model to check EXISTING SCHEMAS for the target type's existence — once framed as "check before defaulting to text," once as "MUST be existing... do NOT invent... omit if absent." They don't conflict (different framing, and together they complete the logic — see above), but it's a bit of restatement back-to-back. Not worth blocking on; could be tightened in a future pass if this seam gets touched again.

Verification performed

  1. Correctness/seam — confirmed no contradiction between the new RELATIONSHIP_VS_FIELD.imperative and the immediately-following TARGET_TYPE_MUST_EXIST.imperative in schema_creation_guidance()'s template; content is complementary (see Improvements above).
  2. "EXISTING SCHEMAS" vs. CLI phrasing — confirmed the new imperative correctly says "check whether the target type already exists in EXISTING SCHEMAS," matching the terminology TARGET_TYPE_MUST_EXIST/FIELDS_FROM_REQUEST_ONLY already use for this surface. It does not borrow cli.md's prose phrasing ("check nodespace schema list"), which would be nonsensical for the in-app tool-calling agent. Good adaptation, not a copy-paste.
  3. Staleness — grepped the whole tree for the old short RELATIONSHIP_VS_FIELD text. It also appears, verbatim (old form), inside several packages/agent/goldens/ablation/*.toml files (prod-paired-current.toml, must-exist-id-armA/B/baseline.toml, etc.). Confirmed via their own headers and packages/agent/goldens/ablation/README.toml that these are hand-run, point-in-time "GUIDANCE MINIMISATION SPIKE" experiment records (reproduced manually via golden_runner, not asserted against current source by any test) — correctly out of scope, not stale generated fixtures. Ran cargo test -p nodespace-agent --test prompt_assembly_snapshot directly: 5/5 pass, confirming stage2_candidate_block.golden is correctly regenerated. Also confirmed packages/cli/tests/skill_md_generation.rs::every_schema_rule_reaches_the_skill and gen_skill_md.rs both key off RELATIONSHIP_VS_FIELD.prose (unchanged), so cli.md's generation path is unaffected.
  4. Scope — diff touches exactly the two expected files/lines; .prose is untouched (verified in both skill_rules.rs and gen_skill_md.rs's usage); no unrelated changes. Text length (1174 chars) is in line with sibling rules already in this file (TARGET_TYPE_MUST_EXIST 1985, DELETE_A_SCHEMA 1147, GROUPING_IS_COLLECTIONS 946) — not a disproportionate prompt-budget increase given established precedent.

Verdict

APPROVE

@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: APPROVE (posted as a comment — GitHub blocks self-approval). Full findings in the review comment above.

@mstomar125

Copy link
Copy Markdown
Contributor Author

Address-Review Summary

Findings from the first review: APPROVE, zero Critical/Improvement findings, one Nit (minor restatement at the RELATIONSHIP_VS_FIELD/TARGET_TYPE_MUST_EXIST seam in schema_creation_guidance()'s prompt template — the reviewer explicitly assessed it as "not worth a follow-up").

Decision: Skipping the Nit. It's a cosmetic restatement, not a correctness or clarity problem the reviewer flagged as needing a fix — addressing it would mean reflowing wording across two independently-owned rule constants for no behavior change, which is scope creep against this issue's "keep the diff minimal and focused" instruction.

Changes made: none — no code changes needed.

Re-Review Decision

Decision: RE-REVIEW NEEDED (independent second pass)

Rationale: This repo's merge policy requires a genuine second review round for packages/agent changes regardless of how clean the first pass came back, since it's normally Michael's lane and gets extra scrutiny even for small content-only changes. Requesting an independent second review now.

@mstomar125

Copy link
Copy Markdown
Contributor Author

Second/independent re-review pass (fresh eyes, per merge policy for packages/agent)

Re-derived context from scratch: full gh pr diff, skill_rules.rs in its entirety (all SchemaRule constants, SCHEMA_RULES ordering, tests), schema_creation_guidance()'s template in skill_pipeline.rs, cli.md's "Recognizing a relationship field" section, and gen_skill_md.rs's region-splicing logic. Also independently reran the tests rather than trusting the PR body.

Code Review Summary

Net positive, minimal, correctly-scoped. Pure content port: RELATIONSHIP_VS_FIELD.imperative (+1/-1 line) plus its regenerated golden. Agree with the first pass's APPROVE.

Findings

Critical Issues

None.

Suggested Improvements

None.

Nitpicks

  • Same seam the first review flagged (RELATIONSHIP_VS_FIELD's "check EXISTING SCHEMAS before defaulting to text" butting against TARGET_TYPE_MUST_EXIST's "if absent, omit the relationship entirely") — pre-existing, not introduced here, not worth a follow-up on its own.

Independent verification performed

  1. Content correctness vs. ground truth — TARGET_TYPE_MUST_EXIST.imperative (the targetType/reverseName/reverseCardinality mechanics) is unchanged and the new RELATIONSHIP_VS_FIELD text doesn't restate or contradict any of it; the two are complementary, concatenated on one template line in schema_creation_guidance().
  2. Worked examples / false-friends list — decided_by/assignee/affects_project and the deciders, assignee, owner, author, reviewer, reported_by, members list read as sensible schema-authoring guidance; person/project as example targetTypes match the convention already used elsewhere in this file (e.g. TARGET_TYPE_MUST_EXIST's own decided_by→person example).
  3. "EXISTING SCHEMAS" phrasing — correct choice: matches how TARGET_TYPE_MUST_EXIST/FIELDS_FROM_REQUEST_ONLY/ONE_SCHEMA_PER_REQUEST already refer to that block for the in-app agent, deliberately diverging from cli.md's nodespace schema list phrasing (which would be meaningless to a tool-calling agent that never runs a shell).
  4. .prose/.imperative drift risk — checked the actual generation pipeline, not just the diff. RELATIONSHIP_VS_FIELD.prose is untouched and stays a one-line sentence. Traced why that's correct rather than a gap: gen_skill_md.rs::render_schema_rules_block() splices .prose into cli.md's auto-generated schema-rules region — the expanded "Recognizing a relationship field" worked-examples section (which this PR's .imperative content mirrors) sits outside those generation markers, as hand-written judgment prose the module doc explicitly exempts from the drift contract ("every source must have a rendered section... never requires every section have a source"). So .prose was never the container for this content even pre-PR; there's no new asymmetry introduced here, just the pre-existing Skill guidance: teach relationship recognition and document decomposition #2466 split.
  5. Diff completeness — grep -rl for the old terse sentence across the tree turns up only skill_rules.rs and stage2_candidate_block.golden (both touched) plus packages/agent/goldens/ablation/*.toml. Confirmed those ablation files are cited only from doc-comments (tools.rs, agent_loop.rs) as historical measurement records — no #[test] anywhere reads them — matching their own README.toml header ("not a case file... runner is never pointed at it"). Correctly out of scope.
  6. Length/budget — measured directly rather than trusting the PR's numbers: RELATIONSHIP_VS_FIELD 1174 chars vs. siblings ONE_SCHEMA_PER_REQUEST 554, GROUPING_IS_COLLECTIONS 946, DELETE_A_SCHEMA 1147, ENUM_EDGE_FIELDS 1329, TARGET_TYPE_MUST_EXIST 1985. Squarely mid-pack, not an outlier.
  7. Tests — ran them myself, first-hand:
    • cargo test -p nodespace-agent --test prompt_assembly_snapshot: 5/5 passed.
    • cargo test -p nodespace-agent (full package): 629 passed, 0 failed (remaining ignored are pre-existing live-model tests needing an inference backend) — grepped full output for FAILED/panicked, none.
    • cargo test -p nodespace-cli --test skill_md_generation: 11/11 passed, including every_schema_rule_reaches_the_skill and checked_in_skill_md_is_up_to_date — confirms cli.md's .prose-generated region is unaffected.

Verdict: APPROVE

Agree with the first review's conclusion. This pass independently confirmed the one thing the first review asserted but didn't fully trace — why .prose/.imperative diverging here isn't drift — by following the actual codegen path in gen_skill_md.rs rather than taking the "no drift" claim at face value. No Critical/Improvement findings; the one Nit (seam restatement) is the same one already logged and knowingly skipped as out-of-scope cosmetic polish.

@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 second/independent pragmatic-code-review pass (posted as a comment — GitHub blocks self-approval): APPROVE. This is a genuine independent re-review, not a rubber-stamp of the first pass — reread the full diff, the whole of skill_rules.rs, schema_creation_guidance()'s template, cli.md's relationship section, and gen_skill_md.rs's codegen path, and reran cargo test -p nodespace-agent (full package, 629 passed) + --test prompt_assembly_snapshot + cargo test -p nodespace-cli --test skill_md_generation myself rather than trusting the PR body. Verdict and full findings in the review comment above. Agree with the first pass's conclusion; found one thing worth tracing further (why .prose/.imperative divergence here isn't drift — traced through gen_skill_md.rs's generated-region split) but nothing that changes the verdict.

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.

Teach relationship recognition in the in-app local agent's imperative rule too

1 participant