@aikdna/kdna-core 0.17.0 → 0.19.0

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 (38) hide show
  1. package/CHANGELOG.md +227 -64
  2. package/README.md +114 -77
  3. package/package.json +8 -2
  4. package/schema/agent-host-capabilities.schema.json +62 -0
  5. package/schema/agent-host-receipt.schema.json +371 -0
  6. package/schema/agent-host-request.schema.json +223 -0
  7. package/schema/{bundle-profile-v1.schema.json → bundle-profile.schema.json} +9 -5
  8. package/schema/checksums.schema.json +42 -3
  9. package/schema/consumption-plan.schema.json +428 -0
  10. package/schema/digest-evidence.schema.json +212 -0
  11. package/schema/{kdna-envelope-external-grant-v1.schema.json → external-grant-envelope.schema.json} +17 -4
  12. package/schema/{kdna-key-grant-v1.schema.json → external-key-grant.schema.json} +39 -7
  13. package/schema/judgment-trace.schema.json +1251 -0
  14. package/schema/load-plan.schema.json +7 -5
  15. package/schema/manifest.schema.json +70 -10
  16. package/schema/{payload-profile-v1.schema.json → payload-profile.schema.json} +30 -6
  17. package/schema/runtime-capsule.schema.json +116 -0
  18. package/src/asset-reader.js +106 -120
  19. package/src/{v1 → container}/index.js +566 -209
  20. package/src/container/index.mjs +20 -0
  21. package/src/container-dispatcher.js +10 -7
  22. package/src/crypto-profile.js +37 -107
  23. package/src/external-key-grant.js +41 -15
  24. package/src/index.js +11 -4
  25. package/src/index.mjs +143 -24
  26. package/src/loader-compatibility.js +59 -0
  27. package/src/loader.js +1 -1
  28. package/src/public-api.js +59 -163
  29. package/src/remote-runtime.d.ts +13 -0
  30. package/src/remote-runtime.js +27 -0
  31. package/src/remote-runtime.mjs +3 -0
  32. package/src/runtime-api.js +9 -10
  33. package/src/runtime-capsule.js +529 -0
  34. package/src/runtime-contract.js +1882 -0
  35. package/src/types.d.ts +1127 -136
  36. package/src/workpack-pure.js +1 -1
  37. package/src/lint-pure.js +0 -430
  38. package/src/v1/index.mjs +0 -20
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "$schema": "https://json-schema.org/draft/2020-12/schema",
3
3
  "$id": "https://github.com/aikdna/kdna/schema/load-plan.schema.json",
4
- "title": "KDNA LoadPlan v1",
4
+ "title": "KDNA LoadPlan",
5
5
  "description": "Machine-readable pre-load authorization and runtime planning result for packaged KDNA assets.",
6
6
  "type": "object",
7
7
  "required": [
8
- "kdna_version",
8
+ "format_version",
9
9
  "asset",
10
10
  "access",
11
11
  "access_alias",
@@ -21,7 +21,9 @@
21
21
  ],
22
22
  "additionalProperties": false,
23
23
  "properties": {
24
- "kdna_version": { "type": ["string", "null"] },
24
+ "format_version": {
25
+ "oneOf": [{ "const": "0.1.0" }, { "type": "null" }]
26
+ },
25
27
  "asset": {
26
28
  "type": "object",
27
29
  "required": ["asset_id", "asset_uid", "title", "version", "judgment_version"],
@@ -126,8 +128,8 @@
126
128
  "required": ["kind", "path"],
127
129
  "additionalProperties": false,
128
130
  "properties": {
129
- "kind": { "type": ["string", "null"], "enum": ["dir", "file", null] },
130
- "path": { "type": "string" }
131
+ "kind": { "type": ["string", "null"], "enum": ["dir", "file", "memory", null] },
132
+ "path": { "type": ["string", "null"] }
131
133
  }
132
134
  }
133
135
  }
