Repository navigation
Local stack runs a runner job end to end (DM-17) - #2156
Merged
neuromechanist merged 2 commits intoNov 14, 2026
Merged
neuromechanist merged 2 commits into
neuromechanist merged 2 commits into
Conversation
📦 Package PreviewYour package is ready to test! bun install -g nemar-cli@PR2156Version: 🤖 Updated on each push. |
This branch was previously deployed
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.
Card DM-17 of the portable compute plan: the local control-plane stack runs a runner job end to end, in process.
New
backend/test/compute-local-stack-runner.test.tsstartscompute-local-stack(ephemeral ports, temporary state,--seed-fixture) and drives onenemar-floor-zarrjob from dispatch to a settledfinishedthrough NEMAR's real routes: the owner registers a runner with the stored key, the runner exchanges its secret, an administrator dispatches withexecutor: "runner"overPOST /admin/compute/pipeline/run, then claim (free_slots: 1),started, the launcher's four files and the outputs underX-Compute-Leasethrough the outputs route and presigned PUTs, outputs-complete,uploading, complete with usage.The record is asserted through
GET /admin/compute/records/<id>andGET /admin/compute/jobsplus the job row:finished,executorrunner,accountingnone,runner_backendlocal,launch_spec_digestequal to the SHA-256 of the text decoded from the launch value the stack answered,settled_final_atset,charged_milli0, zero ledger rows; then the stack'soutputs --job <id>command (spawned) lists and downloads every declared file with its size and bytes.The same flow runs with
localhost/nemar-python@sha256:<64 hex>as the stack's--image(plan, unverified item 15): the launch specification carries that reference,image_digestis its digest, and the job finishes.Lease cases on the stack: an outputs request with no lease, another lease or a malformed one is refused (404
job_not_found) and records nothing; a request that passed the route's check and then lost the lease (the claim released by the sweep and taken by another runner through the real claim route, interleaving injected between two real statements) is refused 409, presigns and writes nothing, and the new holder's own outputs are accepted.No change in
backend/srcorbackend/scripts: the flow needed none. The external party is the stack's own--seed-fixturestand-in for GitHub and the index; the container's files are the only thing played.Gates:
bun run typecheckandbun run lintclean;bunx biome check backend/test/compute-local-stack-runner.test.tsclean;bun test backend/test/compute-local-stack-runner.test.ts backend/test/compute-local-stack.test.ts backend/test/compute-runner-queue.test.ts: 132 pass, 0 fail (6 new); leak check prints nothing.Mutations (each run alone, reverted, tree clean):
holdsCurrentLeasealways true (compute-job-callbacks.ts) kills the no-lease case;leaseBindsreturning[0, null]and the lease term ofCLAIM_RESULTS_BYTES_SQLmade always true (compute-outputs.ts) each kill the lost-lease case only;settled_final_atdropped fromNONE_SETTLED_STAMP_SQLand another launch digest written byLAUNCH_DIGEST_UNDER_LEASE_SQLkill the whole-run case;downloadOutputslisting no file, or writing none, kills the outputs case.Not run, would check: the full
bun testbecause it is the epic gate (about 80 minutes).Card: DM-17.
Review hardening (head see the last commit):
The hand-written lease expiry and the direct
sweepRunnerLeasescall are the only non-route steps in the file (commented in the lease-loss case): expiry is clock-driven and the sweep is the cron step the stack lacks.The outputs-command case takes its job id from the whole-run case (a describe-scoped variable), so a name filter or
test.onlycannot break it; the whole-run case assertsspec.bundleis undefined (a Zarr runner job stages no bundle, so there is no bundle call).Teardown: each
describewaits (at most 10 s) until every ended job has its records copy, then stops the stack raced against a 10 s timeout that logsstack_stop_timeout.Follow-up for the stack's owner, repro: with
exit_number: 1in the complete call (the job endsfailed), a case that throws right after, andstack.stop()called at once,mf.dispose()inteardownofcompute-local-stack.tsnever returns and the process does not exit (timers, including the hook timeout, never fire, so the block is synchronous; aPromise.racecannot save it). A 3 s sleep before the stop avoids it, so the trigger is a stop while the records copy that the complete route hands towaitUntil(a no-op in the stack, nothing awaits it) is in flight. Astop()that awaited the stack's pendingwaitUntilpromises, or made them cancelable, would close it. The test now waits for the copy itself; with the fix a failing case fails in about 0.5 s.Gates rerun: typecheck, lint and biome on the file clean; the three-file run 132 pass, 0 fail; leak check prints nothing.