Skip to content

Phase E3: Compute job page - #507

Merged
neuromechanist merged 17 commits into
feature/issue-493-epic-compute-webfrom
feature/issue-496-compute-job-page
Nov 7, 2026
Merged

neuromechanist merged 17 commits into
feature/issue-493-epic-compute-webfrom
feature/issue-496-compute-job-page

Conversation

@neuromechanist

@neuromechanist neuromechanist commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

Phase E3 of epic #493: the compute job page /compute/jobs/<id>. Implements #496 from the approved plan (#496 (comment)) and the driver's answers to its eight questions. Base is the epic branch; do not merge here.

What it does

  • A job's state on a timeline that claims only what the record carries (created, started, ended; "not known" for a stage the record cannot vouch for), resources and charge (three decimals, the CLI's digits, shared chargeText with the table), one plain sentence per failure code (17), the log on request, result links on request with renew and cursor paging, and a cancel for a live job through the shared ConfirmDialog.
  • Live refresh: 10 s, doubling to 60 s while nothing changes, pause in a hidden tab with one immediate read on return, stop at an ended or unknown state, five errors stop it, two-hour stop with Resume. The schedule is pure (nextPoll, injected clock).
  • Log: inert text; ANSI stripped, everything else through displaySafeBody so hostile characters are written out; lines capped at 2,000 characters; last 200 lines with "Show earlier lines"; a log cut at 1 MiB says so and points at nemar compute logs.
  • Results: viewing mints nothing and the server HTML carries no link; only the buttons mint. Links only through safeResultHref, rel="noopener noreferrer", never stored, logged or copied; the list clears on a bfcache restore and when the links expire.
  • One 404 for an absent, foreign or malformed id; Cache-Control: private, no-store and Referrer-Policy: no-referrer before any return; /compute added to routeBypassesEdgeCache; the proxy forwards X-Nemar-Truncated (its constant has one reader, a scan asserts it).
  • The mail link form /compute/jobs/<id> is this route; no mismatch.

Backend gaps filed (nemar-cli, generic wording)

nemar-cli#2094 log tail (the route serves the FIRST 1 MiB; the issue text assumed ?tail=), #2095 result links as attachments, #2096 server-stated results expiry, #2097 per-stage times. Existing: #2079 (job name; the guard reads an optional name).

Where the backend differs from the issue (the backend won; quoted from caf3a77a, 27eecff9)

The job read is GET /compute/me/jobs/:id answering { job, stale }; 17 failure codes, not 8; no tail on the log; no job name; three times only; the cancel route refuses nothing by state (an ended job answers 200 already_ended, cancelled: false), so canCancel is the page's own choice; the links field is files; no route serves the submitted record or manifest, so the 410 copy says only what the page keeps (state, resources, charge, log).

Deviations from the plan

  • An unterminated escape sequence is NOT dropped (the plan said it would be): it is written out with the text after it, so a program cannot hide the rest of its log behind one.
  • Result paging is one backend page at a time ("Get the next links" replaces the list, "Back to the first links"), not appended, so Renew always renews the page shown.
  • The second cancel of a job whose cluster could not be reached answers cancel_requested again, not already_cancelled (captured); the words follow the data.
  • compute-job-live.ts is the clock exception; the page frontmatter reads the clock through its nowMs (so the one-clock rule holds).
  • The local seed gives the job page its own account localjobs (the concurrency limit left no room on localrich) and runs the backend as ENVIRONMENT=development because compute only runs in production or development.
  • The results notice is required by the guard (a missing one is a shape error) so it is never retyped on the site.

Fixtures

Step 0 passed: the backend's lifecycle fixture runs outside bun test. scripts/capture-compute-job-fixtures.mjs (command in compute-api-job.test.ts's header) writes nine files from the real router: the ten states, 17 failure codes, a recorded cancel, a stale read, a lifecycle job at running and finished, logs (live, ended, empty, hostile, over 1 MiB headers only, none yet), results (get, renew, second page, bad state, expired 410, failed), cancel outcomes (including with the cluster down) and the refusals. Lifecycle files carry fresh ids and signatures on every run; the first page of 1,000 links is summarized, not stored.

Gates

  • bun run lint, bun run typecheck (0 errors), bun run build (passes; public/og-image.png reverted).
  • bun run test with the drift variables pointed at the Epic D worktree (27eecff9): 192 files passed, 3 skipped, 5263 tests passed. New: compute-job-view, compute-logs, compute-failure, compute-api-job, api-proxy-compute-log, compute-job-ui, compute-job-contract-drift, middleware and safeRedirectPath cases.
  • Mutation checks, each caught: terminal keeps polling (2 fail), > to >= at the retention boundary (1), cancel offered with a cancel recorded (2), non-https result link (2), hidden tab does not pause (1), ANSI not stripped (5), proxy header dropped (1).
  • Known red in CI until the compute epic reaches nemar-cli dev: the drift tests (new NEMAR_CLI_COMPUTE_SUBMIT_CONTRACT and _RESPONSES_CONTRACT variables and sparse-checkout paths added to ci.yml).

