Skip to content

Guard "delete the resolved incidents" against the conflict-journal pull (closes #3097) - #3130

Merged
malibio merged 2 commits into
mainfrom
issue-3097-delete-resolved-incidents
Sep 27, 2026
Merged

malibio merged 2 commits into
mainfrom
issue-3097-delete-resolved-incidents

Conversation

@malibio

@malibio malibio commented Sep 27, 2026

Copy link
Copy Markdown
Collaborator

Summary

Closes #3097. The reported pull is gone on main. This PR adds a live production-stack guard so it stays gone, and adds no production code.

Measurement (E4B, real LocalAgentService, seeded registry + embedding model, scored from the store, 3 reps)

Arm Stage-2 candidates Outcome
Incident schema embedded (steady state) Node Deletion, Incident, Conflict Journal search_nodes(node_type: incident, state = resolved), names exactly the 2 resolved incidents, then asks to confirm. list_conflicts 0/3
Schema not embedded (matches the original #3097 trace) Node Deletion, Conflict Journal, Node Merge search_nodes(node_type: "Incident") (the display name), finds nothing. list_conflicts 0/3

Cause, from the dumped Stage-2 prompt: delete_node is offered and Node Deletion is Candidate 1 in both arms. The model no longer takes Conflict Journal's status: resolved filter. It stops short of deleting because Node Deletion's guidance says "Confirm each deletion before proceeding to the next". Whether an agent delete should run without an explicit yes is #3096's decision, so the guard pins targeting (the right records, never the conflict journal), not delete-vs-confirm.

Added: packages/agent/tests/live_delete_resolved_incidents.rs (ignored, needs the models)

  • delete_the_resolved_incidents_targets_the_incidents_not_the_conflict_journal: 3/3
  • conflict_journal_requests_still_call_list_conflicts: "show me the resolved conflicts" and "list the open conflicts", 6/6

Found, filed separately

Test plan

  • cargo test --release -p nodespace-agent --test live_delete_resolved_incidents -- --ignored --nocapture --test-threads=1: 2/2 pass
  • Push check passed

🤖 Generated with Claude Code

https://claude.ai/code/session_01M8ravhwjBi8ShMBthhVuji

@malibio

malibio commented Sep 27, 2026

Copy link
Copy Markdown
Collaborator Author

Pragmatic Code Review: PR #3130

Review Type: Initial review. There are no earlier reviews or comments.

Summary

The PR adds no production code. It adds one ignored live test file, packages/agent/tests/live_delete_resolved_incidents.rs (322 lines), that guards two things: the deletion request must target the incidents and never the conflict journal, and conflict-journal requests must still reach list_conflicts. The test runs through the real production stack: the seeded skill registry embedded with the real model, GraphToolExecutor over SqliteStore, PromptAssembler, workspace context, and E4B through LocalAgentService::send_message. Outcomes are scored from the store and from the executed calls. This is the most production-faithful of the sibling live_* tests, and it is the right kind of guard for a regression the model caused and that no longer reproduces.

Requirements Check (#3097)

AC Status Notes
"delete the resolved incidents" deletes exactly the resolved incidents, 3/3 ✅ (relaxed scope, user-approved) The test passes if the turn either deletes both resolved incidents or names exactly those two. In both cases it must never call list_conflicts and never remove the open incident. The relaxation is documented well in the test's doc comment (lines 253-259): targeting is pinned, and delete-vs-confirm is left as a separate decision. The comment does not cite an issue number, as CLAUDE.md requires. The PR body cross-references #3096.
Conflict-journal requests still call list_conflicts ✅ (one phrase substituted) "show me the resolved conflicts" and "list the open conflicts" pass 6/6. The issue's phrase "are there any unresolved conflicts?" fails at Stage 1 on unchanged main, so it is not a regression from this change. It was filed as #3129, and the substitute phrase keeps the same guard intent.
Cause identified from the dumped Stage-2 prompt ✅ The PR body explains the result from the dumped prompt. delete_node is on the surface and Node Deletion is Candidate 1 in both arms. The confirm-first behaviour traces to Node Deletion's "Confirm each deletion before proceeding" guidance. NODESPACE_PROMPT_DUMP is documented in the file header, so the dump can be reproduced.

Code Review Findings

🔴 Critical

None.

🟡 Improvements

  1. The scoring does not constrain what gets deleted, only what survives.
    📁 packages/agent/tests/live_delete_resolved_incidents.rs:270-283
    ok checks that the resolved incidents are gone and the open one is kept. It never checks that delete_node calls targeted only the resolved incident ids. A turn that deletes both resolved incidents and also a skill node, the incident schema, or anything else would still pass. The guard's stated purpose is to pin targeting (see the doc comment), so the fix is cheap and on-mission: assert that every delete_node call's id argument, with any nodespace:// prefix stripped, is in fx.resolved. Principle: a test's pass condition should cover the property it claims to guard. Otherwise a regression toward over-broad deletion passes silently.

  2. Matching the reply by title substring leans toward false failures, not vacuous passes.
    📁 packages/agent/tests/live_delete_resolved_incidents.rs:278-279
    named_exactly_the_resolved needs the model to reproduce both titles verbatim and case-sensitively. It also fails any reply that mentions the open incident, even to say it will be kept (e.g. "'Search index lagging' is still open and won't be touched"). I checked for vacuous passes and found none: a reply that lists all three incidents fails the open-exclusion check, and a reply that names nothing fails unless deletion happened. The risk is therefore flakiness toward FAIL, which is the safe direction for a guard. It still costs reruns on a non-decision-grade stack. If this flakes, the fix is to score the confirm path from the executed search_nodes call (for example, that it filtered incident by state = resolved) rather than from the reply prose. No change is needed now. I'm recording it so a future flake is diagnosed correctly.

🟢 Nits / Observations

  1. Nit: the embedding model is reloaded, and the whole skill registry re-embedded, on every rep.
    📁 packages/agent/tests/live_delete_resolved_incidents.rs:91-92, 101-121 (called at 267 and 306, 9 fixtures in total)
    Each fixture() call builds a fresh EmbeddingService and re-embeds every seeded skill root. A fresh DB per rep is correct for isolation, since a delete in one rep must not leak into the next. The model load, however, is pure overhead. You could hoist Arc<EmbeddingService> out of the loop (load once per test, as load_engine() already does for the GGUF) and pass it into fixture. This saves 8 model loads and the transient memory churn next to a 5GB GGUF resident on 16GB Metal. It isn't blocking, because the test is #[ignore] and runs with --test-threads=1, and each rep's service drops before the next is built.

  2. Nit: the workspace-context wiring differs slightly from the daemon.
    📁 packages/agent/tests/live_delete_resolved_incidents.rs:217-227 vs packages/daemon/src/services/local_agent_service.rs:778-800, 3010-3078
    The test calls the core build_workspace_context directly. It therefore skips the daemon wrapper's recently-created-schema injector and set_session_mentioned_entities. Neither affects this scenario:

    • The Incident schema is embedded explicitly, so it reaches the context semantically.
    • The duplicate-create guard doesn't apply to delete or list.
    • For a single turn with empty history, schema_retrieval_query reduces to the message.

    A one-line comment saying that the daemon wrapper's extras don't matter here would stop a future reader from assuming full parity. This matters in particular if someone adds the "schema not embedded" arm from the PR body, because production would inject a schema that was just created and this test would not.

  3. Observation: this is consistent with the sibling tests. The file uses REPS = 3 with the "not decision-grade" rationale, #[ignore] with a reason, multi_thread flavor, the standard catalog model path, and per-rep eprintln! diagnostics, matching live_update_node_noop_gate.rs and live_unset_schema_field.rs. It has no lint suppression and no issue numbers in comments, and it adds no docs or .md files. The nodespace:// prefix strip at line 182 is defensive and correct.

Recommendation

APPROVE. The change is a net-positive, narrowly scoped regression guard. It is faithful to the production stack, its scope reduction is documented and was approved by the user, and it spun off the Stage-1 finding (#3129) as its own issue. Finding 1, asserting that delete_node targets only resolved ids, is worth folding in because it is small and strengthens the exact property the guard claims to pin. The rest are optional.

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

@malibio

malibio commented Sep 27, 2026

Copy link
Copy Markdown
Collaborator Author

Review addressed (c4cbf4b)

Re-ran live: both tests pass (deletion guard 3/3 with deleted_only_resolved=true, conflict controls 6/6). Push check passed.

Re-review: not needed. These are small, low-risk changes to one test-only file.

malibio and others added 2 commits September 27, 2026 12:33
…ll (closes #3097)

The reported failure (list_conflicts called 6/6 instead of acting on the
incidents) no longer reproduces on main: 0/6 across an arm with the
Incident schema embedded and an arm whose Stage-2 candidates match the
original trace. The model now searches the incidents and names exactly
the resolved ones.

Adds a live production-stack guard (real LocalAgentService, seeded
registry, embedding model, E4B, scored from the store):
- the deletion request never calls list_conflicts, never removes the
  open incident, and deletes or names exactly the resolved incidents
- "show me the resolved conflicts" / "list the open conflicts" still
  call list_conflicts

"are there any unresolved conflicts?" clarifies at Stage 1 on unchanged
main; filed as #3129.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
- Every delete_node call must target a resolved incident; a turn that
  also deleted a skill or the schema no longer passes
- Embedding model loads once per test instead of once per rep
- Comment where the harness's workspace context differs from the
  daemon's and why that is inert here

Skipped: switching the confirm path from reply-title matching to the
search_nodes filter. No flake observed across 6 reps; revisit if it
flakes.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01M8ravhwjBi8ShMBthhVuji
@malibio
malibio force-pushed the issue-3097-delete-resolved-incidents branch from c4cbf4b to 7541961 Compare September 27, 2026 10:41
@malibio
malibio merged commit 76508dd into main Sep 27, 2026
@malibio
malibio deleted the issue-3097-delete-resolved-incidents branch September 27, 2026 10:41
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 resolved incidents" calls list_conflicts instead of delete_node, even when Node Deletion wins retrieval

1 participant