Repository navigation
feat(runtime): enforce server handler lifetimes - #429
Conversation
Opus reviewReviewed 1.
|
Astra reviewReviewed StandardsNo merge-blocking method or YAGNI findings. SpecIntent blocker: invocation-log writes escape the bounded lifetime#397 requires the host to "settle within the cleanup bound", independently of the caller. In Reproduced with the real Keep pre-dispatch and settlement logging within the absolute lifetime, with bounded failure handling. Action-slot release must not depend on an unbounded attribution write. Preserve fail-closed admission and attribution when making that change. Verification: 55 focused tests passed across nine files, including the real workerd own-table/gateway scenario. The separate Postgres-lock smoke reproduced the blocker. Wire/API docs, migration consumers, attribution UI, and domain documentation were included in the review. Summary: Standards 0 blockers; Spec 1 blocker, invocation-log I/O bypasses the settlement bound. |
|
Reviewed SpecPartial#397's doc list is done for the runtime glossary, ADR-0003, ADR-0012,
The direct-operation gate refuses every op that starts with ScopeNo query snapshots, mutation transactions, metering increments, or tier 2 publish. The rollup tables are the schema #397 and #384 section 16 asked for, and nothing writes them. That is the right cut. WrongA fenced callback never finishes its operation row. const result = yield* Effect.exit(withDeadline);
if (Exit.isFailure(result) && Cause.hasInterrupts(result.cause))
return yield* Effect.failCause(result.cause);
A trusted callback refusal is rethrown as The five done-when cases are tested, and the own-table read runs on supervised workerd through the private listener. Public StandardsHard, from
Judgement:
Intent and method#397's intent is a host-owned lifetime: a callback cannot outlive its authority, and settlement cannot depend on the browser staying open. That is what the code does.
This is the small version of that design. One map, one scope fiber, one private listener.
The server and the dev supervisor do not provide YAGNI
I would leave Spec: 2 wrong, 1 partial doc set. Worst: a fenced callback leaves |
|
Original review fixes landed in 27c9ef6; the invocation-local session-check correction is in aca6661. Read the conversation comments, review bodies and inline comments; the latter two APIs were empty at intake. Opus
Astra
Grok Build
Verification
|
b1e39ba to
3b18121
Compare
Implement #397 with replica-local capabilities, a private callback gateway, detached deadline settlement, and attributed invocation records. Keep tier 2 publishing refused.
aca6661 to
2f85870
Compare
…as since #429 Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…as since #429 Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
… no accounts (#475) Building Patchy Cloud was slower and less trustworthy than it should be, for us and for agents. `pnpm test` took 8 minutes locally and 12.6 in CI, almost all of it one file. Tests were never typechecked, and 256 errors were hiding there. `main` went red twice this week from a flaky fleet test. A fresh clone couldn't start `pnpm dev` without Clerk keys. And an agent had to read a 1,585-line DEVELOPMENT.md before starting anything. This makes the checks fast enough to run constantly and honest enough to believe, puts them behind one command, and lets anyone run the whole loop with no accounts. **Faster** - `cli.test.ts` (732 of the 759 seconds in CI's test job) is split into eight files along its `describe` blocks, so vitest runs them in parallel. - Every vitest run and dev start rebuilt the packed CLI release (~16 s). It is now reused when nothing it reads has changed: every module-graph file, the workspace manifests and the lockfile, plus a check that every output it made is still there. - `pnpm typecheck` compiles each package once, through its build, instead of building and then checking again. **Honest** - `tsconfig.test.json` typechecks every test and harness file, keeping Effect's correctness rules and dropping its style rules. Fixing the 256 errors turned up three real test bugs: the dev-resources handlers ran with `admin` undefined, a RuntimeApi test never sent the header it claimed to check, and an ESLint test hook did nothing. #474 tracks a fourth: typed file-route tests never send the file name. - The fleet flake's cause: the test's clock barrier counted the replenish loop's 5 s sleep as a lease renewal, so under load fake time outran the renewal loop until the lease expired. The barrier now waits for the renewal loop only. Instrumenting it showed two fibers handing out tokens before the fix and one after. - Cold PGlite operation tests and packed `patchy dev` starts get budgets that survive a loaded run. - pnpm 11.28 links skipped optional platform packages (e.g. `lightningcss-darwin-x64`) to the workspace root, and the CLI suites' offline registry was tarring the whole checkout because of it. That failed whenever another suite wrote into the repo mid-archive. The registry now accepts a package only when its name matches. - Migrations come from one record, `apps/server/src/migrations.ts`, for the server, the dev runner and the test template, with a test that ids are unique and gap-free. New tests fail when `docs/API.md` or the global skill's lock hash goes stale. The API.md test already caught #473 leaving it unrendered (same content, new order), so it is re-rendered here. - A `flaky` label, and DEVELOPMENT says to check it before treating a red check as yours. **One command** - `pnpm check` runs format, lint, typecheck and the offline tests. `pnpm verify` adds every acceptance suite CI runs except live Clerk, and `--changed` skips them for docs-only or runner-only changes. These replace `test:all`. - CI now runs the tier 1/2 browser suite as a `browser` job, everything except the one native-print test, which needs a display. The suite had never run in CI, and five problems surfaced, all fixed: - one test had drifted since #429 (Runtime refuses tier 1 `server.call` with `access_denied`); - an online-retry test raced the shell's up-to-30-second backoff. Pinning `Math.random` to the worst case reproduces CI's failure exactly; the test now steps the page clock; - the harness proxy piped streams with `pipe`, so a host that died mid-stream left the browser's stream open and silent forever. A SIGKILL restart reproduces CI's failure. The proxy now uses `pipeline`, which resets the stream as real ingress would; - the harness lost a bind race when another process took its reserved port. It now relaunches on a fresh port; - native printing shared a test with unrelated sandbox and download checks. It has its own `@print` test now, so the rest runs in CI. - The ruleset is unchanged, so `browser` is not a required check. **Local loop** - `pnpm dev` signs people in as dev personas, and `--clerk` opts into Clerk. Existing instances keep Clerk. Plain instances now listen on loopback only. - `pnpm dev shot <person> <path>` writes a full-page PNG of what that person sees, patch frames included, and prints the status and any browser errors. - `pnpm dev up` adopts a running plain instance instead of refusing. **Docs and skills** - DEVELOPMENT.md goes from 99 KB to an 18 KB runbook. Running the server by hand, the execution fleet and the spike deploy move to OPERATIONS.md. The dev-loop skill goes from 18 KB to 3 KB, and README's "Try it" needs no Clerk. - Removed the vendored Clerk skills (billing, orgs, webhooks, custom UI, setup, router) and the general Neon skill. The repo doesn't use what they cover, and their descriptions triggered on common words. | | Before | After | | --- | --- | --- | | `pnpm test`, 16-core machine | 498 s, failed on a timeout | ~185 s, passing | | `pnpm test` step in CI | 758 s | 580–611 s (a 4-core runner is now CPU-bound, not waiting on one file) | | One small test file | 19 s | ~4 s | | `pnpm typecheck` in CI | 122 s, tests unchecked | 101 s, tests included | | `pnpm typecheck`, warm, local | — | 4 s | | `pnpm dev`, cold | needed Clerk keys | 6 s | ## How it was verified - On the final head: - CI is green on every job. - Locally, `pnpm check` passes and `pnpm test:browser` passes 53/53. Two more 53/53 runs were just before the rebase onto Effect 4.0.0. - Earlier on the branch, `pnpm verify` ran every suite. - Fleet: 19/19 tests, plus 15 of 15 runs of the flaky case under parallel load. - Each browser flake was reproduced on the old code before its fix: worst-case jitter, a SIGKILL restart, a blocked port. - By hand: - `pnpm dev` with personas, then `pnpm patchy publish`, with `curl` showing 401 anonymous and 200 as `[email protected]`. - `pnpm dev --clerk` refuses on a personas instance. - `pnpm dev up` adopts the plain instance and keeps its data. - `pnpm dev shot jordan /brightline/new-business` captures the tier 2 board with no errors. ## Release impact - [ ] **Breaking** - [x] **Not breaking**: development tooling, tests and docs. The server only moves its migration record into a module; product behaviour is unchanged. Follow-ups: making `browser` a required check is a ruleset change for you. ## Review GPT 6.1 Sol (codex) reviewed three times. - **First pass:** five real issues, all fixed: - the release cache ignored workspace manifests; - a cache hit accepted missing outputs; - the test tsconfig dropped the base config's Effect correctness rules; - `verify --changed` skipped suites that share the runner's Postgres settings; - the `@print` tag hid unrelated browser checks. - **Second pass:** confirmed all five fixes. - **Third pass:** reviewed the CI-driven fixes and the rebase onto Effect 4.0.0 and found nothing. Made by Claude Opus 5.5 via Claude Code; reviewed by GPT 6.1 Sol via codex. --------- Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
Tier 2 handler calls need a host-owned lifetime so callbacks cannot outlive their authority or depend on an open browser connection.
Runtime now admits
server.callthrough a private, capability-authenticated callback gateway. Deadlines fence and settle work after clients disconnect; unresolved resources are destroyed without claiming a timeout. Invocation records separate the initiating viewer from the effective principal and keep handler diagnostics out of browser replies. Tier 2 publishing remains refused.Stacked on
tier2/396-supervisorand targets that branch. The diff against that base contains only the implementation of #397.Closes #397.
Verification
pnpm test: 1,279 tests passed across 120 files.pnpm typecheckandpnpm lintpassed.Implemented with
openai-codex/gpt-6-astrain the omp harness.