Repository navigation
fix(native): let authored hack run and interactive exec wait out another project's stop (HACK-2742) - #1285
fix(native): let authored hack run and interactive exec wait out another project's stop (HACK-2742)#1285roodboi wants to merge 6 commits into
Conversation
…her project's stop (HACK-2742) HACK-2739 made an authored finite `hack exec` wait for the provider lease in its requesting process. Authored one-off `hack run` and authored interactive `hack exec` still had only the owner's 15 s wait and reported its expiry as unconfirmed. In all three, the owner's guard (a pending signal, its own `hack down`, a changed publication or pin) could end that wait with a plain refusal, which the CLI also reported as unconfirmed although nothing ran. - `native::foreground::one_off` and `::interactive` wait up to 35 s for a free lease before they send; the interactive one passes its frontend leash as the check. - All three owner paths go through `exec::owner_command_engine`, which answers `graph_authored_exec_lease_busy`, `graph_authored_run_lease_busy` or `graph_authored_command_not_started` for a wait that ended before acquisition; later failures keep their codes. - `hack run` gets the 85 s request bound (was 45 s), the progress line, the not-run refusals and the released admission slot. - The interactive child sends its lease-wait report on its control channel as one closed event line, and its refusal report names the holder; the CLI prints the progress line and an honest refusal. - ExecStopWait.tla gains the owner's cancel (Cancellable, CancelUnconfirmed) with three controls; earlier state counts unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…CK-2742) The Linux all-features test build compiles the authored exec module but not the macOS interactive requester that reads owner_pre_effect_code, so clippy reported it as dead code. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@codex review |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex Review: Didn't find any major issues. Keep them coming! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
🛡️ Codex Security Review · Automatically triggeredSecurity review completed. No security issues were found in this pull request. Reviewed commit: Only the user who started this review can view the report in Codex. ℹ️ About Codex security reviews in GitHubThis is an experimental Codex feature. Security reviews are triggered when:
Once complete, Codex will leave suggestions, or a comment if no findings are found. |
…(HACK-2741) The authored exec requester test (HACK-2739) and its compose sibling in command_lease_tests held the lease for 600 ms against a 700 ms bound. The retry loop sleeps up to 50 ms and checks the deadline before each attempt, so on a hosted macOS runner the caller could give up just as the lock was freed (provider_busy after about 0.75 s on next). As in #1280, the hold stays and the positive case gets 500 ms of slack, ten capped poll intervals; the expiry case asserts its exact refusal only after its deadline has passed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…-lead/authored-run-waits-out-stop
|
@codex review |
|
Head 8c139fd: merged #1286's branch in (HACK-2741 test slack, so hosted macOS Candidate core is not red from the inherited #1278 test). The two expiry tests this PR added now assert their exact refusal only after the deadline. Checked on this Mac under the native-bench lock, |
|
Codex Review: Didn't find any major issues. Hooray! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
🛡️ Codex Security Review · Automatically triggeredSecurity review completed. No security issues were found in this pull request. Reviewed commit: Only the user who started this review can view the report in Codex. ℹ️ About Codex security reviews in GitHubThis is an experimental Codex feature. Security reviews are triggered when:
Once complete, Codex will leave suggestions, or a comment if no findings are found. |
Real-VM results at
|
| Row | Observed (this head) | next cd2e21fd |
Result |
|---|---|---|---|
1. Authored hack run worker sh -c 'echo …' in Y during X's 30 s stop, ×3 |
one line "Waiting for the native runtime lock, held by a project stop. This command continues once it is released (up to 35 s).", then the command's output; exit 0 after 29.7, 29.3, 29.3 s | exit 1 after 15.1 s: "Native authored run completion is unconfirmed…", 3 of 3 | PASS |
2. Authored interactive hack exec worker -- /bin/sh in a pty during X's stop |
the same single progress line, then the shell prompt after 29.1 s. echo works, exit returns 0. The pty is back to icanon echo afterwards |
exit 1 after 15.2 s: "Interactive exec could not confirm admission or completion (native_graph_foreground)…" | PASS |
3. operation.lock held 45 s (flock): hack run |
exit 1 after 35.1 s: "E_LIFECYCLE_FAILED: hack run could not acquire the native runtime lock (provider_busy); nothing ran." / "Holder: unavailable." / "Retry hack run once the holder finishes." No "unconfirmed", no command output. hack ps shows only worker afterwards |
"unconfirmed" after 15.1 s | PASS |
| 3. The same: interactive exec in a pty | after one progress line, exit 1 after 35.1 s: "hack exec could not acquire the native runtime lock (provider_busy); nothing ran." / "Holder: unavailable." / "Retry hack exec once the holder finishes." No "unconfirmed". Terminal not left raw (icanon echo after exit). Marker absent (touch never ran) |
"could not confirm admission or completion" after 15.2 s | PASS |
4. Y's own hack down while a run waits on the lock (lock held 15 s, run started, down 3 s later) |
the run prints the progress line, then after 24.6 s exits 1 with "E_LIFECYCLE_FAILED: Native authored run completion is unconfirmed; command effects may have occurred and its one-off container may remain until down." The down exits 0 after 21.8 s ("services stopped · data retained") |
the run fails "unconfirmed" after 3.1 s | FAIL |
5. Latency, nothing holding the lock, 20× run and 20× exec, order head, next, next, head |
run medians 0.325 / 0.32 s, exec 0.28 / 0.285 s; no progress line in any of the 80 calls |
run 0.335 / 0.33 s, exec 0.30 / 0.29 s |
PASS |
6. Finite hack exec during X's stop |
one progress line, output, exit 0 after 29.3 s | the same (from #1278) | PASS |
7. smoke |
PASS |
Marker files: for rows 1 and 3 I first used an authored project with persistent /data storage, so hack run could leave a marker. On that project, hack run fails at once as "unconfirmed" (0.10 s, nothing holding the lease) and hack exec takes ~16 s, on this head and on next alike. Filed as HACK-2752. So the busybox project's command output is the proof that the command ran (row 1) or did not run (row 3).
Evidence: 20261126-191440-8b0bca62-p1285-s0 (rows 1, 3 run, 4, 6), 20261126-193424-8b0bca62-p1285-pty-s0 (rows 2, 3 interactive), latency …190802-8b0bca62, …190906-cd2e21fd, …191012-cd2e21fd, …191117-8b0bca62 (p1285-lat), smoke 20261126-191221-8b0bca62-smoke-s0; next: 20261126-192139-cd2e21fd-p1285-s0, 20261126-193729-cd2e21fd-p1285-pty-s0.
Harness false failures, fixed and rerun: the harness sets HACK_NO_INTERACTIVE=1, which forced finite exec in the first pty runs. The first pty driver also could not read termios after the session ended.
Nothing was merged.
…end as not started (HACK-2742) VM row 4: Y's own `hack down` ran while a Y `hack run` waited for the lease. After the wait, the requester found the owner's pin gone (Pin::load or pin.connect in request_selected, pin.connect in the interactive requester) and returned the plain refusal, which the CLI reported as "unconfirmed", although nothing had been sent. Every requester failure before the request is written now answers graph_authored_command_not_started: for finite exec and run as the cause of the native_graph_foreground refusal, for interactive exec as the report code. Status, observe, logs and cleanup keep their refusals. A failure after the write, including an owner that accepted and then exited, keeps "unconfirmed". The CLI's not-started line now says the owner stopped or changed before the command was sent or started. Review L4: the call sites go through owner_exec_engine and run::owner_engine, and tests check that each passes its own command; the interactive requester's forwarding of owner codes is a tested function. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Head 73a1a61 fixes VM row 4 (the review's L1) and adds the L4 tests.
|
|
@codex review |
|
Codex Review: Didn't find any major issues. Already looking forward to the next diff. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
🛡️ Codex Security Review · Automatically triggeredSecurity review completed. No security issues were found in this pull request. Reviewed commit: Only the user who started this review can view the report in Codex. ℹ️ About Codex security reviews in GitHubThis is an experimental Codex feature. Security reviews are triggered when:
Once complete, Codex will leave suggestions, or a comment if no findings are found. |
|
Linux x86_64 at 73a1a61 (toolchain image, |
Real-VM rerun at
|
| Row | Round | Observed | Result |
|---|---|---|---|
4. hack run waiting on the lock while Y's hack down runs |
1 | exit 1 after 24.7 s: "hack run did not start: the project's owner stopped or changed before the command was sent or started (graph_authored_command_not_started); nothing ran." / "Check hack ps, then retry hack run once the project is up." ps: not_started, no entries |
PASS |
| 2 | exit 1 after 24.7 s: "Native authored run completion is unconfirmed; command effects may have occurred and its one-off container may remain until down." The command's output never appeared; ps is clean (not_started) |
FAIL | |
| 3 | the same as round 2 | FAIL | |
4b. Interactive hack exec worker -- /bin/sh in a pty (interactive mode on), same timing |
1 | exit 1 after 24.6 s: "hack exec did not start: …(graph_authored_command_not_started); nothing ran. Check hack ps, then retry hack exec once the project is up." Terminal restored (icanon echo); ps clean |
PASS |
| 2 | exit 1 after 24.7 s: "No receipt is currently retained for session 4c4c…. Interactive exec could not confirm admission or completion (session_cleanup_uncertain); no request was replayed." Terminal restored; ps clean |
FAIL (no did-not-start message) | |
1. hack run during X's 30 s stop |
one progress line, output, exit 0 after 29.4 s | PASS | |
7. smoke |
PASS |
In every round the down exits 0 in about 21.8 s, and the shell or command never ran. So the wrong text claims an uncertainty that is not real. The behaviour depends on timing: the same sequence produces the right message in round 1 and the old one in later rounds.
Evidence: 20261126-201450-73a1a613-p1285-r4-s0 (.keep), smoke 20261126-*-73a1a613-smoke-s0. Nothing was merged.
Fixes HACK-2742. Follows #1278 (HACK-2739), which fixed the same failure for authored finite
hack exec.Problem
In an authored project (
hack.project.json), two commands still sent their request straight to the project's owner, whose lease wait is 15 s inside a fixed 30 s budget on its only loop:hack run;hack exec(a terminal on both ends).During another project's 30 s stop, both should fail after about 15 s with "completion is unconfirmed" (run) or "could not confirm admission or completion" (interactive), although nothing ran.
A third case affected all three authored commands, finite exec included. The owner's check (a pending signal, its own
hack down, a changed publication or pin) runs before every lease attempt, so it can end the owner's wait. It returned the plainrefused(), and the CLI also reported that as unconfirmed, although nothing had been read, touched or started.Root cause
On
nextat cd2e21f:packages/runtime-core/src/provider/graph/native/foreground.rs(one_off,interactive): neither requester waited for the lease before sending.packages/runtime-core/src/provider/graph/native/runtime/run.rs(execute) andexec.rs(interactive): the owner's wait was the only wait, and its expiry kept a rawprovider_busy.exec.rsandrun.rs:guard()?and the guard passed intoconnect_command_untilreturned the plainrefused()(native_graph_foreground) for a pending signal before any effect.src/backends/native-authored-project-oneoff.ts: the request bound was 45 s, too short for a 35 s requester wait plus the owner's fixed 40 s read, and every failure became "unconfirmed".src/backends/native-interactive-exec.ts: the interactive report carried only one code, and every refusal read "could not confirm admission or completion".Behaviour
native::foreground::one_offand::interactivecalllifecycle::await_free_command_leasebefore they send (35 s, the same wait fix(native): let authored hack exec wait out another project's stop (HACK-2739) #1278 added for the finite exec). It is one lock attempt when nothing holds the lease. The interactive requester passes its frontend leash as the check (await_free_command_lease_checked), so a frontend that is gone ends the wait. A refused check is returned as it is.exec::owner_command_engineruns the owner's guard and the 15 s wait for finite exec, interactive exec and run. It answers with a pre-effect code only for a wait that ended before acquisition:graph_authored_exec_lease_busy(exec, as in fix(native): let authored hack exec wait out another project's stop (HACK-2739) #1278) orgraph_authored_run_lease_busy(run) when the lease stayed busy;graph_authored_command_not_startedwhen the guard refused (a pending signal orhack down).nativeAuthoredCommandNotRun(shared by exec and run):{status: "not_run"}with the wire code and cause as they arrived, and a background command's admission slot is released. Everything else keeps "unconfirmed".hack runbound. 85 s, the same as the authored finite exec (it was 45 s): the 35 s wait, 5 s to send, the fixed 40 s read and a 5 s margin.hack runsetsonLeaseWait, as exec does. The interactive child's stderr is the user's terminal, so its lease-wait report goes on its private control channel (fd 3) as one closed event line ahead of the final report:{"version":1,"event":"lease-wait","holder":"project-stop"}. The CLI prints the usual single progress line for an authored interactive exec. A Compose interactive exec ignores the event (its own wait is 15 s)."holder":"project-stop"). The requester forwards the owner's pre-effect codes as the report code, because that report carries only one code. For an authored exec refused before its session existed, the CLI prints the same lines as above; a session-correlated refusal and any Compose refusal keep their messages.psand the normal path are unchanged.pstakes no lease. With nothing holding the lease, each request makes one extra lock attempt and prints nothing.Not changed
hack run(HACK-2740 territory) is untouched: it keeps its owner's 15 s wait within one bound for selection and admission.docs/guides/native-candidate.md, in a different paragraph. Neither PR changessrc/lib/native-authored-command.tsin common: this one doesn't touch it. Whichever lands second getsnextmerged in.Evidence
Local (macOS arm64):
--features native-config-plan, under the native-bench lock): 164 passed across the lease, command-lease, owner-lease, authored-exec, authored-run and interactive filters, including the new tests:the_owners_wait_refusals_have_their_own_pre_effect_codes: the three codes per command; a refused guard wins over a busy lease; other codes are kept; all pass the reply-code filter.the_owners_lease_wait_expires_with_each_commands_pre_effect_code:owner_command_engineon a held flock, for exec and run (scaled: 300 ms for 15 s).a_refused_owner_check_ends_the_wait_as_not_started: a guard that starts refusing after 200 ms ends the wait as not started within 2 s; a guard that refuses at once does the same.an_owner_failure_after_acquisition_keeps_its_code.the_authored_run_requester_waits_before_it_contacts_the_owner: theone_offcall site waits out a 600 ms stop.a_refused_requester_check_ends_the_wait_with_its_own_error: the interactive leash check ends the requester's wait with its own error, and the refusal's holder token isproject-stop.native-authored-project-oneoff: the 85 s bound, one progress line, the three not-run refusals with their details and the released slot, other failures still unconfirmed with the slot held.native-authored-project-exec: the not-started message and detail.native-command-lease: only the exact owner cause pairs are not-run refusals.native-interactive-exec: the event line parser, the report's closedholderfield, the messages for native and Compose, and two new PTY cases (native-lease,native-not-started) in which the fake runtime sends the event and the refusal over the real fd 3: one progress line, "nothing ran", no session query.native-runtime-client: the two new causes pass the closed cause filter.native-authored-command,native-project-exec,native-project-one-off,native-project-dependency-refresh.ExecStopWait.tlagainsCancellable(the owner's check may end its wait) andCancelUnconfirmed(the report before the fix). Every earlier config sets both toFALSE, and their state counts are unchanged. New controls:authored-cancel(335 states; report invariants,NoSendWhileHeldandSettleshold);authored-cancel-old(UnconfirmedOnlyAfterSendviolated:cancelled = TRUE,report = "unconfirmed",sent = FALSE);authored-cancel-reach(the cancel is reachable, reported as not run).bun run test:models: 496 controls verified.bun install --frozen-lockfile, rootbun run typecheckandbun run check(the Biome warnings are the existing set),docs:prepareanddocs:check,privacy:checkafter staging, gitleaks,cargo +1.97.1 fmt --check, clippy--all-targets -D warningswith default features and with--all-features.Linux x86_64, in the repo's toolchain image (
.hack/toolchain/Dockerfile), every container run with--init, in a scratch clone:5c4f1677:cargo fmt --checkpassed; clippy--all-targets -D warningspassed with default features and failed with--all-features:owner_pre_effect_codewas dead code there, because its only reader is the macOS interactive requester. The second commit gates it to macOS. At8b0bca62: fmt and both clippy runs pass.bash scripts/test-runtime-core.sh: 1709 passed, 0 failed.bash scripts/test-runtime-core.sh --all-features: 1924 passed, 0 failed.bun run test:models: all 496 controls verified.Not run: a VM, Docker on the Mac, or the full suite. None of this is real-VM evidence yet.
Mac rows to run
hack runduring a 30 s stophack downin X, then within a secondhack run worker sh -c 'echo ran > /tmp/hack-2742-marker; echo ok'in Yok, exits 0hack execduring a 30 s stophack exec worker -- shin Y on a terminalnothing ran,Holder: …,Retry hack run …(orhack exec …). No "unconfirmed" or "could not confirm". The marker is absenthack downin Yhack runexits 1 with eitherdid not start … (graph_authored_command_not_started); nothing ran.or the requester's lease refusal; no "unconfirmed"; Y'shack downcompleteshack run worker trueandhack exec worker -- truein Y, on this head and onnextcd2e21f🤖 Generated with Claude Code
Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.