@@ -2,10 +2,10 @@
2
2
  "$schema": "https://json-schema.org/draft/2020-12/schema",
3
3
  "$id": "https://github.com/aikdna/kdna/schema/manifest.schema.json",
4
4
  "title": "KDNA Manifest",
5
- "description": "Schema for kdna.json, the public metadata layer of a .kdna container (kdna_version 1.0).",
5
+ "description": "Schema for kdna.json, the public metadata layer of a .kdna container.",
6
6
  "type": "object",
7
7
  "required": [
8
- "kdna_version",
8
+ "format_version",
9
9
  "asset_id",
10
10
  "asset_uid",
11
11
  "asset_type",
@@ -18,11 +18,35 @@
18
18
  "payload"
19
19
  ],
20
20
  "additionalProperties": true,
21
+ "allOf": [
22
+ {
23
+ "if": {
24
+ "properties": {
25
+ "payload": {
26
+ "required": ["encrypted"],
27
+ "properties": { "encrypted": { "const": true } }
28
+ }
29
+ }
30
+ },
31
+ "then": { "required": ["encryption"] }
32
+ },
33
+ {
34
+ "if": { "required": ["encryption"] },
35
+ "then": {
36
+ "properties": {
37
+ "payload": {
38
+ "required": ["encrypted"],
39
+ "properties": { "encrypted": { "const": true } }
40
+ }
41
+ }
42
+ }
43
+ }
44
+ ],
21
45
  "properties": {
22
- "kdna_version": {
46
+ "format_version": {
23
47
  "type": "string",
24
- "description": "KDNA container version this manifest conforms to.",
25
- "enum": ["1.0"]
48
+ "description": "Compatibility coordinate for the KDNA container format.",
49
+ "const": "0.1.0"
26
50
  },
27
51
  "asset_id": {
28
52
  "type": "string",
@@ -81,17 +105,22 @@
81
105
  },
82
106
  "compatibility": {
83
107
  "type": "object",
84
- "required": ["min_loader_version", "profile"],
108
+ "required": ["min_loader_version", "profile", "profile_version"],
85
109
  "additionalProperties": true,
86
110
  "properties": {
87
111
  "min_loader_version": {
88
112
  "type": "string",
89
- "pattern": "^[0-9]+\\.[0-9]+\\.[0-9]+([+-].+)?$"
113
+ "pattern": "^(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)$",
114
+ "description": "Minimum compatible KDNA loader package coordinate. It must be strict x.y.z with no leading zeros, prerelease suffix, or build metadata."
90
115
  },
91
116
  "profile": {
92
117
  "type": "string",
93
- "description": "Payload profile identifier (e.g. judgment-profile-v1).",
94
- "enum": ["judgment-profile-v1", "bundle-profile-v1"]
118
+ "description": "Payload profile identifier (e.g. kdna.payload.judgment).",
119
+ "enum": ["kdna.payload.judgment", "kdna.payload.bundle"]
120
+ },
121
+ "profile_version": {
122
+ "const": "0.1.0",
123
+ "description": "Compatibility coordinate for the selected payload profile."
95
124
  }
96
125
  }
97
126
  },
@@ -105,6 +134,11 @@
105
134
  "encrypted": { "type": "boolean" }
106
135
  }
107
136
  },
137
+ "access": {
138
+ "type": "string",
139
+ "enum": ["public", "licensed", "remote"],
140
+ "description": "Stable delivery and authorization mode for the asset."
141
+ },
108
142
  "summary": { "type": "string" },
109
143
  "description": { "type": "string" },
110
144
  "language": { "type": "string" },
@@ -218,7 +252,33 @@
218
252
  }
219
253
  ]
220
254
  },
