@kashscript/hudhud 0.1.0 → 0.2.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 (44) hide show
  1. package/LICENSE +135 -133
  2. package/README.md +11 -0
  3. package/dist/certificate/certificate.d.ts +11 -4
  4. package/dist/certificate/certificate.d.ts.map +1 -1
  5. package/dist/certificate/certificate.js +21 -18
  6. package/dist/certificate/certificate.js.map +1 -1
  7. package/dist/certificate/html.d.ts.map +1 -1
  8. package/dist/certificate/html.js +1 -2
  9. package/dist/certificate/html.js.map +1 -1
  10. package/dist/errors.d.ts +29 -2
  11. package/dist/errors.d.ts.map +1 -1
  12. package/dist/errors.js +6 -2
  13. package/dist/errors.js.map +1 -1
  14. package/dist/exception/index.d.ts +127 -24
  15. package/dist/exception/index.d.ts.map +1 -1
  16. package/dist/exception/index.js +209 -15
  17. package/dist/exception/index.js.map +1 -1
  18. package/dist/index.d.ts +1 -1
  19. package/dist/index.js +1 -1
  20. package/dist/ledger/writer.d.ts +10 -2
  21. package/dist/ledger/writer.d.ts.map +1 -1
  22. package/dist/ledger/writer.js +16 -4
  23. package/dist/ledger/writer.js.map +1 -1
  24. package/dist/runtime/escalation.d.ts +5 -0
  25. package/dist/runtime/escalation.d.ts.map +1 -1
  26. package/dist/runtime/escalation.js +15 -3
  27. package/dist/runtime/escalation.js.map +1 -1
  28. package/dist/sop/compiler.d.ts.map +1 -1
  29. package/dist/sop/compiler.js +2 -2
  30. package/dist/sop/compiler.js.map +1 -1
  31. package/dist/sop/service.d.ts +5 -0
  32. package/dist/sop/service.d.ts.map +1 -1
  33. package/dist/sop/service.js +25 -6
  34. package/dist/sop/service.js.map +1 -1
  35. package/package.json +3 -3
  36. package/src/certificate/certificate.ts +25 -17
  37. package/src/certificate/html.ts +1 -2
  38. package/src/errors.ts +27 -2
  39. package/src/exception/index.ts +315 -33
  40. package/src/index.ts +1 -1
  41. package/src/ledger/writer.ts +24 -4
  42. package/src/runtime/escalation.ts +21 -9
  43. package/src/sop/compiler.ts +2 -1
  44. package/src/sop/service.ts +30 -5
@@ -1,13 +1,32 @@
1
- /** The failure classes. No "unclassified": classification is mandatory. */
1
+ import type { RelationshipSigningKey } from "@kashscript/identity-server";
2
+ export { ExceptionClassificationError } from "../errors";
3
+ /** The model-failure classes — v1's mandatory class, v2's OPTIONAL one
4
+ * (meaningful only when a model was involved). No "unclassified". */
2
5
  export declare const FAILURE_CLASSES: readonly ["judgment", "gap-filling", "ambiguous"];
3
6
  export type FailureClass = (typeof FAILURE_CLASSES)[number];
4
- /** DST so a classification signature can't replay as a ledger/attestation sig.
5
- * Neutral default; a venture passes its own DST at swap for wire-compat. */
7
+ /** d43 §4.2 — how a doer deviated. Mandatory on v2 records; no default, no
8
+ * "unclassified". error adjust the system, not the person · at-risk → coach
9
+ * · reckless → the only punitive branch · improvement → adopt. */
10
+ export declare const DEVIATION_CLASSES: readonly ["error", "at-risk", "reckless", "improvement"];
11
+ export type DeviationClass = (typeof DEVIATION_CLASSES)[number];
12
+ /** v1 signed label (DST) — v1 records verify under it forever. New records are
13
+ * v2 (`HUDHUD_EXCEPTION_CLASSIFICATION_V2_DST`). */
6
14
  export declare const HUDHUD_EXCEPTION_CLASSIFICATION_DST: "kash-exception-classification-v1\n";
15
+ /** v1 schema label — frozen; see `EXCEPTION_CLASSIFICATION_SCHEMA_VERSION_V2`. */
7
16
  export declare const EXCEPTION_CLASSIFICATION_SCHEMA_VERSION: "exception-classification/1";
8
- /** The mandatory gate throws `ExceptionClassificationError` if `value` is
9
- * absent/empty or not one of the classes. NOT merely the TS type. */
17
+ /** v2 labelsregistered in `@kashscript/attest/dst` (0.1.7) before first use. */
18
+ export declare const HUDHUD_EXCEPTION_CLASSIFICATION_V2_DST: "kash-exception-classification-v2\n";
19
+ export declare const EXCEPTION_CLASSIFICATION_SCHEMA_VERSION_V2: "exception-classification/2";
20
+ /** The doer's countersignature DST — so it can never replay as the operator's. */
21
+ export declare const HUDHUD_EXCEPTION_DOER_ACCOUNT_DST: "kash-exception-doer-account-v1\n";
22
+ /** The v1 mandatory gate — throws `ExceptionClassificationError` if `value` is
23
+ * absent/empty or not one of the classes. NOT merely the TS type.
24
+ * @deprecated New records are v2: gate with `assertDeviationClass`; the model
25
+ * class is optional there. Kept so existing callers compile unchanged. */
10
26
  export declare function assertFailureClass(value: unknown): asserts value is FailureClass;
27
+ /** The v2 mandatory gate — throws `ExceptionClassificationError` if `value` is
28
+ * absent/empty or not one of the four deviation classes. */
29
+ export declare function assertDeviationClass(value: unknown): asserts value is DeviationClass;
11
30
  export interface ExceptionClassificationInput {
12
31
  readonly failureClass: FailureClass;
13
32
  readonly failureTag: string;
@@ -45,8 +64,9 @@ export interface ExceptionClassificationRecord {
45
64
  readonly signoffLedgerStepIndex: number | null;
46
65
  readonly signedEnvelope: ClassificationSignedEnvelope;
47
66
  }
48
- /** Mint + sign a classification record (id/timestamp minted into the signed
49
- * payload). Throws the mandatory gate if `failureClass` is missing/invalid. */
67
+ /** Mint + sign a v1 classification record (id/timestamp minted into the signed
68
+ * payload). Throws the mandatory gate if `failureClass` is missing/invalid.
69
+ * @deprecated Mint v2 with `buildSignedDeviationClassification` (d43). */
50
70
  export declare function buildSignedClassification(input: ExceptionClassificationInput, operator: {
51
71
  readonly did: string;
52
72
  readonly privateKey: Uint8Array;
@@ -54,30 +74,111 @@ export declare function buildSignedClassification(input: ExceptionClassification
54
74
  readonly escalationId?: string | null;
55
75
  readonly signoffLedgerStepIndex?: number | null;
56
76
  }): Promise<ExceptionClassificationRecord>;
57
- /** Verify a record's operator signature. Returns false on a well-formed mismatch. */
58
- export declare function verifyClassificationSignature(record: ExceptionClassificationRecord, operatorPublicKey: Uint8Array): Promise<boolean>;
59
- export interface ExceptionClassificationStore {
60
- append(record: ExceptionClassificationRecord): Promise<void>;
61
- history(): Promise<ReadonlyArray<ExceptionClassificationRecord>>;
62
- latest(): Promise<ExceptionClassificationRecord | null>;
63
- byWorkflow(workflowId: string): Promise<ReadonlyArray<ExceptionClassificationRecord>>;
77
+ export interface DeviationClassificationInput {
78
+ readonly deviationClass: DeviationClass;
79
+ /** Where a model failed — ONLY when a model was involved; requires `model`. */
80
+ readonly failureClass?: FailureClass;
81
+ readonly deviationTag: string;
82
+ readonly workflowId: string;
83
+ /** The rule version the work was judged against (d43: due process in the schema). */
84
+ readonly sopVersion: string;
85
+ readonly inputRef: string;
86
+ readonly contentHash: string;
87
+ /** Omit for human work. Absence means "no model was involved". */
88
+ readonly model?: string;
89
+ /** Requires `model`. */
90
+ readonly modelVersion?: string;
91
+ readonly resolutionSummary: string;
92
+ readonly resolutionActionRefs: ReadonlyArray<string>;
93
+ }
94
+ /** The doer's own account, countersigned with a per-classification key. */
95
+ export interface DoerAccount {
96
+ /** A `did:kash` derived for THIS classification only — never the doer's
97
+ * stable identifier. Self-certifying: the verifier needs no lookup. */
98
+ readonly doerDid: string;
99
+ readonly account: string;
100
+ readonly signedEnvelope: ClassificationSignedEnvelope;
101
+ }
102
+ export interface ExceptionClassificationRecordV2 {
103
+ readonly id: string;
104
+ readonly schemaVersion: typeof EXCEPTION_CLASSIFICATION_SCHEMA_VERSION_V2;
105
+ readonly timestampIso: string;
106
+ readonly workflowId: string;
107
+ readonly sopVersion: string;
108
+ readonly inputRef: string;
109
+ readonly contentHash: string;
110
+ readonly model?: string;
111
+ readonly modelVersion?: string;
112
+ readonly deviationClass: DeviationClass;
113
+ readonly failureClass?: FailureClass;
114
+ readonly deviationTag: string;
115
+ readonly operatorDid: string;
116
+ readonly resolutionSummary: string;
117
+ readonly resolutionActionRefs: ReadonlyArray<string>;
118
+ readonly escalationId: string | null;
119
+ readonly signoffLedgerStepIndex: number | null;
120
+ /** The operator's signature over every field above. */
121
+ readonly signedEnvelope: ClassificationSignedEnvelope;
122
+ /** Present only when the doer signed. Absence is the ONLY representation of
123
+ * declining — see the module header. */
124
+ readonly doerAccount?: DoerAccount;
125
+ }
126
+ export type AnyExceptionClassificationRecord = ExceptionClassificationRecord | ExceptionClassificationRecordV2;
127
+ export declare function isV2Classification(record: AnyExceptionClassificationRecord): record is ExceptionClassificationRecordV2;
128
+ /** Mint + sign a v2 (d43) classification. Gates: `deviationClass` mandatory;
129
+ * `failureClass` only with `model`; `model`/`modelVersion` non-empty when
130
+ * present and OMITTED (never "") when there was no model. */
131
+ export declare function buildSignedDeviationClassification(input: DeviationClassificationInput, operator: {
132
+ readonly did: string;
133
+ readonly privateKey: Uint8Array;
134
+ }, link?: {
135
+ readonly escalationId?: string | null;
136
+ readonly signoffLedgerStepIndex?: number | null;
137
+ }): Promise<ExceptionClassificationRecordV2>;
138
+ /** Verify a record's operator signature — v1 or v2, dispatched on
139
+ * `schemaVersion`. Returns false on a well-formed mismatch. The doer's
140
+ * account, if any, is outside the operator's bytes: check it with
141
+ * `verifyDoerAccount`. */
142
+ export declare function verifyClassificationSignature(record: AnyExceptionClassificationRecord, operatorPublicKey: Uint8Array): Promise<boolean>;
143
+ /** Derive the doer's signing key for exactly ONE classification. Deterministic,
144
+ * so the doer (holding the seed) can re-derive it and prove a record is theirs;
145
+ * unlinkable to every other classification without the seed. */
146
+ export declare function deriveDoerAccountKey(masterSeed: Uint8Array, record: Pick<ExceptionClassificationRecordV2, "id" | "operatorDid">): Promise<RelationshipSigningKey>;
147
+ /** Attach the doer's own account + countersignature over the exact bytes the
148
+ * operator signed. Takes the doer's SEED, never a DID — so no caller can write
149
+ * a stable identifier into the record. Declining = never calling this. */
150
+ export declare function attachDoerAccount(record: ExceptionClassificationRecordV2, doer: {
151
+ readonly masterSeed: Uint8Array;
152
+ }, account: string): Promise<ExceptionClassificationRecordV2>;
153
+ /** Verify the doer's countersignature offline (the key comes from the
154
+ * self-certifying `doerDid`). False when absent, tampered, or re-bound to a
155
+ * different classification. Absence is not a failure of the doer — callers
156
+ * must not treat `false`-because-absent as a mark (check `doerAccount` first). */
157
+ export declare function verifyDoerAccount(record: ExceptionClassificationRecordV2): Promise<boolean>;
158
+ /** Generic over the record version; defaults to v1 so existing implementers
159
+ * compile unchanged. */
160
+ export interface ExceptionClassificationStore<R extends AnyExceptionClassificationRecord = ExceptionClassificationRecord> {
161
+ append(record: R): Promise<void>;
162
+ history(): Promise<ReadonlyArray<R>>;
163
+ latest(): Promise<R | null>;
164
+ byWorkflow(workflowId: string): Promise<ReadonlyArray<R>>;
64
165
  }
65
- export declare class InMemoryExceptionClassificationStore implements ExceptionClassificationStore {
166
+ export declare class InMemoryExceptionClassificationStore<R extends AnyExceptionClassificationRecord = ExceptionClassificationRecord> implements ExceptionClassificationStore<R> {
66
167
  private readonly rows;
67
- append(record: ExceptionClassificationRecord): Promise<void>;
68
- history(): Promise<ReadonlyArray<ExceptionClassificationRecord>>;
69
- latest(): Promise<ExceptionClassificationRecord | null>;
70
- byWorkflow(workflowId: string): Promise<ReadonlyArray<ExceptionClassificationRecord>>;
168
+ append(record: R): Promise<void>;
169
+ history(): Promise<ReadonlyArray<R>>;
170
+ latest(): Promise<R | null>;
171
+ byWorkflow(workflowId: string): Promise<ReadonlyArray<R>>;
71
172
  }
72
173
  export declare const EXCEPTION_DATASET_FORMAT_VERSION: "kash-exception-dataset/1";
73
- export interface ExceptionClassificationDatasetExport {
174
+ export interface ExceptionClassificationDatasetExport<R extends AnyExceptionClassificationRecord = ExceptionClassificationRecord> {
74
175
  readonly formatVersion: string;
75
176
  readonly exportedAtIso: string;
76
177
  readonly count: number;
77
- readonly records: ReadonlyArray<ExceptionClassificationRecord>;
178
+ readonly records: ReadonlyArray<R>;
78
179
  }
79
180
  /** Bundle the dataset for hand-off (records carry their own signatures). */
80
- export declare function exportExceptionClassificationDataset(records: ReadonlyArray<ExceptionClassificationRecord>, exportedAtIso?: string): ExceptionClassificationDatasetExport;
181
+ export declare function exportExceptionClassificationDataset<R extends AnyExceptionClassificationRecord = ExceptionClassificationRecord>(records: ReadonlyArray<R>, exportedAtIso?: string): ExceptionClassificationDatasetExport<R>;
81
182
  export interface WorkflowMonthCount {
82
183
  readonly workflowId: string;
83
184
  readonly month: string;
@@ -92,6 +193,8 @@ export interface ExceptionClassificationStats {
92
193
  }>;
93
194
  readonly perWorkflowOverTime: ReadonlyArray<WorkflowMonthCount>;
94
195
  }
95
- /** Class mix + per-workflow (+ over-time) exception counts (the rate numerator). */
96
- export declare function computeExceptionClassificationStats(records: ReadonlyArray<ExceptionClassificationRecord>): ExceptionClassificationStats;
196
+ /** Model-failure class mix + per-workflow (+ over-time) exception counts. A v2
197
+ * record counts toward `classMix` only when it carries a `failureClass`.
198
+ * Deliberately NO deviation-class mix and nothing per doer (d43 §4.7). */
199
+ export declare function computeExceptionClassificationStats(records: ReadonlyArray<AnyExceptionClassificationRecord>): ExceptionClassificationStats;
97
200
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/exception/index.ts"],"names":[],"mappings":"AAiBA,2EAA2E;AAC3E,eAAO,MAAM,eAAe,mDAAoD,CAAC;AACjF,MAAM,MAAM,YAAY,GAAG,CAAC,OAAO,eAAe,CAAC,CAAC,MAAM,CAAC,CAAC;AAE5D;6EAC6E;AAC7E,eAAO,MAAM,mCAAmC,EAAG,oCAA6C,CAAC;AACjG,eAAO,MAAM,uCAAuC,EAAG,4BAAqC,CAAC;AAc7F;sEACsE;AACtE,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC,KAAK,IAAI,YAAY,CAWhF;AAED,MAAM,WAAW,4BAA4B;IAC3C,QAAQ,CAAC,YAAY,EAAE,YAAY,CAAC;IACpC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,Q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AAC,gCAAgC,CAAC,GACvD,4BAA4B,CAoB9B"}
@@ -10,16 +10,63 @@
10
10
  // bytes (`id` + `timestampIso` minted INTO the signed payload).
11
11
  // Ported from the oreoasis-core-host engine (M5); the DST is neutralized, the
12
12
  // error reuses hudhud's `ExceptionClassificationError`, id generation inlined.
13
+ //
14
+ // ── Schema v2 (2026-09-23, ECOSYSTEM d43 §4.2) ──────────────────────────────
15
+ // v1 classifies WHERE A MODEL FAILED. d43 classifies HOW A DOER DEVIATED —
16
+ // error · at-risk · reckless · improvement — and an improvement is not a
17
+ // failure, so the second taxonomy is not an extension of the first. v2 carries
18
+ // both as ORTHOGONAL fields on one record: a mandatory `deviationClass` and an
19
+ // optional `failureClass`, present only when a model was involved (`model` is
20
+ // optional too; its absence means "no model", never "unknown"). One record, one
21
+ // operator signature, one fact; the model-failure dataset survives intact.
22
+ // v1 is frozen as a wire format: its DST, schema label and header are unchanged
23
+ // and `verifyClassificationSignature` accepts both versions forever.
24
+ //
25
+ // ── The doer's account (d43: no classification of a person is one-sided) ────
26
+ // The doer may attach their own account, countersigned over the exact body the
27
+ // operator signed. Two guards, both structural rather than policy:
28
+ // • UNLINKABLE. `attachDoerAccount` never accepts a DID — only the doer's
29
+ // seed, from which it derives a key for exactly ONE classification
30
+ // (identity-server's relationship derivation, salted by operator + record
31
+ // id). The same doer at two establishments — or twice at one — shows two
32
+ // unrelated DIDs, so the records cannot be joined into a per-person
33
+ // deviation history (§4.7). The doer, holding the seed, can re-derive each
34
+ // key and prove authorship of their own records (§4.8).
35
+ // • DECLINING IS FREE. Not signing is represented by ABSENCE of the
36
+ // `doerAccount` key — no null, no status, no "invited"/"declined" flag. A
37
+ // record without an account names no doer at all, so there is nothing to
38
+ // aggregate against a person; and absence reads identically whether the doer
39
+ // declined, was never asked, or is an AI helper.
40
+ // Limit, stated: an operator can still type a name into `resolutionSummary`.
41
+ // The schema cannot stop free text; it only refuses to make the join easy.
13
42
  // ============================================================================
14
- import { signEvent, verifyEvent } from "@kashscript/identity-core";
43
+ import { parseDid, signEvent, verifyEvent } from "@kashscript/identity-core";
44
+ import { deriveRelationshipSalt, deriveRelationshipSigningKey } from "@kashscript/identity-server";
15
45
  import { ExceptionClassificationError } from "../errors";
16
- /** The failure classes. No "unclassified": classification is mandatory. */
46
+ // Re-export the error this module throws so a consumer can catch it from the
47
+ // same subpath it imports the mandatory gate from.
48
+ export { ExceptionClassificationError } from "../errors";
49
+ /** The model-failure classes — v1's mandatory class, v2's OPTIONAL one
50
+ * (meaningful only when a model was involved). No "unclassified". */
17
51
  export const FAILURE_CLASSES = ["judgment", "gap-filling", "ambiguous"];
18
- /** DST so a classification signature can't replay as a ledger/attestation sig.
19
- * Neutral default; a venture passes its own DST at swap for wire-compat. */
52
+ /** d43 §4.2 — how a doer deviated. Mandatory on v2 records; no default, no
53
+ * "unclassified". error adjust the system, not the person · at-risk → coach
54
+ * · reckless → the only punitive branch · improvement → adopt. */
55
+ export const DEVIATION_CLASSES = ["error", "at-risk", "reckless", "improvement"];
56
+ /** v1 signed label (DST) — v1 records verify under it forever. New records are
57
+ * v2 (`HUDHUD_EXCEPTION_CLASSIFICATION_V2_DST`). */
20
58
  export const HUDHUD_EXCEPTION_CLASSIFICATION_DST = "kash-exception-classification-v1\n";
59
+ /** v1 schema label — frozen; see `EXCEPTION_CLASSIFICATION_SCHEMA_VERSION_V2`. */
21
60
  export const EXCEPTION_CLASSIFICATION_SCHEMA_VERSION = "exception-classification/1";
22
61
  const SIGN_HEADER = { kind: "exception-classification/1" };
62
+ /** v2 labels — registered in `@kashscript/attest/dst` (0.1.7) before first use. */
63
+ export const HUDHUD_EXCEPTION_CLASSIFICATION_V2_DST = "kash-exception-classification-v2\n";
64
+ export const EXCEPTION_CLASSIFICATION_SCHEMA_VERSION_V2 = "exception-classification/2";
65
+ const SIGN_HEADER_V2 = { kind: "exception-classification/2" };
66
+ /** The doer's countersignature DST — so it can never replay as the operator's. */
67
+ export const HUDHUD_EXCEPTION_DOER_ACCOUNT_DST = "kash-exception-doer-account-v1\n";
68
+ const DOER_SIGN_HEADER = { kind: "exception-doer-account/1" };
69
+ const DOER_CONTEXT_PREFIX = "hudhud/exception-doer-account:";
23
70
  let lastIdMicros = 0;
24
71
  function newRecordId() {
25
72
  let micros = Date.now() * 1000;
@@ -32,9 +79,7 @@ function newRecordId() {
32
79
  hex += b.toString(16).padStart(2, "0");
33
80
  return `exc_${micros.toString(36)}_${hex}`;
34
81
  }
35
- /** The mandatory gate — throws `ExceptionClassificationError` if `value` is
36
- * absent/empty or not one of the classes. NOT merely the TS type. */
37
- export function assertFailureClass(value) {
82
+ function gateFailureClass(value) {
38
83
  if (value === undefined || value === null || value === "") {
39
84
  throw new ExceptionClassificationError(`FAILURE_CLASS_REQUIRED — an exception cannot be resolved without a failureClass (one of ${FAILURE_CLASSES.join(" | ")})`);
40
85
  }
@@ -42,14 +87,32 @@ export function assertFailureClass(value) {
42
87
  throw new ExceptionClassificationError(`FAILURE_CLASS_INVALID — failureClass must be one of ${FAILURE_CLASSES.join(" | ")} (got ${String(value)})`);
43
88
  }
44
89
  }
90
+ /** The v1 mandatory gate — throws `ExceptionClassificationError` if `value` is
91
+ * absent/empty or not one of the classes. NOT merely the TS type.
92
+ * @deprecated New records are v2: gate with `assertDeviationClass`; the model
93
+ * class is optional there. Kept so existing callers compile unchanged. */
94
+ export function assertFailureClass(value) {
95
+ gateFailureClass(value);
96
+ }
97
+ /** The v2 mandatory gate — throws `ExceptionClassificationError` if `value` is
98
+ * absent/empty or not one of the four deviation classes. */
99
+ export function assertDeviationClass(value) {
100
+ if (value === undefined || value === null || value === "") {
101
+ throw new ExceptionClassificationError(`DEVIATION_CLASS_REQUIRED — a deviation cannot be resolved without a deviationClass (one of ${DEVIATION_CLASSES.join(" | ")})`);
102
+ }
103
+ if (!DEVIATION_CLASSES.includes(value)) {
104
+ throw new ExceptionClassificationError(`DEVIATION_CLASS_INVALID — deviationClass must be one of ${DEVIATION_CLASSES.join(" | ")} (got ${String(value)})`);
105
+ }
106
+ }
45
107
  function unsignedOf(record) {
46
108
  const { signedEnvelope: _drop, ...rest } = record;
47
109
  return rest;
48
110
  }
49
- /** Mint + sign a classification record (id/timestamp minted into the signed
50
- * payload). Throws the mandatory gate if `failureClass` is missing/invalid. */
111
+ /** Mint + sign a v1 classification record (id/timestamp minted into the signed
112
+ * payload). Throws the mandatory gate if `failureClass` is missing/invalid.
113
+ * @deprecated Mint v2 with `buildSignedDeviationClassification` (d43). */
51
114
  export async function buildSignedClassification(input, operator, link = {}) {
52
- assertFailureClass(input.failureClass);
115
+ gateFailureClass(input.failureClass);
53
116
  const unsigned = {
54
117
  id: newRecordId(),
55
118
  schemaVersion: EXCEPTION_CLASSIFICATION_SCHEMA_VERSION,
@@ -78,11 +141,71 @@ export async function buildSignedClassification(input, operator, link = {}) {
78
141
  signedEnvelope: { alg: "ed25519", sig: signed.sig, dst: HUDHUD_EXCEPTION_CLASSIFICATION_DST, kid: operator.did },
79
142
  };
80
143
  }
81
- /** Verify a record's operator signature. Returns false on a well-formed mismatch. */
144
+ export function isV2Classification(record) {
145
+ return record.schemaVersion === EXCEPTION_CLASSIFICATION_SCHEMA_VERSION_V2;
146
+ }
147
+ function unsignedOfV2(record) {
148
+ const { signedEnvelope: _sig, doerAccount: _doer, ...rest } = record;
149
+ return rest;
150
+ }
151
+ /** Mint + sign a v2 (d43) classification. Gates: `deviationClass` mandatory;
152
+ * `failureClass` only with `model`; `model`/`modelVersion` non-empty when
153
+ * present and OMITTED (never "") when there was no model. */
154
+ export async function buildSignedDeviationClassification(input, operator, link = {}) {
155
+ assertDeviationClass(input.deviationClass);
156
+ if (input.model !== undefined && (typeof input.model !== "string" || input.model === "")) {
157
+ throw new ExceptionClassificationError("MODEL_INVALID — `model`, when present, must be non-empty; omit it for work no model touched");
158
+ }
159
+ if (input.modelVersion !== undefined && (input.model === undefined || typeof input.modelVersion !== "string" || input.modelVersion === "")) {
160
+ throw new ExceptionClassificationError("MODEL_VERSION_INVALID — `modelVersion` must be non-empty and requires `model`");
161
+ }
162
+ if (input.failureClass !== undefined) {
163
+ gateFailureClass(input.failureClass);
164
+ if (input.model === undefined) {
165
+ throw new ExceptionClassificationError("FAILURE_CLASS_WITHOUT_MODEL — failureClass classifies where a model failed; it requires `model`");
166
+ }
167
+ }
168
+ const unsigned = {
169
+ id: newRecordId(),
170
+ schemaVersion: EXCEPTION_CLASSIFICATION_SCHEMA_VERSION_V2,
171
+ timestampIso: new Date().toISOString(),
172
+ workflowId: input.workflowId,
173
+ sopVersion: input.sopVersion,
174
+ inputRef: input.inputRef,
175
+ contentHash: input.contentHash,
176
+ ...(input.model !== undefined ? { model: input.model } : {}),
177
+ ...(input.modelVersion !== undefined ? { modelVersion: input.modelVersion } : {}),
178
+ deviationClass: input.deviationClass,
179
+ ...(input.failureClass !== undefined ? { failureClass: input.failureClass } : {}),
180
+ deviationTag: input.deviationTag,
181
+ operatorDid: operator.did,
182
+ resolutionSummary: input.resolutionSummary,
183
+ resolutionActionRefs: [...input.resolutionActionRefs],
184
+ escalationId: link.escalationId ?? null,
185
+ signoffLedgerStepIndex: link.signoffLedgerStepIndex ?? null,
186
+ };
187
+ const signed = await signEvent(SIGN_HEADER_V2, unsigned, operator.privateKey, {
188
+ dst: HUDHUD_EXCEPTION_CLASSIFICATION_V2_DST,
189
+ encoding: "hex",
190
+ kid: operator.did,
191
+ });
192
+ return {
193
+ ...unsigned,
194
+ signedEnvelope: { alg: "ed25519", sig: signed.sig, dst: HUDHUD_EXCEPTION_CLASSIFICATION_V2_DST, kid: operator.did },
195
+ };
196
+ }
197
+ /** Verify a record's operator signature — v1 or v2, dispatched on
198
+ * `schemaVersion`. Returns false on a well-formed mismatch. The doer's
199
+ * account, if any, is outside the operator's bytes: check it with
200
+ * `verifyDoerAccount`. */
82
201
  export async function verifyClassificationSignature(record, operatorPublicKey) {
202
+ const v2 = isV2Classification(record);
203
+ // v2 pins its DST: a v2 body is never accepted under any other tag.
204
+ if (v2 && record.signedEnvelope.dst !== HUDHUD_EXCEPTION_CLASSIFICATION_V2_DST)
205
+ return false;
83
206
  return verifyEvent({
84
- header: SIGN_HEADER,
85
- body: unsignedOf(record),
207
+ header: v2 ? SIGN_HEADER_V2 : SIGN_HEADER,
208
+ body: v2 ? unsignedOfV2(record) : unsignedOf(record),
86
209
  signature: {
87
210
  alg: "ed25519",
88
211
  sig: record.signedEnvelope.sig,
@@ -92,6 +215,74 @@ export async function verifyClassificationSignature(record, operatorPublicKey) {
92
215
  },
93
216
  }, operatorPublicKey);
94
217
  }
218
+ // ── The doer's account ─────────────────────────────────────────────────────
219
+ function doerSignedBody(record, doerDid, account) {
220
+ return { subject: unsignedOfV2(record), doerDid, account };
221
+ }
222
+ /** Derive the doer's signing key for exactly ONE classification. Deterministic,
223
+ * so the doer (holding the seed) can re-derive it and prove a record is theirs;
224
+ * unlinkable to every other classification without the seed. */
225
+ export async function deriveDoerAccountKey(masterSeed, record) {
226
+ if (!(masterSeed instanceof Uint8Array) || masterSeed.length < 32) {
227
+ throw new ExceptionClassificationError("DOER_SEED_INVALID — the doer's master seed must be at least 32 bytes");
228
+ }
229
+ const relationshipSalt = await deriveRelationshipSalt({
230
+ requesterDid: record.operatorDid,
231
+ contextLabel: DOER_CONTEXT_PREFIX + record.id,
232
+ });
233
+ return deriveRelationshipSigningKey({ masterSeed, relationshipSalt });
234
+ }
235
+ /** Attach the doer's own account + countersignature over the exact bytes the
236
+ * operator signed. Takes the doer's SEED, never a DID — so no caller can write
237
+ * a stable identifier into the record. Declining = never calling this. */
238
+ export async function attachDoerAccount(record, doer, account) {
239
+ if (!isV2Classification(record)) {
240
+ throw new ExceptionClassificationError("DOER_ACCOUNT_REQUIRES_V2 — a doer account attaches to an exception-classification/2 record");
241
+ }
242
+ if (record.doerAccount !== undefined) {
243
+ throw new ExceptionClassificationError("DOER_ACCOUNT_ALREADY_ATTACHED — a record carries at most one doer account");
244
+ }
245
+ if (typeof account !== "string" || account.trim() === "") {
246
+ throw new ExceptionClassificationError("DOER_ACCOUNT_EMPTY — an attached account must say something; to decline, attach nothing");
247
+ }
248
+ const key = await deriveDoerAccountKey(doer.masterSeed, record);
249
+ const signed = await signEvent(DOER_SIGN_HEADER, doerSignedBody(record, key.did, account), key.privateKey, {
250
+ dst: HUDHUD_EXCEPTION_DOER_ACCOUNT_DST,
251
+ encoding: "hex",
252
+ kid: key.did,
253
+ });
254
+ return {
255
+ ...record,
256
+ doerAccount: {
257
+ doerDid: key.did,
258
+ account,
259
+ signedEnvelope: { alg: "ed25519", sig: signed.sig, dst: HUDHUD_EXCEPTION_DOER_ACCOUNT_DST, kid: key.did },
260
+ },
261
+ };
262
+ }
263
+ /** Verify the doer's countersignature offline (the key comes from the
264
+ * self-certifying `doerDid`). False when absent, tampered, or re-bound to a
265
+ * different classification. Absence is not a failure of the doer — callers
266
+ * must not treat `false`-because-absent as a mark (check `doerAccount` first). */
267
+ export async function verifyDoerAccount(record) {
268
+ const d = record.doerAccount;
269
+ if (d === undefined)
270
+ return false;
271
+ if (d.signedEnvelope.dst !== HUDHUD_EXCEPTION_DOER_ACCOUNT_DST || d.signedEnvelope.kid !== d.doerDid)
272
+ return false;
273
+ let publicKey;
274
+ try {
275
+ publicKey = parseDid(d.doerDid);
276
+ }
277
+ catch {
278
+ return false;
279
+ }
280
+ return verifyEvent({
281
+ header: DOER_SIGN_HEADER,
282
+ body: doerSignedBody(record, d.doerDid, d.account),
283
+ signature: { alg: "ed25519", sig: d.signedEnvelope.sig, dst: d.signedEnvelope.dst, encoding: "hex", kid: d.signedEnvelope.kid },
284
+ }, publicKey);
285
+ }
95
286
  export class InMemoryExceptionClassificationStore {
96
287
  rows = [];
97
288
  async append(record) {
@@ -119,13 +310,16 @@ function emptyClassMix() {
119
310
  mix[c] = 0;
120
311
  return mix;
121
312
  }
122
- /** Class mix + per-workflow (+ over-time) exception counts (the rate numerator). */
313
+ /** Model-failure class mix + per-workflow (+ over-time) exception counts. A v2
314
+ * record counts toward `classMix` only when it carries a `failureClass`.
315
+ * Deliberately NO deviation-class mix and nothing per doer (d43 §4.7). */
123
316
  export function computeExceptionClassificationStats(records) {
124
317
  const classMix = emptyClassMix();
125
318
  const perWorkflow = new Map();
126
319
  const perWfMonth = new Map();
127
320
  for (const r of records) {
128
- classMix[r.failureClass] += 1;
321
+ if (r.failureClass !== undefined)
322
+ classMix[r.failureClass] += 1;
129
323
  perWorkflow.set(r.workflowId, (perWorkflow.get(r.workflowId) ?? 0) + 1);
130
324
  const key = `${r.workflowId} ${r.timestampIso.slice(0, 7)}`;
131
325
  perWfMonth.set(key, (perWfMonth.get(key) ?? 0) + 1);
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/exception/index.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,yEAAyE;AACzE,+EAA+E;AAC/E,+EAA+E;AAC/E,wEAAwE;AACxE,gFAAgF;AAChF,+EAA+E;AAC/E,kDAAkD;AAClD,2EAA2E;AAC3E,qEAAqE;AACrE,8EAA8E;AAC9E,+EAA+E;AAC/E,+EAA+E;AAE/E,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACnE,OAAO,EAAE,4BAA4B,EAAE,MAAM,WAAW,CAAC;AAEzD,2EAA2E;AAC3E,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,UAAU,EAAE,aAAa,EAAE,WAAW,CAAU,CAAC;AAGjF;6EAC6E;AAC7E,MAAM,CAAC,MAAM,mCAAmC,GAAG,oCAA6C,CAAC;AACjG,MAAM,CAAC,MAAM,uCAAuC,GAAG,4BAAqC,CAAC;AAC7F,MAAM,WAAW,GAAG,EAAE,IAAI,EAAE,4BAA4B,EAAW,CAAC;AAEpE,IAAI,YAAY,GAAG,CAAC,CAAC;AACrB,SAAS,WAAW;IAClB,IAAI,MAAM,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC;IAC/B,IAAI,MAAM,IAAI,YAAY;QAAE,MAAM,GAAG,YAAY,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CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,UAAU,GAAG,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAC1D,MAAM,mBAAmB,GAAG,CAAC,GAAG,UAAU,CAAC,OAAO,EAAE,CAAC;SAClD,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE;QACpB,MAAM,CAAC,UAAU,EAAE,KAAK,CAAC,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAC3C,OAAO,EAAE,UAAU,EAAE,UAAW,EAAE,KAAK,EAAE,KAAM,EAAE,KAAK,EAAE,CAAC;IAC3D,CAAC,CAAC;SACD,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,UAAU,KAAK,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,UAAU,GAAG,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACzH,OAAO,EAAE,KAAK,EAAE,OAAO,CAAC,MAAM,EAAE,QAAQ,EAAE,WAAW,EAAE,cAAc,EAAE,mBAAmB,EAAE,CAAC;AAC/F,CAAC"}
package/dist/index.d.ts CHANGED
@@ -11,5 +11,5 @@ export * from "./did-registry";
11
11
  export * from "./identity";
12
12
  export * from "./runtime";
13
13
  /** The hudhud protocol/package version (M5 initial cut). */
14
- export declare const HUDHUD_VERSION: "0.1.0";
14
+ export declare const HUDHUD_VERSION: "0.1.1";
15
15
  //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -28,5 +28,5 @@ export * from "./did-registry";
28
28
  export * from "./identity";
29
29
  export * from "./runtime";
30
30
  /** The hudhud protocol/package version (M5 initial cut). */
31
- export const HUDHUD_VERSION = "0.1.0";
31
+ export const HUDHUD_VERSION = "0.1.1";
32
32
  //# sourceMappingURL=index.js.map
@@ -10,12 +10,15 @@ export interface HostActorSigner {
10
10
  readonly actorClass: ActorClass;
11
11
  sign(payload: LedgerSignaturePayload): Promise<string>;
12
12
  }
13
- /** Build a HostActorSigner from a raw Ed25519 private key. `actorDid` must be a
14
- * did:kash and be registered in the DidRegistry the service verifies against. */
13
+ /** Build a HostActorSigner from a raw Ed25519 private key. `actorDid` must be
14
+ * accepted by `isValidActorDid` (default: canonical did:kash) and be registered
15
+ * in the DidRegistry the service verifies against. */
15
16
  export declare function createEd25519HostSigner(opts: {
16
17
  readonly actorDid: string;
17
18
  readonly actorClass: ActorClass;
18
19
  readonly privateKey: Uint8Array;
20
+ /** Override the DID acceptance policy (default: canonical `did:kash`). */
21
+ readonly isValidActorDid?: (did: string) => boolean;
19
22
  }): HostActorSigner;
20
23
  export interface AppendTransitionLogInput {
21
24
  readonly sessionId: string;
@@ -43,10 +46,15 @@ export interface ForensicLedgerServiceDeps {
43
46
  readonly didRegistry: DidRegistry;
44
47
  /** Required only for `appendActorTransition` (the self-signing path). */
45
48
  readonly hostSigner?: HostActorSigner;
49
+ /** DID acceptance policy for `actorDid` (default: canonical `did:kash`).
50
+ * DID-format is an identity-method policy the CONSUMER owns; the ledger's
51
+ * hard gates remain registry-resolution + signature-verification. */
52
+ readonly isValidActorDid?: (did: string) => boolean;
46
53
  }
47
54
  export declare class ForensicLedgerService {
48
55
  private readonly deps;
49
56
  constructor(deps: ForensicLedgerServiceDeps);
57
+ private isValidActorDid;
50
58
  /** Append a caller-pre-signed transition. @throws LedgerAppendError on any
51
59
  * validation / signature / store failure. */
52
60
  appendTransitionLog(input: AppendTransitionLogInput): Promise<AppendedLedgerBlock>;
@@ -1 +1 @@
1
- {"version":3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