Skip to content

Ingest the observer's nemar.observation.v1 post - #2066

Merged
neuromechanist merged 13 commits into
feature/issue-2005-epic-compute-corefrom
fix/compute-observer-wire
Nov 7, 2026
Merged

neuromechanist merged 13 commits into
feature/issue-2005-epic-compute-corefrom
fix/compute-observer-wire

Conversation

@neuromechanist

Copy link
Copy Markdown
Contributor

What

The compute Worker now takes the real observer's post. Owner decision of 2026-11-06: the Worker adopts the observer's nemar.observation.v1 document and Authorization: Bearer <token>; the observer in nemar-process is not changed.

  • shared/contract/compute-observation.schema.json: the document as a JSON Schema (draft 2020-12, every object the observer writes closed), derived from what observer/observe.py emits. Shared byte for byte with nemar-process (observer/schema/observation-v1.schema.json), the way the launch specification is.
  • shared/contract/compute-observation.ts: the zod mirror, and parseAllocTres, the one reader of Slurm's allocation items (cpu, mem, node, gres/gpu); it fails closed on a value it cannot read.
  • backend/src/services/compute-observation.ts: the document to the stored rows, as a table in the file header. Settlement, tolerance and the mismatch flag are untouched.
  • POST /compute/observer: Authorization: Bearer only; X-Compute-Observer-Token and the {snapshots, sacct} body are gone. Token rules are as before (one-hour per-run HMAC, one uniform 403, 1 MiB, 5,000 rows, never logged).
  • Fixtures test/fixtures/compute-observation/{quick,daily}.v1.json are what the observer itself wrote; nemar-process holds the same bytes.
  • ADR 0118 amendment of 2026-11-06 and the implementation notes.

Mapping

document row
partitions.<name>.jobs.PENDING.jobs / .RUNNING.jobs (0 when the state is absent) compute_queue_snapshots.pending / .running
accounting.jobs[].job_id, partition, state, elapsed_seconds compute_sacct_rows.slurm_job_id, partition, state, elapsed_seconds
alloc_tres: node, cpu, gres/gpu, mem (to MB, rounded up) alloc_nodes, alloc_cpus, alloc_gpus, alloc_mem_mb
submit, start, end submit_time, start_time, end_time
nothing charged_milli = NULL (the rate table prices the allocation)

Refused (400 invalid_post, path and fixed word, run not spent, nothing stored): wrong schema, unknown field at any level, a mode other than quick or daily, more than 5,000 rows, an alloc_tres value that cannot be read (malformed_tres), elapsed time with no cpu item (missing_cpu).
Skipped and counted in skipped: a partition whose queue was not read (jobs null, never stored as zero); a row that is valid but that no table can hold (a pending array id such as 123_[1-5], an unreadable partition, state or elapsed time, a value past a column bound).
Mode: quick and daily are both live; there is no dry run. quick has no accounting.

Tests

From backend/, one file at a time; root for the contract files:

  • bun test test/compute-observer.test.ts: 48 pass
  • bun test test/compute-e2e.test.ts: 3 pass
  • bun test test/compute-switches-flag.test.ts: 39 pass
  • bun test test/compute-route-inventory.test.ts: 5 pass
  • bun test test/oidc-token-allowlist.test.ts: 6 pass
  • root: bun test test/compute-observation-contract.unit.test.ts: 15 pass, 1 skip (the drift tests run with NEMAR_PROCESS_DIR set to the nemar-process branch; the same run with NEMAR_REQUIRE_PROCESS_DRIFT=1), test/contract-schemas.test.ts 63 pass, test/compute-contract.unit.test.ts 454 pass, test/compute-header.unit.test.ts 56 pass
  • bun run typecheck, bun run lint: clean

Mutations, each run and each failing as intended:

  1. parseAllocTres made to guess (lenient integer parse, bare memory read as MB): contract test 1 fail (a value it cannot read is a failure), compute-observer.test.ts fails first at a malformed alloc_tres is refused, settles nothing (later failures in that run are the harness collapsing after a 5 s timeout).
  2. Schema check weakened (schema word any string, top-level objects not strict): contract test 1 fail (Ajv and zod disagree), compute-observer.test.ts 2 fail (a document whose schema is not exactly nemar.observation.v1, a v1 document with a field the observer does not write).
  3. Old header read again: compute-observer.test.ts 1 fail (the token is read from Authorization: Bearer only).

Drift: nemar-process pins this PR's first commit (6e4e8b6b) for the schema and fixtures; after this merges, its pin should move to the squash commit that holds the same files.
Not run: full suites, CI.

@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@PR2066

Version: 0.10.28-PR2066.193dfb1
Commit: 193dfb1


🤖 Updated on each push.

@neuromechanist
neuromechanist merged commit 91945d9 into feature/issue-2005-epic-compute-core Nov 7, 2026
25 checks passed
@neuromechanist
neuromechanist deleted the fix/compute-observer-wire branch November 7, 2026 01:20

This branch was previously deployed

1 inactive deployment
npm — 193dfb10 Deployed Nov 7, 2026 by neuromechanist via publish #4286
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