Skip to content

Refuse a create_node that duplicates an entity the turn resolved - #2859

Merged
malibio merged 4 commits into
mainfrom
issue-2855-duplicate-create-guard
Sep 23, 2026
Merged

malibio merged 4 commits into
mainfrom
issue-2855-duplicate-create-guard

Conversation

@malibio

@malibio malibio commented Sep 22, 2026

Copy link
Copy Markdown
Collaborator

Closes #2855

Problem

With entity resolution, "Add Northwind Trading to the companies we sell to" renders the existing record under MENTIONED ENTITIES, and the locked model creates a duplicate anyway: 3 of 3 reps, under prose guidance, the tool description, and both together.

Approach: enforce it at the write path, with a chance for the model to self-correct

  1. Structured resolved set. The daemon passes the entity tier's matches to the session as AgentSession.mentioned_entities. Both come from the same WorkspaceContext that renders the prompt block, so the guard checks exactly what the model was shown.
  2. Pre-dispatch refusal. A create_node whose node_type and content match a mentioned entity is refused before it executes. Matching is exact once markdown is stripped and case and whitespace are folded. The refusal goes back to the model, naming the existing id and directing it to route_clarify, so the model gets a turn to correct itself.
  3. Turn-end backstop. If the model then neither clarifies nor completes another write (for example an update_node on the existing record), the system replaces the reply with a clarification that names the existing record by id. The user is always asked.
  4. Escape hatch. On a turn that answers a clarification (session_already_clarified, captured at turn start), the guard is disarmed, so a user who confirms they want a second record gets one.
  5. The refusal is flagged is_error, so it is never persisted as a completed write; otherwise it would enter prior_writes and block the confirmed follow-up. It is also excluded from tool-failure surfacing.

Eval

schema-on-menu-company now uses a new outcome expectation. It passes when no create_node succeeded and the reply is a clarification naming the record, or when the existing record was updated. A write-path guard can't change the model's recorded operation decision, so the fixture couldn't pass on that decision alone; operationDecision still records the model's miss. A test binds the fixture's clarification opener to the Rust constant.

Tests

  • Agent loop, all against a scripted model:
    • the duplicate is refused and the user is asked, with the id in an option
    • the refusal is an error result naming the record
    • the model's own clarify is kept
    • a write after the refusal is left alone
    • a create under a different name, or the same name as a different type, still executes
    • the confirmation turn can create the duplicate
    • matching ignores case, whitespace and markdown, and does not accept near-misses
  • Mutation-checked: disabling the guard, the backstop or the escape hatch each makes tests fail.
  • Fixture scoring unit tests are in decisions.test.ts.
  • The pre-push gate passed.

Not yet done

The live eval:decisions run of schema-on-menu-company on the locked model hasn't happened. Another session was running a 3-rep eval on the shared test daemon, and I didn't disrupt it.

🤖 Generated with Claude Code

 #2855)

The entity tier renders an existing record under MENTIONED ENTITIES, and the
locked model created it again anyway under every instruction channel measured
(skill prose, the create_node tool description, both). So the collision is
enforced at the write path instead of requested in the prompt.

- The daemon now hands the resolved set to the session in structured form
  (`AgentSession.mentioned_entities`), from the same WorkspaceContext the
  prompt block is rendered from.
- A create_node whose type and title (markdown-stripped, case/whitespace
  folded, otherwise exact) match one of them is refused before it executes.
  The refusal is returned to the model, naming the existing id and telling it
  to route_clarify, so the model keeps its chance to correct itself.
- If the turn then ends without the model clarifying or completing another
  write, a backstop replaces the reply with a clarification naming the
  existing record by id: the user is always asked.
- The refusal is flagged as an error so it is never persisted as a completed
  write; it is excluded from tool-failure surfacing.
- Escape hatch: on a turn answering a clarification (session_already_clarified,
  taken at turn start), the guard is disarmed so a confirmed second record can
  be created.

schema-on-menu-company now scores the outcome (no duplicate; user asked, or the
existing record updated) via a new `outcome` expectation, since a write-path
guard cannot change the model's recorded operation decision.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@malibio

