@aikdna/kdna-core 0.37.6 → 0.37.8

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 (39) hide show
  1. package/README.md +21 -15
  2. package/package.json +6 -1
  3. package/src/public-contract/browser-native/sections/contract.json +139 -2
  4. package/src/public-contract/browserwhole06/contract.json +2 -2
  5. package/src/public-contract/creation06/contract.json +2 -2
  6. package/src/public-contract/creation06/generation-manifest.json +7 -7
  7. package/src/public-contract/execution06/contract.json +2 -2
  8. package/src/public-contract/execution06/generation-manifest.json +7 -7
  9. package/src/public-contract/issuer-contract.generated.json +4 -4
  10. package/src/public-contract/issuer-validators.generated.js +7 -7
  11. package/src/public-contract/key-grant-issuer-node.d.ts +1 -1
  12. package/src/public-contract/migration06/contract.json +1155 -0
  13. package/src/public-contract/migration06/types.d.ts +41 -0
  14. package/src/public-contract/migration06/validators.cjs +8691 -0
  15. package/src/public-contract/package-set-contract.generated.json +5 -5
  16. package/src/public-contract/package-set-node.d.ts +1 -1
  17. package/src/public-contract/package-set-validators.generated.js +9 -9
  18. package/src/public-contract/packageset06/contract.json +2 -2
  19. package/src/public-contract/packageset06/generation-manifest.json +7 -7
  20. package/src/public-contract/protected-browser-contract/contract.json +4 -4
  21. package/src/public-contract/protected-browser-contract/descriptor.json +1 -1
  22. package/src/public-contract/protected-source-contract.generated.json +6 -6
  23. package/src/public-contract/protected-source-node.d.ts +1 -1
  24. package/src/public-contract/protection-contract.generated.json +6 -6
  25. package/src/public-contract/protection-node.d.ts +2 -2
  26. package/src/public-contract/protection-validators.generated.js +5 -5
  27. package/src/public-contract/retained/contract.json +2 -2
  28. package/src/public-contract/retained/generation-manifest.json +7 -7
  29. package/src/public-contract/retained-browser06/contract.json +2 -2
  30. package/src/public-contract/sectionbytes/contract.json +2 -2
  31. package/src/public-contract/sectionbytes/generation-manifest.json +7 -7
  32. package/src/public-contract/sections/contract.json +139 -2
  33. package/src/public-contract/sections/generation-manifest.json +9 -9
  34. package/src/public-contract/source-migration-node.d.ts +14 -0
  35. package/src/public-contract/source-migration-node.js +253 -0
  36. package/src/public-contract/source-migration-node.mjs +2 -0
  37. package/src/public-contract/source-route-capture.js +1 -1
  38. package/src/public-contract/source-validators.generated.js +6 -6
  39. package/src/public-contract/source06/contract.json +2 -2
@@ -2,8 +2,8 @@
2
2
  "candidate_only": true,
3
3
  "source": {
4
4
  "path": "specs/public-semantic-source.json",
5
- "bytes": 1509417,
6
- "sha256": "63393386af28f33b19d88fa3acdc98e825e91ee78c3e850a95427a32b6087623"
5
+ "bytes": 1541192,
6
+ "sha256": "97019a7d806b8f4be570855f549fa97cb6c293771f6a3d0a439bc03f39fe4367"
7
7
  },
