Skip to content

fix(dashboard): settle undecidable strReplace before-snapshots at flush - #11394

Closed
DcXiaoBing wants to merge 1 commit into
kirodotdev:mainfrom
DcXiaoBing:fix/file-chip-pending-str-replace
Closed

DcXiaoBing wants to merge 1 commit into
kirodotdev:mainfrom
DcXiaoBing:fix/file-chip-pending-str-replace

Conversation

@DcXiaoBing

@DcXiaoBing DcXiaoBing commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: Show the true pre-write content in a file chip when a strReplace leaves the on-disk state ambiguous at snapshot time.

A one-line strReplace can make the dashboard file-change card report the removed line against the entire post-edit file, such as -1 +55 instead of -1 +0. The race occurs when the disk snapshot is valid as both the pre-write and post-write state.

Why it matters

The card's stat badge is the first summary users see. Counting an unchanged file as newly added makes a safe shell configuration edit look destructive and undermines trust in the recorded diff.

Not a goal

  • Tracking writes made through shell commands (the chip pipeline observes write tools only)
  • Moving the pre-existing turn-end after-content read off the event loop

What changed (motivation → approach → change)

The card resolves the full-file before only when one completed tool call can be identified without ambiguity.

Piece Behavior
_classify_str_replace_before and pending_str_replace Preserve three capped hypotheses when the disk state is undecidable, without retaining the raw full-file read.
Snapshot and outcome correlation Use _tcid_identity_key only when _tcid_first_source and _tcid_collapsed prove the redacted ID names one raw call. An absent, over-long, or redaction-collapsed ID binds and settles as unidentified.
_flush_file_changes Key dedup, pending payloads, and writer sets by the canonical path validate_file_path returns, so two spellings of one file are one path. Resolve exactly one completed writer against the turn-end file. Multiple writers, failed or missing outcomes, changed-again files, and truncated ambiguity keep the safe fragment fallback.
Per-turn state and specification Scope a recorded terminal outcome and a bound pending payload to one call occurrence: a tool_call frame reusing an id retires both (_retire_write_tool_outcome) before the new call is snapshotted, so a write cancelled before its terminal frame never binds a stale completed, and a second write under the reused id never settles the first call's payload against the file it restored. Bound _write_tool_outcomes by _MAX_TCID_SOURCES, the constant that already bounds the identified-id population it is keyed on, and clear it per turn; document the bounded hypotheses, completion gate, and fail-closed identity rule.

The implementation is contained in src/kiro_crew/dashboard; the owning system specification and snapshot tests describe and verify the same contract.

The ACP oldText for strReplace is a fragment, while the card needs a full-file before. For substring-shaped replacements, the snapshot race leaves two valid interpretations. Turn-end content distinguishes them only after the write reports completion.

Two distinct raw tool-call IDs can redact to the same displayed constant. Treating that constant as one writer lets a second write satisfy the single-writer gate and persist a fabricated before-state. The existing first-source/collapsed verdict now gates both snapshot bind sites and terminal outcome settlement, so an ambiguous identity cannot resolve pending evidence.

This fix covers only the recoverable ambiguous-strReplace class (the undecidable seam); the other decline branches of _classify_str_replace_before keep the fragment oldText and its badge, by design. Deferred resolution observes write tools only: a shell command that restores the file in the same turn is not a writer the flush can see, so a completed ambiguous strReplace followed by such a restore can still resolve to before_if_post; the owning specification records this residual as accepted.

No product-shape change is introduced. The card reports the full-file comparison it is designed to show.

Backwards compatibility

Compatible: persisted file_changes entries retain their existing {path, before, after} shape and truncation flags. Pending hypotheses, outcome state, and writer identity stamps remain turn-local.

Tests

test/test_file_change_snapshots.py covers pre-write and post-write snapshots, both substring directions, both tool-result event orders, completion/refusal/cancellation, repeated snapshots, multiple writers, capped payloads, capped outcome state, changed-again files, and truncation.

TestPendingStrReplaceThroughTheTurnLoop::test_redaction_colliding_write_ids_keep_fragment drives two distinct raw IDs that redact to one value through _run_chat, restores the original file with the second write, and proves the fragment is kept. Removing the bind and settlement gates makes this test fail by persisting a fabricated full-file before.

