@nexart/ai-execution 0.3.0 → 0.4.1
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 +44 -9
- package/dist/index.cjs +696 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +56 -0
- package/dist/index.d.ts +55 -11
- package/dist/index.mjs +638 -0
- package/dist/index.mjs.map +1 -0
- package/dist/providers/anthropic.cjs +258 -0
- package/dist/providers/anthropic.cjs.map +1 -0
- package/dist/providers/anthropic.d.cts +24 -0
- package/dist/providers/anthropic.d.ts +7 -5
- package/dist/providers/anthropic.mjs +221 -0
- package/dist/providers/anthropic.mjs.map +1 -0
- package/dist/providers/openai.cjs +259 -0
- package/dist/providers/openai.cjs.map +1 -0
- package/dist/providers/openai.d.cts +24 -0
- package/dist/providers/openai.d.ts +7 -5
- package/dist/providers/openai.mjs +222 -0
- package/dist/providers/openai.mjs.map +1 -0
- package/dist/providers/wrap.cjs +221 -0
- package/dist/providers/wrap.cjs.map +1 -0
- package/dist/providers/wrap.d.cts +9 -0
- package/dist/providers/wrap.d.ts +5 -3
- package/dist/providers/wrap.mjs +186 -0
- package/dist/providers/wrap.mjs.map +1 -0
- package/dist/{types.d.ts → types-342Snbrb.d.cts} +31 -16
- package/dist/types-342Snbrb.d.ts +169 -0
- package/package.json +18 -11
- package/dist/archive.d.ts +0 -4
- package/dist/archive.d.ts.map +0 -1
- package/dist/archive.js +0 -28
- package/dist/archive.js.map +0 -1
- package/dist/attest.d.ts +0 -3
- package/dist/attest.d.ts.map +0 -1
- package/dist/attest.js +0 -79
- package/dist/attest.js.map +0 -1
- package/dist/canonicalJson.d.ts +0 -2
- package/dist/canonicalJson.d.ts.map +0 -1
- package/dist/canonicalJson.js +0 -38
- package/dist/canonicalJson.js.map +0 -1
- package/dist/cer.d.ts +0 -7
- package/dist/cer.d.ts.map +0 -1
- package/dist/cer.js +0 -61
- package/dist/cer.js.map +0 -1
- package/dist/certify.d.ts +0 -3
- package/dist/certify.d.ts.map +0 -1
- package/dist/certify.js +0 -27
- package/dist/certify.js.map +0 -1
- package/dist/errors.d.ts +0 -11
- package/dist/errors.d.ts.map +0 -1
- package/dist/errors.js +0 -21
- package/dist/errors.js.map +0 -1
- package/dist/hash.d.ts +0 -6
- package/dist/hash.d.ts.map +0 -1
- package/dist/hash.js +0 -32
- package/dist/hash.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -11
- package/dist/index.js.map +0 -1
- package/dist/providers/anthropic.d.ts.map +0 -1
- package/dist/providers/anthropic.js +0 -61
- package/dist/providers/anthropic.js.map +0 -1
- package/dist/providers/openai.d.ts.map +0 -1
- package/dist/providers/openai.js +0 -62
- package/dist/providers/openai.js.map +0 -1
- package/dist/providers/wrap.d.ts.map +0 -1
- package/dist/providers/wrap.js +0 -28
- package/dist/providers/wrap.js.map +0 -1
- package/dist/run.d.ts +0 -14
- package/dist/run.d.ts.map +0 -1
- package/dist/run.js +0 -62
- package/dist/run.js.map +0 -1
- package/dist/snapshot.d.ts +0 -4
- package/dist/snapshot.d.ts.map +0 -1
- package/dist/snapshot.js +0 -113
- package/dist/snapshot.js.map +0 -1
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -2
- package/dist/types.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
# @nexart/ai-execution v0.
|
|
1
|
+
# @nexart/ai-execution v0.4.1
|
|
2
2
|
|
|
3
3
|
Tamper-evident records and Certified Execution Records (CER) for AI operations.
|
|
4
4
|
|
|
5
5
|
## Why Not Just Store Logs?
|
|
6
6
|
|
|
7
|
-
Logs tell you what happened. CERs prove
|
|
7
|
+
Logs tell you what happened. CERs prove integrity. A log entry can be edited, truncated, or fabricated after the fact with no way to detect it. A CER bundle is cryptographically sealed: any modification — to the input, output, parameters, or ordering — invalidates the certificate hash. If you need to demonstrate to an auditor, regulator, or downstream system that a recorded execution has not been modified post-hoc, logs are insufficient. CERs provide the tamper-evident chain of custody that logs cannot. **CERs certify records, not model determinism or provider execution.**
|
|
8
8
|
|
|
9
9
|
## What This Does
|
|
10
10
|
|
|
@@ -15,13 +15,13 @@ This package creates integrity records for AI executions. Every time you call an
|
|
|
15
15
|
- The exact parameters used (temperature, model, etc.)
|
|
16
16
|
- SHA-256 hashes of everything for tamper detection
|
|
17
17
|
|
|
18
|
-
These records can be verified offline to prove
|
|
18
|
+
These records can be verified offline to detect any post-hoc modification and prove integrity of the recorded execution.
|
|
19
19
|
|
|
20
|
-
**Important:** This does NOT promise that an AI model will produce the same output twice. LLMs are not deterministic. This package provides **integrity and auditability** — proof that
|
|
20
|
+
**Important:** This does NOT promise that an AI model will produce the same output twice, and it does not verify provider or model identity. LLMs are not deterministic. This package provides **integrity and auditability** — proof that the recorded input, output, and parameters have not been modified, and chain-of-custody for the execution record.
|
|
21
21
|
|
|
22
22
|
## Compatibility Guarantees
|
|
23
23
|
|
|
24
|
-
- **v0.1.0 and v0.
|
|
24
|
+
- **v0.1.0, v0.2.0, and v0.3.0 bundles verify forever.** Any CER bundle produced by any prior version will pass `verify()` in v0.4.1 and all future versions.
|
|
25
25
|
- **Hashing rules are frozen for `cer.ai.execution.v1`.** The canonicalization, SHA-256 computation, and certificate hash inputs (bundleType, version, createdAt, snapshot) are unchanged.
|
|
26
26
|
- **New optional snapshot fields** (runId, stepId, stepIndex, etc.) default to undefined and are excluded from legacy snapshots. They participate in the certificate hash only when present.
|
|
27
27
|
- **Canonicalization is frozen for v1.** Number-to-string conversion uses `JSON.stringify()`, which is consistent across JavaScript engines but does not implement RFC 8785 (JCS) for edge cases like `-0`. If stricter canonicalization is required, it will ship as a new bundle type (`cer.ai.execution.v2`), never as a modification to v1.
|
|
@@ -139,7 +139,7 @@ const restored = importCer(json); // parse + verify (throws on tamper)
|
|
|
139
139
|
| `modelVersion` | Optional | `string \| null` | Defaults to `null` |
|
|
140
140
|
| `parameters.topP` | Optional | `number \| null` | Defaults to `null` |
|
|
141
141
|
| `parameters.seed` | Optional | `number \| null` | Defaults to `null` |
|
|
142
|
-
| `sdkVersion` | Optional | `string \| null` | Defaults to `"0.
|
|
142
|
+
| `sdkVersion` | Optional | `string \| null` | Defaults to `"0.4.1"` |
|
|
143
143
|
| `appId` | Optional | `string \| null` | Defaults to `null` |
|
|
144
144
|
| `runId` | Optional | `string \| null` | Workflow run ID |
|
|
145
145
|
| `stepId` | Optional | `string \| null` | Step identifier within a run |
|
|
@@ -172,7 +172,7 @@ The `certificateHash` is SHA-256 of the UTF-8 bytes of the canonical JSON of exa
|
|
|
172
172
|
Endpoint: `POST {nodeUrl}/api/attest`
|
|
173
173
|
|
|
174
174
|
- Authorization: `Bearer {apiKey}`
|
|
175
|
-
- Body: the full CER bundle as JSON
|
|
175
|
+
- Body: the full CER bundle as JSON (auto-sanitized via `sanitizeForAttestation` in v0.4.0+)
|
|
176
176
|
- Returns: `AttestationResult` with `attestationId`, `nodeRuntimeHash`, `certificateHash`, `protocolVersion`
|
|
177
177
|
- Default timeout: 10 seconds (configurable via `timeoutMs`)
|
|
178
178
|
- Validates: response `certificateHash` matches submitted bundle; all hashes in `sha256:<64hex>` format
|
|
@@ -180,6 +180,17 @@ Endpoint: `POST {nodeUrl}/api/attest`
|
|
|
180
180
|
|
|
181
181
|
Attestation verifies internal integrity only. It does not re-run the model or validate the correctness of the AI output.
|
|
182
182
|
|
|
183
|
+
### Sanitization and Redaction
|
|
184
|
+
|
|
185
|
+
`sanitizeForAttestation(bundle)` returns a JSON-safe deep clone:
|
|
186
|
+
- Removes keys with `undefined` values at all nesting levels
|
|
187
|
+
- Rejects `BigInt`, functions, and symbols (throws)
|
|
188
|
+
- Safe to serialize with `JSON.stringify` or canonical JSON
|
|
189
|
+
|
|
190
|
+
**Recommended redaction pattern:** delete keys or set them to `null` — never set to `undefined`, which is not valid JSON. Call `sanitizeForAttestation` before archiving or attesting if your bundle may contain `undefined` values.
|
|
191
|
+
|
|
192
|
+
**Skip re-attestation:** use `hasAttestation(bundle)` to check if a bundle already includes attestation fields before calling `attest()` again.
|
|
193
|
+
|
|
183
194
|
## Canonical JSON Constraints
|
|
184
195
|
|
|
185
196
|
1. Object keys sorted lexicographically (Unicode codepoint order) at every nesting level.
|
|
@@ -226,10 +237,32 @@ Fixtures at `fixtures/vectors/` and `fixtures/golden/`. Cross-language implement
|
|
|
226
237
|
|
|
227
238
|
| Function | Description |
|
|
228
239
|
|---|---|
|
|
229
|
-
| `attest(bundle, options)` | Post CER to canonical node |
|
|
240
|
+
| `attest(bundle, options)` | Post CER to canonical node (auto-sanitizes) |
|
|
241
|
+
| `sanitizeForAttestation(bundle)` | Remove `undefined` keys, reject BigInt/functions/symbols |
|
|
242
|
+
| `hasAttestation(bundle)` | Check if bundle already has attestation fields |
|
|
230
243
|
| `exportCer(bundle)` | Serialize to canonical JSON string |
|
|
231
244
|
| `importCer(json)` | Parse + verify from JSON string |
|
|
232
245
|
|
|
246
|
+
### Reason Codes
|
|
247
|
+
|
|
248
|
+
`CerVerifyCode` — stable string-union constant exported from the package root:
|
|
249
|
+
|
|
250
|
+
| Code | When set |
|
|
251
|
+
|---|---|
|
|
252
|
+
| `OK` | Verification passed |
|
|
253
|
+
| `CERTIFICATE_HASH_MISMATCH` | `certificateHash` doesn't match recomputed hash |
|
|
254
|
+
| `INPUT_HASH_MISMATCH` | `inputHash` doesn't match recomputed hash |
|
|
255
|
+
| `OUTPUT_HASH_MISMATCH` | `outputHash` doesn't match recomputed hash |
|
|
256
|
+
| `SNAPSHOT_HASH_MISMATCH` | Both `inputHash` and `outputHash` are wrong |
|
|
257
|
+
| `INVALID_SHA256_FORMAT` | A hash field doesn't start with `sha256:` |
|
|
258
|
+
| `SCHEMA_ERROR` | Wrong bundleType/version, missing snapshot, non-finite parameters, etc. |
|
|
259
|
+
| `CANONICALIZATION_ERROR` | `toCanonicalJson` threw during verification |
|
|
260
|
+
| `UNKNOWN_ERROR` | Catch-all for unclassified failures |
|
|
261
|
+
|
|
262
|
+
Priority when multiple failures exist: `CANONICALIZATION_ERROR` > `SCHEMA_ERROR` > `INVALID_SHA256_FORMAT` > `CERTIFICATE_HASH_MISMATCH` > `INPUT_HASH_MISMATCH` > `OUTPUT_HASH_MISMATCH` > `SNAPSHOT_HASH_MISMATCH` > `UNKNOWN_ERROR`.
|
|
263
|
+
|
|
264
|
+
**These codes are stable across all future versions.** New codes may be added but existing codes will not be renamed or removed.
|
|
265
|
+
|
|
233
266
|
### Providers (sub-exports)
|
|
234
267
|
|
|
235
268
|
| Function | Export path |
|
|
@@ -244,7 +277,9 @@ Fixtures at `fixtures/vectors/` and `fixtures/golden/`. Cross-language implement
|
|
|
244
277
|
|---|---|
|
|
245
278
|
| v0.1.0 | Core snapshot + CER + verify + OpenAI adapter |
|
|
246
279
|
| v0.2.0 | certifyDecision, RunBuilder, attest, archive, Anthropic, wrapProvider, typed errors, workflow fields |
|
|
247
|
-
|
|
|
280
|
+
| v0.3.0 | Attestation hardening (hash validation, timeout), `verify` alias, `CerAttestationError.details`, release hygiene |
|
|
281
|
+
| v0.4.0 | Dual ESM/CJS build, `sanitizeForAttestation`, `hasAttestation`, auto-sanitize in `attest()`, fixed `ERR_PACKAGE_PATH_NOT_EXPORTED` |
|
|
282
|
+
| **v0.4.1** | Verification reason codes (`CerVerifyCode`), `code` + `details` on `VerificationResult`, README provenance wording tightened |
|
|
248
283
|
| v1.0.0 | Planned: API stabilization, freeze public API surface |
|
|
249
284
|
|
|
250
285
|
## Releasing
|