Skip to content

Phase A1b: launcher contract follow-up - #2034

Merged
neuromechanist merged 11 commits into
feature/issue-2005-epic-compute-corefrom
feature/issue-2006-a1b-launcher-contract-follow-up
Nov 4, 2026
Merged

neuromechanist merged 11 commits into
feature/issue-2005-epic-compute-corefrom
feature/issue-2006-a1b-launcher-contract-follow-up

Conversation

@neuromechanist

@neuromechanist neuromechanist commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

Phase A1b of the compute gateway core (epic #2005, follow-up to phase A1, issue #2006): the launcher contract changes found by the review of the launcher in nemarOrg/nemar-process#7. Nothing here touches D1, the Worker, the CLI or the network. The shared JSON Schema and the golden vector below are the interface nemar-process re-pins to. This body is current as of the round 1 review fixes (head 87fba589).

What changed

  • Launcher details and who pays (item 5). shared/compute-state.ts declares LAUNCHER_DETAILS (each of the seven launcher codes with the fixed-word details it may emit) and PLATFORM_LAUNCHER_DETAILS (the subset that is a NEMAR, node, runtime or contract fault). isPlatformFailure(code, detail) now lets a declared detail decide for a launcher code: a platform detail is a platform failure even under runtime_error, a submitter detail is not one even under code_fetch_failed or dataset_fetch_failed, and a missing or undeclared detail keeps the old behaviour (the code alone decides). The result_upload_failed and RESULT_REFUSAL_DETAILS rules are unchanged. The rule for a word: platform if and only if a submitter cannot cause it with a valid specification and bundle.
  • NEMAR_SIF_ROOT and the image file (item 1). LAUNCHER_ENV.SIF_ROOT is NEMAR_SIF_ROOT, required: the launcher has no fallback and ends image_missing when it is unset. image.sif is exactly <64 lowercase hex>.sif, the file name of the Singularity image file built from the image's digest, relative to NEMAR_SIF_ROOT. The hex of image.digest plus .sif must equal it: a rule the JSON Schema cannot express, enforced by a refinement on LaunchSpecSchema and the pure helper sifFileNameForDigest, and stated in the schema description and the docblock. The launcher does not verify the file's content hash; the name is all that ties the file to the digest. The differential harness now lists the rules only zod enforces apart (ZOD_ONLY_LAUNCH_CASES) instead of failing on them.
  • Dataset version form (item 2). The launch specification's datasets[].version is the data-plane tag, latest or v<major>.<minor>.<patch>, at most 64 characters (round 1: the limit of the provenance staging[].version), in zod and in the JSON Schema; the user-facing job specification keeps accepting what it accepted. The pure helper dataTagForVersion(version) (1.0.2 gives v1.0.2, v1.0.2 and latest unchanged, anything else null) is what the Worker's launch-specification builder will use, and a test holds the grammar to VERSION_TAG_RE in backend/src/services/data-router.ts. launchSpecFits is false for a job whose dataset version has no tag, and datasetVersionWithoutTag names the field.
  • Declared semantics (items 3 and 4). The include glob dialect (matched against manifest paths relative to the dataset root; ** crosses /; * and ? stay inside one path segment; [abc], [a-c] and [!abc] classes; case-sensitive; no escapes; a matcher must run in time linear in pattern length times path length; no cap on wildcards) and the entry semantics (python /code/<entry> followed by args; a command as given with args appended; an image job with an entry runs /code/<entry> directly and needs the executable bit; the runtime image provides python on its PATH; a bundle's member names may carry a leading ./, and absolute names, .., links, devices and named pipes are refused by the launcher) are stated once as COMPUTE_ENTRY_DESCRIPTION, COMPUTE_COMMAND_DESCRIPTION, COMPUTE_ARGS_DESCRIPTION and COMPUTE_INCLUDE_DESCRIPTION, carried as zod descriptions on both specifications, word for word in the schema, and in the JobSpecSchema docblock; tests hold the three to each other.
  • Records (item 6). ADR 0118 (still accepted) gains decisions 13 to 15 and a clause on decision 4; section 6 of .context/compute-program/implementation-notes.md records all of it. The classification table and the import guard in test/contract-schemas.test.ts needed no change: nothing added is a schema object or a strict name (the descriptions and helpers are plain exports).

Round 1 review fixes

  • The launch invariant, stated one way everywhere: a valid job specification always fits the 64 KiB and is well formed; the dataset version tag is the one launch rule JobSpecSchema does not enforce (1.0, abc, V1.0.2 and 2.0.0-rc.1 are valid for a job and have no tag), so the Worker and the CLI must run launchSpecFits and refuse with invalid_spec BEFORE the hold. The new pure helper datasetVersionWithoutTag(datasets) returns the first such field as datasets.<i>.version so they can name it. The launchSpecFits and JobSpecSchema docblocks, the implementation notes, the ADR and the test title are reworded; JobSpec was not tightened.
  • The tag cap is 64 (COMPUTE_DATA_TAG_MAX, schema maxLength 64), so a bare job version is at most 63 characters and every tag dataTagForVersion can return passes the provenance staging[].version pattern and bound; a test walks every tag length and checks it in zod and Ajv.
  • Who pays, decided by the driver: the Worker refuses at submit, with its own dataset_not_eligible, any dataset not public and published, any version not published and any manifest over 38,000 entries, so dataset_not_found and the manifest-too-large case stay the platform's; the Worker's own cancel record overrules the launcher's terminated detail; the default for an undeclared runtime_error detail is deliberate (charged); and a launcher change that adds a detail word lands with its entry here in the same pair of pull requests (the launcher's drift test compares the lists per code). All in ADR 0118 decision 13 and the implementation notes, pinned by a test.
  • The include dialect is precise: **/ matches zero or more directories (a/**/b matches a/b); ** elsewhere matches any run of characters including /; an unterminated [ is a literal; an empty class [] and an inverted range such as [z-a] are refused, and bad_include is exactly that set. The text is one description (schema, zod, COMPUTE_INCLUDE_DESCRIPTION), kept in step by the equality test; the pure helper includePatternProblem(pattern) returns empty_class, inverted_range or null, and JobSpecSchema refuses such a pattern at submit, naming datasets.<i>.include.<j>. A character class never matches / (the driver's last decision): like * and ? it stays inside one path segment, and a negated class [!a] matches any single character except a and /; this sentence is in the same description, ADR decision 15, the implementation notes and the JobSpec docblock, each pinned by a test. The launch specification stays permissive (the launcher alone refuses it).
  • image.uri must end with @sha256: and the hex of image.digest: a zod-only rule like the sif rule, listed in ZOD_ONLY_LAUNCH_CASES and stated in the schema description. Worker-only narrative was trimmed from the shared descriptions of version, sif and uri (it moved to the zod docblocks), and a test keeps it out.

Known launcher limitations (the launcher's matter, not changed here): entry_failed; unsafe_archive raised for an OSError creating a member (a node fault: the launcher is to use disk_error); the Worker routes' own refusal code words used as details under the upload codes; and, for the include dialect, the launcher's glob_regex at c872f5a treats [] as a literal and []x] as a class, lets a class match / (the contract says it never does), and compiles to a backtracking regular expression where the contract requires linear time.

IMPORTANT: item 5 changes which launcher details are refunded, and the owner has not yet confirmed it

Until now code_fetch_failed, dataset_fetch_failed and result_upload_failed were always refunded and runtime_error never was. With this change a launcher failure is refunded or charged by its detail: for example runtime_error with image_missing, invalid_spec, internal_error or no_container_runtime is now REFUNDED, while code_fetch_failed with unsafe_archive or archive_too_large, and dataset_fetch_failed with bad_include, too_many_files or too_many_bytes, are now CHARGED. The word lists were settled by the driver with the advisor and are the launcher implementer's list; they have NOT been confirmed by the owner. Nothing charges or refunds anything yet (the ledger arrives in later phases), so the cost of changing a word is one line in shared/compute-state.ts and its test table.

New schema and golden vector

shared/contract/compute-launch.schema.json: SHA-256 6707bb26d653b6fc7521a2e05fe33758e533f57f3453ca5567e3698e00469ec2, 21,025 bytes (it changed in round 1: the version maxLength, the include and uri descriptions, trimmed narrative; and in the last commit: the include description says a character class never matches /).

The golden launch specification (unchanged in round 1) now has the dataset version v1.0.2 and image.sif equal to the 64-character b digest hex plus .sif; the other fields are as before (a non-ASCII character, an astral character, a double quote and a space in args). Encoded text (766 bytes, ASCII):

{"job_id":"job_0123456789abcdef01234567","runtime":"python","entry":"run.py","args":["--label","caf\u00e9 \"q\" \ud83d\ude00"],"bundle":{"sha256":"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa","size":1234},"datasets":[{"id":"nm000104","version":"v1.0.2"}],"api_base":"https://api.example.test","image":{"uri":"docker://ghcr.io/example/runtime@sha256:bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb","digest":"sha256:bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb","sif":"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb.sif"},"env":{"OMP_NUM_THREADS":"4"},"resources":{"gpus":0},"limits":{"max_files":38000,"max_total_bytes":1073741824},"job_token":"ttttttttttttttttttttttttttttttttttttttttttt"}

SHA-256 of those bytes: 88fcf9a4d6e63ae7bbedc9be536989fd7f2c263bb2b1c2fb6cfd706f49efe857. It is pinned as a literal in test/compute-contract.unit.test.ts and was recomputed independently with Python json.dumps(spec, separators=(",", ":"), ensure_ascii=True) (the same method reproduces the previous golden digest 68ef4653...).

Gates

  • bun test test/compute-state.unit.test.ts test/compute-contract.unit.test.ts test/compute-header.unit.test.ts test/adr-index.unit.test.ts test/contract-schemas.test.ts: 600 pass, 0 fail, 72580 expect() calls, across 5 files.
  • bun run typecheck (tsc --noEmit for the CLI and the backend): exit 0.
  • bunx biome check shared test/compute-state.unit.test.ts test/compute-contract.unit.test.ts test/compute-header.unit.test.ts test/contract-schemas.test.ts: Checked 91 files. No fixes applied.
  • Second consumer: Python jsonschema (Draft 2020-12) over the shared schema with 83 documents (the sif, tag and image corpus, the earlier corpus, the golden vector hashed as raw bytes and then parsed): 0 disagreements; the zod-only cases (the sif, the image reference, the include patterns) are valid there by design.
  • Mutation: every line this change adds was mutated one at a time and killed (round 1 added about 150 more: the tag helper and cap, the include scanner, the image-reference rule, the descriptions and the record sentences), and every bound number of the schema (184), compute-launch.ts (55) and compute.ts (174) was bumped by one in each direction: 0 survivors. One include-scanner mutant hung the test run (an infinite loop) and was counted as killed; two kinds of mutant are equivalent and were not run (p + 2 < body.length against <=, and i = end against i = end + 1).
  • The whole bun test is for the driver to run on the final head.

Words that differ from the launcher's codes.py

Checked against launcher/nemar_launch/*.py on origin/feature/issue-2-phase1-repository-scaffold-and-the-nemar at c872f5a (the file codes.py itself declares no detail words yet, so the words are read from where the launcher raises them).

  • In the brief's list and declared here, but not yet raised by the launcher at that commit: output_dir_not_empty, bind_source_unsafe, pid_namespace_unavailable, outputs_unreadable and fetch_failed.
  • Raised by the launcher, not in the brief's list; declared and classified here as the platform's by the principle: digest_mismatch (the bundle's checksum mismatch, which the launcher renames), size_mismatch, disk_error, bad_manifest, manifest_too_large, unsafe_path, file_not_found, incomplete_plan, upload_failed, outputs_refused and complete_refused.
  • Raised by the launcher and deliberately NOT declared: the transport words http_<status> (not a closed list), timeout, network_error, redirect_refused, range_not_satisfiable, bad_content_range, truncated and too_large, and the outputs and bundle routes' own refusal code words. Under the fetch and upload codes an undeclared detail is refunded by the old rule, which is right for a transport fault, and if the launcher collapses them into fetch_failed as the brief says nothing changes.
  • file_not_found is declared only under dataset_fetch_failed; the launcher can also raise it under code_fetch_failed for the bundle, where it is undeclared and so refunded by the code, the same answer.
  • outputs_unreadable is declared under both runtime_error and result_upload_failed, because the brief does not say which code carries it; it is charged under either.

What I could not do

  • Nothing was recorded from a real tenant. The word lists are the driver's and the launcher implementer's, not the owner's.
  • The design page (admin/design/compute-gateway) is not updated: the docs checkout is read-only, so that step stays with the driver.

@github-actions

github-actions Bot commented Nov 4, 2026 •

Copy link
Copy Markdown

📦 Package Preview

Your package is ready to test!

bun install -g nemar-cli@PR2034

Version: 0.10.28-PR2034.87fba58
Commit: 87fba58


🤖 Updated on each push.

@neuromechanist
neuromechanist merged commit 7ba7d2f into feature/issue-2005-epic-compute-core Nov 4, 2026
2 checks passed
@neuromechanist
neuromechanist deleted the feature/issue-2006-a1b-launcher-contract-follow-up branch November 4, 2026 14:37

This branch was previously deployed

1 inactive deployment
npm — 87fba589 Deployed Nov 4, 2026 by neuromechanist via publish #4146
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