@attestplane/attestplane 0.0.1-alpha.1 → 0.0.3-alpha
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/README.md +17 -10
- package/dist/adapter_conformance.d.ts +46 -0
- package/dist/adapter_conformance.d.ts.map +1 -0
- package/dist/adapter_conformance.js +160 -0
- package/dist/adapter_conformance.js.map +1 -0
- package/dist/adapters/langfuse.d.ts +51 -0
- package/dist/adapters/langfuse.d.ts.map +1 -0
- package/dist/adapters/langfuse.js +157 -0
- package/dist/adapters/langfuse.js.map +1 -0
- package/dist/adapters/langsmith.d.ts +53 -0
- package/dist/adapters/langsmith.d.ts.map +1 -0
- package/dist/adapters/langsmith.js +173 -0
- package/dist/adapters/langsmith.js.map +1 -0
- package/dist/adapters.d.ts +88 -0
- package/dist/adapters.d.ts.map +1 -0
- package/dist/adapters.js +109 -0
- package/dist/adapters.js.map +1 -0
- package/dist/anchoring.d.ts +119 -0
- package/dist/anchoring.d.ts.map +1 -0
- package/dist/anchoring.js +340 -0
- package/dist/anchoring.js.map +1 -0
- package/dist/canonical.d.ts +11 -2
- package/dist/canonical.d.ts.map +1 -1
- package/dist/canonical.js +44 -31
- package/dist/canonical.js.map +1 -1
- package/dist/canonical_text.d.ts +30 -0
- package/dist/canonical_text.d.ts.map +1 -0
- package/dist/canonical_text.js +100 -0
- package/dist/canonical_text.js.map +1 -0
- package/dist/der.d.ts +55 -0
- package/dist/der.d.ts.map +1 -0
- package/dist/der.js +200 -0
- package/dist/der.js.map +1 -0
- package/dist/event_payloads.d.ts +118 -0
- package/dist/event_payloads.d.ts.map +1 -0
- package/dist/event_payloads.js +348 -0
- package/dist/event_payloads.js.map +1 -0
- package/dist/event_types.d.ts +47 -0
- package/dist/event_types.d.ts.map +1 -0
- package/dist/event_types.js +63 -0
- package/dist/event_types.js.map +1 -0
- package/dist/hashchain.d.ts +1 -0
- package/dist/hashchain.d.ts.map +1 -1
- package/dist/hashchain.js +25 -1
- package/dist/hashchain.js.map +1 -1
- package/dist/index.d.ts +22 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +23 -1
- package/dist/index.js.map +1 -1
- package/dist/index_version.d.ts +9 -0
- package/dist/index_version.d.ts.map +1 -0
- package/dist/index_version.js +11 -0
- package/dist/index_version.js.map +1 -0
- package/dist/intoto.d.ts +48 -0
- package/dist/intoto.d.ts.map +1 -0
- package/dist/intoto.js +106 -0
- package/dist/intoto.js.map +1 -0
- package/dist/obligations.d.ts +41 -0
- package/dist/obligations.d.ts.map +1 -0
- package/dist/obligations.js +312 -0
- package/dist/obligations.js.map +1 -0
- package/dist/proof_bundle.d.ts +186 -0
- package/dist/proof_bundle.d.ts.map +1 -0
- package/dist/proof_bundle.js +299 -0
- package/dist/proof_bundle.js.map +1 -0
- package/dist/reason_codes.d.ts +38 -0
- package/dist/reason_codes.d.ts.map +1 -0
- package/dist/reason_codes.js +97 -0
- package/dist/reason_codes.js.map +1 -0
- package/dist/replay_verifier.d.ts +43 -0
- package/dist/replay_verifier.d.ts.map +1 -0
- package/dist/replay_verifier.js +98 -0
- package/dist/replay_verifier.js.map +1 -0
- package/dist/rfc3161.d.ts +52 -0
- package/dist/rfc3161.d.ts.map +1 -0
- package/dist/rfc3161.js +480 -0
- package/dist/rfc3161.js.map +1 -0
- package/dist/settlement_verifier.d.ts +34 -0
- package/dist/settlement_verifier.d.ts.map +1 -0
- package/dist/settlement_verifier.js +139 -0
- package/dist/settlement_verifier.js.map +1 -0
- package/dist/signing/base.d.ts +101 -0
- package/dist/signing/base.d.ts.map +1 -0
- package/dist/signing/base.js +144 -0
- package/dist/signing/base.js.map +1 -0
- package/dist/signing/providers.d.ts +113 -0
- package/dist/signing/providers.d.ts.map +1 -0
- package/dist/signing/providers.js +230 -0
- package/dist/signing/providers.js.map +1 -0
- package/dist/signing/signer.d.ts +66 -0
- package/dist/signing/signer.d.ts.map +1 -0
- package/dist/signing/signer.js +146 -0
- package/dist/signing/signer.js.map +1 -0
- package/dist/signing/trust_roots.d.ts +71 -0
- package/dist/signing/trust_roots.d.ts.map +1 -0
- package/dist/signing/trust_roots.js +267 -0
- package/dist/signing/trust_roots.js.map +1 -0
- package/dist/signing/verifier_ext.d.ts +77 -0
- package/dist/signing/verifier_ext.d.ts.map +1 -0
- package/dist/signing/verifier_ext.js +340 -0
- package/dist/signing/verifier_ext.js.map +1 -0
- package/dist/verifier.d.ts +39 -0
- package/dist/verifier.d.ts.map +1 -0
- package/dist/verifier.js +374 -0
- package/dist/verifier.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: 2026 The Attestplane Authors
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
/**
|
|
4
|
+
* LangSmith → Attestplane evidence-event adapter (TypeScript port of
|
|
5
|
+
* `sdk/python/src/attestplane/adapters/langsmith.py`).
|
|
6
|
+
*
|
|
7
|
+
* Byte-identical translation semantics with the Python adapter:
|
|
8
|
+
* given the same LangSmith Run, both adapters produce the same
|
|
9
|
+
* EventDraft fields (event_type, actor, payload, subject_ref,
|
|
10
|
+
* session_id, reference_db_ref).
|
|
11
|
+
*
|
|
12
|
+
* Pure function per GenericRuntimeAdapter contract: no I/O, no
|
|
13
|
+
* LangSmith API calls.
|
|
14
|
+
*
|
|
15
|
+
* Trust boundary (ADR-0004 § 4): adapter consumes the public
|
|
16
|
+
* LangSmith Run shape, not LangChain proprietary code. LangChain
|
|
17
|
+
* does not endorse this adapter; see docs/policy/forbidden_claims.md
|
|
18
|
+
* § G.
|
|
19
|
+
*
|
|
20
|
+
* Redaction (ADR-0008 § Boundary anti-requirements):
|
|
21
|
+
* - Raw inputs / outputs are NEVER copied to payload — only SHA-256
|
|
22
|
+
* hashes go in `arguments_hash` / `result_hash`.
|
|
23
|
+
* - Error strings are truncated to 200 chars to limit PII leakage.
|
|
24
|
+
* - end_user_id (from LangSmith metadata.user_id) is wrapped in
|
|
25
|
+
* SubjectRef(scheme="opaque").
|
|
26
|
+
*
|
|
27
|
+
* Run type → event_type mapping is identical to the Python adapter:
|
|
28
|
+
* all run_types map to `tool_call_event` in v1; payload.kind carries
|
|
29
|
+
* the LangSmith run_type for downstream filtering.
|
|
30
|
+
*/
|
|
31
|
+
import { createHash } from 'node:crypto';
|
|
32
|
+
import { AdapterTranslationError, GenericRuntimeAdapter } from '../adapters.js';
|
|
33
|
+
import { TOOL_CALL_EVENT } from '../event_types.js';
|
|
34
|
+
import { makeEventDraft, makeSubjectRef } from '../types.js';
|
|
35
|
+
const KNOWN_RUN_TYPES = new Set([
|
|
36
|
+
'tool',
|
|
37
|
+
'llm',
|
|
38
|
+
'chain',
|
|
39
|
+
'retriever',
|
|
40
|
+
'prompt',
|
|
41
|
+
'parser',
|
|
42
|
+
'embedding',
|
|
43
|
+
]);
|
|
44
|
+
function _canonicalReplacer() {
|
|
45
|
+
// sort_keys + default=str equivalent (matches Python's json.dumps
|
|
46
|
+
// with sort_keys=True, separators=(",",":"), default=str).
|
|
47
|
+
return function (_key, value) {
|
|
48
|
+
if (value === undefined)
|
|
49
|
+
return undefined;
|
|
50
|
+
if (value instanceof Date)
|
|
51
|
+
return value.toISOString();
|
|
52
|
+
if (value !== null && typeof value === 'object' && !Array.isArray(value)) {
|
|
53
|
+
const sorted = {};
|
|
54
|
+
const obj = value;
|
|
55
|
+
for (const k of Object.keys(obj).sort()) {
|
|
56
|
+
sorted[k] = obj[k];
|
|
57
|
+
}
|
|
58
|
+
return sorted;
|
|
59
|
+
}
|
|
60
|
+
return value;
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
function _hashJson(value) {
|
|
64
|
+
// Match Python: json.dumps(value, sort_keys=True, separators=(",",":"), default=str)
|
|
65
|
+
// JS JSON.stringify by default uses no separators; we need to mimic compact form.
|
|
66
|
+
// The canonical_replacer above sorts keys; we then re-emit with the no-space
|
|
67
|
+
// separator form by passing the result through a second stringify.
|
|
68
|
+
const sorted = JSON.parse(JSON.stringify(value, _canonicalReplacer()));
|
|
69
|
+
const compact = JSON.stringify(sorted);
|
|
70
|
+
return createHash('sha256').update(compact, 'utf-8').digest('hex');
|
|
71
|
+
}
|
|
72
|
+
function _truncate(text, n = 200) {
|
|
73
|
+
if (text.length <= n)
|
|
74
|
+
return text;
|
|
75
|
+
return `${text.slice(0, n - 3)}...`;
|
|
76
|
+
}
|
|
77
|
+
export class LangSmithAdapter extends GenericRuntimeAdapter {
|
|
78
|
+
runtime_name = 'langsmith';
|
|
79
|
+
schema_version = 1;
|
|
80
|
+
translate(runtime_event) {
|
|
81
|
+
if (typeof runtime_event !== 'object' ||
|
|
82
|
+
runtime_event === null ||
|
|
83
|
+
typeof runtime_event.id !== 'string' ||
|
|
84
|
+
typeof runtime_event.run_type !== 'string') {
|
|
85
|
+
throw new AdapterTranslationError(`expected LangSmithRun object, got ${runtime_event === null ? 'null' : typeof runtime_event}`);
|
|
86
|
+
}
|
|
87
|
+
const run = runtime_event;
|
|
88
|
+
let resultStatus;
|
|
89
|
+
if (run.error) {
|
|
90
|
+
resultStatus = 'ERROR';
|
|
91
|
+
}
|
|
92
|
+
else {
|
|
93
|
+
resultStatus = 'OK';
|
|
94
|
+
}
|
|
95
|
+
const kind = KNOWN_RUN_TYPES.has(run.run_type) ? run.run_type : 'unknown';
|
|
96
|
+
const inputs = run.inputs ?? {};
|
|
97
|
+
const payload = {
|
|
98
|
+
kind,
|
|
99
|
+
tool_name: `langsmith.${kind}.${run.name}`,
|
|
100
|
+
tool_call_id: run.id,
|
|
101
|
+
arguments_hash: _hashJson(inputs),
|
|
102
|
+
result_status: resultStatus,
|
|
103
|
+
};
|
|
104
|
+
if (run.outputs != null) {
|
|
105
|
+
payload.result_hash = _hashJson(run.outputs);
|
|
106
|
+
}
|
|
107
|
+
if (run.end_time != null) {
|
|
108
|
+
const ms = run.end_time.getTime() - run.start_time.getTime();
|
|
109
|
+
payload.latency_ms = Math.trunc(ms);
|
|
110
|
+
}
|
|
111
|
+
if (run.error) {
|
|
112
|
+
payload.error_code = _truncate(run.error);
|
|
113
|
+
}
|
|
114
|
+
if (run.tags && run.tags.length > 0) {
|
|
115
|
+
payload.tags = [...run.tags];
|
|
116
|
+
}
|
|
117
|
+
const sessionId = run.trace_id ?? run.id;
|
|
118
|
+
return makeEventDraft({
|
|
119
|
+
event_type: TOOL_CALL_EVENT,
|
|
120
|
+
actor: `langsmith://${run.run_type}/${run.name}`,
|
|
121
|
+
payload,
|
|
122
|
+
subject_ref: run.end_user_id ? makeSubjectRef('opaque', run.end_user_id) : null,
|
|
123
|
+
session_id: sessionId,
|
|
124
|
+
reference_db_ref: run.parent_run_id ?? null,
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
static fromDict(raw) {
|
|
128
|
+
const required = ['id', 'name', 'run_type', 'start_time'];
|
|
129
|
+
const missing = required.filter((k) => !(k in raw));
|
|
130
|
+
if (missing.length > 0) {
|
|
131
|
+
throw new AdapterTranslationError(`LangSmith run dict missing required fields: ${JSON.stringify(missing.sort())}`);
|
|
132
|
+
}
|
|
133
|
+
const parseDt = (value) => {
|
|
134
|
+
if (value instanceof Date)
|
|
135
|
+
return value;
|
|
136
|
+
if (typeof value === 'string') {
|
|
137
|
+
const normalized = value.endsWith('Z') ? value.replace('Z', '+00:00') : value;
|
|
138
|
+
const d = new Date(normalized);
|
|
139
|
+
if (Number.isNaN(d.getTime())) {
|
|
140
|
+
throw new AdapterTranslationError(`unparsable datetime ${JSON.stringify(value)}`);
|
|
141
|
+
}
|
|
142
|
+
return d;
|
|
143
|
+
}
|
|
144
|
+
throw new AdapterTranslationError(`datetime field has type ${typeof value}, expected Date or ISO string`);
|
|
145
|
+
};
|
|
146
|
+
const metadata = raw.metadata ?? {};
|
|
147
|
+
if (typeof metadata !== 'object' || Array.isArray(metadata)) {
|
|
148
|
+
throw new AdapterTranslationError('metadata must be an object');
|
|
149
|
+
}
|
|
150
|
+
const tagsRaw = raw.tags;
|
|
151
|
+
if (tagsRaw !== undefined && tagsRaw !== null && !Array.isArray(tagsRaw)) {
|
|
152
|
+
throw new AdapterTranslationError('tags must be an array');
|
|
153
|
+
}
|
|
154
|
+
const tags = Array.isArray(tagsRaw) ? tagsRaw.map((t) => String(t)) : [];
|
|
155
|
+
return {
|
|
156
|
+
id: String(raw.id),
|
|
157
|
+
name: String(raw.name),
|
|
158
|
+
run_type: String(raw.run_type),
|
|
159
|
+
start_time: parseDt(raw.start_time),
|
|
160
|
+
end_time: raw.end_time ? parseDt(raw.end_time) : null,
|
|
161
|
+
inputs: raw.inputs ?? {},
|
|
162
|
+
outputs: raw.outputs ?? null,
|
|
163
|
+
error: raw.error ?? null,
|
|
164
|
+
trace_id: raw.trace_id ?? null,
|
|
165
|
+
parent_run_id: raw.parent_run_id ?? null,
|
|
166
|
+
status: raw.status ?? null,
|
|
167
|
+
tags,
|
|
168
|
+
metadata,
|
|
169
|
+
end_user_id: typeof metadata.user_id === 'string' ? metadata.user_id : null,
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
//# sourceMappingURL=langsmith.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"langsmith.js","sourceRoot":"","sources":["../../src/adapters/langsmith.ts"],"names":[],"mappings":"AAAA,uDAAuD;AACvD,sCAAsC;AACtC;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,OAAO,EAAE,uBAAuB,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AAChF,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAmB,cAAc,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAE9E,MAAM,eAAe,GAAG,IAAI,GAAG,CAAC;IAC9B,MAAM;IACN,KAAK;IACL,OAAO;IACP,WAAW;IACX,QAAQ;IACR,QAAQ;IACR,WAAW;CACZ,CAAC,CAAC;AAmBH,S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|
+
*
|
|
4
|
+
* Per ADR-0004 § 1 ("Universal rule"):
|
|
5
|
+
*
|
|
6
|
+
* Any AIOS surface whose primary semantic is authority or execution stays
|
|
7
|
+
* in AIOS. Attestplane only ever records the event of a decision having
|
|
8
|
+
* been made, never owns the decision.
|
|
9
|
+
*
|
|
10
|
+
* A `GenericRuntimeAdapter` translates one runtime-specific event into one
|
|
11
|
+
* `EventDraft`. That is the only verb it owns. The abstract class
|
|
12
|
+
* deliberately exposes no `execute()`, `grant()`, or `decide()` method.
|
|
13
|
+
*
|
|
14
|
+
* Concrete adapters (AIOS, LangGraph, Claude Code SDK, …) live in their
|
|
15
|
+
* respective execution-plane repositories or in `attestplane-contrib`, not
|
|
16
|
+
* in the substrate OSS tree.
|
|
17
|
+
*
|
|
18
|
+
* Spec-Only Phase 0 deliverable (migration plan ticket #3).
|
|
19
|
+
*/
|
|
20
|
+
import type { EventDraft } from './types.js';
|
|
21
|
+
/** Base class for any adapter-raised error. */
|
|
22
|
+
export declare class AdapterError extends Error {
|
|
23
|
+
constructor(message: string);
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* A runtime event could not be translated into an `EventDraft`.
|
|
27
|
+
*
|
|
28
|
+
* Adapters MUST throw this (or a subclass) rather than returning a
|
|
29
|
+
* partially-populated draft or silently dropping the event. Silent drops
|
|
30
|
+
* would defeat the point of a substrate.
|
|
31
|
+
*/
|
|
32
|
+
export declare class AdapterTranslationError extends AdapterError {
|
|
33
|
+
constructor(message: string);
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Abstract base for any execution-plane → Attestplane adapter.
|
|
37
|
+
*
|
|
38
|
+
* The contract is intentionally narrow:
|
|
39
|
+
*
|
|
40
|
+
* 1. `translate()` is the only required method.
|
|
41
|
+
* 2. `translate()` is a **pure function**: given the same input it returns
|
|
42
|
+
* the same output. No I/O, no side effects, no clock reads, no random
|
|
43
|
+
* number generation, no calls back into the runtime.
|
|
44
|
+
* 3. The returned `EventDraft` is the caller-provided portion of the audit
|
|
45
|
+
* event. The substrate assigns `event_id`, `timestamp`, `seq`,
|
|
46
|
+
* `prev_hash`, and `event_hash`. Adapters do not produce those fields.
|
|
47
|
+
* 4. Adapters do not execute, grant, decide, or otherwise affect runtime
|
|
48
|
+
* state. The base class enforces this via a runtime check in the
|
|
49
|
+
* constructor that rejects forbidden method names at instantiation
|
|
50
|
+
* time. (TypeScript does not have a Python-style `__init_subclass__`
|
|
51
|
+
* hook, so the check runs at `new` time rather than class-creation
|
|
52
|
+
* time.)
|
|
53
|
+
*
|
|
54
|
+
* Reserved method names that any subclass MUST NOT define at the public
|
|
55
|
+
* level (any leading underscore exempts the name):
|
|
56
|
+
*
|
|
57
|
+
* - `execute`, `run`, `dispatch`
|
|
58
|
+
* - `grant`, `revoke`, `issue`
|
|
59
|
+
* - `decide`, `approve`, `reject`
|
|
60
|
+
* - `settle`, `charge`, `credit`
|
|
61
|
+
* - `schedule`, `allocate`
|
|
62
|
+
*
|
|
63
|
+
* Defining any of these is an ADR-0004 boundary violation and the
|
|
64
|
+
* constructor throws on first instantiation.
|
|
65
|
+
*/
|
|
66
|
+
export declare abstract class GenericRuntimeAdapter<RuntimeEvent> {
|
|
67
|
+
abstract readonly runtime_name: string;
|
|
68
|
+
abstract readonly schema_version: number;
|
|
69
|
+
constructor();
|
|
70
|
+
/**
|
|
71
|
+
* Translate one runtime-specific event into one `EventDraft`.
|
|
72
|
+
*
|
|
73
|
+
* Implementations MUST:
|
|
74
|
+
*
|
|
75
|
+
* - Throw `AdapterTranslationError` on any input the adapter cannot map.
|
|
76
|
+
* Never return `null` or a partially-populated draft.
|
|
77
|
+
* - Be pure: same input → same output, no I/O, no clock reads.
|
|
78
|
+
* - Apply pseudonymization at the boundary: any direct identifier in
|
|
79
|
+
* `runtime_event` that maps to a data subject MUST be wrapped in a
|
|
80
|
+
* `SubjectRef` with an appropriate `scheme` before being placed in the
|
|
81
|
+
* returned draft. Raw PII in `payload` is a GDPR Art. 4(5) violation.
|
|
82
|
+
* - Not call into the runtime to fetch additional context. If the
|
|
83
|
+
* runtime event lacks information the adapter needs, the runtime must
|
|
84
|
+
* emit a richer event — not the adapter.
|
|
85
|
+
*/
|
|
86
|
+
abstract translate(runtime_event: RuntimeEvent): EventDraft;
|
|
87
|
+
}
|
|
88
|
+
//# sourceMappingURL=adapters.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adapters.d.ts","sourceRoot":"","sources":["../src/adapters.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7C,+CAA+C;AAC/C,qBAAa,YAAa,SAAQ,KAAK;gBACzB,OAAO,EAAE,MAAM;CAI5B;AAED;;;;;;GAMG;AACH,qBAAa,uBAAwB,SAAQ,YAAY;gBAC3C,OAAO,EAAE,MAAM;CAI5B;AAmBD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,8BAAsB,qBAAqB,CAAC,YAAY;IACtD,QAAQ,CAAC,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IACvC,QAAQ,CAAC,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;;IAqBzC;;;;;;;;;;;;;;;OAeG;IACH,QAAQ,CAAC,SAAS,CAAC,aAAa,EAAE,YAAY,GAAG,UAAU;CAC5D"}
|
package/dist/adapters.js
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: 2026 The Attestplane Authors
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
/**
|
|
4
|
+
* Abstract runtime-adapter base — the only adapter surface in the substrate.
|
|
5
|
+
*
|
|
6
|
+
* Per ADR-0004 § 1 ("Universal rule"):
|
|
7
|
+
*
|
|
8
|
+
* Any AIOS surface whose primary semantic is authority or execution stays
|
|
9
|
+
* in AIOS. Attestplane only ever records the event of a decision having
|
|
10
|
+
* been made, never owns the decision.
|
|
11
|
+
*
|
|
12
|
+
* A `GenericRuntimeAdapter` translates one runtime-specific event into one
|
|
13
|
+
* `EventDraft`. That is the only verb it owns. The abstract class
|
|
14
|
+
* deliberately exposes no `execute()`, `grant()`, or `decide()` method.
|
|
15
|
+
*
|
|
16
|
+
* Concrete adapters (AIOS, LangGraph, Claude Code SDK, …) live in their
|
|
17
|
+
* respective execution-plane repositories or in `attestplane-contrib`, not
|
|
18
|
+
* in the substrate OSS tree.
|
|
19
|
+
*
|
|
20
|
+
* Spec-Only Phase 0 deliverable (migration plan ticket #3).
|
|
21
|
+
*/
|
|
22
|
+
/** Base class for any adapter-raised error. */
|
|
23
|
+
export class AdapterError extends Error {
|
|
24
|
+
constructor(message) {
|
|
25
|
+
super(message);
|
|
26
|
+
this.name = 'AdapterError';
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* A runtime event could not be translated into an `EventDraft`.
|
|
31
|
+
*
|
|
32
|
+
* Adapters MUST throw this (or a subclass) rather than returning a
|
|
33
|
+
* partially-populated draft or silently dropping the event. Silent drops
|
|
34
|
+
* would defeat the point of a substrate.
|
|
35
|
+
*/
|
|
36
|
+
export class AdapterTranslationError extends AdapterError {
|
|
37
|
+
constructor(message) {
|
|
38
|
+
super(message);
|
|
39
|
+
this.name = 'AdapterTranslationError';
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
const FORBIDDEN_METHOD_NAMES = new Set([
|
|
43
|
+
'execute',
|
|
44
|
+
'run',
|
|
45
|
+
'dispatch',
|
|
46
|
+
'grant',
|
|
47
|
+
'revoke',
|
|
48
|
+
'issue',
|
|
49
|
+
'decide',
|
|
50
|
+
'approve',
|
|
51
|
+
'reject',
|
|
52
|
+
'settle',
|
|
53
|
+
'charge',
|
|
54
|
+
'credit',
|
|
55
|
+
'schedule',
|
|
56
|
+
'allocate',
|
|
57
|
+
]);
|
|
58
|
+
/**
|
|
59
|
+
* Abstract base for any execution-plane → Attestplane adapter.
|
|
60
|
+
*
|
|
61
|
+
* The contract is intentionally narrow:
|
|
62
|
+
*
|
|
63
|
+
* 1. `translate()` is the only required method.
|
|
64
|
+
* 2. `translate()` is a **pure function**: given the same input it returns
|
|
65
|
+
* the same output. No I/O, no side effects, no clock reads, no random
|
|
66
|
+
* number generation, no calls back into the runtime.
|
|
67
|
+
* 3. The returned `EventDraft` is the caller-provided portion of the audit
|
|
68
|
+
* event. The substrate assigns `event_id`, `timestamp`, `seq`,
|
|
69
|
+
* `prev_hash`, and `event_hash`. Adapters do not produce those fields.
|
|
70
|
+
* 4. Adapters do not execute, grant, decide, or otherwise affect runtime
|
|
71
|
+
* state. The base class enforces this via a runtime check in the
|
|
72
|
+
* constructor that rejects forbidden method names at instantiation
|
|
73
|
+
* time. (TypeScript does not have a Python-style `__init_subclass__`
|
|
74
|
+
* hook, so the check runs at `new` time rather than class-creation
|
|
75
|
+
* time.)
|
|
76
|
+
*
|
|
77
|
+
* Reserved method names that any subclass MUST NOT define at the public
|
|
78
|
+
* level (any leading underscore exempts the name):
|
|
79
|
+
*
|
|
80
|
+
* - `execute`, `run`, `dispatch`
|
|
81
|
+
* - `grant`, `revoke`, `issue`
|
|
82
|
+
* - `decide`, `approve`, `reject`
|
|
83
|
+
* - `settle`, `charge`, `credit`
|
|
84
|
+
* - `schedule`, `allocate`
|
|
85
|
+
*
|
|
86
|
+
* Defining any of these is an ADR-0004 boundary violation and the
|
|
87
|
+
* constructor throws on first instantiation.
|
|
88
|
+
*/
|
|
89
|
+
export class GenericRuntimeAdapter {
|
|
90
|
+
constructor() {
|
|
91
|
+
const proto = Object.getPrototypeOf(this);
|
|
92
|
+
const offenders = [];
|
|
93
|
+
for (const name of Object.getOwnPropertyNames(proto)) {
|
|
94
|
+
if (name === 'constructor')
|
|
95
|
+
continue;
|
|
96
|
+
if (name.startsWith('_'))
|
|
97
|
+
continue;
|
|
98
|
+
if (FORBIDDEN_METHOD_NAMES.has(name)) {
|
|
99
|
+
offenders.push(name);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
if (offenders.length > 0) {
|
|
103
|
+
offenders.sort();
|
|
104
|
+
throw new TypeError(`${this.constructor.name} defines forbidden authority/execution method(s) ` +
|
|
105
|
+
`[${offenders.join(', ')}]; adapters may only translate events. See ADR-0004 § 1.`);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
//# sourceMappingURL=adapters.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adapters.js","sourceRoot":"","sources":["../src/adapters.ts"],"names":[],"mappings":"AAAA,uDAAuD;AACvD,sCAAsC;AACtC;;;;;;;;;;;;;;;;;;GAkBG;AAIH,+CAA+C;AAC/C,MAAM,OAAO,YAAa,SAAQ,KAAK;IACrC,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,cAAc,CAAC;IAC7B,CAAC;CACF;AAED;;;;;;GAMG;AACH,MAAM,OAAO,uBAAwB,SAAQ,YAAY;IACvD,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,yBAAyB,CAAC;IACxC,CAAC;CACF;AAED,MAAM,sBAAsB,GAAwB,IAAI,GAAG,CAAC;IAC1D,SAAS;IACT,KAAK;IACL,UAAU;IACV,OAAO;IACP,QAAQ;IACR,OAAO;IACP,QAAQ;IACR,SAAS;IACT,QAAQ;IACR,QAAQ;IACR,QAAQ;IACR,QAAQ;IACR,UAAU;IACV,UAAU;CACX,CAAC,CAAC;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,MAAM,OAAgB,qBAAqB;IAIzC;QACE,MAAM,KAAK,GAAG,MAAM,CAAC,cAAc,CAAC,IAAI,CAAW,CAAC;QACpD,MAAM,SAAS,GAAa,EAAE,CAAC;QAC/B,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,mBAAmB,CAAC,KAAK,CAAC,EAAE,CAAC;YACrD,IAAI,IAAI,KAAK,aAAa;gBAAE,SAAS;YACrC,IAAI,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC;gBAAE,SAAS;YACnC,IAAI,sBAAsB,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;gBACrC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YACvB,CAAC;QACH,CAAC;QACD,IAAI,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACzB,SAAS,CAAC,IAAI,EAAE,CAAC;YACjB,MAAM,IAAI,SAAS,CACjB,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,mDAAmD;gBACzE,IAAI,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,0DAA0D,CACrF,CAAC;QACJ,CAAC;IACH,CAAC;CAmBF"}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* RFC-3161 anchoring (TypeScript port of `sdk/python/src/attestplane/anchoring/`).
|
|
3
|
+
*
|
|
4
|
+
* Ships the design skeleton — types, abstract base, mock provider,
|
|
5
|
+
* multi-TSA composite, and an anchor-aware verifier API. Real
|
|
6
|
+
* cryptography-backed providers (Free TSA, DigiCert) ship in a
|
|
7
|
+
* follow-up alongside `anchor_vectors.json` cross-language fixtures.
|
|
8
|
+
*
|
|
9
|
+
* Surface parity with the Python module: anyone reading the Python
|
|
10
|
+
* skeleton at `attestplane.anchoring` finds the same shapes here.
|
|
11
|
+
*/
|
|
12
|
+
import type { ChainedEvent } from './types.js';
|
|
13
|
+
export declare const ANCHOR_SCHEMA_VERSION: 1;
|
|
14
|
+
export type AnchorStatus = 'unanchored' | 'pending' | 'anchored' | 'failed_permanent';
|
|
15
|
+
export type CertStatus = 'VALID' | 'VALID_UNVERIFIED' | 'MISSING_LTV_ARTIFACTS' | 'EXPIRED_VALID_AT_ISSUANCE' | 'REVOKED';
|
|
16
|
+
export type AnchorVerificationStatus = 'verified' | 'failed' | 'not_performed';
|
|
17
|
+
export declare class AnchorError extends Error {
|
|
18
|
+
constructor(message: string);
|
|
19
|
+
}
|
|
20
|
+
export declare class TSAUnavailableError extends AnchorError {
|
|
21
|
+
constructor(message: string);
|
|
22
|
+
}
|
|
23
|
+
export declare class AnchorVerificationError extends AnchorError {
|
|
24
|
+
constructor(message: string);
|
|
25
|
+
}
|
|
26
|
+
export interface AnchorRecord {
|
|
27
|
+
readonly anchor_schema_version: number;
|
|
28
|
+
readonly anchored_seq: number;
|
|
29
|
+
readonly anchored_event_hash: Uint8Array;
|
|
30
|
+
readonly tsa_provider_id: string;
|
|
31
|
+
readonly tsa_token: Uint8Array;
|
|
32
|
+
readonly tsa_cert_chain: readonly Uint8Array[];
|
|
33
|
+
readonly ocsp_responses: readonly Uint8Array[];
|
|
34
|
+
readonly issued_at_claimed: Date;
|
|
35
|
+
}
|
|
36
|
+
export declare function validateAnchorRecord(a: AnchorRecord): void;
|
|
37
|
+
export interface AnchorPolicy {
|
|
38
|
+
readonly batch_size: number;
|
|
39
|
+
readonly max_idle_seconds: number;
|
|
40
|
+
readonly per_event: boolean;
|
|
41
|
+
}
|
|
42
|
+
export declare const DEFAULT_ANCHOR_POLICY: AnchorPolicy;
|
|
43
|
+
export declare function makeAnchorPolicy(input?: Partial<AnchorPolicy>): AnchorPolicy;
|
|
44
|
+
export interface TimestampRequest {
|
|
45
|
+
readonly digest: Uint8Array;
|
|
46
|
+
readonly nonce?: Uint8Array;
|
|
47
|
+
}
|
|
48
|
+
export declare function makeTimestampRequest(input: TimestampRequest): TimestampRequest;
|
|
49
|
+
/**
|
|
50
|
+
* Abstract base for any TSA provider implementation.
|
|
51
|
+
*
|
|
52
|
+
* TypeScript analogue of Python's `TSAProvider` ABC. The
|
|
53
|
+
* forbidden-mutating-verb check runs in the constructor (TS has no
|
|
54
|
+
* `__init_subclass__` equivalent).
|
|
55
|
+
*/
|
|
56
|
+
export declare abstract class TSAProvider {
|
|
57
|
+
abstract readonly provider_id: string;
|
|
58
|
+
abstract readonly schema_version: number;
|
|
59
|
+
constructor();
|
|
60
|
+
abstract requestTimestamp(request: TimestampRequest, options?: {
|
|
61
|
+
readonly anchoredSeq?: number;
|
|
62
|
+
readonly now?: Date;
|
|
63
|
+
}): AnchorRecord;
|
|
64
|
+
}
|
|
65
|
+
export interface MockTSAProviderInput {
|
|
66
|
+
readonly provider_id?: string;
|
|
67
|
+
readonly fixed_time?: Date;
|
|
68
|
+
readonly fail_with?: Error;
|
|
69
|
+
}
|
|
70
|
+
export declare class MockTSAProvider extends TSAProvider {
|
|
71
|
+
readonly provider_id: string;
|
|
72
|
+
readonly schema_version: 1;
|
|
73
|
+
private readonly _fixed_time;
|
|
74
|
+
private readonly _fail_with;
|
|
75
|
+
constructor(input?: MockTSAProviderInput);
|
|
76
|
+
requestTimestamp(request: TimestampRequest, options?: {
|
|
77
|
+
readonly anchoredSeq?: number;
|
|
78
|
+
readonly now?: Date;
|
|
79
|
+
}): AnchorRecord;
|
|
80
|
+
}
|
|
81
|
+
export interface MultiTSAProviderInput {
|
|
82
|
+
readonly providers: readonly TSAProvider[];
|
|
83
|
+
readonly tolerate_partial?: boolean;
|
|
84
|
+
}
|
|
85
|
+
export declare class MultiTSAProvider {
|
|
86
|
+
private readonly _providers;
|
|
87
|
+
private readonly _tolerate_partial;
|
|
88
|
+
constructor(input: MultiTSAProviderInput);
|
|
89
|
+
get providerIds(): readonly string[];
|
|
90
|
+
requestTimestamps(request: TimestampRequest, options?: {
|
|
91
|
+
readonly anchoredSeq?: number;
|
|
92
|
+
readonly now?: Date;
|
|
93
|
+
}): AnchorRecord[];
|
|
94
|
+
}
|
|
95
|
+
export interface SingleAnchorResult {
|
|
96
|
+
readonly seq: number;
|
|
97
|
+
readonly provider: string;
|
|
98
|
+
readonly valid: boolean;
|
|
99
|
+
readonly cert_status: CertStatus;
|
|
100
|
+
readonly ltv_artifacts_present: boolean;
|
|
101
|
+
readonly reason: string | null;
|
|
102
|
+
}
|
|
103
|
+
export interface AnchorVerificationResult {
|
|
104
|
+
readonly chain_ok: boolean;
|
|
105
|
+
readonly chain_reason: string | null;
|
|
106
|
+
readonly anchored_seqs: ReadonlySet<number>;
|
|
107
|
+
readonly unanchored_seqs: ReadonlySet<number>;
|
|
108
|
+
readonly anchor_results: readonly SingleAnchorResult[];
|
|
109
|
+
readonly verification_status: AnchorVerificationStatus;
|
|
110
|
+
readonly ok: boolean;
|
|
111
|
+
}
|
|
112
|
+
export interface VerifyChainWithAnchorsOptions {
|
|
113
|
+
readonly trustRootsDer?: readonly Uint8Array[];
|
|
114
|
+
readonly intermediatesDer?: readonly Uint8Array[];
|
|
115
|
+
readonly verificationTime?: Date;
|
|
116
|
+
readonly maxChainDepth?: number;
|
|
117
|
+
}
|
|
118
|
+
export declare function verifyChainWithAnchors(events: readonly ChainedEvent[], anchors: readonly AnchorRecord[], options?: VerifyChainWithAnchorsOptions): AnchorVerificationResult;
|
|
119
|
+
//# sourceMappingURL=anchoring.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"anchoring.d.ts","sourceRoot":"","sources":["../src/anchoring.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;GAUG;AAMH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE/C,eAAO,MAAM,qBAAqB,EAAG,CAAU,CAAC;AAEhD,MAAM,MAAM,YAAY,GAAG,YAAY,GAAG,SAAS,GAAG,UAAU,GAAG,kBAAkB,CAAC;AAEtF,MAAM,MAAM,UAAU,GAClB,OAAO,GACP,kBAAkB,GAClB,uBAAuB,GACvB,2BAA2B,GAC3B,SAAS,CAAC;AACd,MAAM,MAAM,wBAAwB,GAAG,UAAU,GAAG,QAAQ,GAAG,eAAe,CAAC;AAI/E,qBAAa,WAAY,SAAQ,KAAK;gBACxB,OAAO,EAAE,MAAM;CAI5B;AAED,qBAAa,mBAAoB,SAAQ,WAAW;gBACtC,OAAO,EAAE,MAAM;CAI5B;AAED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