malibio commented Sep 22, 2026

Copy link
Copy Markdown
Collaborator Author

Pragmatic Code Review: PR #2859 (duplicate-create guard)

Review Type: Initial review. The PR had no reviews or comments yet.

Summary

This is a clear improvement. The structural guard is the right answer to an ADR-064 finding: instruction channels do not stop a conditional suppression. The design fits the existing guard stack. There is one resolved set, built from the same WorkspaceContext that renders the prompt. The refusal happens before dispatch. It is flagged is_error, so it never enters completed_writes or prior_writes, and the comments say why. The backstop sits in the run_turn wrapper, so every exit path gets it, including the iteration cap and loop breaks. Matching is exact and conservative. The tests cover the main cases, and they read well.

I ran them locally:

  • cargo test -p nodespace-agent --lib: all 9 new guard tests pass.
  • bun test scripts/eval/fixtures/decisions.test.ts: 10 pass.

I am requesting changes for two edge cases, both small and well scoped. In each one the guarantee the issue promises ("the user is asked") breaks, or the reply claims something that did not happen. Both show up when one message names more than one entity.

Requirements Check

  • ✅ A create matching a resolved entity's type and title does not silently duplicate it. The refusal fires before dispatch, and a test checks that the create never reaches the executor. Caveat: finding 1 is a hole in multi-entity turns.
  • ✅ The user is asked, with the existing record offered by id. The backstop builds a ClarifyPrompt whose options include nodespace://<id>, and the persisted history carries the question.
  • ✅ A create whose name does not match is unaffected. Tests cover a different name, the same name with a different type, and a near-miss ("Traders"). Matching only consults mentioned_entities.
  • ✅ A follow-up turn can create the duplicate. It works through session_already_clarified, taken at turn start. Caveats: finding 2 (the hatch is too broad) and finding 3 (in one case it is unreachable after the daemon reloads history).
  • ❌ schema-on-menu-company passes. Unverified. The fixture was moved to the new outcome expectation (user-approved), and the scorer is unit-tested, but the live model eval has not run. Run it before merge; this is the only direct evidence the fix works on the locked model.
  • ⚠️ test:all and quality:fix pass. Not verified here. The pre-push gate owns this.

Code Review Findings

🟡 1. Any later write turns the backstop off, and the refusal is also excluded from failure surfacing, so a false success claim can get through

📁 packages/agent/src/local_agent/agent_loop.rs:753 (wrote_after) together with :2435

wrote_after counts any successful write after the refusal, not a write aimed at the refused entity.

Take "Add Northwind Trading and Tailspin Toys":

  • create_node(Northwind) is refused.
  • create_node(Tailspin) succeeds.
  • The model says "Added both."
  • The backstop sees a write after the refusal and returns early.
  • The refusal is now filtered out of tool-failure surfacing (&& !is_duplicate_entity_refusal(r)), so that guard no longer catches the false claim either.

The user is never asked, and the reply states that a record which was refused was created. This PR creates that fabrication path; before it, the claim was at least true, because the duplicate got written.

Principle: keep a guard's release condition as narrow as the risk it covers, the same way the neighbouring guards narrow by name and retry (see the any_real_tool_calls and later-retry comments).

Fix: only count a later write that touches the refused entity, for example a successful write whose args or result name existing.id (an update_node on nw-1). Add a test for the multi-entity case.

🟡 2. The escape hatch opens after any answered clarification in the current intent, not the one about this duplicate

📁 packages/agent/src/local_agent/agent_loop.rs:1751 and :670

session_already_clarified is true after any clarification that begins with the opener and has a user reply after it. That includes a Stage-1 routing clarification that has nothing to do with duplicates.

Example:

  1. "Add Northwind" gets the routing question "Did you mean a customer or a company you sell to?"
  2. The user answers "company".
  3. The guard is now disarmed, and create_node(company_sold_to, Northwind Trading) duplicates the record without asking.

A related problem: the hatch also opens when the user's answer was "Use the existing". On the model that duplicates 3 out of 3 times, a create on that turn goes straight through, against the user's stated choice.

Principle: least privilege. An override should be scoped to the decision it authorises.

Fix, at minimum: disarm only when the answered clarification names this entity. Every clarification the backstop builds contains node_uri(entity.id), so check that current_intent has an assistant clarification whose content includes that id. That keeps the answer deterministic and adds no model judgment. Keying on the chosen option ("Create a second …") would be stricter; it is optional, and fine as a follow-up.

🟡 3. After the daemon reloads history, the clarification is replaced by write facts when the same turn also completed a write

📁 packages/agent/src/local_agent/agent_loop.rs:742-796, interacting with packages/daemon/src/services/local_agent_service.rs (node_history_from_messages / terse_assistant_facts)

The backstop runs even when writes happened before the refusal; wrote_after only looks after it. That is the "Add Tailspin and Northwind" order.

The persisted assistant message then has a non-empty completed_writes (Tailspin). On reload, node_history_from_messages swaps its content for terse_assistant_facts(...), so the text beginning with CLARIFICATION_OPENER never reaches the next turn. Two things follow:

  • The model on the confirmation turn does not see the question it asked.
  • session_already_clarified is false, so "Create a second" is refused again and the backstop asks again. The duplicate cannot be reached, which is the loop the escape hatch exists to prevent.

The replaced reply also drops any mention that Tailspin was created.

The existing confirmation test seeds session.messages directly, so the daemon's round trip never runs and this case is not covered.

Principle: test at the boundary where the state actually persists, not only in memory.

Fix: keep the clarification text when m.clarify is present (or when content begins with the opener), even if writes exist. Consider stating the other completed writes in the backstop message. Add a daemon-level test that goes through node_history_from_messages.

🟢 4. A streamed reply can be replaced after the user has seen it

📁 packages/agent/src/local_agent/agent_loop.rs:1711-1717

on_chunk has already streamed "Added Northwind Trading." by the time the backstop swaps it for the clarification. The same is true of the existing guards (anti-fabrication, CONFIRMATION_REQUEST), and the persisted message is correct, so this is not new. Still, confirm that the frontend re-renders from the persisted message on done. If it does not, the user sees a false "Added" until reload.

🟢 5. Types with a title_template never match (safe direction, but undocumented)

📁 packages/agent/src/local_agent/agent_loop.rs:650 (comparable_title)

For a schema with a title_template, compute_title builds the stored title from field_values, not from content. The guard compares content against the stored title, so a template type with differing parts is never refused. This errs the safe way (no false refusals). A sentence in the mentioned_entity_duplicated_by doc comment would stop someone later "fixing" it into a fuzzy match.

🟢 6. Tests

Useful additions, one line each:

  • (a) the multi-entity cases from findings 1 and 3;
  • (b) the backstop on an iteration-cap exit, since the wrapper is justified by that path;
  • (c) an unrelated clarification not disarming the guard (finding 2).

Also check that the core test fails with the refusal branch reverted. The name create_duplicating_a_mentioned_entity_asks_the_user suggests it would, but it is worth confirming once.

Nits

  • Nit: scripts/eval/fixtures/decisions.ts:539. t.toolCalls ?? [] makes a build that records no toolCalls pass the "no create succeeded" check vacuously. Fail loudly when toolCalls is absent instead, as assertFixture already does for a build with no decision markers.
  • Nit: set_session_mentioned_entities overwrites the set for the whole session. That is fine for the daemon's one-session-per-turn use, but a caller that reuses a session across turns would keep a stale set. One doc line saying "per-turn; re-seed every turn" is enough.
  • Nit: def_create_node still carries the "STOP if … MENTIONED ENTITIES" prose, which was measured to change nothing. It now pairs with the refusal text, so keeping it is reasonable. Just make sure that is a deliberate choice and not leftover.

CLAUDE.md adherence

No backward-compatibility shims, no lint suppressions, and no issue numbers in code comments (ADR references only). serde(default, skip_serializing_if) on the new field is ordinary serde hygiene, not a migration. Making node_uri pub(crate) is a minimal widening.

Recommendation: REQUEST CHANGES

The core design is sound and a clear improvement. Before merge:

  • Narrow wrote_after to writes on the refused entity (finding 1).
  • Scope the escape hatch to a clarification that names the entity's id (finding 2).
  • Keep the clarification text through the daemon's history reload (finding 3).
  • Run the schema-on-menu-company live eval, once the shared daemon is free.

Each fix is a few lines plus one test.

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

Automated pragmatic-code-review: REQUEST CHANGES (posted as a comment — GitHub blocks self-approval). Full findings in the review comment above.

- Backstop releases only on a write that targets the refused record's id.
  Any write released it before, so "add Northwind and Tailspin" -> "Added
  both." slipped through. The replacement clarification now also lists writes
  the turn did complete, which the replaced reply may have been the only
  report of.
- The escape hatch disarms only for the entity an answered clarification asked
  about (by title or id), not after any answered clarification in the intent.
  answered_clarifications() is factored out of session_already_clarified.
- History reload keeps a clarifying question verbatim even when its turn also
  wrote. Replacing it with terse write facts erased the question, so the
  confirmation turn re-asked it. The writes still follow as their own record.
- The fixture scorer fails loudly when tools ran but no per-call outcomes were
  recorded, instead of reading that as "no create succeeded".
- Docs: mentioned_entities is per-turn; title_template types never match (the
  safe direction, deliberately not fuzzy).

Tests: a write to another record keeps the backstop armed; an unrelated
answered clarification does not disarm the guard; the backstop applies on the
loop-breaker exit; a clarification that also wrote survives reload. All four
fixes were mutation-checked (reverting each one fails its test).

Skipped: replacing an already-streamed reply (finding 4). The existing guards
share this behaviour and the persisted message is correct, so it is out of
scope here. The create_node tool-description prose stays: it is consistent
with the refusal and costs only prompt tokens.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@malibio

malibio commented Sep 22, 2026

Copy link
Copy Markdown
Collaborator Author

Review addressed (5407f2a)

✅ Addressed

  • 🟡 1. Backstop release was too broad. Only a successful write whose args reference the refused record's id now counts as resolving the collision. The replacement clarification also lists what the turn did complete ("Already done: …").

  • 🟡 2. Escape hatch was too broad. It disarms only for an entity that an answered clarification in the current intent names, by title or id. answered_clarifications() is factored out of session_already_clarified, and behaviour there is unchanged.

  • 🟡 3. Reload erased the clarification. node_history_from_messages now keeps assistant content verbatim when the message carries a question. The writes still reach the next turn through the completed-writes record. A daemon-level test covers it.

  • 🟢 5. Documented that title_template types never match, and why that direction is safe.

  • 🟢 6. New tests:

    • a write to another record keeps the backstop armed
    • an unrelated answered clarification does not disarm the guard
    • the backstop applies on the loop-breaker exit
    • a clarification that also wrote survives reload

    Each fix was mutation-checked: reverting it fails its test. The core tests were mutation-checked the same way in the first commit.

  • Nits:

    • The scorer now fails loudly when tools ran but no toolCalls outcomes were recorded.
    • The set_session_mentioned_entities doc now says the set is per-turn.

⏭️ Skipped

  • 🟢 4. Replacing a reply that has already streamed. The existing guards all behave this way and the persisted message is correct, so any change belongs in a separate fix for all of them.
  • def_create_node prose. Kept deliberately. It matches the refusal's instruction and costs only prompt tokens.

Still outstanding: the live eval:decisions run of schema-on-menu-company, which waits until the shared test daemon is free.

The pre-push gate passed.

@malibio

malibio commented Sep 22, 2026

Copy link
Copy Markdown
Collaborator Author

Pragmatic Code Review: PR #2859 (duplicate-create guard), re-review of 5407f2a

Review Type: Re-Review. Scope is 60eaed16..5407f2a3 only.

Previous Review Summary

The earlier review had 6 findings (three 🟡, three 🟢) and 3 nits.

  • Addressed: 5 findings and 2 nits. Findings 1, 2, 3, 5 and 6, plus the scorer nit and the per-turn doc nit.
  • Reasonably skipped: 1 finding and 1 nit.
    • Finding 4 (an already-streamed reply gets replaced). This is shared across the existing guards and belongs in its own fix.
    • The def_create_node prose, kept on purpose.
  • Not addressed: none.
  • New issues: 2 🟡 and 3 🟢.

