Skip to content

Fix codex backend patch check under shallow Git clones - #51

Closed
LikC1606 wants to merge 1 commit into
mainfrom
fix/codex-backend-diff-abbrev
Closed

LikC1606 wants to merge 1 commit into
mainfrom
fix/codex-backend-diff-abbrev

Conversation

@LikC1606

Copy link
Copy Markdown
Collaborator

Root Cause

In Publish workbench images (images.yml), publish (worker) failed at apps/web/Dockerfile:14 (scripts/build-codex-backend.sh) with:

Source worktree differs from the checked-in build patches.

scripts/build-codex-backend.sh compared git diff --binary --no-ext-diff HEAD byte-for-byte against scripts/codex-backend/agent-control.patch and derived-lock.patch without pinning --abbrev. Under Git's default core.abbrev=auto:

  • The checked-in patches (from PR Upgrade worker Codex CLI and team backend to 0.172.0 #41) were generated in a fuller clone with 8-char index headers (index a1c6feec..dfa8869e, index 2e557339..b751234a).
  • In a clean CI/Docker build, git clone --depth 1 --single-branch has fewer objects so core.abbrev=auto emits 7-char index headers (index a1c6fee..dfa8869, index 2e55733..b751234), causing cmp -s to fail even though all file contents and hunks are identical.

Fix

  • Read the checked-in patch's Git index abbreviation length via patch_abbrev() and pass --abbrev="$agent_patch_abbrev" / --abbrev="$lock_patch_abbrev" explicitly to git diff in scripts/build-codex-backend.sh.
  • Keeps agent-control.patch, derived-lock.patch, and upstream.json (lockPatchSha256) untouched and preserves strict byte-for-byte cmp -s verification of both blob hashes and patch bodies.

Verification

  • bash -n scripts/build-codex-backend.sh passed.
  • Verified end-to-end against a fresh --depth 1 --single-branch --branch rust-v0.172.0 shallow clone:
    1. Fresh shallow clone passes patch verification and reaches cargo build cleanly (exact byte-for-byte match for both agent-control.patch and derived-lock.patch).
    2. Idempotent re-run on the already-patched worktree passes cleanly.
    3. Extra edit to a tracked file is rejected with Source worktree differs from the checked-in build patches..
    4. Untracked file in the worktree is rejected with Source worktree differs from the checked-in build patches..

@LikC1606 LikC1606 closed this Dec 1, 2026
@LikC1606
LikC1606 deleted the fix/codex-backend-diff-abbrev branch December 1, 2026 20:14
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