@kudzujs/core 0.8.15 → 0.8.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,72 @@
1
+ # Current Compiler Architecture
2
+
3
+ This maps the completed `0.8.17` command ModuleIR boundary. File and function names are the stable references; line numbers are intentionally omitted because Goal A moves code.
4
+
5
+ ## Responsibility Map
6
+
7
+ | Responsibility | Current owner | Current contract |
8
+ |---|---|---|
9
+ | CLI entry | [`bin/kudzu.mjs`](../../bin/kudzu.mjs) | Dispatches build and development commands. |
10
+ | Build orchestration | [`framework/build.mjs`](../../framework/build.mjs), `build()` | Loads config; discovers reachable source, CSS, and assets; compiles sources; renders routes; plans capabilities; emits `dist/`; invokes `afterBuild`. |
11
+ | Reachability/import resolution | `framework/build.mjs`, `reachableSourceFiles()`, `resolveSourceImport()` | Starts from page entries, follows relative runtime imports/re-exports and validated Worker references, and excludes unreachable migration source. |
12
+ | Ordered normalization | [`framework/compiler/normalization-pipeline.mjs`](../../framework/compiler/normalization-pipeline.mjs), `applyNormalizationPasses()`; `framework/build.mjs`, `normalizeCompilerSource()` | Applies migration/resource passes in order and repairs TypeScript parent pointers after every pass. Imported source uses the same pipeline. |
13
+ | Focused normalization passes | [`framework/compiler/`](../../framework/compiler/) | React, Router, browser signals, animation-frame refs, custom-hook timers, Zustand, and render control each validate and lower a narrow source shape. |
14
+ | Shared AST/scope helpers | [`framework/compiler/ast-helpers.mjs`](../../framework/compiler/ast-helpers.mjs) | Binding, scope, reference, effect-return, and source-location analysis. |
15
+ | Pure collection language | [`framework/compiler/collection-analysis.mjs`](../../framework/compiler/collection-analysis.mjs) | Analyzes collection roots/selectors and serializes the allowed pure expression language used by lists and derived dependencies. |
16
+ | Main semantic analysis | `framework/build.mjs`, `createKudzuTransformer()` | Still owns component specialization, hooks/state, effects, keyed-list ownership, imports, reactive JSX, and many AST-identity side tables. This is the largest remaining coupling. |
17
+ | Per-source descriptor registration | [`framework/compiler/descriptor-session.mjs`](../../framework/compiler/descriptor-session.mjs), `createSemanticArtifact()`, `createDescriptorSession()` | Registers deterministic native handler, effect handler, binding, list evaluator, and client-import descriptors into one source-local artifact. |
18
+ | Command IR and codegen | [`framework/compiler/optimize/command-specialization.mjs`](../../framework/compiler/optimize/command-specialization.mjs), [`framework/compiler/ir/module-ir.mjs`](../../framework/compiler/ir/module-ir.mjs), [`framework/compiler/codegen/command-codegen.mjs`](../../framework/compiler/codegen/command-codegen.mjs) | Supported command handlers specialize to JSON-safe ModuleIR, then emit the existing `__kBehavior` AST without changing route plans. |
19
+ | Build module generation | `framework/build.mjs`, `compile()` | Runs TypeScript with the Kudzu transformer, writes build-executable modules to `.kudzu`, rejects surviving React/Router runtime references, and generates handler source when descriptors exist. |
20
+ | Handler/evaluator codegen | [`framework/compiler/handler-codegen.mjs`](../../framework/compiler/handler-codegen.mjs) | Converts descriptor AST into browser ESM exports and rewrites state, setter, reducer, capture, and imported-helper reads. It does not discover features. |
21
+ | Worker graph | [`framework/compiler/worker-compiler.mjs`](../../framework/compiler/worker-compiler.mjs) | Validates the exact effect-owned Worker form, validates its relative graph, emits content-hashed ESM, and resolves placeholders only for rendered effects. |
22
+ | Build-time JSX execution | [`framework/core.mjs`](../../framework/core.mjs), `renderPage()` | Executes compiled pages/layouts, allocates deterministic route/layout ownership IDs, emits complete HTML, and returns the serializable route plan and capability booleans. |
23
+ | Route capability projection | [`framework/compiler/route-capability-planner.mjs`](../../framework/compiler/route-capability-planner.mjs), `planRouteCapabilities()` | Purely folds rendered route plans and route facts into aggregate runtime/artifact requirements. |
24
+ | Effect entry generation | [`framework/compiler/effect-codegen.mjs`](../../framework/compiler/effect-codegen.mjs) | Generates ordinary, dependency, owned, and navigable effect entries from rendered descriptors. |
25
+ | Runtime specialization/emission | `framework/build.mjs` | Selects runtime files and currently removes branches through feature booleans, string replacement, compile-time defines, and esbuild. |
26
+ | Browser capabilities | [`framework/*.js`](../../framework/) | Small optional modules for commands, bindings, lists, effects, native handlers, serialization, parameters, and navigation; no component runtime. |
27
+ | Opt-in navigation | [`framework/navigation-runtime.js`](../../framework/navigation-runtime.js) plus `framework/build.mjs` navigation configuration/emission | Fetches and validates complete same-origin documents, replaces only the marked route range, manages route/layout disposal, history, focus, finite prefetch retention, and native fallback. |
28
+ | Development serving | [`framework/dev-server.mjs`](../../framework/dev-server.mjs) and [`framework/dev-state.js`](../../framework/dev-state.js) | Rebuild/watch/SSE and response-only short-lived state restoration; never changes production `dist/`. |
29
+
30
+ ## Current Data Flow
31
+
32
+ ```text
33
+ src/pages entries + config
34
+ -> project discovery and reachable relative graph
35
+ -> shared ordered source normalization
36
+ -> main transformer semantic analysis
37
+ -> transformed build-time TS/TSX
38
+ -> per-source semantic artifact
39
+ -> TypeScript transpilation
40
+ -> .kudzu executable modules
41
+ -> generated handler/effect/binding/list-evaluator modules
42
+ -> import page modules and execute renderPage()
43
+ -> complete HTML
44
+ -> serializable route plan
45
+ -> referenced handler URLs and route facts
46
+ -> remove unrendered handlers/effects/Workers
47
+ -> planRouteCapabilities(route plans, route facts)
48
+ -> aggregate capability manifest
49
+ -> specialize and emit only selected runtime/capability ESM
50
+ -> write route index.html, CSS/assets, Worker graphs, rewrites, and .kudzu/kudzu-plan.json
51
+ -> optional afterBuild()
52
+ ```
53
+
54
+ The browser consumes static HTML first. State seeds and descriptors in that HTML connect only to emitted command, binding, list, native-handler, effect, parameter, or navigation modules. Browser execution patches owned DOM directly; it does not invoke component functions or reconstruct a component tree.
55
+
56
+ ## Current Coupling To Remove
57
+
58
+ - `createKudzuTransformer()` combines discovery, validation, specialization, descriptor registration, and transformed-source emission.
59
+ - Component/effect/list relationships remain in `WeakMap`/`WeakSet` tables keyed by AST identity; they cannot be moved safely until replaced by explicit results.
60
+ - `build()` destructures a broad capability manifest into many booleans and performs artifact-specific source surgery.
61
+ - Runtime specialization relies on exact source-string and regular-expression replacements in `framework/build.mjs`.
62
+ - Route facts, rendered plans, artifact requirements, and emitted-file decisions are represented at adjacent but not fully explicit boundaries.
63
+
64
+ Goal A addresses these couplings without changing source support, output semantics, or browser architecture.
65
+
66
+ ## Continuation Checklist
67
+
68
+ - [ ] Re-read every caller before moving a helper out of `framework/build.mjs`.
69
+ - [ ] Keep analysis results serializable where AST identity is not required.
70
+ - [ ] Keep AST-bearing descriptors source-local and consume them before render planning.
71
+ - [ ] Do not move tightly coupled code behind a large context object merely to reduce file size.
72
+ - [ ] Compare route plans and emitted artifacts before and after each extraction.
@@ -0,0 +1,154 @@
1
+ # Goal A: Compiler Foundation
2
+
3
+ ## Status
4
+
5
+ The `0.8.17` command vertical slice is complete. Goal A continues with the planned `0.8.18` state/props/component analysis result while preserving accepted React-shaped syntax, diagnostics, complete HTML, emitted capability behavior, and current public APIs.
6
+
7
+ ## Target Boundaries
8
+
9
+ ```text
10
+ project/build session
11
+ -> normalized source result
12
+ -> analyzed source result + transformed build module
13
+ -> rendered route plan
14
+ -> pure capability/artifact plan
15
+ -> generated artifact sources
16
+ -> filesystem emission
17
+ ```
18
+
19
+ Each arrow needs a concrete input/output contract. A file split without a reduced dependency surface does not count.
20
+
21
+ ## Minimum Kudzu IR
22
+
23
+ Goal A adds only the representation missing between normalized TypeScript AST and generated Kudzu core calls. It does not duplicate the existing serializable route plan or model a component tree.
24
+
25
+ ```js
26
+ {
27
+ version: 1,
28
+ file: "src/pages/counter.tsx",
29
+ signals: [],
30
+ handlers: [],
31
+ bindings: [],
32
+ derived: [],
33
+ effects: [],
34
+ keyedBlocks: [],
35
+ clientImports: [],
36
+ sourceLocations: []
37
+ }
38
+ ```
39
+
40
+ The active IR boundary must be JSON-safe. No `ts.Node`, `Map`, `Set`, `WeakMap`, function, closure, or Symbol crosses from analysis into optimization/codegen. Temporary AST identity remains an analyzer implementation detail until a feature receives an explicit result.
41
+
42
+ Existing representations are promoted rather than copied:
43
+
44
+ | Required concept | Canonical direction |
45
+ |---|---|
46
+ | `KudzuProgram` | Module, route, capability, and reference closure assembled only after the parts are explicit. |
47
+ | `RouteIR` | Version the existing `renderPage().plan`; do not add a second route plan. |
48
+ | `SignalIR` | Type the existing state descriptor and add an internal numeric slot plus readable debug metadata. |
49
+ | `HandlerIR` | Plain command data or a stable generated-module export reference. |
50
+ | `BindingIR` | Promote existing binding descriptors. |
51
+ | `DerivedIR` | Reuse the existing tagged Collection Expression IR. |
52
+ | `EffectIR` | Replace effect AST side tables with one explicit result when that seam is ready. |
53
+ | `KeyedBlockIR` | Promote the existing list descriptor after ownership analysis is explicit. |
54
+ | `CapabilityIR` | Reuse the current pure route capability manifest. |
55
+
56
+ A JSX tree, VDOM, component IR, retained component identity, or general expression VM is not part of Goal A.
57
+
58
+ ## First Vertical Slice
59
+
60
+ The existing command fixture is the first real `TSX -> IR -> optimization -> existing codegen` path:
61
+
62
+ ```tsx
63
+ const [count, setCount] = useState(0)
64
+ return <button onClick={() => setCount(count + 1)}>{count}</button>
65
+ ```
66
+
67
+ Analysis produces plain data:
68
+
69
+ ```js
70
+ {
71
+ signals: [{ slot: 0, key: "state:0:count", debugName: "count" }],
72
+ handlers: [{
73
+ slot: 0,
74
+ kind: "commands",
75
+ commands: [{ operation: "add", signal: 0, value: 1 }]
76
+ }]
77
+ }
78
+ ```
79
+
80
+ The `0.8.17` slice intentionally records only lexical signal identity and command handlers. Initial values, state scope, bindings, derived values, effects, and keyed blocks join ModuleIR in their later planned patches; `core.mjs` remains authoritative for those values today.
81
+
82
+ Source codegen lowers that data through the existing build ABI:
83
+
84
+ ```js
85
+ __kBehavior([["add", count, 1]])
86
+ ```
87
+
88
+ `core.mjs` remains responsible for final route/layout state IDs, complete HTML, `data-k-*` descriptors, and the route plan. The generated HTML, command runtime, plan, and asset set must remain byte-identical. The command route must not gain handler, native, effect, binding, list, or serialization modules.
89
+
90
+ ### Source Result
91
+
92
+ One source-local result owns transformed source plus the sparse ModuleIR, generated handler/effect/binding/list evaluator source, client imports, Worker references, and explicit pass metadata. AST-bearing data is consumed inside analysis/codegen and does not become IR or cross-build state.
93
+
94
+ ### Route Result
95
+
96
+ `renderPage()` remains the build-time authority for complete HTML and ownership IDs. Its serializable plan remains the behavioral source for states, events, effects, bindings, conditions, lists, parameters, and search parameters. Route-level facts such as navigability and dependency-runtime selection accompany rather than mutate that plan.
97
+
98
+ ### Artifact Plan
99
+
100
+ A pure projection determines which shared runtimes, route entries, handler modules, Worker roots, and optional branches are required. Artifact generators consume that projection; they do not rediscover syntax or inspect application AST.
101
+
102
+ ## Generator Strategy
103
+
104
+ Use the smallest generator that removes fragile source surgery:
105
+
106
+ - Keep authored browser capability modules as readable JavaScript.
107
+ - Give each generated artifact one focused generator function with an explicit manifest subset and deterministic output.
108
+ - Prefer composing imports, constants, and named source sections over a general template engine or code-generation IR.
109
+ - Move existing specialization in behavior-preserving slices; do not rewrite all runtimes at once.
110
+ - Let esbuild perform syntax lowering, dead-code elimination, bundling, defines, and minification after Kudzu chooses the capability branches.
111
+ - Preserve stable path names where they are public output behavior; preserve content-hashed Worker/chunk naming.
112
+ - Assert that requested source sections exist before replacing/removing them during transition. The end state must not depend on incidental whitespace or entire function-body string matches.
113
+
114
+ No generator may analyze TSX, invent runtime component abstractions, or broaden the capability contract.
115
+
116
+ ## Execution Rules
117
+
118
+ - One patch, one boundary, with no migration feature mixed in.
119
+ - Extract only code whose callers and outputs are understood.
120
+ - Replace AST side tables only when an explicit keyed result can preserve ownership and source diagnostics.
121
+ - Keep `build()` as orchestration; do not replace it with a service container or plugin framework.
122
+ - Preserve current runtime files until their corresponding generator has artifact parity.
123
+ - Treat deterministic byte changes as review items even when tests pass.
124
+
125
+ ## Acceptance
126
+
127
+ - Build orchestration reads as stage coordination rather than feature analysis or source generation.
128
+ - Source normalization, semantic analysis, route planning, artifact planning, generation, and writing have explicit ownership.
129
+ - Codegen consumes descriptors/manifests and does not discover compiler semantics.
130
+ - No module-global mutable analysis state or new broad context object is added.
131
+ - Static routes still emit complete HTML and zero JavaScript.
132
+ - Interactive and navigation routes preserve capability selection, ownership, stale-write, and cleanup behavior.
133
+ - Unreachable handlers, effects, package helpers, and Workers remain absent.
134
+ - Diagnostics retain source file and location.
135
+ - [`performance-gates.md`](./performance-gates.md) passes for every patch.
136
+
137
+ ## Non-Goals
138
+
139
+ - New React compatibility, hooks, routing, state, resource, or Worker forms.
140
+ - A compiler plugin API, full JSX/component-tree IR, template framework, or dependency-injection layer.
141
+ - Rewriting `framework/core.mjs` into a browser renderer.
142
+ - Optimizing browser hot paths before Goal A establishes a comparable baseline.
143
+ - React islands, hydration, or component serialization.
144
+
145
+ ## Continuation Checklist
146
+
147
+ - [ ] Confirm the next planned version in [`versioning.md`](./versioning.md).
148
+ - [ ] Write down the current producer, consumer, and artifact before changing the boundary.
149
+ - [ ] Add or retain the smallest parity check that catches descriptor/plan/output drift.
150
+ - [ ] Compare representative static, command, binding, list, effect, Worker, runtime-parameter, and navigation outputs.
151
+ - [ ] Record raw/gzip and build measurements under the protocol in [`performance-gates.md`](./performance-gates.md).
152
+ - [ ] Mark a patch complete only after behavior and output gates pass.
153
+ - [ ] Delete the previous AST-valued representation when an IR path lands; never maintain both indefinitely.
154
+ - [ ] Preserve descriptor allocation order and final state IDs unless a versioned output change is explicitly approved.
@@ -0,0 +1,59 @@
1
+ # Goal B: Optimization Benchmarks
2
+
3
+ ## Status
4
+
5
+ Deferred until Goal A is complete. Do not combine optimization with the compiler-boundary patches: structural movement would invalidate attribution and make output drift harder to review.
6
+
7
+ ## Purpose
8
+
9
+ Use matched fixtures to identify measured build, output, or browser losses after the new boundaries are stable. Goal B is evidence-led optimization, not an architecture rewrite or a framework leaderboard.
10
+
11
+ ## Baseline
12
+
13
+ At Goal A completion, record one source revision and the current maintained fixtures for:
14
+
15
+ - clean build time;
16
+ - emitted file list and deterministic hashes where applicable;
17
+ - HTML, CSS, raw/gzip JavaScript, and Worker bytes;
18
+ - static zero-JavaScript routes;
19
+ - command update, reactive binding, keyed list update/reorder/removal, dependency effect, and enhanced navigation;
20
+ - repeated ownership cycles and heap trend.
21
+
22
+ Historical figures in [`PERFORMANCE.md`](../../PERFORMANCE.md) and the top-level Goal records are provenance, not an automatic current baseline. Reproduce a fixture before using it to approve work.
23
+
24
+ ## Candidate Order
25
+
26
+ 1. Profile the largest measured loss in a maintained fixture.
27
+ 2. Separate analysis/build cost, transfer bytes, startup, selector evaluation, DOM mutation, and ownership cleanup.
28
+ 3. Change the narrowest shared path responsible for the loss.
29
+ 4. Keep the change only if repeated measurements clear the materiality rule and correctness gates.
30
+
31
+ Known historical pressure points include large keyed-list removal/reconciliation and broad runtime specialization, but neither is authorized without a reproduced current loss.
32
+
33
+ ## Benchmark Contract
34
+
35
+ - Match visible content, behavior, errors, accessibility, and navigation semantics.
36
+ - Disclose static HTML versus CSR/SSR architecture differences.
37
+ - Use one warm-up and at least seven interleaved production builds.
38
+ - Use rotating fresh browser profiles and more runs when ranges overlap.
39
+ - Record environment, source revision, raw arrays, medians, min/max or distributions, artifacts, and limitations.
40
+ - A repeatable browser median change above 5% is material; deterministic byte growth is always reviewed.
41
+
42
+ ## Rejection Rules
43
+
44
+ Reject an optimization that:
45
+
46
+ - removes complete initial HTML or zero-JavaScript exclusion;
47
+ - changes DOM identity, state lifetime, cleanup, stale-write, focus, history, or native fallback semantics;
48
+ - introduces a retained tree, scheduler, cache, generalized runtime, or public API;
49
+ - wins by omitting matched behavior or accessibility;
50
+ - cannot be reproduced outside profiler instrumentation.
51
+
52
+ ## Continuation Checklist
53
+
54
+ - [ ] Verify Goal A acceptance is complete.
55
+ - [ ] Freeze and record the post-Goal-A baseline revision.
56
+ - [ ] Select one measured loss, not a speculative hotspot.
57
+ - [ ] Add one minimal benchmark or reuse a maintained one.
58
+ - [ ] Record before/after raw arrays and artifacts.
59
+ - [ ] Revert experiments that do not clear correctness and materiality gates.
@@ -0,0 +1,50 @@
1
+ # Goal C: State And Resource Research
2
+
3
+ ## Status
4
+
5
+ Research only. There is no approved public store API, resource API, cache API, query API, scheduler, or runtime proposal.
6
+
7
+ ## Existing Model
8
+
9
+ Kudzu already has compiler-owned state slots and explicit ownership:
10
+
11
+ | Owner | Lifetime | Existing examples |
12
+ |---|---|---|
13
+ | Document | Full non-persisted document | global disposal and document listeners |
14
+ | Layout | One enhanced-navigation group session | explicitly shared state/effects |
15
+ | Route | Current complete-document route range | parameters, requests, route effects/state |
16
+ | DOM range/key path | Conditional or keyed ownership | row state/effects/refs and nested resources |
17
+
18
+ `framework/core.mjs` allocates ownership IDs and serializable plans at build time. Browser runtimes hold only logical state and direct DOM/lifecycle registrations needed by emitted capabilities. Effects own browser resources and cleanup; stale invocations are invalidated before replacement.
19
+
20
+ ## Research Questions
21
+
22
+ - Which real migration cannot be expressed with build-time data, ordinary state, layout ownership, route ownership, or one effect-owned browser resource?
23
+ - Is the missing behavior compile-time specialization, lifetime declaration, deduplication, persistence, or request coordination?
24
+ - Can a reduced conventional React fixture retain familiar source without shipping a public resource abstraction?
25
+ - What exact cancellation, stale-result, error, retry, disposal, navigation, and BFCache semantics are required?
26
+ - Can the capability be absent from unrelated routes and avoid a shared cache/scheduler?
27
+
28
+ ## Required Evidence
29
+
30
+ Before any proposal, provide:
31
+
32
+ - a real application or reduced conventional React fixture that fails today;
33
+ - the smallest unsupported source shape and current diagnostic;
34
+ - data timing and required owner lifetime;
35
+ - behavior for success, empty, failure, retry, replacement, unmount, navigation, and late completion;
36
+ - output and ownership costs;
37
+ - an explanation of why existing async build rendering, state/effects, layout ownership, native platform storage, or effect-owned resources are insufficient.
38
+
39
+ ## Decision Boundary
40
+
41
+ Research may produce notes, fixtures, measurements, or a narrow compiler-specialization proposal. It must not publish `createStore`, `resource`, `query`, cache, Provider, subscription, or scheduler APIs. A public API requires separate approval after at least two independent migration fixtures establish the same semantics and after zero-cost exclusion is demonstrated.
42
+
43
+ ## Continuation Checklist
44
+
45
+ - [ ] Keep Goal C out of Goal A implementation patches.
46
+ - [ ] Start with a failing migration fixture, not API design.
47
+ - [ ] Classify build-known, browser-only, layout-owned, route-owned, and DOM-owned data.
48
+ - [ ] Test existing compiler capabilities before proposing a new one.
49
+ - [ ] Record unresolved semantics instead of filling them with a generic runtime.
50
+ - [ ] Stop at research unless a separate implementation decision is approved.
@@ -0,0 +1,51 @@
1
+ # Goal D: Routing Compatibility Decisions
2
+
3
+ ## Status
4
+
5
+ Preserve the current model. Goal D records decisions; it does not authorize a new router.
6
+
7
+ ## Current Decision
8
+
9
+ Every emitted route is a complete HTML document. Native document navigation is the default. `kudzu.config` may explicitly group emitted routes sharing one layout identity for same-document enhancement; routes outside a group, cross-group links, unsupported matches, modified clicks, downloads, external links, failures, and redirects retain or fall back to native behavior.
10
+
11
+ Supported React Router-shaped migration remains narrow:
12
+
13
+ - static root-relative `Link` lowers to a base-prefixed native `<a>`;
14
+ - bracket runtime routes may lower direct `useParams()` to the pathname reader;
15
+ - top-level direct `useSearchParams()` reads/writes lower to URL signals and native history;
16
+ - direct nested `useNavigate()` calls lower to native `location.assign()` or `location.replace()`;
17
+ - no React Router package executes in build output or the browser.
18
+
19
+ ## Enhanced Navigation Contract
20
+
21
+ [`framework/navigation-runtime.js`](../../framework/navigation-runtime.js) receives one generated record set per configured group. It:
22
+
23
+ - intercepts only eligible same-origin group anchors;
24
+ - prefetches complete HTML into a finite link-derived cache;
25
+ - validates application, layout, route markers, and same-origin capability assets;
26
+ - disposes route ownership before replacing the marked route range;
27
+ - retains layout ownership for the group session;
28
+ - initializes pathname/search state before route effects mount;
29
+ - updates history, managed head elements, focus, scroll, and live status;
30
+ - aborts/suppresses superseded transitions and falls back to native navigation on failure.
31
+
32
+ No fragment protocol, route component registry, browser route render, or application-wide router is implied.
33
+
34
+ ## React Islands Decision
35
+
36
+ React islands remain blocked under current invariants. An island requires React execution, hydration or client rendering, a retained component tree, duplicated ownership semantics, and non-capability-specific runtime bytes. That conflicts with zero JavaScript for static routes, direct DOM ownership, compiler-specialized handlers/effects, and the prohibition on React/VDOM/hydration.
37
+
38
+ Do not add an `island`, `client:*`, hydration boundary, serialized props protocol, or React package exception. Reconsideration requires an explicit product-invariant change, not a routing compatibility patch.
39
+
40
+ ## Revisit Evidence
41
+
42
+ Routing behavior may be reconsidered only when a real migration fixture proves that complete documents plus native anchors and current opt-in groups cannot meet required behavior. The proposal must cover direct entry, reload, back/forward, base paths, query/hash, accessibility, failure fallback, ownership cleanup, static-route output, and route-specific bytes.
43
+
44
+ ## Continuation Checklist
45
+
46
+ - [ ] Preserve complete route HTML during Goal A.
47
+ - [ ] Keep navigation group configuration explicit and validated.
48
+ - [ ] Compare exact/runtime route matching and overlap diagnostics after generator changes.
49
+ - [ ] Verify ungrouped and cross-group links remain native.
50
+ - [ ] Verify route cleanup precedes replacement and layout cleanup occurs on non-persisted exit.
51
+ - [ ] Reject islands or SPA routing unless product invariants are explicitly changed first.
@@ -0,0 +1,50 @@
1
+ # Performance And Output Gates
2
+
3
+ These gates apply to every Goal A patch and later optimization work.
4
+
5
+ ## Output Parity
6
+
7
+ - Unaffected static routes emit complete HTML and zero JavaScript.
8
+ - Build-known route content remains in HTML rather than moving behind browser execution.
9
+ - Unused command, binding, list, effect, native, parameter, navigation, package-helper, and Worker capabilities remain absent.
10
+ - Route plans and `.kudzu/kudzu-plan.json` rewrites retain equivalent serializable meaning and deterministic ordering.
11
+ - Worker entries remain content-hashed, deterministic across unchanged builds, base-aware, and absent unless a rendered effect references them.
12
+ - Generated module paths, preload closure, CSS/assets, and navigation group assets change only deliberately.
13
+ - React and `react-router-dom` references never survive in build-executable or browser output.
14
+
15
+ ## Behavioral Parity
16
+
17
+ - State setters remain logically synchronous with DOM commits batched at synchronous-turn boundaries.
18
+ - Bindings and conditions patch direct DOM without rerendering components.
19
+ - Keyed rows preserve retained identity and release state/effects/refs on removal.
20
+ - Dependency effects compare with `Object.is`, clean up before rerun, and reject stale writes.
21
+ - Document, layout, route, conditional, and keyed ownership dispose exactly once.
22
+ - Enhanced navigation preserves direct entry, reload, back/forward, base, query/hash, focus, scroll, head updates, native fallback, and stale-transition suppression.
23
+
24
+ ## Measurement Protocol
25
+
26
+ For each planned patch:
27
+
28
+ 1. Record source revision, OS/hardware, Node/npm, browser when applicable, fixture, and command.
29
+ 2. Run one clean production warm-up followed by at least seven interleaved measured builds when comparing revisions.
30
+ 3. Use rotating fresh browser profiles; increase samples when ranges overlap.
31
+ 4. Record raw arrays, medians, raw/gzip bytes by artifact class, complete emitted file lists, and known limitations.
32
+ 5. Compare representative static, command-only, binding/conditional, keyed-list, effect, Worker, runtime-parameter, and navigation routes.
33
+
34
+ ## Review Thresholds
35
+
36
+ - Any unexpected deterministic byte or file-list change requires explanation.
37
+ - A repeatable browser median regression above 5% is material.
38
+ - Build-time changes above 5% are material when interleaved ranges establish the difference.
39
+ - Smaller changes still block when they violate zero-cost exclusion, determinism, identity, cleanup, or complete-HTML behavior.
40
+ - Cross-framework claims require matched content, behavior, accessibility, and explicit architecture caveats.
41
+
42
+ ## Patch Gate
43
+
44
+ - [ ] Relevant focused tests pass.
45
+ - [ ] `npm run check` passes.
46
+ - [ ] `npm test` passes.
47
+ - [ ] Representative emitted file lists are compared.
48
+ - [ ] Raw/gzip deltas are recorded and explained.
49
+ - [ ] Browser ownership/navigation checks run when affected.
50
+ - [ ] No result is presented as a release until package version, release notes, and release process actually establish it.
@@ -0,0 +1,42 @@
1
+ # Planned Version Sequence
2
+
3
+ This is an execution sequence, not release history. `0.8.16` and `0.8.17` are completed scopes represented by package/release records; later rows remain planned until their package version and release record exist.
4
+
5
+ Keep each patch behavior-preserving and independently reviewable. If a boundary proves inseparable, revise this plan before combining releases; do not silently broaden a patch.
6
+
7
+ | Planned patch | Scope | Completion evidence |
8
+ |---|---|---|
9
+ | `0.8.16` | Finish source-local descriptor, collection, command, capability, and Zustand analysis boundaries; publish the current architecture and continuation packet. | Existing descriptor order, diagnostics, transformed modules, route plans, output bytes, and benchmark graphs remain equivalent. |
10
+ | `0.8.17` | Add the sparse JSON-safe ModuleIR and move the Counter command fast path from generated AST to plain Command IR before lowering through existing codegen. | Exact command IR round-trip and byte-identical Counter module, HTML, plan, and asset set. |
11
+ | `0.8.18` | Produce explicit state, setter, props, ref, ID, and component-specialization results without changing final state allocation. | Repeated, conditional, imported, setter-adapter, Context, and reducer component ownership remains identical. |
12
+ | `0.8.19` | Promote native HandlerIR, BindingIR, and DerivedIR; codegen consumes results without rediscovering captures, states, reducers, imports, or pure expressions. | Command-only routes retain zero handler ESM; native/binding/package/reducer fixtures preserve output and diagnostics. |
13
+ | `0.8.20` | Replace keyed-list AST side tables with an explicit KeyedBlock ownership result and typed existing list descriptor. | Insert/update/reorder/remove/nested/SVG identity and exact state/effect/ref release remain unchanged. |
14
+ | `0.8.21` | Replace effect AST side tables with EffectIR covering setup, cleanup, dependencies, ownership, source, and Worker edges. | Route/layout/conditional/list lifetime, stale-write isolation, and exact resource cleanup remain unchanged. |
15
+ | `0.8.22` | Version the existing RouteIR and CapabilityIR, formalize numeric slots plus readable debug metadata, and complete the Goal A architecture/output audit. | `build.mjs` coordinates stages rather than feature semantics; all fixtures, output gates, Chrome checks, and recorded baseline pass. |
16
+
17
+ ## Sequence Rules
18
+
19
+ - Do not start Goal B optimization before `0.8.22` Goal A acceptance and baseline recording.
20
+ - Keep Goal C research out of these patches and publish no store/resource API.
21
+ - Keep Goal D behavior unchanged: complete HTML, native default, opt-in groups, no islands.
22
+ - A planned patch may ship under a different actual version only if this table and release-facing documentation are updated before release.
23
+ - Release notes describe completed facts; this file continues to describe future work.
24
+ - Internal decomposition alone does not require `0.9.0`; use a minor only for a public compiler/tooling or compatibility boundary.
25
+
26
+ ## Generator Versions
27
+
28
+ Keep `create-kudzu@0.1.101` while its template remains unchanged. Its `@kudzujs/core` range `^0.8.15` already accepts every planned Goal A patch. Publish `0.1.102` only when the template or minimum core range changes; a future `0.9.0` template must use `^0.9.0`.
29
+
30
+ ## Release Boundary
31
+
32
+ Every patch is independently revertible before publication. After npm publication, never repoint its tag; forward-fix with the next patch. Require the exact commit to pass CI, package smoke installation, registry verification, and the performance gates before starting the next ownership seam.
33
+
34
+ ## Per-Patch Continuation Checklist
35
+
36
+ - [ ] Confirm all earlier planned patches are complete or explicitly replanned.
37
+ - [ ] Inspect current uncommitted changes and preserve unrelated work.
38
+ - [ ] Name the exact producer/consumer boundary being changed.
39
+ - [ ] Keep source support and public runtime behavior unchanged.
40
+ - [ ] Apply [`performance-gates.md`](./performance-gates.md).
41
+ - [ ] Update current architecture mapping when responsibility actually moves.
42
+ - [ ] Update `RELEASES.md` only as part of a real release, never from this plan alone.
@@ -34,14 +34,19 @@ Reduced Zustand migration stores lower to one ordinary layout-lifetime state slo
34
34
  - `compiler/ast-helpers.mjs`: shared TypeScript AST traversal, scope, binding, effect-return, and source-location helpers used by compiler passes.