TestPendingStrReplaceResolution::test_later_write_under_another_spelling_keeps_fragment restores the file through a dir/./rc spelling of the same path and proves the two writes share one bucket and keep the fragment. Keying by the raw path makes this test fail with two entries and a fabricated before.

TestPendingStrReplaceThroughTheTurnLoop::test_a_reused_id_does_not_inherit_the_earlier_calls_outcome drives a completed call and a later write that reuse one raw ID through _run_chat, ends the turn before the write's terminal frame, and proves the fragment is kept. Removing the retirement at the tool_call site makes this test fail by persisting before_if_post, a before that was never on disk. TestPendingStrReplaceResolution::test_outcome_map_is_capped pins the shared _MAX_TCID_SOURCES bound and the absence of a second constant.

TestPendingStrReplaceThroughTheTurnLoop::test_a_second_write_reusing_the_id_cannot_settle_the_first drives two completed writes that reuse one raw ID through _run_chat, restores the file with the second write, and proves the fragment is kept. Removing the pending-payload walk in _retire_write_tool_outcome makes this test fail by persisting before_if_post.

Hand-built second-writer entries in the resolution tests carry canonical_path like every runner-produced snapshot, so the flush buckets them with the first writer on a host whose temp directory realpath differs from its spelling (Windows 8.3 names).

test/test_chat_runner_coverage.py pins the classifier's decline paths.

Manual verification

N/A — the turn-loop tests replay the dispatcher event order and disk transitions that produce the card metadata; no frontend renderer changes.

Screenshots / video

N/A — this backend correction changes the accuracy of existing card data without changing the rendered component or layout.

Related Issues

Fixes #11387

Pattern harvest

Rule candidate: review-prompt
Pattern: before/after inference must not correlate operations through an identifier that redaction can collapse.

Checklist

  • At most two commits (one is the norm), with a Conventional Commits title (feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable)
  • No secrets, credentials, or internal references in the diff

@DcXiaoBing
DcXiaoBing requested review from a team and CrysisDeu September 16, 2026 22:21
@github-actions github-actions Bot added fork Pull request from a fork (external contributor) readiness: checking Automated validation is still running labels Sep 16, 2026
@github-actions

github-actions Bot commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Fable 5, fork) — ✅ PASS

Premise-level review of f692e5b5746d6404e4fc0c20228e3cae3144f714 via the fork AI-review pipeline — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

First-Principles-Verdict: PASS

Canonical-path dedup now merges every multi-spelling write into one chip for all writes, not just ambiguous strReplace — confirm that collapse is wanted.

What this change ships

Inventory (9 items) — 9 justified

Intent: FIX — the file-change card stops counting an unchanged file as fully added when a strReplace snapshot is ambiguous (#11387), by settling the before at turn end.

  1. Ambiguous one-line strReplace now shows the true full-file before instead of -1 +N — justified
  2. Resolution only after the tool reports completed; refused/failed/cancelled writes keep the fragment — justified
  3. Two path spellings of one file now render as one chip entry (flush keys by canonical path) — justified
  4. Snapshots carry canonical_path, computed off the event loop by the existing validate_file_path call — justified
  5. New per-turn _write_tool_outcomes map, bounded by the existing _MAX_TCID_SOURCES, reset at turn start and every flush — justified
  6. A new tool_call reusing an id retires the earlier call's outcome and pending payload — justified
  7. Redaction-collapsed, over-long, or absent ids never bind or settle (fail-closed via existing _tcid_first_source/_tcid_collapsed) — justified
  8. A repeat write from another or unidentified call voids the held pending payload — justified
  9. Owning spec section updated in the same commit — justified

Lens 4/5 checks: identity tables (_tcid_identity_key, _MAX_TCID_SOURCES) and validate_file_path exist on base and are reused, not duplicated; canonical_path and _write_tool_outcomes each have multiple real consumers in _flush_file_changes, _bind_pending_str_replace, _settle_pending_str_replace_outcome, _retire_write_tool_outcome.

[FIRST-PRINCIPLES-REVIEWED] f692e5b

Description read

[DESCRIPTION-READ] f4f6ede96960c1cd4481fdaa639cfce49a147f74a75b04be6c815eae72689691

That sha256 names the PR description this verdict read. Recompute it with .github/scripts/pr-description-capture.sh; if it differs, the description changed after this verdict was formed and any finding drawn from the description is unproven.

@github-actions

github-actions Bot commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Fable 5, fork) — ✅ PASS

Design-level review of f692e5b5746d6404e4fc0c20228e3cae3144f714 via the fork AI-review pipeline — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

Design-Verdict: PASS

Reproduce issue #11387 once against a live kiro-cli turn: every verification replays synthetic dispatcher event orders, never the real frame sequence.

[DESIGN-REVIEWED] f692e5b

Description read

[DESCRIPTION-READ] 10462c0ba94f6568a900db67de8862e52aa2bd3adece26b64a2895c4fa44f3ad

That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

GPT 5.6 Review (fork) — 🔴 changes requested (blocking)

Reviewed f692e5b5746d6404e4fc0c20228e3cae3144f714 via the fork AI-review pipeline; updated in place on each push.

1 of 1 blocking finding(s) are security-class and were withheld from adjudication, so the blocking verdict stands.

BLOCKING -- src/kiro_crew/dashboard/chat_runner.py:3271 -- Unobserved shell restore fabricates the before-snapshot

single_writer = len(writers) == 1 and "" not in writers; resolved = _resolve_pending_str_replace(pending, after.content)
Completed ambiguous strReplace -> shell restores the file -> flush sees one writer and persists a before-state that never existed.
Anchor: residual/crash-data-loss-corruption
Fix: Treat any subsequent shell call as an unknown writer and decline resolution.
[BLOCK-MERGE] f692e5b
[GPT-REVIEWED] f692e5b

Adjudication (Opus 5) — is blocking on each finding proportionate?

Harm: UNBOUNDED-class per the fence (silent fabrication of persisted before-state). Conditions confirmed: only create/strReplace/insert ever produce a snapshot (chat_runner.py:2386, chat_runner.py:2709), so a shell call never enters slot._file_changes and so never lands in the flush's writers_by_path set (authentic.patch → _flush_file_changes, writers_by_path.setdefault(...)); single_writer is therefore true with one real writer plus an unseen shell restore, and _resolve_pending_str_replace returns before_if_post once pending["completed"] is set by the terminal completed frame and after == if_post_write.content.
Recovery path: none — the resolved value is assigned to entry["before"], redacted, attached as file_changes meta and persisted to history; the accumulator and outcome map are reset at turn exit, so nothing re-derives it.
Rarity argument cannot be completed: the triggering combination is an ordinary agent workflow (edit → run tests → git checkout -- F in the same turn), named as the example in the PR's own spec text, not a contradictory or writer-impossible state.

[ADJUDICATION] f692e5b total=0 uphold=0 downgrade=0
[GPT-ADJUDICATED] f692e5b
[ADJUDICATION-FENCED] f692e5b fenced=1 flagged=0
UPHOLD-FENCED F1 src/kiro_crew/dashboard/chat_runner.py:3271 -- A same-turn shell restore (git checkout -- F after a failed test) is ordinary agent behaviour rather than an extreme condition, shell calls are structurally invisible to the single_writer check because only create/strReplace/insert are snapshotted (chat_runner.py:2386,2709), and the fabricated before is persisted with no recovery path.
[GPT-ADJUDICATED-FENCED] f692e5b

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Sep 16, 2026
@github-actions

github-actions Bot commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5 Review (fork) — ✅ no blocking findings

Reviewed f692e5b5746d6404e4fc0c20228e3cae3144f714 via the fork AI-review pipeline; updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] f692e5b

