Skip to content

CL-9026: stop writing duplicate prompt snapshot when identical to live turns - #1178

Merged
TheGreatAxios merged 3 commits into
mainfrom
cl-9026-stop-writing-duplicate-prompt-snapshot-when-identical-to
Sep 27, 2026
Merged

TheGreatAxios merged 3 commits into
mainfrom
cl-9026-stop-writing-duplicate-prompt-snapshot-when-identical-to

Conversation

@TheGreatAxios

Copy link
Copy Markdown
Collaborator

Summary

The reactor checkpoints the materialized prompt every cycle, but most cycles run no transform that changes it. The optimized context store wrote that identical snapshot to prompt.jsonl unconditionally, doubling disk and re-hash cost for zero information. writePrompt now hash-compares (per-turn JSON.stringify, the writer's own serialization) against live turns and skips the write entirely when identical.

Behavior

  • Identical prompt (by reference fast path, then serialized equality) against unpublishedRewrite ?? liveTurnRefs in memory, else on-disk live turns for fresh instances: writer is never invoked, no prompt segment is created.
  • Identical-after-differing converges disk to no-prompt-segment: stale prompt segments are unlinked, their removals staged so commit drops them from the tree, and the prompt writer is reset. Nothing reads prompt.jsonl (load merges base turns + turns extras only), so resume falls back to live turns by omission.
  • Differing prompts (compaction folds, cache-shrinks, ephemeral appends) write exactly as before. Any baseline-read failure fails open to a normal write.
  • Old sessions: byte-identical snapshots become prompt no-ops on the first post-upgrade checkpoint; pre-existing differing prompts are preserved until replaced/removed.

Tests

  • T1 identical writeTurns then writePrompt: prompt.jsonl absent on disk and in commit tree, including a fresh-instance writePrompt against on-disk turns.
  • T2 differing (shrunk tool-result body, plus ephemeral trailing turn): prompt.jsonl present with exact content.
  • T3 turns-only store: load returns live turns; fresh-instance commit is a hash-identical no-op that invents no prompt file.
  • T4 differing-then-identical: stale segments removed from disk, removal staged, tree clean after commit, load unchanged.

Fixes CL-9026

@linear-code

linear-code Bot commented Sep 25, 2026

Copy link
Copy Markdown

CL-9026

@github-actions

Copy link
Copy Markdown
Contributor

Thank you for your contribution to Corbits Code. Before it can be merged, please read our Contributor License Agreement and sign it by posting a new comment on this pull request containing exactly the line below (nothing else):


I have read the CLA Document and I hereby sign the CLA


corbits-builder seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You can retrigger this bot by commenting recheck in this Pull Request. Posted by the CLA Assistant Lite bot.

extraCommitPaths stripped vendor roots from the remove list because
base.commit() git.adds files that still exist. It never git.removes
missing ones, so a committed-then-identical prompt snapshot stayed
in HEAD.
@TheGreatAxios
TheGreatAxios merged commit b167db3 into main Sep 27, 2026
12 of 13 checks passed
@TheGreatAxios
TheGreatAxios deleted the cl-9026-stop-writing-duplicate-prompt-snapshot-when-identical-to branch September 27, 2026 22:29
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.

1 participant