@kashscript/hudhud 0.1.1 → 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.
- package/LICENSE +135 -133
- package/README.md +11 -0
- package/dist/certificate/certificate.d.ts +11 -4
- package/dist/certificate/certificate.d.ts.map +1 -1
- package/dist/certificate/certificate.js +21 -18
- package/dist/certificate/certificate.js.map +1 -1
- package/dist/certificate/html.d.ts.map +1 -1
- package/dist/certificate/html.js +1 -2
- package/dist/certificate/html.js.map +1 -1
- package/dist/exception/index.d.ts +126 -24
- package/dist/exception/index.d.ts.map +1 -1
- package/dist/exception/index.js +206 -15
- package/dist/exception/index.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/package.json +3 -3
- package/src/certificate/certificate.ts +25 -17
- package/src/certificate/html.ts +1 -2
- package/src/exception/index.ts +312 -33
- package/src/index.ts +1 -1
|
@@ -1,14 +1,32 @@
|
|
|
1
|
+
import type { RelationshipSigningKey } from "@kashscript/identity-server";
|
|
1
2
|
export { ExceptionClassificationError } from "../errors";
|
|
2
|
-
/** The failure classes
|
|
3
|
+
/** The model-failure classes — v1's mandatory class, v2's OPTIONAL one
|
|
4
|
+
* (meaningful only when a model was involved). No "unclassified". */
|
|
3
5
|
export declare const FAILURE_CLASSES: readonly ["judgment", "gap-filling", "ambiguous"];
|
|
4
6
|
export type FailureClass = (typeof FAILURE_CLASSES)[number];
|
|
5
|
-
/**
|
|
6
|
-
*
|
|
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`). */
|
|
7
14
|
export declare const HUDHUD_EXCEPTION_CLASSIFICATION_DST: "kash-exception-classification-v1\n";
|
|
15
|
+
/** v1 schema label — frozen; see `EXCEPTION_CLASSIFICATION_SCHEMA_VERSION_V2`. */
|
|
8
16
|
export declare const EXCEPTION_CLASSIFICATION_SCHEMA_VERSION: "exception-classification/1";
|
|
9
|
-
/**
|
|
10
|
-
|
|
17
|
+
/** v2 labels — registered 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. */
|
|
11
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;
|
|
12
30
|
export interface ExceptionClassificationInput {
|
|
13
31
|
readonly failureClass: FailureClass;
|
|
14
32
|
readonly failureTag: string;
|
|
@@ -46,8 +64,9 @@ export interface ExceptionClassificationRecord {
|
|
|
46
64
|
readonly signoffLedgerStepIndex: number | null;
|
|
47
65
|
readonly signedEnvelope: ClassificationSignedEnvelope;
|
|
48
66
|
}
|
|
49
|
-
/** Mint + sign a classification record (id/timestamp minted into the signed
|
|
50
|
-
* 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). */
|
|
51
70
|
export declare function buildSignedClassification(input: ExceptionClassificationInput, operator: {
|
|
52
71
|
readonly did: string;
|
|
53
72
|
readonly privateKey: Uint8Array;
|
|
@@ -55,30 +74,111 @@ export declare function buildSignedClassification(input: ExceptionClassification
|
|
|
55
74
|
readonly escalationId?: string | null;
|
|
56
75
|
readonly signoffLedgerStepIndex?: number | null;
|
|
57
76
|
}): Promise<ExceptionClassificationRecord>;
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
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>>;
|
|
65
165
|
}
|
|
66
|
-
export declare class InMemoryExceptionClassificationStore implements ExceptionClassificationStore {
|
|
166
|
+
export declare class InMemoryExceptionClassificationStore<R extends AnyExceptionClassificationRecord = ExceptionClassificationRecord> implements ExceptionClassificationStore<R> {
|
|
67
167
|
private readonly rows;
|
|
68
|
-
append(record:
|
|
69
|
-
history(): Promise<ReadonlyArray<
|
|
70
|
-
latest(): Promise<
|
|
71
|
-
byWorkflow(workflowId: string): Promise<ReadonlyArray<
|
|
168
|
+
append(record: R): Promise<void>;
|
|
169
|
+
history(): Promise<ReadonlyArray<R>>;
|
|
170
|
+
latest(): Promise<R | null>;
|
|
171
|
+
byWorkflow(workflowId: string): Promise<ReadonlyArray<R>>;
|
|
72
172
|
}
|
|
73
173
|
export declare const EXCEPTION_DATASET_FORMAT_VERSION: "kash-exception-dataset/1";
|
|
74
|
-
export interface ExceptionClassificationDatasetExport {
|
|
174
|
+
export interface ExceptionClassificationDatasetExport<R extends AnyExceptionClassificationRecord = ExceptionClassificationRecord> {
|
|
75
175
|
readonly formatVersion: string;
|
|
76
176
|
readonly exportedAtIso: string;
|
|
77
177
|
readonly count: number;
|
|
78
|
-
readonly records: ReadonlyArray<
|
|
178
|
+
readonly records: ReadonlyArray<R>;
|
|
79
179
|
}
|
|
80
180
|
/** Bundle the dataset for hand-off (records carry their own signatures). */
|
|
81
|
-
export declare function exportExceptionClassificationDataset(records: ReadonlyArray<
|
|
181
|
+
export declare function exportExceptionClassificationDataset<R extends AnyExceptionClassificationRecord = ExceptionClassificationRecord>(records: ReadonlyArray<R>, exportedAtIso?: string): ExceptionClassificationDatasetExport<R>;
|
|
82
182
|
export interface WorkflowMonthCount {
|
|
83
183
|
readonly workflowId: string;
|
|
84
184
|
readonly month: string;
|
|
@@ -93,6 +193,8 @@ export interface ExceptionClassificationStats {
|
|
|
93
193
|
}>;
|
|
94
194
|
readonly perWorkflowOverTime: ReadonlyArray<WorkflowMonthCount>;
|
|
95
195
|
}
|
|
96
|
-
/**
|
|
97
|
-
|
|
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;
|
|
98
200
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/exception/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/exception/index.ts"],"names":[],"mappings":"AA6CA,OAAO,KAAK,EAAO,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AAI/E,OAAO,EAAE,4BAA4B,EAAE,MAAM,WAAW,CAAC;AAEzD;sEACsE;AACtE,eAAO,MAAM,eAAe,mDAAoD,CAAC;AACjF,MAAM,MAAM,YAAY,GAAG,CAAC,OAAO,eAAe,CAAC,CAAC,MAAM,CAAC,CAAC;AAE5D;;mEAEmE;AACnE,eAAO,MAAM,iBAAiB,0DAA2D,CAAC;AAC1F,MAAM,MAAM,cAAc,GAAG,CAAC,OAAO,iBAAiB,CAAC,CAAC,MAAM,CAAC,CAAC;AAEhE;qDACqD;AACrD,eAAO,MAAM,mCAAmC,EAAG,oCAA6C,CAAC;AACjG,kFAAkF;AAClF,eAAO,MAAM,uCAAuC,EAAG,4BAAqC,CAAC;AAG7F,mFAAmF;AACnF,eAAO,MAAM,sCAAsC,EAAG,oCAA6C,CAAC;AACpG,eAAO,MAAM,0CAA0C,EAAG,4BAAqC,CAAC;AAEhG,kFAAkF;AAClF,eAAO,M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CAAC;CACpC;AAED,4EAA4E;AAC5E,wBAAgB,oCAAoC,CAAC,CAAC,SAAS,gCAAgC,GAAG,6BAA6B,EAC7H,OAAO,EAAE,aAAa,CAAC,CAAC,CAAC,EACzB,aAAa,GAAE,MAAiC,GAC/C,oCAAoC,CAAC,CAAC,CAAC,CAEzC;AAED,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,4BAA4B;IAC3C,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC;IAChD,QAAQ,CAAC,WAAW,EAAE,aAAa,CAAC;QAAE,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC7F,QAAQ,CAAC,mBAAmB,EAAE,aAAa,CAAC,kBAAkB,CAAC,CAAC;CACjE;AAQD;;2EAE2E;AAC3E,wBAAgB,mCAAmC,CACjD,OAAO,EAAE,aAAa,CAAC,gCAAgC,CAAC,GACvD,4BAA4B,CAoB9B"}
|
package/dist/exception/index.js
CHANGED
|
@@ -10,19 +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
46
|
// Re-export the error this module throws so a consumer can catch it from the
|
|
17
47
|
// same subpath it imports the mandatory gate from.
|
|
18
48
|
export { ExceptionClassificationError } from "../errors";
|
|
19
|
-
/** The failure classes
|
|
49
|
+
/** The model-failure classes — v1's mandatory class, v2's OPTIONAL one
|
|
50
|
+
* (meaningful only when a model was involved). No "unclassified". */
|
|
20
51
|
export const FAILURE_CLASSES = ["judgment", "gap-filling", "ambiguous"];
|
|
21
|
-
/**
|
|
22
|
-
*
|
|
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`). */
|
|
23
58
|
export const HUDHUD_EXCEPTION_CLASSIFICATION_DST = "kash-exception-classification-v1\n";
|
|
59
|
+
/** v1 schema label — frozen; see `EXCEPTION_CLASSIFICATION_SCHEMA_VERSION_V2`. */
|
|
24
60
|
export const EXCEPTION_CLASSIFICATION_SCHEMA_VERSION = "exception-classification/1";
|
|
25
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:";
|
|
26
70
|
let lastIdMicros = 0;
|
|
27
71
|
function newRecordId() {
|
|
28
72
|
let micros = Date.now() * 1000;
|
|
@@ -35,9 +79,7 @@ function newRecordId() {
|
|
|
35
79
|
hex += b.toString(16).padStart(2, "0");
|
|
36
80
|
return `exc_${micros.toString(36)}_${hex}`;
|
|
37
81
|
}
|
|
38
|
-
|
|
39
|
-
* absent/empty or not one of the classes. NOT merely the TS type. */
|
|
40
|
-
export function assertFailureClass(value) {
|
|
82
|
+
function gateFailureClass(value) {
|
|
41
83
|
if (value === undefined || value === null || value === "") {
|
|
42
84
|
throw new ExceptionClassificationError(`FAILURE_CLASS_REQUIRED — an exception cannot be resolved without a failureClass (one of ${FAILURE_CLASSES.join(" | ")})`);
|
|
43
85
|
}
|
|
@@ -45,14 +87,32 @@ export function assertFailureClass(value) {
|
|
|
45
87
|
throw new ExceptionClassificationError(`FAILURE_CLASS_INVALID — failureClass must be one of ${FAILURE_CLASSES.join(" | ")} (got ${String(value)})`);
|
|
46
88
|
}
|
|
47
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
|
+
}
|
|
48
107
|
function unsignedOf(record) {
|
|
49
108
|
const { signedEnvelope: _drop, ...rest } = record;
|
|
50
109
|
return rest;
|
|
51
110
|
}
|
|
52
|
-
/** Mint + sign a classification record (id/timestamp minted into the signed
|
|
53
|
-
* 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). */
|
|
54
114
|
export async function buildSignedClassification(input, operator, link = {}) {
|
|
55
|
-
|
|
115
|
+
gateFailureClass(input.failureClass);
|
|
56
116
|
const unsigned = {
|
|
57
117
|
id: newRecordId(),
|
|
58
118
|
schemaVersion: EXCEPTION_CLASSIFICATION_SCHEMA_VERSION,
|
|
@@ -81,11 +141,71 @@ export async function buildSignedClassification(input, operator, link = {}) {
|
|
|
81
141
|
signedEnvelope: { alg: "ed25519", sig: signed.sig, dst: HUDHUD_EXCEPTION_CLASSIFICATION_DST, kid: operator.did },
|
|
82
142
|
};
|
|
83
143
|
}
|
|
84
|
-
|
|
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`. */
|
|
85
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;
|
|
86
206
|
return verifyEvent({
|
|
87
|
-
header: SIGN_HEADER,
|
|
88
|
-
body: unsignedOf(record),
|
|
207
|
+
header: v2 ? SIGN_HEADER_V2 : SIGN_HEADER,
|
|
208
|
+
body: v2 ? unsignedOfV2(record) : unsignedOf(record),
|
|
89
209
|
signature: {
|
|
90
210
|
alg: "ed25519",
|
|
91
211
|
sig: record.signedEnvelope.sig,
|
|
@@ -95,6 +215,74 @@ export async function verifyClassificationSignature(record, operatorPublicKey) {
|
|
|
95
215
|
},
|
|
96
216
|
}, operatorPublicKey);
|
|
97
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
|
+
}
|
|
98
286
|
export class InMemoryExceptionClassificationStore {
|
|
99
287
|
rows = [];
|
|
100
288
|
async append(record) {
|
|
@@ -122,13 +310,16 @@ function emptyClassMix() {
|
|
|
122
310
|
mix[c] = 0;
|
|
123
311
|
return mix;
|
|
124
312
|
}
|
|
125
|
-
/**
|
|
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). */
|
|
126
316
|
export function computeExceptionClassificationStats(records) {
|
|
127
317
|
const classMix = emptyClassMix();
|
|
128
318
|
const perWorkflow = new Map();
|
|
129
319
|
const perWfMonth = new Map();
|
|
130
320
|
for (const r of records) {
|
|
131
|
-
|
|
321
|
+
if (r.failureClass !== undefined)
|
|
322
|
+
classMix[r.failureClass] += 1;
|
|
132
323
|
perWorkflow.set(r.workflowId, (perWorkflow.get(r.workflowId) ?? 0) + 1);
|
|
133
324
|
const key = `${r.workflowId} ${r.timestampIso.slice(0, 7)}`;
|
|
134
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;AACzD,6EAA6E;AAC7E,mDAAmD;AACnD,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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ED
|
@@ -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.
|
|
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.
|
|
31
|
+
export const HUDHUD_VERSION = "0.1.1";
|
|
32
32
|
//# sourceMappingURL=index.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kashscript/hudhud",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "The Agent Protocol — the accountable agent runtime. SOP compiler, MCP allowlist + circuit breaker, PII-redaction interceptor, a signed action ledger + forensic scan (on @kashscript/attest), exception classification, AIUC-1 work certificates, DID registry, and a neuron-kernel work runtime. Agent auth via @kashscript/identity-server MCP OAuth 2.1 tokens. Ventures import hudhud, never raw neuron. Commercial (SSLA Schedule B).",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -79,8 +79,8 @@
|
|
|
79
79
|
},
|
|
80
80
|
"dependencies": {
|
|
81
81
|
"@kashscript/identity-core": "0.3.1",
|
|
82
|
-
"@kashscript/attest": "0.1.
|
|
83
|
-
"@kashscript/identity-server": "0.
|
|
82
|
+
"@kashscript/attest": "0.1.7",
|
|
83
|
+
"@kashscript/identity-server": "0.2.0",
|
|
84
84
|
"@kashscript/neuron": "0.1.1"
|
|
85
85
|
},
|
|
86
86
|
"peerDependencies": {
|