fix(ffi): replace removed std.atomic.Mutex with std.Thread.Mutex#291
Merged
Conversation
`Zig FFI Tests` has been failing on every PR with:
src/catalogue.zig:16:22: error: root source file struct 'atomic'
has no member named 'Mutex'
`std.atomic.Mutex` was removed from the standard library. Nine files in
ffi/zig/src/ still carried a byte-identical hand-rolled wrapper around it
(verified: all nine hash to the same value — one template copied nine times):
const Mutex = struct {
state: std.atomic.Mutex = .unlocked,
pub fn lock(m: *Mutex) void {
while (!m.state.tryLock()) std.atomic.spinLoopHint();
}
pub fn unlock(m: *Mutex) void { m.state.unlock(); }
};
The wrapper's public surface — `lock()` / `unlock()`, instantiated as
`var mutex: Mutex = .{}` — is already exactly `std.Thread.Mutex`'s, so the
whole struct collapses to a one-line alias with no call-site changes:
const Mutex = std.Thread.Mutex;
This is also a behavioural improvement, not merely a compile fix: the wrapper
busy-waited via `spinLoopHint`, burning a core under contention, whereas
`std.Thread.Mutex` parks the waiting thread. 81 other files in this repo
already use `std.Thread.Mutex` directly, so this converges on the in-tree norm
rather than introducing a new one.
Files: sla, catalogue, sdp, loader, verisimdb, guardian, community,
federation, coprocessor.
Verified under the CI pin (zig 0.15.2, per .github/workflows/zig-test.yml) —
all four targets CI runs:
zig build test PASS (13 + 3 tests passed)
zig build readiness PASS (28/28 tests passed)
zig build lib PASS (2/2 steps)
zig build bench PASS (3/3 steps)
Note: `.tool-versions` pins 0.15.1 while the workflow uses 0.15.2. Not changed
here, but the two should be reconciled.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
🔍 Hypatia Security ScanFindings: 228 issues detected
View findings[
{
"reason": "Action actions/checkout@v4 needs attention",
"type": "unpinned_action",
"file": "pages-deploy.yml",
"action": "pin_sha",
"rule_module": "workflow_audit",
"severity": "medium"
},
{
"reason": "Action actions/checkout@v4 needs attention",
"type": "unpinned_action",
"file": "pages.yml",
"action": "pin_sha",
"rule_module": "workflow_audit",
"severity": "medium"
},
{
"reason": "Action actions/checkout@v4 needs attention",
"type": "unpinned_action",
"file": "pages.yml",
"action": "pin_sha",
"rule_module": "workflow_audit",
"severity": "medium"
},
{
"reason": "Action actions/upload-pages-artifact@v3 needs attention",
"type": "unpinned_action",
"file": "pages.yml",
"action": "pin_sha",
"rule_module": "workflow_audit",
"severity": "medium"
},
{
"reason": "Action actions/deploy-pages@v4 needs attention",
"type": "unpinned_action",
"file": "pages.yml",
"action": "pin_sha",
"rule_module": "workflow_audit",
"severity": "medium"
},
{
"reason": "Issue in build.yml",
"type": "missing_timeout_minutes",
"file": "build.yml",
"action": "flag",
"rule_module": "workflow_audit",
"severity": "medium"
},
{
"reason": "Issue in pages-deploy.yml",
"type": "missing_timeout_minutes",
"file": "pages-deploy.yml",
"action": "flag",
"rule_module": "workflow_audit",
"severity": "medium"
},
{
"reason": "Issue in push-email-notify.yml",
"type": "missing_timeout_minutes",
"file": "push-email-notify.yml",
"action": "flag",
"rule_module": "workflow_audit",
"severity": "medium"
},
{
"reason": "Issue in scorecard-enforcer.yml",
"type": "missing_timeout_minutes",
"file": "scorecard-enforcer.yml",
"action": "flag",
"rule_module": "workflow_audit",
"severity": "medium"
},
{
"reason": "Issue in scorecard-enforcer.yml",
"type": "scorecard_publish_with_run_step",
"file": "scorecard-enforcer.yml",
"action": "split_scorecard_publish_job",
"rule_module": "workflow_audit",
"severity": "high"
}
]Powered by Hypatia Neurosymbolic CI/CD Intelligence |
🏁 path-claims benchCommit NumbersHost-dependent — compare deltas across commits, not absolute values. |
hyperpolymath
marked this pull request as ready for review
July 21, 2026 12:33
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.
The failure
Zig FFI Testshas been failing on every PR:This was invisible until the repository's Actions policy was fixed — the workflow
was
startup_failureing before any job ran, so the compile error never surfaced.The cause
std.atomic.Mutexwas removed from Zig's standard library. Nine files inffi/zig/src/still carried a byte-identical hand-rolled wrapper around it(all nine hash to the same value — one template copied nine times):
The fix
The wrapper's public surface —
lock()/unlock(), instantiated asvar mutex: Mutex = .{}— is already exactlystd.Thread.Mutex's. So the wholestruct collapses to a one-line alias, with no call-site changes:
Two things worth noting:
via
spinLoopHint, burning a core under contention.std.Thread.Mutexparks thewaiting thread.
std.Thread.Mutexdirectly, so this removes a divergent copy rather than adding anew pattern.
Files:
sla,catalogue,sdp,loader,verisimdb,guardian,community,federation,coprocessor.Verification
Run locally against the exact CI pin (zig 0.15.2, per
zig-test.yml) — all fourtargets the workflow runs:
zig build testzig build readinesszig build libzig build benchZero remaining code references to
std.atomic.Mutex/std.atomic.spinLoopHint.Note
.tool-versionspins zig0.15.1whilezig-test.ymluses0.15.2. Not changedhere, but the two should be reconciled.