Skip to content

Phase A6: First-party pipeline dispatch - #2054

Merged
neuromechanist merged 28 commits into
feature/issue-2005-epic-compute-corefrom
feature/issue-2011-phase6-first-party-pipeline-dispatch
Nov 6, 2026
Merged

neuromechanist merged 28 commits into
feature/issue-2005-epic-compute-corefrom
feature/issue-2011-phase6-first-party-pipeline-dispatch

Conversation

@neuromechanist

@neuromechanist neuromechanist commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Phase A6 of the compute core epic (#2005): first-party pipeline dispatch. Closes #2011 once it reaches dev with the epic.

What changed

  • Migration 0117_compute_pipeline_stamps.sql: one stamp per dataset version, recipe, recipe version and engine; a partial unique index on dispatched and succeeded; deleteDatasetCascade deletes stamps and keeps the job rows.
  • shared/compute-recipes.ts (import-free): nemar-floor (CPU, shared, automatic) and nemar-ica (GPU, a placeholder: no path dispatches it, recipe_placeholder); the argument vector that carries --image-digest; the reader of the recipe's own record.
  • compute-pipeline-eligibility.ts: one predicate, SQL and TypeScript side by side, decided from the D1 row (ADR 0065).
  • compute-pipeline.ts: dispatchPipelineJob resolves the recipe BEFORE createJob, builds the specification before the claim, claims the stamp first, creates the job on the platform pipelines pool, links the stamp and submits; syncPipelineStamps; the queue (with a cooldown and a cap for tuples that fail for a dataset-caused reason), pipelineDryRun and dispatchEligible.
  • verifyResults compares the digest a recipe job passed with the launcher's provenance.json and fails the job as image_digest_mismatch.
  • POST /admin/compute/pipeline/run and GET /admin/compute/pipeline/status; nemar admin compute pipeline run|status, every command with --json.
  • runComputePipelineDispatchCron in the production-only daily block, dark without both switches.
  • ADR 0118 amendment for this phase.

Review fixes (second round of commits)

  • F1: a tuple whose stamp failed is not a candidate for 7 days (RETRY_COOLDOWN_DAYS) and not after 3 failed attempts (MAX_FAILED_ATTEMPTS); both are initial values, because the issue states none. Decided in the candidate SQL. Only dataset-caused failures count toward either. NON_DATASET_FAILURE_WORDS excludes the platform failure codes, job_cancelled, no_job, job_missing, create_failed, recipe_unknown, tuple_mismatch, tuple_already_stamped and tuple_attempt_taken; a refusal is not a failure either. The launcher's runtime_error, time_limit, out_of_memory and entry_not_found, job_failed, and the recipe's outputs_missing, record_unreadable and record_mismatch count. An admin dispatch of one named dataset bypasses the cooldown and the cap (it is still refused for a live stamp, a held tuple or an ineligible dataset).
  • F2: the seven-day drift comparison is replaced by a per-result rule. A finished job whose record names another tuple than its stamp claimed holds the CLAIMED tuple (a failed stamp, tuple_mismatch), checked in the shared dispatch path, the queue, the cron and the dry run (registry_drift). A version bump is never held. The hold does not clear by time: it clears on a registry bump, or when its rows are deleted with their dataset (the dataset cascade is the rule), and the next mismatch on any dataset holds the tuple again, so the exposure is bounded by the live cap. The jobs already in flight when a mismatch first appears remain exposed (in the ADR).
  • F3: if createJob throws after its batch committed and the key lookup fails too, the stamp stays dispatched and the sync links the job.
  • F4: the specification is built before the claim; one the schema refuses is invalid_spec, writes nothing and ends a queue run instead of aborting the tick.
  • F5: nemar-ica is a placeholder and every path refuses it with recipe_placeholder, writing nothing.
  • F6: every open stamp the sync visits is touched, so a stuck stamp cannot starve newer ones; every outcome that leaves a stamp open logs the stamp id, dataset id and reason; a queue run that throws reports what it dispatched, and the cron logs the partial count.
  • F7: an engine string longer than the stamp's 64-character column is record_unreadable.
  • F8: a stamp that cannot carry the tuple its record names is labeled for the index that refused it and logged: tuple_already_stamped for the live index (the tuple already holds a live or succeeded stamp) and tuple_attempt_taken for the attempt index (history only, same attempt number); a failed audit write after a dispatch returns the job ids with audit_pending instead of a 500.
  • T1: the digest test now clears the row digest the submit records, so only the new check can fail it (it passed before with the check mutated away). T2: the tick syncs once, and the cost comment and ADR state the bound (about 510). T3 to T5: comments, a test title and spelling. T6: a recipe cut by the tick bound is reported as tick_cap. updated_at of a dispatched stamp means last examined (documented in the migration, the contract and the route).

Deviations and decisions for review

  • The dispatcher dispatches at most 10 jobs a tick, a bound of its own below the owner's daily cap. The tick syncs the stamps once (the second sync per recipe is gone), a stamp costs 5 to 9 statements and calls (so the sync is 250 to 450), a dispatch about 25, so a tick is about 510 in the usual case and 710 at worst, against an allowance of 1,000 that the other daily jobs share (unmeasured).
  • Route placement: the admin routes live in a new file, backend/src/routes/admin/compute-pipeline.ts, registered in routes/admin/index.ts, and not in routes/admin/compute.ts as the issue's wording suggests. The file is the A5 pattern (compute-jobs.ts) and keeps compute.ts to the policy and the pools.
  • backend/test/compute-source-scan.test.ts allowed one gating read of computeEnabled; it now names the dispatch and the route (new work is refused with compute off) and the dry run (reports it).
  • Not done here: the design page and the owner runbook (docs repository), which the issue lists under "When merged".

Mutation evidence

Each mutation was applied by hand, the named tests failed, and the code was restored. None is committed. The anonymous = 0 to IS NOT 1 mutation named in the issue cannot be realized as a row: the column is NOT NULL, so the NULL row cannot be stored. The SQL form is pinned by a test (the term text), and the TypeScript form is tested with a NULL value (the mutation !== 1 flips it).

Guard Test file Mutation Failing tests
Eligibility, anonymity term compute-pipeline-eligibility = 0 to IS NOT 1 (SQL and TypeScript) 2
Eligibility, EEG whole token compute-pipeline-eligibility token match to LIKE 2
Eligibility re-check at dispatch compute-pipeline if (!loaded.eligible) removed 10
Compute switch in dispatch compute-pipeline check removed 1
One live or succeeded stamp per tuple compute-pipeline-stamps-migration, compute-pipeline live index loses dispatched 4 and 5 (race tests on SQLite and Miniflare D1)
Recipe resolved before createJob compute-pipeline python runtime without an image 1
Stamp rewritten from the recipe's record compute-pipeline version and engine not written 3
A conflicting key is never linked compute-pipeline always look up the key 1
Recipe digest vs provenance compute-pipeline-verify check removed 3
Cooldown (F1) compute-pipeline-queue failed stamps ignored in the cooldown clause 2
Dataset-caused failures only (M1) compute-pipeline-queue platform exclusion disabled (NON_DATASET_FAILURE_WORDS emptied) in compute-pipeline.ts 1
Collision words (N2) compute-pipeline attempt-index match removed 1
Failed-attempt cap (F1) compute-pipeline-queue cap raised by 1000 1
Result-based hold written (F2) compute-pipeline hold insert skipped 4
Hold refused at dispatch (F2) compute-pipeline check removed 3
Hold refused in the queue (F2) compute-pipeline check removed 1
Key lookup failure (F3) compute-pipeline branch removed 1
Spec before claim (F4) compute-pipeline, compute-pipeline-dispatch invalid spec rethrown 2
Placeholder (F5) compute-pipeline check removed 1
Sync rotation (F6) compute-pipeline touch removed 1
Sync log (F6) compute-pipeline log text removed 1
Partial count in cron log (F6) compute-pipeline-dispatch count removed 1
Engine bound (F7) compute-pipeline, compute-recipes check removed 2
Collision label (F8) compute-pipeline old label 1
Audit failure (F8) compute-pipeline-routes catch rethrows 3
One sync per tick (T2) compute-pipeline-dispatch sync: false removed 1
Tick cap skip (T6) compute-pipeline-dispatch skip not recorded 1
Queue: dry run writes compute-pipeline-queue dry run syncs and audits 2
Queue: stop at a refused hold compute-pipeline-queue word removed from the stop set 1
Queue: live stamp exclusion compute-pipeline-queue dispatched removed 3
Queue: manifest bound compute-pipeline-queue bound raised 1
Routes: strict body compute-pipeline-routes .strict() removed 3
Routes: dry run before the compute check compute-pipeline-routes check moved above 1
Routes: sync before status compute-pipeline-routes sync removed 1
Routes: live run needs compute compute-pipeline-routes check removed 1
Dispatcher: pipelines switch compute-pipeline-dispatch check removed 10
Dispatcher: production fence compute-pipeline-dispatch check removed 8
Dispatcher: daily cap compute-pipeline-dispatch cap removed 4
Dispatcher: automatic only compute-pipeline-dispatch filter removed 1
Dispatcher: live cap compute-pipeline-dispatch cap removed 2
CLI: dry run flag admin-compute-pipeline-cli flag not sent 4
CLI: neither or both admin-compute-pipeline-cli check removed 2
CLI: blocked terms shown admin-compute-pipeline-cli terms not printed 1

Coverage gaps and residual risks

  • pool_refused and run_ended in the cron need a second automatic recipe in the same pool, and the registry has one (the other is a placeholder). The queue run and dispatch look recipes up by name in the real registry, so a fixture registry cannot reach those branches through the real cron. They are two lines each and are tested only by reading.
  • tick_cap for a recipe that starts with no tick budget left has the same limit; the case where the bound cuts a run is tested.
  • The engine string is unverified against a real run.
  • The record reader depends on C3's draft file names and fields (extensions.nemar.recipe, .engine, .counts).
  • The subrequest cost is unmeasured.
  • An unreported job keeps its stamp dispatched until an administrator cancels it.
  • The status route's GET runs the sync by design, as the issue requires.

Tests run (targeted; the full suite was not run)

  • bun test on the 14 changed test files: 511 pass, 0 fail. Neighbors (compute-full-path, compute-lifecycle-migration, compute-lifecycle-money, compute-lifecycle-submit, compute-lifecycle, compute-switches-flag): 206 pass, 0 fail.
  • bun run migrations:d1-check (120 migrations, 195 objects), bun run typecheck, bun run lint.
  • Full bun test and CI: not run by the implementer.

Import-free table of nemar-floor and nemar-ica: version, engine,
application, resources, and the argument vector that carries the image
digest. Reads the recipe's own record for the stamp. Tested: registry
shape and digest argument (21 pass); one mutation killed.
Migration 0117 holds one stamp per dataset version, recipe, recipe
version and engine, with a partial unique index so a live or
succeeded tuple is claimed once. Deleting a dataset deletes its
stamps and keeps the job rows. Tested: migration on two engines
(19 pass); one mutation killed.
One list of named terms, SQL and TypeScript side by side: active,
public, not anonymous (anonymous = 0, decided from the row), first
published, not withdrawn, DOI not tombstoned, has a version, EEG as a
whole modality token, real nm or on id outside the fixture band. Also
the version helpers a run reads. Tested: 24 pass; two mutations killed.
A recipe passes its image digest as an argument and cannot check it, so
the Worker compares the value the job passed with the digest the
launcher's provenance says it ran, and fails the job as
image_digest_mismatch on a difference, a missing flag or a second one.
Tested: 5 new, 108 lifecycle pass; one mutation killed.
dispatchPipelineJob resolves a recipe into a complete image job before
createJob, claims the tuple's stamp first, takes the hold on the
platform pipelines pool, links the stamp and submits. syncPipelineStamps
moves stamps to succeeded (rewritten from the recipe's own record) or
failed, and recovers a job whose link was lost by its key. Tested: 45
pass on SQLite and Miniflare D1 (race, eligibility, sync, cascade);
six mutations killed.
pipelineCandidates lists the eligible datasets whose newest version
holds no live or succeeded stamp for the recipe's tuple, skipping a
version no launcher can stage. pipelineDryRun reads only and reports
the estimate and what blocks each term. dispatchEligible runs the next
n datasets and stops at a refusal that would repeat. Tested: 18 queue
tests pass; four mutations killed.
POST /admin/compute/pipeline/run takes a recipe, then one dataset with
an optional version or the eligible queue with a limit, plus dry_run;
the body is strict and the Worker supplies every fact itself. A dry run
reads only and works in every environment; a live run refuses
compute_disabled unless compute is on and is audited with counts.
GET /admin/compute/pipeline/status syncs the stamps and pages them.
Tested: 32 route tests, contract and inventory pass; four mutations
killed.
The scan allowed one gating read of COMPUTE_ENABLED. The dispatch and
its route now refuse new pipeline work with compute off, and the dry
run reports the switch; each is named in the scan. Tested: source
scan 4 pass.
runComputePipelineDispatchCron is wired into the production-only daily
block. It returns null outside exact production, does nothing and
touches no table until compute and the pipelines switch are both 1,
dispatches automatic recipes only within the daily cap and the live cap
per pool and a bound per tick, stops at a refused hold, and holds back a
recipe whose registry disagrees with a recent success. Tested: 39 new
tests and the cron wiring pass; five mutations killed.
run takes a recipe and one dataset with an optional version, or the
eligible queue with a limit, plus --dry-run; wrong arguments are refused
before anything is sent and a refused dataset exits 1 with the Worker's
word and the terms that block it. status lists and pages the stamps.
Every command takes --json. Tested: 33 CLI tests against the real routes
pass; three mutations killed.
Amendment for phase A6: the recipe resolved before createJob, the stamp
and its claim, the stamp rewritten from the recipe's record, the image
digest check, eligibility, the dispatcher's caps and the dry run. Tested:
compute-state unit suite passes.
A tuple whose stamp failed is not a candidate for 7 days (initial) and not after 3 failed attempts (initial), decided in the candidate SQL, so failing datasets at the head cannot starve the queue. Tested: 4 new queue tests failed before the change; queue, dispatch, route suites pass.
nemar-ica is marked a placeholder and every dispatch path (single, queue, dry run, route) refuses it with recipe_placeholder, writing nothing. Tested: 3 new tests failed before the change; pipeline suites pass.
A specification the job schema refuses is now invalid_spec with nothing written, and ends a run over the queue, instead of a throw that left a dispatched stamp and aborted the cron. Tested: 2 new tests failed before the change; pipeline suites pass.
If createJob throws after its batch committed and the lookup of the job by its key fails too, the stamp stays dispatched and the failure is logged, so the sync links the job instead of a later attempt making a second one. Tested: new test failed before the change; compute-pipeline suite passes (48).
A record whose package@version exceeds the 64-character engine column is unreadable, so the stamp ends failed (record_unreadable) instead of staying dispatched when the update throws. Tested: 2 new tests failed before the change; pipeline and recipe suites pass.
A rewritten tuple that is already stamped now ends the stamp failed as tuple_already_stamped and is logged; the run itself may be good. A failed audit write after a dispatch returns the job ids with audit_pending instead of a 500. Tested: 4 new or changed tests failed before the change; pipeline, route and contract suites pass.
Every open stamp the sync visits goes to the back of the line, every outcome that leaves a stamp open for later logs the stamp, dataset and reason, and a run over the queue that throws reports the jobs it already made so the cron logs the partial count. Tested: 4 new tests failed before the change; pipeline suites pass.
dispatchEligible no longer syncs again when the cron has just done so, and the cost comment and ADR state the true bound of a tick (about 510). Tested: new test failed before the change; dispatch and state suites pass.
When a job finishes, a record that names another tuple than its stamp claimed holds the claimed tuple on every path (single dispatch, queue, cron, dry run) with registry_drift; a version bump is never held. The seven-day comparison is gone. The ADR records the remaining exposure of jobs in flight. Tested: 9 new or rewritten tests failed before the change; pipeline, dispatch, queue and route suites pass.
The submit records the image digest on the job row, so a provenance naming another image was refused by the older check. The test now clears the row digest first, so only the recipe check can fail it; with that check mutated away it now fails (it passed before). Tested: verify suite passes (5).
The rewrite test no longer promises an assertion it lacks, the compute-off test now proves the gate comes before the dataset read, and the prose uses canceled. Tested: pipeline and migration suites pass.
A recipe cut by the 10-job tick bound is reported as tick_cap in the result and the log line, not as having nothing eligible. Tested: the bound test and a below-the-bound test pass; the first failed before the change.
@github-actions

github-actions Bot commented Nov 6, 2026 •

Copy link
Copy Markdown

📦 Package Preview

Your package is ready to test!

bun install -g nemar-cli@PR2054

Version: 0.10.28-PR2054.b8cf506
Commit: b8cf506


🤖 Updated on each push.

Platform, cancel and registry failure words no longer count toward the retry cooldown or the failed-attempt cap, so transient errors cannot shut a dataset out. The ADR also says a single-dataset admin dispatch bypasses both. Tested: new test failed before the change and fails with the word list emptied; queue and pipeline suites pass.
The hold does not clear by time. It clears on a registry bump or when its rows are deleted with their dataset; the next mismatch holds the tuple again, bounded by the live cap. Wording only, in the ADR and two comments.
The comment and the ADR gave 5 per stamp; a stamp costs 5 to 9, so the tick is bounded at about 510 usually and 710 at the worst. Wording only.
A rewritten tuple refused by the attempt index (history only) is tuple_attempt_taken; one refused by the live index stays tuple_already_stamped. Neither counts toward the cooldown or the cap. Tested: new test failed before the change and fails with the match removed; pipeline suite passes.
On a dispatched stamp the column is when the sync last looked, since the sync touches every open stamp it visits. Comments in the migration, the contract and the route; no behavior change.
@neuromechanist
neuromechanist merged commit df9e5bd into feature/issue-2005-epic-compute-core Nov 6, 2026
17 of 19 checks passed
@neuromechanist
neuromechanist deleted the feature/issue-2011-phase6-first-party-pipeline-dispatch branch November 6, 2026 03:36

This branch was previously deployed

1 inactive deployment
npm — b8cf506f Deployed Nov 6, 2026 by neuromechanist via publish #4240
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