Skip to content

Phase 3b: re-vendor eegprep-lean 0.1.0.dev2 and watch upstream - #450

Merged
neuromechanist merged 16 commits into
feature/issue-429-epic-browser-executionfrom
feature/issue-424-phase3-wheel-refresh
Sep 23, 2026
Merged

neuromechanist merged 16 commits into
feature/issue-429-epic-browser-executionfrom
feature/issue-424-phase3-wheel-refresh

Conversation

@neuromechanist

Copy link
Copy Markdown
Member

Summary

The second of three OSA pull requests for phase 3. It re-vendors eegprep-lean 0.1.0.dev2, which nemar-cli's next recipe needs, and turns the refresh into a written procedure that a weekly watcher starts and that a daily check against the live recipe proves.

Why now

nemar-cli dev makes nemar_read_window's python_browser recipe lead with read_index(id, index_url=<contract_base>index.json). index_url exists only from eegprep-lean 0.1.0.dev2, and OSA vendored dev1. #449's contract check reports exactly this (read_index takes no keyword 'index_url'). This PR closes that gap before the epic finalizes, which is the condition nemar-cli's ADR 0071 sets.

What ships

eegprep-lean 0.1.0.dev2, reproducibly. Built from sccn/eegprep b4aa18bd (#416) with SOURCE_DATE_EPOCH set to the commit's own timestamp, which makes the wheel byte-reproducible: sha256 39f33b99...7157582, rebuilt independently three times. Its requirements are unchanged from dev1, so depends.toml is unchanged.

sources.toml records where each vendored wheel came from: repository, branch, path, commit and build command for eegprep-lean, and PyPI for zarr. A test fails if a wheel and the file disagree, or if the build command names a different commit.

A weekly watcher. scripts/eegprep_lean_drift.py compares the recorded commit with the newest upstream commit touching the package, never the version string alone, and reports current, behind or unknown. It fails closed: current is returned only after a fetched, matched commit, and any fetch, parse or crash reads as unknown. Run for real, it said behind before the re-vendor and current after. When upstream changes the package without a new version, reviewed_through records that a maintainer read the change and found it leaves the wheel as it is, because a re-vendor needs a new version: a wheel's name is its identity. .github/workflows/eegprep-lean-watch.yml runs it weekly and keeps one labeled issue.

One way to track a scheduled check's issue. .github/actions/track-issue replaces the near-identical open, comment and close steps in widget-route-health.yml and nemar-mcp-contract.yml, and serves the watcher. Each workflow now runs it in a job of its own after the check job, with a sparse checkout of the action, so a check job that fails before its check (checkout included) still opens the issue, and the check job no longer holds issues: write. A cancelled run leaves the issue alone. The watcher's status is read from its own status line, never its exit code, so a crash reads as unknown.

Both recipes, verbatim or transcribed, in the data lane. frontend/test-data-lane.js runs production's v0.10.5 recipe and nemar-cli dev's level-0 recipe, transcribed line for line from its buildHowTo, on the real Pyodide against a loopback index and store. The level-0 recipe's index_url must land on contract_base + index.json, and its physical read must equal digital times scale plus offset. The loopback indexes name nm099900, which nemar-cli declares never resolves.

The live recipe, run daily on CPython. A network test fetches production's python_browser recipe and runs it verbatim in uv run --isolated with nothing installed but the vendored wheel, checking every read's width and dtype, and a physical read's unit. It is part of the daily contract workflow. nemar-cli dev's recipe, run the same way against dev2, reads (129, 500) float64 in µV and the matching int16 counts.

The procedure, written down in src/assistants/nemar/runtime/README.md: owner, signal, the reproducible build, the four proofs in order, and what to do when upstream moved without a new version.

Test plan

  • uv run pytest -m "not network": 2707 passed, 50 skipped. The one failure is test_version_shows_version fails locally and passes in CI, because rich colorizes on a TTY #434. ruff check and ruff format --check are clean.
  • The network tests against production: the contract file's 4, including the CPython run of the live recipe.
  • bun frontend/test-data-lane.js: 57 of 57. test-worker-core.js 108 of 108, test-widget-tools.js 99 of 99, workers/osa-worker/test-routing.js all green, and build-runtime-bundle.js --check current.
  • chrome.js: 40 checks on nemarlike, including eegprep-lean 0.1.0.dev2 loaded by URL with its digest checked and the prelude's transport in place; control fails to boot, as it must.
  • The watcher, run for real against GitHub: behind (dev1 at 67670f5b) before the re-vendor, current after.
  • Mutation-checked: each new guard was loosened in turn and a test failed each time, including the watcher's fail-closed paths, the reviewed-through version check, the runner's dtype and no-read exit, the sources and build-command checks.
  • actionlint is clean on the three workflows. act is not available. A second Sonnet review traced every path through the three workflows (green, check failing, a setup step failing, cancelled, the tracking job's own checkout failing). widget-route-health.yml already exists on the default branch, so it is dispatched on this branch to run the two-job form and the composite action for real; the result is in a comment below.

Reviewed locally by Sonnet agents; how each finding was addressed is in a comment below.

Closes #424.
Part of #432 and epic #429.

Add sources.toml, one table per wheel in runtime/wheels/, and a test that
fails if a wheel has no entry or an entry names no wheel.
sccn/eegprep@b4aa18bd adds read_index's index_url keyword, which
nemar-cli dev's browser recipe now requires. Regenerate the lock overlay
and update the README's provenance table and the generator test's
wheel filename to match.
scripts/eegprep_lean_drift.py compares the commit sources.toml records
against the newest commit on sccn/eegprep's develop branch that touches
packages/eegprep-lean, never by version string alone (it can sit still
across more than one upstream commit). current/behind/unknown, exit
0/1/2; unknown is never reported as current.

Real run against GitHub before this PR's re-vendor: behind, recorded
67670f5b/0.1.0.dev1 vs upstream b4aa18bd/0.1.0.dev2. Against the
now-committed sources.toml: current.
Add nemar_cli dev's level-0 python_browser recipe (buildHowTo's isLevel0
branch, read_index with index_url) to the data lane, filled for the
loopback dataset. Asserts the primary physical read (read_window: shape,
unit, rate, labels, values) and the raw digital-counts read the recipe
keeps as a fallback. Production's recipe (0.10.5, open_array-first) keeps
running unchanged; both pass on the re-vendored dev2 wheel.
Fetch nm000103's live python_browser recipe from mcp.nemar.org and run
it verbatim in a fresh uv --isolated subprocess with only eegprep-lean[zarr]
installed from the vendored wheel file. The runner (scripts/run_python_
browser_recipe.py) compiles with ast.PyCF_ALLOW_TOP_LEVEL_AWAIT, evaluates
to get the coroutine, awaits it, and reports what window/digital bound.

Checked what eegprep-lean's CPython transport sends: UrllibTransport
already sets User-Agent to 'eegprep-lean', never the bare Python-urllib
default the NEMAR hosts refuse, so no workaround was needed. Verified
live: passes in ~10s against production.

Added as its own target in nemar-mcp-contract.yml, split out from the
existing whole-file target so it gets its own pass/fail line.
widget-route-health.yml and nemar-mcp-contract.yml each opened, commented
on and closed a labeled issue near-identically; the weekly eegprep-lean
watcher would be a third copy. Pull the plumbing into
.github/actions/track-issue, taking label/title/failed/report/
recovery_message, still passing text through env rather than
interpolating it into the script.

Behavior preserved: same labels and titles, nemar-mcp-contract.yml still
opens on a setup failure (failure() is disallowed inside a with: value,
so that check now reads job.status == 'failure'), widget-route-health.yml
still opens/closes only when its own probe step ran, recovery still
closes with the same message text. Verified the extracted script logic
with a standalone simulation (create vs comment, close vs no-op).

actionlint is workflow-only and refuses action.yml outright (no jobs:/
on:), so it was run against the two workflow files, not the composite
action. act is not installed on this machine.
Weekly + workflow_dispatch, contents: read / issues: write. Runs
scripts/eegprep_lean_drift.py; behind or unknown opens or updates the
eegprep-lean-drift issue (via .github/actions/track-issue) with the
watcher's report and the refresh procedure's location, current closes
it. unknown is distinguished from behind in the issue body, both by the
bold status line and by an explanatory paragraph.

Verified the shell step locally against the real committed state:
unauthenticated it hit GitHub's anonymous rate limit and correctly
reported unknown (exit 2), never current; with a token (as the workflow
always has via github.token) it reports current (exit 0).
Owner (the OSA maintainer for NEMAR), signal (the drift watcher's
issue), build (from sources.toml's commit, with the reproducible
SOURCE_DATE_EPOCH command), and proof in order: overlay --check,
bun test-data-lane.js, bun browser-harness/chrome.js, then
widget_e2e.py --nemar's recipe and prompt scripts against the live
archive. Only then update sources.toml and the table.
check_drift returned current by default and relied on each failure
path to change it; every return now names its status. reviewed_through
acknowledges an upstream commit that leaves the wheel as it is, since
a re-vendor needs a new version. A test pins the build command to the
recorded commit. Mutation-checked.
if: always() let a cancelled run pass failed=false, which the action
reads as green and closes the issue. The watcher's issue title now
fits unknown as well as behind. actionlint is clean.
The runner described a bare array by its .data, a memoryview with no
dtype. The live test now checks every read's width and dtype, and a
physical read's unit. A tool that answers in text fails with its text.
Ran against production and nemar-cli dev's recipe on dev2.
Loopback indexes used ids in the reserved exemplar band; they now use
nm099900, which nemar-cli declares never resolves. The dev recipe is
labeled as transcribed from buildHowTo, not verbatim.
The composite action loads from the workspace, so a failed checkout in
the check job would also lose the issue. Each workflow now runs the
action in a second job with a sparse checkout, which also gives the
health probe issues on setup failures. The check jobs drop issues:write.
The watcher's status comes from its status line, never its exit code,
and the action refuses a failed value other than true or false.
actionlint is clean; act is not available.
An overlay that is not a JSON object, or any crash inside the check,
is now an unknown report with its reason, never an uncaught exit 1.
Tests cover the human report for each status, GitHub error shapes,
wrapped base64 and the JSON fields. Mutation-checked.
The runner called asyncio.run on None for a recipe with no await, which
the new offline tests found. A recipe that binds neither window nor
digital now exits 3. Mutation-checked.
A structured error answer now fails with its content rather than a
KeyError. The data lane builds its two loopback indexes with one helper.
The live tests pass against production.
@github-actions

Copy link
Copy Markdown
Contributor

Preview Deployment

Name Link
Preview URL https://feature-issue-424-phase3-whe-demo.osc.earth
Branch feature/issue-424-phase3-wheel-refresh
Commit beea689

This preview will be updated automatically when you push new commits.

@neuromechanist

Copy link
Copy Markdown
Member Author

Local review, and what was done with each finding

The lead's pass over the implementer's commits came first, then six Sonnet reviewers (code and workflows, tests, error handling, comments and docs, simplification, and the seams with sccn/eegprep and nemar-cli), then a seventh on the reworked workflows. Every finding is addressed except the two noted.

The lead's pass (4e1cf17..b575dbd)

  • The watcher started at current and relied on each failure path to change it. Every return now names its status.
  • An upstream commit that changes nothing the wheel ships (tests, docs, CI) would have read as behind every week, and no re-vendor could clear it, since a wheel's name is its identity. reviewed_through records that a maintainer read it; a version bump still reads as behind.
  • A cancelled run passed failed=false to the tracking step, which closed the issue.
  • The runner described a bare array by its .data, a memoryview with no dtype, so production's current recipe reported an empty dtype. The live test now checks every read's width and dtype, and a physical read's unit.
  • The loopback indexes used ids in NEMAR's reserved exemplar band. They now use nm099900, which nemar-cli declares never resolves. The dev recipe is labeled as transcribed, not verbatim.

Workflows

  • A failed checkout lost the issue (critical). The composite action loads from the workspace, so a checkout failure in the check job took the tracking step with it. Each workflow now runs the action in a second job with a sparse checkout of .github/actions, which also gives the health probe issues on setup failures, and takes issues: write away from the jobs that run network code. The alternative, a remote @main reference, does not work until the epic releases. a50b0a1
  • The watcher's workflow mapped exit code 1 to behind, and a crash also exits 1. The status is now read from the watcher's own status line, and a missing one is unknown. a50b0a1
  • The composite action silently did nothing for a failed value other than true or false. It now fails. a50b0a1
  • Verified for real: widget-route-health.yml exists on the default branch, so it was dispatched on this branch. Run 35816520464: the probe job ran without a checkout, the tracking job checked out the action sparsely and ran it, and both were green.

Error handling

  • An overlay whose top level is not an object raised an uncaught AttributeError. It is now unknown, and main reports any crash as unknown with its reason. b16984a
  • A recipe that binds neither window nor digital now exits 3 from the runner. 27f72f5
  • A live answer that is an error object fails with its content rather than a KeyError. eee5e2a

Tests

  • The human report, the text that lands in the issue, had no test: deleting it left every test green. Each status is now tested, including the guidance when the version did not move. b16984a
  • GitHub's error shapes (rate-limited 403, 500, an object, an empty list, a non-string or missing sha), base64 wrapped as GitHub sends it, and the JSON fields for each status. b16984a
  • The runner had no offline test. Five now run in-process, and they found a real bug: a recipe with no await made the runner call asyncio.run(None). 27f72f5
  • Each new guard was mutation-checked; each mutation failed a test.

Comments, seams, simplification

  • A test cited .rules/testing.md for the HTTP-boundary rule, which lives in .rules/testing_guidelines.md. b16984a
  • The data lane's two index documents share one builder. eee5e2a
  • Verified, no change: the wheel rebuilds to the identical sha256 from the recorded commit and command; both recipe transcriptions match nemar-cli v0.10.5 and origin/dev line for line; the overlay's dependencies resolve in Pyodide 0.29.5's lock; recipe_problems reports nothing for nemar-cli dev's recipe on dev2.
  • Not taken, deliberately: one helper for the watcher's two GitHub fetches. Each failure message names its own fetch, and those messages are what the issue shows.
  • Not taken: render_human and render_machine as one. The issue shows the first, and the workflow parses the second.

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