I ran the new and changed tests locally, and all pass:

  • cargo test -p nodespace-agent --lib on the guard tests: 12 pass.
  • The daemon test a_clarification_that_also_wrote_keeps_its_question_on_reload passes.

Requirements Check

  • ✅ A duplicate create is refused before dispatch. Unchanged.
  • ✅ The user is asked, and the existing record is offered by id. The backstop now fires correctly in multi-entity turns (a_write_to_another_record_does_not_release_the_backstop) and on the loop-breaker exit.
  • ✅ A follow-up turn can create the duplicate. It now survives the daemon reload: node_history_from_messages keeps the question verbatim, and the completed-writes record is still emitted as its own System message, so it does not close the intent in answered_clarifications.
  • ❌ The schema-on-menu-company live eval has run. It is still outstanding, and the author says so. This remains the only direct evidence on the locked model.

Verification of the specific points

resolved_after (id substring over serialized args). Correct for the realistic cases:

  • existing.id is nodespace://<id>. The bare id is stripped, so args that use either the uri form or the bare form both match.
  • Node ids are UUIDs, so one id being a substring of another is not a practical risk. The nw-1/nw-10 style only happens in fixtures.
  • The empty-id guard prevents "".contains from always being true.

See 🟢 A for one semantic widening.

answered_clarifications vs the old session_already_clarified. Equivalent. The old code took the first clarification in the intent and checked for any later user message. The new code collects every clarification that has a later user message. If any clarification has a user reply after it, the first clarification does too, so "non-empty" means exactly what the old boolean meant. The intent boundary (rposition of a non-clarification assistant message) is untouched.

Daemon m.question.is_none(). The change only has an effect when a turn has both a question and completed_writes. When there are no writes, terse_assistant_facts returned None and the content was already used verbatim. So a Stage-1 clarification with no writes is unchanged. The only affected turns are clarifications that also wrote, and for those, keeping the question is the correct behaviour. It does not change the intent boundary, because the writes record uses the System role.

Fixture scorer. The loud failure is correct. runner.ts derives toolsCalled from toolCalls, so the two cannot disagree in real runs. The new branch has no unit test (see nit).

Findings

🟡 1. The "Already done" summary is never shown to the user

📁 packages/agent/src/local_agent/agent_loop.rs:801-810, with packages/desktop-app/src/lib/components/chat/chat-message.svelte:28-32

The problem: the summary is appended after the options list, separated by \n\n. For any message that has options, the chat UI renders only message.content.split('\n\n')[0] above the chips, which is the opener plus the question. Everything after the first blank line is dropped, including the bullet list (by design) and this new block (not by design). The comment says the summary is there to keep other writes "visible rather than asking as though nothing happened", but in the app that only reaches the model on reload, never the user. The Tailspin create in "add Northwind and Tailspin" is still invisible to the person who asked for it.

A second problem: even where it is visible, summarize_executions prints humanized tool labels ("• node creation completed"), not which record was written. So it would not say Tailspin was created.

Principle: verify a user-facing guarantee at the layer that renders it. The test only asserts response.contains("Already done").

Fix: put the completed writes into the header paragraph. One option is to fold them into question itself, for example Added "Tailspin Toys". "Northwind Trading" already exists as …. That keeps the opener first, so CLARIFICATION_OPENER recognition still works. It also makes the note visible in both the UI header and the question field. Use the record's content or summary rather than the tool label.

🟡 2. Matching on the title in the escape hatch partly reopens finding 2

📁 packages/agent/src/local_agent/agent_loop.rs:698-702

The hatch opens when any answered clarification contains the entity's title after normalization (comparable_title(asked).contains(&title)). I see why the title is included: a model-authored route_clarify clarification renders only the question and the option labels, not the option ids. So an id-only check would miss the model_clarifying_after_the_refusal_keeps_its_own_question path and make the confirmation unreachable again. the_confirmation_turn_can_create_the_duplicate depends on the title path.

