Skip to content

feat(cli): fail CI when a module stops compiling under Strong mode - #1515

Merged
trueadm merged 6 commits into
mainfrom
feat/strong-coverage-baseline
Oct 2, 2026
Merged

trueadm merged 6 commits into
mainfrom
feat/strong-coverage-baseline

Conversation

@trueadm

@trueadm trueadm commented Oct 1, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Every Strong check applies only to a module that compiles in Strong mode, so the cheapest way around one is to leave Strong mode. That takes a one-line change that is easy to miss in review: delete "use strong", turn compiler.strong off, or move code into another package, which the application's compiler.strong does not reach. This PR makes that change fail CI. It is the coverage ratchet item in section D of #1027.

octane analyze --strong-baseline init     # record today's non-Strong modules
octane analyze                            # fails on anything that regressed
octane analyze --strong-baseline update   # drop names that are now Strong
  • init writes octane-strong-baseline.json ({ "version": 1, "exceptions": [...] }), listing every module Octane compiles that is not Strong today.
  • While the file exists, every octane analyze run measures the whole project and reports two errors:
    • OCTANE_STRONG_COVERAGE_REGRESSION: a module that is neither Strong nor listed, whether new, stripped of its directive, or moved out of compiler.strong's reach.
    • OCTANE_STRONG_COVERAGE_STALE: a listed name that is now Strong, gone, or no longer compiled by Octane. A stale name would let that module leave Strong mode again unnoticed. It is reported at the entry's line in the baseline file.
  • update only ever removes names, and init refuses to overwrite an existing file. The tool never adds an exception, so a new one is always a hand edit to the file, visible in review. A CODEOWNERS entry can route those edits to an owner.
  • The regression message tells an agent how to make the module Strong, and that exceptions are reviewed. It does not suggest editing the baseline.

The compiler decides which modules are Strong

The CLI does not re-derive the policy. OctaneBundlerCompiler gains strongModuleStatus(code, id), which returns { strong, directive, config }. It reads the directive prologue through the same parsers and the new declaresStrongMode helper that strongDirectives now uses, and applies the existing _hasApplicationStrongPolicy. A parity test checks the method against transform for each case:

  • the application policy
  • nested packages
  • node_modules
  • a directive after other directives and comments
  • a 'use strong' string elsewhere in the file
  • a function-body directive
  • plain .ts hook modules

octane/compiler/bundler also re-exports findLeadingJsxImportSourcePragma, so the CLI reads module ownership with the compiler's own scanner. transform is untouched and nothing calls the new method on a build path.

Which modules count

  • Every .tsrx.
  • Every .tsx whose JSX goes to Octane. A leading @jsxImportSource pragma, or the tsconfig jsxImportSource, naming another library excludes it, so React-hosted files are left out.
  • Every .ts/.js file with a runtime octane import. Type-only imports don't count.
  • .d.ts files are excluded.

Two octane analyze defects fixed along the way

  • compiler.strong was ignored. analyze compiled every file with {} options, so in projects that enable Strong through octane.config.ts it never reported a Strong diagnostic for modules without a directive. It now evaluates the config with the project's own @octanejs/app-core loader (moved out of doctor into kernel/octane-config.js) and analyzes those modules in Strong mode, as the build does.
  • Coded compiler errors were reported as parse errors. A thrown Strong error such as [OCTANE_STRONG_EFFECT_STATE_UPDATE] … was labelled OCTANE_PARSE_ERROR, with the file path repeated in the message. It now carries its own code, so --code can select it.

analyze.js moved to analyze/index.js next to the new strong-coverage.js.

Validation

  • pnpm format:check: passed before rebasing onto current main. pnpm format:files:check on the changed files passed after.
  • pnpm typecheck: passed before rebasing. After rebasing, tsgo --noEmit passed for packages/cli/tsconfig.typecheck.json and packages/octane/tsconfig.json.
  • pnpm test: did not finish locally. The vitest main process ran out of heap after 56 minutes with the machine at a load average above 40, while three other sessions ran suites. Every failure in that run was a 5-second timeout, including analyze tests that predate this PR and unrelated Volar, behavior-root, and evals files. Each failed file passes on its own, so CI is the full-suite gate here.
  • targeted tests:
    • packages/cli/tests: all pass, including 9 new Strong coverage tests (the slowest takes 138ms).
    • packages/octane/tests/compiler/bundler-compiler.test.ts, strong-mode.test.ts, strong-effects.test.ts, strong-hook-policy.test.ts, strong-template-policy.test.ts, and volar.test.ts: all pass.
    • behavior-root.test.ts and the two octane-evals files that timed out in the full run: pass on their own.
  • I checked that each new test fails when its behavior is broken:
    • accepting "use strong" outside the prologue fails the parity test;
    • compiling without compiler.strong, or dropping the coded-error extraction, fails the config test;
    • having update add regressions, or skipping stale detection, fails the stale/update test.
  • pnpm sync produced no generated changes.

Risk / follow-ups

  • Inline plugin options are invisible. A bundler plugin's inline strong option overrides octane.config.ts at build time and the CLI cannot see it. The docs say to keep the setting in octane.config.ts. Closing this fully would need the build itself to report coverage.
  • Some modules Octane won't compile are still counted. exclude and requireDirective are inline plugin options too. The ownership rule above approximates them, so an excluded file that the pragma/tsconfig rule still counts is recorded once at init.
  • analyze now evaluates octane.config.ts on every run when the file exists, as doctor already does. If the config cannot be evaluated, a run that needs coverage fails with the reason. Otherwise analyze prints a warning and keeps its diagnostics.
  • Large projects can't be measured. Coverage refuses to run on a project over the CLI's 5000-source-file scan limit rather than report a partial result.

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

Medium Risk
Changes CI-facing analyze behavior (config evaluation, Strong compile options, new failure modes) and introduces compiler API surface, but does not alter production transform output.

Overview
Adds a Strong coverage ratchet to octane analyze: --strong-baseline init writes octane-strong-baseline.json listing modules that compile without Strong mode; while it exists, analyze fails on OCTANE_STRONG_COVERAGE_REGRESSION (non-Strong, unlisted modules) and OCTANE_STRONG_COVERAGE_STALE (listed exceptions that are now Strong, gone, or no longer Octane-compiled). update only removes stale names—new exceptions require a hand-edited baseline file.

The bundler compiler exposes strongModuleStatus(code, id) (same rules as transform) plus declaresStrongMode; the CLI uses that and compiler.strong from octane.config.ts so coverage and per-file analysis match the build. octane analyze also compiles policy-reached modules with { strong: true }, and thrown errors with [OCTANE_*] codes keep those codes instead of OCTANE_PARSE_ERROR. Config loading is shared via kernel/octane-config.js (moved out of doctor).

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

Strong is opt-in per module or per application, so the cheapest way around a
Strong diagnostic is to stop being Strong: delete "use strong", turn
compiler.strong off, or move the code into another package. `octane analyze
--strong-baseline init` records the modules that are not Strong today in
octane-strong-baseline.json. While the file exists, every run fails on a module
that is neither Strong nor listed (OCTANE_STRONG_COVERAGE_REGRESSION) and on a
listed name that is now Strong or gone (OCTANE_STRONG_COVERAGE_STALE).
`--strong-baseline update` only removes names, so a new exception is always a
reviewed edit to the file.

The compiler decides which modules are Strong: the bundler compiler gains
strongModuleStatus(code, id), the decision transform already makes.

Also fixes two analyze defects: it ignored compiler.strong from
octane.config.ts, and it reported coded compiler errors such as Strong rules as
OCTANE_PARSE_ERROR.

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 feat PR: new feature or capability labels Oct 1, 2026
@github-actions
github-actions Bot marked this pull request as draft October 1, 2026 21:02

@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.

Autofix Details

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

  • ✅ Fixed: Type-only named imports counted as runtime
    • Replaced bare OCTANE_IMPORT.test() with hasRuntimeOctaneImport() that checks all matched imports and verifies at least one named specifier lacks the inline type modifier, so import { type X } from 'octane' is no longer counted as a runtime import.

Create PR

Or push these changes by commenting:

@cursor push f2a7d299b9
Preview (f2a7d299b9)
diff --git a/packages/cli/src/commands/analyze/strong-coverage.js b/packages/cli/src/commands/analyze/strong-coverage.js
--- a/packages/cli/src/commands/analyze/strong-coverage.js
+++ b/packages/cli/src/commands/analyze/strong-coverage.js
@@ -116,14 +116,31 @@
 }
 
 /**
- * A runtime (not type-only) import of octane or one of its subpaths. The
- * clause may span lines but never reaches into the next `import`, so a
- * semicolon-free module cannot borrow a later type-only import's specifier.
+ * A non-`import type` import of octane or one of its subpaths. The clause may
+ * span lines but never reaches into the next `import`, so a semicolon-free
+ * module cannot borrow a later type-only import's specifier.
  */
 const OCTANE_IMPORT =
-	/^\s*import\s+(?!type\b)(?:(?!\bimport\b)[^;])*?\bfrom\s*['"]octane(?:\/[^'"]*)?['"]/m;
+	/^\s*import\s+(?!type\b)(?:(?!\bimport\b)[^;])*?\bfrom\s*['"]octane(?:\/[^'"]*)?['"]/gm;
 
 /**
+ * True when `source` contains at least one runtime (non-type) import of
+ * octane. Both `import type { X }` and `import { type X }` are erased by
+ * TypeScript and do not make the module something Octane compiles.
+ *
+ * @param {string} source
+ */
+function hasRuntimeOctaneImport(source) {
+	for (const m of source.matchAll(OCTANE_IMPORT)) {
+		const braces = m[0].match(/\{([^}]*)\}/s);
+		if (!braces) return true;
+		const specifiers = braces[1].split(',');
+		if (specifiers.some((s) => s.trim() !== '' && !/^type\s/.test(s.trim()))) return true;
+	}
+	return false;
+}
+
+/**
  * @param {string | undefined} source a JSX import source
  */
 function isOctaneJsxSource(source) {
@@ -153,7 +170,7 @@
 		if (pragma !== null) return isOctaneJsxSource(pragma);
 		return jsxImportSource === undefined || isOctaneJsxSource(jsxImportSource);
 	}
-	if (extension === '.ts' || extension === '.js') return OCTANE_IMPORT.test(source);
+	if (extension === '.ts' || extension === '.js') return hasRuntimeOctaneImport(source);
 	return false;
 }
 

diff --git a/packages/cli/tests/analyze.test.js b/packages/cli/tests/analyze.test.js
--- a/packages/cli/tests/analyze.test.js
+++ b/packages/cli/tests/analyze.test.js
@@ -271,6 +271,8 @@
 			'src/strong-hook.ts':
 				"'use strong';\nimport { useState } from 'octane';\nexport function useOne() { return useState(1); }\n",
 			'src/types.ts': "import type { OctaneNode } from 'octane';\nexport type Node = OctaneNode;\n",
+			'src/inline-types.ts':
+				"import { type OctaneNode, type StrongStatus } from 'octane';\nexport type Node = OctaneNode;\nexport type Status = StrongStatus;\n",
 			'src/no-semi.ts':
 				"import { add } from './math'\nimport type { OctaneNode } from 'octane'\nexport type Sum = OctaneNode\n",
 			'src/math.ts': 'export const add = (a: number, b: number) => a + b;\n',

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

@github-actions

github-actions Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Benchmark report

  • 🟡 js-framework: 1 timed operation(s) possibly slower
  • 🔴 bundle-reachability: 3 value(s) increased

Compares ec59fa37c with c341788b4 on the same runner. Timing verdicts require a change beyond the combined margin of error (at least 5%) and one 0.1ms timer tick, with the fastest sample moving the same way. Workflow run

js-framework: 1k/10k row operations (ms, lower is better)

target operation base head Δ noise
octane-jsx clear 37.80 45.87 +21.3% ±21% 🟡 slower
All 20 timed operations (19 within noise)
target operation base head Δ noise
octane-tsrx run 5.85 5.79 −1.0% ±98% ⚪ within noise
octane-tsrx replace 12.46 9.60 −23.0% ±84% ⚪ within noise
octane-tsrx add 5.14 4.26 −17.1% ±76% ⚪ within noise
octane-tsrx update 0.62 0.62 ±0.0% ±112% ⚪ within noise
octane-tsrx select 0.23 0.20 −13.0% ±91% ⚪ within noise
octane-tsrx swap 0.38 0.44 +15.8% ±49% ⚪ within noise
octane-tsrx remove 0.44 0.38 −13.6% ±79% ⚪ within noise
octane-tsrx runlots 38.78 39.82 +2.7% ±24% ⚪ within noise
octane-tsrx select_lots 0.23 0.27 +17.4% ±54% ⚪ within noise
octane-tsrx clear 41.84 40.94 −2.2% ±53% ⚪ within noise
octane-jsx run 8.06 6.04 −25.1% ±105% ⚪ within noise
octane-jsx replace 15.22 9.47 −37.8% ±68% ⚪ within noise
octane-jsx add 7.13 4.92 −31.0% ±101% ⚪ within noise
octane-jsx update 0.94 0.98 +4.3% ±92% ⚪ within noise
octane-jsx select 0.57 0.72 +26.3% ±68% ⚪ within noise
octane-jsx swap 1.06 1.09 +2.8% ±91% ⚪ within noise
octane-jsx remove 0.90 0.91 +1.1% ±86% ⚪ within noise
octane-jsx runlots 43.35 41.46 −4.4% ±88% ⚪ within noise
octane-jsx select_lots 3.03 4.40 +45.2% ±66% ⚪ within noise
octane-jsx clear 37.80 45.87 +21.3% ±21% 🟡 slower

Application bundle size (bytes)

No changes across 45 measured values.

Public-import reachability bundles (bytes)

target metric base head Δ
server-render raw 64,556 64,570 +14 (+0.0%) 🔴
server-render gzip 22,245 22,254 +9 (+0.0%) 🔴
server-render brotli 20,055 20,059 +4 (+0.0%) 🔴

102 other measured values are unchanged.

CI job durations

  • 🟢 2 job(s) faster than every recent main run: validate publishable packages, typecheck checks

Compares the CI run for 3c2828922 (run) with the last 5 successful main push runs. A job is only slower or faster outside the whole main range, by at least 10% and 15s.

job main median main range this PR Δ
wall clock (first job start to last job end) 17m 36s 13m 51s–23m 15s 84m 46s +67m 10s (+382%) 🟡 slower
total job time 178m 49s 157m 01s–242m 49s 159m 04s −19m 45s (−11%) ⚪ within noise
validate publishable packages 5m 03s 4m 32s–5m 22s 4m 18s −45s (−15%) 🟢 faster
typecheck checks 10m 02s 8m 33s–11m 07s 8m 08s −1m 54s (−19%) 🟢 faster
All 26 timed jobs
job main median main range this PR Δ
website integration suite 6m 30s 5m 59s–11m 41s 7m 09s +39s (+10%) ⚪ within noise
lint checks 9m 40s 8m 35s–11m 33s 9m 52s +12s (+2%) ⚪ within noise
examples 4s 4s–4s 4s ±0s (±0%) ⚪ within noise
lint 4s 4s–5s 4s ±0s (±0%) ⚪ within noise
classify changeset release 16s 15s–17s 16s ±0s (±0%) ⚪ within noise
test (24) 4s 4s–5s 4s ±0s (±0%) ⚪ within noise
CI provenance 4s 3s–4s 4s ±0s (±0%) ⚪ within noise
typecheck 4s 3s–5s 3s −1s (−25%) ⚪ within noise
React parity checks 16s 15s–18s 15s −1s (−6%) ⚪ within noise
Three compatibility 3m 42s 2m 41s–3m 51s 3m 37s −5s (−2%) ⚪ within noise
example apps (2/3) 4m 44s 3m 44s–9m 58s 4m 19s −25s (−9%) ⚪ within noise
Lynx compatibility 2m 10s 1m 35s–2m 55s 1m 41s −29s (−22%) ⚪ within noise
example apps (1/3) 4m 03s 3m 12s–9m 27s 3m 32s −31s (−13%) ⚪ within noise
React parity shard (1/4) 12m 33s 10m 54s–18m 11s 12m 01s −32s (−4%) ⚪ within noise
React parity shard (2/4) 11m 47s 10m 32s–19m 40s 11m 15s −32s (−5%) ⚪ within noise
example apps (3/3) 4m 19s 3m 41s–6m 06s 3m 46s −33s (−13%) ⚪ within noise
test shard (Node 24, 3/4) 11m 39s 10m 05s–13m 34s 11m 03s −36s (−5%) ⚪ within noise
heavy integration (package builds, eval corpus, runtime loaders, Astro) 6m 35s 5m 30s–16m 52s 5m 53s −42s (−11%) ⚪ within noise
validate publishable packages 5m 03s 4m 32s–5m 22s 4m 18s −45s (−15%) 🟢 faster
test shard (Node 24, 1/4) 13m 16s 10m 39s–17m 32s 12m 17s −59s (−7%) ⚪ within noise
React parity shard (4/4) 13m 19s 11m 22s–22m 17s 11m 48s −1m 31s (−11%) ⚪ within noise
test shard (Node 24, 2/4) 14m 32s 12m 25s–15m 53s 13m 01s −1m 31s (−10%) ⚪ within noise
test shard (Node 24, 4/4) 12m 54s 11m 03s–14m 15s 11m 18s −1m 36s (−12%) ⚪ within noise
typecheck checks 10m 02s 8m 33s–11m 07s 8m 08s −1m 54s (−19%) 🟢 faster
React parity shard (3/4) 12m 46s 10m 11s–18m 01s 10m 44s −2m 02s (−16%) ⚪ within noise
heavy integration (browser - chromium) 16m 56s 12m 15s–19m 08s 12m 32s −4m 24s (−26%) ⚪ within noise

…overage

`import { type OctaneNode } from 'octane'` matched the runtime-import check
because only the `import type { … }` spelling was recognised. TypeScript erases
a named clause whose every specifier is type-marked, so a types-only module was
recorded as an exception at init, and a new one failed CI as
OCTANE_STRONG_COVERAGE_REGRESSION. A clause with a default, namespace, or
unmarked specifier still counts.

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

vercel Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

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

2 Skipped Deployments
Project Deployment Actions Updated
octane-website Skipped Skipped Oct 1, 2026 11:05pm UTC
octane-website-mcp Skipped Skipped Oct 1, 2026 11:05pm UTC

Request Review

@vercel
vercel Bot temporarily deployed to Preview – octane-website October 1, 2026 21:34 Inactive
@vercel
vercel Bot temporarily deployed to Preview – octane-website-mcp October 1, 2026 21:34 Inactive
@trueadm
trueadm marked this pull request as ready for review October 1, 2026 22:30
@vercel
vercel Bot temporarily deployed to Preview – octane-website October 1, 2026 22:45 Inactive
@vercel
vercel Bot temporarily deployed to Preview – octane-website-mcp October 1, 2026 22:45 Inactive

@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: Type-only imports with comments count as runtime
    • Added a .replace() call to strip line comments (//...) and block comments (/* ... */) from the named import clause content before splitting on commas, so comment fragments no longer cause every() to fail on fully type-erased imports.

Create PR

Or push these changes by commenting:

@cursor push 091dd1dde5
Preview (091dd1dde5)
diff --git a/packages/cli/src/commands/analyze/strong-coverage.js b/packages/cli/src/commands/analyze/strong-coverage.js
--- a/packages/cli/src/commands/analyze/strong-coverage.js
+++ b/packages/cli/src/commands/analyze/strong-coverage.js
@@ -137,6 +137,7 @@
 		const named = /^\{([\s\S]*)\}$/.exec(clause);
 		if (named === null) return true;
 		const specifiers = named[1]
+			.replace(/\/\/[^\n]*|\/\*[\s\S]*?\*\//g, '')
 			.split(',')
 			.map((specifier) => specifier.trim())
 			.filter(Boolean);

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

Reviewed by Cursor Bugbot for commit f4990f4. Configure here.

A comment inside a type-only import, such as `{ type A, /* note */ type B }`
or `import /* note */ type { A }`, was read as a runtime specifier, so a
types-only module was counted toward Strong coverage and reported as a false
OCTANE_STRONG_COVERAGE_REGRESSION. Comments are dropped before the clause is
classified.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@vercel
vercel Bot temporarily deployed to Preview – octane-website-mcp October 1, 2026 23:05 Inactive
@vercel
vercel Bot temporarily deployed to Preview – octane-website October 1, 2026 23:05 Inactive
@trueadm
trueadm merged commit 09565b4 into main Oct 2, 2026
57 of 60 checks passed
@trueadm
trueadm deleted the feat/strong-coverage-baseline branch October 2, 2026 07:27

This branch was previously deployed

2 inactive deployments
Preview – octane-website — 3c282892 Deployed Oct 1, 2026 by vercel[bot]
Preview – octane-website-mcp — 3c282892 Deployed Oct 1, 2026 by vercel[bot]
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 feat PR: new feature or capability

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant