@kindgi/compliance 0.0.0-stage → 0.1.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.
@@ -0,0 +1,75 @@
1
+ import type { AuditEventBinding } from '@kindgi/audit-events';
2
+ import type { Scope } from '@kindgi/platform';
3
+ import type { EnvName, ProjectId, TenantId } from '@kindgi/types';
4
+ /**
5
+ * Uniform caller-of-resolution shape. Structurally identical to
6
+ * `@kindgi/api.ResolveContext` (kept as a duplicate declaration here
7
+ * to avoid a compliance → api dep cycle — TS structural typing
8
+ * makes them assignable across the boundary).
9
+ */
10
+ export interface ResolveContext {
11
+ readonly runId?: string;
12
+ readonly deploymentId?: string;
13
+ readonly nodeId?: string;
14
+ readonly caller: 'dispatch' | 'deploy-sync' | 'admin-cli' | 'boot-bridge';
15
+ }
16
+ /** Input to `emitResolveEvent`. */
17
+ export interface EmitResolveEventInput {
18
+ readonly kind: 'env' | 'secret';
19
+ readonly scope: Scope;
20
+ readonly envName: EnvName;
21
+ readonly name: string;
22
+ readonly outcome: 'succeeded' | 'failed';
23
+ readonly resolveContext: ResolveContext;
24
+ readonly version?: number;
25
+ readonly errorCode?: string;
26
+ readonly auditEvents: AuditEventBinding;
27
+ readonly tenantId: TenantId;
28
+ readonly projectId: ProjectId;
29
+ }
30
+ /**
31
+ * Emit an `env-resolved` or `secret-resolved` audit event.
32
+ *
33
+ * The helper NEVER accepts nor emits the resolved value — the resolve
34
+ * outcome carries the plaintext to the caller; the audit event carries
35
+ * only the fact-of-resolution + version + scope + caller attribution.
36
+ *
37
+ * Fire-and-forget: any error is logged but swallowed. The resolve path
38
+ * must not fail because the audit sink is unreachable.
39
+ */
40
+ export declare function emitResolveEvent(input: EmitResolveEventInput): Promise<void>;
41
+ /**
42
+ * Input to `emitLifecycleEvent`. Used for env `set` / `delete` and
43
+ * secret `set` / `rotate` / `revoke` — the non-resolve write ops that
44
+ * still need audit-trail attribution.
45
+ */
46
+ export interface EmitLifecycleEventInput {
47
+ readonly evidenceKind: string;
48
+ readonly bindingKind: 'env' | 'secret';
49
+ readonly scope: Scope;
50
+ readonly envName: EnvName;
51
+ readonly name: string;
52
+ readonly outcome: 'succeeded' | 'failed';
53
+ /**
54
+ * Caller-of-op attribution. Same shape as the resolve path — env
55
+ * `set` from an admin CLI produces `actor = 'admin'`; a
56
+ * deployment-sync `set` produces `actor = 'system:<deploymentId>'`.
57
+ */
58
+ readonly resolveContext?: ResolveContext;
59
+ readonly version?: number;
60
+ readonly previousVersion?: number;
61
+ readonly errorCode?: string;
62
+ readonly hard?: boolean;
63
+ readonly reason?: string;
64
+ readonly auditEvents: AuditEventBinding;
65
+ readonly tenantId: TenantId;
66
+ readonly projectId: ProjectId;
67
+ }
68
+ /**
69
+ * Emit a non-resolve lifecycle event (`env-set` / `env-deleted` /
70
+ * `secret-set` / `secret-rotated` / `secret-rotation-started` /
71
+ * `secret-rotation-failed` / `secret-revoked` / `secret-hard-revoked`).
72
+ * Same fire-and-forget contract as `emitResolveEvent`.
73
+ */
74
+ export declare function emitLifecycleEvent(input: EmitLifecycleEventInput): Promise<void>;
75
+ //# sourceMappingURL=resolve-emit.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolve-emit.d.ts","sourceRoot":"","sources":["../src/resolve-emit.ts"],"names":[],"mappings":"AAyBA,OAAO,KAAK,EAAc,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAC1E,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAa,MAAM,eAAe,CAAC;AAE7E;;;;;GAKG;AACH,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC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AC;IAClC,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,IAAI,CAAC,EAAE,OAAO,CAAC;IACxB,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,WAAW,EAAE,iBAAiB,CAAC;IACxC,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;IAC5B,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC;CAC/B;AAED;;;;;GAKG;AACH,wBAAsB,kBAAkB,CAAC,KAAK,EAAE,uBAAuB,GAAG,OAAO,CAAC,IAAI,CAAC,CActF"}
@@ -0,0 +1,181 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ // Copyright (C) 2026 Kindgi Inc.
3
+ /**
4
+ * Shared helpers for emitting `env-*` and `secret-*` audit events.
5
+ * `EnvBinding` and `SecretBinding` implementations call
6
+ * `emitResolveEvent` from their `resolve` paths and `emitLifecycleEvent`
7
+ * for `set` / `delete` / `rotate` / `revoke`.
8
+ *
9
+ * Writes land on the single `AuditEventBinding`. Classification
10
+ * (retention / signing / export) is a lens on top, not baked into the
11
+ * write path.
12
+ *
13
+ * Design guardrails:
14
+ * - Framework NEVER copies a secret plaintext `value` into a payload.
15
+ * Payloads carry only metadata (name, version, scope,
16
+ * caller, errorCode).
17
+ * - Emission is fire-and-forget: failures inside the binding are
18
+ * logged (via `console.warn`) but never poison the caller's op.
19
+ * - The `resolveContext.caller` discriminant maps to a distinct
20
+ * `actor` string.
21
+ */
22
+ import { randomUUID } from 'node:crypto';
23
+ /**
24
+ * Emit an `env-resolved` or `secret-resolved` audit event.
25
+ *
26
+ * The helper NEVER accepts nor emits the resolved value — the resolve
27
+ * outcome carries the plaintext to the caller; the audit event carries
28
+ * only the fact-of-resolution + version + scope + caller attribution.
29
+ *
30
+ * Fire-and-forget: any error is logged but swallowed. The resolve path
31
+ * must not fail because the audit sink is unreachable.
32
+ */
33
+ export async function emitResolveEvent(input) {
34
+ const kind = input.kind === 'env' ? 'env-resolved' : 'secret-resolved';
35
+ const payload = buildResolvePayload(input);
36
+ const actor = actorFromResolveContext(input.resolveContext);
37
+ const event = buildEvent({
38
+ tenantId: input.tenantId,
39
+ projectId: input.projectId,
40
+ kind,
41
+ outcome: input.outcome,
42
+ actor,
43
+ runId: input.resolveContext.runId,
44
+ payload,
45
+ });
46
+ await safeEmit(input.auditEvents, event);
47
+ }
48
+ /**
49
+ * Emit a non-resolve lifecycle event (`env-set` / `env-deleted` /
50
+ * `secret-set` / `secret-rotated` / `secret-rotation-started` /
51
+ * `secret-rotation-failed` / `secret-revoked` / `secret-hard-revoked`).
52
+ * Same fire-and-forget contract as `emitResolveEvent`.
53
+ */
54
+ export async function emitLifecycleEvent(input) {
55
+ const payload = buildLifecyclePayload(input);
56
+ const actor = input.resolveContext !== undefined ? actorFromResolveContext(input.resolveContext) : undefined;
57
+ const event = buildEvent({
58
+ tenantId: input.tenantId,
59
+ projectId: input.projectId,
60
+ kind: input.evidenceKind,
61
+ outcome: input.outcome,
62
+ actor,
63
+ runId: input.resolveContext?.runId,
64
+ payload,
65
+ });
66
+ await safeEmit(input.auditEvents, event);
67
+ }
68
+ function buildEvent(input) {
69
+ return {
70
+ id: randomUUID(),
71
+ tenantId: input.tenantId,
72
+ projectId: input.projectId,
73
+ kind: input.kind,
74
+ timestamp: new Date().toISOString(),
75
+ actor: input.actor ?? 'user:system',
76
+ outcome: input.outcome,
77
+ ...(input.runId !== undefined && { runId: input.runId }),
78
+ payload: { v: 1, doc: input.payload },
79
+ };
80
+ }
81
+ async function safeEmit(binding, event) {
82
+ try {
83
+ const result = await binding.append([event]);
84
+ if (result.kind === 'err') {
85
+ // eslint-disable-next-line no-console -- no injected logger here
86
+ console.warn(`[compliance] emit ${event.kind} audit event failed: ${result.error.message}`);
87
+ }
88
+ }
89
+ catch (cause) {
90
+ // eslint-disable-next-line no-console -- no injected logger here
91
+ console.warn(`[compliance] emit ${event.kind} audit event threw: ${cause instanceof Error ? cause.message : String(cause)}`);
92
+ }
93
+ }
94
+ /**
95
+ * Map the `resolveContext.caller` discriminant to a subject string.
96
+ * Format matches the audit-events `actor` convention
97
+ * (`<type>:<id>` — `agent:<runId>`, `system:<deploymentId>`, `user:admin`,
98
+ * `user:system`).
99
+ */
100
+ function actorFromResolveContext(ctx) {
101
+ switch (ctx.caller) {
102
+ case 'dispatch':
103
+ return ctx.runId !== undefined ? `agent:${ctx.runId}` : 'agent:unknown';
104
+ case 'deploy-sync':
105
+ return ctx.deploymentId !== undefined ? `system:${ctx.deploymentId}` : 'system:deploy';
106
+ case 'admin-cli':
107
+ return 'user:admin';
108
+ case 'boot-bridge':
109
+ return 'user:system';
110
+ default:
111
+ return undefined;
112
+ }
113
+ }
114
+ function scopeToPayloadShape(scope) {
115
+ if (scope.kind === 'tenant') {
116
+ return { kind: 'tenant', tenantId: scope.tenantId };
117
+ }
118
+ if (scope.kind === 'org') {
119
+ return {
120
+ kind: 'org',
121
+ tenantId: scope.tenantId,
122
+ orgId: scope.orgId,
123
+ };
124
+ }
125
+ return {
126
+ kind: 'project',
127
+ tenantId: scope.tenantId,
128
+ projectId: scope.projectId,
129
+ };
130
+ }
131
+ /**
132
+ * Build the resolve-event payload. Structural guarantee: NO `value`
133
+ * key ever appears. Every field is either metadata (name,
134
+ * version, scope) or attribution (caller, errorCode).
135
+ */
136
+ function buildResolvePayload(input) {
137
+ const payload = {
138
+ scope: scopeToPayloadShape(input.scope),
139
+ envName: input.envName,
140
+ name: input.name,
141
+ caller: input.resolveContext.caller,
142
+ };
143
+ if (input.version !== undefined)
144
+ payload.recordVersion = input.version;
145
+ if (input.errorCode !== undefined)
146
+ payload.errorCode = input.errorCode;
147
+ if (input.resolveContext.nodeId !== undefined)
148
+ payload.nodeId = input.resolveContext.nodeId;
149
+ if (input.resolveContext.runId !== undefined)
150
+ payload.runId = input.resolveContext.runId;
151
+ return payload;
152
+ }
153
+ /**
154
+ * Build the lifecycle-event payload. Same structural rule as
155
+ * `buildResolvePayload` — never carries the value.
156
+ */
157
+ function buildLifecyclePayload(input) {
158
+ const payload = {
159
+ scope: scopeToPayloadShape(input.scope),
160
+ envName: input.envName,
161
+ name: input.name,
162
+ };
163
+ if (input.resolveContext !== undefined)
164
+ payload.caller = input.resolveContext.caller;
165
+ if (input.version !== undefined)
166
+ payload.recordVersion = input.version;
167
+ if (input.previousVersion !== undefined)
168
+ payload.previousVersion = input.previousVersion;
169
+ if (input.errorCode !== undefined)
170
+ payload.errorCode = input.errorCode;
171
+ if (input.hard !== undefined)
172
+ payload.hard = input.hard;
173
+ if (input.reason !== undefined)
174
+ payload.reason = input.reason;
175
+ if (input.resolveContext?.nodeId !== undefined)
176
+ payload.nodeId = input.resolveContext.nodeId;
177
+ if (input.resolveContext?.runId !== undefined)
178
+ payload.runId = input.resolveContext.runId;
179
+ return payload;
180
+ }
181
+ //# sourceMappingURL=resolve-emit.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolve-emit.js","sourceRoot":"","sources":["../src/resolve-emit.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,iCAAiC;AAEjC;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAkCzC;;;;;;;;;GASG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAAC,KAA4B;IACjE,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,KAAK,KAAK,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,iBAAiB,CAAC;IACvE,MAAM,OAAO,GAAG,mBAAmB,CAAC,KAAK,CAAC,CAAC;IAC3C,MAAM,KAAK,GAAG,uBAAuB,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC;IAC5D,MAAM,KAAK,GAAG,UAAU,CAAC;QACvB,QAAQ,EAAE,KAAK,CAAC,QAAQ;QACxB,SAAS,EAAE,KAAK,CAAC,SAAS;QAC1B,IAAI;QACJ,OAAO,EAAE,KAAK,CAA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SAAS,qBAAqB,CAAC,KAA8B;IAC3D,MAAM,OAAO,GAA4B;QACvC,KAAK,EAAE,mBAAmB,CAAC,KAAK,CAAC,KAAK,CAAC;QACvC,OAAO,EAAE,KAAK,CAAC,OAA4B;QAC3C,IAAI,EAAE,KAAK,CAAC,IAAI;KACjB,CAAC;IACF,IAAI,KAAK,CAAC,cAAc,KAAK,SAAS;QAAE,OAAO,CAAC,MAAM,GAAG,KAAK,CAAC,cAAc,CAAC,MAAM,CAAC;IACrF,IAAI,KAAK,CAAC,OAAO,KAAK,SAAS;QAAE,OAAO,CAAC,aAAa,GAAG,KAAK,CAAC,OAAO,CAAC;IACvE,IAAI,KAAK,CAAC,eAAe,KAAK,SAAS;QAAE,OAAO,CAAC,eAAe,GAAG,KAAK,CAAC,eAAe,CAAC;IACzF,IAAI,KAAK,CAAC,SAAS,KAAK,SAAS;QAAE,OAAO,CAAC,SAAS,GAAG,KAAK,CAAC,SAAS,CAAC;IACvE,IAAI,KAAK,CAAC,IAAI,KAAK,SAAS;QAAE,OAAO,CAAC,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC;IACxD,IAAI,KAAK,CAAC,MAAM,KAAK,SAAS;QAAE,OAAO,CAAC,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC;IAC9D,IAAI,KAAK,CAAC,cAAc,EAAE,MAAM,KAAK,SAAS;QAAE,OAAO,CAAC,MAAM,GAAG,KAAK,CAAC,cAAc,CAAC,MAAM,CAAC;IAC7F,IAAI,KAAK,CAAC,cAAc,EAAE,KAAK,KAAK,SAAS;QAAE,OAAO,CAAC,KAAK,GAAG,KAAK,CAAC,cAAc,CAAC,KAAK,CAAC;IAC1F,OAAO,OAAO,CAAC;AACjB,CAAC"}
@@ -0,0 +1,307 @@
1
+ import type { AgentId, ComplianceEvidenceId, FlowId, ProjectId, ProvenanceId, RunId, SigningKeyId, TenantId, Timestamp } from '@kindgi/types';
2
+ /**
3
+ * The built-in (known) compliance-relevant event classes. Listed as
4
+ * `examples` in `@kindgi/specs/compliance-evidence.schema.json`.
5
+ *
6
+ * Not exhaustive: evidence is a classifier lens over the audit stream,
7
+ * whose kinds are open (pack authors add their own), and a deployment's
8
+ * compliance classifier can mark any kind exportable. See `EvidenceKind`.
9
+ */
10
+ export declare const EVIDENCE_KINDS: readonly ["access-event", "policy-decision", "config-change", "secret-rotation", "incident-event", "guardrail-violation", "eval-run", "approval-completed", "data-retention-action", "authn-event", "authz-decision", "model-invocation", "pack-install", "pack-upgrade", "pack-uninstall", "run-outcome", "env-resolved", "env-set", "env-deleted", "secret-resolved", "secret-set", "secret-rotated", "secret-rotation-started", "secret-rotation-failed", "secret-revoked", "secret-hard-revoked", "hitl-decision"];
11
+ /**
12
+ * An evidence kind: one of the built-in `EVIDENCE_KINDS`, or any other
13
+ * audit-event kind a deployment's classifier marks exportable. Consumers
14
+ * must tolerate kinds they don't know.
15
+ */
16
+ export type EvidenceKind = (typeof EVIDENCE_KINDS)[number] | (string & {});
17
+ export type ActorKind = 'user' | 'agent' | 'system' | 'admin' | 'external';
18
+ export interface EvidenceActor {
19
+ readonly kind: ActorKind;
20
+ readonly id?: string;
21
+ readonly ipAddress?: string;
22
+ readonly userAgent?: string;
23
+ }
24
+ export interface EvidenceSubject {
25
+ readonly kind: string;
26
+ readonly id?: string;
27
+ }
28
+ export type EvidenceOutcome = 'allowed' | 'denied' | 'succeeded' | 'failed' | 'escalated';
29
+ /**
30
+ * Reference back to the provenance DAG that produced this evidence.
31
+ * Same shape as `provenance.schema.json`'s runId + nodeId pair.
32
+ */
33
+ export interface ProvenanceRef {
34
+ readonly runId?: RunId;
35
+ readonly nodeId?: string;
36
+ /** For records linked to a persisted provenance record by id. */
37
+ readonly recordId?: ProvenanceId;
38
+ }
39
+ /** Ed25519 signature over the canonical serialisation of the evidence. */
40
+ export interface EvidenceSignature {
41
+ readonly algorithm: 'ed25519';
42
+ readonly keyId: string;
43
+ readonly value: string;
44
+ readonly signedAt: Timestamp;
45
+ }
46
+ /**
47
+ * The kind-specific payload lives here. `payload` always includes a
48
+ * `version` field, so consumers migrate older shapes to the current one
49
+ * on read instead of rewriting stored records.
50
+ */
51
+ export interface EvidencePayload {
52
+ readonly version: number;
53
+ readonly [key: string]: unknown;
54
+ }
55
+ /**
56
+ * One evidence record. Matches `@kindgi/specs/compliance-evidence.schema.json`
57
+ * modulo `payload` being an in-package-typed versioned document.
58
+ */
59
+ export interface Evidence {
60
+ readonly id: ComplianceEvidenceId;
61
+ readonly tenantId: TenantId;
62
+ /**
63
+ * Content-scope anchor — the project the underlying audit event
64
+ * belongs to. Absent for tenant-level events (e.g. authz decisions,
65
+ * admin actions before any project exists), mirroring the optional
66
+ * `AuditEvent.projectId`.
67
+ */
68
+ readonly projectId?: ProjectId;
69
+ readonly kind: EvidenceKind;
70
+ readonly timestamp: Timestamp;
71
+ readonly actor?: EvidenceActor;
72
+ readonly subject?: EvidenceSubject;
73
+ readonly outcome?: EvidenceOutcome;
74
+ readonly payload: EvidencePayload;
75
+ readonly provenanceRef?: ProvenanceRef;
76
+ readonly signature?: EvidenceSignature;
77
+ }
78
+ /**
79
+ * Alias exposing the public wire type under the framework-standard name.
80
+ * `ComplianceEvidence` and `Evidence` are the same type.
81
+ */
82
+ export type ComplianceEvidence = Evidence;
83
+ /**
84
+ * Optional signer. If a caller wires one up (typically backed by a
85
+ * signing key), every emitted record is signed for tamper detection.
86
+ * Absent signer = unsigned records, still valid but weaker audit story.
87
+ */
88
+ export type EvidenceSigner = (bytes: Uint8Array, tenantId: TenantId) => Promise<EvidenceSignature>;
89
+ /**
90
+ * Filter for `ComplianceProvider.list`. `tenantId` is required; the other
91
+ * fields are optional and compose as AND — with only `tenantId` set, it
92
+ * matches all evidence for the tenant.
93
+ */
94
+ export interface ListEvidenceFilter {
95
+ readonly tenantId: TenantId;
96
+ readonly kind?: EvidenceKind;
97
+ readonly runId?: RunId;
98
+ readonly since?: Date;
99
+ readonly until?: Date;
100
+ readonly limit?: number;
101
+ }
102
+ /**
103
+ * Pluggable provider — adapters forward evidence to an external
104
+ * compliance platform or SIEM. The core `emit` API stays constant;
105
+ * adapters translate the wire format.
106
+ */
107
+ export interface ComplianceProvider {
108
+ emit(evidence: EmitEvidenceInput): Promise<import('./errors.js').EmitResult>;
109
+ list(filter: ListEvidenceFilter): Promise<import('./errors.js').ListResult>;
110
+ describe(): {
111
+ readonly name: string;
112
+ readonly version: string;
113
+ };
114
+ }
115
+ /**
116
+ * Caller-supplied input to `emit`. The provider fills in `id` +
117
+ * `timestamp` + optional `signature`; everything else comes from the
118
+ * caller.
119
+ */
120
+ export interface EmitEvidenceInput {
121
+ readonly tenantId: TenantId;
122
+ readonly projectId: ProjectId;
123
+ readonly kind: EvidenceKind;
124
+ readonly payload: EvidencePayload;
125
+ readonly actor?: EvidenceActor;
126
+ readonly subject?: EvidenceSubject;
127
+ readonly outcome?: EvidenceOutcome;
128
+ readonly provenanceRef?: ProvenanceRef;
129
+ /** Override the record id (defaults to `randomUUID()`). */
130
+ readonly id?: ComplianceEvidenceId;
131
+ /** Override the timestamp (defaults to `now()`). Useful for backfills. */
132
+ readonly timestamp?: Timestamp;
133
+ }
134
+ /**
135
+ * One model call summary attached to a run's evidence record. Redaction-
136
+ * safe by construction: no raw prompt text, no raw completion — only
137
+ * hashes + counts + timing + outcome. Callers that need raw content pass
138
+ * it via `RecordFromRunOptions.rawMessages` under the explicit opt-in
139
+ * (`RecordFromRunOptions.allowRawMessages: true`).
140
+ */
141
+ export interface ModelCallSummary {
142
+ readonly provider: string;
143
+ readonly model: string;
144
+ /** `<provider>/<model>@<date-or-version>` — matches provenance node convention. */
145
+ readonly modelVersion?: string;
146
+ /** SHA-256 (or similar) of the canonical prompt; caller-supplied. */
147
+ readonly promptHash?: string;
148
+ readonly inputTokens?: number;
149
+ readonly outputTokens?: number;
150
+ readonly durationMs?: number;
151
+ readonly outcome?: 'succeeded' | 'failed';
152
+ }
153
+ /**
154
+ * One tool invocation summary. Same redaction discipline as
155
+ * `ModelCallSummary` — args are hashed, not embedded.
156
+ */
157
+ export interface ToolInvocationSummary {
158
+ readonly toolId: string;
159
+ /** SHA-256 (or similar) of the canonical args; caller-supplied. */
160
+ readonly argsHash?: string;
161
+ readonly outcome?: 'succeeded' | 'failed';
162
+ readonly durationMs?: number;
163
+ }
164
+ /** One guardrail check outcome captured on the run. */
165
+ export interface GuardrailResultSummary {
166
+ readonly guardrailId: string;
167
+ readonly verdict: 'pass' | 'fail' | 'warn';
168
+ readonly severity?: 'low' | 'medium' | 'high' | 'critical';
169
+ /** Short human message; caller ensures no sensitive content. */
170
+ readonly message?: string;
171
+ }
172
+ /**
173
+ * Structured input to `generator.recordFromRun`. Represents the state of
174
+ * a terminated run that the pipeline turns into one evidence record.
175
+ *
176
+ * By construction this shape is redaction-safe: model prompts and tool
177
+ * args are hashes, guardrail messages are short strings without payload
178
+ * content.
179
+ */
180
+ export interface RunEvidenceContext {
181
+ readonly status: 'completed' | 'failed' | 'cancelled';
182
+ readonly startedAt?: Timestamp;
183
+ readonly endedAt?: Timestamp;
184
+ readonly agentId?: AgentId;
185
+ readonly flowId?: FlowId;
186
+ readonly flowVersion?: string;
187
+ readonly modelCalls?: readonly ModelCallSummary[];
188
+ readonly toolInvocations?: readonly ToolInvocationSummary[];
189
+ readonly guardrailResults?: readonly GuardrailResultSummary[];
190
+ /**
191
+ * Failure message from the terminal run. Callers redact this before
192
+ * passing — the generator does not scan it for secrets.
193
+ */
194
+ readonly failureMessage?: string;
195
+ /**
196
+ * Free-form extra fields the caller wants on the evidence payload.
197
+ * Additive; caller is responsible for redaction. NEVER put secrets or
198
+ * raw user-message content here — use `RecordFromRunOptions.rawMessages`
199
+ * for the latter (with the opt-in flag) so the redaction seam stays
200
+ * explicit.
201
+ */
202
+ readonly extra?: Readonly<Record<string, unknown>>;
203
+ }
204
+ /**
205
+ * Options for `generator.recordFromRun`. `tenantId`, `projectId`, `runId`,
206
+ * `kind` and `runContext` are required; everything else is optional, and
207
+ * the generator fills in `id` + `timestamp` when absent.
208
+ */
209
+ export interface RecordFromRunOptions {
210
+ readonly tenantId: TenantId;
211
+ /**
212
+ * Content-scope anchor. The generator
213
+ * threads this into `Evidence.projectId` on the emitted record.
214
+ */
215
+ readonly projectId: ProjectId;
216
+ readonly runId: RunId;
217
+ /**
218
+ * Compliance-relevant event class the caller wants this record filed
219
+ * under. The pipeline does NOT infer kind from the run outcome — the
220
+ * caller knows why the record is being emitted.
221
+ */
222
+ readonly kind: EvidenceKind;
223
+ readonly runContext: RunEvidenceContext;
224
+ readonly actor?: EvidenceActor;
225
+ readonly subject?: EvidenceSubject;
226
+ readonly outcome?: EvidenceOutcome;
227
+ /** Override the record id (defaults to `randomUUID()`). */
228
+ readonly id?: ComplianceEvidenceId;
229
+ /** Override the timestamp (defaults to `now()`). */
230
+ readonly timestamp?: Timestamp;
231
+ /** Optional provenance DAG back-reference. */
232
+ readonly provenanceRef?: ProvenanceRef;
233
+ /**
234
+ * When the tenant has explicitly opted in to raw-message retention,
235
+ * caller passes the raw messages here. They land verbatim under
236
+ * `payload.rawMessages`. Without this opt-in, raw content stays out
237
+ * of the record entirely.
238
+ */
239
+ readonly rawMessages?: readonly Readonly<Record<string, unknown>>[];
240
+ /**
241
+ * Must be `true` for `rawMessages` to be embedded — a belt-and-braces
242
+ * guard so a caller can't accidentally pass raw messages without an
243
+ * explicit opt-in acknowledgement.
244
+ */
245
+ readonly allowRawMessages?: boolean;
246
+ }
247
+ /**
248
+ * Filter shape shared by evidence listing and signed export
249
+ * (`ComplianceEvidenceGenerator.exportSigned`). `ComplianceProvider.list`
250
+ * takes `ListEvidenceFilter` instead. Every field is optional; an empty
251
+ * filter is "everything in the tenant". Composition is AND — all
252
+ * populated fields must match.
253
+ */
254
+ export interface EvidenceFilter {
255
+ readonly runId?: RunId;
256
+ readonly agentId?: AgentId;
257
+ readonly flowId?: FlowId;
258
+ readonly evidenceKind?: EvidenceKind;
259
+ /**
260
+ * Restrict to these kinds. An empty array matches nothing. Callers
261
+ * applying a classifier pass its exportable kinds here, so a signed
262
+ * bundle records exactly which kinds it covers.
263
+ */
264
+ readonly evidenceKinds?: readonly EvidenceKind[];
265
+ readonly from?: Timestamp;
266
+ readonly to?: Timestamp;
267
+ }
268
+ /** One page of evidence records from a cursor-paginated listing. */
269
+ export interface EvidencePage {
270
+ readonly data: readonly ComplianceEvidence[];
271
+ /** Absent when there are no more results after this page. */
272
+ readonly nextCursor?: string;
273
+ }
274
+ /**
275
+ * The signed export bundle envelope. Same shape family as the provenance
276
+ * signed export + audit-bundle envelope, so verifiers can reuse the exact
277
+ * same Ed25519 verification wrapper across all three surfaces.
278
+ */
279
+ export interface SignedEvidenceBundle {
280
+ readonly bundleSchemaVersion: '1.0.0';
281
+ readonly tenantId: TenantId;
282
+ /** Base64 of canonical JSON bytes — exactly what was signed. */
283
+ readonly bundle: string;
284
+ readonly algorithm: 'ed25519';
285
+ readonly signingKeyId: SigningKeyId;
286
+ /** Base64 of the Ed25519 signature bytes (64 bytes decoded). */
287
+ readonly signature: string;
288
+ /** PEM-encoded Ed25519 public key. */
289
+ readonly publicKey: string;
290
+ readonly canonicalization: 'sorted-key-json';
291
+ readonly exportedAt: Timestamp;
292
+ }
293
+ /**
294
+ * The body inside the signed bundle. Kept as a distinct exported type so
295
+ * downstream verifiers can type the decoded bytes without duplicating the
296
+ * shape.
297
+ */
298
+ export interface EvidenceBundleBody {
299
+ readonly bundleSchemaVersion: '1.0.0';
300
+ readonly tenantId: TenantId;
301
+ readonly filter: EvidenceFilter;
302
+ readonly records: readonly ComplianceEvidence[];
303
+ readonly exportedAt: Timestamp;
304
+ /** Count of records in the bundle. */
305
+ readonly recordCount: number;
306
+ }
307
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,OAAO,EACP,oBAAoB,EACpB,MAAM,EACN,SAAS,EACT,YAAY,EACZ,KAAK,EACL,YAAY,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sC;IACtC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;CAC9B"}
package/dist/types.js ADDED
@@ -0,0 +1,51 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ // Copyright (C) 2026 Kindgi Inc.
3
+ // ============ Wire types (schema-derived) ============
4
+ /**
5
+ * The built-in (known) compliance-relevant event classes. Listed as
6
+ * `examples` in `@kindgi/specs/compliance-evidence.schema.json`.
7
+ *
8
+ * Not exhaustive: evidence is a classifier lens over the audit stream,
9
+ * whose kinds are open (pack authors add their own), and a deployment's
10
+ * compliance classifier can mark any kind exportable. See `EvidenceKind`.
11
+ */
12
+ export const EVIDENCE_KINDS = [
13
+ 'access-event',
14
+ 'policy-decision',
15
+ 'config-change',
16
+ // `secret-rotation` is the coarse kind; emitters use the granular
17
+ // `secret-rotated` / `secret-rotation-started` / `secret-rotation-failed`
18
+ // kinds.
19
+ 'secret-rotation',
20
+ 'incident-event',
21
+ 'guardrail-violation',
22
+ 'eval-run',
23
+ 'approval-completed',
24
+ 'data-retention-action',
25
+ 'authn-event',
26
+ 'authz-decision',
27
+ 'model-invocation',
28
+ 'pack-install',
29
+ 'pack-upgrade',
30
+ 'pack-uninstall',
31
+ 'run-outcome',
32
+ // Env-binding lifecycle events. Symmetric with the secret-* kinds
33
+ // below; `env-*` events never carry the value in their payload.
34
+ 'env-resolved',
35
+ 'env-set',
36
+ 'env-deleted',
37
+ // Secret-binding lifecycle events. The framework NEVER copies the
38
+ // plaintext value into an evidence payload;
39
+ // payloads carry only metadata (name, version, scope, caller, errorCode).
40
+ 'secret-resolved',
41
+ 'secret-set',
42
+ 'secret-rotated',
43
+ 'secret-rotation-started',
44
+ 'secret-rotation-failed',
45
+ 'secret-revoked',
46
+ 'secret-hard-revoked',
47
+ // Human-in-the-loop approval decisions (exportable in the shipped
48
+ // compliance classifier).
49
+ 'hitl-decision',
50
+ ];
51
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,iCAAiC;AAcjC,wDAAwD;AAExD;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,cAAc;IACd,iBAAiB;IACjB,eAAe;IACf,kEAAkE;IAClE,0EAA0E;IAC1E,SAAS;IACT,iBAAiB;IACjB,gBAAgB;IAChB,qBAAqB;IACrB,UAAU;IACV,oBAAoB;IACpB,uBAAuB;IACvB,aAAa;IACb,gBAAgB;IAChB,kBAAkB;IAClB,cAAc;IACd,cAAc;IACd,gBAAgB;IAChB,aAAa;IACb,kEAAkE;IAClE,gEAAgE;IAChE,cAAc;IACd,SAAS;IACT,aAAa;IACb,kEAAkE;IAClE,4CAA4C;IAC5C,0EAA0E;IAC1E,iBAAiB;IACjB,YAAY;IACZ,gBAAgB;IAChB,yBAAyB;IACzB,wBAAwB;IACxB,gBAAgB;IAChB,qBAAqB;IACrB,kEAAkE;IAClE,0BAA0B;IAC1B,eAAe;CACP,CAAC"}