Repository navigation
feat(cli): fail CI when a module stops compiling under Strong mode - #1515
Conversation
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]>
There was a problem hiding this comment.
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
typemodifier, soimport { type X } from 'octane'is no longer counted as a runtime import.
- Replaced bare OCTANE_IMPORT.test() with hasRuntimeOctaneImport() that checks all matched imports and verifies at least one named specifier lacks the inline
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.
Benchmark report
Compares js-framework: 1k/10k row operations (ms, lower is better)
All 20 timed operations (19 within noise)
Application bundle size (bytes)No changes across 45 measured values. Public-import reachability bundles (bytes)
102 other measured values are unchanged. CI job durations
Compares the CI run for
All 26 timed jobs
|
…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]>
|
The latest updates on your projects. Learn more about Vercel for GitHub. 2 Skipped Deployments
|
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
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 causeevery()to fail on fully type-erased imports.
- Added a
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]>


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", turncompiler.strongoff, or move code into another package, which the application'scompiler.strongdoes not reach. This PR makes that change fail CI. It is the coverage ratchet item in section D of #1027.initwritesoctane-strong-baseline.json({ "version": 1, "exceptions": [...] }), listing every module Octane compiles that is not Strong today.octane analyzerun 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 ofcompiler.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.updateonly ever removes names, andinitrefuses 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 compiler decides which modules are Strong
The CLI does not re-derive the policy.
OctaneBundlerCompilergainsstrongModuleStatus(code, id), which returns{ strong, directive, config }. It reads the directive prologue through the same parsers and the newdeclaresStrongModehelper thatstrongDirectivesnow uses, and applies the existing_hasApplicationStrongPolicy. A parity test checks the method againsttransformfor each case:node_modules'use strong'string elsewhere in the file.tshook modulesoctane/compiler/bundleralso re-exportsfindLeadingJsxImportSourcePragma, so the CLI reads module ownership with the compiler's own scanner.transformis untouched and nothing calls the new method on a build path.Which modules count
.tsrx..tsxwhose JSX goes to Octane. A leading@jsxImportSourcepragma, or the tsconfigjsxImportSource, naming another library excludes it, so React-hosted files are left out..ts/.jsfile with a runtimeoctaneimport. Type-only imports don't count..d.tsfiles are excluded.Two
octane analyzedefects fixed along the waycompiler.strongwas ignored.analyzecompiled every file with{}options, so in projects that enable Strong throughoctane.config.tsit never reported a Strong diagnostic for modules without a directive. It now evaluates the config with the project's own@octanejs/app-coreloader (moved out ofdoctorintokernel/octane-config.js) and analyzes those modules in Strong mode, as the build does.[OCTANE_STRONG_EFFECT_STATE_UPDATE] …was labelledOCTANE_PARSE_ERROR, with the file path repeated in the message. It now carries its own code, so--codecan select it.analyze.jsmoved toanalyze/index.jsnext to the newstrong-coverage.js.Validation
pnpm format:check: passed before rebasing onto currentmain.pnpm format:files:checkon the changed files passed after.pnpm typecheck: passed before rebasing. After rebasing,tsgo --noEmitpassed forpackages/cli/tsconfig.typecheck.jsonandpackages/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, includinganalyzetests 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.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, andvolar.test.ts: all pass.behavior-root.test.tsand the twooctane-evalsfiles that timed out in the full run: pass on their own."use strong"outside the prologue fails the parity test;compiler.strong, or dropping the coded-error extraction, fails the config test;updateadd regressions, or skipping stale detection, fails the stale/update test.pnpm syncproduced no generated changes.Risk / follow-ups
strongoption overridesoctane.config.tsat build time and the CLI cannot see it. The docs say to keep the setting inoctane.config.ts. Closing this fully would need the build itself to report coverage.excludeandrequireDirectiveare inline plugin options too. The ownership rule above approximates them, so an excluded file that the pragma/tsconfig rule still counts is recorded once atinit.analyzenow evaluatesoctane.config.tson every run when the file exists, asdoctoralready does. If the config cannot be evaluated, a run that needs coverage fails with the reason. Otherwiseanalyzeprints a warning and keeps its diagnostics.Provenance
agent-authored)🤖 Generated with Claude Code
Need help on this PR? Tag
@codesmith-botwith 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 initwritesoctane-strong-baseline.jsonlisting modules that compile without Strong mode; while it exists, analyze fails onOCTANE_STRONG_COVERAGE_REGRESSION(non-Strong, unlisted modules) andOCTANE_STRONG_COVERAGE_STALE(listed exceptions that are now Strong, gone, or no longer Octane-compiled).updateonly removes stale names—new exceptions require a hand-edited baseline file.The bundler compiler exposes
strongModuleStatus(code, id)(same rules astransform) plusdeclaresStrongMode; the CLI uses that andcompiler.strongfromoctane.config.tsso coverage and per-file analysis match the build.octane analyzealso compiles policy-reached modules with{ strong: true }, and thrown errors with[OCTANE_*]codes keep those codes instead ofOCTANE_PARSE_ERROR. Config loading is shared viakernel/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.