Skip to content

Local stack runs a runner job end to end (DM-17) - #2156

Merged
neuromechanist merged 2 commits into
feature/portable-compute-epicfrom
feature/pc-dm17-stack-runner-flow
Nov 14, 2026
Merged

neuromechanist merged 2 commits into
feature/portable-compute-epicfrom
feature/pc-dm17-stack-runner-flow

Conversation

@neuromechanist

@neuromechanist neuromechanist commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

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.ts starts compute-local-stack (ephemeral ports, temporary state, --seed-fixture) and drives one nemar-floor-zarr job from dispatch to a settled finished through NEMAR's real routes: the owner registers a runner with the stored key, the runner exchanges its secret, an administrator dispatches with executor: "runner" over POST /admin/compute/pipeline/run, then claim (free_slots: 1), started, the launcher's four files and the outputs under X-Compute-Lease through the outputs route and presigned PUTs, outputs-complete, uploading, complete with usage.
The record is asserted through GET /admin/compute/records/<id> and GET /admin/compute/jobs plus the job row: finished, executor runner, accounting none, runner_backend local, launch_spec_digest equal to the SHA-256 of the text decoded from the launch value the stack answered, settled_final_at set, charged_milli 0, zero ledger rows; then the stack's outputs --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_digest is 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/src or backend/scripts: the flow needed none. The external party is the stack's own --seed-fixture stand-in for GitHub and the index; the container's files are the only thing played.
Gates: bun run typecheck and bun run lint clean; bunx biome check backend/test/compute-local-stack-runner.test.ts clean; 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): holdsCurrentLease always true (compute-job-callbacks.ts) kills the no-lease case; leaseBinds returning [0, null] and the lease term of CLAIM_RESULTS_BYTES_SQL made always true (compute-outputs.ts) each kill the lost-lease case only; settled_final_at dropped from NONE_SETTLED_STAMP_SQL and another launch digest written by LAUNCH_DIGEST_UNDER_LEASE_SQL kill the whole-run case; downloadOutputs listing no file, or writing none, kills the outputs case.
Not run, would check: the full bun test because 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 sweepRunnerLeases call 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.only cannot break it; the whole-run case asserts spec.bundle is undefined (a Zarr runner job stages no bundle, so there is no bundle call).
Teardown: each describe waits (at most 10 s) until every ended job has its records copy, then stops the stack raced against a 10 s timeout that logs stack_stop_timeout.
Follow-up for the stack's owner, repro: with exit_number: 1 in the complete call (the job ends failed), a case that throws right after, and stack.stop() called at once, mf.dispose() in teardown of compute-local-stack.ts never returns and the process does not exit (timers, including the hook timeout, never fire, so the block is synchronous; a Promise.race cannot 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 to waitUntil (a no-op in the stack, nothing awaits it) is in flight. A stop() that awaited the stack's pending waitUntil promises, 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.

@github-actions

Copy link
Copy Markdown

📦 Package Preview

Your package is ready to test!

bun install -g nemar-cli@PR2156

Version: 0.10.34-PR2156.830dd6c
Commit: 830dd6c


🤖 Updated on each push.

@neuromechanist
neuromechanist merged commit 27868ce into feature/portable-compute-epic Nov 14, 2026
1 check passed
@neuromechanist
neuromechanist deleted the feature/pc-dm17-stack-runner-flow branch November 14, 2026 02:38

This branch was previously deployed

1 inactive deployment
npm — 830dd6cc Deployed Nov 14, 2026 by neuromechanist via publish #4438
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant