Skip to content

SEL-285: Production image build copies a gitignored file that is not in the tree - #143

Merged
PetrefiedThunder merged 26 commits into
mainfrom
agent/cursor/sel-285
Oct 20, 2026
Merged

PetrefiedThunder merged 26 commits into
mainfrom
agent/cursor/sel-285

Conversation

@PetrefiedThunder

@PetrefiedThunder PetrefiedThunder commented Oct 19, 2026 •

Copy link
Copy Markdown
Collaborator

Linear: SEL-285
Fixes #107

Coding engine: cursor, dispatched by Grok Bot for C.Lee.

What changed
The production image no longer copies .build_commit_sha by name. That path is gitignored, nothing in this repo created it, and a clean docker build died before the build started. gateway/Dockerfile now runs gateway/scripts/write_build_commit_sha.py, which writes /app/.build_commit_sha from a stamp already in the build context, or from --build-arg RELEASE_COMMIT_SHA. The build fails if the stamp is missing, not a 7,64 character hex SHA, or the staged file and the build arg disagree. The arg is not named COMMIT_SHA or BUILD_COMMIT_SHA, so a stale Railway service variable is not baked in as the stamp. A release archive that already contains .build_commit_sha still works, because COPY . . brings that file in and the script treats it as authoritative.

How verified (exact commands and results)
Confirmed gateway/.build_commit_sha is absent and gateway/Dockerfile had COPY .build_commit_sha /app/.build_commit_sha at HEAD 611fdf3.

~/metacode/fleet/heavy /Users/sellers/Projects/agent-middleware/gateway/.venv/bin/python -m pytest tests/test_write_build_commit_sha.py tests/test_stale_commit_sha_prevention.py tests/test_build_provenance.py tests/test_commit_sha_precedence.py -q --no-cov

Run from gateway/. Result: 50 passed in 0.95s.

/Users/sellers/Projects/agent-middleware/gateway/.venv/bin/ruff check scripts/write_build_commit_sha.py tests/test_write_build_commit_sha.py tests/test_stale_commit_sha_prevention.py app/core/build_metadata.py

Result: All checks passed!

Muse was invoked on a scratch copy and stopped with model did not reach a terminal state within 8 step(s). No review findings were applied.

Not done / follow-ups
docker is not on PATH here, so the image was not built. A clean docker build still fails unless the context contains .build_commit_sha or the command passes --build-arg RELEASE_COMMIT_SHA=$(git rev-parse HEAD). That failure happens inside the image build, with the script's error, instead of a missing-file copy. railway up and prepare_railway_release.py (not in this repo) were not run. A leftover local .build_commit_sha is authoritative and will reject a different build arg until it is removed or matches.


Note

Medium Risk
Changes release image provenance and build-time validation (supply-chain sensitive), plus reconciliation behavior for legacy success receipts that could affect billing/receipt adoption during sweeps.

Overview
Production gateway images no longer use a named COPY of gitignored .build_commit_sha, which broke clean docker build. A build-metadata stage copies the repo context (with secrets stripped via .dockerignore), runs write_build_commit_sha.py, and the final image takes /app/.build_commit_sha only from that validated output. Provenance comes from a context-root stamp (e.g. release archive) or RELEASE_COMMIT_SHA; mismatches, invalid SHAs, or a lone gateway/.build_commit_sha fail the build. The arg name avoids stale Railway COMMIT_SHA / BUILD_COMMIT_SHA env vars.

.dockerignore now excludes gateway/.build_commit_sha, .secrets, and tightens credential-related paths so the metadata stage can copy context safely.

MCP dispatch reconciliation treats success like other legacy finalization outcomes when signed receipts lack permit-v2 snapshots (empty constraints_evaluated with only jev_risk_guard), so stale sweeps can adopt pre-permit success receipts; conflicting signed permit snapshots still raise linkage errors.

CI smoke tests cover the metadata stage, stamp byte assertions, and negative provenance cases.

Reviewed by Cursor Bugbot for commit 02a0d5a. Bugbot is set up for automated code reviews on this repo. Configure here.

Linear: SEL-286
Refs #106
Engine: grok (fleet coding engine, Grok Bot dispatch)
…in the tree

Linear: SEL-285
Refs #107
Engine: cursor (fleet coding engine, Grok Bot dispatch)
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-19T01:15:58.660438Z — PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@cursor cursor 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.

Stale Bugbot comment from a previous run.

Comment thread .dockerignore

@cursor cursor 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.

Cursor Bugbot has reviewed your changes using default effort and found 2 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit c41d177. Configure here.

Comment thread gateway/app/services/mcp_dispatch_reconciliation.py
Comment thread gateway/app/routers/billing.py Outdated
@PetrefiedThunder
PetrefiedThunder merged commit 0c60935 into main Oct 20, 2026
44 checks passed
@PetrefiedThunder
PetrefiedThunder deleted the agent/cursor/sel-285 branch October 20, 2026 11:10
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.

Production image build copies a gitignored file that is not in the tree

1 participant