Repository navigation
tooling: check the split runtime's rules on the concept modules - #2091
Conversation
…nds migration-only Once runtime.ts is split, the concept modules are the source of truth. On that layout `split-runtime.mjs check` now reads the modules themselves and enforces what matters going forward: module-scope initializers read only their own module's bindings, every order constraint (a driver or uninlined constant above the reads that fold or inline it) holds along the chain the modules' order links form, and every module with code stays on that chain. A test runs it on the committed modules in ci:workflow:test, and another shows it failing on a cross-module initializer read and a removed link. The map, `split`, `order` and `--suggest` are migration-only and refuse to run on the split layout; the tool header, the map comment, the facade text and CONTRIBUTING.md say so. The root factories move from the map into the tool, and the joined runtime reports each module's range and the chain. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Generated, not edited: `node scripts/split-runtime.mjs split` on the single-file runtime.ts of the split's parent with the updated map. Only the facade comment changes: the concept modules are the source to edit, and `check` enforces their rules. 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: Split order rule cannot fail
- checkSplit now computes a sourceOrder mapping from the map's module order (original single-file layout) and passes it to orderConstraints, so the source-order filter uses the correct inter-module ordering instead of the chain evaluation order that hides inverted pairs.
Or push these changes by commenting:
@cursor push b0d96c49b2
Preview (b0d96c49b2)
diff --git a/scripts/split-runtime.mjs b/scripts/split-runtime.mjs
--- a/scripts/split-runtime.mjs
+++ b/scripts/split-runtime.mjs
@@ -666,7 +666,7 @@
* bundle with the read and never folds. `inline`: a primitive `const` above a
* later read, unless Rolldown inlines it anywhere.
*/
-export function orderConstraints(model, map) {
+export function orderConstraints(model, map, { sourceOrder } = {}) {
const writers = writerIndex(model);
const reach = reachIndex(model);
// What every rendering bundle keeps: the intersection of what each root
@@ -684,7 +684,9 @@
for (const [name, r] of reader.refs) {
if (!r.read) continue;
const binding = model.unitByName.get(name);
- if (binding.order > reader.order) continue;
+ const bPos = sourceOrder?.get(binding.id) ?? binding.order;
+ const rPos = sourceOrder?.get(reader.id) ?? reader.order;
+ if (bPos > rPos) continue;
if (isMutable(binding)) {
const kept = reach(reader);
const written = (writers.get(binding.id) ?? []).some(
@@ -813,6 +815,23 @@
const moduleOf = new Map(
model.units.map((u) => [u.id, moduleAt(model.sf.statements[u.statements[0]].getStart())]),
);
+ // The joined text orders modules by evaluation chain, but the source-order
+ // filter in orderConstraints must reflect the original single-file layout.
+ // Use the map's module order (which mirrors the unsplit source) when available;
+ // fall back to the joined text order when the map does not cover the modules.
+ let sourceOrder;
+ try {
+ const map = readMap();
+ const rank = new Map(map.modules.map((m, i) => [m.name, i]));
+ if (model.units.every((u) => rank.has(moduleOf.get(u.id)))) {
+ const stride = model.sf.statements.length;
+ sourceOrder = new Map(
+ model.units.map((u) => [u.id, rank.get(moduleOf.get(u.id)) * stride + u.order]),
+ );
+ }
+ } catch {
+ /* map unavailable; model order is the fallback */
+ }
const violations = moduleRules(model, moduleOf);
const position = new Map(chain.map((m, i) => [m, i]));
const offChain = new Set(OFF_CHAIN);
@@ -825,7 +844,7 @@
offChain.add(m);
}
}
- for (const c of orderConstraints(model, { rootEntries })) {
+ for (const c of orderConstraints(model, { rootEntries }, { sourceOrder })) {
const [a, b] = [moduleOf.get(c.before.id), moduleOf.get(c.after.id)];
if (a === b || !position.has(a) || !position.has(b)) continue;
if (position.get(a) > position.get(b))You can send follow-ups to the cloud agent here.
Reviewed by Cursor Bugbot for commit fdaf44b. Configure here.
Benchmark report🟢 No byte growth, no added work, and no timing changes beyond ±3%. Compares js-framework: 1k/10k row operationsAll 20 timed operations (20 without a verdict)
All 64 work counters are unchanged. Application bundle size (bytes)No changes across 93 measured values. Public-import reachability bundles (bytes)No changes across 123 measured values. |
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
octane-website | 90e4ec8 | Commit Preview URL Branch Preview URL |
Oct 15 2026, 02:55 PM |
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
octane-website-mcp | 90e4ec8 | Commit Preview URL Branch Preview URL |
Oct 15 2026, 02:55 PM |
…ion order checkSplit fed the joined modules to orderConstraints, which keeps only the pairs whose binding already precedes its reader in the text, so a driver or uninlined constant moved below its reader dropped out and was never reported. The split check now collects every fold- or inline-dependent read, wherever it sits, and compares the binding's and reader's evaluation order, across modules and within one. The 24 reads that already came before their binding in the single-file runtime never folded and are listed in ORDER_BASELINE; an entry that comes back into order is reported so the list only shrinks. The new test relocates a driver below its folding reader and fails on the previous check. Co-Authored-By: Claude Opus 5.5 <[email protected]>


Summary
node scripts/split-runtime.mjs checknow checks the modules themselves. CI runs it throughci:workflow:test.split,orderand--suggestare migration-only, and they refuse to run on the split layout.Why
check --suggestexits with "already split", yet the docs still told people to use it for declarations added later.Changes
checkSplit()inscripts/split-runtime.mjsreads the facade andruntime/*.tsthroughbenchmarks/lib/client-runtime.mjs, which now also reports each module's range and the chain its order links form. It enforces:export {} fromorder link.scripts/split-runtime.test.mjs, which runs inci:workflow:test:--suggestfor new declarations" guidance.Validation
node scripts/split-runtime.mjs check: 34 modules in the chain, 0 violationspnpm ci:workflow:test: 434 tests, 0 failuresnode --test benchmarks/lib/client-runtime.test.mjspnpm format:files:checkon the changed filesruntime.tschanges only its facade comment. No runtime code changes, so bytes and counters are unchanged.perf-review: not applicable (tooling, plus a comment in runtime.ts)concise-code: about 120 lines of tooling and tests. The check reuses the migration's analysis and rule functions, and the joined-runtime helper, rather than adding a second analyzer.Risk / follow-ups
profile-probesis listed as off-chain in the tool.Provenance
agent-authored)🤖 Generated with Claude Code
Need help on this PR? Tag
@codesmith-botwith what you need.Note
Low Risk
Tooling and documentation only; runtime code is unchanged aside from facade comments, with new CI guardrails on module layout.
Overview
node scripts/split-runtime.mjs checknow validates the post-split layout: it joinsruntime.tswithruntime/*.ts(via extendedjoinClientRuntimemetadata) and runscheckSplit()for load/write/pure rules, evaluation-order constraints along the order-link chain, and that every code module stays on that chain. Non-checkcommands are migration-only and error if the facade is already split.ROOT_ENTRIESand anORDER_BASELINEof legacy single-file order quirks live in the tool instead of the map;orderConstraintsgainsanyOrderfor split-time checks. Docs and theruntime.tsfacade comment now say concept modules are what you edit and CI enforces the check—no runtime behavior change beyond comments.Reviewed by Cursor Bugbot for commit 90e4ec8. Bugbot is set up for automated code reviews on this repo. Configure here.