35
35
  - `compiler/animation-frame-pass.mjs`: effect-owned animation-frame ref validation and plain mutable effect-scope lowering.
36
36
  - `compiler/browser-signal-passes.mjs`: static media-query external-store and navigator capability-condition normalization.
37
+ - `compiler/collection-analysis.mjs`: pure collection expression IR, selector pipeline, alias, and imported-transform analysis.
38
+ - `compiler/descriptor-session.mjs`: per-source semantic artifact creation and deterministic command, handler, effect, binding, and list evaluator descriptor registration.
37
39
  - `compiler/normalization-pipeline.mjs`: ordered source normalization with parent-pointer repair after every compiler pass.
38
40
  - `compiler/react-migration-pass.mjs`: React import, memo, callback, `forwardRef`, and `useId` migration validation and lowering.
39
41
  - `compiler/custom-hook-timer-pass.mjs`: private custom-hook timeout-ref validation and compiler-owned timer-state lowering.
40
42
  - `compiler/effect-codegen.mjs`: route-specific ordinary, owned, and navigable effect entry generation.
43
+ - `compiler/optimize/command-specialization.mjs`, `compiler/ir/module-ir.mjs`, and `compiler/codegen/command-codegen.mjs`: JSON-safe command analysis, sparse per-source ModuleIR, and source-analysis-free existing behavior-call generation.
41
44
  - `compiler/handler-codegen.mjs`: route-specific native handler, reactive binding, keyed-list evaluator, and client-import module source generation.
42
45
  - `compiler/render-control-pass.mjs`: render-function early-return and exhaustive adjacent-assignment normalization.
43
46
  - `compiler/router-pass.mjs`: React Router import validation and native Link, pathname parameter, search parameter, and imperative navigation lowering.
47
+ - `compiler/route-capability-planner.mjs`: pure route-plan projection into runtime and artifact capability requirements.
44
48
  - `compiler/worker-compiler.mjs`: relative TypeScript Worker candidate validation, effect rewriting, graph validation, and content-hashed ESM emission.
49
+ - `compiler/zustand-pass.mjs`: reduced Zustand store analysis, diagnostics, and migration normalization.
45
50
  - `dev-server.mjs`: development HTTP server, source watching, rebuild serialization, SSE reloads, runtime-route fallback serving, and response-only state restoration injection.
46
51
  - `core.mjs`: server-side JSX rendering, state slots, context providers, behavior metadata, and serializable capture validation.
47
52
  - `jsx-runtime.mjs`: automatic JSX runtime used by TypeScript.
@@ -57,7 +62,7 @@ Reduced Zustand migration stores lower to one ordinary layout-lifetime state slo
57
62
  - `dev-state.js`: dev-only, short-lived logical-state snapshot validation and restoration.
58
63
  - `*.d.ts`: public TypeScript and JSX declarations.
59
64
 
60
- Compiler ownership follows four explicit stages. `build.mjs` owns project discovery, route planning, capability selection, and artifact emission. `compiler/normalization-pipeline.mjs` owns pass order and repairs parent pointers after every source transform; migration passes keep per-file state local and return additional metadata explicitly. The main transformer analyzes normalized source into handler, effect, binding, and list descriptors. The codegen modules turn those descriptors into route-specific ESM without participating in source analysis.
65
+ Compiler ownership follows four explicit stages. `build.mjs` owns project discovery, route planning, and artifact emission. `compiler/normalization-pipeline.mjs` owns pass order and repairs parent pointers after every source transform; migration passes keep per-file state local and return additional metadata explicitly. The main transformer analyzes normalized source while `compiler/descriptor-session.mjs` owns one per-source semantic artifact containing handler, effect, binding, list, and client-import descriptors. `compiler/collection-analysis.mjs` owns the shared pure collection language used by React migration, reactive expressions, effects, and keyed lists. After build-time rendering, `compiler/route-capability-planner.mjs` projects serializable route plans into one capability manifest consumed by runtime specialization and artifact emission. Codegen modules turn descriptors into route-specific ESM without participating in source analysis. The versioned continuation plan lives in `docs/next-architecture`; it adds no runtime or accepted syntax by itself.
61
66
 
62
67
  New syntax support belongs in an existing pass or a focused new pass only when a reduced migration fixture proves it. Passes must preserve source-located diagnostics, avoid module-global analysis state, and expose metadata through return values rather than AST-identity side channels. Build orchestration stays in `build.mjs`; feature-specific graph validation or code generation moves under `compiler/` when it has a stable input/output boundary.
63
68