@chrona-city/ugc-kit 1.5.9 → 1.5.10

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.
Files changed (31) hide show
  1. package/README.md +79 -5
  2. package/contracts/ugc/public-runtime/v1/README.md +42 -5
  3. package/contracts/ugc/public-runtime/v1/manifest.mjs +35 -4
  4. package/contracts/ugc/public-runtime/v1/runtime-manifest.schema.json +126 -23
  5. package/contracts/ugc/public-runtime/v1/target-compatibility.test.mjs +98 -0
  6. package/docs/harness-onboarding.md +55 -12
  7. package/docs/npm-creator.md +95 -12
  8. package/docs/runtime-download.md +43 -2
  9. package/lib/creator-cli.mjs +6 -4
  10. package/lib/creator-platform.mjs +2 -1
  11. package/lib/creator-toolchain-compat.mjs +3 -0
  12. package/lib/host-ipc/distribution-node-support-contract/contracts/ugc/public-runtime/v1/manifest.mjs +198 -0
  13. package/lib/host-ipc/distribution-node-support-contract/contracts/ugc/public-runtime/v1/runtime-manifest.schema.json +854 -0
  14. package/lib/host-ipc/distribution-node-support-contract/contracts/ugc/registry/v1/conformance/js/capability-resolver.mjs +191 -0
  15. package/lib/host-ipc/host-ipc.schema.json +2 -27
  16. package/lib/host-ipc/runtime-contract.mjs +7 -3
  17. package/lib/host-ipc/source-lock.json +16 -4
  18. package/lib/local-development.mjs +5 -2
  19. package/lib/runtime-host-client.mjs +1 -0
  20. package/lib/runtime-host.mjs +10 -3
  21. package/lib/runtime-install.mjs +1 -0
  22. package/node_modules/@esbuild/darwin-x64/README.md +3 -0
  23. package/node_modules/@esbuild/darwin-x64/bin/esbuild +0 -0
  24. package/node_modules/@esbuild/darwin-x64/package.json +20 -0
  25. package/node_modules/@esbuild/linux-x64/README.md +3 -0
  26. package/node_modules/@esbuild/linux-x64/bin/esbuild +0 -0
  27. package/node_modules/@esbuild/linux-x64/package.json +20 -0
  28. package/package.json +1 -1
  29. package/public-runtime.snapshot.lock.json +8 -4
  30. package/runtime-catalog.json +8 -24
  31. /package/lib/host-ipc/{distribution-document-tool-package-contract → distribution-node-support-contract}/contracts/ugc/creator-source/v1/tool-package.schema.json +0 -0
@@ -1,5 +1,62 @@
1
1
  # Portable creator package
2
2
 
3
+ ## Current creator entry
4
+
5
+ <!-- creator-entry:start -->
6
+ <!-- Generated by tools/creator-entry-docs.mjs from the existing release profiles. -->
7
+ Inside the intended work directory, use the Testing npm entry:
8
+
9
+ ```sh
10
+ npx @chrona-city/ugc-kit@testing init
11
+ ```
12
+
13
+ The selected package defaults to **https://chrona.city** and discovers
14
+ `/site-assets/chrona-kit-current.json`. Initialization still verifies the current and immutable
15
+ metadata, exact archive and caller. npm publication alone does not prove that
16
+ the platform's download aliases, current tool policy or ordinary user flow are ready.
17
+
18
+ | Release profile | Package identity | Default platform Origin |
19
+ | --- | --- | --- |
20
+ | city | `@chrona-city/ugc-kit` | https://chrona.city |
21
+ | world | `@chrona-world/ugc-kit` | https://chrona.world |
22
+
23
+ The world row describes a separate release profile, not a public rollout claim.
24
+ npm tags select package versions; they do not change an existing project's
25
+ platform, World, permissions or private authorization. Keep existing bindings.
26
+ Local initialization must explicitly select the registered loopback platform;
27
+ it never falls back to Testing. MCP uses the verified persistent executable,
28
+ not a mutable npm tag. Installing does not authorize, upload, preview or publish a work.
29
+
30
+ Both the website archive and npm entry must resolve to the same verified release
31
+ identity. A newer npm package does not silently replace an existing MCP executable,
32
+ project binding or authorization session. Check the actual registered executable
33
+ with `chrona version`, and inspect the saved session without changing it:
34
+
35
+ ```sh
36
+ chrona auth-status --session-directory ABSOLUTE_PRIVATE_SESSION_DIRECTORY
37
+ ```
38
+
39
+ For the city profile, the returned authorization Origin and the project's
40
+ authorization, submission, review and preview links must use https://chrona.city.
41
+ If an older registration or session still selects another Origin, preserve its
42
+ receipts and unknown operations. `--replace-from` only updates the same binding;
43
+ it does not migrate a session across Origins. Select the intended platform
44
+ explicitly, complete its official authorization yourself, then verify access to
45
+ the same project before writing. Do not edit session JSON, rewrite a project ID,
46
+ re-upload content or switch accounts to hide the mismatch. The installer never
47
+ performs these authorization or submission steps automatically.
48
+
49
+ Installation metadata lists verified installation targets, not every CPU binary
50
+ bundled in the archive. Its Node version records the build environment; Runtime
51
+ support must come from the trusted Runtime declaration and real execution.
52
+ <!-- creator-entry:end -->
53
+
54
+ The published 1.5.9 archive remains immutable. These source-guide corrections
55
+ do not rewrite its bundled documentation. Historical versions and tool hashes
56
+ below describe compatibility history, not a request to downgrade, recreate a
57
+ project or change its platform. Package availability and platform availability
58
+ must be checked separately.
59
+
3
60
  ### Bind an imported Document to ordinary Creator authoring
4
61
 
5
62
  `import-presentation` prepares the original editable HTML/resources and a fixed
@@ -83,7 +140,7 @@ download minimum or a promise about another network. Reordering the same require
83
140
  download or omitting the binary does not establish a faster usable first install.
84
141
  Warm-cache and repeat-init measurements must remain separate from cold results.
85
142
 
86
- This unissued candidate bundles all six production dependency roots and their
143
+ The package bundles all six production dependency roots and their
87
144
  locked transitive dependencies, including Darwin ARM64 and Linux ARM64 esbuild.
88
145
  Development dependencies, complete City assets and the separately pinned gameplay
89
146
  runtime are not part of the npm archive. Bundling a Linux binary does not itself
@@ -112,15 +169,31 @@ the user's Home or projects.
112
169
 
113
170
  This source candidate supports `chrona init` from the intended project directory. Bundled `creator-release.json` supplies the official Testing Origin and stable release metadata URL; neither project files nor routine user input supply release hashes/URLs. The installer checks the stable metadata against its same-origin immutable copy, verifies archive bytes and caller identity, and preserves the existing durable installation and AI configuration. Home/root and ambiguous launch folders require a project choice; ambiguous AI detection requires `--harness codex|claude`. Interactive terminals ask these choices; noninteractive callers receive `selection-required`. Explicit advanced options remain available. Init does not create, upgrade or overwrite content.
114
171
 
115
- After the matching Site release exposes the stable aliases, the Testing entry is `npm exec --yes --ignore-scripts --no-audit --no-fund --no-update-notifier --package https://18.145.213.118/site-assets/chrona-kit.tgz -- chrona init`. This is not live merely because source code or a local pack passes. Only after separately authorized npm publication may testers use `npx @chrona/ugc-kit@1.3.0 init`; the `latest` channel must not point to an unverified candidate. The MCP config uses the fixed persistent executable, never a mutable npm tag. Original immutable download commands remain specific to their exact previously issued archives.
116
-
117
- The current source repair candidate is `@chrona/ugc-kit@1.5.3`; the issued `v1.5.2` source, archive and Tag remain unchanged. The issued 1.5.2 archive does not contain the historical-project compatibility repair; isolated development archives with that version text are not user releases. This candidate needs a catalog whose Darwin ARM64 and Linux ARM64 entries match its exact tool version and snapshot identity before final release verification. Until that pairing and release verification are complete, source version 1.5.3 is not a user download or published npm release. Its default original Testing platform Origin is `https://18.145.213.118`; the runtime catalog must separately pin four verified URLs at that Origin. Distribution still requires verified files at the selected origin and installation checks against the exact final archive. Use the explicitly registered local runtime source for local delivery; canonical HTTPS catalog URLs are not evidence of Testing deployment. npm registry publication is separate from creator content submission, independent review and platform publication. A fixed archive can be installed without a registry release; this does not disable `submit` or `publish --channel testing`. Those commands still require actual authorization and matching platform validation. The package does not grant an open-source license (`UNLICENSED`).
172
+ Use the profile-derived entry at the top of this guide. The selected package's
173
+ `creator-release.json` supplies its default Origin and release metadata path;
174
+ schema3 `kit-release.json` supplies the actual package/version/archive identity.
175
+ Site must derive presentation from those verified fields, not maintain a second
176
+ package/domain mapping or infer an environment from an npm tag. A metadata
177
+ endpoint failure or incompatible caller is a concrete installation failure,
178
+ not permission to silently install an older release. MCP uses the fixed persistent
179
+ executable. Its presence does not prove the user's model has called the tools.
180
+
181
+ Historical 1.5.2/1.5.3 archives, old IP aliases and legacy package names remain
182
+ specific to their original immutable releases. They are not current default
183
+ installation examples and must not be edited in place. Use the actual installed
184
+ catalog and runtime manifests for compatibility; URLs alone do not prove a
185
+ platform deployment. npm publication, creator source submission, preview and
186
+ explicit publication are separate. The package remains `UNLICENSED`.
118
187
 
119
188
  Optional [Meshy generation](meshy.md) uses your local key and explicit requests. New installation and explicit same-scope Harness replacement use the existing `init`; `--replace-from /absolute/old-install/bin/chrona.mjs` authorizes replacing only that exact existing registration. Workspace, platform and session scope must remain identical; edited/unmanaged configurations reject. No silent update occurs. Project metadata migration remains a separate `upgrade` operation. Credentials in the private user directory are not part of either installation.
120
189
 
121
190
  Runtime compatibility is determined by the project's tool/contracts locks, the trusted catalog's verified manifests and the packaged host identity. Read actual `dev/test` results; do not infer that the platform supports only an older tool version, or that every new project is compatible. `RUNTIME_CONTENT_INCOMPATIBLE` requires a matching fixed runtime or an explicitly approved project migration, not editing locks or downgrading a version label. Changing only the external runtime manifest cannot add host support. Do not modify an existing archive or report a new snapshot as an older tool version. A local tarball install is not a registry publication or a playable-content acceptance. Node 22.16 or later and Git are required. There are no install hooks or runtime downloads at installation. The original static compiler dependencies are pinned; npm may fetch those packages during installation, but does not run their hooks with the commands below.
122
191
 
123
- In a separate tools directory, install the fixed `.tgz` supplied for evaluation using `npm install --ignore-scripts /absolute/path/chrona-ugc-kit-1.3.0-alpha.1.2.tgz`. Invoke the local binary from that directory with `npm exec --offline -- chrona`; no Services or Clients checkout is required:
192
+ For an explicitly selected fixed-archive alternative, use a separate tools
193
+ directory and `npm install --ignore-scripts /absolute/path/verified-ugc-kit.tgz`.
194
+ The file must be the release's verified archive, not a development pack. Invoke
195
+ the local binary from that directory with `npm exec --offline -- chrona`; no
196
+ Services or Clients checkout is required:
124
197
 
125
198
  ```sh
126
199
  npm exec --offline -- chrona create my-world --content-id ugc.example.my-world --workspace /existing/creator/projects
@@ -131,9 +204,15 @@ npm exec --offline -- chrona capabilities
131
204
 
132
205
  This source candidate also exposes `chrona projects --workspace /existing/creator/projects` and the read-only MCP `list_ugc_projects`. The MCP uses its registered workspace, so conversational callers supply no local path. Results include the configured project itself as `projectName: "."` and initialized direct-child projects, with explicit unavailable metadata; they never select a project, prove source access, or start a runtime. The dot cannot refer to a parent or sibling directory. With platform authorization configured, `list_creator_materials` lists the selected platform project's currently authorized materials; `create_from_creator_material` downloads and verifies the selection and creates a new isolated project. The fixed earlier 0.2.13 installation does not contain these additions.
133
206
 
134
- The creator project contains content and small metadata only. In that project, use `npm install --ignore-scripts --no-save --package-lock=false /absolute/path/chrona-ugc-kit-1.3.0-alpha.1.2.tgz` to install this unpublished candidate without replacing the fixed dependency with a local path. Then use `npm run validate` and resolve `#chrona/shared` / `#chrona/client` through the installed SDK. The exact tool version and snapshot digest are pinned in `chrona.toolchain.json`; incompatible tools fail instead of selecting latest. Neither metadata nor SDK resolution grants execution permission. The platform revalidates with its own trusted Kit.
207
+ The creator project contains content and small metadata only. Its exact package
208
+ dependency, SDK import mappings and `chrona.toolchain.json` retain their original
209
+ identity. Use the normal initialized project commands; do not edit an existing
210
+ lock, replace a dependency with a local archive path or install latest to suppress
211
+ a mismatch. Inspect the explicit `chrona upgrade` plan when a supported migration
212
+ is needed. Neither metadata nor SDK resolution grants execution permission. The
213
+ platform revalidates with its own trusted Kit.
135
214
 
