fix(trust): fall back to in-memory TUF metadata on a cache write race #3512
All Vouch review confidence checks passed
Residual risk 0.19 = Change Risk (0.48) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.48 · 546 lines diff across 6 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.377
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #3512"
general
weight: 0.35
yuanchen8911
Summary
Fixes a race in the shared Sigstore TUF cache that failed binary-attestation verification when several
aicrprocesses ran at once. This is what turned main's CLI E2E red on 563077763.Motivation / Context
The On Push Qualification run for 563077763 (run 40932605071) failed CLI E2E on both attempts, each time in a different parallel signing test:
cli-bundle-headless-oidc-ci;cli-bundle-attestation-ci.Both failed with:
That commit (#3505) only bumps a chart pin; the previous 11 main runs were green.
Fixes: N/A
Related: N/A (main On Push Qualification run 40932605071)
Type of Change
Component(s) Affected
cmd/aicr,pkg/cli)cmd/aicrd,pkg/server)pkg/recipe)pkg/bundler,pkg/component)pkg/collector,pkg/snapshotter)pkg/validator)pkg/errors,pkg/k8s)docs/,examples/)pkg/trust(Sigstore trusted root and signing config)Implementation Notes
Cause. Every
aicrprocess uses the same TUF cache under~/.sigstore. When go-tuf refreshes, it writes each metadata file to a temp file, renames it into place, reads it back and compares (persistMetadatain go-tuf v2.4.2). If another process renames in different bytes between that rename and the read-back, the comparison fails withfailed to persist metadata, which has no underlying cause. Timestamp metadata is re-signed often, so two concurrent refreshes can download different bytes.On push, main's CLI E2E runs extra keyless signing tests in parallel. Each runs
aicr bundle --attest, which refreshes the cache to verify the binary attestation, so main hits the race while PR runs do not. The same race can hit any user who runsaicrcommands in parallel on one host.Fix.
pkg/trustnow builds and refreshes TUF clients through two helpers,newClientandrefresh. When either loses that race, it starts over once withWithDisableLocalCache(), which reads the metadata into memory and cannot race again. Every other error is returned as before, and the callers keep their error classification. The match is on go-tuf's message text, because go-tuf exports no sentinel for it; the comment cites the source.Testing
TestNewClientFallsBackOnPersistRaceandTestRefreshFallsBackOnPersistRacereplace the TUF operations with fakes. They cover the fallback, the fallback failing in memory too, and other errors not being retried. Both fail with the fallback disabled.All pass;
make qualifyreports 85.8% coverage.Risk Assessment
The fallback runs only on this one error. It reads the same verified metadata from the same TUF repository, just without writing the cache.
Rollout notes: N/A
Checklist
make testwith-race)make lint)git commit -s -S) — GPG signing info