Skip to content

Phase 2: progress contract, plugin manifest and progress table - #2330

Merged
neuromechanist merged 24 commits into
feature/issue-2324-epic-pipeline-progressfrom
feature/issue-2325-progress-contract
Nov 23, 2026
Merged

neuromechanist merged 24 commits into
feature/issue-2324-epic-pipeline-progressfrom
feature/issue-2325-progress-contract

Conversation

@neuromechanist

@neuromechanist neuromechanist commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Phase 2 of ADR 0134: live progress of NEMAR's pipeline runs, the plugin manifest contract, and the tables that hold progress and the neuroschema documents built from it.

  • neuroschema 0.5.0 vendored with a record root (roots: {dataset, record}) and validation of any bundled schema by its nsc:/ id; NEUROSCHEMA_VERSION is 0.5.0. The live schema_version checks also accept 0.4.x until the backend serving 0.5.0 is deployed (NEUROSCHEMA_TRANSITION_LINES; empty it after the deploy).
  • nemar.progress.v1 (shared/contract/compute-progress.ts and .schema.json): closed, counts per checkpoint in the shape of neuroschema checkpointCounts, at most 10 failures, at most 8192 bytes. The heartbeat request gains an optional progress (the runner schema refers to the progress schema by $id).
  • nemar.plugin-manifest.v1 (shared/contract/plugin-manifest.ts and .schema.json): closed; a declared metric plus a value and the plugin is a valid neuroschema qualityMetric; a time-series figure is PNG or WebP only.
  • The recipe registry declares each recipe version's step-to-checkpoint map (nemar-floor, nemar-ica), with declaredCheckpoints, checkpointOfStep, recipeCheckpointMap.
  • shared/compute-checkpoints.ts: the counting rules (table reader, per-recording outcomes, counts, failures), progressProblem, liveDisagrees, pipelineRunStatus (stalled worked out on read), and the builders of the processing and signalJourney entries. shared/contract/compute-progress-vectors.json holds vectors nemar-process replays in Phase 3.
  • Migration 0150: compute_pipeline_progress_runs, compute_pipeline_progress, compute_pipeline_documents.
  • POST /compute/jobs/:id/progress (job token, no session) for NEMAR pipeline jobs on Tapis; the runner heartbeat stores progress after the lease renewal, never at its cost. Both go through one guarded batch (recordProgress): the first statement holds the job state, the rate floor and not-yet-reconciled; every later statement is gated on its random write_id.
  • New refusal word report_too_soon (429, Retry-After: 60); report_too_soon and storage_unavailable are now route sentences (the latter declared once, the submit table inherits it).
  • Reconciliation rides syncPipelineStamps (reconcilePipelineProgress, 10 runs and 10 stored rows per call): counts from the uploaded recordings table, disagreement with the live counts recorded, stored resolved from the derivative store, processing and signalJourney documents written. SyncResult gains reconciled, reconcile_later, reconcile_errored.
  • /<id>/metadata.json serves the final dataset-level extensions.processing and extensions.signalJourney entries, and an in_progress link worked out on read for a reporting run, behind the existing public gate and never for a concealed deposit.
  • Dataset deletion removes the progress rows, run rows and documents.
  • ADR 0134: the Consequences line now says one 0.5.0 minor release; decision 4 notes that stalled is derived on read and reconciliation rides the stamp sync.

No compute switch is added or changed; no cron is added.

Owner answers (2026-11-22)

  • The Tapis route accepts NEMAR pipeline jobs in submitted, queued, running; refuses archiving, unreported, terminal and tenant jobs; 429 report_too_soon with a 50 s floor against the 60 s launcher cadence.
  • Checkpoint maps attach to the registry entry's version. The registry/image version alignment landed separately (Align recipe registry versions with the images #2329, merged into the epic branch here): the registry now says 1.0.0-b1, and the vectors were regenerated with NEMAR_WRITE_PROGRESS_VECTORS=1.
  • The dataset-level processing and signalJourney entries are served now in /<id>/metadata.json under extensions, through that route's existing access rules. Record-level documents stay deferred. stored is resolved from the derivative store.
  • Live line transition, plugin caps (1 MiB per figure, 64 KiB manifest, 64 metrics, 32 figures), counting edge cases (unknown step fails at the first checkpoint; missing rows of a killed run are skipped not_run), failure entries carry their checkpoint, ASCII paths up to 256, at most 10 failures, unreported shows as stalled: as recommended.

Closes #2325
Part of epic #2324

Test plan

  • bun run typecheck, bun run lint, Biome on every touched file (43 files, clean)
  • bun run migrations:d1-check: all migrations applied on real D1, catalog matches bun:sqlite
  • Vendor script reproducible: re-running it on neuroschema 98f2b0c8 leaves the bundle unchanged
  • Pure contract tests (13 files incl. progress, plugin manifest, checkpoints, runner, recipes, neuroschema, schemas, state, ADR index): 918 pass, 0 fail
  • Backend: migration 0150 on bun:sqlite and Miniflare D1, the progress route, runner heartbeat progress, reconciliation, metadata.json extensions, route inventory, job callbacks, runner jobs, switches flag, cron wiring: 450 pass, 0 fail
  • Regressions: runner queue (98 pass), pipeline, dispatch, derivatives, pipeline input and queue (250 pass), deletion-related suites (255 pass)
  • Mutations checked by hand: dropping the rate floor fails the heartbeat floor test; dropping reconciled_at IS NULL from the gate fails the reconciled-run test; dropping the stamp order on documents fails the older-stamp test; dropping the concealed-deposit check fails its test
  • Not run, would check: the full bun test (epic to dev gate)
  • Not run, would check: test/contract-live.test.ts and test/data-route.test.ts against the deployed dev backend, which serves 0.4.1 until this deploys (the transition line keeps them green)

Follow-ups

  • Empty NEUROSCHEMA_TRANSITION_LINES once the backend serving 0.5.0 is deployed.
  • /<id>/page-bundle.json builds the same metadata with its own read and does not yet carry the pipeline extensions: page-bundle.json does not carry the pipeline extensions #2331.
  • Phase 3 (nemar-process): copy compute-progress.schema.json, plugin-manifest.schema.json and the vectors; validate progress before attaching it to a heartbeat and retry without it on invalid_body.

Review round 1