136
- Trusted local hosts can import `verifyLocalDevelopmentInput` and `validateLocalLaunchRequest` from `@chrona/ugc-kit/local-content`. The snapshot and launch definitions are in `contracts/ugc/local-content/v1/README.md` and `LOCAL-LAUNCH.md`; seven files are bound by `local-content.snapshot.lock.json` and the project toolchain hash. The sandbox contract snapshot is 1.2.0. The trusted public host selects local launch validation; formal execution continues to reject local identities. These exports verify offline inputs; scene compilation uses `build` below and execution requires a separately trusted runtime. Verification requires host-owned reads, a fixed expected identity and trusted policy hashes. Local validation does not grant formal review, preview membership or publication.
215
+ Trusted local hosts import `verifyLocalDevelopmentInput` and `validateLocalLaunchRequest` from the selected installed package's `/local-content` export. Resolve its package name from actual installed `package.json`, not a second scope list. Historical legacy projects keep their own exact identity. The snapshot and launch definitions are in `contracts/ugc/local-content/v1/README.md` and `LOCAL-LAUNCH.md`; the exact inventory is bound by `local-content.snapshot.lock.json` and the project toolchain hash. The trusted public host selects local launch validation; formal execution continues to reject local identities. These exports verify offline inputs; scene compilation uses `build` below and execution requires a separately trusted runtime. Verification requires host-owned reads, a fixed expected identity and trusted policy hashes. Local validation does not grant formal review, preview membership or publication.
137
216
 
138
217
  Static validate never imports creator JavaScript. Repair its structured errors and rerun. Missing required capabilities return `needs_capability` with exit code 2. Failed validation returns 1; passed returns 0. The public tool rejects reviewed-tier projects. `publish` requests independent review only; there is no native creator execution or automatic approval/publication fallback.
139
218
 
@@ -157,7 +236,7 @@ Only a complete zero-match result with `canCreateProject:true` permits offering
157
236
 
158
237
  The AI validates the work, preserves intentional changes and makes the requested real source commit. Submit through the original MCP/CLI with `expectedHead` and `idempotencyKey` omitted by default: the tool obtains or reuses the verified head, derives the key and retains both in `build/creator-upload.json`. An unchanged retry preserves the original operation; a conflict requires inspecting current source state, not forcing `none` or deleting the record. `get_creator_preflight` exposes current platform compatibility and release eligibility; submit also checks preflight before uploading. Return the actual job/Studio link and state. Uploaded or queued is not reviewed, published or playable. Preview and `publish --channel testing` request separate platform steps; npm registry availability is not their gate. Earlier fixed archives require their own supported explicit parameters and do not acquire this behavior automatically.
159
238
 
160
- ### 1.5 candidate submission slice (source only; not distributed)
239
+ ### Contribution candidates (separate from owner submission)
161
240
 
162
241
  The separate contribution candidate interface requires an existing project and a project-bound terminal authorization with `projects:read,source:read,contributions:write`. The default owner six-scope login does not include candidate write. Use `chrona login --platform ORIGIN --session-directory PRIVATE_DIR --project-id PROJECT_ID --scopes projects:read,source:read,contributions:write`, then the normal browser approval and `login-complete`. After committing a clean local work, run `chrona contribute --session-directory PRIVATE_DIR --project DIR --project-id PROJECT_ID` (optionally pin `--expected-head MAIN_SHA` and `--idempotency-key KEY`). The CLI reads the current main source head, uploads committed content through the distinct candidate blob namespace and persists the key in `build/creator-contribution.json`, never `build/creator-upload.json`.
163
242
 
