Skip to content

test(runtime): add the #3259 flake canary (nested writes stay green at the stock 250ms CPU budget under load)#3351

Merged
os-zhuang merged 1 commit into
mainfrom
claude/nested-write-flake-canary
Jul 20, 2026
Merged

test(runtime): add the #3259 flake canary (nested writes stay green at the stock 250ms CPU budget under load)#3351
os-zhuang merged 1 commit into
mainfrom
claude/nested-write-flake-canary

Conversation

@os-zhuang

Copy link
Copy Markdown
Contributor

The verification flake canary from the ADR-0102 plan (#3275) — the last item on that issue's checklist. #3275 is now closed; this ships the canary as a small test-only follow-up.

What it does

Drives the real nested-write scenario (child afterInsert → nested parent.update → the parent's own hook = a second re-entrant sandbox VM) across 128 chains concurrently through one shared stock QuickJSScriptRunner (250ms CPU budget), and asserts every invocation lands the correct rollup with zero CPU-budget / wall-ceiling errors.

Why it matters (ADR-0102 D1)

#3259 was a load flake, not a logic bug: under the old wall-clock budget, the time an invocation spent parked at an await while other concurrent invocations ran was charged to it, so it blew 250ms under oversubscription even though its own VM did microseconds of work. D1 made the budget script CPU-time, so parked time isn't counted — this canary is the end-to-end proof that the fix holds under concurrency.

It's a real gate, and it's robust

Validated in both directions during development:

  • Reverting the interrupt handler to a Date.now() - start wall budget turns this suite RED from ~64 concurrent chains up → it genuinely catches a D1 regression.
  • The shipped CPU budget stays green through 256 chains → no false positives.

It can't flake on its own because concurrency stresses the parked-time accounting D1 excludes, not slice size: the charged CPU per tiny rollup body is invariant to how many chains are in flight (JS runs each synchronous slice to completion, so concurrent chains interleave only between slices, at await points). OS_CANARY_CONCURRENCY overrides the default for an ad-hoc heavier soak.

Notes

  • Test-only, no changeset.
  • allow-major bypasses the unrelated pre-existing @objectstack/console: major changeset already on main.

🤖 Generated with Claude Code

https://claude.ai/code/session_011iJLjqToxNv1aYP3syQtRp


Generated by Claude Code

…at the stock 250ms CPU budget under load

The verification "flake canary" from the ADR-0102 plan (#3275). It drives the
real nested-write scenario (child afterInsert -> nested parent.update -> the
parent's own hook = a second re-entrant VM) across 128 chains CONCURRENTLY
through one shared stock runner, and asserts every invocation lands the correct
rollup with zero CPU-budget / wall-ceiling errors at the stock 250ms budget.

Closes the loop on ADR-0102 D1. #3259 was a LOAD flake: under the old
wall-clock budget, the time an invocation spent parked at an `await` while other
concurrent invocations ran was charged to it, so it blew 250ms under
oversubscription even though its own VM did microseconds of work. D1 charges
script CPU-time only, so parked time is not counted.

Validated as a real regression gate, not a no-op: temporarily reverting the
interrupt handler to a `Date.now() - start` wall budget turns this suite RED
from ~64 concurrent chains up, while the shipped CPU budget stays green through
256. It is robust (not itself flaky) because concurrency stresses the
parked-time accounting D1 excludes, not slice size — the charged CPU per tiny
rollup body is invariant to how many chains are in flight.
`OS_CANARY_CONCURRENCY` overrides the default for an ad-hoc heavier soak.

Test-only; no changeset.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011iJLjqToxNv1aYP3syQtRp
@vercel

vercel Bot commented Jul 20, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
spec Ready Ready Preview, Comment Jul 20, 2026 6:18am

Request Review

@github-actions

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

This PR changes 1 package(s): @objectstack/runtime.

17 hand-written doc(s) reference the affected code and may need an implementation-accuracy re-verification:

  • content/docs/api/index.mdx (via @objectstack/runtime)
  • content/docs/api/wire-format.mdx (via @objectstack/runtime)
  • content/docs/automation/hook-bodies.mdx (via @objectstack/runtime)
  • content/docs/concepts/north-star.mdx (via packages/runtime)
  • content/docs/data-modeling/drivers.mdx (via @objectstack/runtime)
  • content/docs/deployment/index.mdx (via @objectstack/runtime)
  • content/docs/deployment/production-readiness.mdx (via @objectstack/runtime)
  • content/docs/deployment/single-project-mode.mdx (via @objectstack/runtime)
  • content/docs/deployment/vercel.mdx (via @objectstack/runtime)
  • content/docs/getting-started/your-first-project.mdx (via @objectstack/runtime)
  • content/docs/permissions/authentication.mdx (via @objectstack/runtime)
  • content/docs/permissions/authorization.mdx (via packages/runtime)
  • content/docs/plugins/packages.mdx (via @objectstack/runtime)
  • content/docs/protocol/kernel/http-protocol.mdx (via @objectstack/runtime)
  • content/docs/protocol/kernel/index.mdx (via @objectstack/runtime)
  • content/docs/protocol/kernel/lifecycle.mdx (via @objectstack/runtime)
  • content/docs/releases/implementation-status.mdx (via @objectstack/runtime)

Advisory only. To re-verify, run the docs-accuracy-audit workflow scoped to these files:
node scripts/docs-audit/affected-docs.mjs origin/main → pass the list as args.docs.

@os-zhuang os-zhuang added the allow-major label Jul 20, 2026 — with Claude
@os-zhuang
os-zhuang marked this pull request as ready for review July 20, 2026 07:45
@os-zhuang
os-zhuang merged commit dc5c733 into main Jul 20, 2026
19 checks passed
@os-zhuang
os-zhuang deleted the claude/nested-write-flake-canary branch July 20, 2026 07:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants