@aikdna/kdna-core 0.15.2 → 0.15.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,33 @@
1
1
  # Changelog
2
2
 
3
+ ## v0.15.4 (2026-06-28)
4
+
5
+ Audit follow-ups (2026-06-28 round-trip verification). This release
6
+ keeps the canonicalisation paths in sync across producers (studio-cli
7
+ `manifestForSigning`, kdna-cli `publish.js#manifestForSigning`,
8
+ kdna-studio-core `buildPayload`, kdna-core's own verifier) so a
9
+ signature generated by one tool is accepted by every other.
10
+
11
+ - **manifestForSignature now recursively strips `authoring.content_digest`.**
12
+ Prior version only stripped the top-level content_digest. The digest
13
+ builder (`manifestForDigest`) has always stripped the nested field
14
+ too, so a manifest that contained an `authoring` block with a
15
+ `content_digest` would hash differently for signing vs. digest and
16
+ report a false-positive verification failure.
17
+ - **asset-reader canonicalisation is now the single source of truth**
18
+ for the list of fields the signing payload excludes. Documented
19
+ in `docs/CANONICALIZATION.md`.
20
+
21
+ ## v0.15.3 (2026-06-27)
22
+ - Fix (PC-2, real): `renderPromptItem` now actually ships the
23
+ boundary card branch. The previous v0.15.2 release (ee20c5e)
24
+ bumped package.json and added a CHANGELOG entry but did NOT
25
+ include the source change to `src/v1/index.js`. This release
26
+ re-bundles the fix that landed in 46047fb (PC-1/PC-4 cleanup).
27
+ Verified end-to-end: `kdna-studio card add boundary` with
28
+ non-empty `scope` + `out_of_scope` → `kdna load` now prints
29
+ `in scope: X; out of scope: Y` instead of the UUID `id`.
30
+
3
31
  ## v0.15.2 (2026-06-27)
4
32
  - Fix (PC-2): `renderPromptItem` now renders boundary cards as
5
33
  `in scope: X; out of scope: Y; exceptions: ...` instead of
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aikdna/kdna-core",
3
- "version": "0.15.2",
3
+ "version": "0.15.4",
4
4
  "description": "KDNA Core library for validating, planning, and loading local .kdna judgment assets.",
5
5
  "engines": {
6
6
  "node": ">=18.0.0"
@@ -204,6 +204,14 @@ function buildContentDigest(asset) {
204
204
  }
205
205
 
206
206
  function manifestForSignature(manifest, { stripDigestFields = true } = {}) {
207
+ // Mirrors manifestForDigest above. The two must agree on every field
208
+ // they strip, or the signing and digest paths will hash different
209
+ // representations of the same manifest and verifiers will report a
210
+ // mismatch on otherwise-valid assets.
211
+ //
212
+ // Bug: prior version omitted the `authoring.content_digest` strip
213
+ // that manifestForDigest performs, so the signing payload included
214
+ // a digest field that the digest payload did not.
207
215
  const copy = { ...(manifest || {}) };
208
216
  delete copy.signature;
209
217
  delete copy._source;
@@ -211,6 +219,11 @@ function manifestForSignature(manifest, { stripDigestFields = true } = {}) {
211
219
  delete copy.asset_digest;
212
220
  delete copy.container_sha256;
213
221
  delete copy.content_digest;
222
+ if (copy.authoring && typeof copy.authoring === 'object') {
223
+ const auth = { ...copy.authoring };
224
+ delete auth.content_digest;
225
+ copy.authoring = auth;
226
+ }
214
227
  }
215
228
  return copy;
216
229
  }
package/src/v1/index.js CHANGED
@@ -1509,6 +1509,30 @@ function renderPromptItem(item) {
1509
1509
  if (item.failure_risk) parts.push(`failure risk: ${item.failure_risk}`);
1510
1510
  return parts.join(' — ');
1511
1511
  }
1512
+ // Boundary card: kdna-studio writes { id, scope, out_of_scope,
1513
+ // acceptable_exceptions }. Render the scope/out-of-scope rule
1514
+ // instead of falling through to the UUID `id` (which was the
1515
+ // v0.15.0 behavior and made boundaries unreadable in
1516
+ // `kdna load --as=prompt`).
1517
+ if (
1518
+ item.type === 'boundary' ||
1519
+ (item.scope !== undefined && item.out_of_scope !== undefined)
1520
+ ) {
1521
+ const parts = [];
1522
+ if (item.scope) parts.push(`in scope: ${sanitizePrompt(item.scope)}`);
1523
+ if (item.out_of_scope) parts.push(`out of scope: ${sanitizePrompt(item.out_of_scope)}`);
1524
+ if (Array.isArray(item.acceptable_exceptions) && item.acceptable_exceptions.length) {
1525
+ parts.push(`exceptions: ${item.acceptable_exceptions.map(sanitizePrompt).join('; ')}`);
1526
+ }
1527
+ if (parts.length === 0) {
1528
+ // Boundary card with empty scope/out_of_scope: surface as
1529
+ // "(boundary card with empty scope)" instead of falling through
1530
+ // to the UUID `id`. The author should fill in scope/out_of_scope
1531
+ // before publishing.
1532
+ return '(boundary card with empty scope)';
1533
+ }
1534
+ return parts.join('; ');
1535
+ }
1512
1536
  if (item.boundary && item.one_sentence) return `${item.one_sentence}: ${item.boundary}`;
1513
1537
  if (item.stance) return item.stance;
1514
1538
  if (item.statement) return item.statement;
@@ -1521,8 +1545,16 @@ function renderPromptItem(item) {
1521
1545
  if (item.one_sentence) return item.one_sentence;
1522
1546
  if (item.essence) return item.essence;
1523
1547
  if (item.question) return item.question;
1524
- if (item.id) return item.id;
1525
- return JSON.stringify(item);
1548
+ // Last-resort fall-through. Returning the id (e.g. "bo_xxxx-...") makes
1549
+ // the output unreadable; prefer a note that the card is unrecognized.
1550
+ return `(unrendered card: ${item.type || 'unknown'})`;
1551
+ }
1552
+
1553
+ function sanitizePrompt(s) {
1554
+ if (s === undefined || s === null) return '';
1555
+ if (typeof s === 'string') return s;
1556
+ if (Array.isArray(s)) return s.map(sanitizePrompt).join('; ');
1557
+ return String(s);
1526
1558
  }
1527
1559
 
1528
1560
  function loadAuthorized(inputPath, opts = {}) {