221
- "encryption": { "type": "object" },
255
+ "encryption": {
256
+ "type": "object",
257
+ "required": ["profile", "profile_version", "encrypted_entries"],
258
+ "additionalProperties": true,
259
+ "properties": {
260
+ "profile": {
261
+ "type": "string",
262
+ "enum": [
263
+ "kdna.encryption.licensed-entry",
264
+ "kdna.encryption.password",
265
+ "kdna.encryption.password.scrypt",
266
+ "kdna.envelope.external-grant"
267
+ ]
268
+ },
269
+ "profile_version": {
270
+ "const": "0.1.0",
271
+ "description": "Compatibility coordinate for the selected encryption or envelope profile."
272
+ },
273
+ "encrypted_entries": {
274
+ "type": "array",
275
+ "minItems": 1,
276
+ "maxItems": 1,
277
+ "uniqueItems": true,
278
+ "items": { "const": "payload.kdnab" }
279
+ }
280
+ }
281
+ },
222
282
  "load_contract": { "$ref": "load-contract.schema.json" },
223
283
  "scope": { "type": "object" },
224
284
  "evidence_claims": { "type": "object" }
@@ -1,16 +1,20 @@
1
1
  {
2
2
  "$schema": "https://json-schema.org/draft/2020-12/schema",
3
- "$id": "https://github.com/aikdna/kdna/schema/payload-profile-v1.schema.json",
4
- "title": "Judgment Profile v1",
3
+ "$id": "https://github.com/aikdna/kdna/schema/payload-profile.schema.json",
4
+ "title": "KDNA Judgment Payload Profile",
5
5
  "description": "Schema for the payload entry of a .kdna container. The payload is the actual judgment data.",
6
6
  "type": "object",
7
- "required": ["profile", "core"],
7
+ "required": ["profile", "profile_version", "core"],
8
8
  "additionalProperties": true,
9
9
  "properties": {
10
10
  "profile": {
11
11
  "type": "string",
12
- "const": "judgment-profile-v1",
13
- "description": "Profile identifier. Must be the literal string 'judgment-profile-v1'."
12
+ "const": "kdna.payload.judgment",
13
+ "description": "Profile identifier. Must be the literal string 'kdna.payload.judgment'."
14
+ },
15
+ "profile_version": {
16
+ "const": "0.1.0",
17
+ "description": "Compatibility coordinate for the judgment payload profile."
14
18
  },
15
19
  "core": {
16
20
  "type": "object",
@@ -76,7 +80,27 @@
76
80
  "type": "object",
77
81
  "additionalProperties": true,
78
82
  "properties": {
79
- "self_checks": { "type": "array", "items": { "type": "string" } },
83
+ "self_check": {
84
+ "type": "array",
85
+ "description": "Self-check questions. Each item is either a string or an object with a required string `question` field and optional metadata.",
86
+ "items": {
87
+ "oneOf": [
88
+ { "type": "string" },
89
+ {
90
+ "type": "object",
91
+ "required": ["question"],
92
+ "additionalProperties": true,
93
+ "properties": {
94
+ "question": { "type": "string" },
95
+ "applies_when": { "type": "array" },
96
+ "does_not_apply_when": { "type": "array" },
97
+ "failure_risk": { "type": "string" }
98
+ }
99
+ }
100
+ ]
101
+ }
102
+ },
103
+ "self_checks": false,
80
104
  "failure_modes": {
81
105
  "type": "array",
82
106
  "items": { "type": "object" }
@@ -0,0 +1,116 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://github.com/aikdna/kdna/specs/runtime-capsule.schema.json",
4
+ "title": "KDNA Runtime Capsule",
5
+ "description": "Current Runtime Capsule carrying explicit A/C/E digest evidence. P is external delivery metadata and is never embedded here.",
6
+ "type": "object",
7
+ "required": [
8
+ "type",
9
+ "contract_version",
10
+ "asset",
11
+ "digests",
12
+ "signature",
13
+ "access",
14
+ "risk_level",
15
+ "profile",
16
+ "context",
17
+ "trace"
18
+ ],
19
+ "additionalProperties": false,
20
+ "properties": {
21
+ "type": { "const": "kdna.runtime-capsule" },
22
+ "contract_version": { "const": "0.1.0" },
23
+ "asset": { "$ref": "#/$defs/asset" },
24
+ "digests": {
25
+ "allOf": [
26
+ {
27
+ "$ref": "https://github.com/aikdna/kdna/specs/digest-evidence.schema.json"
28
+ },
29
+ {
30
+ "properties": {
31
+ "asset": { "$ref": "#/$defs/successfulDigest" },
32
+ "content": { "$ref": "#/$defs/successfulDigest" },
33
+ "runtime_entry_set": { "$ref": "#/$defs/successfulDigest" }
34
+ }
35
+ }
36
+ ]
37
+ },
38
+ "signature": { "$ref": "#/$defs/signature" },
39
+ "access": { "enum": ["public", "licensed", "remote"] },
40
+ "risk_level": { "type": ["string", "null"] },
41
+ "profile": { "enum": ["index", "compact", "scenario", "full"] },
42
+ "context": { "type": "object" },
43
+ "trace": { "$ref": "#/$defs/trace" }
44
+ },
45
+ "$defs": {
46
+ "sha256": {
47
+ "type": "string",
48
+ "pattern": "^sha256:[0-9a-f]{64}$"
49
+ },
50
+ "asset": {
51
+ "type": "object",
52
+ "required": ["asset_id", "asset_uid", "version", "judgment_version"],
53
+ "additionalProperties": false,
54
+ "properties": {
55
+ "asset_id": {
56
+ "type": "string",
57
+ "pattern": "^[a-zA-Z][a-zA-Z0-9_-]*(:[a-zA-Z0-9_.-]+)+$"
58
+ },
59
+ "asset_uid": { "type": "string", "format": "uri" },
60
+ "version": {
61
+ "type": "string",
62
+ "pattern": "^[0-9]+\\.[0-9]+\\.[0-9]+([+-].+)?$"
63
+ },
64
+ "judgment_version": {
65
+ "type": "string",
66
+ "pattern": "^[0-9]+\\.[0-9]+\\.[0-9]+([+-].+)?$"
67
+ }
68
+ }
69
+ },
70
+ "successfulDigest": {
71
+ "type": "object",
72
+ "properties": {
73
+ "value": { "$ref": "#/$defs/sha256" },
74
+ "comparison": {
75
+ "type": "object",
76
+ "properties": {
77
+ "state": { "enum": ["matched", "not_compared"] }
78
+ }
79
+ }
80
+ }
81
+ },
82
+ "signature": {
83
+ "type": "object",
84
+ "required": ["state"],
85
+ "additionalProperties": false,
86
+ "properties": {
87
+ "state": { "enum": ["verified", "not_checked", "absent"] },
88
+ "issuer": { "type": "string", "minLength": 1 }
89
+ }
90
+ },
91
+ "trace": {
92
+ "type": "object",
93
+ "required": [
94
+ "payload_encoding",
95
+ "loaded_by",
96
+ "loaded_at",
97
+ "input_kind",
98
+ "runtime_eligible",
99
+ "schema_valid",
100
+ "signature_state",
101
+ "profile"
102
+ ],
103
+ "additionalProperties": false,
104
+ "properties": {
105
+ "payload_encoding": { "const": "cbor" },
106
+ "loaded_by": { "const": "kdna-core" },
107
+ "loaded_at": { "type": "string", "format": "date-time" },
108
+ "input_kind": { "enum": ["packaged_file", "packaged_bytes"] },
109
+ "runtime_eligible": { "const": true },
110
+ "schema_valid": { "const": true },
111
+ "signature_state": { "enum": ["verified", "not_checked", "absent"] },
112
+ "profile": { "enum": ["index", "compact", "scenario", "full"] }
113
+ }
114
+ }
115
+ }
116
+ }