feat(import): anchor Codex turns to recorded commits - #2109
Open
yinguangyao wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
entire import codexalready restores historical Codex turns, but the Codex importer never populatedTurn.CommitSHAs. Every imported turn therefore used the default-branch fallback introduced in #1825, even when the rollout recorded the exactgit commitinvocation and its resulting SHA.This PR extracts explicit commit candidates from current Codex rollout formats and hands them to the existing
turnAnchorResolver:call_idfunction_call/exec_commandandcustom_tool_call/execenvelopestools.exec_command({cmd: ...})JavaScript calls, while rejecting dynamic template interpolationgit commitonly at unquoted shell command boundaries[branch <sha>] subjectsuccess headersThe existing resolver remains the authority for expanding candidates and requiring default-branch reachability. No time/file heuristics or metadata schema changes are added.
Why
Historical import should use exact evidence when the agent recorded it. Without this, a turn that visibly created a commit is displayed at the import-time default branch head instead of that commit.
A privacy-preserving local audit over one repository last 30 days found:
The audit printed only aggregate counts; no prompt, command, or output content was retained.
Tests
go test ./cmd/entire/cli/agentimport -count=1mise run lintmise run checkwas also attempted. Formatting and all lint jobs passed, and the changedagentimportpackage passed under the race run. The full suite failed in unrelated existing tests that dirtied.story/logs/story.logduring branch checkout (TestReconcileDisconnected_NoRemote,TestIsMetadataDisconnected_NoRemote) andTestRunUninstall_Force_NothingInstalled; no failure referenced the changed files.