@@ -171,10 +250,14 @@ When another contribution advances main, use `chrona project-source-update --ses
171
250
 
172
251
  ### Continue a work from an earlier fixed toolchain
173
252
 
174
- Source candidates containing `chrona upgrade` can explicitly migrate the fixed
175
- 0.2.13/e24f4d5d and 0.2.14/ac0cb216, bed80a0f, 334894a4 or 1c996822 toolchains, plus 1.3.0-alpha.1, 1.3.0-alpha.1.1 and 1.3.0-alpha.1.2/1d15d99b, and 1.3.0-alpha.1.3, 1.3.0-alpha.1.4 or 1.3.0-alpha.1.5/a7cde603, and 1.3.0/a7cde603, 1.4.0/a7cde603 or 1.5.0/a7cde603 or 1.5.1/a7cde603 or 1.5.2/a7cde603, to the installed 1.5.3/a7cde603 source candidate. The destination is an exact tool/contracts identity, not merely a matching package version. Content must pass the destination static contract; a successful metadata upgrade does not prove the work's runtime or platform eligibility. Previously distributed archives do
176
- not acquire this command. Check the installed `help` and the exact archive supplied
177
- by the platform; do not overwrite an old archive or install latest automatically.
253
+ `chrona upgrade` plans against the actual installed package/tool/contracts
254
+ identity and its registered historical-source compatibility rules. Read the
255
+ returned plan; neither a numeric version range nor a documentation list grants
256
+ compatibility. Historical identities and SDK mappings remain protected in the
257
+ original resolver. Content must pass the destination static contract; a metadata
258
+ upgrade does not prove Runtime or platform eligibility. Earlier archives do not
259
+ gain newer migration rules automatically. Do not overwrite an old archive or
260
+ install latest merely to bypass a source/toolchain mismatch.
178
261
 
179
262
  The Testing review snapshot uses explicit source-declaration acceptance and technical
180
263
  inspection results, not independent copyright clearance or general image moderation.
@@ -48,6 +48,47 @@ finalization or bypass the final version/source/archive checks. Release tooling,
48
48
  portable integrity, target installation and ordinary gameplay remain separate
49
49
  verification stages; an engineering source/package fixture is not an issued Kit.
50
50
 
51
+ ## Local selection failures
52
+
53
+ `dev` and `test` read the trusted catalog bundled with the CLI actually invoked,
54
+ including the executable saved in an existing MCP registration. Installing a new
55
+ package does not switch an already running MCP connection. The state directory is
56
+ a verified download/installation cache, not a search path for arbitrary runtimes.
57
+
58
+ The issued city 1.5.9 catalog declares **Node 22.16.0 exactly** for its Linux arm64
59
+ and macOS arm64 runtimes. It does not supply a Linux x64 runtime. In WSL, the
60
+ Linux process architecture is the target, not the Windows host. Node 24.1.0 is
61
+ outside these declared targets; changing only Node still cannot supply a missing
62
+ x64 runtime. These are facts about this issued catalog, not a new compatibility
63
+ rule or a promise about future releases. The pinned manifest `targets` remain
64
+ authoritative.
65
+
66
+ For a no-rebuild local path, use an already available supported arm64 environment,
67
+ its existing verified Kit installation and its Node 22.16.0 executable to run the
68
+ same snapshot through `test`. Call that Node executable and Kit binary explicitly:
69
+ a saved wrapper or MCP entry may still invoke a different Node even after a shell
70
+ version switch. No source reupload or identity/hash change is required. Passing
71
+ the target check still leaves the snapshot's full content tuple to be checked;
72
+ without that tuple, content compatibility remains unknown. This is not a command
73
+ to install Node, alter a user's registration or switch their environment.
74
+
75
+ - `RUNTIME_TARGET_UNSUPPORTED`: no catalog runtime supports the current OS,
76
+ architecture and Node version. Check `node --version` and the pinned manifest
77
+ targets. CLI installation support is not a promise that every Runtime supports
78
+ every newer Node version.
79
+ - `RUNTIME_CONTENT_INCOMPATIBLE`: a target is supported, but no declared row
80
+ matches the snapshot's builder, tool and contracts. Check the selected CLI and
81
+ actual snapshot; do not rewrite its identity, force a runtime ID or reupload to
82
+ bypass the refusal. A version difference alone does not establish semantic
83
+ incompatibility or authorize adding a compatibility row.
84
+
85
+ Both are local selection failures before creator execution, not cloud candidate
86
+ check results. An unknown error, unavailable/corrupt manifest or cancellation
87
+ retains its original failure; no automatic retry or alternate source is selected.
88
+ Existing platform/session Origins are independent of Runtime transport. Preserve
89
+ old registrations and unresolved requests; `--replace-from` below is not an
90
+ automatic cross-Origin migration or permission to edit a saved session.
91
+
51
92
  ## Explicit local distribution (same pinned runtime bytes)
52
93
 
53
94
  Runtime distribution and the creator API are separate. `--platform` never chooses a CDN.
@@ -103,7 +144,7 @@ The caller supplies a canonical, private cache directory outside creator project
103
144
 
104
145
  ## Verified installation
105
146
 
106
- `@chrona/ugc-kit/runtime-install` exports `installPinnedRuntime`, `inspectInstalledRuntime` and `verifyPublicRuntimeSnapshot`. The authoritative distribution contract is mirrored verbatim from Services in `contracts/ugc/public-runtime/v1`, bound by `public-runtime.snapshot.lock.json`; no second archive schema is maintained here. This separate installer snapshot does not change the content compiler's snapshot identity.
147
+ The selected installed package's `/runtime-install` export provides `installPinnedRuntime`, `inspectInstalledRuntime` and `verifyPublicRuntimeSnapshot`. Read its package name from actual installed `package.json`; do not hardcode a legacy scope or change a historical project's identity. The authoritative distribution contract is mirrored verbatim from Services in `contracts/ugc/public-runtime/v1`, bound by `public-runtime.snapshot.lock.json`; no second archive schema is maintained here. This separate installer snapshot does not change the content compiler's snapshot identity.
107
148
 
108
149
  Trusted platform code calls `installPinnedRuntime({cacheDirectory, installationsDirectory, lock, trustedLock, expected, offline?, signal?})`. `lock` is the project selection; `trustedLock` must come from an independently platform-managed catalog, never the same creator-controlled input used as both arguments. Exact supported targets and content toolchains come from the fixed release catalog and verified runtime manifests, not historical examples in this guide. An engineering candidate may still await its matching runtime catalog and is not thereby playable. Older installed archives retain their original catalogs; a matching version label alone is insufficient. The export is an installation primitive for the platform CLI, not a creator permission to add code URLs. Source entitlement, backend runtime installation and formal approval are separate.
109
150
 
@@ -153,7 +194,7 @@ their separate formal consumers.
153
194
 
154
195
  ## Installed host management
155
196
 
156
- `@chrona/ugc-kit/runtime-host` exports `openInstalledRuntimeHost({installationDirectory,lock,trustedLock,content,signal?,onStatus?})`. This platform-facing operation **executes the selected trusted native host**, unlike installation. Never pass a creator-controlled catalog or executable as its trusted selection. Only the exact catalog release and its supported content identities may execute. The Clients-owned IPC validator and Schema are mirrored without changes under `lib/host-ipc`, with their source commit and hashes; the distribution contract above remains the only manifest/archive authority.
197
+ The same installed package's `/runtime-host` export provides `openInstalledRuntimeHost({installationDirectory,lock,trustedLock,content,signal?,onStatus?})`. This platform-facing operation **executes the selected trusted native host**, unlike installation. Never pass a creator-controlled catalog or executable as its trusted selection. Only the exact catalog release and its supported content identities may execute. The Clients-owned IPC validator and Schema are mirrored without changes under `lib/host-ipc`, with their source commit and hashes; the distribution contract above remains the only manifest/archive authority.
157
198
 
158
199
  `content` contains the canonical absolute `snapshotRoot`, raw `snapshotManifestSha256` and complete original `expected` LocalContentSnapshot identity. The original snapshot's builder/tool version is not replaced by the calling CLI version. Before spawning, management rechecks the entire installed release, actual platform, content compatibility and request shape. The child must still verify all snapshot files, policies and sandbox eligibility; an IPC-valid request is not a content approval.
159
200
 
@@ -109,7 +109,7 @@ const messages = {
109
109
  UPGRADE_BUSY: 'Another upgrade or recovery is active. Do not remove its transaction.',
110
110
  UPGRADE_RECOVERY_REQUIRED: 'An unfinished upgrade exists. Stop editing, inspect its owner and use explicit recovery after the owner exits.',
111
111
  UPGRADE_RECOVERY_CONFLICT: 'Recovery conflicts with the committed source or current files. Preserve the transaction for operator inspection.',
112
- CREATOR_SESSION_ORIGIN_MISMATCH: 'The saved session does not match the platform fixed during initialization.',
112
+ CREATOR_SESSION_ORIGIN_MISMATCH: 'The saved session belongs to another platform. Preserve it and inspect auth-status for its Origin. Authorize the intended platform explicitly before further writes; installing or upgrading a Kit does not migrate authorization.',
113
113
  CREATOR_SESSION_SCOPE_REQUIRED: 'Uploading requires source:read, submissions:write and projects:read for live platform preflight. Preserve this session and explicitly start a new authorization in a separate private session directory with these scopes for the selected project; approve it in the browser and exchange it before retrying. No permission was added or revoked.',
114
114
  CREATOR_SESSION_PROJECT_MISMATCH: 'This authorization is restricted to another project. Select its authorized project or explicitly create a new authorization for the intended project; do not edit the saved scope or project binding.',
115
115
  CREATOR_SESSION_RENEWAL_REQUIRED: 'The existing authorization is expired, revoked or uncertain. Preserve it and explicitly configure a new authorization session.',
@@ -132,7 +132,7 @@ const messages = {
132
132
  INSTALL_RELEASE_CHANGED: 'The official current release and immutable metadata differ. No connection was written; retry after the release is consistent.',
133
133
  INVALID_HARNESS_CONFIG: 'The selected Harness configuration is not a supported regular file.',
134
134
  HARNESS_CONFIG_BUSY: 'Another initialization owns this configuration. Retry after it finishes.',
135
- HARNESS_CONFIG_CONFLICT: 'The existing Chrona or unsupported configuration must be resolved explicitly; it was preserved.',
135
+ HARNESS_CONFIG_CONFLICT: 'The existing AI registration was preserved. Inspect its executable, workspace, platform and session. Use --replace-from only for the same binding; a different platform requires an explicit registration and its own authorization, not an edited session.',
136
136
  HARNESS_CONFIG_CHANGED: 'The configuration changed during initialization. Inspect it before retrying.',
137
137
  RUNTIME_NOT_AVAILABLE: 'Isolated tests and dev require a compatible public runtime. No creator code was executed.',
138
138
  INVALID_RUNTIME_SOURCE: 'Use the packaged catalog or an explicitly selected literal loopback runtime origin with --runtime-source local --runtime-origin ORIGIN --allow-local-http true. Upload origins and project catalogs cannot supply runtime trust.',
@@ -185,6 +185,8 @@ for (const code of ['INVALID_INSTALL_RELEASE', 'INSTALL_DOWNLOAD_FAILED', 'INSTA
185
185
  'INSTALL_INVENTORY_INVALID', 'INSTALL_PLATFORM_UNSUPPORTED', 'INSTALL_NODE_UNSUPPORTED', 'INSTALL_PREREQUISITE_MISSING',
186
186
  'INSTALL_CALLER_MISMATCH', 'INSTALL_BUSY', 'INSTALL_CONFLICT', 'INSTALL_NPM_FAILED']) messages[code] = code;
187
187
  Object.assign(messages, {
188
+ RUNTIME_TARGET_UNSUPPORTED: 'The selected runtime or catalog does not support this OS, architecture and Node version. Check node --version and the selected Kit runtime targets. Preserve the project and runtime pins; do not rewrite versions. This local refusal does not describe cloud candidate checks.',
189
+ RUNTIME_CONTENT_INCOMPATIBLE: 'No selected runtime declares a matching builder, tool and contracts row for this snapshot. Check the selected CLI, snapshot and trusted runtime catalog. Preserve the source identity; do not rewrite hashes or reupload to bypass this local refusal. Cloud candidate checks are separate.',
188
190
  INVALID_RESOURCE: 'A resource declaration is missing, malformed or no longer bound to verified content. Review the indicated provenance entry before submitting; explicit author or third-party terms are not rewritten.',
189
191
  SOURCE_PROVENANCE_UPDATED: 'Testing creator declarations were updated from verified asset bytes before source freeze. Review and commit the intended content changes with your normal Git harness, then retry submit. Nothing was uploaded; no extra source questionnaire is required.',
190
192
  SOURCE_PROVENANCE_CONTROLLED_UNKNOWN: 'This imported project lacks explicit controlled scene provenance. Restore its original source-package declarations with the supported preparation path; do not relabel controlled assets as AI-generated.',
@@ -198,8 +200,8 @@ Object.assign(messages, {
198
200
  INSTALL_BUSY: 'Another initialization owns this exact installation. Wait for that process; do not delete its lock.',
199
201
  INSTALL_NPM_FAILED: 'Dependency installation failed. Check access to the public npm registry and retry the official entry; no partial program was registered.',
200
202
  INSTALL_CALLER_MISMATCH: 'The initializer and selected release package/version do not match. Preserve the installed tool and verify the explicit platform and matching release metadata. Do not downgrade to an older webpage recommendation, rename the package or rewrite hashes.',
201
- INSTALL_PLATFORM_UNSUPPORTED: 'This release has no verified installation for this system. Check the supported platforms on the official page.',
202
- INSTALL_NODE_UNSUPPORTED: 'Use a supported Node.js version of at least 22.16.0. The initializer does not upgrade your system tools.',
203
+ INSTALL_PLATFORM_UNSUPPORTED: 'This release metadata has no verified installation for this OS and architecture. Bundled native tools alone do not prove installation or Runtime support. Preserve the project; obtain a release verified for this target, without editing its metadata.',
204
+ INSTALL_NODE_UNSUPPORTED: 'The initializer requires Node.js 22.16.0 or newer; this is not a requirement to match its build Node patch. Runtime execution has its own declared support. The initializer does not change your Node installation.',
203
205
  INSTALL_PREREQUISITE_MISSING: 'Install the documented Node.js/npm and Git prerequisites, then retry. The initializer does not install system tools.',
204
206
  SOURCE_UPDATE_BASE_UNAVAILABLE: 'No verified old base is available for this project or candidate. Preserve the original project and pending key; update cannot safely infer the old main.',
205
207
  SOURCE_UPDATE_CONFLICT: 'The same files changed locally and on the new main. Review the listed paths in your original project; no file or candidate was overwritten.',
@@ -1,4 +1,5 @@
1
1
  import { parseReleaseVersion } from './release-version.mjs';
2
+ import { isCreatorPackageName } from './creator-package-identity.mjs';
2
3
 
3
4
  const fail = code => { throw Object.assign(new Error(code), { code }); };
4
5
  const exact = (v, keys) => v && typeof v === 'object' && !Array.isArray(v)
@@ -50,7 +51,7 @@ export function readPlatformPreflight(data, projectId, now = Date.now()) {
50
51
  || hashes.some(k => !hash(data[k])) || typeof data.policyId !== 'string' || !/^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/.test(data.policyId)
51
52
  || !positive(data.validUntilMs) || !positive(data.observedAtMs)) fail('INVALID_CREATOR_RESPONSE');
52
53
  const t = data.toolchain;
53
- if (!exact(t, ['package', 'schemaVersion', 'version', 'snapshotHash', 'sdk']) || t.package !== '@chrona/ugc-kit'
54
+ if (!exact(t, ['package', 'schemaVersion', 'version', 'snapshotHash', 'sdk']) || !isCreatorPackageName(t.package)
54
55
  || t.schemaVersion !== '1.0.0' || !parseReleaseVersion(t.version) || !hash(t.snapshotHash)
55
56
  || !exact(t.sdk, ['client', 'shared']) || t.sdk.client !== '#chrona/client' || t.sdk.shared !== '#chrona/shared') fail('INVALID_CREATOR_RESPONSE');
56
57
  if (!Array.isArray(data.capabilities) || data.capabilities.length > 128) fail('INVALID_CREATOR_RESPONSE');
@@ -59,6 +59,9 @@ export const registeredUpgradeSources = [{ schemaVersion: '1.0.0', package: '@ch
59
59
  sdk: { shared: '#chrona/shared', client: '#chrona/client' } },
60
60
  { schemaVersion: '1.0.0', package: '@chrona/ugc-kit', version: '1.5.8',
61
61
  snapshotHash: 'sha256:2a150f290a642e1c72c9ac887cf787a916e4a1ee6f5e25b47f1d87467198285f',
62
+ sdk: { shared: '#chrona/shared', client: '#chrona/client' } },
63
+ { schemaVersion: '1.0.0', package: '@chrona-city/ugc-kit', version: '1.5.9',
64
+ snapshotHash: 'sha256:1bc56acdc3fdac6999115526f804068c101dcc73ef5054eb2c2c3dc29e381af8',
62
65
  sdk: { shared: '#chrona/shared', client: '#chrona/client' } }];
63
66
 
64
67
  const fail = code => { throw Object.assign(new Error(code), { code }); };
@@ -0,0 +1,198 @@
1
+ import toolPackageSchema from '../../creator-source/v1/tool-package.schema.json' with { type: 'json' };
2
+ import { createHash } from 'node:crypto';
3
+ import { canonicalJson } from '../../registry/v1/conformance/js/capability-resolver.mjs';
4
+
5
+ export const runtimeHash = bytes => `sha256:${createHash('sha256').update(bytes).digest('hex')}`;
6
+ export const runtimeCanonical = canonicalJson;
7
+ export const RUNTIME_LIMITS = Object.freeze({ files: 4096, fileBytes: 33554432, totalBytes: 134217728, archiveBytes: 268435456, manifestBytes: 2097152 });
8
+ const fail = code => { throw Object.assign(new Error(code), { code }); };
9
+ const exact = (v, keys) => v && typeof v === 'object' && !Array.isArray(v) && Object.keys(v).sort().join(',') === [...keys].sort().join(',');
10
+ const digest = v => typeof v === 'string' && /^sha256:[a-f0-9]{64}$/.test(v);
11
+ const commit = v => typeof v === 'string' && /^[a-f0-9]{40}$/.test(v);
12
+ const version = v => typeof v === 'string' && /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$/.test(v);
13
+ const toolVersion = v => typeof v === 'string' && /^(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(?:-alpha\.[1-9][0-9]*(?:\.[1-9][0-9]*)?)?$(?![\s\S])/.test(v);
14
+ const bounded = (v, min, max) => Number.isSafeInteger(v) && v >= min && v <= max;
15
+ const roles = ['node', 'browser', 'sandbox', 'wasm', 'data', 'license'];
16
+
17
+ export function validRuntimePath(v, { document = false } = {}) {
18
+ const roomImplementation = document && typeof v === 'string'
19
+ && /^node\/content-room-document-authority\/services\/game-worker\/src\/runtime\/content\/[A-Za-z0-9_-][A-Za-z0-9_.-]*\.js$/.test(v);
20
+ const localExecutionImplementation = document && typeof v === 'string'
21
+ && /^node\/document-local-execution\/services\/ugc-pipeline\/src\/(?:document-local-execution|private-state-model|private-event-model|private-ecs-model|registry-release)\.mjs$/.test(v);
22
+ return typeof v === 'string' && v.length <= 512 && /^[A-Za-z0-9_@-][A-Za-z0-9_@.-]*(?:\/[A-Za-z0-9_@-][A-Za-z0-9_@.-]*)*$/.test(v)
23
+ && !v.split('/').some(p => ['credentials', 'secrets', 'private'].includes(p.toLowerCase())
24
+ || p.toLowerCase() === 'ugc-pipeline' && !localExecutionImplementation
25
+ || p.toLowerCase() === 'content' && !roomImplementation)
26
+ && !v.split('/').some(p => p.endsWith('.') || /^(con|prn|aux|nul|com[0-9]|lpt[0-9])(\.|$)/i.test(p))
27
+ && !/\.(?:pem|key|p12|pfx|glb|gltf)$/i.test(v) && !['runtime.zip', 'runtime-manifest.json'].includes(v.toLowerCase());
28
+ }
29
+
30
+ export function validateRuntimeFiles(files, { document = false } = {}) {
31
+ if (!Array.isArray(files) || !files.length || files.length > RUNTIME_LIMITS.files) fail('INVALID_RUNTIME_FILES');
32
+ let previous = '', total = 0;
33
+ const folded = new Set(), directories = new Set();
34
+ for (const f of files) {
35
+ if (!exact(f, ['path', 'bytes', 'sha256', 'role']) || !validRuntimePath(f.path, { document }) || f.path <= previous
36
+ || !digest(f.sha256) || !bounded(f.bytes, 0, RUNTIME_LIMITS.fileBytes) || !roles.includes(f.role)) fail('INVALID_RUNTIME_FILES');
37
+ const parts = f.path.toLowerCase().split('/');
38
+ if (folded.has(parts.join('/')) || directories.has(parts.join('/')) || parts.some((_, i) => folded.has(parts.slice(0, i).join('/')))) fail('INVALID_RUNTIME_FILES');
39
+ for (let i = 1; i < parts.length; i++) directories.add(parts.slice(0, i).join('/'));
40
+ folded.add(parts.join('/')); previous = f.path; total += f.bytes;
41
+ }
42
+ if (total > RUNTIME_LIMITS.totalBytes) fail('RUNTIME_PACKAGE_BUDGET_EXCEEDED');
43
+ return total;
44
+ }
45
+
46
+ export function computeRuntimeHash(value) {
47
+ const { runtimeId, runtimeHash: ignoredHash, archive, ...body } = value;
48
+ return runtimeHash(`chrona.public-runtime.v1\n${canonicalJson(body)}`);
49
+ }
50
+ export const runtimeIdentity = value => `runtime_${computeRuntimeHash(value).slice(7)}`;
51
+ export const runtimeHashFromId = value => {
52
+ if (typeof value !== 'string' || !/^runtime_[a-f0-9]{64}$/.test(value)) fail('INVALID_RUNTIME_MANIFEST');
53
+ return `sha256:${value.slice(8)}`;
54
+ };
55
+ // Actual execution observations are exact versions. A support declaration is a
56
+ // separate, versioned manifest value; neither package engines nor a report
57
+ // silently widens it. Old string targets keep their original exact semantics.
58
+ const nodeVersion = v => {
59
+ if (typeof v !== 'string' || v.length > 48 || !/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$(?![\s\S])/.test(v)) return null;
60
+ const parts = v.split('.').map(Number);
61
+ return parts.every(Number.isSafeInteger) && parts[0] > 0 ? parts : null;
62
+ };
63
+ const targetPlatform = v => ['darwin', 'linux'].includes(v.os) && ['arm64', 'x64'].includes(v.arch);
64
+ export const validateRuntimeTarget = v => Boolean(exact(v, ['os', 'arch', 'nodeVersion']) && targetPlatform(v) && nodeVersion(v.nodeVersion));
65
+ const validTarget = v => {
66
+ if (exact(v, ['os', 'arch', 'nodeVersion'])) return validateRuntimeTarget(v) && v.nodeVersion === '22.16.0';
67
+ if (!exact(v, ['os', 'arch', 'nodeSupport']) || !targetPlatform(v)
68
+ || !exact(v.nodeSupport, ['schemaVersion', 'lines']) || v.nodeSupport.schemaVersion !== '1.0.0'
69
+ || !Array.isArray(v.nodeSupport.lines) || !v.nodeSupport.lines.length || v.nodeSupport.lines.length > 4) return false;
70
+ return v.nodeSupport.lines.every((line, i, lines) => exact(line, ['major', 'minimum'])
71
+ && Number.isSafeInteger(line.major) && line.major > 0 && nodeVersion(line.minimum)?.[0] === line.major
72
+ && (!i || line.major > lines[i - 1].major));
73
+ };
74
+ const targetMatches = (declared, actual) => {
75
+ if (Object.hasOwn(declared, 'nodeVersion')) return canonicalJson(declared) === canonicalJson(actual);
76
+ const observed = nodeVersion(actual.nodeVersion);
77
+ return declared.os === actual.os && declared.arch === actual.arch && declared.nodeSupport.lines.some(line => {
78
+ if (observed[0] !== line.major) return false;
79
+ const minimum = nodeVersion(line.minimum);
80
+ return observed[1] > minimum[1] || observed[1] === minimum[1] && observed[2] >= minimum[2];
81
+ });
82
+ };
83
+ // The Host IPC and Runtime compatibility use the same exact tuple definition.
84
+ // `document` is selected from the verified snapshot/runtime variant, not a
85
+ // claim made by the child. This validates format, not source approval or access.
86
+ export function validateRuntimeContentContracts(c, { document = false } = {}) {
87
+ return exact(c, ['registryVersion', 'registryHash', 'resolutionPolicyHash', 'contractSetHashes']) && version(c.registryVersion)
88
+ && digest(c.registryHash) && digest(c.resolutionPolicyHash)
89
+ && exact(c.contractSetHashes, document ? ['localContent', 'worldScene', 'documentPresentation'] : ['localContent', 'worldScene'])
90
+ && Object.values(c.contractSetHashes).every(digest);
91
+ }
92
+ function validContentRow(row, document = false) {
93
+ if (!exact(row, ['builderVersion', 'tool', 'contracts']) || row.builderVersion !== (document ? 'local-content@1.1.0' : 'local-content@1.0.0')) return false;
94
+ const t = row.tool, c = row.contracts;
95
+ return exact(t, ['packageName', 'packageVersion', 'kitVersion', 'kitSnapshotHash']) && toolPackageSchema.enum.includes(t.packageName)
96
+ && toolVersion(t.packageVersion) && toolVersion(t.kitVersion) && digest(t.kitSnapshotHash)
97
+ && validateRuntimeContentContracts(c, { document });
98
+ }
99
+
100
+ export function validateRuntimeManifest(v) {
101
+ if (!exact(v, ['schemaVersion', 'kind', 'apiVersion', 'runtimeId', 'runtimeHash', 'executionTier', 'source', 'targets', 'compatibility', 'entrypoints', 'files', 'archive'])
102
+ || !['1.0.0', '1.1.0'].includes(v.schemaVersion) || v.kind !== 'public-local-runtime' || v.apiVersion !== '1.0.0'
103
+ || v.executionTier !== 'public-untrusted' || !/^runtime_[a-f0-9]{64}$/.test(v.runtimeId ?? '') || !digest(v.runtimeHash)) fail('INVALID_RUNTIME_MANIFEST');
104
+ validateRuntimeFiles(v.files, { document: v.schemaVersion === '1.1.0' });
105
+ const document = v.schemaVersion === '1.1.0';
106
+ const files = new Map(v.files.map(f => [f.path, f]));
107
+ const reference = (p, role) => validRuntimePath(p, { document }) && files.get(p)?.role === role;
108
+ const sourceKeys = document ? ['publicNode', 'contentRoom', 'documentAuthority'] : ['publicNode', 'publicFlight'];
109
+ if (!exact(v.source, ['clientsCommitSha', ...sourceKeys]) || !commit(v.source.clientsCommitSha)) fail('INVALID_RUNTIME_SOURCE');
110
+ for (const key of sourceKeys) {
111
+ const source = v.source[key];
112
+ if (!exact(source, ['commitSha', 'sourceHash', 'lockPath']) || !commit(source.commitSha) || !digest(source.sourceHash)
113
+ || !reference(source.lockPath, 'data')) fail('INVALID_RUNTIME_SOURCE');
114
+ }
115
+ if (new Set(sourceKeys.map(key => v.source[key].lockPath)).size !== sourceKeys.length) fail('INVALID_RUNTIME_SOURCE');
116
+ const c = v.compatibility;
117
+ if (!Array.isArray(v.targets) || !v.targets.length || v.targets.length > 4 || v.targets.some(t => !validTarget(t))
118
+ || v.targets.some((t, i) => i && canonicalJson(t) <= canonicalJson(v.targets[i - 1]))) fail('INVALID_RUNTIME_COMPATIBILITY');
119
+ if (!exact(c, ['protocol', 'content', 'policyFiles', 'localContentContract'])
120
+ || !exact(c.protocol, ['major', 'schemaRevision']) || c.protocol.major !== 1
121
+ || !(c.protocol.schemaRevision === 2 || document && c.protocol.schemaRevision === 3)
122
+ || !Array.isArray(c.content) || !c.content.length || c.content.length > 8
123
+ || !(document ? exact(c.policyFiles, ['documentPresentation']) && reference(c.policyFiles.documentPresentation, 'data')
124
+ : exact(c.policyFiles, ['worldScene', 'sceneRender']) && reference(c.policyFiles.worldScene, 'data')
125
+ && reference(c.policyFiles.sceneRender, 'data') && c.policyFiles.worldScene !== c.policyFiles.sceneRender)
126
+ || !reference(c.localContentContract, 'node')) fail('INVALID_RUNTIME_COMPATIBILITY');
127
+ let previous = '';
128
+ for (const row of c.content) {
129
+ if (!validContentRow(row, document) || canonicalJson(row) <= previous) fail('INVALID_RUNTIME_COMPATIBILITY');
130
+ previous = canonicalJson(row);
131
+ }
132
+ if (!exact(v.entrypoints, ['api', 'browser', 'sandbox'])
133
+ || v.entrypoints.api !== 'node/host.mjs' || !reference(v.entrypoints.api, 'node')
134
+ || v.entrypoints.browser !== 'web/index.html' || !reference(v.entrypoints.browser, 'browser')
135
+ || !reference('web/app.js', 'browser')
136
+ || v.entrypoints.sandbox !== (document ? 'sandbox/document-view.html' : 'sandbox/public-content-bridge.html')
137
+ || !reference(v.entrypoints.sandbox, 'sandbox')
138
+ || !document && !reference('sandbox/public-content-worker.js', 'sandbox')
139
+ || !v.files.some(f => f.role === 'wasm' && f.path.endsWith('.wasm')) || !v.files.some(f => f.role === 'license' && f.path.startsWith('licenses/'))) fail('INVALID_RUNTIME_ENTRYPOINT');
140
+ if (!exact(v.archive, ['path', 'format', 'bytes', 'sha256']) || v.archive.path !== 'runtime.zip' || v.archive.format !== 'zip-store-v1'
141
+ || !bounded(v.archive.bytes, 22, RUNTIME_LIMITS.archiveBytes) || !digest(v.archive.sha256)) fail('INVALID_RUNTIME_ARCHIVE');
142
+ const expectedBytes = 22 + v.files.reduce((n, f) => n + f.bytes + 76 + 2 * Buffer.byteLength(f.path), 0);
143
+ if (v.archive.bytes !== expectedBytes || runtimeIdentity(v) !== v.runtimeId || computeRuntimeHash(v) !== v.runtimeHash) fail('RUNTIME_PACKAGE_IDENTITY_MISMATCH');
144
+ return v;
145
+ }
146
+
147
+ export function verifyRuntimeManifest(bytes, expectedHash) {
148
+ if (!(bytes instanceof Uint8Array) || bytes.byteLength > RUNTIME_LIMITS.manifestBytes || !digest(expectedHash)
149
+ || runtimeHash(bytes) !== expectedHash) fail('RUNTIME_MANIFEST_HASH_MISMATCH');
150
+ let value;
151
+ try { value = JSON.parse(Buffer.from(bytes)); } catch { fail('INVALID_RUNTIME_MANIFEST'); }
152
+ validateRuntimeManifest(value);
153
+ if (!Buffer.from(`${canonicalJson(value)}\n`).equals(Buffer.from(bytes))) fail('INVALID_RUNTIME_MANIFEST');
154
+ return value;
155
+ }
156
+
157
+ function artifactPin(v, maximum, allowLocalHttp) {
158
+ if (!exact(v, ['url', 'bytes', 'sha256']) || !bounded(v.bytes, 1, maximum) || !digest(v.sha256) || typeof v.url !== 'string' || v.url.length > 2048) fail('INVALID_RUNTIME_LOCK');
159
+ let url;
160
+ try { url = new URL(v.url); } catch { fail('INVALID_RUNTIME_LOCK'); }
161
+ if (url.href !== v.url || url.username || url.password || url.search || url.hash
162
+ || !(url.protocol === 'https:' || allowLocalHttp && url.protocol === 'http:' && ['127.0.0.1', '[::1]'].includes(url.hostname))) fail('INVALID_RUNTIME_LOCK');
163
+ }
164
+
165
+ function validateLockShape(lock, allowLocalHttp) {
166
+ if (typeof allowLocalHttp !== 'boolean' || !exact(lock, ['schemaVersion', 'kind', 'runtimeId', 'runtimeHash', 'manifest', 'archive'])
167
+ || lock.schemaVersion !== '1.0.0' || lock.kind !== 'public-runtime-lock' || !/^runtime_[a-f0-9]{64}$/.test(lock.runtimeId ?? '')) fail('INVALID_RUNTIME_LOCK');
168
+ if (runtimeHashFromId(lock.runtimeId) !== lock.runtimeHash) fail('INVALID_RUNTIME_LOCK');
169
+ artifactPin(lock.manifest, RUNTIME_LIMITS.manifestBytes, allowLocalHttp); artifactPin(lock.archive, RUNTIME_LIMITS.archiveBytes, allowLocalHttp);
170
+ }
171
+
172
+ export function validateRuntimeLock(lock, trustedLock, { allowLocalHttp = false } = {}) {
173
+ validateLockShape(lock, allowLocalHttp);
174
+ if (!trustedLock || canonicalJson(lock) !== canonicalJson(trustedLock)) fail('UNTRUSTED_RUNTIME_LOCK');
175
+ return lock;
176
+ }
177
+
178
+ export function assertRuntimeTargetCompatibility(manifest, { target = { os: process.platform, arch: process.arch, nodeVersion: process.versions.node } } = {}) {
179
+ validateRuntimeManifest(manifest);
180
+ if (!validateRuntimeTarget(target) || !manifest.targets.some(t => targetMatches(t, target))) fail('RUNTIME_TARGET_UNSUPPORTED');
181
+ return true;
182
+ }
183
+
184
+ export function assertRuntimeCompatibility(manifest, { target, expected } = {}) {
185
+ assertRuntimeTargetCompatibility(manifest, { target });
186
+ const row = { builderVersion: expected?.builderVersion, tool: expected?.tool, contracts: expected?.contracts };
187
+ if (!validContentRow(row, manifest.schemaVersion === '1.1.0') || !manifest.compatibility.content.some(r => canonicalJson(r) === canonicalJson(row))) fail('RUNTIME_CONTENT_INCOMPATIBLE');
188
+ return true;
189
+ }
190
+
191
+ export function verifyRuntimePair(manifest, lock, expected, { target, allowLocalHttp = false } = {}) {
192
+ validateLockShape(lock, allowLocalHttp);
193
+ assertRuntimeCompatibility(manifest, { target, expected });
194
+ const bytes = Buffer.from(`${canonicalJson(manifest)}\n`);
195
+ if (manifest.runtimeId !== lock.runtimeId || manifest.runtimeHash !== lock.runtimeHash || manifest.archive.sha256 !== lock.archive.sha256
196
+ || manifest.archive.bytes !== lock.archive.bytes || bytes.length !== lock.manifest.bytes || runtimeHash(bytes) !== lock.manifest.sha256) fail('RUNTIME_PAIR_MISMATCH');
197
+ return { runtimeId: manifest.runtimeId, runtimeHash: manifest.runtimeHash, manifestSha256: lock.manifest.sha256, apiVersion: manifest.apiVersion, ready: false };
198
+ }