Skip to content

docs(skills): add perf-review and hot-path V8, DOM, and scheduling rules - #1868

Merged
domgan-oai merged 4 commits into
mainfrom
docs/perf-discipline-skills
Oct 7, 2026
Merged

domgan-oai merged 4 commits into
mainfrom
docs/perf-discipline-skills

Conversation

@trueadm

@trueadm trueadm commented Oct 7, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Agent-written PRs now have one place that states the low-level hot-path rules (V8 shapes, DOM work, scheduling), and a validator skill that checks a diff against them and asks for the evidence each risk needs. Nothing under packages/*/src changes. The scheduling rules defer to #1864 and do not change the documented contract in docs/differences-from-react.md §Scheduler.

New and changed skills

Skill / rule Trigger What changed Source patterns cited
perf-review (new) Before readying a PR that touches packages/octane/src, compiler output, or binding hot paths; when reviewing agent-written code. Routed from the root rule. Validator: pick the target (worktree, --head <branch>, or gh pr diff <n>), classify hot or cold, read the scan's candidates, judge shapes, allocation, DOM, scheduling, and React divergences, then require evidence. Report with must-fix / needs-evidence / note; every candidate is either a finding or dismissed with a reason. BlockImpl/ScopeImpl/LiteBlockImpl, HMR wrapper (arguments on a cold branch), schedulePostPaint, actCheckpoint, resumeOnSettle, createResizeObserver, drainPassivesBeforeRender, §Scheduler, #990
performance-audit (changed) Unchanged trigger; description now names scheduling and the rules it holds. New "Hot-path discipline" summary, three references, an evidence table per kind of change, the harness list (it named 5 suites before), and the local-load rule. See the three references below
↳ references/v8-shapes.md (new) Loaded from performance-audit, perf-review, and octane-core-extend. Hidden classes; monomorphic sites; Smi vs double fields; elements kinds; allocation in hot loops; try/catch and function size; bundle reachability; how to verify (%HaveSameMap, %GetOptimizationStatus, --trace-deopt, --log-ic/--log-maps, file-backed stdout). BlockImpl doc comment and declare fields, Scope.slots, bag0–bag16 / makeBag, both ForSlot literals' plainDeopt, template()'s LazyTemplateRecord, getFirstChild/initDomOperations cached accessors, seedExpando/delegateEvents, unmountSlot's single __kind read, $$ctxDepsEpoch -1 poison, ReactiveFlags/revision (signals/graph.ts), hookMemoCreate .fill(null), compile.js dense slot indices, PINNED_HOST_BATCH_SHAPES (universal-core.ts), hydration-flag.ts guard forms, compiler/pure-factories.js, benchmarks/runtime-object-shapes, benchmarks/client-hot-paths/functions.{mjs,md}, delete p.key in 894d51c
↳ references/dom-work.md (new) Same. Forced synchronous layout, read-then-write batching, template cloning and single insertion, native delegated events, ResizeObserver loops, rAF running before paint, after-paint work. vtMeasureElements, dom-stage.ts PROJECTED_PROPERTIES, scripts/check-staged-dom.mjs NATIVE_READS, template()/parseTemplate/clone(), delegateEvents/dispatchDelegated/TARGET_ONLY_DELEGATED/delegatedListenerOptions, maybeFlushDiscrete, createResizeObserver, schedulePostPaint/schedulePassiveFlush, .github/workflows/pr-bench.yml DOM-mutation gate
↳ references/scheduling.md (new) Same. Microtask vs task; megatasks; coalesce first, then yield; one shared budget; reuse an existing task poster; never depend on rAF; defer contract changes to #1864. Evidence: the MessageChannel marker commit count (kept in the bench/ratio system until #1864 documents a guarantee, per testing.md), Event Timing in Chromium via octane-events-browser, and the scheduling suites. scheduleRender → queueMicrotask(flush), flush/flushWork/drainQueue, commitEffects, schedulePassiveFlush, drainPassivesBeforeRender, the four ad-hoc posters, nested-update chain reset, #1864 measurements
octane-core-extend (changed) Unchanged (before editing packages/octane/src). Preflight names call-frequency tiers. New "Hot-path rules" section covers Block/Scope shape, records, reachability, DOM, and scheduling. Validation adds perf-review and "owning suite only"; three new risk checks. BlockImpl, scope.slots, #990's 13 shape-forking writes, scheduleRender, §Scheduler
create-a-pr (changed) Unchanged (before any branch/commit/PR). New "Performance review gate": run perf-review before the first gh pr ready when the diff touches packages/octane/src, compiled-output transforms, or a binding hot path. Report in the PR body; no open must-fix. Template line and readiness gate added. —
core-engineering rule (changed) Glob-loaded for runtime, compiler, and plugin sources. Hot-class and hot-literal shape rules, the "a microtask is not a yield" rule, and a perf-review handoff requirement. BlockImpl/ScopeImpl/LiteBlockImpl, #1864
Root rule (changed) Always loaded. Adds the perf-review routing line. To stay under the 8,000-byte budget (7,982 now), it trims a sentence that repeated the code block's comments. —

scripts/perf-review-scan.mjs (advisory, not a CI gate)

It reads a unified diff and scans only added lines, with comments and strings blanked. With --diff (a pasted gh pr diff), fields the diff declares count as known, and the structural check is left to --head, which reads the head's runtime.ts. The default scope is packages/octane/src minus compiler/; bindings are opt-in by path. It always exits 0.

  • Two invariants hold on main with zero hits:
    • hot-class-shape: BlockImpl (72 fields), ScopeImpl (22), and LiteBlockImpl (11) are declare-only, and each field is assigned unconditionally in the constructor.
    • hot-field-write: every write through a Block or Scope receiver, including casts like (b as any).x =, targets a declared field.
  • Line rules: delete-operator, conditional-shape, shape-mutation, holey-array, rest-or-arguments, layout-read (noting an earlier DOM write in the hunk), microtask-hop and schedule-render (noting an enclosing loop), await-as-yield, animation-frame, and task-poster (zero-delay or delay-less setTimeout only).

False-positive evidence, measured before deciding to ship it:

Its 17 node:test cases run in ci:workflow:test (lint job), including an end-to-end --head run against a temporary repository. Mutation checks: 12 of 14 deliberate breakages turned the suite red. The other two were dead guards that no input could reach, and were removed. scripts/classify-ci-change.mjs lists the scan and its test as lightweight helpers, alongside format-files/typecheck-files. They can't affect shipped code, and the universal lint job still runs their tests.

Validation

  • pnpm sync (via npx [email protected] run sync): exit 0, all generated changes committed; rulesync generate --check up to date
  • node scripts/check-context-budget.mjs: CLAUDE.md 165 lines / 7,982 bytes; perf-review description 367 chars
  • pnpm format:files:check on the changed files: clean
  • targeted tests: node --test scripts/perf-review-scan.test.mjs scripts/classify-ci-change.test.mjs scripts/ci-workflow.test.mjs: 98/98 pass
  • node scripts/check-typecheck-coverage.mjs: passes. The new scripts are in no TS project, same as classify-ci-change.mjs
  • pnpm format:check, pnpm typecheck, pnpm test: not run locally (load rule; no package source changed). CI classifies this diff as lightweight.
  • perf-review: not applicable. No shipped package source changed, and node scripts/perf-review-scan.mjs reports no candidates.

Risk / follow-ups

Provenance

  • An agent produced this diff (agent-authored)

🤖 Generated with Claude Code


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.


Note

Low Risk
Documentation and agent workflow only; no changes under packages/*/src. Misapplied scan rules could slow PRs or miss edge cases, but shipped behavior is unchanged.

Overview
Adds agent-facing perf-review workflow and codifies Octane hot-path rules (V8 shapes, DOM commit discipline, microtask scheduling) without changing shipped runtime code.

A new perf-review skill walks diffs through scripts/perf-review-scan.mjs, classifies hot vs cold paths, triages scan candidates, and requires evidence before PRs are marked ready. performance-audit gains three reference docs (v8-shapes, dom-work, scheduling) plus an evidence table and expanded harness guidance. octane-core-extend, create-a-pr, and core-engineering (and mirrored .agents/.claude/.cursor/.gemini/Copilot copies) wire in hot-path preflight, validation checklists, and a performance review gate on PRs that touch runtime, compiler output, or binding hot paths. Root project rules add perf-review routing; classify-ci-change treats the scan scripts as lightweight CI helpers.

Reviewed by Cursor Bugbot for commit 2af46c7. Bugbot is set up for automated code reviews on this repo. Configure here.

Agent-written PRs now get one place that states the hot-path rules and one
skill that checks a diff against them.

- performance-audit gains three references grounded in runtime code:
  V8 shapes and allocation, DOM work without forced layout, and
  microtask/task scheduling (the #1864 megatask findings). It also gains
  an evidence table per kind of change and the local-load rule.
- New perf-review skill: classify the diff hot or cold, read the
  mechanical candidates, judge each dimension, and require evidence.
- scripts/perf-review-scan.mjs is the advisory scan behind it. Two
  invariants hold on main with zero hits: hot classes assign every
  declared field unconditionally in the constructor, and writes through
  Block/Scope receivers only target declared fields. On pre-#990 runtime
  the second finds all 13 shape-forking writes #990 fixed. Over the last
  150 source commits the line rules report 44 candidate lines in 11
  commits.
- octane-core-extend, core-engineering, and create-a-pr route hot-path
  diffs through perf-review; the root rule lists its trigger.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions github-actions Bot added agent-authored Diff or issue body substantially produced by an AI agent docs PR: documentation only labels Oct 7, 2026
@trueadm
trueadm marked this pull request as ready for review October 7, 2026 21:31
…ares

A pasted PR diff is scanned against the local checkout's runtime.ts. A PR
that correctly declares a new BlockImpl field would then get a false
hot-field-write for writing it, and the structural check would inspect the
checkout instead of the reviewed head. Fields declared in the diff now count
as known, and --diff leaves hot-class-shape to --head.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions

github-actions Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Benchmark report

🟢 No budget breaches, no added work, and no timing changes beyond ±3%.

Compares 31724a3f9, the merge commit's first parent with 9cf3e0f58 on the same runner. A byte value over its committed budget or any increase in a js-framework work counter fails this check. Wall time is a report: base and head samples alternate in one browser, and an operation is called slower or faster only when the 95% confidence interval of its ratio excludes ±3%. Workflow run

js-framework: 1k/10k row operations

All 20 timed operations (20 without a verdict)
target operation base ms head ms head/base 95% CI
octane-tsrx run 4.117 4.283 −8.9% −15.2% … +4.5% ⚪ within noise
octane-tsrx replace 9.150 9.983 +7.2% −0.5% … +16.5% ⚪ within noise
octane-tsrx add 2.900 2.692 −1.7% −7.2% … +7.7% ⚪ within noise
octane-tsrx update 0.140 0.141 −0.3% −5.7% … +3.2% ⚪ within noise
octane-tsrx select 0.006 0.006 −1.1% −2.8% … +0.8% ⚪ within noise
octane-tsrx swap 0.034 0.034 +1.3% ±0.0% … +3.9% ⚪ within noise
octane-tsrx remove 0.015 0.015 −2.3% −5.5% … +2.5% ⚪ within noise
octane-tsrx runlots 23.767 24.125 +1.7% −1.8% … +3.6% ⚪ within noise
octane-tsrx select_lots 0.006 0.006 −2.4% −4.7% … −1.0% ⚪ within noise
octane-tsrx clear 48.758 51.033 +2.4% −0.6% … +6.1% ⚪ within noise
octane-jsx run 3.708 3.867 −0.0% −4.2% … +2.7% ⚪ within noise
octane-jsx replace 7.092 7.258 +0.8% −2.7% … +4.6% ⚪ within noise
octane-jsx add 3.350 3.225 −2.9% −5.9% … +1.5% ⚪ within noise
octane-jsx update 0.282 0.290 +1.7% −0.6% … +4.0% ⚪ within noise
octane-jsx select 0.140 0.132 −1.7% −5.0% … +0.9% ⚪ within noise
octane-jsx swap 0.225 0.230 ±0.0% −2.2% … +1.6% ⚪ within noise
octane-jsx remove 0.196 0.192 −1.9% −5.4% … +1.9% ⚪ within noise
octane-jsx runlots 30.208 29.525 −1.4% −4.0% … +0.8% ⚪ within noise
octane-jsx select_lots 1.571 1.505 −1.1% −5.7% … +0.6% ⚪ within noise
octane-jsx clear 51.267 50.675 +0.8% −3.4% … +6.8% ⚪ within noise

All 64 work counters are unchanged.

Application bundle size (bytes)

No changes across 60 measured values.

Public-import reachability bundles (bytes)

No changes across 111 measured values.

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix prepared a fix for the issue found in the latest run.

  • ✅ Fixed: Head scan uses wrong merge base
    • Added resolveMainRef() that returns the branch ref name (origin/main or main) instead of using resolveBase() which returns a checkout-dependent merge-base commit, so --head now computes merge-base(origin/main, head) correctly.

Create PR

Or push these changes by commenting:

@cursor push 90c6ffd787
Preview (90c6ffd787)
diff --git a/scripts/perf-review-scan.mjs b/scripts/perf-review-scan.mjs
--- a/scripts/perf-review-scan.mjs
+++ b/scripts/perf-review-scan.mjs
@@ -476,6 +476,16 @@
 	return execFileSync('git', args, { cwd: ROOT, encoding: 'utf8', maxBuffer: 256 * 1024 * 1024 });
 }
 