Browser check (real Chrome, real local backend with --seed-compute --seed-compute-jobs)

Run: finished job (log, Get links, download list, Renew gives new links, no link in the source, storage, URL or console; a minted link fetched with curl returns the file); the watch job went running to finished in place with the aria-live text, results and retention line appeared, polling stopped (no requests afterwards); polling on a running job at about 7, 19, 42 s (10, 20, 40 s backoff with jitter); hidden tab simulated with document.hidden and visibilitychange: no request for 80 s, one immediately on return; cancel from the dialog with a double click on confirm sent one POST, badge to Canceled, status line focused; cancel from a stale tab (job already canceled elsewhere) says "The job was canceled."; hostile log (escapes visible, nothing executed, 5,000-character line capped); log over 1 MiB (truncated note, "last 200 of 33,116 lines of the first 1 MiB", earlier lines add 1,000); 1,002 outputs (100 rows, 9 x "Show 100 more" to 1,000, next page, Renew of the page shown, back to the first); expiring (2 days left) and expired (real 410 copy, button gone); foreign, absent and malformed ids answer the same 404 page; page headers; signed-out 302 to login with next; light and dark; 360 px in an iframe (no horizontal scroll, stacked rows).

Not run or not verifiable: a real click on a result anchor opening a new tab (the tab did not appear in the tool's group; the link's bytes were verified with curl and the anchor's rel, target and referrerpolicy inspected); a truly hidden tab (simulated); keyboard-only run and focus order, prefers-reduced-motion live (no animation in any job style by a scan), a real screen reader; a stale: true page and a 5xx live (fixture and unit tests only); Escape in the dialog; the deployed build. Dev-server finding: bun run dev (Vite) 500s a URL ending in .txt (a results cursor that is a path ending in .txt); dev-only (a deployed build was checked), no code change; the seed uses .dat.

Review round (security review: no Critical; all findings fixed)

  • I1: the job read has a 12 s deadline and the cancel 20 s (named constants; the log keeps 30 s), with tests that spy on AbortSignal.timeout for each and a mutation (job read back on the 5 s default) that fails them.
  • I2 and I3: the held result links are now a pure state machine, compute-job-results-state.ts, rendered by one renderResults(); the "Get download links" button is derived from the job, not from what was shown last, so a back-forward-cache restore brings it back. 13 behavioral tests (rows dropped after expires_at, restore drops every link and status and returns the button, 410 never returns it); mutating handlePageshow, expireIfDue and the button rule to no-ops, and keeping the rows after expiry, each fails tests. No DOM harness was added: the pageshow listener is only a one-line call into the tested function, pinned by a source scan.
  • Minors: plain-http result links only when the page itself is on a loopback host (allowLoopback); logs write out LRM, RLM and ALM (an escapeMarks option of displaySafeBody, mail unchanged); the first poll no longer counts as a change (10, 20, 40, 60: the SSR record seeds state, cancel flag, charge and stale); result anchors carry the file path as visually hidden text and the <ul> lost role="region"; a partner job's bad_state reads like its log ("appear once NEMAR has checked the job"); Refresh and Resume go through the poller's one-in-flight rule (restartNow), show "Refreshing", and on failure stop the poller and say "Could not refresh just now. Try again."; the source scan bans window.open, location.assign and replace, sendBeacon and friends, and its comment stripper no longer takes a // inside a string, template or pattern for a comment (tested); role=status regions are filled one tick after they are un-hidden.
  • Re-run: lint, typecheck (0 errors), full vitest with the drift variables (193 files passed, 3 skipped, 5289 tests passed), build (og-image reverted). Browser, against the real local backend: a simulated pageshow with persisted: true after Get links (list gone, panel hidden, button back, no link in the DOM, Get links works again); a cancel that takes 7 s (longer than the old 5 s deadline) ends in "The job was canceled."; a forced 2-hour clock jump shows "Updates paused." with Resume, a failed Resume shows "Refreshing" then the failure sentence with the button usable, a successful one clears it.
  • Not changed: nothing disputed. One note: the pageshow listener, clearResults successor and the expiry timing are tested through the pure functions and the browser, not through a DOM test.

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Nov 7, 2026 •

Copy link
Copy Markdown

Deploying nemar-website with  Cloudflare Pages  Cloudflare Pages

Latest commit: bc998d7
Status:⚡️  Build in progress...

View logs

@neuromechanist
neuromechanist force-pushed the feature/issue-496-compute-job-page branch from 18360f2 to bc998d7 Compare November 7, 2026 17:21
@neuromechanist
neuromechanist merged commit 41299d4 into feature/issue-493-epic-compute-web Nov 7, 2026
2 of 3 checks passed
@neuromechanist
neuromechanist deleted the feature/issue-496-compute-job-page branch November 7, 2026 17:22
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