Skip to content

fix(server): exclude between-turn edits from V2 turn diffs - #10197

Closed
emmsixx wants to merge 1 commit into
pingdotgg:t3code/codex-turn-mappingfrom
emmsixx:fix/turn-diff-baseline-v2
Closed

emmsixx wants to merge 1 commit into
pingdotgg:t3code/codex-turn-mappingfrom
emmsixx:fix/turn-diff-baseline-v2

Conversation

@emmsixx

@emmsixx emmsixx commented Sep 5, 2026 •

Copy link
Copy Markdown

External changes made between V2 turns currently appear in the next turn's changed-files summary and diff, even when the agent edits nothing. For example, committing two new README lines while the thread is idle produces a misleading README.md +2 card on the next no-edit reply.

Capture a separate starting snapshot for each V2 turn and compare the completed snapshot against it for the changed-files summary and individual turn diff. Existing completed checkpoints remain intact for history and restore. Older checkpoints without a starting snapshot retain the previous diff behavior. Multi-turn comparisons continue to use their checkpoint endpoints. Changes made during a turn remain part of that turn's diff; this does not attribute changes by Git author.

A replay-safe checkpoint.baseline.cleanup effect reclaims abandoned starting snapshots after non-completed runs, aborted starts, unsuccessful checkpoint capture, and restart recovery. Stopping a run before its provider turn starts queues cleanup in the same transaction as cancellation. Cleanup re-reads the projection, skips active runs and ready checkpoints owned by that run, and preserves a completed run's baseline while capture is still pending. A later turn's baseline at the same ordinal does not prevent cleanup of an abandoned starting snapshot. Ref deletion runs under the workspace lock and is harmless when repeated or when the workspace has no Git repository. Rollback cleanup also removes the starting snapshots associated with discarded checkpoints.

Targets the orchestration V2 branch from #2829 (t3code/codex-turn-mapping), related to #4249, and addresses #10348 for orchestration V2. The separate main backport is outside this PR; this change does not fix the legacy orchestration implementation by itself.

Validation:

  • 148 tests passed across 13 focused suites on base 0d606c8, covering checkpoint diffs, capture, storage, scope ownership and rollback, run execution and interruption, recovery, effect workers, replay, selection restart, and steering completion.
  • Regression coverage includes external commits, uncommitted idle edits, actual turn edits, duplicate baseline capture, historical snapshots, rollback cleanup, legacy diff fallback, abandoned-baseline cleanup, and non-Git workspaces. New integration cases use real Git refs to verify cleanup after startup cancellation and delayed cleanup after a later turn creates a baseline at the same ordinal, while preserving that later turn's refs.
  • Formatting passed across all 18 changed files. Targeted lint completed with three upstream unused-declaration warnings in Utils.ts, EffectWorker.ts, and Orchestrator.ts. Server typecheck still reports the two upstream errors in HostPowerMonitor.ts:69 and NativeTelemetryClient.ts (now line 509), previously reproduced on untouched base 6102d00. No additional type errors were reported with this PR applied.
  • Earlier manual V2 verification reported no changed-files card after an idle external commit, followed by only notes.txt +1 for an actual agent edit. Before/after screenshots are attached in the PR comments. This manual verification was not repeated after updating the base.
  • Earlier manual rollback verification restored the files, but Codex rejected conversation rollback with paginated threads do not support thread/rollback, also reproduced on the unpatched nightly. Full client rollback is not marked as passing.

Implemented with GPT-6 through the Codex harness in T3 Code. Earlier review follow-ups were implemented with Opus 5 in T3 Code. Merge integration, history cleanup, and description review used GPT-6 through Codex.

@github-actions github-actions Bot added vouch:unvouched PR author is not yet trusted in the VOUCHED list. size:M 30-99 changed lines (additions + deletions). labels Sep 5, 2026
@emmsixx

emmsixx commented Sep 6, 2026

Copy link
Copy Markdown
Author

Before — unpatched nightly

An external commit adds two lines to README.md between turns. The next reply edits nothing, but incorrectly shows README.md +2.

image

After — patched V2

The same external-commit scenario produces no changed-files card on the next no-edit reply.

image

Real edits still appear

A subsequent agent edit correctly shows only notes.txt +1. The external README change is excluded.

image

@emmsixx
emmsixx marked this pull request as ready for review September 6, 2026 01:40
@macroscopeapp

macroscopeapp Bot commented Sep 6, 2026 •

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Not approved

Macroscope's review found this PR not approvable — This change introduces per-turn Git baselines and a new cleanup workflow across checkpoint capture, terminal handling, recovery, and outbox execution, so its runtime and persistence impact is broader than a small bug fix. An unresolved concrete concern about abandoned refs and cleanup behavior further requires human verification.

Adjust the Minimum Blocking Severity for this repo — including turning it Off — in Settings. You can add or adjust custom eligibility rules. Learn more.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: edbfa5afa3

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread apps/server/src/orchestration-v2/CheckpointService.ts
@github-actions github-actions Bot added size:L 100-499 changed lines (additions + deletions). and removed size:M 30-99 changed lines (additions + deletions). labels Sep 6, 2026
Comment thread apps/server/src/orchestration-v2/CheckpointCaptureService.ts
@juliusmarminge
juliusmarminge force-pushed the t3code/codex-turn-mapping branch from cfc65ec to f5a9e8b Compare September 8, 2026 02:59
@github-actions github-actions Bot added size:XXL 1,000+ changed lines (additions + deletions). size:L 100-499 changed lines (additions + deletions). and removed size:L 100-499 changed lines (additions + deletions). size:XXL 1,000+ changed lines (additions + deletions). labels Sep 8, 2026
@emmsixx
emmsixx force-pushed the fix/turn-diff-baseline-v2 branch from dfbf577 to 089c235 Compare September 8, 2026 03:11
@juliusmarminge
juliusmarminge force-pushed the t3code/codex-turn-mapping branch from 9242b91 to 3d81172 Compare September 8, 2026 03:31
@emmsixx
emmsixx force-pushed the fix/turn-diff-baseline-v2 branch from 089c235 to fe951ef Compare September 8, 2026 03:36
@juliusmarminge
juliusmarminge force-pushed the t3code/codex-turn-mapping branch from efd9994 to 6102d00 Compare September 8, 2026 06:23
@emmsixx
emmsixx force-pushed the fix/turn-diff-baseline-v2 branch from 9f3403f to 1f25845 Compare September 8, 2026 23:34
@juliusmarminge
juliusmarminge force-pushed the t3code/codex-turn-mapping branch from 8187b17 to ada72ce Compare September 9, 2026 06:39
@emmsixx
emmsixx force-pushed the fix/turn-diff-baseline-v2 branch 3 times, most recently from f425259 to cad689b Compare September 10, 2026 14:32
@juliusmarminge
juliusmarminge force-pushed the t3code/codex-turn-mapping branch 5 times, most recently from e03e376 to e39429e Compare September 12, 2026 08:17
@emmsixx

emmsixx commented Sep 13, 2026

Copy link
Copy Markdown
Author

Closing this PR in favor of #11528

@emmsixx emmsixx closed this Sep 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L 100-499 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant