@zhivex-ai/harness 0.8.0 → 0.9.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/CHANGELOG.md CHANGED
@@ -4,6 +4,38 @@ All notable changes to Zhivex Harness are documented in this file.
4
4
 
5
5
  The project follows Semantic Versioning. During `0.x`, minor releases may change user-facing contracts when the change is documented with a migration note. Patch releases remain backwards compatible bug fixes.
6
6
 
7
+ ## 0.9.0 - 2026-08-20
8
+
9
+ ### Added
10
+
11
+ - `ChangeEnvelope v1`, a deterministic, agent-agnostic and offline-verifiable change-admission document that binds base/tree identity, exact patch bytes, harness/policy/environment fingerprints, redacted check evidence, expiry, approval references, and optional external attestation references.
12
+ - `zhx changes create` and `zhx changes verify` for binding an exact patch artifact and validating integrity, expiry, and caller-supplied preconditions without loading a provider or contacting a network service.
13
+ - Bounded `read_files` and `search_many` tools so independent repository lookups share one model/tool round trip and multi-query search reads each candidate file once.
14
+ - A reproducible `bun run benchmark:workspace` fixture plus workspace-index and OCI I/O diagnostics.
15
+ - A reproducible `bun run benchmark:oci` fixture for first-command, warm no-op, mutation, and snapshot latency.
16
+
17
+ ### Changed
18
+
19
+ - Workspace pagination now reuses a topology-only, freshness-checked index with binary path lookup. File contents and digests are still read through the race-sensitive stable-read path; structural changes invalidate active cursors.
20
+ - OCI snapshots retain metadata rather than the full repository contents in memory, write the immutable base once, and use copy-on-write cloning with a portable copy fallback for the mutable workspace. Patch inspection rereads content only for changed files.
21
+ - OCI commands now reuse one paused container per acquired run. Unchanged canonical workspace seals skip export, changed workspaces still publish through a validated atomic staging directory, and failures, background processes, or host-snapshot divergence destroy and reseed the warm session.
22
+
23
+ ### Performance
24
+
25
+ - On the local 5,000-file benchmark, listing all 25 pages of 200 files decreased from about 3.02 seconds to 0.38 seconds, and the first page decreased from about 118 ms to 42 ms. These figures are development-machine observations, not cross-platform release guarantees.
26
+ - On the local 1,001-file Docker benchmark, warm no-op OCI commands decreased from about 838 ms to roughly 0.31–0.37 seconds median. Commands that change the workspace retain the full validation/export path. These figures are development-machine observations, not cross-platform release guarantees.
27
+
28
+ ### Migration from 0.8.x
29
+
30
+ - Complete or deny paused `0.8.x` approvals with the matching `0.8.x` artifact. The workspace tool contract fingerprint changed to include the new batch tools, so `0.9.x` intentionally refuses to resume those approvals under a different tool surface.
31
+ - Configuration schema `4`, the durable store, existing single-file tools, and both CLI executable aliases remain compatible. The OCI policy fingerprint advances because isolation changes from per-tool-call containers to a paused per-run container; complete or deny paused OCI approvals with the matching older artifact. Callers can adopt `read_files`, `search_many`, and change envelopes incrementally.
32
+
33
+ ### Security
34
+
35
+ - Change-envelope verification proves canonical integrity, rejects future creation/check evidence, enforces expiration, exact patch binding, and explicit preconditions only. Approval and external-attestation authenticity is reported as `not-verified` and requires an external trust verifier.
36
+ - The workspace index never caches file contents or content digests. It validates directory and ignore-rule fingerprints before reuse, rejects stale topology-bound cursors, and invalidates after every harness mutation and declared check.
37
+ - Warm OCI reuse never mounts the durable host snapshot writable. Commands are serialized; background processes fail closed; `/tmp` is cleared after success; and any failed or divergent session is destroyed before a later command reseeds from the last published snapshot.
38
+
7
39
  ## 0.8.0 - 2026-08-20
8
40
 
9
41
  ### Changed
package/README.md CHANGED
@@ -13,7 +13,7 @@ Zhivex Harness runs coding agents against real repositories with conflict-safe e
13
13
 
14
14
  The model provides capability. The harness controls what it may inspect, execute, change, resume, and prove. Every provider uses the same bounded tool and approval contract.
15
15
 
16
- Version `0.8.0` is the source release candidate for the coordinated SDK refresh and GPT-5.6-first OpenAI integration. The latest public npm release is `0.7.0`; local validation does not imply that `0.8.0` has been published or release-certified. See [ROADMAP.md](./ROADMAP.md), [CHANGELOG.md](./CHANGELOG.md), the [CLI contract](./docs/CLI.md), the [extensibility guide](./docs/EXTENSIBILITY.md), and the [durable-operations guide](./docs/DURABLE_OPERATIONS.md).
16
+ Version `0.9.0` is the source candidate for faster governed repository inspection and the agent-agnostic `ChangeEnvelope v1` admission contract. The latest public npm release is `0.8.0`; local validation does not imply that `0.9.0` has been published or release-certified. See [ROADMAP.md](./ROADMAP.md), [CHANGELOG.md](./CHANGELOG.md), the [change-envelope guide](./docs/CHANGE_ENVELOPES.md), the [CLI contract](./docs/CLI.md), the [extensibility guide](./docs/EXTENSIBILITY.md), and the [durable-operations guide](./docs/DURABLE_OPERATIONS.md).
17
17
 
18
18
  ## Why Zhivex Harness
19
19
 
@@ -40,7 +40,15 @@ bun run demo:hostile
40
40
 
41
41
  The expected result is a schema-versioned JSON proof with `secretExcluded`, `networkDenied`, `exactlyOnceJournal`, and `staleHostImportBlocked` all set to `true`. Pass `--keep` to retain the disposable workspace for inspection. The complete scenario and evidence limits are documented in [docs/HOSTILE_REPOSITORY_DEMO.md](./docs/HOSTILE_REPOSITORY_DEMO.md).
42
42
 
43
- ## What 0.8 changes
43
+ ## What 0.9 changes
44
+
45
+ - reuses a freshness-checked topology index across file-list and search pages while reading current file bytes for every digest;
46
+ - adds bounded `read_files` and `search_many` tools that reduce model/tool round trips without parallelizing writes;
47
+ - reuses a paused OCI container within an acquired run, skips exports for unchanged workspace seals, and reseeds after failures or host-snapshot changes without weakening the reviewed host-import boundary;
48
+ - adds a reproducible workspace benchmark and observable index/OCI I/O counters; and
49
+ - introduces deterministic, offline-verifiable `ChangeEnvelope v1` documents bound to exact patch bytes, base identity, runtime policy, redacted checks, expiry, and optional approval/attestation references.
50
+
51
+ ## What 0.8 changed
44
52
 
45
53
  - updates the coordinated Zhivex SDK batch while retaining a single Core runtime identity;
46
54
  - makes `gpt-5.6-luna` the OpenAI default, with Terra and Sol available through explicit model selection; and
@@ -68,7 +76,7 @@ The expected result is a schema-versioned JSON proof with `secretExcluded`, `net
68
76
  - governed MCP over bounded HTTPS/loopback HTTP with explicit server/tool allowlists, permissions, timeouts, approvals, output limits, and environment-backed credentials;
69
77
  - named explorer, implementer, tester, and reviewer subagents with independent durable budgets and promoted approvals;
70
78
  - deterministic application-owned parallel read-only review groups with child progress, hierarchy, usage, and cost evidence;
71
- - optional enforced Docker/Podman execution with no container network, a read-only root filesystem, non-root execution, dropped capabilities, bounded CPU/memory/PIDs/time/output, and an ephemeral secret-free workspace snapshot;
79
+ - optional enforced Docker/Podman execution with a paused per-run container, no container network, a read-only root filesystem, non-root execution, dropped capabilities, bounded CPU/memory/PIDs/time/output, and an ephemeral secret-free workspace snapshot;
72
80
  - argv-only allowlisted environment commands, isolated package checks, deterministic patch inspection, and a separate durable approval before importing changes into the host workspace;
73
81
  - environment/image/policy fingerprint binding, cancellation cleanup, labeled orphan cleanup, retained audit artifacts, and installed-package plus real-runtime smoke gates;
74
82
  - protection against path traversal, symlink escapes, unsafe state targets, secret-file reads, special files, concurrent non-overwrite races, and unbounded output;
@@ -90,7 +98,7 @@ bun add @zhivex-ai/harness
90
98
  bunx --package @zhivex-ai/harness zhx --version
91
99
  ```
92
100
 
93
- To exercise the `0.8.0` source checkout:
101
+ To exercise the `0.9.0` source checkout:
94
102
 
95
103
  ```bash
96
104
  bun install --frozen-lockfile
@@ -169,7 +177,7 @@ zhx run --provider openai --route explorer=qwen --route reviewer=gemini \
169
177
  "implement the change, then review it independently"
170
178
  ```
171
179
 
172
- Routing with `--max-cost-usd` is rejected in `0.8.0`: aggregate usage cannot yet be priced correctly when roles use different models.
180
+ Routing with `--max-cost-usd` remains rejected in `0.9.0`: aggregate usage cannot yet be priced correctly when roles use different models.
173
181
 
174
182
  Writes and checks pause for approval. In a non-interactive execution, state is saved in `.zhivex-harness/runs/operations.sqlite`:
175
183
 
@@ -221,6 +229,15 @@ zhx run --provider gemini --jsonl "analyze the issue without modifying files"
221
229
 
222
230
  The JSON shapes and exit codes are documented in [docs/CLI.md](./docs/CLI.md).
223
231
 
232
+ Create a portable change-admission envelope from structured, redacted evidence and the exact patch bytes, then verify it without provider credentials or network access:
233
+
234
+ ```bash
235
+ zhx changes create examples/change-envelope-input.json --patch examples/change.patch > change-envelope.json
236
+ zhx changes verify change-envelope.json --patch examples/change.patch
237
+ ```
238
+
239
+ The verifier proves integrity, expiry, and explicit preconditions; it deliberately reports approval and external-attestation authenticity as `not-verified`. See [docs/CHANGE_ENVELOPES.md](./docs/CHANGE_ENVELOPES.md).
240
+
224
241
  Repository edits use digest-bound proposals. Discovery returns `nextCursor` when another deterministic page is available; mutating tools reject stale content instead of merging or overwriting it. Deletions move files into harness-owned quarantine and return a recovery identifier. The complete contract and migration from `0.2.x` are documented in [docs/REPOSITORY_EDITING.md](./docs/REPOSITORY_EDITING.md).
225
242
 
226
243
  The default check allowlist is `test`, `typecheck`, `lint`, and `build`. Replace it with repeatable CLI flags when a repository uses different declared scripts:
@@ -250,7 +267,7 @@ zhivex-harness run --execution oci --yes "inspect, implement, test, review the e
250
267
 
251
268
  Override any model with `--model`. Optional provider overrides are `META_BASE_URL`, `QWEN_BASE_URL`, `QWEN_WORKSPACE_ID`, `QWEN_REGION`, `OPENAI_BASE_URL`, and `GEMINI_BASE_URL`. Non-credential transport settings are hash-bound to durable resumes without persisting their values.
252
269
 
253
- Meta and Qwen retain the published support conclusion for the unchanged approval/restart, delegation/persistence, and enforced-execution paths. OpenAI is GPT-5.6-first in `0.8.0`: Luna is the default, while Terra and Sol remain explicit `--model` selections. All three passed the local base approval/restart gate, but delegation, OCI execution, and release-artifact certification still require the release-candidate matrix. Controlled and official-SDK MCP interoperability are verified separately and do not imply compatibility with every server or protocol feature. Provider capability claims remain artifact- and date-bound under the [live certification contract](./docs/LIVE_CERTIFICATION.md); credential detection and deterministic tests do not replace real provider evidence.
270
+ Meta and Qwen retain the published support conclusion for the unchanged approval/restart, delegation/persistence, and enforced-execution paths. OpenAI remains GPT-5.6-first from `0.8.0`: Luna is the default, while Terra and Sol remain explicit `--model` selections. All three passed the local base approval/restart gate, but delegation, OCI execution, and `0.9.0` release-artifact certification still require the release-candidate matrix. Controlled and official-SDK MCP interoperability are verified separately and do not imply compatibility with every server or protocol feature. Provider capability claims remain artifact- and date-bound under the [live certification contract](./docs/LIVE_CERTIFICATION.md); credential detection and deterministic tests do not replace real provider evidence.
254
271
 
255
272
  ## Security boundaries
256
273
 
@@ -282,6 +299,7 @@ bun run typecheck
282
299
  bun test
283
300
  bun run build
284
301
  bun run evaluate
302
+ bun run benchmark:workspace
285
303
  bun run smoke:package
286
304
  bun run pack:inspect
287
305
  bun run check
package/ROADMAP.md CHANGED
@@ -3,7 +3,7 @@
3
3
  - Status: active
4
4
  - Baseline date: 2026-08-20
5
5
 
6
- This roadmap takes the harness from its `0.1.0` MVP to a stable CLI and library contract. The `0.2.0` source baseline is tagged locally, `0.3.0` and `0.4.0` are private checkpoints, and `0.5.0` through `0.7.0` are published on npm. `0.8.0` is the source release candidate for the coordinated SDK refresh and GPT-5.6-first OpenAI integration; publication and release certification remain separate operations. Releases are ordered by dependency and safety risk, not by calendar date. A version ships only when its exit criteria are satisfied.
6
+ This roadmap takes the harness from its `0.1.0` MVP to a stable CLI and library contract. The `0.2.0` source baseline is tagged locally, `0.3.0` and `0.4.0` are private checkpoints, and `0.5.0` through `0.8.0` are published on npm. `0.9.0` is the source candidate for faster governed repository inspection and portable change-admission evidence; publication and release certification remain separate operations. Releases are ordered by dependency and safety risk, not by calendar date. A version ships only when its exit criteria are satisfied.
7
7
 
8
8
  ## Planning principles
9
9
 
@@ -41,7 +41,8 @@ The `0.6.0` dependency batch pins and overrides `@zhivex-ai/core@1.6.0`, retaini
41
41
  | `0.6.0` | Enforced execution | Shell and checks inside a real isolation boundary | Published on npm | XL |
42
42
  | `0.6.1` | Positioning and proof | Reproducible hostile-repository control evidence | Published on npm | S |
43
43
  | `0.7.0` | Multi-provider agent console | Durable sessions, extensible providers, safe role routing, and automation events | Published on npm | L |
44
- | `0.8.0` | SDK refresh and GPT-5.6 | One Core runtime, current adapters, and a GPT-5.6-first OpenAI path | Source release candidate | M |
44
+ | `0.8.0` | SDK refresh and GPT-5.6 | One Core runtime, current adapters, and a GPT-5.6-first OpenAI path | Published on npm | M |
45
+ | `0.9.0` | Fast governed change admission | Lower repository/OCI overhead plus portable offline evidence bound to exact patch bytes | Source candidate | L |
45
46
  | `1.0.0` | Stable contract | Supported compatibility and release guarantees | Planned | L |
46
47
 
47
48
  Relative size is for sequencing only; dates require a capacity decision.
@@ -195,7 +196,7 @@ Exit criteria:
195
196
 
196
197
  Implementation summary:
197
198
 
198
- - the SDK execution-environment contract is implemented with a Docker/Podman adapter, immutable image identity, per-tool-call isolation, manifest authorization, and run fingerprint binding;
199
+ - the SDK execution-environment contract is implemented with a Docker/Podman adapter, immutable image identity, paused per-run isolation, transactional command publication, manifest authorization, and run fingerprint binding;
199
200
  - the enforced policy denies network and undeclared tools, uses a non-root identity, read-only root, dropped capabilities, no-new-privileges, and bounded memory, CPU, PIDs, time, output, snapshot, imported-file, and tmpfs resources;
200
201
  - repository tools and subagents share an ephemeral secret-free snapshot; package checks and argv-only commands run inside OCI, while network MCP fails closed under the no-network policy;
201
202
  - content- and run-bound patch inspection plus a separate durable import approval are the only environment-to-host mutation path; deletes remain recoverable through quarantine;
@@ -246,7 +247,7 @@ Deferred after `0.7.0`:
246
247
 
247
248
  ## 0.8.0 — SDK refresh and GPT-5.6-first OpenAI
248
249
 
249
- Status: source release candidate. Deterministic, installed-artifact, live-provider, and publication evidence remain separate gates.
250
+ Status: published on npm with registry provenance. Provider evidence remains date- and model-bound.
250
251
 
251
252
  Goal: adopt the coordinated SDK release batch without duplicating Core contracts, make the current GPT-5.6 family the primary OpenAI experience, and keep approval pauses reliable across provider behavior changes.
252
253
 
@@ -263,6 +264,29 @@ Exit criteria:
263
264
  - Luna, Terra, and Sol pass the base proposal/approval/restart/exactly-once live gate with date-bound evidence.
264
265
  - The exact release artifact, annotated tag, registry integrity, and provenance are verified independently before claiming publication.
265
266
 
267
+ ## 0.9.0 — fast governed change admission
268
+
269
+ Status: source candidate. Deterministic tests and the local performance fixture pass; real-OCI, installed-artifact, live-provider, tag, registry, and provenance gates remain separate.
270
+
271
+ Goal: reduce the cost of inspecting large repositories and materialize the harness's change-control evidence as a portable, agent-agnostic admission contract.
272
+
273
+ Scope:
274
+
275
+ - Reuse a freshness-checked, topology-only workspace index across pages while keeping file contents and digests on the stable anti-race read path.
276
+ - Add bounded batch reads and multi-query search without enabling unsafe global tool parallelism.
277
+ - Reduce OCI snapshot memory and duplicate patch-comparison reads without introducing a long-lived container or weakening transactional publication.
278
+ - Expose reproducible workspace benchmarks plus workspace-index and OCI I/O diagnostics.
279
+ - Add deterministic `ChangeEnvelope v1` creation and offline verification bound to exact patch bytes, base identity, policy/environment fingerprints, redacted check evidence, expiry, approval references, and external-attestation references.
280
+ - Keep authenticity explicit: built-in verification checks integrity, expiration, and preconditions; external signatures and attestations require their native verifier.
281
+
282
+ Exit criteria:
283
+
284
+ - Workspace index invalidation, external-change freshness, cursor staleness, batch bounds, duplicate reads, and multi-query single-pass behavior have deterministic regression coverage.
285
+ - The 5,000-file benchmark reports one index build and materially improves complete pagination against the pre-`0.9` baseline without setting a flaky CI wall-time threshold.
286
+ - OCI deterministic tests prove independent base/workspace copies, bounded inventory pages, changed-file-only patch reads, and unchanged import/stale-host guarantees; a real daemon gate remains mandatory for release.
287
+ - Change-envelope tests cover canonical determinism, exact patch tampering, base/policy/evidence changes, expiry, strict redaction schemas, and explicit authenticity limits.
288
+ - Documentation, typecheck, full tests, evaluation, build, package inspection, and installed-tarball smoke pass from a clean release commit before any tag or publication.
289
+
266
290
  ## 1.0.0 — Stable CLI and library contract
267
291
 
268
292
  Goal: freeze a supportable public contract after the pre-1.0 safety and operational surfaces have been exercised in real repositories.
@@ -275,7 +299,7 @@ Scope:
275
299
  - Complete threat model, security review, dependency audit, provenance, integrity, and rollback documentation.
276
300
  - Run a representative repository evaluation matrix across every supported provider and publish date-bound evidence.
277
301
  - Add full installation, operations, policy, MCP, isolation, troubleshooting, migration, and release documentation.
278
- - Require release candidates before `latest`; no direct `0.6.x` to untested GA promotion.
302
+ - Require release candidates before `latest`; no direct pre-1.0 source checkpoint to untested GA promotion.
279
303
 
280
304
  Exit criteria:
281
305
 
@@ -308,7 +332,8 @@ These can become separate post-1.0 tracks after the CLI/runtime contract and sec
308
332
 
309
333
  ## Immediate next actions
310
334
 
311
- 1. Finish the `0.8.0` deterministic, real-OCI, and installed-artifact gates from a clean release commit.
312
- 2. Complete the remaining GPT-5.6 and provisional-provider live matrices; keep uncertified paths provisional on any failure or missing evidence.
313
- 3. Dogfood the GPT-5.6 default, durable `zhx` sessions, provider handoff, role routing, and JSONL consumption on representative repositories.
314
- 4. Only after those gates, complete the reviewed release workflow and verify registry integrity and provenance against the exact artifact.
335
+ 1. Review and commit the `0.9.0` workspace-index, batch-tool, OCI I/O, and ChangeEnvelope contracts from a clean branch.
336
+ 2. Run the required real-OCI and installed-artifact gates; keep the current local benchmark as comparative evidence rather than a cross-machine latency promise.
337
+ 3. Dogfood exact-patch envelope creation/verification and batch repository inspection on representative repositories, including external workspace mutations between pages.
338
+ 4. Complete the remaining GPT-5.6 and provisional-provider live matrices; keep uncertified paths provisional on any failure or missing evidence.
339
+ 5. Only after those gates, create the annotated tag, dispatch the reviewed release workflow, and verify registry integrity and provenance against the exact artifact.
package/SECURITY.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  ## Supported versions
4
4
 
5
- Security fixes are provided for the latest published `0.6.x` version. Pre-release source snapshots and older private checkpoints are not supported release channels.
5
+ Security fixes are provided for the latest published `0.8.x` version. The `0.9.x` source candidate and older private checkpoints are not supported release channels until their exact artifacts are published and verified.
6
6
 
7
7
  ## Reporting a vulnerability
8
8
 
@@ -21,3 +21,9 @@ Private vulnerability reporting must be enabled before the repository is made pu
21
21
  Reports are in scope when they affect packaged runtime code, workspace or state isolation, approval enforcement, secret handling, MCP boundaries, provider communication, dependency integrity, or the build and release pipeline.
22
22
 
23
23
  The absence of an OS sandbox is a documented product boundary rather than a vulnerability by itself. The harness does not expose generic host shell or permanent-delete model tools.
24
+
25
+ `ChangeEnvelope v1` verifies canonical integrity, expiration, exact patch binding, and caller-supplied preconditions. It is not a signature or identity system; approval and external-attestation authenticity are explicitly reported as `not-verified`. A bypass in the documented built-in checks is in scope, while failure to validate an external trust bundle that the application never configured is outside that boundary.
26
+
27
+ The `0.9.x` workspace index caches topology only. File contents and content digests are reread through the stable anti-race path. Reports showing stale content returned as current, ignored files becoming discoverable after an ignore-policy change, or an accepted topology cursor after a structural mutation are in scope.
28
+
29
+ The `0.9.x` OCI backend may reuse one paused container inside an acquired run, but every command remains a separate publication transaction. Reports showing concurrent command execution, a failed/background command surviving into a later command, host-snapshot divergence not forcing reseed, `/tmp` state crossing a successful command boundary, or an unvalidated workspace reaching the durable snapshot are in scope.
package/SUPPORT.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Support
2
2
 
3
- Zhivex Harness `0.8.x` is a pre-1.0 CLI and TypeScript library for Bun. Observable contracts may change in a later minor release when the change and migration path are documented in [CHANGELOG.md](./CHANGELOG.md). The source checkout may be a release candidate newer than the latest public npm artifact.
3
+ Zhivex Harness `0.9.x` is a pre-1.0 CLI and TypeScript library for Bun. Observable contracts may change in a later minor release when the change and migration path are documented in [CHANGELOG.md](./CHANGELOG.md). The source checkout may be a release candidate newer than the latest public npm artifact.
4
4
 
5
5
  ## Supported baseline
6
6
 
@@ -0,0 +1,271 @@
1
+ import { z } from "zod";
2
+ import { type FileDigest } from "./edit-contracts.js";
3
+ export declare const CHANGE_ENVELOPE_SCHEMA_VERSION: 1;
4
+ export declare const CHANGE_ENVELOPE_DIGEST_ALGORITHM: "sha256";
5
+ export declare const MAX_CHANGE_ENVELOPE_CHECKS = 100;
6
+ export declare const MAX_CHANGE_ENVELOPE_APPROVALS = 100;
7
+ export declare const MAX_CHANGE_ENVELOPE_APPROVAL_SCOPES = 32;
8
+ export declare const MAX_CHANGE_ENVELOPE_ATTESTATIONS = 32;
9
+ export declare const changeEnvelopeCheckSchema: z.ZodObject<{
10
+ checkId: z.ZodString;
11
+ status: z.ZodEnum<{
12
+ passed: "passed";
13
+ failed: "failed";
14
+ skipped: "skipped";
15
+ }>;
16
+ redacted: z.ZodLiteral<true>;
17
+ startedAt: z.ZodISODateTime;
18
+ completedAt: z.ZodISODateTime;
19
+ durationMs: z.ZodNumber;
20
+ exitCode: z.ZodOptional<z.ZodNumber>;
21
+ redactedOutputDigest: z.ZodOptional<z.ZodString>;
22
+ runnerFingerprint: z.ZodOptional<z.ZodString>;
23
+ }, z.core.$strict>;
24
+ export type ChangeEnvelopeCheck = z.infer<typeof changeEnvelopeCheckSchema>;
25
+ export declare const changeEnvelopeApprovalSchema: z.ZodObject<{
26
+ kind: z.ZodLiteral<"approval-reference">;
27
+ approvalId: z.ZodString;
28
+ approvalDigest: z.ZodString;
29
+ approverDigest: z.ZodString;
30
+ scopes: z.ZodArray<z.ZodString>;
31
+ approvedAt: z.ZodISODateTime;
32
+ expiresAt: z.ZodOptional<z.ZodISODateTime>;
33
+ }, z.core.$strict>;
34
+ export type ChangeEnvelopeApproval = z.infer<typeof changeEnvelopeApprovalSchema>;
35
+ export declare const externalAttestationReferenceSchema: z.ZodObject<{
36
+ kind: z.ZodLiteral<"external-attestation-reference">;
37
+ attestationId: z.ZodString;
38
+ format: z.ZodString;
39
+ mediaType: z.ZodString;
40
+ bundleDigest: z.ZodString;
41
+ }, z.core.$strict>;
42
+ export type ExternalAttestationReference = z.infer<typeof externalAttestationReferenceSchema>;
43
+ export declare const changeEnvelopeBaseSchema: z.ZodObject<{
44
+ workspaceDigest: z.ZodString;
45
+ treeDigest: z.ZodString;
46
+ }, z.core.$strict>;
47
+ export declare const changeEnvelopePatchSchema: z.ZodObject<{
48
+ patchId: z.ZodString;
49
+ patchDigest: z.ZodString;
50
+ }, z.core.$strict>;
51
+ export declare const changeEnvelopeFingerprintsSchema: z.ZodObject<{
52
+ harness: z.ZodString;
53
+ policy: z.ZodString;
54
+ environment: z.ZodString;
55
+ }, z.core.$strict>;
56
+ export declare const changeEnvelopeEvidenceSchema: z.ZodObject<{
57
+ schemaVersion: z.ZodLiteral<1>;
58
+ kind: z.ZodLiteral<"check-evidence-summary">;
59
+ digestAlgorithm: z.ZodLiteral<"sha256">;
60
+ evidenceDigest: z.ZodString;
61
+ checks: z.ZodArray<z.ZodObject<{
62
+ checkId: z.ZodString;
63
+ status: z.ZodEnum<{
64
+ passed: "passed";
65
+ failed: "failed";
66
+ skipped: "skipped";
67
+ }>;
68
+ redacted: z.ZodLiteral<true>;
69
+ startedAt: z.ZodISODateTime;
70
+ completedAt: z.ZodISODateTime;
71
+ durationMs: z.ZodNumber;
72
+ exitCode: z.ZodOptional<z.ZodNumber>;
73
+ redactedOutputDigest: z.ZodOptional<z.ZodString>;
74
+ runnerFingerprint: z.ZodOptional<z.ZodString>;
75
+ }, z.core.$strict>>;
76
+ }, z.core.$strict>;
77
+ export type ChangeEnvelopeEvidence = z.infer<typeof changeEnvelopeEvidenceSchema>;
78
+ export declare const changeEnvelopeInputSchema: z.ZodObject<{
79
+ createdAt: z.ZodISODateTime;
80
+ expiresAt: z.ZodOptional<z.ZodISODateTime>;
81
+ base: z.ZodObject<{
82
+ workspaceDigest: z.ZodString;
83
+ treeDigest: z.ZodString;
84
+ }, z.core.$strict>;
85
+ patch: z.ZodObject<{
86
+ patchId: z.ZodString;
87
+ patchDigest: z.ZodString;
88
+ }, z.core.$strict>;
89
+ fingerprints: z.ZodObject<{
90
+ harness: z.ZodString;
91
+ policy: z.ZodString;
92
+ environment: z.ZodString;
93
+ }, z.core.$strict>;
94
+ checks: z.ZodArray<z.ZodObject<{
95
+ checkId: z.ZodString;
96
+ status: z.ZodEnum<{
97
+ passed: "passed";
98
+ failed: "failed";
99
+ skipped: "skipped";
100
+ }>;
101
+ redacted: z.ZodLiteral<true>;
102
+ startedAt: z.ZodISODateTime;
103
+ completedAt: z.ZodISODateTime;
104
+ durationMs: z.ZodNumber;
105
+ exitCode: z.ZodOptional<z.ZodNumber>;
106
+ redactedOutputDigest: z.ZodOptional<z.ZodString>;
107
+ runnerFingerprint: z.ZodOptional<z.ZodString>;
108
+ }, z.core.$strict>>;
109
+ approvals: z.ZodOptional<z.ZodArray<z.ZodObject<{
110
+ kind: z.ZodLiteral<"approval-reference">;
111
+ approvalId: z.ZodString;
112
+ approvalDigest: z.ZodString;
113
+ approverDigest: z.ZodString;
114
+ scopes: z.ZodArray<z.ZodString>;
115
+ approvedAt: z.ZodISODateTime;
116
+ expiresAt: z.ZodOptional<z.ZodISODateTime>;
117
+ }, z.core.$strict>>>;
118
+ externalAttestations: z.ZodOptional<z.ZodArray<z.ZodObject<{
119
+ kind: z.ZodLiteral<"external-attestation-reference">;
120
+ attestationId: z.ZodString;
121
+ format: z.ZodString;
122
+ mediaType: z.ZodString;
123
+ bundleDigest: z.ZodString;
124
+ }, z.core.$strict>>>;
125
+ }, z.core.$strict>;
126
+ export type CreateChangeEnvelopeInput = z.infer<typeof changeEnvelopeInputSchema>;
127
+ export declare const changeEnvelopeSchema: z.ZodObject<{
128
+ schemaVersion: z.ZodLiteral<1>;
129
+ kind: z.ZodLiteral<"change-envelope">;
130
+ digestAlgorithm: z.ZodLiteral<"sha256">;
131
+ envelopeId: z.ZodString;
132
+ createdAt: z.ZodISODateTime;
133
+ expiresAt: z.ZodOptional<z.ZodISODateTime>;
134
+ base: z.ZodObject<{
135
+ workspaceDigest: z.ZodString;
136
+ treeDigest: z.ZodString;
137
+ }, z.core.$strict>;
138
+ patch: z.ZodObject<{
139
+ patchId: z.ZodString;
140
+ patchDigest: z.ZodString;
141
+ }, z.core.$strict>;
142
+ fingerprints: z.ZodObject<{
143
+ harness: z.ZodString;
144
+ policy: z.ZodString;
145
+ environment: z.ZodString;
146
+ }, z.core.$strict>;
147
+ evidence: z.ZodObject<{
148
+ schemaVersion: z.ZodLiteral<1>;
149
+ kind: z.ZodLiteral<"check-evidence-summary">;
150
+ digestAlgorithm: z.ZodLiteral<"sha256">;
151
+ evidenceDigest: z.ZodString;
152
+ checks: z.ZodArray<z.ZodObject<{
153
+ checkId: z.ZodString;
154
+ status: z.ZodEnum<{
155
+ passed: "passed";
156
+ failed: "failed";
157
+ skipped: "skipped";
158
+ }>;
159
+ redacted: z.ZodLiteral<true>;
160
+ startedAt: z.ZodISODateTime;
161
+ completedAt: z.ZodISODateTime;
162
+ durationMs: z.ZodNumber;
163
+ exitCode: z.ZodOptional<z.ZodNumber>;
164
+ redactedOutputDigest: z.ZodOptional<z.ZodString>;
165
+ runnerFingerprint: z.ZodOptional<z.ZodString>;
166
+ }, z.core.$strict>>;
167
+ }, z.core.$strict>;
168
+ approvals: z.ZodOptional<z.ZodArray<z.ZodObject<{
169
+ kind: z.ZodLiteral<"approval-reference">;
170
+ approvalId: z.ZodString;
171
+ approvalDigest: z.ZodString;
172
+ approverDigest: z.ZodString;
173
+ scopes: z.ZodArray<z.ZodString>;
174
+ approvedAt: z.ZodISODateTime;
175
+ expiresAt: z.ZodOptional<z.ZodISODateTime>;
176
+ }, z.core.$strict>>>;
177
+ externalAttestations: z.ZodOptional<z.ZodArray<z.ZodObject<{
178
+ kind: z.ZodLiteral<"external-attestation-reference">;
179
+ attestationId: z.ZodString;
180
+ format: z.ZodString;
181
+ mediaType: z.ZodString;
182
+ bundleDigest: z.ZodString;
183
+ }, z.core.$strict>>>;
184
+ }, z.core.$strict>;
185
+ export type ChangeEnvelope = z.infer<typeof changeEnvelopeSchema>;
186
+ /** Content-addresses exact artifact bytes for patch/base inputs without parsing them. */
187
+ export declare const digestChangeEnvelopeArtifact: (value: string | Uint8Array) => FileDigest;
188
+ /**
189
+ * Creates a content-addressed envelope. The caller supplies all timestamps, so
190
+ * repeated calls with semantically identical input return the same envelope.
191
+ * Raw command output, prompts, reasons, and credentials are intentionally not
192
+ * representable by this contract.
193
+ */
194
+ export declare const createChangeEnvelope: (input: unknown) => ChangeEnvelope;
195
+ /** Returns the canonical, whitespace-free JSON representation of a valid envelope. */
196
+ export declare const canonicalizeChangeEnvelope: (input: unknown) => string;
197
+ /** Recomputes the envelope identifier without trusting its embedded envelopeId. */
198
+ export declare const computeChangeEnvelopeDigest: (input: unknown) => FileDigest;
199
+ /** Recomputes the independently addressable digest of the redacted check summary. */
200
+ export declare const computeChangeEnvelopeEvidenceDigest: (input: unknown) => FileDigest;
201
+ export declare const changeEnvelopePreconditionsSchema: z.ZodObject<{
202
+ envelopeId: z.ZodOptional<z.ZodString>;
203
+ baseWorkspaceDigest: z.ZodOptional<z.ZodString>;
204
+ baseTreeDigest: z.ZodOptional<z.ZodString>;
205
+ patchId: z.ZodOptional<z.ZodString>;
206
+ patchDigest: z.ZodOptional<z.ZodString>;
207
+ harnessFingerprint: z.ZodOptional<z.ZodString>;
208
+ policyFingerprint: z.ZodOptional<z.ZodString>;
209
+ environmentFingerprint: z.ZodOptional<z.ZodString>;
210
+ evidenceDigest: z.ZodOptional<z.ZodString>;
211
+ requiredPassedChecks: z.ZodOptional<z.ZodArray<z.ZodString>>;
212
+ requiredApprovalDigests: z.ZodOptional<z.ZodArray<z.ZodString>>;
213
+ requiredApprovalScopes: z.ZodOptional<z.ZodArray<z.ZodString>>;
214
+ requiredAttestationDigests: z.ZodOptional<z.ZodArray<z.ZodString>>;
215
+ }, z.core.$strict>;
216
+ export type ChangeEnvelopePreconditions = z.infer<typeof changeEnvelopePreconditionsSchema>;
217
+ export interface ChangeEnvelopeVerificationOptions {
218
+ now?: Date | string | number;
219
+ preconditions?: ChangeEnvelopePreconditions;
220
+ }
221
+ export type ChangeEnvelopeVerificationIssueCode = "invalid-schema" | "envelope-digest-mismatch" | "evidence-digest-mismatch" | "envelope-not-yet-valid" | "envelope-expired" | "approval-expired" | "precondition-mismatch" | "missing-passed-check" | "missing-approval-digest" | "missing-approval-scope" | "missing-attestation-digest";
222
+ export interface ChangeEnvelopeVerificationIssue {
223
+ code: ChangeEnvelopeVerificationIssueCode;
224
+ path: readonly (string | number)[];
225
+ message: string;
226
+ expected?: string;
227
+ actual?: string;
228
+ }
229
+ export interface ChangeEnvelopeVerificationResult {
230
+ valid: boolean;
231
+ verificationScope: "integrity-expiration-and-preconditions-only";
232
+ envelope?: ChangeEnvelope;
233
+ issues: ChangeEnvelopeVerificationIssue[];
234
+ integrity: {
235
+ envelopeDigestValid: boolean;
236
+ evidenceDigestValid: boolean;
237
+ };
238
+ expiration: {
239
+ checkedAt: string;
240
+ envelopeNotYetValid: boolean;
241
+ envelopeExpired: boolean;
242
+ expiredApprovalIds: string[];
243
+ };
244
+ checks: {
245
+ recorded: number;
246
+ passed: string[];
247
+ failed: string[];
248
+ skipped: string[];
249
+ requiredPassed: string[];
250
+ missingPassed: string[];
251
+ };
252
+ approvals: {
253
+ recorded: number;
254
+ requiredScopes: string[];
255
+ missingScopes: string[];
256
+ authenticity: "not-verified";
257
+ };
258
+ externalAttestations: {
259
+ referenced: number;
260
+ requiredDigests: FileDigest[];
261
+ missingDigests: FileDigest[];
262
+ authenticity: "not-verified";
263
+ };
264
+ }
265
+ /**
266
+ * Verifies schema, content digests, expiry, and caller-supplied preconditions
267
+ * without network access. Approval and attestation references are integrity
268
+ * bound only: their issuer/signature authenticity must be checked by an
269
+ * external Sigstore/in-toto (or equivalent) verifier.
270
+ */
271
+ export declare const verifyChangeEnvelope: (input: unknown, options?: ChangeEnvelopeVerificationOptions) => ChangeEnvelopeVerificationResult;