@zhivex-ai/harness 0.5.0 → 0.6.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.
@@ -53,6 +53,12 @@ export declare class Workspace {
53
53
  content: string;
54
54
  truncated: boolean;
55
55
  }>;
56
+ inspectFile(relativePath: string): Promise<{
57
+ path: string;
58
+ digest: string;
59
+ mode: number;
60
+ bytes: number;
61
+ }>;
56
62
  searchFiles(query: string, relativePath?: string, options?: SearchFilesOptions): Promise<{
57
63
  nextCursor?: string;
58
64
  matches: SearchMatch[];
@@ -63,6 +69,10 @@ export declare class Workspace {
63
69
  private secureWorkspaceDirectory;
64
70
  private stageFile;
65
71
  applyPatch(input: ApplyEditProposalInput): Promise<ApplyPatchResult>;
72
+ applyPatchWithModes(input: ApplyEditProposalInput, modes: ReadonlyMap<string, {
73
+ beforeMode?: number;
74
+ afterMode: number;
75
+ }>): Promise<ApplyPatchResult>;
66
76
  /** @deprecated Use applyPatch with an inspected expectedDigest. */
67
77
  writeFile(relativePath: string, content: string, overwrite?: boolean): Promise<{
68
78
  path: string;
package/docs/CLI.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # CLI contract
2
2
 
3
- Zhivex Harness `0.5.x` is Bun-first and exposes a human terminal interface plus versioned JSON documents for automation.
3
+ Zhivex Harness `0.6.x` is Bun-first and exposes a human terminal interface plus versioned JSON documents for automation.
4
4
 
5
5
  ## Commands
6
6
 
@@ -20,7 +20,7 @@ zhivex-harness --version
20
20
  zhivex-harness --help
21
21
  ```
22
22
 
23
- `doctor` is local and makes no provider or MCP request. It checks the Bun version, workspace, Git, supported package scripts, state-directory safety, provider credential presence, endpoint shape, provider configuration, and the local MCP configuration file without returning secret or endpoint values.
23
+ `doctor` is local and makes no provider or MCP request. It checks the Bun version, workspace, Git, supported package scripts, state-directory safety, provider credential presence, endpoint shape, provider configuration, the local MCP configuration file, and—when requested—the OCI runtime and preloaded image without returning secret or endpoint values.
24
24
 
25
25
  `--allow-check <script>` is repeatable and replaces the default check allowlist for that invocation. Values are declared `package.json` script names, never command text.
26
26
 
@@ -28,6 +28,25 @@ zhivex-harness --help
28
28
 
29
29
  `review` is application-owned parallelism and accepts only read-only explorer/reviewer members. Model-directed delegation occurs only inside `run` or `chat` when the parent invokes an enabled `delegate_<profile>` tool.
30
30
 
31
+ Enforced execution is opt-in:
32
+
33
+ ```text
34
+ --execution <none|oci>
35
+ --oci-runtime <docker|podman>
36
+ --oci-image <reference>
37
+ --oci-allow-command <bare-name>
38
+ --oci-max-process-runtime-ms <n>
39
+ --oci-max-process-output-bytes <n>
40
+ --oci-max-memory-mb <n>
41
+ --oci-max-pids <n>
42
+ --oci-max-cpus <n>
43
+ --oci-max-workspace-bytes <n>
44
+ --oci-max-file-write-bytes <n>
45
+ --oci-tmpfs-mb <n>
46
+ ```
47
+
48
+ `--oci-allow-command` is repeatable, replaces the default executable allowlist, and must include `bun` so declared package checks can run. Commands are exact argv arrays, never shell strings. See [EXECUTION_ENVIRONMENTS.md](./EXECUTION_ENVIRONMENTS.md).
49
+
31
50
  ## Exit codes
32
51
 
33
52
  | Code | Meaning |
@@ -39,6 +58,8 @@ zhivex-harness --help
39
58
 
40
59
  Agent results with status `failed` or `timed_out` return `1`. A paused approval is a valid durable result and does not imply a runtime failure.
41
60
 
61
+ Every new CLI run persists its resolved, non-secret harness configuration with the durable state. The printed resume command includes the canonical workspace, state-store backend, and scope locator; after loading the run, `resume` restores the original execution policy, including every OCI image, runtime, allowlist, and resource limit, before validating the harness fingerprint. Explicit conflicting resume options still fail closed. Runs created before this metadata existed must repeat their original policy options manually.
62
+
42
63
  Operator commands do not construct a provider model and do not require provider credentials. They must use the workspace, state directory, backend, and scope that own the target run. `cancel` creates a cooperative cancellation request by default; `--final` writes a terminal cancellation. `cleanup` requires an explicit cutoff and defaults to terminal statuses only.
43
64
 
44
65
  ## JSON schemas
@@ -56,10 +77,10 @@ Additive fields may appear within schema version `1`. Removing a field, changing
56
77
 
57
78
  Provider diagnostics include credential variable names and boolean presence only. Endpoint diagnostics include validation booleans only. Neither contract contains credential values or endpoint URLs.
58
79
 
59
- `run-result.mutations` contains the mutation audit entries produced by the current harness process. `run-result.children` reports bounded child identity, status, steps, tool/error counts, and usage without raw child messages or tool payloads. Capability evidence and configured MCP server names are included. `review-group` contains a group ID and one bounded member result. Operational inspect/export documents are redacted and do not include raw messages, tool inputs/outputs, approval arguments, metadata, or full output text; `run-inspection.hierarchy` adds the redacted run tree. Tool-level repository-editing documents use their own schema version `1` and kinds such as `edit-proposal`, `patch-result`, `mutation-audit`, and `workspace-diff`; see [REPOSITORY_EDITING.md](./REPOSITORY_EDITING.md).
80
+ `run-result.mutations` contains the mutation audit entries produced by the current harness process. `run-result.children` reports bounded child identity, status, steps, tool/error counts, and usage without raw child messages or tool payloads. Capability evidence, configured MCP server names, and the execution backend/binding/image are included. `review-group` contains a group ID and one bounded member result. Operational inspect/export documents are redacted and do not include raw messages, tool inputs/outputs, approval arguments, metadata, or full output text; `run-inspection.hierarchy` adds the redacted run tree. Tool-level repository-editing documents use their own schema version `1` and kinds such as `edit-proposal`, `patch-result`, `mutation-audit`, and `workspace-diff`; see [REPOSITORY_EDITING.md](./REPOSITORY_EDITING.md).
60
81
 
61
82
  ## Configuration schema
62
83
 
63
- Resolved library configuration includes `schemaVersion: 3`, an explicit `allowedChecks` array, `storeBackend`, `scope`, parent `budget`, `compaction`, `requiredCapabilities`, optional `mcpConfigPath`, and an `orchestration` object with profiles, child budget/timeout, and review concurrency. The check default is `test`, `typecheck`, `lint`, and `build`; `--allow-check` or `ZHIVEX_HARNESS_ALLOWED_CHECKS` replaces that set. Passing a different explicit schema version fails before a model or tool can run. During `0.x`, a minor release may add a new schema version with a documented migration; patch releases remain compatible.
84
+ Resolved library configuration includes `schemaVersion: 4`, an explicit `allowedChecks` array, `storeBackend`, `scope`, parent `budget`, `compaction`, `requiredCapabilities`, optional `mcpConfigPath`, an `orchestration` object with profiles, child budget/timeout, and review concurrency, and a discriminated `execution` policy. The check default is `test`, `typecheck`, `lint`, and `build`; `--allow-check` or `ZHIVEX_HARNESS_ALLOWED_CHECKS` replaces that set. Execution defaults to `{ backend: "none" }`; an OCI policy records the runtime, image, allowed commands, and every resource ceiling. Passing a different explicit schema version fails before a model or tool can run. During `0.x`, a minor release may add a new schema version with a documented migration; patch releases remain compatible.
64
85
 
65
86
  The default state directory is `<workspace>/.zhivex-harness/runs` and the default backend is scoped SQLite at `operations.sqlite`. Explicit external state directories are supported, but the workspace root, filesystem root, sensitive workspace paths, regular files, and symbolic-link targets are rejected before the run store is created. See [DURABLE_OPERATIONS.md](./DURABLE_OPERATIONS.md) for state migration and operations, and [EXTENSIBILITY.md](./EXTENSIBILITY.md) for capability, MCP, subagent, and review-group configuration.
@@ -1,6 +1,6 @@
1
1
  # Durable operations
2
2
 
3
- Zhivex Harness `0.4.x` makes local runs inspectable and recoverable across process restarts. The default store is Bun SQLite at `<workspace>/.zhivex-harness/runs/operations.sqlite`; `--store file` remains a migration fallback.
3
+ Zhivex Harness durable operations make local runs inspectable and recoverable across process restarts. The default store is Bun SQLite at `<workspace>/.zhivex-harness/runs/operations.sqlite`; `--store file` remains a migration fallback.
4
4
 
5
5
  ## Scope and identity
6
6
 
@@ -10,7 +10,9 @@ Every durable key is isolated by:
10
10
  - optional user;
11
11
  - namespace: a SHA-256-derived canonical-workspace identifier by default.
12
12
 
13
- Use the same workspace, state directory, backend, tenant, user, and namespace for `run`, `resume`, and every `runs` command. A run fingerprint is bound to the canonical workspace, durable scope, provider/model, tool contract, approval policy, config schema, and harness version. Resume fails closed when a current binding differs.
13
+ Use the same workspace, state directory, backend, tenant, user, and namespace for `run`, `resume`, and every `runs` command. A run fingerprint is bound to the canonical workspace, durable scope, provider/model, tool contract, approval policy, config schema, harness version, and execution-environment policy. Under OCI, the resolved image identity is also bound. Resume fails closed when a current binding differs.
14
+
15
+ CLI-created runs persist the resolved non-secret harness configuration in versioned run metadata. The terminal prints a scope-complete locator command, and `resume` restores the original OCI policy before fingerprint validation, so approval restart does not silently fall back to `execution=none`. Explicit conflicting overrides are rejected by the existing binding check.
14
16
 
15
17
  ```bash
16
18
  zhivex-harness run \
@@ -107,6 +109,18 @@ ZHIVEX_HARNESS_OUTPUT_COST_PER_MILLION
107
109
  ZHIVEX_HARNESS_COMPACTION_MAX_MESSAGES
108
110
  ZHIVEX_HARNESS_COMPACTION_MAX_INPUT_TOKENS
109
111
  ZHIVEX_HARNESS_COMPACTION_KEEP_RECENT
112
+ ZHIVEX_HARNESS_EXECUTION
113
+ ZHIVEX_HARNESS_OCI_RUNTIME
114
+ ZHIVEX_HARNESS_OCI_IMAGE
115
+ ZHIVEX_HARNESS_OCI_ALLOWED_COMMANDS
116
+ ZHIVEX_HARNESS_OCI_MAX_PROCESS_RUNTIME_MS
117
+ ZHIVEX_HARNESS_OCI_MAX_PROCESS_OUTPUT_BYTES
118
+ ZHIVEX_HARNESS_OCI_MAX_MEMORY_MB
119
+ ZHIVEX_HARNESS_OCI_MAX_PIDS
120
+ ZHIVEX_HARNESS_OCI_MAX_CPUS
121
+ ZHIVEX_HARNESS_OCI_MAX_WORKSPACE_BYTES
122
+ ZHIVEX_HARNESS_OCI_MAX_FILE_WRITE_BYTES
123
+ ZHIVEX_HARNESS_OCI_TMPFS_MB
110
124
  ```
111
125
 
112
126
  ## Evaluation gate
@@ -0,0 +1,130 @@
1
+ # Enforced execution environments
2
+
3
+ Zhivex Harness `0.6.x` adds an opt-in local OCI backend for shell-class work. The default remains `execution=none`: repository tools and declared checks keep their existing narrow contract, and no generic command tool is exposed. Selecting `execution=oci` acquires an SDK execution-environment session, copies an eligible workspace snapshot, and routes repository tools, checks, environment commands, and child agents through that session.
4
+
5
+ This is a local enforced runner. It is not a hosted sandbox, a virtual machine, or a promise that a compromised container runtime cannot affect its host.
6
+
7
+ ## Trust boundary
8
+
9
+ The harness trusts the operator, host OS, Docker or Podman daemon, configured image, Zhivex packages, and its own state directory. The model and code executed in the container are outside that trust boundary.
10
+
11
+ The OCI policy is enforced per tool call with:
12
+
13
+ - `--network none`;
14
+ - a read-only container root filesystem;
15
+ - every Linux capability dropped and `no-new-privileges` enabled;
16
+ - the host numeric user/group rather than root;
17
+ - a size-bounded writable `tmpfs` at `/workspace` plus a separate bounded `tmpfs` at `/tmp`;
18
+ - an optional host `node_modules` directory mounted read-only at `/dependencies` and linked into the container workspace;
19
+ - exact argv execution through the configured entrypoint, with no shell interpolation;
20
+ - a fixed container environment containing only `HOME`, `TMPDIR`, `BUN_INSTALL_CACHE_DIR`, and `CI`;
21
+ - time, output, memory, CPU, PID, workspace-size, and per-file patch limits.
22
+
23
+ The snapshot is populated through the normal bounded workspace discovery contract. Git internals, harness state, dependency/build output, `.env`, `.npmrc`, private keys, secret-like paths, external symlinks, and special files are not copied. Provider credentials and arbitrary host environment variables are never passed to the container.
24
+
25
+ When the backend is disabled, these OCI claims do not apply. The harness responds by omitting `run_environment_command`, not by falling back to an unrestricted host shell.
26
+
27
+ ## OCI configuration
28
+
29
+ Preload the image intentionally; the harness never pulls or updates images:
30
+
31
+ ```bash
32
+ docker pull oven/bun:1.3.7-slim
33
+ bun run dev doctor --execution oci
34
+ bun run dev run --execution oci --yes "implement the change, test it, inspect the environment patch, and import it"
35
+ ```
36
+
37
+ Podman is also supported through `--oci-runtime podman`. Defaults are:
38
+
39
+ | Setting | Default |
40
+ | --- | ---: |
41
+ | Backend | `none` |
42
+ | Runtime | `docker` |
43
+ | Image | `oven/bun:1.3.7-slim` |
44
+ | Allowed commands | `bun` |
45
+ | Process time | 120,000 ms |
46
+ | Retained process output | 20,000 bytes |
47
+ | Memory | 1,024 MB |
48
+ | PIDs | 128 |
49
+ | CPUs | 2 |
50
+ | Snapshot | 64 MiB |
51
+ | Imported file | 1 MiB |
52
+ | `/tmp` tmpfs | 256 MB |
53
+
54
+ CLI flags are listed in [CLI.md](./CLI.md). The matching environment variables are:
55
+
56
+ ```text
57
+ ZHIVEX_HARNESS_EXECUTION
58
+ ZHIVEX_HARNESS_OCI_RUNTIME
59
+ ZHIVEX_HARNESS_OCI_IMAGE
60
+ ZHIVEX_HARNESS_OCI_ALLOWED_COMMANDS
61
+ ZHIVEX_HARNESS_OCI_MAX_PROCESS_RUNTIME_MS
62
+ ZHIVEX_HARNESS_OCI_MAX_PROCESS_OUTPUT_BYTES
63
+ ZHIVEX_HARNESS_OCI_MAX_MEMORY_MB
64
+ ZHIVEX_HARNESS_OCI_MAX_PIDS
65
+ ZHIVEX_HARNESS_OCI_MAX_CPUS
66
+ ZHIVEX_HARNESS_OCI_MAX_WORKSPACE_BYTES
67
+ ZHIVEX_HARNESS_OCI_MAX_FILE_WRITE_BYTES
68
+ ZHIVEX_HARNESS_OCI_TMPFS_MB
69
+ ```
70
+
71
+ `ZHIVEX_HARNESS_OCI_ALLOWED_COMMANDS` is comma-separated. `bun` is mandatory because `run_check` invokes declared scripts as `bun --no-env-file run <script>`. Adding an executable permits that bare entrypoint but does not add a shell or wildcard. Each environment command still requires normal high-risk interrupt approval unless the operator deliberately supplied `--yes`.
72
+
73
+ The image is inspected before model construction. Its immutable image ID/digest, runtime/server version, complete policy, canonical workspace identity, and environment manifest contribute to the run binding. A missing daemon/image fails before model execution. A changed image or policy makes a paused resume fail closed.
74
+
75
+ ## Snapshot and patch import
76
+
77
+ The acquired environment contains two owner-only copies under `<state-dir>/environments/<run-hash>`:
78
+
79
+ - `base`: the immutable comparison snapshot;
80
+ - `workspace`: the mutable snapshot used by repository tools and containers.
81
+
82
+ For each successful command, the harness seeds a fresh, size-bounded `/workspace` tmpfs from the durable snapshot, pauses the container, copies the result into a new owner-only staging directory, rejects symlinks, hard links, special files, oversized workspaces, excessive entries, and oversized changed files, then atomically replaces the durable snapshot. The host snapshot is never mounted writable into an untrusted container. Failed, cancelled, timed-out, or output-limited commands do not publish partial filesystem mutations.
83
+
84
+ `inspect_environment_patch` compares them deterministically and returns a run-bound patch identifier plus create/update/delete entries, content digests, and before/after permission modes. Content-identical mode changes remain visible, and modes are part of the reviewed `patchId`. It rejects binary changes, more than 50 files, a patch above 4 MiB, or a file above the configured import ceiling.
85
+
86
+ `apply_environment_patch` is a different high-risk tool and approval. Immediately before import it recomputes the patch identifier and verifies every host precondition against the digest and mode captured at acquisition. Creates must still be absent; updates and deletes must still match. Writes publish content and mode atomically, including newly created executable files and mode-only updates; rollback restores both. Deletions use recoverable quarantine, and a deletion failure triggers best-effort rollback. The host remains unchanged until this import succeeds.
87
+
88
+ Because repository tools are snapshot-scoped while OCI is active, `apply_patch`, moves, quarantine, and restore alter only the snapshot. The model-facing `git_diff` tool is omitted in this mode because it would read the canonical host outside the environment boundary; the caller still receives the canonical final host Git status/diff after any approved import.
89
+
90
+ ## Resource and network policy
91
+
92
+ Every command receives the configured timeout and combined output ceiling. Cancellation, timeout, or output overflow kills the client process and force-removes the named container. The runtime also applies the memory, PID, CPU, read-only-root, workspace-tmpfs, `/tmp`-tmpfs, capability, and network controls listed above.
93
+
94
+ The environment manifest declares zero network requests and bytes and denies undeclared tools. Consequently, all MCP configuration is rejected before discovery when OCI enforcement is active: executing a client on the host would bypass the environment boundary, while executing a network client inside the container would violate `network=deny`. Governed MCP remains available in a separate non-OCI run, with mandatory durable approval for network tools. `stdio` MCP remains unavailable.
95
+
96
+ PID limits are the primary fork-bomb control. Memory and CPU limits constrain resource exhaustion, while the harness timeout and cancellation path bound command duration. These limits reduce impact; they are not a substitute for isolating the container daemon on a dedicated host when running actively hostile code.
97
+
98
+ ## Lifecycle and recovery
99
+
100
+ Environment artifacts are keyed by a hash of the durable run ID and include an owner-only metadata file bound to that exact run, workspace, environment fingerprint, and image. Reacquisition reuses the same snapshot only when every binding matches.
101
+
102
+ Each runtime container and temporary workspace volume carries `com.zhivex.harness.execution=v1` and a hashed run label. Session release force-removes resources for that run and records the terminal status and release timestamp. `runs cleanup --before <cutoff>` removes only released terminal artifact directories older than the cutoff; with OCI configured it also removes labeled containers in `created`, `exited`, `dead`, or `paused` state and unused labeled volumes. Unknown directories, symlinks, active resources, and unlabeled OCI resources are skipped.
103
+
104
+ Crash recovery relies on the same labels and durable artifacts. An operator can rerun cleanup after a process crash. The harness does not issue broad container/volume prune commands and never deletes an unlabeled OCI resource.
105
+
106
+ ## Migration from 0.5.x
107
+
108
+ Configuration schema version advances from `3` to `4`. Update schema-pinned callers and regenerated configuration snapshots. The run-store database schema does not require a rewrite.
109
+
110
+ The default backend remains `none`, so upgrades do not unexpectedly start a container daemon or expose shell execution. Enable OCI explicitly and preload its image. Paused runs created with `0.5.x` have a different harness/tool fingerprint and should be completed with their original version rather than silently rebound.
111
+
112
+ Applications constructing the harness can inject a `HarnessOciRuntimeAdapter` for a controlled runtime implementation. They should use the exported SDK environment rather than bypassing authorization or importing snapshot files directly.
113
+
114
+ ## Certification
115
+
116
+ The deterministic tests use an injected runtime to cover acquisition, secret exclusion, snapshot-only mutation, patch binding/import, separate approvals, image-fingerprint resume rejection, release, and safe artifact cleanup. The installed-package smoke imports the public OCI API and proves that a consumer can perform the same snapshot/import flow.
117
+
118
+ `bun run smoke:oci` exercises a real Docker/Podman daemon and preloaded image. It verifies secret exclusion, denied outbound network, denied root-filesystem writes, snapshot mutation, enforced workspace capacity, package checks, host non-mutation before import, approved import, cancellation, release, orphan cleanup, and artifact retention cleanup. It skips locally when no daemon is available unless `ZHIVEX_HARNESS_OCI_REQUIRED=1`; Linux CI, release validation, and live certification set that variable so absence is a failure.
119
+
120
+ Provider certification is separate and billable. The live workflow runs the required OCI gate before the model-directed Meta, Qwen, and OpenAI matrices. A deterministic OCI pass does not by itself certify a provider, and live provider success does not replace exact installed-artifact or published-registry proof.
121
+
122
+ ## Known limits
123
+
124
+ - Docker and Podman use different host security implementations; current gates certify behavior, not identical internals.
125
+ - The default Bun image and read-only host `node_modules` mount optimize JavaScript/TypeScript checks. Other ecosystems need an explicit image and executable allowlist, and dependencies should be prepared without exposing secrets.
126
+ - The local container daemon, kernel, image, and mounted dependency tree remain trusted. This backend is not a microVM boundary.
127
+ - Network is deny-only in this policy version. Domain allowlists, package installation, browser automation, and network MCP require a future policy/backend rather than an implicit exception.
128
+ - Patch import accepts bounded UTF-8 text changes only. Binary artifacts and large generated trees must use a future reviewed artifact-transfer contract.
129
+ - Per-file atomic publication plus best-effort rollback is not a transaction across power loss or hostile concurrent host writers.
130
+ - The harness does not build, pull, scan, sign, or attest the configured image. Operators should pin and govern images according to their deployment policy.
@@ -131,6 +131,6 @@ Human terminal mode reports child start and finish telemetry. `run-result` JSON
131
131
  - The built-in MCP transport implements bounded JSON-RPC over Streamable HTTP response forms; it does not support OAuth discovery, server-initiated sampling, roots, subscriptions, elicitation, or arbitrary SSE reconnection.
132
132
  - MCP prompt-injection detection is a safety filter, not a proof that remote content is trustworthy.
133
133
  - Parallel review groups have a durable shared parent identifier, but the group itself is not a standalone persisted agent state.
134
- - Subagents share the host process and workspace. They are policy boundaries, not OS isolation.
135
- - Generic shell, `stdio` MCP, containers, network namespaces, and remote workers remain `0.6.x` scope.
134
+ - With `execution=none`, subagents share the host process and workspace and are policy boundaries rather than OS isolation. With `execution=oci`, they inherit the same acquired snapshot and environment authorization; this does not turn the local container runtime into a VM.
135
+ - Generic host shell, `stdio` MCP, network-enabled OCI policies, and remote workers remain unavailable. The `0.6.x` OCI policy rejects all MCP before discovery rather than executing an undeclared client outside the acquired boundary.
136
136
  - Provider-specific orchestration behavior requires date-bound live certification and is separate from deterministic implementation evidence.
@@ -0,0 +1,97 @@
1
+ # Hostile repository demonstration
2
+
3
+ The hostile-repository demo is a reproducible product proof for the governed change path in Zhivex Harness `0.6.x`. It uses a disposable repository with malicious instructions and a decoy `.env`; it never targets the checkout from which the command is launched.
4
+
5
+ ## What it proves
6
+
7
+ One run exercises the real harness contracts in this order:
8
+
9
+ 1. create a secret-bearing hostile fixture under the operating-system temporary directory;
10
+ 2. request one allowlisted Bun command and stop at a durable `run_environment_command` approval;
11
+ 3. close and reopen the SQLite-backed harness before approving the command;
12
+ 4. verify from inside OCI that `.env` is absent and outbound network is denied;
13
+ 5. modify only the ephemeral snapshot and inspect the content- and run-bound patch;
14
+ 6. stop at a different durable `apply_environment_patch` approval while the host remains unchanged;
15
+ 7. reopen again, approve the exact patch, import it once, and inspect the redacted ledger; and
16
+ 8. create another reviewed patch, change its host target concurrently, and prove that import fails closed without overwriting the developer edit.
17
+
18
+ The model in this demo is deterministic and scripted. That keeps the proof focused on control-plane behavior rather than model quality, latency, cost, or prompt-following variance.
19
+
20
+ ## Prerequisites
21
+
22
+ - Bun 1.3.7 or newer;
23
+ - Docker or Podman running locally; and
24
+ - the configured image already present locally.
25
+
26
+ The default command uses Docker and `oven/bun:1.3.7-slim`:
27
+
28
+ ```bash
29
+ bun install --frozen-lockfile
30
+ docker pull oven/bun:1.3.7-slim
31
+ bun run build
32
+ bun run demo:hostile
33
+ ```
34
+
35
+ Use the existing OCI environment variables to select Podman, a different preloaded image, or narrower limits. The harness never pulls an image implicitly.
36
+
37
+ ## Expected evidence
38
+
39
+ Progress is written to stderr. A successful run writes one JSON document to stdout:
40
+
41
+ ```json
42
+ {
43
+ "schemaVersion": 1,
44
+ "kind": "hostile-repository-demo",
45
+ "ok": true,
46
+ "runId": "hostile-demo-approved",
47
+ "approvals": [
48
+ "run_environment_command",
49
+ "apply_environment_patch"
50
+ ],
51
+ "persistenceReopens": 2,
52
+ "secretExcluded": true,
53
+ "networkDenied": true,
54
+ "hostUnchangedUntilApprovedImport": true,
55
+ "exactlyOnceJournal": true,
56
+ "staleHostImportBlocked": true,
57
+ "redactedLedger": true
58
+ }
59
+ ```
60
+
61
+ The output also includes the immutable image digest used for the proof. Pass `--keep` to retain the disposable workspace and print its location:
62
+
63
+ ```bash
64
+ bun run demo:hostile --keep
65
+ ```
66
+
67
+ The kept directory contains only fixture data and harness-owned evidence. Remove it when inspection is complete.
68
+
69
+ ## Ninety-second recording outline
70
+
71
+ 1. Show the hostile README and decoy `.env` fixture description.
72
+ 2. Run `bun run demo:hostile`.
73
+ 3. Highlight the first command approval and SQLite reopen.
74
+ 4. Highlight `secretExcluded` and `networkDenied` from the OCI result.
75
+ 5. Show that the host file stays unchanged until the separate import approval.
76
+ 6. Highlight the completed exactly-once journal and redacted ledger.
77
+ 7. End on the rejected stale-host import and the final JSON proof.
78
+
79
+ Suggested title: **Can your coding agent survive a hostile repository?**
80
+
81
+ ## Live provider follow-up
82
+
83
+ The deterministic demo does not certify model-directed tool use. The billable live gate separately requires Meta, Qwen, and OpenAI to choose the exact OCI command, inspect the resulting patch, preserve both approvals, and import it:
84
+
85
+ ```bash
86
+ ZHIVEX_HARNESS_LIVE=1 bun run smoke:live:execution
87
+ ```
88
+
89
+ Provider evidence is date-, model-, endpoint-, account-, and credential-dependent. See [LIVE_CERTIFICATION.md](./LIVE_CERTIFICATION.md).
90
+
91
+ ## Evidence limits
92
+
93
+ - Docker/Podman containers are not virtual machines or a managed hostile-code sandbox.
94
+ - The demo proves the documented policy against its exact fixture, runtime, image, and platform; it does not prove that arbitrary untrusted code is harmless.
95
+ - A redacted operational export is a defensive boundary, not a substitute for controlling prompts, repository eligibility, or operator access.
96
+ - The demo auto-approves only after asserting the expected pending operation inside a disposable fixture. Production operators should review each approval or use `--yes` only in an intentionally disposable environment.
97
+ - Coding quality and broad task success belong to separate evaluation and live-provider gates.
@@ -42,7 +42,7 @@ Optional model overrides are:
42
42
 
43
43
  Endpoint, Qwen workspace, and Qwen region overrides use the normal `META_BASE_URL`, `QWEN_BASE_URL`, `QWEN_WORKSPACE_ID`, `QWEN_REGION`, and `OPENAI_BASE_URL` variables.
44
44
 
45
- The separate `0.5.x` delegation matrix uses the same opt-in, provider selection, credentials, and model overrides:
45
+ The separate delegation matrix uses the same opt-in, provider selection, credentials, and model overrides:
46
46
 
47
47
  ```bash
48
48
  ZHIVEX_HARNESS_LIVE=1 bun run smoke:live:orchestration
@@ -82,7 +82,7 @@ The complete delegation matrix passed at `2026-08-17T02:21:45.553Z`. Each provid
82
82
 
83
83
  This certifies the bounded reviewer-delegation path, not arbitrary task quality or every subagent profile.
84
84
 
85
- The separate controlled MCP interoperability gate passed at `2026-08-17T13:05:05.542Z` against a real loopback Streamable HTTP server. It exercised protocol `2025-06-18`, authorization and protocol headers, session negotiation, `initialize`, `notifications/initialized`, `tools/list`, `tools/call`, JSON and SSE responses, schema-backed discovery, bounded output, and the forced interrupt-approval policy for network tools. Run it with:
85
+ The separate controlled MCP interoperability gate passed at `2026-08-17T16:48:09.043Z` against a real loopback Streamable HTTP server. It exercised protocol `2025-06-18`, authorization and protocol headers, session negotiation, `initialize`, `notifications/initialized`, `tools/list`, `tools/call`, JSON and SSE responses, schema-backed discovery, bounded output, and the forced interrupt-approval policy for network tools. Run it with:
86
86
 
87
87
  ```bash
88
88
  bun run smoke:mcp
@@ -90,6 +90,49 @@ bun run smoke:mcp
90
90
 
91
91
  This is stronger than an injected `fetch` fixture because it uses the operating system network stack and a running server. It certifies the harness transport contract against the controlled implementation; it does not claim compatibility with every third-party MCP server or unsupported `stdio` transport.
92
92
 
93
+ ## 0.6.0 execution and interoperability status
94
+
95
+ `0.6.0` adds a third, independent MCP transport gate implemented with the official `@modelcontextprotocol/server@2.0.0` package. It passed at `2026-08-17T16:48:09.141Z` over a real loopback Streamable HTTP endpoint. The harness negotiated its supported `2025-06-18` protocol through the server's documented legacy-stateless compatibility mode, discovered one schema-backed tool, preserved the mandatory network approval, called it exactly once, and validated the bounded response.
96
+
97
+ ```bash
98
+ bun run smoke:mcp:official
99
+ ```
100
+
101
+ This is interoperability evidence for that exact SDK version and compatibility mode, not a claim that the harness implements the newer `2026-07-28` wire protocol or every official SDK feature.
102
+
103
+ Enforced execution has separate evidence layers:
104
+
105
+ - deterministic injected-runtime tests for environment/session semantics;
106
+ - installed-package proof for the exported execution API;
107
+ - `ZHIVEX_HARNESS_OCI_REQUIRED=1 bun run smoke:oci` for the real Docker/Podman boundary;
108
+ - billable provider matrices for model-directed tools and delegation.
109
+
110
+ The final real Docker gate passed on macOS/Docker Desktop at `2026-08-17T16:48Z` with Docker `29.7.2` and image digest `sha256:b7d0366ff1c11bd3897aeaca2e3d215ee1e5902932073434ffc9186ca0a3ac96`. It verified secret exclusion, denied outbound network, a read-only root, total-workspace and changed-file quotas, read-only dependency reuse without snapshot persistence, the configured cgroup PID ceiling under a spawn burst, memory exhaustion containment, combined-output termination, prompt cancellation with immediate container removal, transactional snapshot publication, isolated package checks, approved host patch import, terminal artifact cleanup, and zero remaining harness-labeled containers or volumes.
111
+
112
+ The live workflow requires this real OCI gate before provider execution. Date-bound model-directed environment results are recorded only after the provider commands complete; implementation, credential presence, or the container result alone is not provider certification.
113
+
114
+ The billable model-directed matrix is:
115
+
116
+ ```bash
117
+ ZHIVEX_HARNESS_LIVE=1 bun run smoke:live:execution
118
+ ```
119
+
120
+ For each selected provider it requires exactly one approved argv-only environment command, one patch inspection, and one separately approved host import. It verifies exact tool order, durable journal completion, host contents, image/environment binding, and the provider-specific completion token.
121
+
122
+ The complete Meta/Qwen/OpenAI enforced-execution matrix passed together against the final quota-backed workspace implementation at `2026-08-17T16:49:12.975Z` and image digest `sha256:b7d0366ff1c11bd3897aeaca2e3d215ee1e5902932073434ffc9186ca0a3ac96`.
123
+
124
+ | Provider | Model | Result | Evidence |
125
+ | --- | --- | --- | --- |
126
+ | Meta | `muse-spark-1.2` | Certified | One approved OCI command, one patch inspection, one separately approved import, exact host contents, and environment binding. |
127
+ | Qwen | `qwen3.8-max` | Certified | One approved OCI command, one patch inspection, one separately approved import, exact host contents, and environment binding. |
128
+ | OpenAI | `gpt-5.4` | Certified | Responses mode persisted across both approval continuations; exact OCI tool order, host import, journal, and binding passed. |
129
+
130
+ The base proposal/approval/process-restart matrix passed again for all three providers at `2026-08-17T16:22:34.885Z`. The reviewer-delegation/child-persistence/SQLite-reopen/hierarchy/aggregate-budget matrix passed again at `2026-08-17T16:24:14.381Z`. These refreshes cover the `0.6.0` dependency and harness artifact; registry publication is proved separately.
131
+
132
+ The full deterministic gate then passed with 99 tests, 468 assertions, seven golden evaluations, both MCP implementations, real OCI, and installed-package smoke. The exact 31-file tarball passed SHA-512 inspection and isolated consumer execution. `@zhivex-ai/harness@0.6.0` was subsequently published through the protected OIDC workflow; on 2026-08-17 America/Argentina/Buenos_Aires, the downloaded registry tarball, `latest` tag, integrity, SLSA subject, repository, workflow, branch, and source commit were verified against `fd420f7560b2`.
133
+
134
+ `0.6.1` does not change provider, tool, approval, execution, or streaming behavior, so it inherits this date-bound provider evidence subject to the normal exact-artifact and registry release gates. Its new hostile-repository demo is deterministic control-plane evidence, not a substitute for the billable provider matrix.
135
+
93
136
  ## 0.3.0 private-milestone evidence
94
137
 
95
138
  Evidence collected on 2026-08-16 with the default models and locally configured account. After aligning the gate with the required proposal-first workflow, Qwen and OpenAI passed together at `2026-08-16T23:37:23.791Z`. After upgrading to `@zhivex-ai/meta@0.2.1`, Meta passed four consecutive runs from `2026-08-16T23:32:50.716Z` through `2026-08-16T23:33:27.161Z`.
package/docs/RELEASE.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Release process
2
2
 
3
- `@zhivex-ai/harness@0.5.0` is configured as a public npm package, but publication is never performed from a development checkout. The confirmation-gated `.github/workflows/release.yml` workflow builds, inspects, transfers, and publishes one exact tarball. Creating a tag alone does not publish anything.
3
+ `@zhivex-ai/harness@0.6.0` is public on npm with exact registry integrity and SLSA workflow provenance verified against source tag `v0.6.0`. `0.6.1` is the next source candidate, but publication is never performed from a development checkout. The confirmation-gated `.github/workflows/release.yml` workflow builds, inspects, transfers, and publishes one exact tarball through npm Trusted Publishing/OIDC. Creating a tag alone does not publish anything.
4
4
 
5
5
  ## Deterministic gates
6
6
 
@@ -13,7 +13,7 @@ git diff --check
13
13
  git status --short
14
14
  ```
15
15
 
16
- `bun run release:check` performs documentation validation, typechecking, deterministic tests, the golden evaluation gate, a dependency-externalized build, package-content validation, clean tarball installation, direct binary execution, public import, SQLite restart/resume, redacted inspection, exactly-once side-effect verification, dependency audit, untrusted lifecycle-script inspection, dry-run packing, and release metadata validation.
16
+ `bun run release:check` performs documentation validation, typechecking, deterministic tests, the golden evaluation gate, the required real-OCI boundary gate, a dependency-externalized build, package-content validation, clean tarball installation, direct binary execution, public import, SDK execution-environment import, SQLite restart/resume, redacted inspection, exactly-once side-effect verification, dependency audit, untrusted lifecycle-script inspection, dry-run packing, and release metadata validation.
17
17
 
18
18
  CI repeats the deterministic and installed-package gates on Linux and macOS. Build output is ignored and must not create tracked changes.
19
19
 
@@ -24,9 +24,11 @@ Provider behavior is certified separately because it is credential-, account-, m
24
24
  ```bash
25
25
  ZHIVEX_HARNESS_LIVE=1 bun run scripts/live-provider-smoke.ts
26
26
  ZHIVEX_HARNESS_LIVE=1 bun run smoke:live:orchestration
27
+ ZHIVEX_HARNESS_LIVE=1 bun run smoke:live:execution
28
+ ZHIVEX_HARNESS_OCI_REQUIRED=1 bun run smoke:oci
27
29
  ```
28
30
 
29
- The base reviewed-edit gate and the separate `0.5.x` delegation gate must pass for every provider in the supported release matrix. Integrated provisional providers are reported separately and must not be described as certified. `bun run check` also runs the controlled loopback Streamable HTTP MCP interoperability gate; third-party server claims remain separate. See [LIVE_CERTIFICATION.md](./LIVE_CERTIFICATION.md).
31
+ The base reviewed-edit gate and the separate delegation gate must pass for every provider in the supported release matrix. The `0.6.x` workflow must additionally pass the real OCI boundary before live model execution; model-directed environment use is recorded separately from deterministic container enforcement. Integrated provisional providers are reported separately and must not be described as certified. `bun run check` also runs controlled Streamable HTTP MCP interoperability gates; each external implementation claim remains bounded to the tested server/version. See [LIVE_CERTIFICATION.md](./LIVE_CERTIFICATION.md).
30
32
 
31
33
  ## Exact artifact gate
32
34
 
@@ -46,31 +48,24 @@ For a local artifact rehearsal after the source gate:
46
48
 
47
49
  ```bash
48
50
  mkdir -p release-artifacts
49
- bun pm pack --filename release-artifacts/zhivex-ai-harness-0.5.0.tgz --ignore-scripts
50
- bun run artifact:check -- release-artifacts/zhivex-ai-harness-0.5.0.tgz
51
- bun run smoke:artifact -- release-artifacts/zhivex-ai-harness-0.5.0.tgz
51
+ bun pm pack --filename release-artifacts/zhivex-ai-harness-0.6.1.tgz --ignore-scripts
52
+ bun run artifact:check -- release-artifacts/zhivex-ai-harness-0.6.1.tgz
53
+ bun run smoke:artifact -- release-artifacts/zhivex-ai-harness-0.6.1.tgz
52
54
  ```
53
55
 
54
56
  `release-artifacts/`, `.npmrc`, `.env`, source tests, Git metadata, and local run state are excluded from the package.
55
57
 
56
58
  ## External prerequisites
57
59
 
58
- Before the first dispatch:
60
+ Before a `0.6.1` dispatch, reverify rather than assuming the previous release state:
59
61
 
60
- - make `Zhivex/zhivex-harness` public; npm cannot generate public provenance from a private repository;
62
+ - confirm `Zhivex/zhivex-harness` remains public; npm cannot generate public provenance from a private repository;
61
63
  - enable GitHub private vulnerability reporting;
62
64
  - protect the GitHub `npm` environment with required reviewers and restrict it to `main`/release tags;
63
- - verify an npm account with 2FA can create public packages in the `@zhivex-ai` scope; and
64
- - verify `@zhivex-ai/harness` is still unclaimed.
65
+ - verify an npm account with 2FA still administers the public `@zhivex-ai/harness` package; and
66
+ - confirm the npm Trusted Publisher is organization `Zhivex`, repository `zhivex-harness`, workflow `release.yml`, environment `npm`, allowed action `npm publish`.
65
67
 
66
- The package does not yet exist on npm, and npm requires a package to exist before Trusted Publishing can be configured. For `0.5.0` only, create a temporary granular npm token with the minimum available organization scope, store it as `NPM_TOKEN` in the protected `npm` environment, and remove it immediately after the first successful publication. The workflow still publishes from GitHub Actions with `--provenance`.
67
-
68
- After `0.5.0` exists:
69
-
70
- 1. configure its npm Trusted Publisher as organization `Zhivex`, repository `zhivex-harness`, workflow `release.yml`, environment `npm`, allowed action `npm publish`;
71
- 2. set package publishing access to require 2FA and disallow tokens;
72
- 3. delete the GitHub `NPM_TOKEN` secret and revoke the temporary token; and
73
- 4. use OIDC-only workflow publication for every later version.
68
+ The one-time `0.5.0` bootstrap and the protected `0.6.0` publication are complete: the package exists, Trusted Publishing is configured, and the temporary token was removed/revoked. The release workflow intentionally supplies no `NODE_AUTH_TOKEN` or npm token. Do not reintroduce one as a fallback; a failed OIDC assertion is a stop condition to diagnose.
74
69
 
75
70
  Trusted Publishing currently requires npm CLI `11.5.1` or newer and Node `22.14.0` or newer. The workflow follows npm's current Node 24 guidance and uses npm only for the OIDC/provenance-aware registry transaction; dependency management, build, tests, packing, and artifact installation remain Bun-first.
76
71
 
@@ -79,10 +74,10 @@ Trusted Publishing currently requires npm CLI `11.5.1` or newer and Node `22.14.
79
74
  After the release commit is reviewed, merged, and pushed to `main`:
80
75
 
81
76
  ```bash
82
- git tag -a v0.5.0 -m "Release v0.5.0"
83
- git push origin v0.5.0
77
+ git tag -a v0.6.1 -m "Release v0.6.1"
78
+ git push origin v0.6.1
84
79
  gh workflow run release.yml \
85
- -f tag=v0.5.0 \
80
+ -f tag=v0.6.1 \
86
81
  -f channel=latest \
87
82
  -f confirm_publication=true
88
83
  ```
@@ -100,7 +95,7 @@ Do not dispatch or approve publication when any of these is true:
100
95
  - package scope ownership, 2FA, the intended `public` access level, or the protected environment is unclear;
101
96
  - the inspected package contents and the to-be-published artifact are not the same file;
102
97
  - the package version already exists in npm;
103
- - the temporary first-release credential is broader or longer-lived than necessary;
98
+ - an npm token or `NODE_AUTH_TOKEN` has been reintroduced into the OIDC-only workflow;
104
99
  - Trusted Publishing is expected but its repository, workflow filename, environment, or allowed action disagrees with the workflow; or
105
100
  - version, changelog, tag, registry metadata, source commit, integrity, or provenance disagree.
106
101
 
@@ -82,6 +82,8 @@ Checks do not load the workspace `.env` automatically. A non-zero exit, timeout,
82
82
 
83
83
  `git_diff` is read-only and reports the repository status, unstaged diff, and staged diff as separate results, including renamed, deleted, and untracked paths. `mutation_audit` returns the harness mutation history for the current workspace process.
84
84
 
85
+ With enforced OCI execution, `git_diff` is intentionally omitted from the model tool set because the Git repository remains on the canonical host outside the snapshot boundary. The model reviews `mutation_audit` and the content-bound environment patch instead; the CLI/library result reports canonical host Git evidence after an approved import.
86
+
85
87
  Every mutation audit entry includes an identifier, operation, affected path, timestamp, and the available before/after digest evidence. Move and restore operations may include a destination; quarantine-related entries may include a quarantine identifier.
86
88
 
87
89
  Before completion, an editing run should report:
@@ -115,4 +117,4 @@ The new quarantine and audit state is harness-owned and must remain excluded fro
115
117
  - Git rename detection is heuristic and may display a delete plus add for heavily rewritten content.
116
118
  - Ignore evaluation and filesystem behavior can differ by platform; Linux and macOS fixtures are required release gates.
117
119
  - Quarantine does not replace version control or an external backup.
118
- - Checks execute with the local process permissions. Enforced shell and filesystem isolation is planned for `0.6.0`.
120
+ - With the default `execution=none`, checks use the narrow host check runner and generic shell remains unavailable. With `execution=oci`, repository tools and checks operate on a secret-free snapshot and only a separately approved digest-bound environment patch may change the host workspace.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@zhivex-ai/harness",
3
- "version": "0.5.0",
4
- "description": "Provider-portable coding agent harness powered by Zhivex AI SDK.",
3
+ "version": "0.6.1",
4
+ "description": "Governed, provider-portable runtime for coding agents with durable approvals and isolated repository execution.",
5
5
  "type": "module",
6
6
  "license": "MIT",
7
7
  "repository": {
@@ -21,6 +21,14 @@
21
21
  "ai",
22
22
  "agents",
23
23
  "coding-agent",
24
+ "agent-runtime",
25
+ "agent-governance",
26
+ "sandbox",
27
+ "durable-workflows",
28
+ "mcp",
29
+ "docker",
30
+ "typescript",
31
+ "bun",
24
32
  "harness",
25
33
  "zhivex"
26
34
  ],
@@ -48,7 +56,7 @@
48
56
  "scripts": {
49
57
  "dev": "bun run src/cli.ts",
50
58
  "start": "bun run dist/cli.js",
51
- "build": "bun build ./src/index.ts ./src/cli.ts --outdir ./dist --target bun --packages external && tsc --emitDeclarationOnly",
59
+ "build": "bun build ./src/index.ts ./src/cli.ts --outdir ./dist --target bun --packages external && bun build ./scripts/hostile-repository-demo.ts --outfile ./dist/hostile-repository-demo.js --target bun --packages external && tsc --emitDeclarationOnly",
52
60
  "prepack": "bun run build",
53
61
  "docs:check": "bun run scripts/check-docs.ts",
54
62
  "typecheck": "tsc --noEmit",
@@ -57,24 +65,32 @@
57
65
  "smoke:package": "bun run build && bun run scripts/package-smoke.ts",
58
66
  "smoke:artifact": "bun run scripts/package-smoke.ts",
59
67
  "smoke:mcp": "bun run scripts/mcp-interoperability-smoke.ts",
68
+ "smoke:mcp:official": "bun run scripts/mcp-official-sdk-smoke.ts",
69
+ "smoke:oci": "bun run scripts/oci-execution-smoke.ts",
60
70
  "smoke:live": "bun --env-file=.env run scripts/live-provider-smoke.ts",
61
71
  "smoke:live:orchestration": "bun --env-file=.env run scripts/live-orchestration-smoke.ts",
72
+ "smoke:live:execution": "bun --env-file=.env run scripts/live-execution-smoke.ts",
73
+ "demo:hostile": "bun run dist/hostile-repository-demo.js",
62
74
  "artifact:check": "bun run scripts/check-release-artifact.ts",
63
75
  "pack:inspect": "bun run build && bun pm pack --dry-run --ignore-scripts",
64
- "check": "bun run docs:check && bun run typecheck && bun test && bun run evaluate && bun run smoke:mcp && bun run smoke:package",
76
+ "check": "bun run docs:check && bun run typecheck && bun test && bun run evaluate && bun run smoke:mcp && bun run smoke:mcp:official && bun run smoke:oci && bun run smoke:package",
65
77
  "release:check": "bun run check && bun audit && bun pm untrusted && bun run pack:inspect && bun run scripts/check-release-readiness.ts",
66
78
  "release:status": "bun run scripts/check-registry-release-status.ts",
67
79
  "release:verify": "bun run scripts/verify-registry-release.ts"
68
80
  },
69
81
  "dependencies": {
70
82
  "@zhivex-ai/agents": "1.2.0",
71
- "@zhivex-ai/core": "1.5.0",
83
+ "@zhivex-ai/core": "1.6.0",
72
84
  "@zhivex-ai/meta": "0.2.1",
73
- "@zhivex-ai/openai": "0.9.4",
85
+ "@zhivex-ai/openai": "0.9.5",
74
86
  "@zhivex-ai/qwen": "0.10.1",
75
87
  "zod": "4.4.3"
76
88
  },
89
+ "overrides": {
90
+ "@zhivex-ai/core": "1.6.0"
91
+ },
77
92
  "devDependencies": {
93
+ "@modelcontextprotocol/server": "2.0.0",
78
94
  "@types/bun": "1.3.14",
79
95
  "typescript": "6.0.3"
80
96
  },