feat(ffi): surface the terminating reason (timeout/signal/kill) through the C ABI and SDKs#136
Merged
Merged
Conversation
…e C ABI and SDKs (multikernel#131) sandlock_result_exit_code flattens Signal/Killed/Timeout to -1, so a caller can't tell a timeout from a signal from a normal exit. Add a systemd-style reason taxonomy — deliberately WITHOUT an oom-kill reason: Linux bottoms both a timeout and an OOM kill out in SIGKILL, and telling OOM apart needs cgroup v2 memory.events introspection, so KILLED (SIGKILL, no recoverable number) and TIMEOUT (sandlock-enforced) are the honest split we can report. - C ABI: `sandlock_exit_reason` enum { EXITED, SIGNALED, KILLED, TIMEOUT } (#[repr(u32)]) + `sandlock_result_reason`/`_signal` and the dry-run pair. - Python: `ExitReason` IntEnum + `Result.reason`/`.signal` (and DryRunResult), wired into every native-result path (run/wait/spawn/reduce/Process.wait/ Pipeline/GatherPipeline/dry_run); the fragile `exit_code == -1` timeout heuristic is replaced by `reason == TIMEOUT`. reason defaults to None on the error paths that never produced a native result. - Go: `ExitReason` + `Result.Reason`/`.Signal` via readResult and DryRun. - Tests: Python + Go cover exited/timeout/signaled(SIGTERM)/killed(SIGKILL); a Rust FFI unit test pins all four ExitStatus variants incl. KILLED and the null-result contract.
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.
Closes #131.
sandlock_result_exit_codeflattensSignal/Killed/Timeoutto-1, so acaller can't tell a timeout from a signal from a normal exit. This adds the
systemd-style reason taxonomy you approved ("go for it", minus the oom-kill):
Linux bottoms both a timeout and an OOM kill out in
SIGKILL, and telling OOMapart needs cgroup v2
memory.eventsintrospection, soKILLED(SIGKILL, norecoverable number) and
TIMEOUT(sandlock-enforced) are the honest split.C ABI
sandlock_exit_reasonenum{ EXITED, SIGNALED, KILLED, TIMEOUT }(
#[repr(u32)], matching the sibling enums).sandlock_result_reason/sandlock_result_signal, plus thedry_runpair.signalis the number forSIGNALED, else-1; a null result isKILLED/-1.Bindings (parity)
ExitReasonIntEnum +Result.reason/.signalandDryRunResult,wired into every native-result path (run / wait / spawn / reduce /
Process.wait/Pipeline/GatherPipeline/dry_run). The fragileexit_code == -1timeout heuristic is replaced byreason == TIMEOUT.ExitReason+Result.Reason/.SignalviareadResultandDryRun.Tests
ExitStatusvariants incl.KILLEDand thenull-result contract.
Full CI (Rust + Go + Python 3.10–3.12, low-ABI, cbindgen header check) is green.