osuite 2.18.0 → 2.19.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/GOVERNED_TOOLS.md +106 -10
- package/README.md +1 -0
- package/RELEASE_NOTES.md +7 -0
- package/checkpointCli.mjs +36 -0
- package/cli.js +6 -1
- package/governed-tools/authority.mjs +4 -1
- package/governed-tools/dsse.mjs +57 -0
- package/governed-tools/native-evidence.mjs +24 -0
- package/native-proof.mjs +178 -27
- package/package.json +2 -1
package/GOVERNED_TOOLS.md
CHANGED
|
@@ -201,16 +201,112 @@ offline. It accepts the export or its `proof_bundle` member. The Studio
|
|
|
201
201
|
record is tamper-evident. The owner's signature authenticates the scoped
|
|
202
202
|
resource finding and binds it to the earlier proof and the runtime observation.
|
|
203
203
|
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
204
|
+
### Native proof packages and independent checkpoints
|
|
205
|
+
|
|
206
|
+
Use Studio with the native proof log migration and SDK 2.19 or later.
|
|
207
|
+
Configure distinct base64 Ed25519 PKCS8 DER keys in
|
|
208
|
+
`OSUITE_NATIVE_PROOF_SIGNING_KEY` and `OSUITE_NATIVE_CHECKPOINT_SIGNING_KEY`.
|
|
209
|
+
Enroll the runtime RSA identity in the workspace. Configure the resource owner's
|
|
210
|
+
v2 closure adapter. Call `reconcile` to collect its committed or absent finding.
|
|
211
|
+
|
|
212
|
+
Use a workspace evidence credential for these requests.
|
|
213
|
+
|
|
214
|
+
| GET `/api/proof/export` query | Result |
|
|
215
|
+
| --- | --- |
|
|
216
|
+
| `format=native-log` | Workspace ID, log UUID, and latest assigned position. |
|
|
217
|
+
| `format=native&first=1&last=100` | Ordered `osuite.native_proof_package.v2` records for an inclusive interval. |
|
|
218
|
+
| `format=native-checkpoint&first=1&last=100` | Studio's checkpoint candidate for the same interval. |
|
|
219
|
+
|
|
220
|
+
Each workspace log starts at position 1. An action gets a position when its
|
|
221
|
+
insert commits. Earlier actions get positions in creation order during migration.
|
|
222
|
+
Use up to 1,000 positions per request. An export with missing evidence fails.
|
|
223
|
+
An action update can change the record digest while keeping its position. Export
|
|
224
|
+
after the intended owner findings have settled. Freeze the package and the
|
|
225
|
+
checkpoint together.
|
|
226
|
+
|
|
227
|
+
The Studio candidate is Ed25519 DSSE with payload type
|
|
228
|
+
`application/vnd.osuite.native-checkpoint.v2+json`. Its
|
|
229
|
+
`osuite.native_checkpoint.v2` payload carries `scope`, `count`, and `head`.
|
|
230
|
+
Scope contains `org_id`, `log_id`, `first_position`, and `last_position`.
|
|
231
|
+
The head starts with SHA-256 of canonical JSON `[checkpoint_schema, scope]`.
|
|
232
|
+
For each record in order, hash canonical JSON `[previous_head, record_digest]`.
|
|
233
|
+
The record digest covers the full canonical record, including its DSSE envelope.
|
|
234
|
+
Canonical JSON sorts object keys, preserves array order, and uses UTF-8.
|
|
235
|
+
Hashes and public key fingerprints are lowercase SHA-256 hex.
|
|
236
|
+
|
|
237
|
+
### Run the witness offline
|
|
238
|
+
|
|
239
|
+
The custodian controls a separate machine or account and an Ed25519 key.
|
|
240
|
+
Keep the private key in that domain. Give the verifier the witness public key
|
|
241
|
+
through a separate trusted channel. Get Studio, runtime and owner public keys
|
|
242
|
+
from their authorities. Pin them before collecting the package.
|
|
243
|
+
|
|
244
|
+
Choose the workspace and position interval under the custodian's own procedure.
|
|
245
|
+
Read the log UUID through a workspace evidence credential the custodian controls.
|
|
246
|
+
Save the chosen scope in `scope.json`. Collect `bundles.json` and `candidate.json`
|
|
247
|
+
for those positions. The witness tool checks the pinned Studio signature, the
|
|
248
|
+
chosen scope, and the head over the files it receives. Store its output in the
|
|
249
|
+
custodian's archive. Each output path is written once.
|
|
250
|
+
|
|
251
|
+
```sh
|
|
252
|
+
umask 077
|
|
253
|
+
openssl genpkey -algorithm Ed25519 -out witness.pem
|
|
254
|
+
openssl pkey -in witness.pem -pubout -out witness.pub.pem
|
|
255
|
+
osuite checkpoint witness --bundles bundles.json --candidate candidate.json \
|
|
256
|
+
--checkpoint-key studio-checkpoint.pub.pem --scope scope.json \
|
|
257
|
+
--witness-key witness.pem --out witnessed.json
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
The witnessed checkpoint is DSSE with payload type
|
|
261
|
+
`application/vnd.osuite.witnessed-native-checkpoint.v1+json`. Its payload is
|
|
262
|
+
the entire Studio candidate, including the Studio signature. The witness states
|
|
263
|
+
which exact range and bytes it observed. A claim about events that never reached
|
|
264
|
+
the log requires the custodian's own intake evidence.
|
|
265
|
+
|
|
266
|
+
### Verify a package offline
|
|
267
|
+
|
|
268
|
+
Give the verifier the packages, the authority keys, and the witnessed checkpoint.
|
|
269
|
+
Deliver `witnessed.json` and `witness.pub.pem` from the custodian's archive.
|
|
270
|
+
The optional scope file pins the independently planned range on the verifier too.
|
|
271
|
+
|
|
272
|
+
```sh
|
|
273
|
+
osuite checkpoint verify --bundles bundles.json --checkpoint witnessed.json \
|
|
274
|
+
--keys authority-keys.json --witness-key witness.pub.pem --scope scope.json
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
Use a JSON key file in this shape. Studio and runtime keys can be PEM or base64
|
|
278
|
+
SPKI DER. Owner keys use base64 SPKI DER. Keep old runtime pins for records that
|
|
279
|
+
precede a key rotation. Add `issuers` with `id`, `org_id` and `public_key` for
|
|
280
|
+
delegated records.
|
|
281
|
+
|
|
282
|
+
```json
|
|
283
|
+
{
|
|
284
|
+
"proof": "STUDIO_PROOF_PUBLIC_KEY",
|
|
285
|
+
"checkpoint": "STUDIO_CHECKPOINT_PUBLIC_KEY",
|
|
286
|
+
"runtimes": [{ "agent_id": "runtime-1", "public_key": "RUNTIME_RSA_PUBLIC_KEY" }],
|
|
287
|
+
"owners": [{ "resource_id": "refund-ledger", "public_key": "OWNER_ED25519_PUBLIC_KEY" }]
|
|
288
|
+
}
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
`verifyNativeProofPackage({ bundles, roots, checkpoint, witnessPublicKey, scope })`
|
|
292
|
+
from `osuite/native-proof` returns the same JSON as the CLI. It reports the
|
|
293
|
+
overall result and reasons for each record. The CLI exits with status 1 on
|
|
294
|
+
failure. Studio's records are tamper-evident. The runtime DSSE binds the actor
|
|
295
|
+
and input. Each v2 owner signature binds the workspace, action, resource, and
|
|
296
|
+
input digest to the original observation and proof. A committed finding names the
|
|
297
|
+
resource reference. An absent finding comes from a complete read with a write
|
|
298
|
+
fence in that same scope.
|
|
299
|
+
|
|
300
|
+
`RUNTIME_SIGNING_NOT_CONFIGURED` means the action had no configured signing
|
|
301
|
+
identity. `RUNTIME_SIGNATURE_MISSING` means the record lacks the runtime DSSE
|
|
302
|
+
evidence. This includes historical native records with only HTTP signatures.
|
|
303
|
+
`PROOF_SIGNING_NOT_CONFIGURED` reports a missing Studio export key.
|
|
304
|
+
The overall result fails if any required signature or owner finding is missing.
|
|
305
|
+
The outcome stays `unknown` when the owner finding cannot be verified.
|
|
306
|
+
|
|
307
|
+
Existing single-action exports still use `verifyNativeOwnerClosure`. Existing
|
|
308
|
+
`from` and `to` native windows still use `verifyNativeProofCohort` and their
|
|
309
|
+
Studio checkpoint. Independent verification uses the position-based format.
|
|
214
310
|
|
|
215
311
|
### Delegated Calls
|
|
216
312
|
|
package/README.md
CHANGED
|
@@ -191,6 +191,7 @@ The v2 SDK exposes the core governance loop plus first-class PCAA, replay, proof
|
|
|
191
191
|
- `verifyGovernanceProof(actionId)` -- Verify attestation/proof integrity and return structured checks.
|
|
192
192
|
- `getComplianceEvidence({ window })` -- Pull live evidence aggregates for compliance and PCAA health.
|
|
193
193
|
- `exportProof({ actionId, bundleId })` -- Export the portable verifier-facing proof package.
|
|
194
|
+
- [Native proof packages](GOVERNED_TOOLS.md#native-proof-packages-and-independent-checkpoints) support offline verification with an independent custodian.
|
|
194
195
|
- The opt-in [business evidence reader](BUSINESS_EVIDENCE.md) links a refund
|
|
195
196
|
to independently signed approval and resource-close records. A Studio proof
|
|
196
197
|
on its own does not establish that a refund posted. This is an experimental
|
package/RELEASE_NOTES.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
# SDK 2.19.0 release notes
|
|
2
|
+
|
|
3
|
+
- Export continuous ranges of tamper-evident native records from a Studio with the proof log migration.
|
|
4
|
+
- The runtime adds DSSE evidence for the actor and input. Native packages carry v2 owner findings for committed and absent outcomes.
|
|
5
|
+
- Run `osuite checkpoint witness` in the custodian's own environment. Run `osuite checkpoint verify` with the custodian's public key, checkpoint, and pinned authority keys.
|
|
6
|
+
- Keep using the existing verification functions for older proof formats. See [native proof packages](GOVERNED_TOOLS.md#native-proof-packages-and-independent-checkpoints).
|
|
7
|
+
|
|
1
8
|
# SDK 2.18.0 release notes
|
|
2
9
|
|
|
3
10
|
- Reopen the same governed tools journal and call `reconcile` to read an authenticated owner closure.
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { readFileSync, writeFileSync } from 'node:fs';
|
|
2
|
+
import { parseArgs } from 'node:util';
|
|
3
|
+
import { verifyNativeProofPackage, witnessNativeCheckpoint } from './native-proof.mjs';
|
|
4
|
+
|
|
5
|
+
const help = `osuite checkpoint witness --bundles FILE --candidate FILE --checkpoint-key FILE --scope FILE --witness-key PRIVATE_PEM --out FILE
|
|
6
|
+
osuite checkpoint verify --bundles FILE --checkpoint FILE --keys FILE --witness-key PUBLIC_PEM [--scope FILE]`;
|
|
7
|
+
|
|
8
|
+
const read = file => readFileSync(file, 'utf8');
|
|
9
|
+
const json = file => JSON.parse(read(file));
|
|
10
|
+
|
|
11
|
+
export function runCheckpointCommand([command, ...args], write) {
|
|
12
|
+
if (!command || ['--help', '-h'].includes(command) || args.includes('--help')) return write(help);
|
|
13
|
+
const shared = ['bundles', 'witness-key'];
|
|
14
|
+
const required = command === 'witness' ? [...shared, 'candidate', 'checkpoint-key', 'scope', 'out']
|
|
15
|
+
: [...shared, 'checkpoint', 'keys'];
|
|
16
|
+
if (!['verify', 'witness'].includes(command)) throw new Error(help);
|
|
17
|
+
const options = Object.fromEntries([...new Set([...required, 'scope'])].map(name => [name, { type: 'string', multiple: true }]));
|
|
18
|
+
const { values } = parseArgs({ args, options });
|
|
19
|
+
if (required.some(name => values[name]?.length !== 1) || Object.values(values).some(value => value.length !== 1 || !value[0])) {
|
|
20
|
+
throw new Error(help);
|
|
21
|
+
}
|
|
22
|
+
const bundles = json(values.bundles[0]);
|
|
23
|
+
const scope = values.scope && json(values.scope[0]);
|
|
24
|
+
const witnessKey = read(values['witness-key'][0]);
|
|
25
|
+
if (command === 'witness') {
|
|
26
|
+
const checkpoint = witnessNativeCheckpoint(json(values.candidate[0]), {
|
|
27
|
+
bundles, scope, checkpointPublicKey: read(values['checkpoint-key'][0]), witnessPrivateKey: witnessKey,
|
|
28
|
+
});
|
|
29
|
+
writeFileSync(values.out[0], `${JSON.stringify(checkpoint, null, 2)}\n`, { flag: 'wx', mode: 0o600 });
|
|
30
|
+
return write(`Witnessed checkpoint saved to ${values.out[0]}`);
|
|
31
|
+
}
|
|
32
|
+
const result = verifyNativeProofPackage({ bundles, scope, checkpoint: json(values.checkpoint[0]),
|
|
33
|
+
roots: json(values.keys[0]), witnessPublicKey: witnessKey });
|
|
34
|
+
write(JSON.stringify(result, null, 2));
|
|
35
|
+
if (!result.verified) process.exitCode = 1;
|
|
36
|
+
}
|
package/cli.js
CHANGED
|
@@ -177,7 +177,7 @@ const CONTROLLED_TRANSFER_CLI = ['doctor', 'mcp'].includes(process.argv[2])
|
|
|
177
177
|
&& process.argv.slice(3).some(value => /^--(?:controlled-transfers|require-controlled-transfers)(?:=|$)/.test(value));
|
|
178
178
|
const NATIVE_RUNTIME_DOCTOR = process.argv[2] === 'doctor'
|
|
179
179
|
&& process.argv.slice(3).some(value => /^--runtime(?:=|$)/.test(value));
|
|
180
|
-
loadProjectEnvironment();
|
|
180
|
+
if (process.argv[2] !== 'checkpoint') loadProjectEnvironment();
|
|
181
181
|
|
|
182
182
|
function envValue(name, fallback) {
|
|
183
183
|
return process.env[name] || process.env[fallback] || '';
|
|
@@ -800,6 +800,7 @@ function printHelp() {
|
|
|
800
800
|
write(' osuite adapters [status|coverage] Explain Runtime Coverage tiers and next steps');
|
|
801
801
|
write(' osuite adapter init <name> Scaffold an enterprise custom adapter mapping');
|
|
802
802
|
write(' osuite adapter test <file> Validate an enterprise custom adapter mapping');
|
|
803
|
+
write(' osuite checkpoint witness|verify Countersign or verify a native checkpoint offline');
|
|
803
804
|
write(' osuite external status Show external verifier network setup and usage');
|
|
804
805
|
write(' osuite external configure --provider babyblue_invinoveritas --mode shadow --api-key <key> --expected-source-class independent_mediator');
|
|
805
806
|
write(' osuite connect [auto|codex|claude|cursor|sdk|mcp] Detect runtime and start browser handoff');
|
|
@@ -1890,6 +1891,10 @@ async function main() {
|
|
|
1890
1891
|
if (!command) return onboardingWelcome();
|
|
1891
1892
|
if (['help', '--help', '-h'].includes(command)) return printHelp();
|
|
1892
1893
|
if (['version', '--version', '-v'].includes(command)) return write(pkg.version);
|
|
1894
|
+
if (command === 'checkpoint') {
|
|
1895
|
+
const { runCheckpointCommand } = await import('./checkpointCli.mjs');
|
|
1896
|
+
return runCheckpointCommand(process.argv.slice(3), write);
|
|
1897
|
+
}
|
|
1893
1898
|
if (CONTROLLED_TRANSFER_CLI) return controlledTransferCommand(command, args);
|
|
1894
1899
|
if (NATIVE_RUNTIME_DOCTOR) {
|
|
1895
1900
|
if (args._.length || !['sdk', 'mcp'].includes(args.runtime) || Object.keys(args).some(key => !['_', 'runtime'].includes(key))) {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import path from 'node:path';
|
|
2
2
|
import { setTimeout as delay } from 'node:timers/promises';
|
|
3
3
|
import { canonicalJson, createApiClient, isTransientFailure, sha256 } from '../runtime/protocol.mjs';
|
|
4
|
+
import { signNativeRuntimeCall } from './native-evidence.mjs';
|
|
4
5
|
import { MAX_GUARD_WEBHOOK_TIMEOUT_MS } from '../runtime/guard-timeout.mjs';
|
|
5
6
|
import { rejectionFenceUnchanged, resolveRemotePosture } from '../runtime/posture.mjs';
|
|
6
7
|
import { createStateStore } from '../runtime/state.mjs';
|
|
@@ -99,6 +100,7 @@ export function createStudioAuthority(config, journalPath) {
|
|
|
99
100
|
const phase = record.state === 'held' ? 'redeeming' : 'requesting';
|
|
100
101
|
const { api, effective } = await current(aborted);
|
|
101
102
|
if (aborted()) reject('ABORTED');
|
|
103
|
+
const runtimeEvidence = signNativeRuntimeCall(effective, { ...record, operationDigest: sha256(record.operationId) });
|
|
102
104
|
const session = await api.request('POST', '/api/runtime-sessions', {
|
|
103
105
|
runtime_session_id: record.sessionId, agent_id: config.agentId, runtime_adapter_id: config.runtimeId,
|
|
104
106
|
runtime_family: 'sdk_tool_runtime', adapter_mode: 'sdk_wrapper', client_name: 'osuite/governed-tools',
|
|
@@ -128,7 +130,8 @@ export function createStudioAuthority(config, journalPath) {
|
|
|
128
130
|
claim();
|
|
129
131
|
dispatchDeadline = performance.now() + actionWindow.timeoutMs;
|
|
130
132
|
}
|
|
131
|
-
if (guardRequest
|
|
133
|
+
if (guardRequest || registering) body = { ...body, native_runtime_evidence: runtimeEvidence };
|
|
134
|
+
if (guardRequest && phase === 'requesting') body.native_guard_replay = 'v1';
|
|
132
135
|
const window = registering ? actionWindow : guardRequest ? { timeoutMs: guardTimeoutMs, signal } : options;
|
|
133
136
|
const response = await api.request(method, endpoint, body, {
|
|
134
137
|
...window, readForbiddenBody: registering || guardRequest,
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { createPublicKey, sign, verify } from 'node:crypto';
|
|
2
|
+
import { canonicalJson, isObject, sha256 } from '../runtime/protocol.mjs';
|
|
3
|
+
|
|
4
|
+
export function exactFields(value, fields) {
|
|
5
|
+
return isObject(value) && Object.keys(value).length === fields.length && fields.every(field => Object.hasOwn(value, field));
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export function keyPin(key) {
|
|
9
|
+
const publicKey = key.type === 'public' ? key : createPublicKey(key);
|
|
10
|
+
return { key, id: sha256(publicKey.export({ format: 'der', type: 'spki' })) };
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export function publicKeyPin(value, algorithm) {
|
|
14
|
+
if (typeof value !== 'string' || value.length > 2500) return null;
|
|
15
|
+
try {
|
|
16
|
+
const pem = value.trim();
|
|
17
|
+
const der = Buffer.from(pem, 'base64');
|
|
18
|
+
const key = pem.startsWith('-----BEGIN PUBLIC KEY-----')
|
|
19
|
+
? createPublicKey(pem)
|
|
20
|
+
: der.toString('base64') === pem && createPublicKey({ key: der, format: 'der', type: 'spki' });
|
|
21
|
+
return key?.asymmetricKeyType === algorithm ? keyPin(key) : null;
|
|
22
|
+
} catch { return null; }
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function pae(type, data) {
|
|
26
|
+
return Buffer.concat([Buffer.from(`DSSEv1 ${Buffer.byteLength(type)} ${type} ${data.length} `), data]);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const algorithm = key => key.asymmetricKeyType === 'ed25519' ? null : 'sha256';
|
|
30
|
+
|
|
31
|
+
export function signDsse(payloadType, value, signer) {
|
|
32
|
+
const data = Buffer.from(canonicalJson(value));
|
|
33
|
+
const signatures = signer
|
|
34
|
+
? [{ keyid: signer.id, sig: sign(algorithm(signer.key), pae(payloadType, data), signer.key).toString('base64') }]
|
|
35
|
+
: [];
|
|
36
|
+
return { payloadType, payload: data.toString('base64'), signatures };
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export function openDsse(envelope, payloadType, pin) {
|
|
40
|
+
if (!exactFields(envelope, ['payloadType', 'payload', 'signatures']) || envelope.payloadType !== payloadType
|
|
41
|
+
|| typeof envelope.payload !== 'string' || envelope.payload.length > 1_500_000 || !Array.isArray(envelope.signatures)) return null;
|
|
42
|
+
try {
|
|
43
|
+
const data = Buffer.from(envelope.payload, 'base64');
|
|
44
|
+
if (data.toString('base64') !== envelope.payload) return null;
|
|
45
|
+
if (pin) {
|
|
46
|
+
const [signature] = envelope.signatures;
|
|
47
|
+
if (envelope.signatures.length !== 1 || !exactFields(signature, ['keyid', 'sig']) || signature.keyid !== pin.id
|
|
48
|
+
|| typeof signature.sig !== 'string' || signature.sig.length > 1500) return null;
|
|
49
|
+
const bytes = Buffer.from(signature.sig, 'base64');
|
|
50
|
+
if (bytes.toString('base64') !== signature.sig
|
|
51
|
+
|| !verify(algorithm(pin.key), pae(payloadType, data), pin.key, bytes)) return null;
|
|
52
|
+
} else if (envelope.signatures.length !== 0) return null;
|
|
53
|
+
const value = JSON.parse(data);
|
|
54
|
+
if (!isObject(value) || !Buffer.from(canonicalJson(value)).equals(data)) return null;
|
|
55
|
+
return { value, digest: sha256(data) };
|
|
56
|
+
} catch { return null; }
|
|
57
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { createPrivateKey } from 'node:crypto';
|
|
2
|
+
import { canonicalJson } from '../runtime/protocol.mjs';
|
|
3
|
+
import { keyPin, openDsse, signDsse } from './dsse.mjs';
|
|
4
|
+
|
|
5
|
+
export const NATIVE_RUNTIME_TYPE = 'application/vnd.osuite.native-runtime-call+json';
|
|
6
|
+
|
|
7
|
+
function runtimeClaims(orgId, agentId, actionId, marker) {
|
|
8
|
+
return {
|
|
9
|
+
schema_version: 'osuite.native_runtime_call.v1', org_id: orgId, agent_id: agentId, action_id: actionId,
|
|
10
|
+
input_digest: marker.input_digest, binding_digest: marker.binding_digest, operation_digest: marker.operation_digest,
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function signNativeRuntimeCall(config, { actionId, inputDigest, bindingDigest, operationDigest }) {
|
|
15
|
+
const signer = keyPin(createPrivateKey(Buffer.from(config.privateKeyBase64, 'base64')));
|
|
16
|
+
return signDsse(NATIVE_RUNTIME_TYPE, runtimeClaims(config.orgId, config.agentId, actionId, {
|
|
17
|
+
input_digest: inputDigest, binding_digest: bindingDigest, operation_digest: operationDigest,
|
|
18
|
+
}), signer);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function verifyNativeRuntimeCall(envelope, pin, { orgId, agentId, actionId, marker }) {
|
|
22
|
+
const opened = pin && openDsse(envelope, NATIVE_RUNTIME_TYPE, pin);
|
|
23
|
+
return Boolean(opened && canonicalJson(opened.value) === canonicalJson(runtimeClaims(orgId, agentId, actionId, marker)));
|
|
24
|
+
}
|
package/native-proof.mjs
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { canonicalJson, isObject, sha256 } from './runtime/protocol.mjs';
|
|
1
|
+
import { createPrivateKey, verify } from 'node:crypto';
|
|
2
|
+
import { canonicalJson, isObject, safeId, sha256 } from './runtime/protocol.mjs';
|
|
3
|
+
import { exactFields, keyPin, openDsse, publicKeyPin, signDsse } from './governed-tools/dsse.mjs';
|
|
4
|
+
import { verifyNativeRuntimeCall } from './governed-tools/native-evidence.mjs';
|
|
3
5
|
import { ownerClosureObservation, ownerReceiptKey, verifyOwnerClosure, verifyOwnerReceipt,
|
|
4
6
|
OWNER_CLOSURE_RECEIPT_SCHEMA } from './governed-tools/owner-receipt.mjs';
|
|
5
7
|
import { proofManifestPayload } from './governed-tools/proof-digest.mjs';
|
|
@@ -9,6 +11,13 @@ export { OWNER_CLOSURE_RECEIPT_SCHEMA, ownerReceiptPayload } from './governed-to
|
|
|
9
11
|
export const NATIVE_PROOF_TYPE = 'application/vnd.in-toto+json';
|
|
10
12
|
export const NATIVE_CHECKPOINT_TYPE = 'application/vnd.osuite.native-checkpoint+json';
|
|
11
13
|
export const NATIVE_CHECKPOINT_SCOPE = 'registered_native_tools';
|
|
14
|
+
export const NATIVE_RANGE_CHECKPOINT_TYPE = 'application/vnd.osuite.native-checkpoint.v2+json';
|
|
15
|
+
export const NATIVE_WITNESS_TYPE = 'application/vnd.osuite.witnessed-native-checkpoint.v1+json';
|
|
16
|
+
export const NATIVE_PACKAGE_SCHEMA = 'osuite.native_proof_package.v2';
|
|
17
|
+
export const NATIVE_RANGE_RECORD_SCHEMA = 'osuite.native_proof.v2';
|
|
18
|
+
export const NATIVE_RANGE_CHECKPOINT_SCHEMA = 'osuite.native_checkpoint.v2';
|
|
19
|
+
export const NATIVE_RANGE_PREDICATE = 'https://osuite.ai/attestations/native-tool/v2';
|
|
20
|
+
export const NATIVE_RANGE_LIMIT = 1000;
|
|
12
21
|
const hex = /^[0-9a-f]{64}$/;
|
|
13
22
|
const actionId = /^act_[0-9a-f]{64}$/;
|
|
14
23
|
const fail = code => ({ verified: false, code });
|
|
@@ -52,30 +61,14 @@ export function verifyNativeOwnerClosure(bundle, ownerPublicKey) {
|
|
|
52
61
|
resourceReference: receipt.claims.resource_reference };
|
|
53
62
|
}
|
|
54
63
|
|
|
55
|
-
|
|
56
|
-
return Buffer.concat([Buffer.from(`DSSEv1 ${Buffer.byteLength(type)} ${type} ${data.length} `), data]);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
export function signNativeEvidence(payloadType, value, signer) {
|
|
60
|
-
const payload = Buffer.from(canonicalJson(value));
|
|
61
|
-
return { payloadType, payload: payload.toString('base64'),
|
|
62
|
-
signatures: [{ keyid: signer.id, sig: sign(null, pae(payloadType, payload), signer.key).toString('base64') }] };
|
|
63
|
-
}
|
|
64
|
+
export { signDsse as signNativeEvidence };
|
|
64
65
|
|
|
65
|
-
function
|
|
66
|
-
if (
|
|
67
|
-
|
|
68
|
-
if (!
|
|
69
|
-
const { keyid, sig } =
|
|
70
|
-
|
|
71
|
-
try {
|
|
72
|
-
const data = Buffer.from(envelope.payload, 'base64'), signature = Buffer.from(sig, 'base64');
|
|
73
|
-
if (data.toString('base64') !== envelope.payload || signature.length !== 64 || signature.toString('base64') !== sig
|
|
74
|
-
|| !verify(null, pae(payloadType, data), pin.key, signature)) return null;
|
|
75
|
-
const value = JSON.parse(data);
|
|
76
|
-
if (!isObject(value) || !Buffer.from(canonicalJson(value)).equals(data)) return null;
|
|
77
|
-
return { value, digest: sha256(data) };
|
|
78
|
-
} catch { return null; }
|
|
66
|
+
function openLegacy(envelope, payloadType, pin) {
|
|
67
|
+
if (!pin) return null;
|
|
68
|
+
const { payload, signatures, payloadType: type } = envelope || {};
|
|
69
|
+
if (!Array.isArray(signatures) || signatures.length !== 1) return null;
|
|
70
|
+
const { keyid, sig } = signatures[0] || {};
|
|
71
|
+
return openDsse({ payloadType: type, payload, signatures: [{ keyid, sig }] }, payloadType, pin);
|
|
79
72
|
}
|
|
80
73
|
|
|
81
74
|
export function nativeProofRoot(entries) {
|
|
@@ -113,7 +106,7 @@ function validDelegation(predicate, issuers) {
|
|
|
113
106
|
export function verifyNativeProofCohort(records, roots, checkpoint) {
|
|
114
107
|
const proofKey = ownerReceiptKey(roots?.proof), checkpointKey = ownerReceiptKey(roots?.checkpoint);
|
|
115
108
|
if (!proofKey || !checkpointKey || proofKey.id === checkpointKey.id || !Array.isArray(roots.owners)) return fail('INVALID_TRUST_ROOTS');
|
|
116
|
-
const opened =
|
|
109
|
+
const opened = openLegacy(checkpoint, NATIVE_CHECKPOINT_TYPE, checkpointKey);
|
|
117
110
|
const scope = opened?.value;
|
|
118
111
|
const from = Date.parse(scope?.from), to = Date.parse(scope?.to);
|
|
119
112
|
if (scope?.schema_version !== 'osuite.native_checkpoint.v1' || scope.scope !== NATIVE_CHECKPOINT_SCOPE
|
|
@@ -124,7 +117,7 @@ export function verifyNativeProofCohort(records, roots, checkpoint) {
|
|
|
124
117
|
const seen = new Map();
|
|
125
118
|
const outcomes = { committed: 0, absent: 0, unknown: 0 };
|
|
126
119
|
for (const record of records) {
|
|
127
|
-
const decoded =
|
|
120
|
+
const decoded = openLegacy(record?.dsse_envelope, NATIVE_PROOF_TYPE, proofKey);
|
|
128
121
|
const statement = decoded?.value, p = statement?.predicate, subject = statement?.subject;
|
|
129
122
|
const created = Date.parse(p?.created_at);
|
|
130
123
|
if (!decoded || record.schema_version !== 'osuite.native_proof.v1' || decoded.digest !== record.payload_sha256
|
|
@@ -158,3 +151,161 @@ export function verifyNativeProofCohort(records, roots, checkpoint) {
|
|
|
158
151
|
if (nativeProofRoot(seen) !== scope.root) return fail('CHECKPOINT_MISMATCH');
|
|
159
152
|
return { verified: true, count: seen.size, outcomes };
|
|
160
153
|
}
|
|
154
|
+
|
|
155
|
+
export function validNativeRange(first, last) {
|
|
156
|
+
return Number.isSafeInteger(first) && Number.isSafeInteger(last) && first > 0 && last >= first && last - first < NATIVE_RANGE_LIMIT;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
function validRangeScope(scope) {
|
|
160
|
+
return exactFields(scope, ['org_id', 'log_id', 'first_position', 'last_position']) && safeId(scope.org_id)
|
|
161
|
+
&& typeof scope.log_id === 'string' && /^[a-f0-9]{8}(?:-[a-f0-9]{4}){3}-[a-f0-9]{12}$/.test(scope.log_id)
|
|
162
|
+
&& validNativeRange(scope.first_position, scope.last_position);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
export function nativeRangeHead(records, scope) {
|
|
166
|
+
let head = sha256(canonicalJson([NATIVE_RANGE_CHECKPOINT_SCHEMA, scope]));
|
|
167
|
+
for (const record of records) head = sha256(canonicalJson([head, sha256(canonicalJson(record))]));
|
|
168
|
+
return head;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
function openRangeCheckpoint(candidate, pin) {
|
|
172
|
+
const value = pin && openDsse(candidate, NATIVE_RANGE_CHECKPOINT_TYPE, pin)?.value;
|
|
173
|
+
if (!exactFields(value, ['schema_version', 'scope', 'count', 'head']) || value.schema_version !== NATIVE_RANGE_CHECKPOINT_SCHEMA
|
|
174
|
+
|| !validRangeScope(value.scope) || typeof value.head !== 'string' || !hex.test(value.head)
|
|
175
|
+
|| value.count !== value.scope.last_position - value.scope.first_position + 1) return null;
|
|
176
|
+
return value;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
function packageRecords(bundles) {
|
|
180
|
+
if (Array.isArray(bundles)) return bundles;
|
|
181
|
+
return exactFields(bundles, ['schema_version', 'records']) && bundles.schema_version === NATIVE_PACKAGE_SCHEMA
|
|
182
|
+
&& Array.isArray(bundles.records) ? bundles.records : null;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
export function witnessNativeCheckpoint(candidate, { bundles, checkpointPublicKey, witnessPrivateKey, scope } = {}) {
|
|
186
|
+
const authority = publicKeyPin(checkpointPublicKey, 'ed25519');
|
|
187
|
+
const checkpoint = openRangeCheckpoint(candidate, authority);
|
|
188
|
+
if (!checkpoint) throw new Error('INVALID_STUDIO_CHECKPOINT');
|
|
189
|
+
if (!validRangeScope(scope) || canonicalJson(scope) !== canonicalJson(checkpoint.scope)) throw new Error('CHECKPOINT_SCOPE_MISMATCH');
|
|
190
|
+
const records = packageRecords(bundles);
|
|
191
|
+
if (records?.length !== checkpoint.count || nativeRangeHead(records, scope) !== checkpoint.head) throw new Error('CHECKPOINT_HEAD_MISMATCH');
|
|
192
|
+
const key = witnessPrivateKey?.type === 'private' ? witnessPrivateKey : createPrivateKey(witnessPrivateKey);
|
|
193
|
+
if (key.asymmetricKeyType !== 'ed25519') throw new Error('INVALID_WITNESS_KEY');
|
|
194
|
+
const witness = keyPin(key);
|
|
195
|
+
if (authority.id === witness.id) throw new Error('WITNESS_MUST_USE_OWN_KEY');
|
|
196
|
+
return signDsse(NATIVE_WITNESS_TYPE, candidate, witness);
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
function checkRuntime(record, envelope, marker, roots) {
|
|
200
|
+
const signing = envelope.native_runtime_signing;
|
|
201
|
+
const status = signing?.status ?? 'missing';
|
|
202
|
+
if (record.runtime_signing !== status) return 'RUNTIME_SIGNING_STATUS_MISMATCH';
|
|
203
|
+
if (status === 'not_configured' && !signing.dsse_envelope) return 'RUNTIME_SIGNING_NOT_CONFIGURED';
|
|
204
|
+
const dsse = signing?.dsse_envelope;
|
|
205
|
+
if (!dsse?.signatures?.length) return 'RUNTIME_SIGNATURE_MISSING';
|
|
206
|
+
const pins = (roots?.runtimes || []).filter(root => root?.agent_id === envelope.agent_id)
|
|
207
|
+
.map(root => publicKeyPin(root.public_key, 'rsa')).filter(pin => pin?.id === dsse.signatures[0]?.keyid);
|
|
208
|
+
const scope = { orgId: envelope.org_id, agentId: envelope.agent_id, actionId: envelope.action_id, marker };
|
|
209
|
+
if (status !== 'signed' || pins.length !== 1 || !verifyNativeRuntimeCall(dsse, pins[0], scope)) return 'INVALID_RUNTIME_SIGNATURE';
|
|
210
|
+
return null;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
function checkOwner(proof, predicate, roots, authorityIds) {
|
|
214
|
+
if (!proof.outcome?.native_owner_receipt || !proof.outcome?.native_owner_closure) return fail('OWNER_CLOSURE_MISSING');
|
|
215
|
+
const { native_resource: resource, business_authority: businessAuthority } = proof.action_envelope;
|
|
216
|
+
const owners = (roots?.owners || []).filter(root => root?.resource_id === resource?.resource_id
|
|
217
|
+
&& ownerReceiptKey(root.public_key)?.id === resource?.key_id);
|
|
218
|
+
if (!resource?.key_id || owners.length !== 1 || authorityIds.includes(resource.key_id)) return fail('INVALID_OWNER_KEY');
|
|
219
|
+
const observation = proof.outcome.native_owner_closure.original;
|
|
220
|
+
const outcome = verifyNativeOwnerClosure(proof, owners[0].public_key);
|
|
221
|
+
if (!outcome.verified) return outcome;
|
|
222
|
+
if (canonicalJson(observation) !== canonicalJson(predicate.observation)) return fail('OWNER_CLOSURE_PROOF_MISMATCH');
|
|
223
|
+
if (!validDelegation({ ...predicate, timestamp_start: observation.timestamp_start, business_authority: businessAuthority,
|
|
224
|
+
approval_receipts: proof.approval_receipts }, roots.issuers)) return fail('INVALID_DELEGATION');
|
|
225
|
+
return outcome;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
function checkRecord(record, proofPin, roots, authorityIds) {
|
|
229
|
+
const reasons = [];
|
|
230
|
+
const failRecord = code => ({ reasons: [...reasons, code], outcome: 'unknown' });
|
|
231
|
+
if (!exactFields(record, ['schema_version', 'payload_sha256', 'proof_signing', 'runtime_signing', 'dsse_envelope'])
|
|
232
|
+
|| record.schema_version !== NATIVE_RANGE_RECORD_SCHEMA) return failRecord('INVALID_RECORD');
|
|
233
|
+
const unsigned = record.proof_signing === 'not_configured';
|
|
234
|
+
const envelope = record.dsse_envelope;
|
|
235
|
+
if (unsigned) reasons.push('PROOF_SIGNING_NOT_CONFIGURED');
|
|
236
|
+
else if (!envelope?.signatures?.length) reasons.push('PROOF_SIGNATURE_MISSING');
|
|
237
|
+
const opened = unsigned ? openDsse(envelope, NATIVE_PROOF_TYPE) : proofPin && openDsse(envelope, NATIVE_PROOF_TYPE, proofPin);
|
|
238
|
+
if (!opened || (!unsigned && record.proof_signing !== 'signed')) {
|
|
239
|
+
return reasons.length ? { reasons, outcome: 'unknown' } : failRecord('INVALID_PROOF_SIGNATURE');
|
|
240
|
+
}
|
|
241
|
+
const statement = opened.value;
|
|
242
|
+
const p = statement.predicate;
|
|
243
|
+
const proof = p?.proof_bundle;
|
|
244
|
+
const action = proof?.action_envelope;
|
|
245
|
+
let marker;
|
|
246
|
+
try { marker = JSON.parse(action?.input_summary)?.osuite_native_call; } catch { return failRecord('INVALID_RECORD_BINDING'); }
|
|
247
|
+
if (opened.digest !== record.payload_sha256 || statement._type !== 'https://in-toto.io/Statement/v1'
|
|
248
|
+
|| statement.predicateType !== NATIVE_RANGE_PREDICATE || proof.schema_version !== 'osuite.proof_bundle.v1'
|
|
249
|
+
|| proof.derived_from_legacy || action.runtime_family !== 'sdk_tool_runtime' || action.adapter_mode !== 'sdk_wrapper'
|
|
250
|
+
|| !actionId.test(p.action_id || '') || !safeId(p.agent_id) || !safeId(p.org_id)
|
|
251
|
+
|| action.action_id !== p.action_id || action.agent_id !== p.agent_id || action.org_id !== p.org_id
|
|
252
|
+
|| marker?.schema_version !== 'osuite.native_tool_call.v1'
|
|
253
|
+
|| ![marker.input_digest, marker.binding_digest, marker.operation_digest].every(value => typeof value === 'string' && hex.test(value))
|
|
254
|
+
|| !Array.isArray(statement.subject) || statement.subject.length !== 1 || statement.subject[0]?.name !== p.action_id
|
|
255
|
+
|| proof.manifest?.digest !== proofDigest(proofManifestPayload(proof))
|
|
256
|
+
|| `sha256:${statement.subject[0]?.digest?.sha256}` !== proof.manifest.digest) return failRecord('INVALID_RECORD_BINDING');
|
|
257
|
+
const runtime = checkRuntime(record, action, marker, roots);
|
|
258
|
+
if (runtime) reasons.push(runtime);
|
|
259
|
+
const owner = checkOwner(proof, { ...p, input_digest: marker.input_digest }, roots, authorityIds);
|
|
260
|
+
if (!owner.verified) reasons.push(owner.code);
|
|
261
|
+
return { action_id: p.action_id, org_id: p.org_id, log_id: p.log_id, position: p.position, reasons,
|
|
262
|
+
outcome: owner.outcome ?? 'unknown' };
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
export function verifyNativeProofPackage({ bundles, roots, checkpoint, witnessPublicKey, scope: expectedScope } = {}) {
|
|
266
|
+
const reasons = [];
|
|
267
|
+
const proofPin = publicKeyPin(roots?.proof, 'ed25519');
|
|
268
|
+
const checkpointPin = publicKeyPin(roots?.checkpoint, 'ed25519');
|
|
269
|
+
const witnessPin = publicKeyPin(witnessPublicKey, 'ed25519');
|
|
270
|
+
const authorityIds = [proofPin?.id, checkpointPin?.id, witnessPin?.id];
|
|
271
|
+
const validRoots = new Set(authorityIds).size === 3 && authorityIds.every(Boolean)
|
|
272
|
+
&& Array.isArray(roots?.runtimes) && Array.isArray(roots?.owners);
|
|
273
|
+
if (!validRoots) reasons.push('INVALID_TRUST_ROOTS');
|
|
274
|
+
const witnessed = witnessPin && openDsse(checkpoint, NATIVE_WITNESS_TYPE, witnessPin);
|
|
275
|
+
if (!witnessed) reasons.push('INVALID_WITNESS_SIGNATURE');
|
|
276
|
+
const claim = witnessed && openRangeCheckpoint(witnessed.value, checkpointPin);
|
|
277
|
+
if (witnessed && !claim) reasons.push('INVALID_STUDIO_CHECKPOINT');
|
|
278
|
+
const scope = claim?.scope ?? null;
|
|
279
|
+
if (scope && expectedScope !== undefined && (!validRangeScope(expectedScope) || canonicalJson(scope) !== canonicalJson(expectedScope))) {
|
|
280
|
+
reasons.push('CHECKPOINT_SCOPE_MISMATCH');
|
|
281
|
+
}
|
|
282
|
+
const records = packageRecords(bundles);
|
|
283
|
+
if (!records || records.length > NATIVE_RANGE_LIMIT) {
|
|
284
|
+
return { verified: false, scope, reasons: [...reasons, 'INVALID_PACKAGE'], count: 0, records: [] };
|
|
285
|
+
}
|
|
286
|
+
if (claim) {
|
|
287
|
+
if (records.length !== claim.count) reasons.push('INCOMPLETE_RANGE');
|
|
288
|
+
try {
|
|
289
|
+
if (nativeRangeHead(records, scope) !== claim.head) reasons.push('CHECKPOINT_HEAD_MISMATCH');
|
|
290
|
+
} catch { reasons.push('INVALID_PACKAGE'); }
|
|
291
|
+
}
|
|
292
|
+
const seen = new Set();
|
|
293
|
+
const outcomes = { committed: 0, absent: 0, unknown: 0 };
|
|
294
|
+
const results = Array.from(records, (record, index) => {
|
|
295
|
+
let result;
|
|
296
|
+
try { result = checkRecord(record, proofPin, roots, authorityIds); }
|
|
297
|
+
catch { result = { reasons: ['INVALID_RECORD'], outcome: 'unknown' }; }
|
|
298
|
+
const { action_id, org_id, log_id, position, outcome, reasons: issues } = result;
|
|
299
|
+
if (action_id) {
|
|
300
|
+
if (seen.has(action_id)) issues.push('DUPLICATE_RECORD');
|
|
301
|
+
seen.add(action_id);
|
|
302
|
+
if (scope && (org_id !== scope.org_id || log_id !== scope.log_id || !Number.isSafeInteger(position)
|
|
303
|
+
|| position < scope.first_position || position > scope.last_position)) issues.push('RECORD_OUTSIDE_CHECKPOINT');
|
|
304
|
+
else if (scope && position !== scope.first_position + index) issues.push('RECORD_OUT_OF_ORDER');
|
|
305
|
+
}
|
|
306
|
+
outcomes[outcome]++;
|
|
307
|
+
return { index, position: position ?? null, action_id: action_id ?? null, outcome, verified: issues.length === 0, reasons: issues };
|
|
308
|
+
});
|
|
309
|
+
if (results.some(record => !record.verified)) reasons.push('RECORD_VERIFICATION_FAILED');
|
|
310
|
+
return { verified: reasons.length === 0, scope, reasons, count: records.length, outcomes, records: results };
|
|
311
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "osuite",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.19.0",
|
|
4
4
|
"description": "OSuite governed action SDK for AI agents. Approve, replay, prove, and verify runtime decisions.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"publishConfig": {
|
|
@@ -35,6 +35,7 @@
|
|
|
35
35
|
},
|
|
36
36
|
"files": [
|
|
37
37
|
"cli.js",
|
|
38
|
+
"checkpointCli.mjs",
|
|
38
39
|
"onboardingCli.js",
|
|
39
40
|
"credentials.js",
|
|
40
41
|
"installationIdentity.js",
|