@ultimat3/cli 31.6.0 → 31.6.1

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.
package/CLAUDE.md CHANGED
@@ -149,7 +149,7 @@ Commands: `bun test ./packages/cli/` (repo root: the preload),
149
149
  | `page-navigation.ts` | the client router for `navigation.client` surfaces — built, routed and named ONCE for `x dev`, the container and the static export; none opted in builds nothing |
150
150
  | `page-speculation.ts` | Speculation Rules for documents WITHOUT the router (`navigation.speculation`): an allow-list of pure-read pages ‡ |
151
151
  | `static-document.ts` | a served `static` page: `304` on `If-None-Match`; container keeps the document (never `x dev`) † |
152
- | `island-{bundle,groups,outputs,build-pool,group-cache,cache-inputs,store,sources,runtime}.ts` / `island-realtime*.ts` / `solid-loader.ts` | islands, source-addressed: one `Bun.build` per route group — islands on exactly the same routes split together, every other alone; groups read from `page.tsx` sources, the one input every caller has before rendering (`islands.sharedChunks` = one group). A group's output is reused from `.x/cache/islands/` while every file it read (Sass partials included), every directory listing it resolved in and the lockfile/tsconfig/`package.json` environment hash the same (`reuse: false` for a determinism test) † |
152
+ | `island-{bundle,groups,outputs,build-pool,group-cache,cache-inputs,store,sources,runtime}.ts` / `island-realtime*.ts` / `solid-loader.ts` | islands, named by their final bytes (#1075): one `Bun.build` per route group — islands on exactly the same routes split together, every other alone; groups read from `page.tsx` sources, the one input every caller has before rendering (`islands.sharedChunks` = one group). A group's output is reused from `.x/cache/islands/` while every file it read (Sass partials included), every directory listing it resolved in and the lockfile/tsconfig/`package.json` environment hash the same (`reuse: false` for a determinism test) † |
153
153
  | `local-cli.ts` / `local-cli-handoff.ts` | a global `x` hands over to the app's own CLI (`local-cli.ts` decides whether; `x upgrade` alone stays when the app's is strictly older — `upgrade-handover.test.ts`) |
154
154
  | `serve-prebuilt.ts` / `serve-prebuilt-paths.ts` | the image's prebuilt store; a boot that built anything logs `X_IMAGE_NOT_PREBUILT` † |
155
155
  | `dev-*.ts` | `x dev` only: dashboard sources, traces, the N+1 ledger, watcher, reload, lock, port |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ultimat3/cli",
3
- "version": "31.6.0",
3
+ "version": "31.6.1",
4
4
  "description": "The `x` binary: new, dev, build, verify, generate, db, mcp, doctor, deploy",
5
5
  "keywords": [
6
6
  "ultimate",
@@ -53,34 +53,34 @@
53
53
  },
54
54
  "dependencies": {
55
55
  "@babel/core": "^8.0.9",
56
- "@ultimat3/action": "31.6.0",
57
- "@ultimat3/admin": "31.6.0",
58
- "@ultimat3/ai": "31.6.0",
59
- "@ultimat3/auth": "31.6.0",
60
- "@ultimat3/cache": "31.6.0",
61
- "@ultimat3/core": "31.6.0",
62
- "@ultimat3/db": "31.6.0",
63
- "@ultimat3/entity": "31.6.0",
64
- "@ultimat3/flags": "31.6.0",
65
- "@ultimat3/http": "31.6.0",
66
- "@ultimat3/i18n": "31.6.0",
67
- "@ultimat3/jobs": "31.6.0",
68
- "@ultimat3/mail": "31.6.0",
69
- "@ultimat3/manifest": "31.6.0",
70
- "@ultimat3/mcp": "31.6.0",
71
- "@ultimat3/money": "31.6.0",
72
- "@ultimat3/notify": "31.6.0",
73
- "@ultimat3/policy": "31.6.0",
74
- "@ultimat3/pwa": "31.6.0",
75
- "@ultimat3/query": "31.6.0",
76
- "@ultimat3/realtime": "31.6.0",
77
- "@ultimat3/render": "31.6.0",
78
- "@ultimat3/schema": "31.6.0",
79
- "@ultimat3/scraping": "31.6.0",
80
- "@ultimat3/seo": "31.6.0",
81
- "@ultimat3/storage": "31.6.0",
82
- "@ultimat3/testing": "31.6.0",
83
- "@ultimat3/time": "31.6.0",
56
+ "@ultimat3/action": "31.6.1",
57
+ "@ultimat3/admin": "31.6.1",
58
+ "@ultimat3/ai": "31.6.1",
59
+ "@ultimat3/auth": "31.6.1",
60
+ "@ultimat3/cache": "31.6.1",
61
+ "@ultimat3/core": "31.6.1",
62
+ "@ultimat3/db": "31.6.1",
63
+ "@ultimat3/entity": "31.6.1",
64
+ "@ultimat3/flags": "31.6.1",
65
+ "@ultimat3/http": "31.6.1",
66
+ "@ultimat3/i18n": "31.6.1",
67
+ "@ultimat3/jobs": "31.6.1",
68
+ "@ultimat3/mail": "31.6.1",
69
+ "@ultimat3/manifest": "31.6.1",
70
+ "@ultimat3/mcp": "31.6.1",
71
+ "@ultimat3/money": "31.6.1",
72
+ "@ultimat3/notify": "31.6.1",
73
+ "@ultimat3/policy": "31.6.1",
74
+ "@ultimat3/pwa": "31.6.1",
75
+ "@ultimat3/query": "31.6.1",
76
+ "@ultimat3/realtime": "31.6.1",
77
+ "@ultimat3/render": "31.6.1",
78
+ "@ultimat3/schema": "31.6.1",
79
+ "@ultimat3/scraping": "31.6.1",
80
+ "@ultimat3/seo": "31.6.1",
81
+ "@ultimat3/storage": "31.6.1",
82
+ "@ultimat3/testing": "31.6.1",
83
+ "@ultimat3/time": "31.6.1",
84
84
  "babel-preset-solid": "^1.9.16"
85
85
  }
86
86
  }
@@ -1,6 +1,6 @@
1
1
  // The island chunk table: every `*.island.tsx` in the app compiled as a bundle entry point,
2
- // addressed by a hash of its SOURCE GRAPH (`graphHash` — `Bun.build`'s minified output is not
3
- // byte-deterministic), plus the resolver that turns a page's `src` specifier into the URL its
2
+ // named by a hash of its final BYTES (`island-link.ts`; why not its sources: `island-identity.ts`),
3
+ // plus the resolver that turns a page's `src` specifier into the URL its
4
4
  // `data-x-entry` carries. The page's graph never reaches an island, so a `site/` document stays at
5
5
  // 0kb whatever the island imports — axiom 6 made mechanical.
6
6
  //
@@ -74,8 +74,8 @@ export interface IslandChunk {
74
74
  /** `islandModuleId` of the filename — the id the document, the budget and a finding all name. */
75
75
  readonly moduleId: string;
76
76
  /**
77
- * Immutable, source-addressed URL. What `data-x-entry` carries and what a route serves — stable
78
- * for as long as the sources, the framework version and the Bun version are. See `graphHash`.
77
+ * Immutable URL named by `contentHash(code)`. What `data-x-entry` carries and what a route
78
+ * serves — one name, one byte string, across every build that emits it (#1075).
79
79
  */
80
80
  readonly url: string;
81
81
  /** The built JavaScript. Held in memory so `x dev` and the container serve without a disk hop. */
@@ -98,7 +98,7 @@ export interface IslandChunk {
98
98
 
99
99
  /** A module two or more islands import, served once beside them. */
100
100
  export interface SharedChunk {
101
- /** `/islands/chunk-<identity>.js` — source-addressed like an entry, so `immutable` holds. */
101
+ /** `/islands/chunk-<contentHash(code)>.js` — named by its bytes, so `immutable` holds. */
102
102
  readonly url: string;
103
103
  readonly code: string;
104
104
  readonly bytes: number;
@@ -181,7 +181,7 @@ async function buildAll(
181
181
  format: 'esm',
182
182
  splitting,
183
183
  // `[dir]` keeps two islands sharing a filename apart and maps an output back to its island;
184
- // a chunk's Bun hash is only a placeholder — `island-link.ts` renames every one.
184
+ // a chunk's Bun hash is only a placeholder — `island-link.ts` renames every one by its bytes.
185
185
  naming: { entry: '[dir]/[name].[ext]', chunk: 'chunk-[hash].[ext]' },
186
186
  minify: true,
187
187
  // A build with no `plugins` is a build with no JSX transform: `Bun.plugin` installs into the
@@ -222,9 +222,9 @@ async function buildAll(
222
222
  // `x dev` serves the same chunk the container does, and bytes that depend on the ambient
223
223
  // NODE_ENV are a content hash and a byte budget measured on a build nobody ships.
224
224
  define: { 'process.env.NODE_ENV': '"production"' },
225
- // The fourth, and it is asked for its INPUT list rather than its output: `sourcesContent` is
226
- // the whole module graph each output was built from, which is the only stable identity an
227
- // output has. See `graphHash`. Measured on 1.4.0 against a 131 kB island: 277ms with it and
225
+ // The fourth, and it is asked for its INPUT list rather than its output: `sources` are the
226
+ // files each output was built from, which the island store re-checks a prebuilt chunk
227
+ // against (`island-sources.ts`). Measured on 1.4.0 against a 131 kB island: 277ms with it and
228
228
  // 276ms without, so the map costs nothing worth naming.
229
229
  sourcemap: 'external',
230
230
  // The fifth: which inputs each output carries, so one module bundled twice is refused below
@@ -27,7 +27,8 @@ import { hasPathSegment } from './path-segments';
27
27
  export const ISLAND_CACHE_DIR = '.x/cache/islands';
28
28
 
29
29
  /** Bumped when an entry's shape or meaning changes: an older entry is a miss, never a misread. */
30
- const FORMAT = 2;
30
+ // 3: URLs name the bytes (#1075); a 2 entry holds source-addressed URLs a 3 build never mints.
31
+ const FORMAT = 3;
31
32
 
32
33
  /** An entry or a partial nobody read or wrote for this long is swept. */
33
34
  const SWEEP_AFTER_MS = 14 * 86_400_000;
@@ -1,11 +1,8 @@
1
- // An island output's identity and the one byte string served under it: the source-graph hash
2
- // that names a URL (`graphHash`), the per-process pin that keeps one URL one byte string
3
- // (`stableChunk`), and the bundler-diagnostic flattening every island refusal carries. Split from
4
- // `island-bundle.ts`, which builds; `worker-bundle.ts` names its chunks by the same rules.
1
+ // What an island output is, beyond its bytes: the source map's inputs (`sourcesContentOf`), the
2
+ // per-process pin that keeps one URL one byte string (`stableChunk`), and the bundler-diagnostic
3
+ // flattening every island refusal carries. Split from `island-bundle.ts`, which builds.
5
4
 
6
- import { frameworkVersion, renderThrowable } from '@ultimat3/core';
7
- import { contentHash } from '@ultimat3/render/server';
8
- import { IslandBuildFailedError } from './errors';
5
+ import { renderThrowable } from '@ultimat3/core';
9
6
 
10
7
  /**
11
8
  * `sourcemap: 'external'` appends `//# debugId=<hex>` to the chunk. It is a pointer to a map this
@@ -21,48 +18,20 @@ export function stripDebugId(code: string): string {
21
18
  return at === -1 ? code : code.slice(0, at);
22
19
  }
23
20
 
24
- /**
25
- * The chunk's identity, computed from what went IN rather than from what came out.
26
- *
27
- * `Bun.build` was not byte-deterministic under `minify` before 1.4.1 (oven-sh/bun#40657). Measured
28
- * on 1.4.0, one entry point, no source file touched: a 131,589-byte island alternated between two
29
- * outputs of IDENTICAL length differing only in minified identifier names
30
- * (`var ca=Object.defineProperty` against `var la=…`) — roughly one build in ten, a race in the
31
- * renamer and not anything a caller can order. Hashing that output made the URL flap: ten distinct
32
- * `session-console-*.js` names in ten minutes, so a service worker's precache manifest named a
33
- * chunk that already 404ed and a browser's `immutable` cache never hit on a 131 kB download.
34
- * Fixed upstream in 1.4.1; on 1.4.2, 192 child-process build pairs of `examples/dummy`'s islands
35
- * under 12- and 16-way contention emitted one byte string per island (2026-10-05, issue #354), and
36
- * `island-bytes.test.ts` now demands byte identity outright.
37
- *
38
- * `sourcesContent`, hashed per file and SORTED, so the identity is independent of the order the
39
- * bundler happened to visit the graph in. The PATHS are deliberately not in it: they are absolute
40
- * on the build machine and would make a chunk built in a container disagree with the same chunk
41
- * built on a laptop for no difference a browser could observe. `file` is, so two islands with
42
- * byte-identical sources under different names stay two chunks; the framework version and the Bun
43
- * version are, because both decide the emitted bytes while no source file moves — an upgrade must
44
- * mint a new URL rather than leave a stale chunk pinned in a browser for a year.
45
- *
46
- * What this gives up, stated plainly: the URL is source-addressed, not byte-addressed. On a Bun
47
- * with the renamer race (< 1.4.1) two processes building the same sources served two byte-strings
48
- * at one URL — the same program under different local identifier names — and the alternative,
49
- * `minify: { identifiers: false }`, was +47% raw and +20% gzipped. The `engines` floor is now past
50
- * the fix, so the reason this function exists is gone; it is kept for now because moving every
51
- * island URL to a content hash re-keys every browser cache and every precache manifest, which is a
52
- * change of its own to make deliberately (issue #354's follow-up), not a comment edit.
53
- */
54
- export function graphHash(file: string, map: string): string {
55
- const parsed: unknown = JSON.parse(map);
56
- const contents = sourcesContentOf(parsed);
57
- if (contents === undefined) {
58
- throw new IslandBuildFailedError({
59
- file,
60
- logs: 'the bundler emitted a source map with no sourcesContent, so the chunk has no stable identity',
61
- });
62
- }
63
- const graph = contents.map((source) => contentHash(source)).sort();
64
- return contentHash([file, frameworkVersion(), Bun.version, ...graph].join('\u0000'));
65
- }
21
+ // An island output's URL is `contentHash` of the bytes served under it (`island-link.ts`), never of
22
+ // its sources. Both were tried:
23
+ //
24
+ // - Output-addressed, then flapped: `Bun.build` under `minify` was not byte-deterministic before
25
+ // 1.4.1 (oven-sh/bun#40657) — ten `session-console-*.js` names in ten minutes on 1.4.0 — so a
26
+ // precache manifest named a chunk that already 404ed (19.2.0). Fixed upstream; on 1.4.2, 192
27
+ // contended build pairs of `examples/dummy`'s islands emitted one byte string per island (#354),
28
+ // and `island-determinism.test.ts` holds it.
29
+ // - Source-addressed, then served the wrong program (#1075): the minifier names a shared chunk's
30
+ // exports by how often the WHOLE build uses them, so editing one entry swapped two export
31
+ // names in a chunk whose sources had not moved. One URL, two byte strings, `immutable` — and a CDN handed
32
+ // the next build's islands the action client where they imported the query client.
33
+ //
34
+ // A flapping name costs a cache miss; a stuck one ships a broken page. So the name is the bytes.
66
35
 
67
36
  /**
68
37
  * `sourcesContent`, read the way `aggregatedErrors` below reads `errors`: narrowed first,
@@ -89,7 +58,9 @@ export function sourcesContentOf(
89
58
  }
90
59
 
91
60
  /**
92
- * The code this process already emitted for these inputs, or the code it just built.
61
+ * The code this process already emitted under this identity, or the code it just built. Every
62
+ * caller's identity is now `contentHash(code)`, so a hit is these bytes again: the table pins
63
+ * nothing the name does not, and `bytes` is measured here, once, on what is served.
93
64
  *
94
65
  * Keyed by PATH and validated by the input hash, `transformIslandTsx`'s cache's shape and for its
95
66
  * reason: one entry per island bounds the map by the island count, which is the only quantity that
@@ -104,7 +75,7 @@ export function clearIslandChunkCache(): void {
104
75
 
105
76
  /**
106
77
  * `graph`, never `hash`: `bun run secret-compare` reads the NAME of a comparison's operands, and a
107
- * value called `hash` is a digest an attacker may be probing. This one is a build input's
78
+ * value called `hash` is a digest an attacker may be probing. This one is a build output's
108
79
  * identity — the same reason `pr-threads.ts` calls a review state `wanted`.
109
80
  */
110
81
  export function stableChunk(
@@ -1,14 +1,15 @@
1
1
  // One split `Bun.build` of every island, turned into the files a browser fetches: an entry per
2
- // island and a chunk per module two or more islands share, each named by its SOURCE identity and
3
- // importing the others by that name. `island-bundle.ts` runs the build; this file only links.
2
+ // island and a chunk per module two or more islands share, each named by a hash of its FINAL
3
+ // bytes and importing the others by that name. `island-bundle.ts` runs the build; this only links.
4
4
  //
5
- // Why the names are rewritten rather than taken from Bun's `chunk-[hash]`: that hash is of the
6
- // OUTPUT, and `Bun.build` under `minify` is not byte-deterministic (`graphHash` in
7
- // `island-bundle.ts` has the measurement). An output-addressed shared chunk flaps its URL, and
8
- // every entry importing it flaps with it — the precache-404 and cold-cache defect, back.
5
+ // Why the names are rewritten rather than taken from Bun's `chunk-[hash]`: every import of another
6
+ // output is rewritten here, so Bun's hash is of bytes no browser receives. And why the hash is of
7
+ // the OUTPUT, never the sources (#1075): the minifier names a shared chunk's exports by how often
8
+ // the WHOLE build uses them, so an edit to one entry swapped `var g=q(…),y=Fe(…)` for
9
+ // `var y=q(…),g=Fe(…)` in a chunk whose sources had not moved. Named by its sources, it kept its
10
+ // URL, and a CDN holding the old copy under `immutable` handed the new islands the wrong export.
9
11
 
10
12
  import { posix } from 'node:path'; // why: Bun ships no path API; `basename` of a specifier.
11
- import { frameworkVersion } from '@ultimat3/core';
12
13
  import { contentHash } from '@ultimat3/render/server';
13
14
  import { IslandBuildFailedError } from './errors';
14
15
 
@@ -20,15 +21,13 @@ export interface BuiltOutput {
20
21
  readonly file?: string;
21
22
  /** Emitted code, the debug-id comment already removed. */
22
23
  readonly code: string;
23
- /** Its source map's `sourcesContent` — empty for a chunk of bundler runtime helpers only. */
24
- readonly sources: readonly string[];
25
24
  }
26
25
 
27
26
  export interface LinkedFile {
28
27
  /** The output this came from, so the caller can pair it with its island. */
29
28
  readonly path: string;
30
29
  readonly file?: string;
31
- /** `chunk-<identity>` for a shared chunk; the caller prefixes an entry with its module id. */
30
+ /** `contentHash(code)`: `chunk-<identity>` shared, `<moduleId>-<identity>` an entry. */
32
31
  readonly identity: string;
33
32
  /** The code with every import of another output rewritten to that output's final name. */
34
33
  readonly code: string;
@@ -42,97 +41,65 @@ export const sharedChunkName = (identity: string): string => `chunk-${identity}.
42
41
  /** Static imports and `import()` both: a browser fetches either before the island is whole. */
43
42
  const LOADS = new Set(['import-statement', 'dynamic-import']);
44
43
 
45
- interface Scanned {
46
- readonly exports: readonly string[];
47
- /** Specifiers exactly as written, each naming another output of this build. */
48
- readonly specifiers: readonly string[];
49
- }
50
-
51
- function scan(code: string, byName: ReadonlyMap<string, BuiltOutput>): Scanned {
44
+ /** Specifiers exactly as written, each naming another output of this build. */
45
+ function specifiersOf(code: string, byName: ReadonlyMap<string, BuiltOutput>): readonly string[] {
52
46
  const scanned = new Bun.Transpiler({ loader: 'js' }).scan(code);
53
47
  const specifiers = scanned.imports
54
48
  .filter((one) => LOADS.has(one.kind) && byName.has(posix.basename(one.path)))
55
49
  .map((one) => one.path);
56
- return { exports: [...scanned.exports].sort(), specifiers: [...new Set(specifiers)] };
50
+ return [...new Set(specifiers)];
57
51
  }
58
52
 
59
53
  /**
60
- * Every output's identity, from what went in: its own sources (hashed and sorted, as `graphHash`
61
- * does), its EXPORT names, and the identities of every output it imports. The exports are in it
62
- * because they are the link between two files built together — an importer's `import{a as o}`
63
- * is only correct against a chunk exporting `a`, so a chunk whose interface moved must not keep a
64
- * URL an older importer is holding. The imports are in it because an entry's bytes NAME its
65
- * chunks: a moved chunk moves every entry that loads it.
54
+ * Every output linked, leaves first: an output's bytes NAME the chunks it imports, so its final
55
+ * code — and so its name — exists only once theirs do. The identity is `contentHash` of exactly the
56
+ * code returned, so one name is one byte string across every build that ever emits it.
66
57
  */
67
58
  export function linkOutputs(outputs: readonly BuiltOutput[]): readonly LinkedFile[] {
68
59
  const byName = new Map(outputs.map((one) => [posix.basename(one.path), one]));
69
- const scans = new Map(outputs.map((one) => [one.path, scan(one.code, byName)]));
70
- const identities = new Map<string, string>();
60
+ const linked = new Map<string, LinkedFile>();
71
61
  const visiting = new Set<string>();
72
62
 
73
- const identityOf = (output: BuiltOutput): string => {
74
- const known = identities.get(output.path);
63
+ const link = (output: BuiltOutput): LinkedFile => {
64
+ const known = linked.get(output.path);
75
65
  if (known !== undefined) return known;
76
66
  if (visiting.has(output.path)) throw cycle(output);
77
67
  visiting.add(output.path);
78
- const scanned = scans.get(output.path) ?? { exports: [], specifiers: [] };
79
- const deps = scanned.specifiers
80
- .map((spec) => byName.get(posix.basename(spec)))
81
- .filter((dep): dep is BuiltOutput => dep !== undefined)
82
- .map(identityOf)
83
- .sort();
84
- // A chunk of bundler runtime helpers has no source file behind it — its code IS its source.
85
- const own = output.sources.length === 0 ? [contentHash(output.code)] : output.sources;
86
- const identity = contentHash(
87
- [
88
- output.file ?? 'shared',
89
- frameworkVersion(),
90
- Bun.version,
91
- ...own.map((source) => contentHash(source)).sort(),
92
- 'exports',
93
- ...scanned.exports,
94
- 'imports',
95
- ...deps,
96
- ].join('\u0000'),
97
- );
98
- visiting.delete(output.path);
99
- identities.set(output.path, identity);
100
- return identity;
101
- };
102
-
103
- return outputs.map((output) => {
104
- const identity = identityOf(output);
105
- const scanned = scans.get(output.path) ?? { exports: [], specifiers: [] };
106
68
  let code = output.code;
107
69
  const imports: string[] = [];
108
- for (const spec of scanned.specifiers) {
70
+ for (const spec of specifiersOf(output.code, byName)) {
109
71
  const dep = byName.get(posix.basename(spec));
110
72
  if (dep === undefined) continue;
111
- const name = sharedChunkName(identityOf(dep));
73
+ const name = sharedChunkName(link(dep).identity);
112
74
  imports.push(name);
113
75
  // The quoted literal, whole: Bun writes every specifier double-quoted, and a chunk name is a
114
76
  // hash no program text contains by accident. Relative, so it resolves beside the importer
115
77
  // under any base path — `/islands/` served, a temp directory in `mountIsland`.
116
78
  code = code.split(JSON.stringify(spec)).join(JSON.stringify(`./${name}`));
117
79
  }
118
- return {
80
+ const done: LinkedFile = {
119
81
  path: output.path,
120
82
  ...(output.file === undefined ? {} : { file: output.file }),
121
- identity,
83
+ identity: contentHash(code),
122
84
  code,
123
85
  imports: [...new Set(imports)].sort(),
124
86
  };
125
- });
87
+ visiting.delete(output.path);
88
+ linked.set(output.path, done);
89
+ return done;
90
+ };
91
+
92
+ return outputs.map(link);
126
93
  }
127
94
 
128
95
  /**
129
- * Two outputs importing each other: esbuild-family splitting does not emit one, and an identity
130
- * built from its imports' identities has no answer for it. Refused by name rather than answered
131
- * with a hash that silently ignores an edge.
96
+ * Two outputs importing each other: esbuild-family splitting does not emit one between chunks, and
97
+ * a name that is a hash of bytes containing the other's name has no answer for it. Refused by
98
+ * name rather than answered with a name that ignores an edge.
132
99
  */
133
100
  function cycle(output: BuiltOutput): IslandBuildFailedError {
134
101
  return new IslandBuildFailedError({
135
102
  file: output.file ?? output.path,
136
- logs: `the island build emitted a chunk import cycle through ${output.path}, so its outputs have no source identity to be named by`,
103
+ logs: `the island build emitted a chunk import cycle through ${output.path}, so its outputs cannot each be named by their own bytes`,
137
104
  });
138
105
  }
@@ -59,14 +59,13 @@ export async function builtOutputs(
59
59
  if (sources === undefined || (artifact.kind === 'entry-point' && file === undefined)) {
60
60
  throw new IslandBuildFailedError({
61
61
  file: file ?? key,
62
- logs: `the bundler emitted ${key} with no source map or no island behind it, so the output has no stable identity`,
62
+ logs: `the bundler emitted ${key} with no source map or no island behind it, so the files it was built from are unknown`,
63
63
  });
64
64
  }
65
65
  outputs.push({
66
66
  path: key,
67
67
  ...(file === undefined ? {} : { file }),
68
68
  code: stripDebugId(await artifact.text()),
69
- sources,
70
69
  });
71
70
  }
72
71
  return outputs;
@@ -117,10 +116,7 @@ export function entryChunks(
117
116
  file,
118
117
  moduleId,
119
118
  url: `${ISLAND_BASE_PATH}/${moduleId}-${entry.identity}.js`,
120
- // The FIRST bytes this process emitted for these inputs, so a URL served `immutable` answers
121
- // one byte string for as long as the process lives. Without it `x dev` re-mints the chunk on
122
- // every watcher tick and a browser holding the previous one under `max-age=31536000` has two
123
- // different files at one address. `bytes` is measured on THAT code, never on this build's.
119
+ // The identity IS `contentHash(entry.code)` (`island-link.ts`), so the URL names these bytes.
124
120
  ...stableChunk(file, entry.identity, entry.code),
125
121
  imports: closure(entry.imports),
126
122
  sources: withOwnFile(file, sources.get(entry.path) ?? []),
@@ -82,9 +82,7 @@ const entrySource = (file: string, follows: boolean): string =>
82
82
  /**
83
83
  * The install names `@ultimat3/realtime` BARE, and `islandRealtimePlugin` resolves it from the
84
84
  * ISLAND's own directory — the resolution the island itself gets — so the bundle holds one copy
85
- * and the signal lands where the hooks read it. Never the resolved absolute path spliced in: this
86
- * source is part of the chunk's `sourcesContent`, which is what `graphHash` names the URL from, so
87
- * a path in it gave the same island a different URL in every checkout and every image build.
85
+ * and the signal lands where the hooks read it.
88
86
  * `solid-js` goes through `island-solid-dedupe.ts` like every other import in the graph.
89
87
  *
90
88
  * The await comes first: no hook may run before the page runtime is installed, and the module
@@ -1,16 +1,17 @@
1
1
  // The page runtime as ONE chunk beside the islands (#505): realtime's `page-runtime.ts` — the store,
2
- // the socket stack, the query client, core's transport — built once per build, addressed by its
3
- // source graph like any island, and loaded by a realtime island only on a document the page boot
2
+ // the socket stack, the query client, core's transport — built once per build, named by its
3
+ // bytes like any island, and loaded by a realtime island only on a document the page boot
4
4
  // is absent from. Islands carry thin hooks over it; none carries a copy of it.
5
5
 
6
6
  // why: Bun ships no path API; the runtime is resolved beside the realtime the islands bundle.
7
7
  import { dirname, join } from 'node:path';
8
+ import { contentHash } from '@ultimat3/render/server';
8
9
  import type { BunPlugin } from 'bun';
9
10
  import { IslandBuildFailedError } from './errors';
10
11
  import type { IslandChunk, SharedChunk } from './island-bundle';
11
12
  import { inputFiles } from './island-cache-inputs';
12
13
  import { realSpelling } from './island-duplicates';
13
- import { describeBuildError, graphHash, stableChunk, stripDebugId } from './island-identity';
14
+ import { describeBuildError, stableChunk, stripDebugId } from './island-identity';
14
15
  import { frameworkDedupePlugins } from './island-package-dedupe';
15
16
  import type { SourcePaths } from './island-sources';
16
17
  import { sourcesOnDisk } from './island-sources';
@@ -147,7 +148,7 @@ async function buildRuntime(
147
148
  minify: true,
148
149
  plugins: [runtimeEntryPlugin(file), ...frameworkDedupePlugins(root)],
149
150
  // `island-bundle.ts`'s reasons, verbatim: only ever built to be shipped, and the map's
150
- // `sourcesContent` is the one stable identity a minified bundle has.
151
+ // sources are what the island store re-checks a prebuilt chunk against.
151
152
  define: { 'process.env.NODE_ENV': '"production"' },
152
153
  sourcemap: 'external',
153
154
  metafile: true,
@@ -164,13 +165,15 @@ async function buildRuntime(
164
165
  });
165
166
  }
166
167
  const text = await map.text();
167
- const identity = graphHash(ENTRY, text);
168
+ // Named by its bytes (#1075), as every island output is: `immutable` is a promise about them.
169
+ const code = stripDebugId(await output.text());
170
+ const identity = contentHash(code);
168
171
  const url = `${basePath}/page-runtime.${identity}.js`;
169
172
  return {
170
173
  realtime,
171
174
  wait,
172
175
  url,
173
- ...stableChunk(url, identity, stripDebugId(await output.text())),
176
+ ...stableChunk(url, identity, code),
174
177
  sources: await sourcesOnDisk(root, JSON.parse(text)),
175
178
  inputs: await inputFiles(Object.keys(built.metafile?.inputs ?? {})),
176
179
  };
@@ -178,8 +181,8 @@ async function buildRuntime(
178
181
 
179
182
  /**
180
183
  * The entry installs the runtime as its whole body; the module is named BARE in that source and
181
- * resolved here, because the source is part of `sourcesContent` and a machine path in it would give
182
- * one runtime a different URL in every checkout (the reason `island-realtime.ts` names realtime).
184
+ * resolved here, the reason `island-realtime.ts` names realtime: resolved from where the islands
185
+ * resolve it, it is the one copy they bundle.
183
186
  */
184
187
  function runtimeEntryPlugin(file: string): BunPlugin {
185
188
  return {
package/src/page-sync.ts CHANGED
@@ -34,7 +34,7 @@ export interface PageSync {
34
34
 
35
35
  /**
36
36
  * Built at boot and never on the watcher tick: the worker is framework code, not the app's, and a
37
- * worker that changes under tabs already running it is exactly what a source-addressed URL exists
37
+ * worker that changes under tabs already running it is exactly what a byte-addressed URL exists
38
38
  * to keep from happening mid-session.
39
39
  */
40
40
  export async function pageSync(
@@ -69,7 +69,7 @@ export interface ServiceWorkerInput {
69
69
  /**
70
70
  * The page's framework scripts — realtime's page boot and sync worker (`pageSync(…).scripts`), and
71
71
  * the client router when a surface opted in (`pageNavigation(…).script`).
72
- * Precached beside the island chunks for their reason: source-addressed and `immutable`, and an
72
+ * Precached beside the island chunks for their reason: byte-addressed and `immutable`, and an
73
73
  * offline reload that cannot load the boot restores no record and shows the old count.
74
74
  */
75
75
  readonly scripts?: readonly { readonly url: string; readonly bytes: number }[];
@@ -1,5 +1,5 @@
1
1
  // The page's framework scripts (plan 101), each built as its own classic-script browser bundle,
2
- // addressed by a hash of its source graph, served `immutable` by the same route in `x dev` and the
2
+ // named by a hash of its bytes, served `immutable` by the same route in `x dev` and the
3
3
  // container: the ONE sync worker (`@ultimat3/realtime/sync-worker`, slice 11) and the ONE page boot
4
4
  // (`@ultimat3/realtime/boot` — the disk restore and the outbox, once per page instead of once per
5
5
  // island). A new deploy is a new URL, so an old tab keeps what it started with.
@@ -8,9 +8,10 @@
8
8
  import { dirname, join, relative } from 'node:path';
9
9
  import type { Route, UltimateRequest } from '@ultimat3/http';
10
10
  import { applyCacheHeaders, jsonResponse, NO_STORE, textResponse } from '@ultimat3/http';
11
+ import { contentHash } from '@ultimat3/render/server';
11
12
  import { assetRouteMeta } from './asset-route-meta';
12
13
  import { FrameworkScriptBuildFailedError, type FrameworkScriptKind } from './errors';
13
- import { describeBuildError, graphHash, stripDebugId } from './island-identity';
14
+ import { describeBuildError } from './island-identity';
14
15
 
15
16
  /**
16
17
  * The ONE prefix every framework-served, content-addressed script lives under — the sync worker,
@@ -128,10 +129,8 @@ async function buildFrameworkScript(
128
129
  format: 'iife',
129
130
  splitting: false,
130
131
  minify: true,
131
- // `island-bundle.ts`'s reasons, verbatim: a chunk is only ever built to be shipped, and the
132
- // map's `sourcesContent` is the one stable identity a minified bundle has.
132
+ // `island-bundle.ts`'s reason, verbatim: a chunk is only ever built to be shipped.
133
133
  define: { 'process.env.NODE_ENV': '"production"' },
134
- sourcemap: 'external',
135
134
  });
136
135
  } catch (error) {
137
136
  throw new FrameworkScriptBuildFailedError({
@@ -141,17 +140,17 @@ async function buildFrameworkScript(
141
140
  });
142
141
  }
143
142
  const output = built.outputs.find((artifact) => artifact.kind === 'entry-point');
144
- const map = built.outputs.find((artifact) => artifact.kind === 'sourcemap');
145
- if (!built.success || output === undefined || map === undefined) {
143
+ if (!built.success || output === undefined) {
146
144
  throw new FrameworkScriptBuildFailedError({
147
145
  what,
148
146
  entry: label,
149
147
  logs: built.logs.map((log) => String(log)).join('; '),
150
148
  });
151
149
  }
152
- const code = stripDebugId(await output.text());
150
+ const code = await output.text();
153
151
  return {
154
- url: `${basePath}/${graphHash(specifier, await map.text())}.js`,
152
+ // Named by its bytes (#1075): served `immutable`, so the name must change whenever they do.
153
+ url: `${basePath}/${contentHash(code)}.js`,
155
154
  code,
156
155
  bytes: new TextEncoder().encode(code).byteLength,
157
156
  };
package/wiki/Upgrading.md CHANGED
@@ -211,6 +211,7 @@ A setter still on a package's `.` barrel is `X_ADAPTER_PORT_INCOMPLETE` on the `
211
211
  | `x verify`'s `contract-diff` step is red, `X_MANIFEST_BREAKING`, on a breaking change that `x manifest` or `x g` had already written into `x.manifest.json`: from **31.6.0** the baseline is the manifest as committed (at `HEAD`, or at the merge base with `origin/$GITHUB_BASE_REF` in a GitHub pull request), never the working-tree file | bump the major version, or restore the removed surface. Regenerating the manifest no longer clears it |
212
212
  | `x verify`'s `unit` step runs the app's seeds on the memory driver (**31.6.0**): a seed row the entity refuses — float money, a value its schema rejects — turns `unit` red under the entity's own code, and a seed that throws with no code is `X_SEED_FAILED` | fix the seed row the finding names, as its `fix:` says. Then `x verify --only unit` |
213
213
  | `x verify`'s `errors` step reports `X_ERROR_FIX_INVALID` on an app's own error whose `fix:` defers the edit (a whitespace-delimited `# after <verb>ing …` or `# once <…>ed`), only says re-run, or runs `x g … --force` (**31.6.0**) | rewrite that `fix:` as the edit itself (`edit <path>.<ext>:<line> — <instruction>`) or a command that works on its own, with no `--force` |
214
+ | every island and `/_x/assets` URL changes once (**31.6.1**): each is now named by a hash of its final bytes, never its sources (#1075) | nothing to do; a CDN in front needs no purge, since new names never collide with old ones |
214
215
 
215
216
  ## 29.x → 30.0.0, entry by entry
216
217