Skip to content

fix(scripts): inject GIT_SHA in dogfood-build.sh so provenance check passes#2996

Merged
code-yeongyu merged 2 commits intomainfrom
fix/dogfood-build-inject-git-sha
May 4, 2026
Merged

fix(scripts): inject GIT_SHA in dogfood-build.sh so provenance check passes#2996
code-yeongyu merged 2 commits intomainfrom
fix/dogfood-build-inject-git-sha

Conversation

@code-yeongyu
Copy link
Copy Markdown
Collaborator

Problem

The dogfood-build.sh added in #2995 fails its own provenance check every time because cargo build without GIT_SHA env var causes option_env!("GIT_SHA")Noneversion --output-format json returns git_sha: null → script exits 1.

Root Cause

GIT_SHA must be injected as an environment variable at build time — it's not read from git at runtime. The CI pipeline injects it; local builds don't.

Fix

Pass GIT_SHA=$(git rev-parse --short HEAD) to cargo build in the script. The provenance check now passes on local builds.

Verification

$ bash scripts/dogfood-build.sh
▶ Building claw from ... (d074d1c0 ...)
✓ Binary verified: d074d1c0 == HEAD (d074d1c0)
  To dogfood: export CLAW=.../target/debug/claw

$ $CLAW version --output-format json | jq .git_sha
"d074d1c0"   ← non-null, matches HEAD

Also documents latency: cargo run = ~1s overhead/invocation vs 7ms for pre-built binary.

…passes

cargo build without GIT_SHA env var → option_env!("GIT_SHA") = None
→ version JSON returns git_sha:null → dogfood-build.sh fails its own
provenance check every time.

Fix: pass GIT_SHA=$(git rev-parse --short HEAD) to cargo build.
The script now:
  1. Sets GIT_SHA to current HEAD before cargo build
  2. Reads git_sha from the built binary
  3. Compares against HEAD — fails if still null or mismatched

Also adds latency note: cargo run = ~1s overhead/invocation vs 7ms
for pre-built binary; pre-built is recommended for dogfood loops.

Closes the broken provenance check introduced in the initial
dogfood-build.sh commit.
…ation

Two gaps from Gaebal's 21:30 dogfood round:
1. cargo compile noise leaked to stderr during dogfood probes
2. real user config (~/.claw/settings.json) bled in via deprecation
   warnings ("enabledPlugins") even for purely local introspection

Changes:
- Redirect cargo build stderr to /dev/null (-q flag + 2>/dev/null)
  with a fallback re-run on failure so errors remain visible
- Document CLAW_CONFIG_HOME isolation pattern in script output:
    CLAW_ISOLATED=$(mktemp -d)
    CLAW_CONFIG_HOME=$CLAW_ISOLATED $CLAW <cmd> --output-format json
    rm -rf $CLAW_ISOLATED
- With isolation: zero stderr lines for plugins list probe, pure
  JSON stdout, no config warnings

Verified: exit 0, kind:plugin, 0 stderr lines, 0 sessions created.
@code-yeongyu code-yeongyu merged commit ab44985 into main May 4, 2026
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