@intentset/publisher 0.12.0 → 0.13.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.
package/dist/index.d.ts CHANGED
@@ -11,6 +11,6 @@ export { EXCLUSION_REASONS, type Exclusion, type ExclusionReason, type ProjectOp
11
11
  export { type PublicationIndex, type PublishOptions, type PublishResult, type PublishedDocument, REFUSAL_REASONS, type RefusalReason, publish, renderDocument, } from "./publish.ts";
12
12
  export { type Reference, type ReferenceKind, checkReferences, checkTitles, findReferences, resolveTarget, titlePattern, } from "./references.ts";
13
13
  export { type IndexedRequest, PROJECTION_ADMITS, type PublicationRequest, REQUEST_DIMENSIONS, type RequestDimension, admits, checkRequest, indexedRequest, } from "./request.ts";
14
- export { CURRENT_PIN, REVIEW_EXTENSION, type ReviewRecord, type ReviewStatus, bindReviewPins, knowledgeReport, readReviewRecord, reviewSources, reviewStatus, } from "./review.ts";
14
+ export { CURRENT_PIN, PIN_KINDS, type PinKind, REVIEW_EXTENSION, type ReviewRecord, type ReviewStatus, bindReviewPins, knowledgeReport, pinHash, readReviewRecord, reviewSources, reviewStatus, } from "./review.ts";
15
15
  export { YamlEmitError, type YamlValue, emitYaml } from "./yaml.ts";
16
16
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,KAAK,KAAK,EAAE,KAAK,YAAY,EAAE,KAAK,WAAW,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACxF,OAAO,EACL,KAAK,eAAe,EACpB,KAAK,iBAAiB,EACtB,eAAe,EACf,mBAAmB,EACnB,KAAK,eAAe,EACpB,KAAK,WAAW,EAChB,cAAc,EACd,gBAAgB,EAChB,UAAU,EACV,aAAa,EACb,eAAe,GAChB,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,SAAS,EACT,YAAY,EACZ,KAAK,QAAQ,EACb,KAAK,aAAa,EAClB,KAAK,WAAW,EAChB,KAAK,OAAO,EACZ,QAAQ,GACT,MAAM,WAAW,CAAC;AACnB,OAAO,EACL,iBAAiB,EACjB,KAAK,SAAS,EACd,KAAK,eAAe,EACpB,KAAK,cAAc,EACnB,KAAK,UAAU,EACf,KAAK,QAAQ,EACb,eAAe,EACf,cAAc,EACd,OAAO,GACR,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,KAAK,gBAAgB,EACrB,KAAK,cAAc,EACnB,KAAK,aAAa,EAClB,KAAK,iBAAiB,EACtB,eAAe,EACf,KAAK,aAAa,EAClB,OAAO,EACP,cAAc,GACf,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,KAAK,SAAS,EACd,KAAK,aAAa,EAClB,eAAe,EACf,WAAW,EACX,cAAc,EACd,aAAa,EACb,YAAY,GACb,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,KAAK,cAAc,EACnB,iBAAiB,EACjB,KAAK,kBAAkB,EACvB,kBAAkB,EAClB,KAAK,gBAAgB,EACrB,MAAM,EACN,YAAY,EACZ,cAAc,GACf,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,WAAW,EACX,gBAAgB,EAChB,KAAK,YAAY,EACjB,KAAK,YAAY,EACjB,cAAc,EACd,eAAe,EACf,gBAAgB,EAChB,aAAa,EACb,YAAY,GACb,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,aAAa,EAAE,KAAK,SAAS,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,KAAK,KAAK,EAAE,KAAK,YAAY,EAAE,KAAK,WAAW,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAC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js CHANGED
@@ -11,6 +11,6 @@ export { EXCLUSION_REASONS, exclusionReason, plannedSources, project, } from "./
11
11
  export { REFUSAL_REASONS, publish, renderDocument, } from "./publish.js";
12
12
  export { checkReferences, checkTitles, findReferences, resolveTarget, titlePattern, } from "./references.js";
13
13
  export { PROJECTION_ADMITS, REQUEST_DIMENSIONS, admits, checkRequest, indexedRequest, } from "./request.js";
14
- export { CURRENT_PIN, REVIEW_EXTENSION, bindReviewPins, knowledgeReport, readReviewRecord, reviewSources, reviewStatus, } from "./review.js";
14
+ export { CURRENT_PIN, PIN_KINDS, REVIEW_EXTENSION, bindReviewPins, knowledgeReport, pinHash, readReviewRecord, reviewSources, reviewStatus, } from "./review.js";
15
15
  export { YamlEmitError, emitYaml } from "./yaml.js";
16
16
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAmD,QAAQ,EAAE,MAAM,aAAa,CAAC;AACxF,OAAO,EAGL,eAAe,EACf,mBAAmB,EAGnB,cAAc,EACd,gBAAgB,EAChB,UAAU,EACV,aAAa,EACb,eAAe,GAChB,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,SAAS,EACT,YAAY,EAKZ,QAAQ,GACT,MAAM,WAAW,CAAC;AACnB,OAAO,EACL,iBAAiB,EAMjB,eAAe,EACf,cAAc,EACd,OAAO,GACR,MAAM,cAAc,CAAC;AACtB,OAAO,EAKL,eAAe,EAEf,OAAO,EACP,cAAc,GACf,MAAM,cAAc,CAAC;AACtB,OAAO,EAGL,eAAe,EACf,WAAW,EACX,cAAc,EACd,aAAa,EACb,YAAY,GACb,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAEL,iBAAiB,EAEjB,kBAAkB,EAElB,MAAM,EACN,YAAY,EACZ,cAAc,GACf,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,WAAW,EACX,gBAAgB,EAGhB,cAAc,EACd,eAAe,EACf,gBAAgB,EAChB,aAAa,EACb,YAAY,GACb,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,aAAa,EAAkB,QAAQ,EAAE,MAAM,WAAW,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAmD,QAAQ,EAAE,MAAM,aAAa,CAAC;AACxF,OAAO,EAGL,eAAe,EACf,mBAAmB,EAGnB,cAAc,EACd,gBAAgB,EAChB,UAAU,EACV,aAAa,EACb,eAAe,GAChB,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,SAAS,EACT,YAAY,EAKZ,QAAQ,GACT,MAAM,WAAW,CAAC;AACnB,OAAO,EACL,iBAAiB,EAMjB,eAAe,EACf,cAAc,EACd,OAAO,GACR,MAAM,cAAc,CAAC;AACtB,OAAO,EAKL,eAAe,EAEf,OAAO,EACP,cAAc,GACf,MAAM,cAAc,CAAC;AACtB,OAAO,EAGL,eAAe,EACf,WAAW,EACX,cAAc,EACd,aAAa,EACb,YAAY,GACb,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAEL,iBAAiB,EAEjB,kBAAkB,EAElB,MAAM,EACN,YAAY,EACZ,cAAc,GACf,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,WAAW,EACX,SAAS,EAET,gBAAgB,EAGhB,cAAc,EACd,eAAe,EACf,OAAO,EACP,gBAAgB,EAChB,aAAa,EACb,YAAY,GACb,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,aAAa,EAAkB,QAAQ,EAAE,MAAM,WAAW,CAAC"}
package/dist/review.d.ts CHANGED
@@ -18,17 +18,31 @@
18
18
  * rules that govern each explained behavior: a rule changing under a behavior
19
19
  * changes what the behavior promises, which is catalog case P04.
20
20
  *
21
+ * A pin is one of two kinds, named by the record's `hash` (publication §3,
22
+ * ADR 0018). Without `hash`, a pin is the source's `sourceHash`, the bytes of
23
+ * the whole file, which every review made before 0.13.0 holds. With
24
+ * `hash: content-v1`, it is the source's `contentHash`, which leaves out the
25
+ * lifecycle and review fields, so approving or implementing a source, or
26
+ * marking its delivery, leaves the knowledge current. Any other `hash` is a
27
+ * kind this version does not know: every pin reads as changed.
28
+ *
21
29
  * A pin of the literal `@current` is a fixture placeholder: `bindReviewPins`
22
- * replaces it with the source's hash in the snapshot being checked, so a
23
- * case can say "reviewed against what is there now" without computing a
24
- * hash. Unbound, it never equals a hash, so it reads as changed.
30
+ * replaces it with the source's hash of the record's kind in the snapshot
31
+ * being checked, so a case can say "reviewed against what is there now"
32
+ * without computing a hash. Unbound, it never equals a hash, so it reads as
33
+ * changed.
25
34
  */
26
35
  import { type Artifact, type Graph, type KnowledgeReportSection } from "@intentset/core";
27
36
  export declare const REVIEW_EXTENSION = "intentset.org/review";
28
37
  export declare const CURRENT_PIN = "@current";
38
+ /** The pin kinds a review record can name in `hash` (publication §3). Absent means `source`, the whole file. */
39
+ export declare const PIN_KINDS: readonly ["content-v1"];
40
+ export type PinKind = (typeof PIN_KINDS)[number];
29
41
  export interface ReviewRecord {
30
42
  /** Source ID -> the source hash it was reviewed against. Entries that are not strings are dropped. */
31
43
  sources: Record<string, string>;
44
+ /** What the pins hash: absent for the whole file, `content-v1` for the content hash, anything else unknown. */
45
+ hash?: string;
32
46
  snapshot?: string;
33
47
  }
34
48
  export interface ReviewStatus {
@@ -37,6 +51,8 @@ export interface ReviewStatus {
37
51
  changed: string[];
38
52
  /** Sources the review record does not pin. */
39
53
  missing: string[];
54
+ /** The record's `hash` when this version does not know it, so no pin can match; null otherwise. */
55
+ unknownHash: string | null;
40
56
  /** `reviewedBy`, or null when the knowledge names no reviewer. */
41
57
  reviewer: string | null;
42
58
  /** `reviewedAt`, or null when absent. */
@@ -48,6 +64,8 @@ export declare function reviewSources(graph: Graph, artifact: Artifact): string[
48
64
  export declare function readReviewRecord(artifact: Artifact): ReviewRecord | null;
49
65
  /** Core §9: whether the knowledge is current against the sources it was reviewed against. */
50
66
  export declare function reviewStatus(graph: Graph, artifact: Artifact): ReviewStatus;
67
+ /** The hash a pin of this kind holds for a source, or null for a kind this version does not know. */
68
+ export declare function pinHash(kind: string | undefined): ((source: Artifact) => string) | null;
51
69
  /**
52
70
  * Bind every `@current` pin to the pinned source's hash in this graph, for
53
71
  * fixtures. Returns a new graph; the given one is not modified, and nothing
@@ -1 +1 @@
1
- {"version":3,"file":"review.d.ts","sourceRoot":"","sources":["../src/review.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,OAAO,EAAE,KAAK,QAAQ,EAAE,KAAK,KAAK,EAAa,KAAK,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AAGpG,eAAO,MAAM,gBAAgB,yBAAyB,CAAC;AACvD,eAAO,MAAM,WAAW,aAAa,CAAC;AAEtC,MAAM,WAAW,YAAY;IAC3B,sGAAsG;IACtG,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,SAAS,GAAG,cAAc,CAAC;IACnC,2FAA2F;IAC3F,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,8CAA8C;IAC9C,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,kEAAkE;IAClE,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,yCAAyC;IACzC,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3B;AAED,oHAAoH;AACpH,wBAAgB,aAAa,CAAC,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,GAAG,MAAM,EAAE,CAQxE;AAED,iHAAiH;AACjH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,QAAQ,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UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3B;AAED,oHAAoH;AACpH,wBAAgB,aAAa,CAAC,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,GAAG,MAAM,EAAE,CAQxE;AAED,iHAAiH;AACjH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,QAAQ,GAAG,YAAY,GAAG,IAAI,CAYxE;AAED,6FAA6F;AAC7F,wBAAgB,YAAY,CAAC,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,GAAG,YAAY,CAgB3E;AAED,qGAAqG;AACrG,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,CAAC,CAAC,MAAM,EAAE,QAAQ,KAAK,MAAM,CAAC,GAAG,IAAI,CAIvF;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,KAAK,GAAG,KAAK,CAkBlD;AAUD;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,KAAK,GAAG,sBAAsB,CAoBpE"}
package/dist/review.js CHANGED
@@ -18,15 +18,26 @@
18
18
  * rules that govern each explained behavior: a rule changing under a behavior
19
19
  * changes what the behavior promises, which is catalog case P04.
20
20
  *
21
+ * A pin is one of two kinds, named by the record's `hash` (publication §3,
22
+ * ADR 0018). Without `hash`, a pin is the source's `sourceHash`, the bytes of
23
+ * the whole file, which every review made before 0.13.0 holds. With
24
+ * `hash: content-v1`, it is the source's `contentHash`, which leaves out the
25
+ * lifecycle and review fields, so approving or implementing a source, or
26
+ * marking its delivery, leaves the knowledge current. Any other `hash` is a
27
+ * kind this version does not know: every pin reads as changed.
28
+ *
21
29
  * A pin of the literal `@current` is a fixture placeholder: `bindReviewPins`
22
- * replaces it with the source's hash in the snapshot being checked, so a
23
- * case can say "reviewed against what is there now" without computing a
24
- * hash. Unbound, it never equals a hash, so it reads as changed.
30
+ * replaces it with the source's hash of the record's kind in the snapshot
31
+ * being checked, so a case can say "reviewed against what is there now"
32
+ * without computing a hash. Unbound, it never equals a hash, so it reads as
33
+ * changed.
25
34
  */
26
35
  import { graphHash } from "@intentset/core";
27
36
  import { compareStrings, sortedUnique } from "./diagnostic.js";
28
37
  export const REVIEW_EXTENSION = "intentset.org/review";
29
38
  export const CURRENT_PIN = "@current";
39
+ /** The pin kinds a review record can name in `hash` (publication §3). Absent means `source`, the whole file. */
40
+ export const PIN_KINDS = ["content-v1"];
30
41
  /** The sources a review must pin: everything explained, and the rules governing each explained behavior. Sorted. */
31
42
  export function reviewSources(graph, artifact) {
32
43
  const ids = [];
@@ -50,6 +61,8 @@ export function readReviewRecord(artifact) {
50
61
  sources[id] = pin;
51
62
  }
52
63
  const record = { sources };
64
+ if (value.hash !== undefined)
65
+ record.hash = typeof value.hash === "string" ? value.hash : JSON.stringify(value.hash);
53
66
  if (typeof value.snapshot === "string")
54
67
  record.snapshot = value.snapshot;
55
68
  return record;
@@ -57,19 +70,30 @@ export function readReviewRecord(artifact) {
57
70
  /** Core §9: whether the knowledge is current against the sources it was reviewed against. */
58
71
  export function reviewStatus(graph, artifact) {
59
72
  const record = readReviewRecord(artifact);
73
+ const hashOf = pinHash(record?.hash);
74
+ const unknownHash = record?.hash !== undefined && hashOf === null ? record.hash : null;
60
75
  const changed = [];
61
76
  const missing = [];
62
77
  for (const id of reviewSources(graph, artifact)) {
63
78
  const pin = record?.sources[id];
79
+ const source = graph.artifacts.get(id);
64
80
  if (pin === undefined)
65
81
  missing.push(id);
66
- else if (graph.artifacts.get(id)?.sourceHash !== pin)
82
+ else if (source === undefined || hashOf === null || hashOf(source) !== pin)
67
83
  changed.push(id);
68
84
  }
69
85
  const reviewer = nonEmpty(artifact.meta.reviewedBy);
70
86
  const reviewedAt = nonEmpty(artifact.meta.reviewedAt);
71
87
  const current = changed.length === 0 && missing.length === 0 && reviewer !== null && reviewedAt !== null;
72
- return { status: current ? "current" : "needs-review", changed, missing, reviewer, reviewedAt };
88
+ return { status: current ? "current" : "needs-review", changed, missing, unknownHash, reviewer, reviewedAt };
89
+ }
90
+ /** The hash a pin of this kind holds for a source, or null for a kind this version does not know. */
91
+ export function pinHash(kind) {
92
+ if (kind === undefined)
93
+ return (source) => source.sourceHash;
94
+ if (kind === "content-v1")
95
+ return (source) => source.contentHash;
96
+ return null;
73
97
  }
74
98
  /**
75
99
  * Bind every `@current` pin to the pinned source's hash in this graph, for
@@ -85,9 +109,11 @@ export function bindReviewPins(graph) {
85
109
  artifacts.set(id, artifact);
86
110
  continue;
87
111
  }
112
+ const hashOf = pinHash(typeof value.hash === "string" || value.hash === undefined ? value.hash : "");
88
113
  const sources = {};
89
114
  for (const [source, pin] of Object.entries(value.sources)) {
90
- sources[source] = pin === CURRENT_PIN ? (graph.artifacts.get(source)?.sourceHash ?? pin) : pin;
115
+ const found = graph.artifacts.get(source);
116
+ sources[source] = pin === CURRENT_PIN && found !== undefined && hashOf !== null ? hashOf(found) : pin;
91
117
  }
92
118
  const extensions = { ...artifact.meta.extensions, [REVIEW_EXTENSION]: { ...value, sources } };
93
119
  artifacts.set(id, { ...artifact, meta: { ...artifact.meta, extensions } });
@@ -1 +1 @@
1
- {"version":3,"file":"review.js","sourceRoot":"","sources":["../src/review.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,OAAO,EAA6B,SAAS,EAA+B,MAAM,iBAAiB,CAAC;AACpG,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/D,MAAM,CAAC,MAAM,gBAAgB,GAAG,sBAAsB,CAAC;AACvD,MAAM,CAAC,MAAM,WAAW,GAAG,UAAU,CAAC;AAoBtC,oHAAoH;AACpH,MAAM,UAAU,aAAa,CAAC,KAAY,EAAE,QAAkB;IAC5D,MAAM,GAAG,GAAa,EAAE,CAAC;IACzB,KAAK,MAAM,EAAE,IAAI,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,IAAI,EAAE,EAAE,CAAC;QACpD,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AC,KAAK,EAAE,QAAQ,CAAC;gBACvC,OAAO,EAAE,CAAC,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,cAAc,CAAC;gBACjD,OAAO,EAAE,CAAC,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,cAAc,CAAC;gBACjD,QAAQ,EAAE,CAAC;aACZ,CAAC;QACJ,CAAC,CAAC;KACH,CAAC;AACJ,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@intentset/publisher",
3
- "version": "0.12.0",
3
+ "version": "0.13.0",
4
4
  "description": "Audience and release projection of reviewed knowledge into Markset documents with provenance.",
5
5
  "keywords": [
6
6
  "intentset",
@@ -35,8 +35,8 @@
35
35
  }
36
36
  },
37
37
  "dependencies": {
38
- "@intentset/core": "^0.12.0",
39
- "@intentset/markset-adapter": "^0.12.0",
38
+ "@intentset/core": "^0.13.0",
39
+ "@intentset/markset-adapter": "^0.13.0",
40
40
  "@markset-lang/parser": "0.4.1",
41
41
  "@markset-lang/render-html": "0.4.1"
42
42
  }
package/src/index.ts CHANGED
@@ -69,11 +69,14 @@ export {
69
69
  } from "./request.ts";
70
70
  export {
71
71
  CURRENT_PIN,
72
+ PIN_KINDS,
73
+ type PinKind,
72
74
  REVIEW_EXTENSION,
73
75
  type ReviewRecord,
74
76
  type ReviewStatus,
75
77
  bindReviewPins,
76
78
  knowledgeReport,
79
+ pinHash,
77
80
  readReviewRecord,
78
81
  reviewSources,
79
82
  reviewStatus,
package/src/review.ts CHANGED
@@ -18,20 +18,34 @@
18
18
  * rules that govern each explained behavior: a rule changing under a behavior
19
19
  * changes what the behavior promises, which is catalog case P04.
20
20
  *
21
+ * A pin is one of two kinds, named by the record's `hash` (publication §3,
22
+ * ADR 0018). Without `hash`, a pin is the source's `sourceHash`, the bytes of
23
+ * the whole file, which every review made before 0.13.0 holds. With
24
+ * `hash: content-v1`, it is the source's `contentHash`, which leaves out the
25
+ * lifecycle and review fields, so approving or implementing a source, or
26
+ * marking its delivery, leaves the knowledge current. Any other `hash` is a
27
+ * kind this version does not know: every pin reads as changed.
28
+ *
21
29
  * A pin of the literal `@current` is a fixture placeholder: `bindReviewPins`
22
- * replaces it with the source's hash in the snapshot being checked, so a
23
- * case can say "reviewed against what is there now" without computing a
24
- * hash. Unbound, it never equals a hash, so it reads as changed.
30
+ * replaces it with the source's hash of the record's kind in the snapshot
31
+ * being checked, so a case can say "reviewed against what is there now"
32
+ * without computing a hash. Unbound, it never equals a hash, so it reads as
33
+ * changed.
25
34
  */
26
35
  import { type Artifact, type Graph, graphHash, type KnowledgeReportSection } from "@intentset/core";
27
36
  import { compareStrings, sortedUnique } from "./diagnostic.ts";
28
37
 
29
38
  export const REVIEW_EXTENSION = "intentset.org/review";
30
39
  export const CURRENT_PIN = "@current";
40
+ /** The pin kinds a review record can name in `hash` (publication §3). Absent means `source`, the whole file. */
41
+ export const PIN_KINDS = ["content-v1"] as const;
42
+ export type PinKind = (typeof PIN_KINDS)[number];
31
43
 
32
44
  export interface ReviewRecord {
33
45
  /** Source ID -> the source hash it was reviewed against. Entries that are not strings are dropped. */
34
46
  sources: Record<string, string>;
47
+ /** What the pins hash: absent for the whole file, `content-v1` for the content hash, anything else unknown. */
48
+ hash?: string;
35
49
  snapshot?: string;
36
50
  }
37
51
 
@@ -41,6 +55,8 @@ export interface ReviewStatus {
41
55
  changed: string[];
42
56
  /** Sources the review record does not pin. */
43
57
  missing: string[];
58
+ /** The record's `hash` when this version does not know it, so no pin can match; null otherwise. */
59
+ unknownHash: string | null;
44
60
  /** `reviewedBy`, or null when the knowledge names no reviewer. */
45
61
  reviewer: string | null;
46
62
  /** `reviewedAt`, or null when absent. */
@@ -68,6 +84,7 @@ export function readReviewRecord(artifact: Artifact): ReviewRecord | null {
68
84
  if (typeof pin === "string") sources[id] = pin;
69
85
  }
70
86
  const record: ReviewRecord = { sources };
87
+ if (value.hash !== undefined) record.hash = typeof value.hash === "string" ? value.hash : JSON.stringify(value.hash);
71
88
  if (typeof value.snapshot === "string") record.snapshot = value.snapshot;
72
89
  return record;
73
90
  }
@@ -75,17 +92,27 @@ export function readReviewRecord(artifact: Artifact): ReviewRecord | null {
75
92
  /** Core §9: whether the knowledge is current against the sources it was reviewed against. */
76
93
  export function reviewStatus(graph: Graph, artifact: Artifact): ReviewStatus {
77
94
  const record = readReviewRecord(artifact);
95
+ const hashOf = pinHash(record?.hash);
96
+ const unknownHash = record?.hash !== undefined && hashOf === null ? record.hash : null;
78
97
  const changed: string[] = [];
79
98
  const missing: string[] = [];
80
99
  for (const id of reviewSources(graph, artifact)) {
81
100
  const pin = record?.sources[id];
101
+ const source = graph.artifacts.get(id);
82
102
  if (pin === undefined) missing.push(id);
83
- else if (graph.artifacts.get(id)?.sourceHash !== pin) changed.push(id);
103
+ else if (source === undefined || hashOf === null || hashOf(source) !== pin) changed.push(id);
84
104
  }
85
105
  const reviewer = nonEmpty(artifact.meta.reviewedBy);
86
106
  const reviewedAt = nonEmpty(artifact.meta.reviewedAt);
87
107
  const current = changed.length === 0 && missing.length === 0 && reviewer !== null && reviewedAt !== null;
88
- return { status: current ? "current" : "needs-review", changed, missing, reviewer, reviewedAt };
108
+ return { status: current ? "current" : "needs-review", changed, missing, unknownHash, reviewer, reviewedAt };
109
+ }
110
+
111
+ /** The hash a pin of this kind holds for a source, or null for a kind this version does not know. */
112
+ export function pinHash(kind: string | undefined): ((source: Artifact) => string) | null {
113
+ if (kind === undefined) return (source) => source.sourceHash;
114
+ if (kind === "content-v1") return (source) => source.contentHash;
115
+ return null;
89
116
  }
90
117
 
91
118
  /**
@@ -102,9 +129,11 @@ export function bindReviewPins(graph: Graph): Graph {
102
129
  artifacts.set(id, artifact);
103
130
  continue;
104
131
  }
132
+ const hashOf = pinHash(typeof value.hash === "string" || value.hash === undefined ? value.hash : "");
105
133
  const sources: Record<string, unknown> = {};
106
134
  for (const [source, pin] of Object.entries(value.sources)) {
107
- sources[source] = pin === CURRENT_PIN ? (graph.artifacts.get(source)?.sourceHash ?? pin) : pin;
135
+ const found = graph.artifacts.get(source);
136
+ sources[source] = pin === CURRENT_PIN && found !== undefined && hashOf !== null ? hashOf(found) : pin;
108
137
  }
109
138
  const extensions = { ...artifact.meta.extensions, [REVIEW_EXTENSION]: { ...value, sources } };
110
139
  artifacts.set(id, { ...artifact, meta: { ...artifact.meta, extensions } });