Merged origin/feature/issue-2324-epic-pipeline-progress (with #2329) into this branch; no rebase.

  • C1: the job index of compute_pipeline_progress_runs is not unique; RECONCILE_CANDIDATES_SQL skips a tuple_mismatch hold stamp whose job belongs to another stamp (HOLD_STAMP_WORD, held equal to TUPLE_MISMATCH_WORD); stampForJob reads only the dispatched stamp. Test: a tuple-mismatch sync ends with reconcile_errored 0, the hold stamp has no run row, and the run behind it is reconciled.
  • I1 (decided): compute_pipeline_documents holds only final entries (no final column); /<id>/metadata.json works out in_progress from a dispatched stamp and its unreconciled run row (liveSignalJourneyLinks). Every outcome writes a final result: completed link when buildable, a final failed link for a failed stamp and for every outcome without counts, and a succeeded run whose link cannot be built keeps the previous final link (link_not_written reason=record_unlinkable). Tests: both reviewer repro cases, and "a new run's live report does not erase the last completed link".
  • I2: the run row records recipe_version and declared at reconcile; resolveStored resolves from them, each item in its own try/catch; a row that cannot make an entry is resolved without a document (processing_not_written reason=<word>); processingDatasetEntry returns null on a missing column. Tests: stamp version moved after reconcile, a missing middle row, limit 1 with a bad row ahead of a good one.
  • I3: pipelineRunStatus takes PipelineStampState and ComputeState; stalled only for submitted, queued, running (and unreported); archiving is running; a terminal job on a dispatched stamp is finished or failed; PIPELINE_STALLED_SQL gains the stamp-state precondition. Table tests both sides.
  • I4 (decided): the step record counts against the last declared checkpoint (RECORD_STEP); step-less faults keep the first-checkpoint rule; vectors gain record rows.
  • I5: pipelineDispatchLogLine reports synced_reconcile_later and synced_reconcile_errored (errored is level error); reconcile_later stamp=<id> reason=results_unbound|read_failed; the skipped failed-run processing entry is logged; reconciled counts only when the gate's meta.changes is 1 (race test).
  • I6: the phase test sets a pending cancel so the job stays running and the phase is the only difference; the cap test sends schema-valid bodies padded inside progress to exactly 16,384 bytes (accepted) and 16,385 (refused).
  • I7: the recipes test is version-agnostic; after Align recipe registry versions with the images #2329 the vectors are regenerated and the no_checkpoint_map caveat is gone.
  • M1: direct recordProgress tests: a Tapis job moved to archiving or finished after stampForJob, another lease, another runner, and a deleted stamp each give bad_state and zero rows; the reconcile gate wins once; a stale write id writes no document.
  • M2: stored branch tests for a stored, failed, and expired derivative with and without stored_at.
  • M3: a D1 fault reading the stamp answers 503 storage_unavailable with progress_stamp_read_failed (test renames the stamps table away and back).
  • M4: COST comment about 80 more, about 590 usual and 790 worst.
  • M5: the report gate also requires the stamp dispatched and naming the job.
  • M6: parseRecordingsTable refuses more than PROGRESS_MAX_RECORDINGS rows (too_many_rows, so table_unreadable).
  • M7: resolving stored claims the run row with a write id; the stored update and the document are gated on it.
  • S1: the schema says live counts count only recordings with a table row; vector floor_live_partial.
  • S2: PROGRESS_MAX_BYTES is stated as compact UTF-8 JSON; the largest-object test uses a 256-character path of " (8,142 bytes).
  • S3: the plugin manifest says a declared metric without headline plus value and plugin is a qualityMetric, and where headline lives.
  • S4: plugin manifest string caps count code points in zod too; astral-character cases in the corpus.
  • S5: RecipeCheckpoint.checkpoint is DeclarableCheckpoint; TableRead.reason is TableReadProblem.
  • S6: "Behavior"; test/compute-recipes-process-drift.unit.test.ts also compares each checkpoint map with nemar-process STEP_ORDER (floor, then floor plus ica).
  • S7: page-bundle.json does not carry the pipeline extensions #2331.

Mutation evidence (each reverted): dropping the hold exclusion, the job-state term, the lease term, the stamp term, the document write-id guard or the stamp order each fail their test; counting reconciled without the gate's change fails the race test; reading the stamp's version instead of the recorded one fails the I2 test; accepting progress in any phase fails the phase test; an 8 KiB or a 32 KiB heartbeat cap each fail the cap test; a changed STEP_ORDER copy fails the drift test.

Gates on 5ce7177: typecheck, lint, Biome on all 43 touched files, migrations:d1-check; pure tests 941 pass (with the drift test against nemar-process dev and NEMAR_REQUIRE_PROCESS_RECIPES=1); backend 756 pass (migration, route, runner progress, reconcile, metadata, inventory, callbacks, runner jobs, switches, cron wiring, pipeline, dispatch, derivatives, runner queue). Not run, would check: the full bun test (epic to dev).

Review round 2

  • I1 (decided): an outcome without counts writes the failed link only for a failed stamp. A succeeded stamp of a known recipe gets the completed link built from its record (no checkpoint map needed); a record that cannot make one, or a recipe the registry no longer knows, leaves the last final link standing (link_not_written reason=record_unlinkable|recipe_unknown). One finalLinkStatement serves both paths; docblocks and the test header corrected. Tests: the hold-stamp case serves completed (version 9.0.0) for the succeeded stamp; a succeeded no_checkpoint_map run replaces the last completed link with its own completed link; a succeeded run of an unknown recipe leaves the last link standing.
  • S1: LIVE_LINKS_SQL keeps s.state = 'dispatched', now pinned: an ended stamp whose run reported and was never reconciled serves no in_progress.
  • S2: two resolvers racing for one stored row resolve it once and write its entry; a resolved row can no longer be claimed (STORED_CLAIM_SQL changes 0).
  • S3 (decided): LIVE_LINKS_SQL joins compute_jobs and requires submitted, queued, running or archiving (LIVE_LINK_JOB_STATES); test: submitted and archiving are live, finished, cancelled and unreported are not.

Mutation evidence (each reverted): writing failed for every outcome fails the no-checkpoint-map test; dropping the dispatched term fails the S1 test; dropping the job term fails the S3 test; dropping the claim's pending guard fails the S2 claim test.

Gates on 5cfa3f8: typecheck, lint, Biome on the touched files; reconcile, metadata, route, runner progress, pipeline, dispatch, migration and checkpoint tests pass (232). Not run, would check: the full bun test (epic to dev).

@github-actions

github-actions Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

📦 Package Preview

Your package is ready to test!

bun install -g nemar-cli@PR2330

Version: 0.10.40-PR2330.6d191fb
Commit: 6d191fb


🤖 Updated on each push.

@neuromechanist

Copy link
Copy Markdown
Contributor Author

Review converged: round 1 by a three-reviewer panel (code+types, tests+errors+comments, Opus xhigh on the route, write path, migration and metadata.json access), round 2 Opus xhigh delta; every finding fixed or decided, final fix verified by the driver (5cfa3f8, 6d191fb). The diff-caused CI failures (schema_version expectations, the compute-switch reader rule, metadata snapshots) are fixed in 6d191fb. The remaining red is unit-pure shard 1, which fails on Miniflare D1 itself (a hang to timeout, then a migration assertion in an unnamed hook on rerun), also seen on dev; filed as #2332. Merging into the epic branch per the phase-to-epic gate (targeted tests pass); full green CI is required at epic to dev.

@neuromechanist
neuromechanist merged commit 3d17fab into feature/issue-2324-epic-pipeline-progress Nov 23, 2026
49 of 53 checks passed
@neuromechanist
neuromechanist deleted the feature/issue-2325-progress-contract branch November 23, 2026 07:17

This branch was previously deployed

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