@DcXiaoBing
DcXiaoBing force-pushed the fix/file-chip-pending-str-replace branch 2 times, most recently from 1b01e6e to d2035ad Compare September 16, 2026 23:50
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Sep 16, 2026
@DcXiaoBing
DcXiaoBing force-pushed the fix/file-chip-pending-str-replace branch 2 times, most recently from 90d3c3c to 569b045 Compare September 17, 2026 00:34
@github-actions github-actions Bot added readiness: checking Automated validation is still running merge conflict Branch has merge conflicts with its base — author must resolve before merge readiness: action required A blocking check or review needs attention and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Sep 17, 2026
@DcXiaoBing
DcXiaoBing force-pushed the fix/file-chip-pending-str-replace branch from 569b045 to 1af8823 Compare September 17, 2026 02:08
@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Sep 17, 2026
@DcXiaoBing
DcXiaoBing force-pushed the fix/file-chip-pending-str-replace branch from 1af8823 to d8a362c Compare September 17, 2026 02:18
@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running merge conflict Branch has merge conflicts with its base — author must resolve before merge labels Sep 17, 2026
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Sep 25, 2026
@DcXiaoBing
DcXiaoBing force-pushed the fix/file-chip-pending-str-replace branch from f9a3215 to 71e043f Compare September 25, 2026 09:51
@DcXiaoBing

Copy link
Copy Markdown
Contributor Author
  • Redaction-colliding tool IDs bypass the multiple-writer guard

disposition: fixed
71e043f1e363d6a91cde17a14f0c986f1370c9ba gates both _run_chat snapshot binds and terminal settlement on _tcid_first_source / _tcid_collapsed; an ambiguous id becomes "" and identifies no writer.
The turn-loop collision test passes with the gates and fails by persisting a fabricated full-file before when all three gates are reverted.
Retrospective: keep the capped outcome map for settle-before-bind order and non-completed writes; keep digest keying because it bounds backend-authored ids with the existing helper.
Retrospective: keep snapshot stamps plus single_writer because a later same-path write can restore a hypothesis; this fix adds no map, constant, or counter.

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running and removed readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention labels Sep 25, 2026
@DcXiaoBing
DcXiaoBing force-pushed the fix/file-chip-pending-str-replace branch from 71e043f to d2a5c6b Compare September 25, 2026 20:54
@DcXiaoBing

Copy link
Copy Markdown
Contributor Author
  • Equivalent path spellings bypass the multi-writer guard

disposition: fixed
d2a5c6b702af13fcfb6fe85f311972f27bc3117b: _flush_file_changes keys deduped, pending_by_path and writers_by_path by the canonical path validate_file_path returns (falling back to the raw spelling only when validation refuses it), so two spellings of one file share one bucket; the entry keeps the first-seen spelling for display. No new state.
Test: TestPendingStrReplaceResolution::test_later_write_under_another_spelling_keeps_fragment restores the file through a dir/./rc spelling with a second tool call and asserts one entry whose before is the fragment; keying by the raw path makes it fail with two entries and a fabricated before.

@DcXiaoBing

Copy link
Copy Markdown
Contributor Author
  • single_writer counts only snapshot-producing writes; a same-turn shell restore is invisible to it

disposition: not-fixing (advisory)
The file-chip pipeline observes write tools only (_WRITE_COMMANDS); a shell edit produces no chip at all, before and after this PR. Treating every non-write terminal frame as a writer is a new mechanism over the whole tool stream, not a correction to this diff, so it belongs in its own change if the seam-edit-then-shell-restore case is judged worth it.

  • Every pending payload after the first for a path is retained for the turn and read by nothing

disposition: not-fixing (advisory)
Each payload is at most three _MAX_SNAPSHOT-capped strings, one per snapshot event, the same cardinality as the content string every snapshot already retains; _file_changes is turn-local and cleared by the flush. Skipping the second build would add a slot lookup at snapshot time to save one capped copy per repeated rawInput.

@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Sep 25, 2026
@DcXiaoBing

Copy link
Copy Markdown
Contributor Author

span=db37e66c9e96

  • Reused tool-call IDs consume a stale terminal outcome -- fixed

A recorded outcome is now scoped to one call occurrence: _retire_write_tool_outcome (chat_runner.py) pops _write_tool_outcomes[key] at the tool_call site in _run_chat before that call is snapshotted, since the dispatcher emits no terminal frame from a tool_call update, so any entry under a reused id belongs to an earlier call.
The later call's bind therefore finds no outcome and a write cancelled before its terminal frame stays unresolved; the flush keeps the fragment instead of persisting before_if_post.
Regression: TestPendingStrReplaceThroughTheTurnLoop::test_a_reused_id_does_not_inherit_the_earlier_calls_outcome (completed call, then a write reusing the raw id, turn ends without its terminal frame). Mutation-verified: removing the retirement call makes it fail with the fabricated full-file before. Fixed in 400143a.