But the title check brings back the case the previous review used as its example. For "Add Northwind Trading", a Stage-1 routing question will very likely name the entity: "Should Northwind Trading be a customer or a company you sell to?". Once the user answers it, the guard is disarmed for Northwind, and a duplicate create goes through without the duplicate question ever being asked. The new test an_unrelated_answered_clarification_does_not_disarm_the_guard uses a routing question that does not name the entity, so it does not cover this.

There is a secondary issue. The comparison is a plain substring match over the whole clarification text, with no word boundaries. A short title, or one that is a prefix of another word ("Acme" inside "Acme Holdings", "Box" inside "Boxwood"), matches unrelated text.

Principle: least privilege. An override should be keyed to the decision it authorizes, and a model's paraphrase is not a reliable key.

Fix (small): make the id always present in any clarification raised about a refused duplicate, then match on the id only.

  • In the route_clarify handling, when this turn contains a duplicate refusal, append the existing record's nodespace:// id to the rendered clarification. Or render option ids when they are node uris.
  • The backstop's own text already includes the id.

If that is too much for this PR, at least require word boundaries and a mention of "already exists" alongside the title. Also add a test where the routing clarification names "Northwind Trading" and check that the guard stays armed.

🟢 A. resolved_after also releases on a write that only references the record

📁 packages/agent/src/local_agent/agent_loop.rs:777-783

r.args.to_string().contains(bare_id) also matches a create whose parent_id or relationship target is the existing record. For example, "add a note under Northwind" in the same turn would release the backstop even if the Northwind duplicate question was never answered. That is arguably correct, because the model chose to use the existing record, so this is not worth tightening now. A single sentence in the comment ("any write that names the record, including as a parent or target") would record that it is deliberate. Matching a target-id field (node_id / id) instead would be the stricter alternative.

🟢 B. Only the last refusal is asked about (carried over from the first commit)

📁 packages/agent/src/local_agent/agent_loop.rs:762-765

rposition(is_duplicate_entity_refusal) picks the last refusal. Take "add Northwind and Contoso" when both already exist: the backstop asks about Contoso only. The Northwind refusal is filtered out of failure surfacing, and the reply is replaced, so the user never hears about Northwind. This PR's narrowing of resolved_after makes the gap easier to hit. It is rare, so a follow-up issue is fine. Asking about the first unresolved refusal, or listing all of them in one question, would close it.

🟢 C. Test coverage for the release path is good

The existing a_write_after_the_refusal_is_left_standing test (an update_node on nodespace://nw-1) now exercises the narrowed resolved_after release. Together with the new negative test, both directions are pinned, which matches the mutation-checking the author described.

Nits

  • Nit: scripts/eval/fixtures/decisions.ts:542. The new loud-failure branch has no case in decisions.test.ts. Add one: toolsCalled: ["create_node"] with no toolCalls should give passed: false.
  • Nit: packages/agent/src/local_agent/agent_loop.rs:678-680. The doc says the hatch "cannot tell 'create a second one' from 'use the existing one'". That is honest. The "use the existing" answer would still be allowed to create, and it remains model-dependent on the model that duplicated 3 out of 3 times. It is worth tracking as a follow-up, keyed on the chosen option label, which the backstop controls.

CLAUDE.md adherence

  • No compatibility shims or lint suppressions.
  • No issue numbers in comments. The daemon doc change describes behaviour rather than history.
  • The pub(crate) surface is unchanged.

Recommendation: APPROVE WITH SUGGESTIONS

The re-review commit correctly addresses every blocking finding from the first review:

  • The backstop's release condition is scoped to the refused record.
  • The escape hatch is scoped to an entity.
  • The clarification now survives the daemon round trip, with a test at that boundary.
  • The answered_clarifications refactor preserves the old semantics exactly.

The change is a clear net improvement.

Two things are left, each a few lines:

  • Finding 1: the new "Already done" note is hidden by the chat UI's header split and names no records.
  • Finding 2: title containment lets a routing clarification that names the entity disarm the guard.

I recommend fixing both before merge, but neither is a regression against main. The live schema-on-menu-company eval is still outstanding and should run before merge.

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

Automated pragmatic-code-review (re-review): APPROVE WITH SUGGESTIONS (posted as a comment — GitHub blocks self-approval). Full findings in the review comment above.

… writes

- The escape hatch now recognises a confirmation by the existing record's id
  only. The title substring match let a routing question that merely named
  the entity disarm the guard, and ignored word boundaries.
- To make id-only matching complete, the backstop now also covers turns where
  the model asked for itself: if its route_clarify does not carry the id (its
  option ids never reach the user), the id is appended to the question.
- Writes the turn did complete are named in the question (e.g. node creation
  "Tailspin Toys"), not appended after it. The chat UI renders only the first
  paragraph above the option chips, so the "Already done" block never reached
  the user.
- Documented that a write merely referencing the record (a child under it)
  deliberately releases the backstop, and that only the turn's last refusal
  is raised.
- Added a fixture test for the scorer's loud-failure branch.

Both new fixes are mutation-checked. Follow-up, not addressed here: telling
"use the existing" apart from "create a second" in the user's answer.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@malibio

malibio commented Sep 22, 2026

Copy link
Copy Markdown
Collaborator Author

Re-review addressed (590ade0)

✅ Addressed

  • 🟡 1. The user never saw "Already done". Writes the turn completed are now named in the question's first paragraph, which is what the chat UI renders. Each is listed by record name, e.g. node creation "Tailspin Toys". The test asserts on clarify.question.
  • 🟡 2. Title matching in the escape hatch. The guard now disarms only when an answered clarification contains the existing record's id. For that to cover every case, the backstop also handles turns where the model called route_clarify itself: if its question lacks the id, the id is appended, because the model's option ids never reach the user. New test: a routing question that names Northwind without its id does not disarm the guard.
  • 🟢 A. Documented that a write merely referencing the record deliberately releases the backstop.
  • 🟢 B. Documented that only the turn's last refusal is raised.
  • Nit: added a fixture test for the loud-failure branch.

Both fixes were mutation-checked, and the pre-push gate passed.

⏭️ Follow-up, not in this PR: telling "use the existing" apart from "create a second" in the user's answer. Once the user has been asked, acting on the answer stays with the model.

Still outstanding: the live eval:decisions run.

@malibio

malibio commented Sep 23, 2026

Copy link
Copy Markdown
Collaborator Author

Live eval: eval:decisions, 3 reps, gemma-4-e4b-q4km, n_ctx 32768

Run on a release build of this branch (590ade0), resetting the database and restarting the daemon between reps. Baseline is origin/main at dc9fbeb (decisions-entity.json).

Scenario Baseline This branch
schema-on-menu-company 0/3 2/2 scored (rep 3 never ran — see below)
the 8 other shared scenarios 3/3 each 3/3 each

The guard fired on the path it was built for, in every scored rep. The model called create_node for "Northwind Trading", and the guard refused it. The model then neither clarified nor updated the record, so the backstop asked the user:

I can take that a couple of ways. "Northwind Trading" already exists as a company_sold_to (nodespace://…). Did you mean that record, or do you want a second, separate one?

  • Use the existing "Northwind Trading" (nodespace://…)
  • Create a second "Northwind Trading"

In one rep the model had even put the existing id into a field value of its create call. It knew the record existed and created it anyway, which is the conditional-suppression failure this issue describes.

Ordinary creates were unaffected: entity-no-match-is-a-create (Tailspin) and skill-instance-request (Contoso) both passed 3/3.

Rep 3 of schema-on-menu-company was excluded, not failed. In that group, the setup-company turn produced no tool call at all (a model flake on a setup prompt; the guard never ran), so the harness excluded the scenario before sending it. The summary still printed 2/3 ← FLIPPED. That is a runner bug: aggregateReps doesn't drop excludedAsSetupFailed reps, although partitionExcluded does. It is separate from this PR.

Out of scope for this branch: the two declarative scenarios in the baseline, which were added on main after this branch was cut.

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_node duplicates an entity the turn already resolved; instruction channels do not prevent it

1 participant