Skip to content

fix(workspace): dedupe run-change attribution for overlapping runs (#2404) - #2466

Open
suantea wants to merge 1 commit into
EKKOLearnAI:mainfrom
suantea:fix/workspace-run-change-attribution-2404
Open

fix(workspace): dedupe run-change attribution for overlapping runs (#2404)#2466
suantea wants to merge 1 commit into
EKKOLearnAI:mainfrom
suantea:fix/workspace-run-change-attribution-2404

Conversation

@suantea

@suantea suantea commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Closes #2404

Problem

When two sessions whose workspace points to the same directory run concurrently, a file written by session B during session A's active run is recorded as a workspace change of both sessions. The run-end diff scans the whole shared directory, so attribution is "whatever changed in the shared directory while this run was active" rather than "what this run actually wrote".

Evidence from #2404 (production DB): the same physical file creation (+122, size_after 6197, change_type 'added') appears under both session B's run and session A's overlapping run, with A's spurious row written at A's finished_at (the run-end diff).

Fix (store layer)

insertWorkspaceRunChange now drops directory-diff echoes of writes already attributed to a concurrently-active run:

  • Physical-change fingerprint: (path, change_type, additions, deletions, size_before, size_after) uniquely identifies one physical write.
  • Time-overlap guard: dedupe only when the other run's [started_at, finished_at] window overlaps this run's. Two sequential runs that make byte-identical changes to the same file (e.g. re-applying the same fix) are distinct real events and must both be recorded — they are never deduped.
  • Zero-file exemption: empty file lists (pure workspace_diff cards) are not deduplication and are persisted exactly as before.
  • When every file of a change is an echo, the change is not inserted at all — attribution stays with the first run.

Verification

  • New regression suite tests/server/workspace-run-change-dedupe.test.ts (4 tests): unique change recorded; overlapping echo dropped; partially-echoed run keeps its own files; sequential byte-identical modification preserved.
  • Full server suite: 236 files / 2280 passed / 4 skipped.
  • tsc --noEmit -p packages/server/tsconfig.json clean.

Co-Authored-By: AtomCode (deepseek-v4-flash) noreply@atomgit.com

…KKOLearnAI#2404)

When two sessions whose workspace points to the same directory run
concurrently, the run-end diff scans the whole shared directory, so a file
written by session B is also recorded as a workspace change of session A.
Fix at the store layer: a change row whose (path, change_type, additions,
deletions, size_before, size_after) fingerprint matches a row already
attributed to a time-overlapping run is a directory-diff echo of the same
physical write and is dropped; the attribution stays with the first run.

The overlap guard keeps genuinely sequential runs intact: two runs that make
byte-identical changes to the same file are distinct real events and must
both be recorded. Zero-file changes (pure workspace_diff cards) are exempt.

Co-Authored-By: AtomCode (deepseek-v4-flash) <noreply@atomgit.com>
@suantea
suantea force-pushed the fix/workspace-run-change-attribution-2404 branch from 71bc188 to ff96455 Compare August 10, 2026 14:21
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.

Workspace run-changes mis-attributed to other sessions when runs overlap on a shared workspace

1 participant