+function resolveMainRef() {
+	for (const ref of ['origin/main', 'main']) {
+		try {
+			git(['rev-parse', '--verify', ref]);
+			return ref;
+		} catch {}
+	}
+	throw new Error('Could not resolve main; pass --base <ref> or --diff <file>.');
+}
+
 function resolveBase(ref) {
 	for (const candidate of [ref, 'origin/main', 'main'].filter(Boolean)) {
 		try {
@@ -513,7 +523,7 @@
 	}
 	const unified = `--unified=${CONTEXT_LINES}`;
 	if (options.head !== undefined) {
-		const base = git(['merge-base', options.base ?? resolveBase(), options.head]).trim();
+		const base = git(['merge-base', options.base ?? resolveMainRef(), options.head]).trim();
 		return {
 			text: git([
 				'diff',

You can send follow-ups to the cloud agent here.

Reviewed by Cursor Bugbot for commit 615fd9f. Configure here.

Comment thread scripts/perf-review-scan.mjs Resolved
Without --base, --head took the merge-base of the current checkout and main,
then a second merge-base with the target. A checkout older than the target's
fork point pulled unrelated main commits into the scanned diff. The base is
now the merge-base of the target itself and main (or --base). The scan also
resolves its repository from the working directory, so it runs from any
subdirectory and against any checkout.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@domgan-oai
domgan-oai merged commit 73af48a into main Oct 7, 2026
23 checks passed
@domgan-oai
domgan-oai deleted the docs/perf-discipline-skills branch October 7, 2026 22:10
trueadm added a commit that referenced this pull request Oct 7, 2026
#1868 added .rulesync/skills/perf-review without mapping it in
REPO_SKILLS, so octane_skill could not reach it and the MCP server test
that compares the map with the directory fails. It fails on main too
(37a1c14, test shard 3/4), and so on every PR merged with main. Map
it and list it in the README.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

@domgan-oai domgan-oai left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agent-authored retrospective review (Codex). The advisory scanner tests pass, including the corrected --head merge-base case. One integration regression remains: the new skill is missing from the MCP skill registry, and the existing catalog test is now failing on main.

@@ -0,0 +1,151 @@
---
targets: ['*']
name: perf-review

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P1] Register the new skill in the MCP catalog. Adding this directory without adding perf-review to REPO_SKILLS in packages/octane-mcp-server/src/index.js leaves octane_skill unable to serve a skill the new maintainer workflow requires: its input enum is built from that registry. It also breaks the existing serves every RuleSync skill, and only skills that exist test at index.test.js:410. This is confirmed on main 37a1c14847920eeaf97b12af8355f90ff825ff3b in the failed test shard, whose only assertion failure is the missing perf-review entry. Add the registry mapping and run the owning MCP test; also run the catalog consistency check for lightweight RuleSync-only changes, since that classification skipped the check on this PR.

leonidaz added a commit that referenced this pull request Oct 7, 2026
…tly (#1730)

* chore: make the native catalog's TypeScript 7.1 nightly the repository's only TypeScript 7

The native catalog now holds one entry, `typescript-native`, an alias of the
pinned 7.1 nightly, so a package can keep the classic `typescript` (default
catalog, 5.9) beside it. octane-tsc and base-ui's and base-ui-utils' native
pristine type lanes use it; those lanes ran TypeScript 7.0.2 through their own
`typescript-pristine-native` alias, and the root typecheck now calls the
native tsc by path instead of the package's ambiguous `.bin/tsc`. Both pristine
lanes pass on the nightly, and UPSTREAM.md says the lane no longer runs
upstream's 7.0.2.

With that alias gone, nothing installs TypeScript 7.0.2. The optional
`typescript` peers that pnpm had filled with it (@tsrx/ripple, vue, i18next,
valibot, cosmiconfig) resolve to the classic 6.0.3 or 5.9.3 already in the
workspace; every other locked version is unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* feat(react-port): build type evidence on the native TypeScript 7 API

`createNativeTypeEvidenceProgram(rootNames, project)` builds the react-port
type-evidence program on `typescript-native` (the native catalog's 7.1 nightly)
through `typescript/unstable/sync`. A sibling wrapper tsconfig, as in octane-tsc,
enables @tsrx/content-mapper with Octane's Volar compiler, so `.tsrx` imports
are typed instead of `any`; the new test fails without the mapper.

octane-tsc's native compiler path, `.tsrx` content-mapper entry and TypeScript
5.9 compatibility options move to scripts/octane-tsc/native.mjs, which both
share.

The classic `createTypeEvidenceProgram` stays for evidence.mjs and
generate-public-contract-tests.mjs until they move to the TypeScript 7 AST and
checker. Over base-ui's adapted type specs (575 files, 4,227 exports) the native
program builds in about half the time and gives every export the same type,
apart from union member order (213) and literal quote style (4) in
`typeToString` text.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* refactor(react-port): check type evidence on the TypeScript 7 API

evidence.mjs, pinned-public-types.mjs and generate-public-contract-tests.mjs
now read the react-port type-evidence program through TypeScript 7's
`typescript/unstable/sync` API, and the classic Volar-proxied program is
removed. `createTypeEvidenceProgram(rootNames, project)` builds it from the
project's tsconfig with the `.tsrx` content mapper, and throws when the mapper
cannot resolve (TS100031) instead of checking imported TSRX as `any`.

TypeScript 7 differs from the classic API in ways that would otherwise read as
`undefined` rather than fail, so scripts/react-port/native-types.mjs keeps them
in one place: symbols, types and signatures refer to each other by id behind
getters (`getSymbol()`, `getTypes()`, `getParameters()`); declarations are
handles to resolve; `getTarget()` throws for a type without a target; alias
type arguments are `[]` rather than absent; index infos carry `valueType`; a
type parameter's default is `defaultType`; boolean literals carry `value`
rather than an intrinsic name; TypeScript's own declarations live in the
native platform package, which has no `hasNoDefaultLib`; and modifiers are
read by `SyntaxKind`. Classic TypeScript remains only to parse tsconfig files
and upstream sources, never program nodes.

The regenerated base-ui and base-ui-utils published contracts keep every
assertion; four gain members from TypeScript 7.1's newer DOM and Temporal lib
declarations (`customElementRegistry`, `moveBefore`, `oncommand`,
`toTemporalInstant`), the same libs octane-tsc checks them with, and group
numbering follows TypeScript 7's export order. Test fixtures outside the
repository link @tsrx/content-mapper and octane, as a workspace package
resolves them.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(mcp-server): serve the perf-review RuleSync skill

#1868 added .rulesync/skills/perf-review without mapping it in
REPO_SKILLS, so octane_skill could not reach it and the MCP server test
that compares the map with the directory fails. It fails on main too
(37a1c14, test shard 3/4), and so on every PR merged with main. Map
it and list it in the README.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
Co-authored-by: Dominic Gannaway <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent-authored Diff or issue body substantially produced by an AI agent docs PR: documentation only

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants