Skip to content

Phase B3: admin quality API (#2324) - #2386

Merged
neuromechanist merged 8 commits into
feature/issue-2324-epic-pipeline-progressfrom
feature/issue-2324-b3-admin-quality
Nov 26, 2026
Merged

neuromechanist merged 8 commits into
feature/issue-2324-epic-pipeline-progressfrom
feature/issue-2324-b3-admin-quality

Conversation

@neuromechanist

@neuromechanist neuromechanist commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Phase B3 of #2324 (ADR 0137 decision 7): the admin quality API. Refs #2384.

What changed

  • GET /admin/compute/pipeline/runs/:stamp/quality (routes/admin/compute-pipeline.ts, services/quality-admin.ts), behind the admin router's authentication, admin and cookie-origin middleware. Every answer, refusals included, is Cache-Control: no-store.
  • One D1 statement (RUN_QUALITY_SQL, by index) reads the stamp, its derivative row, the skip log's word and whether the row is the current public derivative (B1's CURRENT_PUBLIC_DERIVATIVE_SQL).
  • The derivative's standing is one word of COMPUTE_RUN_QUALITY_STATES: run_in_progress (a dispatched stamp), run_not_succeeded, not_keyed (with skip), awaiting_derivative, failed, expired, copying, canary, current, superseded, not_current. A canary past its date is expired before the sync marks it (the missing-canary case), and no state is a 500. The answer also carries retention, stored_at, expires_at, superseded_at, failure and serving_index, and dataset_public: whether the dataset passes QUALITY_DATASET_GATE_SQL now. A current row is the row public pages read only while the dataset is public; W9 needs this. not_keyed with duplicate_key means an earlier run with the same inputs holds the derivative.
  • The succeeded recordings, 100 a page in code-unit path order with next_after, from the recordings table stored under the derivative's key. The table is read only when the files stand (stored, not past date). The read is bounded at TABLE_READ_MAX_BYTES, the bound reconciliation uses; a larger body is never read. The table is parsed by parseRecordingsTable, and the sorted list is kept in the edge cache under the derivative key. A later page costs one D1 statement and one cache match, with no store read. The cache is consulted only after D1 says the files stand. A succeeded path the quality route would refuse, and every repeat of a duplicate path, is left out and counted as unlisted. An oversize table's body is cancelled, not read.
  • The cursor after must be a recording path: the quality route's relativeLocation pattern and a recording name. Anything else, a repeated key or an unknown key is invalid_query, and the cursor is never echoed. A well-formed cursor the list does not hold pages from where it would sort.
  • Words, page size and response schema in shared/contract/compute-admin.ts. The lists are literals for the website's drift tests, and the contract test covers them. The website drift tests pin COMPUTE_RUN_QUALITY_STATES, so W9 must take the new run_in_progress word.
  • nemar admin compute pipeline quality <stamp-id> [--after <path>] [--json], plus getComputeRunQuality in src/lib/api/compute.ts.
  • Route inventory (274 entries), API export pin and CHANGELOG.

No migration. None of B2b's files (dispatch, launch spec, derivative keying) are touched.

Tests

  • backend/test/quality-admin-route.test.ts (26 tests) runs on the real admin router, real migrations, real hashed API keys and Miniflare R2. It covers:
    • no key, a member's key and a revoked admin key;
    • every state word, including a dispatched stamp;
    • dataset_public: each term of the gate turns it false and a missing dataset row is false. The concealed case also clears first_published_at, because a trigger forbids a published anonymous dataset; the anonymity term itself is covered by B2's gate tests;
    • an empty page, exact multiples of 100, 101 and 250;
    • a cursor past the end, a cursor between paths, and forged cursors;
    • an oversize table: one get, body never read;
    • a missing table, an unparseable table and a non-UTF-8 table;
    • an unbound store and a throwing store;
    • one read per key with a cache, the expired-after-cache case, and the query plan.
  • test/admin-compute-pipeline-cli.test.ts: three new CLI tests run against the real routes. An empty or overlong cursor (over QUALITY_RECORDING_PATH_MAX) is never sent.
  • Gates: bun run typecheck passes. bun run lint passes, and Biome is clean on the changed files. Targeted root suites pass: compute-admin-contract, admin-route-inventory, api-export-surface and admin-compute-pipeline-cli, 149 tests. Targeted backend suites pass: quality-admin-route, quality-route, quality-documents, compute-pipeline-grid, oidc-token-allowlist, admin-nonadmin-sweep and admin-origin-guard, 150 tests. The full bun test was not run (epic gate).

Mutation run (28 of 28 killed)

Mutation Result
G1 no admin middleware killed
G2 member passes the role check killed
G3 revoked key accepted killed
G4 answers not no-store killed
S1 expired before failed killed
S2 no expired word killed
S3 date not read (marked rows only) killed
S4 no canary word killed
S5 superseded without its date killed
S6 current not judged killed
S7 skip word ignored killed
S8 copying table read killed
S9 stamp state ignored killed
S10 dispatched read as not succeeded killed
D1 dataset_public not gated killed
D2 dataset_public true for a missing dataset row killed
C7 CLI sends an overlong cursor killed
C1 cursor's own path repeated killed
C2 cursor shape not checked killed
C3 a full page always says more killed
C4 a repeated cursor read as its first killed
C5 page one longer killed
C6 CLI sends an empty cursor killed
B1 stated size not checked (the body is read) killed
B2 no bound at all killed
B3 nothing cached killed
B4 cache key without the derivative key killed
B5 table read whatever the row's state killed

Notes for review

  • The edge-cache entry is the parsed table under a synthetic /__quality-admin-cache/ key, never an answer. ADR 0137's "administrator responses are not cached" holds: every answer is no-store.
  • A duplicate_key stamp answers not_keyed and does not point at the first stamp's derivative, because the statement cannot recompute the key.
  • W9 needs the admin mount of the record and file endpoints (Quality views: private and admin route mounts #2384): the public route refuses canary rows, and canary is what the drill-down shows.

Next: B3b

Lead ruling: a separate phase after this PR merges, covering only the admin half of #2384. It must meet the reviewer's security points (a) to (f), as relayed by the lead:

(a) a strict rest pattern and pinned GET in W9's proxy, (b) the admin role checked on the caller's own credential, (c) stored and in-date rows only, (d) no write to B2's edge cache (pinned by a mutation), (e) B2's record and file checks kept, and (f) no anonymous-deposit leak.

Agentic AI tools were used.

@github-actions

github-actions Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

📦 Package Preview

Your package is ready to test!

bun install -g nemar-cli@PR2386

Version: 0.10.40-PR2386.12a2754
Commit: 12a2754


🤖 Updated on each push.

@neuromechanist
neuromechanist merged commit 2266dc8 into feature/issue-2324-epic-pipeline-progress Nov 26, 2026
47 of 53 checks passed
@neuromechanist
neuromechanist deleted the feature/issue-2324-b3-admin-quality branch November 26, 2026 01:52

This branch was previously deployed

1 inactive deployment
npm — 12a27544 Deployed Nov 26, 2026 by neuromechanist via publish #4930
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