@DcXiaoBing

Copy link
Copy Markdown
Contributor Author

span=6dd7854a8bdf

  • a second, smaller literal bound (_MAX_WRITE_TOOL_OUTCOMES = 32) is added over the same per-turn tool-call-id population _MAX_TCID_SOURCES (512) already bounds -- fixed

_MAX_WRITE_TOOL_OUTCOMES is deleted; _settle_pending_str_replace_outcome bounds _write_tool_outcomes by _MAX_TCID_SOURCES, the constant that already bounds the identified-id population (_tcid_first_source) this map is keyed on, so an id the identity table admits keeps its outcome routing.
test_outcome_map_is_capped pins the shared bound and asserts the old constant no longer exists; the owning spec paragraph names the shared bound. Fixed in 400143a.

@DcXiaoBing

Copy link
Copy Markdown
Contributor Author

span=e48125549479

  • the post-write arm if after == if_post_write.content treats "no second write-tool snapshot" as proof the turn-end content is attributable to this edit -- rebutted

Out of goal: the PR body's frozen ## Not a goal states "Tracking writes made through shell commands (the chip pipeline observes write tools only)". A same-turn executeBash mutation (git checkout/stash) is exactly that class.
Code reason: _flush_file_changes receives only the write-tool snapshot accumulator (slot._file_changes) and the turn-end disk read; no shell or other-tool state is plumbed into it, by design, and the finding itself notes the diff does not carry that plumbing.
Corroborating the after against non-write tool activity is a separate feature (shell-write tracking), not a defect in the write-tool contract this PR narrows.

Resolve ambiguous strReplace snapshots at turn flush using capped hypotheses and completed tool outcomes. Correlate snapshots only when the turn first-source tracker proves a redacted tool ID names one call; ambiguous IDs bind and settle as unidentified.

Scope a recorded terminal outcome and a bound pending payload to one call occurrence: a tool_call frame that reuses an id retires both before the new call is snapshotted, so a write cancelled before its terminal frame never binds a stale completed, and a second write under the reused id never settles the first call's payload against the file it restored. Bound the outcome map by _MAX_TCID_SOURCES, the constant that already bounds the identified-id population it is keyed on.

Carry the canonical path on every snapshot from the off-thread snapshot step, so the flush buckets spellings of one file without resolving paths on the event loop. Void a held pending payload when the accumulator collapses a repeat write from another tool call, since that dropped snapshot is the second writer the flush cannot see.

Keep the fragment fallback for multiple writers, changed-again files, truncated ambiguity, and non-completed writes. Cover both event orderings, redaction-colliding writer IDs, and id reuse with turn-loop tests, and align the owning system specification.
@DcXiaoBing

Copy link
Copy Markdown
Contributor Author

span=db37e66c9e96

  • Reused tool-call IDs collapse distinct writers -- fixed

_retire_write_tool_outcome (chat_runner.py), run at the tool_call site before the new call is snapshotted, now also walks slot._file_changes and deletes every pending_str_replace whose tool_call_id is the reused key, so the earlier occurrence's payload cannot be stamped completed by the later call's terminal frame nor resolved by the flush.
Regression: TestPendingStrReplaceThroughTheTurnLoop::test_a_second_write_reusing_the_id_cannot_settle_the_first (two completed writes on one raw id, the second restores the file) asserts the flush keeps the fragment. Mutation-verified: removing the walk fails it with the fabricated before_if_post. Fixed in f692e5b.

@DcXiaoBing

Copy link
Copy Markdown
Contributor Author

span=6dd7854a8bdf

  • A reused tool_call_id lets an unrelated terminal frame confirm a write that never landed, so the flush persists a fabricated full-file "before" -- fixed

Applied the fix the finding names: _retire_write_tool_outcome deletes fc["pending_str_replace"] for every slot._file_changes entry whose pending carries the reused key, beside popping _write_tool_outcomes[key]; a fresh tool_call frame proves the previous occurrence is over and tool_call_update does not retire.
Regression: TestPendingStrReplaceThroughTheTurnLoop::test_a_second_write_reusing_the_id_cannot_settle_the_first; removing the walk fails it with the fabricated before_if_post. Spec paragraph names the retired payload. Fixed in f692e5b.

@DcXiaoBing

Copy link
Copy Markdown
Contributor Author

span=e48125549479

  • single_writer = len(writers) == 1 and "" not in writers is built only from _snapshot_write_target results and cmd not in _WRITE_COMMANDS returns None for every shell tool -- rebutted

Out of goal: the frozen ## Not a goal excludes writes made through shell commands; the chip pipeline observes write tools only, before and after this PR.
The owning spec section now records the residual: a same-turn shell restore is not a writer the flush can see and can let before_if_post resolve; accepted, not guarded. A stat fingerprint on every pending would widen the diff on a span raised across six rounds and is a separate feature.

@DcXiaoBing

Copy link
Copy Markdown
Contributor Author

span=75b5323a637d

  • A shell-command restore can still flip resolution into a fabricated before — the one writer class the new single-writer gates cannot see -- fixed

The file-change-snapshots section of docs/system-specs/modules/learn-cron-dashboard.md now names the limit: deferred resolution observes write tools only; a shell command that restores the file in the same turn (git checkout -- F, a build step) is not a writer the flush can see, so a completed ambiguous strReplace followed by such a restore can still resolve to before_if_post; this residual is accepted, not guarded.
The PR body's ## What changed states the same limit. Fixed in f692e5b.

@DcXiaoBing

Copy link
Copy Markdown
Contributor Author

span=1f8ede687911

  • Item 1 — symptom-level (point patch) -- fixed

## What changed now states that this fix covers only the recoverable ambiguous-strReplace class (the undecidable seam) and that the other decline branches of _classify_str_replace_before keep the fragment oldText and its badge, by design — the second clearing condition the item names.
Fixed in f692e5b.

@DcXiaoBing

Copy link
Copy Markdown
Contributor Author

span=d8b12062375b

  • Item 8 — rides along: test_reads_each_changed_path_from_disk_once pins flush read-count behavior unrelated to the ambiguity fix -- fixed

The test is deleted. Its entries carried no canonical_path, so it exercised none of the dedupe this PR adds; the base _flush_file_changes already read each deduped path once, so it pinned pre-existing behavior.
Fixed in f692e5b.

Copy link
Copy Markdown
Contributor

Triage note (automated PR-overlap scan, inspected origin/main @ a92dde1a6c):

Rebase needed. This branch (merge base 463d4c3aec, 543 commits behind) no longer merges cleanly: git merge-tree reports content conflicts in src/kiro_crew/dashboard/chat_runner.py and docs/system-specs/modules/learn-cron-dashboard.md. The main cause is #16224 (139de6ecc0, "compose the chat turn runtime from chat_turn owners"), which moved _reconstruct_str_replace_before into src/kiro_crew/dashboard/chat_turn/file_changes.py. The new _classify_str_replace_before / pending_str_replace logic has to be ported there. Main has not fixed this yet: file_changes.py still returns None on the undecidable seam, so #11387 is still open and this PR is still needed.

Coordination: two other open PRs also change _flush_file_changes. #13346 adds _flush_file_changes_off_loop, which moves the turn-end after-read onto a worker (that is this PR's "Not a goal"). #9314 scopes the flush to a _turn_anchor_row window. Their goals complement this one rather than duplicate it, but whichever lands second will need to rebase its after-read / pending-resolution loop on top of the other.

No breaking change or P0 found: the persisted file_changes shape is unchanged and the new state is turn-local.

@chenmingwei23

Copy link
Copy Markdown
Contributor

This fix has been taken forward in #17367, a same-repo branch rebased onto current main (the file-change machinery moved from chat_runner.py into chat_turn/file_changes.py since this PR). It ports the deferred-resolution approach here and additionally implements the blocking review remedy — declining pending resolution when a shell command ran in the same turn, since a shell restore is an unobserved writer. Credited via Co-authored-by. Thanks @DcXiaoBing for the original work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fork Pull request from a fork (external contributor) merge conflict Branch has merge conflicts with its base — author must resolve before merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Dashboard file-change card shows -1 +N (whole file counted as added) after a single-line strReplace

5 participants