Skip to content

Phase D3b: nemar compute submit, logs, results and cancel - #2076

Merged
neuromechanist merged 27 commits into
feature/issue-2021-epic-compute-usersfrom
feature/issue-2024-compute-submit-cli
Nov 7, 2026
Merged

neuromechanist merged 27 commits into
feature/issue-2021-epic-compute-usersfrom
feature/issue-2024-compute-submit-cli

Conversation

@neuromechanist

@neuromechanist neuromechanist commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

Phase D3b of epic #2021 (issue #2024): the COMMAND-LINE half of a person's job submission, built on the server half merged in #2073. Base is the epic branch, not dev.

What it adds

nemar compute submit [path] [--entry --dataset --partition --nodes --cores --mem --gpus --time --name --runtime --image --env --wait --dry-run --json] [-- args], logs <job> [--tail n], results <job> [--download dir] [--renew], cancel <job> [--yes].

Exit codes (each command's help has an "Exit codes:" block): 0 done, 1 refused by NEMAR / failed / canceled / not signed in, 2 refused on this machine before any job data was sent, 3 --wait ended with the job still live. Failures are on standard error; --json standard output is only the answer.

  • src/lib/compute/header.ts: finds the # /// nemar / % /// nemar block and nemar-job.toml, merges FLAGS, then HEADER, then FILE, then DEFAULTS key by key. The parser itself is the shared shared/compute-header.ts (A1), not a second one on Bun.TOML.parse.
  • pack.ts: one deterministic bundle.tar.gz (sorted, zeroed owner and times, ustar files and folders, Bun.gzipSync, exec bit kept) and its manifest; caps and rule are shared/contract/compute-bundle.ts only.
  • secret-scan.ts: 12 rules, names and path:line only, exit 2 before any job data is sent, no override.
  • upload.ts: one PUT with exactly the issued headers and Content-Length, three retries on 5xx or no answer.
  • wait.ts: injectable sleep and clock, 5 to 30 s backoff, five-failure cap, Ctrl-C detaches without cancelling.
  • prepare.ts: everything before the first request (so --dry-run sends nothing about the job and needs no sign-in); fail.ts: exit codes and stderr.
  • src/lib/api/compute.ts: submitComputeJob, finalizeComputeJob, getComputeLogs, getComputeResults, renewComputeResults, cancelComputeJob (pinned in api-export-surface); request gained a "text" response mode for the log.
  • No file added under shared/contract/, no account-copy key, the compute switch is not read.

Differences from the issue and the merged D3a code

  • Header: the shared A1 parser is used (the issue said Bun.TOML.parse); env and image are flags only.
  • A dataset needs its version ([email protected]); the A1 contract lets an id alone "resolve" in the CLI, but a job against latest cannot be repeated and --dry-run is offline.
  • Files over the per-file cap are left out and listed (as the issue says); symlinks and special files are left out and counted.
  • --dry-run --json prints the request that would be sent (there is no Worker answer); logs --json wraps the text; submit --json prints the finalize answer (the submit answer holds the signed upload address, which is never printed).
  • Job ids are checked locally, so a bad id is exit 2 (D2's status exits 1).
  • ADR 0118 has an amendment for this phase; implementation notes section 15.

Tests

Root bun test test/<file> one file at a time: compute-header-resolve.unit 22, compute-pack.unit 20, compute-secret-scan.unit 47, compute-wait.unit 20, compute-upload.unit 8, compute-results-download.unit 8, compute-submit-cli 39, compute-pack-worker 13, compute-user-e2e-cli 12; neighbours compute-header.unit 56, api-export-surface.unit 14, help-tiers.unit 12, contract-schemas, completion-candidates, compute-read-cli, compute-submit-contract.unit green. bun run lint, bun run typecheck (both) and bun run migrations:d1-check pass on this head. Not run: the full suite, CI.

The e2e spawns the real CLI against the real compute, admin and webhook routers, Miniflare R2, the local S3 interface and the Tapis stand-in: a person granted through the real admin route submits a script with a header and --waits to finished, downloads and verifies, submits and cancels a second job, and balance shows the charge and the release. Also: a refused hold writes and sends nothing; a late finalize; a 503 after the hold then the same key; Ctrl-C exits 3 and does not cancel; a tampered download is deleted; --json purity; the debug log holds no signature.

Mutation runs (each reverted, each caught): header beats flag; a secret rule skipped; CLI cap +1 (caught by the pack unit test and the Worker parity test); Worker policy default +1; shared cap changed; dry-run falls through to sending; scan skipped in the packer; cancel confirmation guard removed; tag-only image accepted; .. check removed from result paths; checksum not verified; credential sent to the store; upload retry removed; 403 retried; address expiry not checked; wait cap 6; SIGINT listener removed; 4xx retried; backoff never resets; new Idempotency-Key per retry; bearer link printed in the listing; upload without the issued headers; detach exit code 0.

Not verified

R2's enforcement of a signed checksum on a presigned PUT (the S3 interface is a stand-in); a Ctrl-C on a real terminal (the test signals the process); Windows paths; the documentation site's command page (docs repository, not touched). Known and not mine: test/account-copy-parity.test.ts red until website#494's keys reach dev.

Review round 1

Fixes on this branch (new commits): results download hardened (src/lib/compute/download.ts: FileHandle writes, .part and symlink checks, realpath containment, no overwrite of a different file without --force, https and no redirect, connect and stall timeouts, per-file FAILED lines, case collisions); unreadable or vanished files are exit 2 naming the relative path; the credential scan also reads UTF-16 and NUL-stripped views and more credential file names; claims reworded to "no job data left this machine" (the notice poll and update check can still run); --wait has a ceiling (job minutes plus 30), treats 429 as transient with Retry-After, aborts a hung read and exits at once on a second Ctrl-C; the upload address is https-only with no redirect and a 5-minute clock margin; the help and ADR say a rerun makes a second job and hold; downloadOne and packCollected return discriminated results.

@github-actions

github-actions Bot commented Nov 7, 2026 •

Copy link
Copy Markdown

📦 Package Preview

Your package is ready to test!

bun install -g nemar-cli@PR2076

Version: 0.10.28-PR2076.32da6cf
Commit: 32da6cf


🤖 Updated on each push.

@neuromechanist
neuromechanist merged commit 98266cf into feature/issue-2021-epic-compute-users Nov 7, 2026
25 of 27 checks passed
@neuromechanist
neuromechanist deleted the feature/issue-2024-compute-submit-cli branch November 7, 2026 10:48

This branch was previously deployed

1 inactive deployment
npm — 32da6cf4 Deployed Nov 7, 2026 by neuromechanist via publish #4321
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