8
8
  "historical_original_source": {
9
9
  "scope": "historical_original_contract_source_identity_not_current_generator_input",
@@ -3,14 +3,14 @@
3
3
  "candidate_only": true,
4
4
  "source": {
5
5
  "path": "specs/public-semantic-source.json",
6
- "bytes": 1509417,
7
- "sha256": "63393386af28f33b19d88fa3acdc98e825e91ee78c3e850a95427a32b6087623"
6
+ "bytes": 1541192,
7
+ "sha256": "97019a7d806b8f4be570855f549fa97cb6c293771f6a3d0a439bc03f39fe4367"
8
8
  },
9
9
  "producer": {
10
10
  "recipe": {
11
11
  "path": "scripts/public-contract/native-output-recipe.json",
12
- "bytes": 164001,
13
- "sha256": "22ffb30bdd7a5498913ac041405b3d109f22f6fc79b3972b8ae2a8cf3a83f478"
12
+ "bytes": 168167,
13
+ "sha256": "73e48bcebfce225b6a76f1324e152500df2031721e09f72f3a60588db31eb2ac"
14
14
  },
15
15
  "scripts": [
16
16
  {
@@ -20,8 +20,8 @@
20
20
  },
21
21
  {
22
22
  "path": "scripts/public-contract/native-renderer.mjs",
23
- "bytes": 21439,
24
- "sha256": "750e968d0d88908f7c6b6b3d017039919049e22060203a7c721c3204522c211e"
23
+ "bytes": 22518,
24
+ "sha256": "672e3afe5e519f3103345157af721e083a40790769e3878d415534880719b11d"
25
25
  },
26
26
  {
27
27
  "path": "scripts/public-contract/generation-writer.mjs",
@@ -618,7 +618,7 @@
618
618
  {
619
619
  "path": "packages/kdna-core/src/public-contract/retained/contract.json",
620
620
  "bytes": 291233,
621
- "sha256": "3f75b5f8cf08d99faccd2dcb3eb7fcba368aacaede889ebb95528f66e1c2535d"
621
+ "sha256": "0e2f144e27ba4816225ad2946e2851b22a0eeb62d3074eb82689622d36c0948b"
622
622
  },
623
623
  {
624
624
  "path": "packages/kdna-core/src/public-contract/retained/api.d.ts",
@@ -2,8 +2,8 @@
2
2
  "candidate_only": true,
3
3
  "source": {
4
4
  "path": "specs/public-semantic-source.json",
5
- "bytes": 1509417,
6
- "sha256": "63393386af28f33b19d88fa3acdc98e825e91ee78c3e850a95427a32b6087623"
5
+ "bytes": 1541192,
6
+ "sha256": "97019a7d806b8f4be570855f549fa97cb6c293771f6a3d0a439bc03f39fe4367"
7
7
  },
8
8
  "historical_original_source": {
9
9
  "scope": "historical_original_contract_source_identity_not_current_generator_input",
@@ -2,8 +2,8 @@
2
2
  "candidate_only": true,
3
3
  "source": {
4
4
  "path": "specs/public-semantic-source.json",
5
- "bytes": 1509417,
6
- "sha256": "63393386af28f33b19d88fa3acdc98e825e91ee78c3e850a95427a32b6087623"
5
+ "bytes": 1541192,
6
+ "sha256": "97019a7d806b8f4be570855f549fa97cb6c293771f6a3d0a439bc03f39fe4367"
7
7
  },
8
8
  "historical_original_source": {
9
9
  "scope": "historical_original_contract_source_identity_not_current_generator_input",
@@ -3,14 +3,14 @@
3
3
  "candidate_only": true,
4
4
  "source": {
5
5
  "path": "specs/public-semantic-source.json",
6
- "bytes": 1509417,
7
- "sha256": "63393386af28f33b19d88fa3acdc98e825e91ee78c3e850a95427a32b6087623"
6
+ "bytes": 1541192,
7
+ "sha256": "97019a7d806b8f4be570855f549fa97cb6c293771f6a3d0a439bc03f39fe4367"
8
8
  },
9
9
  "producer": {
10
10
  "recipe": {
11
11
  "path": "scripts/public-contract/native-output-recipe.json",
12
- "bytes": 164001,
13
- "sha256": "22ffb30bdd7a5498913ac041405b3d109f22f6fc79b3972b8ae2a8cf3a83f478"
12
+ "bytes": 168167,
13
+ "sha256": "73e48bcebfce225b6a76f1324e152500df2031721e09f72f3a60588db31eb2ac"
14
14
  },
15
15
  "scripts": [
16
16
  {
@@ -20,8 +20,8 @@
20
20
  },
21
21
  {
22
22
  "path": "scripts/public-contract/native-renderer.mjs",
23
- "bytes": 21439,
24
- "sha256": "750e968d0d88908f7c6b6b3d017039919049e22060203a7c721c3204522c211e"
23
+ "bytes": 22518,
24
+ "sha256": "672e3afe5e519f3103345157af721e083a40790769e3878d415534880719b11d"
25
25
  },
26
26
  {
27
27
  "path": "scripts/public-contract/generation-writer.mjs",
@@ -124,7 +124,7 @@
124
124
  {
125
125
  "path": "packages/kdna-core/src/public-contract/sectionbytes/contract.json",
126
126
  "bytes": 31759,
127
- "sha256": "adb7c735e68f9bf72b7b3be19c9b38f5940989aae8e2da6ead3a375fcdeeb159"
127
+ "sha256": "0f2b09ff07731bb77ffb26cf4038bd27346875fd328e4e004146129dbc4e6a0f"
128
128
  },
129
129
  {
130
130
  "path": "packages/kdna-core/src/public-contract/sectionbytes/api.d.ts",
@@ -2,8 +2,8 @@
2
2
  "candidate_only": true,
3
3
  "source": {
4
4
  "path": "specs/public-semantic-source.json",
5
- "bytes": 1509417,
6
- "sha256": "63393386af28f33b19d88fa3acdc98e825e91ee78c3e850a95427a32b6087623"
5
+ "bytes": 1541192,
6
+ "sha256": "97019a7d806b8f4be570855f549fa97cb6c293771f6a3d0a439bc03f39fe4367"
7
7
  },
8
8
  "historical_original_source": {
9
9
  "scope": "historical_original_contract_source_identity_not_current_generator_input",
@@ -1119,6 +1119,143 @@
1119
1119
  "No protected range savings or performance claim is implied; every initial mode incurs complete authentication and domain validation cost."
1120
1120
  ],
1121
1121
  "api_typescript_context": "All new generated types are locally declared/exported in this subpath declaration closure; original ProtectedAdmissionOptions/TrustedProtectionProvider imported explicitly from original protection-node. Read imports every local signature type explicitly in addition to reexport. Opaque declarations use independent private unique symbols; no JSON-callable constructor can mint operation/snapshot/delivery authority."
1122
+ },
1123
+ "a22_source_migration": {
1124
+ "candidate_only": true,
1125
+ "counterexample": "A 0.5 payload.kdnab container and a 0.6 sections container are separate generations. Neither admission path converts, dual-reads or falls back for the other; an explicit migration operation is the only bridge, and it must never be produced by an implicit rewrite inside any admission.",
1126
+ "versions": {
1127
+ "migration_route": "kdna.source-migration/0.1.0-candidate",
1128
+ "source_generation": {
1129
+ "container": "0.5.0",
1130
+ "payload_profile": "kdna.payload.judgment",
1131
+ "payload_version": "0.5.1",
1132
+ "core": "kdna.core/0.8.2",
1133
+ "ir": "kdna.canonical-ir/0.6.1",
1134
+ "runtime": "kdna.runtime-capsule/0.3.1",
1135
+ "plan": "kdna.consumption-plan/0.3.1",
1136
+ "host": "kdna.agent-host/0.3.1",
1137
+ "trace": "kdna.judgment-trace/0.3.1",
1138
+ "read": "kdna.read/0.6.4"
1139
+ },
1140
+ "output_tuple": {
1141
+ "container": "0.6.0",
1142
+ "payload_profile": "kdna.payload.judgment",
1143
+ "payload_version": "0.5.1",
1144
+ "core": "kdna.core/0.8.2",
1145
+ "ir": "kdna.canonical-ir/0.6.1",
1146
+ "runtime": "kdna.runtime-capsule/0.3.1",
1147
+ "plan": "kdna.consumption-plan/0.3.1",
1148
+ "host": "kdna.agent-host/0.3.1",
1149
+ "trace": "kdna.judgment-trace/0.3.1",
1150
+ "read": "kdna.read/0.7.0-candidate"
1151
+ },
1152
+ "unchanged": [
1153
+ "Payload profile, payload_version, core, ir, runtime, plan, host and trace keep their existing definitions; only the container representation coordinate and the reading-contract coordinate move, per version_decisions.",
1154
+ "authoring_workflow/2 and the classic 0.5 admission path stay exact and are reused, never re-branded.",
1155
+ "This route never converts the nine historical tuples and never touches protected or encrypted sources; those are named capability refusals here and, if ever wanted, separate later units."
1156
+ ]
1157
+ },
1158
+ "precedence": "This adds an explicit migration operation on its own subpath only. It does not add a decoder, fallback or dual-read to any admission path, does not change 0.5 or 0.6 admission/Read behavior, does not manufacture old-format brands, does not reinterpret field_retention or version_decisions, and does not make representation_origin valid input for other routes. The creation route's rule that it must not manufacture representation_origin stays exact; this route is the declared producer of that slot.",
1159
+ "native_exports": {
1160
+ "@aikdna/kdna-core/source-migration-node": [
1161
+ "admitSourceMigrationRequest",
1162
+ "inspectSourceMigrationRequest",
1163
+ "createNativeSourceMigrationAuthority",
1164
+ "migratePublicSourceNode"
1165
+ ]
1166
+ },
1167
+ "api_typescript": "import type { CandidateVersionTuple06, RepresentationOrigin06 } from './sections/types.js';\nimport type { Payload } from './types.js';\nimport type { SourceOuterCapture06, SourceRouteCoreRejected06, SourceRouteMemberInventory06 } from './types.js';\nexport type SourceMigrationRequest06 = Readonly<{ request_id: string; tuple: CandidateVersionTuple06; operation: 'migrate_public_source'; source_expected_A: string; timeout_ms: number; signature_policy: Readonly<{ requireSignature: false; expectedPublicKeyHex: null }> }>;\nexport type SourceMigrationCaptureRow06 = Readonly<{ name: string; type: 'file'; mode: number; size: number }>;\nexport type SourceMigrationAuthorityContext06 = Readonly<{ contract: SourceMigrationRouteContract06; request: SourceMigrationRequest06; request_digest: string; capture: SourceOuterCapture06; source_inventory: ReadonlyArray<SourceMigrationCaptureRow06>; output_intent: Readonly<{ container: '0.6.0'; read: 'kdna.read/0.7.0-candidate'; adoption: 'not_observed' }> }>;\nexport type SourceMigrationObservation06 = Readonly<{ contract: SourceMigrationRouteContract06; request_digest: string; capture_id: string; tuple: CandidateVersionTuple06; source_A: string; source_content_digest: string; source_inventory: ReadonlyArray<SourceRouteMemberInventory06>; output: Readonly<{ A: string; C: string; E: string }>; E_profile: 'kdna.digest-basis.runtime-entry-set/0.3.0-candidate'; output_ir_digest: string; member_actions: ReadonlyArray<Readonly<{ name: string; action: 'added' | 'removed' | 'replaced' | 'preserved' }>>; origin: RepresentationOrigin06; body_bytes: number }>;\nexport type SourceMigrationFailure06 = Readonly<{ status: 'source_failed'; diagnostic: Readonly<{ code: string; stage: string }>; disclosure: unknown; body: null; body_bytes: 0 }>;\nexport type NativeSourceMigrationProduced06 = Readonly<{ status: 'migrated'; bytes: Uint8Array; observation: SourceMigrationObservation06 }> | SourceMigrationFailure06 | SourceRouteCoreRejected06;\nexport declare function admitSourceMigrationRequest(candidate: unknown): SourceMigrationRequestAdmission06;\nexport declare function inspectSourceMigrationRequest(request: AdmittedSourceMigrationRequest06): Readonly<SourceMigrationRequest06> | null;\nexport declare function createNativeSourceMigrationAuthority(callback: (context: Readonly<SourceMigrationAuthorityContext06>) => boolean | Promise<boolean>): NativeSourceMigrationAuthority06;\nexport declare function migratePublicSourceNode(input: string | Uint8Array, request: AdmittedSourceMigrationRequest06, authority: NativeSourceMigrationAuthority06): Promise<NativeSourceMigrationProduced06>;\nexport type SourceMigrationRouteContract06 = Readonly<{ id: 'kdna.source-migration/0.1.0-candidate'; version: '0.1.0-candidate'; definition_digest: string }>;\n",
1168
+ "generation_roots": {
1169
+ "AdmittedSourceMigrationRequest06": "candidate/migration06/AdmittedSourceMigrationRequest06.schema.json",
1170
+ "NativeSourceMigrationAuthority06": "candidate/migration06/NativeSourceMigrationAuthority06.schema.json",
1171
+ "SourceMigrationAuthorityContext06": "candidate/migration06/SourceMigrationAuthorityContext06.schema.json",
1172
+ "SourceMigrationCaptureRow06": "candidate/migration06/SourceMigrationCaptureRow06.schema.json",
1173
+ "SourceMigrationDiagnostic06": "candidate/migration06/SourceMigrationDiagnostic06.schema.json",
1174
+ "SourceMigrationFailure06": "candidate/migration06/SourceMigrationFailure06.schema.json",
1175
+ "SourceMigrationObservation06": "candidate/migration06/SourceMigrationObservation06.schema.json",
1176
+ "SourceMigrationRequest06": "candidate/migration06/SourceMigrationRequest06.schema.json",
1177
+ "SourceMigrationRequestAdmission06": "candidate/migration06/SourceMigrationRequestAdmission06.schema.json",
1178
+ "SourceMigrationRouteContract06": "candidate/migration06/SourceMigrationRouteContract06.schema.json"
1179
+ },
1180
+ "binary_runtime_carriers": {
1181
+ "validation": "NativeSourceMigrationProduced06 carries actual output bytes as a runtime value, not JSON and not an opaque authority brand. JSON observations are separately validated by the named closed schemas; no generated schema claims to validate a byte-vector carrier.",
1182
+ "ownership": "Input and output byte arrays are owned copies; caller mutation after invocation cannot change the authorized source or the produced result. All binary inputs obey the original accessor/prototype/ownership checks. No filesystem path is opened after the source bytes are owned; a caller-supplied path is read once under the same bounded capture rules as the source route."
1183
+ },
1184
+ "request_and_authority": {
1185
+ "admission": "Closed request shape with the exact output tuple (CandidateVersionTuple06). Malformed request maps SOURCE_INPUT_INVALID/input; a recognized mixed or unsupported tuple maps the original Core rejection arm and produces no authority. operation must equal 'migrate_public_source'. source_expected_A is a required Digest on this route: migration is always bound to one exact source container A. signature_policy on this route is exactly {requireSignature:false,expectedPublicKeyHex:null}; any other value is SOURCE_CAPABILITY_UNAVAILABLE/input, because the current 0.5 generation carries no verified signature policy meaning here.",
1186
+ "capture": "Reuse the approved bounded ZIP metadata probes to observe the outer directory and Manifest of the source only. The full source A is confirmed on the owned bytes after the grant, mirroring the source route; a mismatch is the named SOURCE_EXPECTED_ASSET_MISMATCH refusal with no output. Before the grant the callback sees only the outer capture identity and the mode/type/size member inventory. checksums.json or signature.kdsig members in the source are observed and reported, never verified as authority for migration and never silently dropped: their presence refuses this first slice by name (see refusals).",
1187
+ "grant": "One closed authority callback receives the exact contract, admitted request, request_digest, the outer capture identity (SourceOuterCapture06), the mode/type/size member inventory and the explicit output intent. Only literal true permits production. false maps SOURCE_PERMISSION_REJECTED/authorization; throw/unknown internal failure maps SOURCE_CAPABILITY_UNAVAILABLE at the observed stage. The callback is the native caller's consent to read this exact source and emit the converted representation; it is not an asset entitlement, not a Read grant and not editorial adoption.",
1188
+ "timeout": "request.timeout_ms is required 1..60000, a per-invocation wall-clock deadline using Date.now() capture and the original comparison rule (now > deadline rejects; equality allowed). Checked after capture, after the authority await, before and after output construction, and before returning bytes. Expiry maps SOURCE_DEADLINE_EXCEEDED at the observed checkpoint. A late true cannot start production.",
1189
+ "adoption": "The result is technical bytes plus producer observation. Neither the source nor the output carries adopted identity, ownership or acceptance; the migration neither invents nor transfers adoption, and a successful migration is not a consumer read, publication or endorsement."
1190
+ },
1191
+ "source_verification": {
1192
+ "generation": "Exactly the current 0.5 generation listed in versions.source_generation: Manifest (format_version, compatibility.profile, compatibility.profile_version) equals (0.5.0, kdna.payload.judgment, 0.5.1), the payload's own profile/profile_version equal the Manifest compatibility, and the container validates against the exact 0.5.1 combined Manifest contract already present in this package's schema set. Any other complete old tuple maps the named MIGRATION_SOURCE_UNSUPPORTED_VERSION/input refusal; a mixed tuple maps SOURCE_INPUT_INVALID/input.",
1193
+ "semantic": "Run the original classic 0.5 semantics without weakening: Manifest schema/domain validation, CBOR payload decode, and the original complete payload/interpretation validation the classic admission performs. A genuine original validation failure maps the original Core rejection reason and diagnostics with stage input, body null and no output. Never declare an invalid 0.5 payload valid by stripping declarations or by validating only the reconstructed 0.6 side.",
1194
+ "refusals": [
1195
+ "MIGRATION_SOURCE_UNSUPPORTED_VERSION/input: a complete historical tuple other than the exact current 0.5 generation (including container 0.5.0 with payload 0.5.0 / read 0.6.0-0.6.3 and every older container coordinate). This slice proves the refusal only; migrating historical generations would be its own declared unit.",
1196
+ "MIGRATION_SOURCE_PROTECTED_UNSUPPORTED/input: payload.encrypted true, an encryption/entitlement declaration or a protected logical payload. Protected migration is reserved for a separate unit; the refusal is by name and never degrades to converting the encrypted bytes as if they were plaintext.",
1197
+ "MIGRATION_SOURCE_EXTENSION_UNSUPPORTED/input: checksums.json or signature.kdsig members, or any member outside the exact 0.5 permitted set for this route (mimetype, kdna.json, payload.kdnab plus ordinary attachments that the 0.5 schema permits). Nothing is dropped, rewritten or re-signed silently.",
1198
+ "MIGRATION_SOURCE_CAPABILITY_UNSUPPORTED/input: an unsupported compression or a structure the bounded capture cannot observe exactly."
1199
+ ]
1200
+ },
1201
+ "output_mapping": {
1202
+ "format_version": "Rebind to the exact '0.6.0' coordinate. No 0.5 byte or descriptor is copied through as a predecessor claim; the source remains an external input, not an embedded asset.",
1203
+ "identity": "Copy asset_id, asset_uid, asset_type, title, version, judgment_version, created_at, updated_at, summary, languages, lineage, history, creator, access, license, description, keywords, runtime.mandatory_entries and every other authored field exactly, preserving optional absence and array order. Never regenerate IDs, timestamps or default objects.",
1204
+ "payload": "Replace the whole PayloadDescriptor with the exact SectionPayloadDescriptor06 produced from this build's real frames, tables and pack members, using the current source-route-frame-writer and metadata codec rules. The logical Payload is reconstructed from the verified 0.5 payload and must deep-equal it (see construction gate 3); the shape of the output is never derived from a fabricated old-side encode.",
1205
+ "representation_metadata": "Add the existing metadata codec projection derived from the complete canonical IR of the migrated payload with the real output member routing, exactly as the creation route derives it, including contract, tuple (this route's output tuple), node_order, catalog, references, relationships, mandatory_closures, asset_index, asset_closure, unresolved_external, ir_digest_claim and runtime_entry_names.",
1206
+ "representation_origin": "This route is the declared producer of RepresentationOrigin06 and always writes it: source_format_version is the exact '0.5.0'; source_container_digest is the confirmed source A; source_content_digest is the source content-tree digest computed under the original 0.5 C profile exactly as the classic side derives it (never a new or guessed digest); payload is the source's exact PayloadDescriptor; runtime is the source's exact runtime object; declared_content_digest and declared_authoring_content_digest are copied present-only from the source Manifest's content_digest and authoring.content_digest. The origin is a provenance record, not authority: downstream routes treat it as untrusted claim, exactly as the sections snapshot rules state.",
1207
+ "content_digest": "If the source Manifest declared content_digest, refresh it to the actual output C under the original canonical-content exclusion profile and disclose the refresh; if absent, keep it absent. Same present-only rule for authoring.content_digest. Never invent a claim that the source did not carry.",
1208
+ "runtime": "Map the source runtime mandatory entries: representation-format-dependent entries that named the replaced payload member are mapped to the actual generated pack members; every non-representation entry is preserved exactly in order; duplicates are never silently introduced or removed beyond the declared representation mapping. The exact before/after mapping is disclosed."
1209
+ },
1210
+ "construction_and_validation": {
1211
+ "order": [
1212
+ "Closed request admission, deadlined capture of the exact source bytes, source A confirmation against source_expected_A and the full member inventory.",
1213
+ "Native authority true with the closed context; false/throw/expiry leave no output and no downstream effect.",
1214
+ "Complete 0.5 source verification (generation classification, schema, CBOR decode, original semantics) with the named refusals above.",
1215
+ "Field-mapping construction: identity and authored fields copied exactly; payload rebuilt to real frames/tables/packs; format_version rebound; representation_metadata derived from the complete canonical IR; representation_origin written from confirmed source observations; C claims refreshed present-only.",
1216
+ "Serialize the actual container, then admit the output through the complete native 0.6 source admission on the produced bytes, which re-derives the full Payload and IR and enforces SECTION_DERIVED_IR_MISMATCH and all physical/frame/table rules. Output re-admission refusal returns no bytes.",
1217
+ "Final gates before return: the reconstructed Payload deep-equals the verified source Payload (MIGRATION_PAYLOAD_MISMATCH/semantic, hard, no output); every retained authored Manifest path equals the source exactly and the origin fields equal the confirmed observations (MIGRATION_MANIFEST_MISMATCH/semantic); the source bytes are unchanged and no partial artifact exists on any failure. Recheck the deadline and return owned bytes with the closed observation."
1218
+ ],
1219
+ "fail_delete": "All failures return no bytes (body null, body_bytes 0). The operation is atomic from the caller's view: a failed migration never yields a partial or best-effort container, and never mutates the source bytes or the caller's arguments.",
1220
+ "bootstrap": "Internal adapters may reuse the original classic 0.5 validation algorithms and the current 0.6 construction algorithms in the same instance; no intermediate branded container is admitted or minted, and an internal semantic view is never an admitted snapshot.",
1221
+ "integrity": "The initial output has no checksums.json or signature.kdsig; those may later be added by their own accepted operations on the saved bytes. A/C/E in the observation are actual observations of the produced bytes and their member set under the current profiles (E06 runtime-entry-set), not authorizations."
1222
+ },
1223
+ "evidence": {
1224
+ "bindings": "request_digest is SHA256JCS of the actual admitted request. source_A and source_content_digest are confirmed observations of the exact captured source; output.A/C/E and output_ir_digest come from the complete actual output re-admission. member_actions list every physical member of the output relative to the source with exactly one of added/removed/replaced/preserved, in physical order. No fabricated capture or snapshot IDs.",
1225
+ "claim": "Migrated means technical bytes plus producer observation only: it is not a transferable admitted token, consumer read result, publication, ownership, editorial adoption or an assertion that every consumer can read container 0.6. The reading-route separation remains external truth."
1226
+ },
1227
+ "diagnostics": {
1228
+ "boundary": "This route defines its own closed failure arm, SourceMigrationFailure06 with SourceMigrationDiagnostic06, instead of extending the shared source diagnostic enum: the SOURCE_* codes keep their source meanings and the named MIGRATION_* refusals are this route's own codes, never re-classifications of an original validation failure. Core rejections reuse SourceRouteCoreRejected06 unchanged. No catch-all converts unknown exceptions into authored-invalid or into a successful conversion.",
1229
+ "original_validation": "A genuine 0.5 original schema/domain/interpretation failure keeps the original CoreAdmissionRejected reason/diagnostics in core_rejected with disclosure none and body null; a failure of the internally constructed 0.6 output shape is an internal capability failure (SOURCE_CAPABILITY_UNAVAILABLE/output), not invalid caller data."
1230
+ },
1231
+ "limits": {
1232
+ "physical": {
1233
+ "member": 8388608,
1234
+ "total_decoded": 12582912,
1235
+ "container": 26214400,
1236
+ "entries": 128
1237
+ },
1238
+ "scope": "The four original06 physical limits apply to the actual completed output including generated Manifest, metadata, packs, tables, mimetype and copied attachments. The source is validated under its own original 0.5 bounds; a source that cannot produce a compliant output within these bounds refuses rather than truncating content."
1239
+ },
1240
+ "contract_observation": {
1241
+ "value": "SourceMigrationRouteContract06 is {id:versions.migration_route,version:\"0.1.0-candidate\",definition_digest:computed}.",
1242
+ "definition_digest_preimage": "definition_digest is sha256: followed by lowercase SHA-256 hex of the existing strict canonicalJson UTF-8 encoding of this complete installed public module value, using the same convention as source/creation route contracts. The field states the rule and does not embed a self-referential digest.",
1243
+ "meaning": "The digest identifies the exact route definition of this receipt. It is an observation, not native authority, migration permission, a release or an acceptance decision."
1244
+ },
1245
+ "prospective_runtime_controls": [
1246
+ "Exact current-generation positives: a delivered 0.5 container migrates to an admitted 0.6 container whose reconstructed Payload and IR deep-equal the verified source, whose retained authored Manifest paths equal the source byte-for-byte at the JSON value level, and whose representation_origin carries the confirmed source A/C and prior claims present-only.",
1247
+ "Refusal controls, each by name with its own fixture: historical tuple, protected/encrypted source, checksums/signature members or out-of-set members, unsupported structure, authority false, expired deadline, tampered source (A mismatch and post-capture mutation), and output re-admission constructed-failure.",
1248
+ "No-admission-change controls: the classic 0.5 admission and Read behavior and the native 0.6 admission and Read behavior are byte-for-byte unchanged by this route's presence, including their refusals of the other generation.",
1249
+ "Origin controls: a migrated output passes source-open and complete 0.6 admission with origin present; an existing 0.6 container without origin remains admissible exactly as before; a tampered origin claim never overrides current observations.",
1250
+ "Determinism control: migrating the same source twice in isolated invocations yields byte-identical output containers."
1251
+ ],
1252
+ "not_claimed": [
1253
+ "No legacy decoder, dual read, fallback or automatic conversion inside any admission path; explicit tool discipline is preserved.",
1254
+ "No historical-generation migration, no protected-source migration, no checksum/signature-member migration and no change to the source asset's own bytes or identity.",
1255
+ "No consumer readback of the output by any specific stack is asserted by producing bytes; the reading-route separation remains a separate, externally evidenced matter.",
1256
+ "No publication, release, stable coordinate for container 0.6 or kdna.read/0.7.0-candidate, real adoption or asset-acceptance claim follows from this route.",
1257
+ "No change to field_retention, version_decisions, representation_metadata semantics or any accepted A08-A21 receipt."
1258
+ ]
1122
1259
  }
1123
1260
  },
1124
1261
  "types": {
@@ -3,14 +3,14 @@
3
3
  "candidate_only": true,
4
4
  "source": {
5
5
  "path": "specs/public-semantic-source.json",
6
- "bytes": 1509417,
7
- "sha256": "63393386af28f33b19d88fa3acdc98e825e91ee78c3e850a95427a32b6087623"
6
+ "bytes": 1541192,
7
+ "sha256": "97019a7d806b8f4be570855f549fa97cb6c293771f6a3d0a439bc03f39fe4367"
8
8
  },
9
9
  "producer": {
10
10
  "recipe": {
11
11
  "path": "scripts/public-contract/native-output-recipe.json",
12
- "bytes": 164001,
13
- "sha256": "22ffb30bdd7a5498913ac041405b3d109f22f6fc79b3972b8ae2a8cf3a83f478"
12
+ "bytes": 168167,
13
+ "sha256": "73e48bcebfce225b6a76f1324e152500df2031721e09f72f3a60588db31eb2ac"
14
14
  },
15
15
  "scripts": [
16
16
  {
@@ -20,8 +20,8 @@
20
20
  },
21
21
  {
22
22
  "path": "scripts/public-contract/native-renderer.mjs",
23
- "bytes": 21439,
24
- "sha256": "750e968d0d88908f7c6b6b3d017039919049e22060203a7c721c3204522c211e"
23
+ "bytes": 22518,
24
+ "sha256": "672e3afe5e519f3103345157af721e083a40790769e3878d415534880719b11d"
25
25
  },
26
26
  {
27
27
  "path": "scripts/public-contract/generation-writer.mjs",
@@ -36,7 +36,7 @@
36
36
  ]
37
37
  },
38
38
  "owner": "sections",
39
- "module_digest": "sha256:e81ecfdc9357500275e10767e34a09b3fc8ce2e3d80df35653a639500c3ebf7f",
39
+ "module_digest": "sha256:38373dc9112c9701cb20d4df23ab9d10e0e47d7ffb0859bf8205f346d0b81fed",
40
40
  "roots": [
41
41
  "Manifest06Candidate",
42
42
  "RepresentationMetadata06",
@@ -657,8 +657,8 @@
657
657
  },
658
658
  {
659
659
  "path": "packages/kdna-core/src/public-contract/sections/contract.json",
660
- "bytes": 547981,
661
- "sha256": "fcaea073a9d3ae14011a1f849d0508170a79f78dccd7c25d9969eb57d18aec9a"
660
+ "bytes": 570835,
661
+ "sha256": "34c8f813f0fa3a46a2ce571d909d22e0d0ec66b5be3162963a0f7372ec2f5643"
662
662
  },
663
663
  {
664
664
  "path": "packages/kdna-core/src/public-contract/protected-sections-node.d.ts",
@@ -0,0 +1,14 @@
1
+ import type { CandidateVersionTuple06, RepresentationOrigin06 } from './sections/types.js';
2
+ import type { Payload } from './types.js';
3
+ import type { SourceOuterCapture06, SourceRouteCoreRejected06, SourceRouteMemberInventory06 } from './types.js';
4
+ export type SourceMigrationRequest06 = Readonly<{ request_id: string; tuple: CandidateVersionTuple06; operation: 'migrate_public_source'; source_expected_A: string; timeout_ms: number; signature_policy: Readonly<{ requireSignature: false; expectedPublicKeyHex: null }> }>;
5
+ export type SourceMigrationCaptureRow06 = Readonly<{ name: string; type: 'file'; mode: number; size: number }>;
6
+ export type SourceMigrationAuthorityContext06 = Readonly<{ contract: SourceMigrationRouteContract06; request: SourceMigrationRequest06; request_digest: string; capture: SourceOuterCapture06; source_inventory: ReadonlyArray<SourceMigrationCaptureRow06>; output_intent: Readonly<{ container: '0.6.0'; read: 'kdna.read/0.7.0-candidate'; adoption: 'not_observed' }> }>;
7
+ export type SourceMigrationObservation06 = Readonly<{ contract: SourceMigrationRouteContract06; request_digest: string; capture_id: string; tuple: CandidateVersionTuple06; source_A: string; source_content_digest: string; source_inventory: ReadonlyArray<SourceRouteMemberInventory06>; output: Readonly<{ A: string; C: string; E: string }>; E_profile: 'kdna.digest-basis.runtime-entry-set/0.3.0-candidate'; output_ir_digest: string; member_actions: ReadonlyArray<Readonly<{ name: string; action: 'added' | 'removed' | 'replaced' | 'preserved' }>>; origin: RepresentationOrigin06; body_bytes: number }>;
8
+ export type SourceMigrationFailure06 = Readonly<{ status: 'source_failed'; diagnostic: Readonly<{ code: string; stage: string }>; disclosure: unknown; body: null; body_bytes: 0 }>;
9
+ export type NativeSourceMigrationProduced06 = Readonly<{ status: 'migrated'; bytes: Uint8Array; observation: SourceMigrationObservation06 }> | SourceMigrationFailure06 | SourceRouteCoreRejected06;
10
+ export declare function admitSourceMigrationRequest(candidate: unknown): SourceMigrationRequestAdmission06;
11
+ export declare function inspectSourceMigrationRequest(request: AdmittedSourceMigrationRequest06): Readonly<SourceMigrationRequest06> | null;
12
+ export declare function createNativeSourceMigrationAuthority(callback: (context: Readonly<SourceMigrationAuthorityContext06>) => boolean | Promise<boolean>): NativeSourceMigrationAuthority06;
13
+ export declare function migratePublicSourceNode(input: string | Uint8Array, request: AdmittedSourceMigrationRequest06, authority: NativeSourceMigrationAuthority06): Promise<NativeSourceMigrationProduced06>;
14
+ export type SourceMigrationRouteContract06 = Readonly<{ id: 'kdna.source-migration/0.1.0-candidate'; version: '0.1.0-candidate'; definition_digest: string }>;
@@ -0,0 +1,253 @@
1
+ 'use strict';
2
+ // Candidate explicit 0.5->0.6 source migration route. It reads exactly the
3
+ // current 0.5 generation, writes an adhered 0.6 container with a confirmed
4
+ // representation_origin, and proves refusal-only paths for everything outside
5
+ // that scope. No admission path elsewhere converts, dual-reads or falls back.
6
+ const crypto = require('node:crypto');
7
+ const Ajv = require('ajv/dist/2020.js');
8
+ const S = require('./source-route-common.js');
9
+ const C = require('./section-common.js');
10
+ const D = require('./digests.js');
11
+ const strict = require('./strict-input.js');
12
+ const { rejected } = require('./admit.js');
13
+ const { validate: validateClassic } = require('./validate.js');
14
+ const { parseContainer } = require('./container.js');
15
+ const { decodeValidatedPayload, assertContentBindings } = require('./semantic-admission.js');
16
+ const { openSourceRouteCapture } = require('./source-route-capture.js');
17
+ const { admitPublicBytes } = require('./source-public-admission.js');
18
+ const { buildIR } = require('./canonical-ir.js');
19
+ const { buildFrames } = require('./source-route-frame-writer.js');
20
+ const M = require('./section-metadata-codec.js');
21
+ const { encodeStored } = require('./container-writer.js');
22
+ const { isDeepStrictEqual } = require('node:util');
23
+ const { inflateRawSync } = require('node:zlib');
24
+
25
+ const M6 = require('./migration06/contract.json');
26
+ const tuple = C.contract.module.versionTuple;
27
+ const routeContract = C.strict.freeze({
28
+ id: 'kdna.source-migration/0.1.0-candidate',
29
+ version: '0.1.0-candidate',
30
+ definition_digest: D.digestCanonical(M6.module),
31
+ });
32
+ const SIGNATURE_POLICY = Object.freeze({ requireSignature: false, expectedPublicKeyHex: null });
33
+ const SOURCE_GENERATION = Object.freeze({
34
+ format_version: '0.5.0',
35
+ profile: 'kdna.payload.judgment',
36
+ profile_version: '0.5.1',
37
+ });
38
+ const HISTORICAL_CONTAINER_VERSIONS = new Set(['0.1.0', '0.2.0', '0.3.0', '0.4.0']);
39
+ const BASE_MEMBERS = Object.freeze(['mimetype', 'kdna.json', 'payload.kdnab']);
40
+
41
+ const requests = new WeakMap(), authorities = new WeakMap(), migrationFailures = new WeakSet();
42
+ const frozen = v => C.strict.freeze(v);
43
+ const none = () => ({ kind: 'none', external_commit: { state: 'not_invoked' } });
44
+ const isDigest = v => typeof v === 'string' && /^sha256:[0-9a-f]{64}$/u.test(v);
45
+ const ajv = new Ajv({ strict: false, allErrors: false, validateFormats: false });
46
+ const typed = new Map();
47
+ function compiled(name) {
48
+ if (!typed.has(name)) typed.set(name, ajv.compile({ $schema: 'https://json-schema.org/draft/2020-12/schema', $defs: M6.types, $ref: '#/$defs/' + name }));
49
+ return typed.get(name);
50
+ }
51
+ function validateTyped(name, value) {
52
+ if (!compiled(name)(value)) fail('SOURCE_CAPABILITY_UNAVAILABLE', 'output');
53
+ return value;
54
+ }
55
+ function failure(code, stage) {
56
+ const out = { status: 'source_failed', diagnostic: { code, stage }, disclosure: none(), body: null, body_bytes: 0 };
57
+ validateTyped('SourceMigrationFailure06', out);
58
+ return frozen(out);
59
+ }
60
+ function coreFailure(code, stage, error = null) {
61
+ const out = { status: 'core_rejected', stage, core: rejected(code, error?.component_failure ?? null, error?.diagnostic ?? null), disclosure: none(), body: null, body_bytes: 0 };
62
+ validateTyped('SourceRouteCoreRejected06', out);
63
+ return frozen(out);
64
+ }
65
+ function fail(code, stage) { const e = new Error(code); e.migrationCode = code; e.migrationStage = stage; migrationFailures.add(e); throw e; }
66
+
67
+ function admitSourceMigrationRequest(candidate) {
68
+ try {
69
+ const data = C.strict.copyJson(candidate);
70
+ S.keys(data, ['request_id', 'tuple', 'operation', 'source_expected_A', 'timeout_ms', 'signature_policy']);
71
+ C.need(C.strict.identifier(data.request_id), 'READ_INPUT_INVALID');
72
+ const t = data.tuple;
73
+ C.need(t && typeof t === 'object' && !Array.isArray(t) && Object.keys(t).every(k => Object.hasOwn(tuple, k) && typeof t[k] === 'string'), 'READ_INPUT_INVALID');
74
+ if (Object.keys(t).length !== Object.keys(tuple).length || Object.entries(tuple).some(([k, v]) => t[k] !== v)) {
75
+ const baseline = require('./generated-contract.json');
76
+ const historical = [baseline.versionTuple, ...baseline.types.UnsupportedVersionTuple.anyOf.map(x => Object.fromEntries(Object.entries(x.properties).map(([k, v]) => [k, v.const])))];
77
+ const known = historical.some(v => Object.keys(v).length === Object.keys(t).length && Object.entries(v).every(([k, x]) => t[k] === x));
78
+ return coreFailure(known ? 'READ_UNSUPPORTED_VERSION' : Object.keys(tuple).some(k => k !== 'payload_profile' && t[k] === tuple[k]) ? 'READ_MIXED_VERSION_TUPLE' : 'READ_UNSUPPORTED_VERSION', 'input');
79
+ }
80
+ C.need(data.operation === 'migrate_public_source', 'READ_INPUT_INVALID');
81
+ C.need(isDigest(data.source_expected_A), 'READ_INPUT_INVALID');
82
+ C.need(Number.isSafeInteger(data.timeout_ms) && data.timeout_ms >= 1 && data.timeout_ms <= 60000, 'READ_INPUT_INVALID');
83
+ const policy = data.signature_policy;
84
+ C.need(policy && typeof policy === 'object' && !Array.isArray(policy) && policy.requireSignature === false && policy.expectedPublicKeyHex === null, 'READ_INPUT_INVALID');
85
+ C.need(compiled('SourceMigrationRequest06')(data), 'READ_INPUT_INVALID');
86
+ const token = Object.freeze({});
87
+ requests.set(token, { data: frozen(data), digest: D.digestCanonical(data) });
88
+ return Object.freeze({ status: 'admitted_request', request: token });
89
+ } catch (e) {
90
+ if (e.migrationCode === 'SOURCE_CAPABILITY_UNAVAILABLE') return failure(e.migrationCode, e.migrationStage);
91
+ if (C.isFailure(e) || S.isFailure(e) || e.reason === 'READ_INPUT_INVALID') return failure('SOURCE_INPUT_INVALID', 'input');
92
+ return failure('SOURCE_CAPABILITY_UNAVAILABLE', 'input');
93
+ }
94
+ }
95
+ function inspectSourceMigrationRequest(token) { return requests.get(token)?.data ?? null; }
96
+ function createNativeSourceMigrationAuthority(callback) {
97
+ if (typeof callback !== 'function') throw new TypeError('Native migration authority callback required');
98
+ const token = Object.freeze({});
99
+ authorities.set(token, callback);
100
+ return token;
101
+ }
102
+
103
+ function classifySource(manifest, entries) {
104
+ const version = manifest.format_version;
105
+ const compatibility = manifest.compatibility ?? {};
106
+ if (version === SOURCE_GENERATION.format_version) {
107
+ if (compatibility.profile !== SOURCE_GENERATION.profile || compatibility.profile_version !== SOURCE_GENERATION.profile_version) fail('MIGRATION_SOURCE_UNSUPPORTED_VERSION', 'input');
108
+ } else if (HISTORICAL_CONTAINER_VERSIONS.has(version)) {
109
+ fail('MIGRATION_SOURCE_UNSUPPORTED_VERSION', 'input');
110
+ } else {
111
+ fail('SOURCE_INPUT_INVALID', 'input');
112
+ }
113
+ if (manifest.payload?.encrypted === true || manifest.encryption || Object.hasOwn(manifest, 'entitlement')) fail('MIGRATION_SOURCE_PROTECTED_UNSUPPORTED', 'input');
114
+ if (Object.hasOwn(entries, 'checksums.json') || Object.hasOwn(entries, 'signature.kdsig')) fail('MIGRATION_SOURCE_EXTENSION_UNSUPPORTED', 'input');
115
+ const allowed = new Set(BASE_MEMBERS);
116
+ for (const resource of manifest.payload?.resources ?? []) if (typeof resource?.entry === 'string') allowed.add(resource.entry);
117
+ for (const name of Object.keys(entries)) if (!allowed.has(name) && !name.startsWith('attachments/')) fail('MIGRATION_SOURCE_EXTENSION_UNSUPPORTED', 'input');
118
+ }
119
+
120
+ function buildOutput(manifest5, payload5, entries5, sourceA, sourceC, requestDigest, captureId) {
121
+ const manifest = { ...manifest5, format_version: '0.6.0' };
122
+ const ir = { ...buildIR(manifest, payload5, entries5), tuple: structuredClone(tuple) };
123
+ const built = buildFrames(ir);
124
+ const packNames = Object.keys(built.packs);
125
+ manifest.payload = { layout: 'sections', encoding: 'strict-cbor-frames', encrypted: false, tables: built.tables, xref_codec: 'frame-local-ordered-scope-dictionary/1' };
126
+ const origin = {
127
+ source_format_version: '0.5.0',
128
+ source_container_digest: sourceA,
129
+ source_content_digest: sourceC,
130
+ payload: strict.freeze(structuredClone(manifest5.payload)),
131
+ runtime: structuredClone(manifest5.runtime),
132
+ };
133
+ if (isDigest(manifest5.content_digest)) origin.declared_content_digest = manifest5.content_digest;
134
+ if (isDigest(manifest5.authoring?.content_digest)) origin.declared_authoring_content_digest = manifest5.authoring.content_digest;
135
+ manifest.representation_origin = origin;
136
+ const mapped = [];
137
+ for (const name of manifest5.runtime?.mandatory_entries ?? []) {
138
+ if (name === 'payload.kdnab') { for (const pack of packNames) if (!mapped.includes(pack)) mapped.push(pack); }
139
+ else if (!mapped.includes(name)) mapped.push(name);
140
+ }
141
+ manifest.runtime = { ...manifest5.runtime, mandatory_entries: mapped };
142
+ const { nodes, expansion_targets, ...meta } = ir;
143
+ meta.node_order = nodes.map(n => n.id);
144
+ meta.ir_digest_claim = D.digestCanonical(ir);
145
+ meta.runtime_entry_names = [...new Set(['kdna.json', ...packNames, ...mapped])].sort(C.utf8);
146
+ manifest.representation_metadata = M.encode(meta);
147
+ const entries = { mimetype: Buffer.from('application/vnd.kdna.asset'), ...built.packs };
148
+ if (isDigest(manifest5.content_digest)) {
149
+ const pre = { ...entries, 'kdna.json': Buffer.from(JSON.stringify(manifest)) };
150
+ const refreshed = D.digest(D.contentTreePreimage(pre));
151
+ manifest.content_digest = refreshed;
152
+ if (isDigest(manifest5.authoring?.content_digest)) manifest.authoring = { ...manifest5.authoring, content_digest: refreshed };
153
+ }
154
+ entries['kdna.json'] = Buffer.from(JSON.stringify(manifest));
155
+ const members = Object.entries(entries).map(([name, bytes]) => ({ name, type: 'file', mode: 0o100644, bytes }));
156
+ C.need(members.length <= 128, 'READ_CORE_INVALID');
157
+ const bytes = encodeStored(members);
158
+ const output = admitPublicBytes(bytes, SIGNATURE_POLICY, captureId, requestDigest);
159
+ if (!isDeepStrictEqual(output.payload, payload5)) fail('MIGRATION_PAYLOAD_MISMATCH', 'semantic');
160
+ const retained = ['asset_id', 'asset_uid', 'asset_type', 'title', 'version', 'judgment_version', 'created_at', 'updated_at', 'summary', 'languages', 'history'];
161
+ for (const key of retained) if (!isDeepStrictEqual(manifest[key], manifest5[key])) fail('MIGRATION_MANIFEST_MISMATCH', 'semantic');
162
+ if (!origin.source_container_digest || !origin.source_content_digest) fail('MIGRATION_ORIGIN_MISSING', 'semantic');
163
+ const actions = [];
164
+ const sourceNames = new Set(Object.keys(entries5));
165
+ const outputNames = new Set(Object.keys(output.entries));
166
+ for (const name of outputNames) actions.push({ name, action: sourceNames.has(name) ? 'replaced' : 'added' });
167
+ for (const name of sourceNames) if (!outputNames.has(name)) actions.push({ name, action: 'removed' });
168
+ return { bytes, manifest, origin, output, actions };
169
+ }
170
+
171
+ async function migratePublicSourceNode(input, token, authority) {
172
+ let capture, stage = 'input';
173
+ try {
174
+ const record = requests.get(token), callback = authorities.get(authority);
175
+ if (!record || !callback) fail('SOURCE_INPUT_INVALID', 'input');
176
+ const started = Date.now(), deadline = started + record.data.timeout_ms;
177
+ const current = where => { if (Date.now() > deadline) fail('SOURCE_DEADLINE_EXCEEDED', where); };
178
+ current('admission'); stage = 'capture'; capture = await openSourceRouteCapture(input); current('admission');
179
+ const manifestMeta = C.strict.parseJson(capture.manifestBytes);
180
+ if (manifestMeta.format_version === SOURCE_GENERATION.format_version) {
181
+ const compatibility = manifestMeta.compatibility ?? {};
182
+ if (compatibility.profile !== SOURCE_GENERATION.profile || compatibility.profile_version !== SOURCE_GENERATION.profile_version) fail('MIGRATION_SOURCE_UNSUPPORTED_VERSION', 'input');
183
+ } else if (HISTORICAL_CONTAINER_VERSIONS.has(manifestMeta.format_version)) {
184
+ fail('MIGRATION_SOURCE_UNSUPPORTED_VERSION', 'input');
185
+ } else {
186
+ fail('SOURCE_INPUT_INVALID', 'input');
187
+ }
188
+ if (manifestMeta.payload?.encrypted === true || manifestMeta.encryption || Object.hasOwn(manifestMeta, 'entitlement')) fail('MIGRATION_SOURCE_PROTECTED_UNSUPPORTED', 'input');
189
+ if (capture.rows.some(r => r.name === 'checksums.json' || r.name === 'signature.kdsig')) fail('MIGRATION_SOURCE_EXTENSION_UNSUPPORTED', 'input');
190
+ C.need(capture.rows.every(r => r.method === 0 || r.method === 8), 'READ_CORE_CAPABILITY_UNAVAILABLE');
191
+ const inventory = capture.rows.map(r => ({ name: r.name, type: 'file', mode: r.mode, size: r.size })).sort((a, b) => C.utf8(a.name, b.name));
192
+ const context = {
193
+ contract: routeContract,
194
+ request: record.data,
195
+ request_digest: record.digest,
196
+ capture: capture.identity,
197
+ source_inventory: inventory.map(({ name, type, mode, size }) => ({ name, type, mode, size })),
198
+ output_intent: { container: '0.6.0', read: 'kdna.read/0.7.0-candidate', adoption: 'not_observed' },
199
+ };
200
+ validateTyped('SourceMigrationAuthorityContext06', context);
201
+ stage = 'authorization'; current('authorization');
202
+ let grant;
203
+ try { grant = await callback(frozen(structuredClone(context))); } catch { fail('SOURCE_CAPABILITY_UNAVAILABLE', 'authorization'); }
204
+ current('authorization'); if (grant !== true) fail('SOURCE_PERMISSION_REJECTED', 'authorization');
205
+ stage = 'admission'; current('admission');
206
+ const bytes = await capture.wholeAfterAuthorization(); current('admission');
207
+ const sourceA = D.digest(bytes);
208
+ if (sourceA !== record.data.source_expected_A) fail('SOURCE_EXPECTED_ASSET_MISMATCH', 'admission');
209
+ const entries = parseContainer(bytes, (data, maxOutputLength) => inflateRawSync(data, { maxOutputLength }));
210
+ const rawManifest = C.strict.parseJson(entries['kdna.json']);
211
+ classifySource(rawManifest, entries);
212
+ const manifest5 = validateClassic('Manifest', rawManifest);
213
+ const payload5 = decodeValidatedPayload(manifest5, entries['payload.kdnab']);
214
+ const sourceC = D.digest(D.contentTreePreimage(entries));
215
+ assertContentBindings(manifest5, sourceC);
216
+ const inventoryFull = inventory.map(r => ({ ...r, sha256: D.digest(entries[r.name]) }));
217
+ await capture.assertUnchanged(); current('semantic');
218
+ stage = 'output';
219
+ const produced = buildOutput(manifest5, payload5, entries, sourceA, sourceC, record.digest, capture.identity.capture_id);
220
+ current('semantic');
221
+ const observation = validateTyped('SourceMigrationObservation06', {
222
+ contract: routeContract,
223
+ request_digest: record.digest,
224
+ capture_id: capture.identity.capture_id,
225
+ tuple: structuredClone(tuple),
226
+ source_A: sourceA,
227
+ source_content_digest: sourceC,
228
+ source_inventory: inventoryFull,
229
+ output: { A: produced.output.observed.A, C: produced.output.observed.C, E: produced.output.observed.E.digest },
230
+ E_profile: produced.output.observed.E.profile,
231
+ output_ir_digest: D.digestCanonical(produced.output.ir),
232
+ member_actions: produced.actions,
233
+ origin: strict.freeze(produced.origin),
234
+ body_bytes: produced.bytes.length,
235
+ proof: 'produced_bytes_with_confirmed_source_observation_not_consumer_read_or_adoption',
236
+ });
237
+ await capture.assertUnchanged(); current('return');
238
+ return Object.freeze({ status: 'migrated', bytes: new Uint8Array(produced.bytes), observation: frozen(observation) });
239
+ } catch (e) {
240
+ if (migrationFailures.has(e)) return failure(e.migrationCode, e.migrationStage);
241
+ if (stage === 'input' && (C.isFailure(e) || S.isFailure(e) || e.reason === 'READ_INPUT_INVALID')) return failure('SOURCE_INPUT_INVALID', 'input');
242
+ const reason = e?.code === 'MODULE_NOT_FOUND' ? 'READ_CORE_CAPABILITY_UNAVAILABLE' : e?.reason;
243
+ if (reason) return coreFailure(reason, ['input', 'capture', 'admission', 'output'].includes(stage) ? stage : 'admission', e);
244
+ return failure('SOURCE_CAPABILITY_UNAVAILABLE', ['input', 'capture', 'admission', 'authorization', 'semantic', 'output', 'return'].includes(stage) ? stage : 'output');
245
+ } finally { if (capture) await capture.close(); }
246
+ }
247
+
248
+ module.exports = {
249
+ admitSourceMigrationRequest,
250
+ inspectSourceMigrationRequest,
251
+ createNativeSourceMigrationAuthority,
252
+ migratePublicSourceNode,
253
+ };
@@ -0,0 +1,2 @@
1
+ import api from './source-migration-node.js';
2
+ export const {admitSourceMigrationRequest,inspectSourceMigrationRequest,createNativeSourceMigrationAuthority,migratePublicSourceNode}=api;