@zhivex-ai/harness 0.5.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.
@@ -0,0 +1,136 @@
1
+ # Extensibility and orchestration
2
+
3
+ Zhivex Harness `0.5.x` adds governed external tools and bounded multi-agent work without adding a generic shell or weakening the workspace contract. Configuration schema version `3` binds capability requirements, MCP policy, subagent profiles, child budgets, and scope into the durable harness fingerprint.
4
+
5
+ ## Capability gate
6
+
7
+ Every run requires streaming and callable-tool support by default. Add explicit requirements with repeatable CLI flags:
8
+
9
+ ```bash
10
+ zhivex-harness run \
11
+ --require-capability tools \
12
+ --require-capability structured-output \
13
+ "produce the requested change"
14
+ ```
15
+
16
+ Supported requirement names are `streaming`, `tools`, `structured-output`, `parallel-tools`, `reasoning`, and `web-search`. The instantiated model is inspected before persistence or model execution. An incompatible model fails before entering MCP or subagent discovery. Library callers can use `inspectHarnessModelCapabilities`, `assertHarnessModelCapabilities`, and `selectHarnessModel` for deterministic candidate routing.
17
+
18
+ Capability acceptance is model-specific. A provider label or compatible endpoint does not imply every model supports the requested contract.
19
+
20
+ ## Declarative MCP configuration
21
+
22
+ Pass a regular JSON file inside the canonical workspace:
23
+
24
+ ```bash
25
+ zhivex-harness run --mcp-config examples/mcp-config.json "consult the approved documentation tool"
26
+ ```
27
+
28
+ The schema is versioned independently:
29
+
30
+ ```json
31
+ {
32
+ "schemaVersion": 1,
33
+ "servers": [
34
+ {
35
+ "name": "docs",
36
+ "transport": "http",
37
+ "url": "https://mcp.example.com/rpc",
38
+ "includeTools": ["search_docs", "read_page"],
39
+ "permissions": ["read", "network"],
40
+ "headerEnv": { "x-api-key": "DOCS_MCP_API_KEY" },
41
+ "callToolTimeoutMs": 30000,
42
+ "maxOutputBytes": 262144
43
+ }
44
+ ]
45
+ }
46
+ ```
47
+
48
+ Every server requires a non-empty tool allowlist and permission set. Tool discovery is paginated and bounded. Tool names are prefixed with `<server>_` unless an explicit safe prefix is supplied. Configuration contains environment-variable names rather than credential values; diagnostics and fingerprints never include resolved header values.
49
+
50
+ The built-in transport supports HTTPS and loopback HTTP. Redirects, URL credentials, unsafe configurable headers, oversized configuration, symlinked configuration, and configuration outside the workspace are rejected. `stdio` is intentionally unavailable because spawning an MCP server is process execution; it remains deferred until the enforced execution environment in `0.6.x`.
51
+
52
+ Library callers can inject a custom `McpClient`. Trusted read-only annotations are accepted only for an explicitly injected custom transport whose sole declared permission is `read`. HTTP always declares `network` and therefore always pauses for operator approval, even when a server claims a tool is read-only.
53
+
54
+ ## MCP result boundary
55
+
56
+ MCP descriptions and results are untrusted. The harness:
57
+
58
+ - bounds discovery pages, discovered tools, time, and response bytes;
59
+ - validates declared input and structured-output schemas through the SDK MCP registry;
60
+ - propagates abort signals, timeout intent, and idempotency keys;
61
+ - rejects common prompt-injection directives before they enter model context;
62
+ - records server permissions and risk in tool metadata;
63
+ - promotes network, write, or external-side-effect calls to durable interrupt approval.
64
+
65
+ The injection filter is deliberately conservative and may reject legitimate security documentation containing imperative attack text. Use a separate trusted preprocessing boundary if that content must be analyzed; do not disable the harness boundary for an untrusted server.
66
+
67
+ ## Named subagent profiles
68
+
69
+ Four profiles are enabled by default:
70
+
71
+ | Profile | Purpose | Tools |
72
+ | --- | --- | --- |
73
+ | `explorer` | Repository discovery and evidence | Read-only workspace inspection |
74
+ | `implementer` | One bounded implementation task | Workspace tools; mutations remain approval-gated |
75
+ | `tester` | Focused verification | Read-only inspection plus approved Bun checks |
76
+ | `reviewer` | Independent correctness/security review | Read-only diff and audit inspection |
77
+
78
+ Select an explicit subset with repeatable flags:
79
+
80
+ ```bash
81
+ zhivex-harness run \
82
+ --subagent explorer \
83
+ --subagent reviewer \
84
+ "analyze the persistence boundary"
85
+ ```
86
+
87
+ The parent receives `delegate_explorer`, `delegate_implementer`, `delegate_tester`, and `delegate_reviewer` tools for the enabled profiles. Delegation is model-directed only when the parent invokes one of these tools. A child inherits the canonical workspace, durable scope, store, memory, cancellation boundary, approval policy, and telemetry observer. Each child has its own harness fingerprint, lease, state limit, timeout, step/tool/error/token budget, and run ID.
88
+
89
+ Child mutations and checks do not inherit an approval automatically. A paused child approval is promoted to the parent as `kind: "subagent"`; approving the parent resumes the same durable child checkpoint. Completed child tools are protected by the shared exactly-once journal.
90
+
91
+ ## Budgets and cancellation
92
+
93
+ Defaults per child are 8 steps, 16 tool calls, 3 tool errors, 30,000 input tokens, 8,000 output tokens, 36,000 total tokens, and a five-minute timeout. Override them with the `--subagent-*` options or matching `ZHIVEX_HARNESS_SUBAGENT_*` variables.
94
+
95
+ The child enforces its independent budget with `includeChildRuns: false`. The parent budget retains `includeChildRuns: true`, so child consumption also counts against the aggregate ceiling. Token ceilings are enforced after each provider step to avoid reserving the entire parent allowance again after a child has consumed tokens; measured usage can cross a ceiling by one provider step.
96
+
97
+ Use cascade cancellation to finalize a parent and every persisted child:
98
+
99
+ ```bash
100
+ zhivex-harness runs cancel <parentRunId> --cascade --final --reason "superseded"
101
+ ```
102
+
103
+ ## Application-owned parallel review
104
+
105
+ `review` runs deterministic application-owned parallel review instead of asking a model to decide the topology:
106
+
107
+ ```bash
108
+ zhivex-harness review \
109
+ --reviewer explorer \
110
+ --reviewer reviewer \
111
+ --json \
112
+ "review the durable approval boundary"
113
+ ```
114
+
115
+ Only the read-only `explorer` and `reviewer` profiles are accepted. The default concurrency ceiling is two and the hard maximum is four. Each member is a durable child with a shared group parent identifier. A member failure is reported without silently discarding the other independent result.
116
+
117
+ ## Progress and JSON
118
+
119
+ Human terminal mode reports child start and finish telemetry. `run-result` JSON includes capability evidence, configured MCP server names, enabled profiles, child run IDs/status/usage, promoted approval identity, and the aggregate budget. `review-group` JSON includes the group ID and one bounded result per member. `runs inspect` adds the redacted hierarchical trace while continuing to omit raw messages, tool inputs/outputs, approval arguments, metadata, and full output text.
120
+
121
+ ## Migration from 0.4.x
122
+
123
+ - Configuration schema `2` becomes schema `3`; remove a pinned `schemaVersion: 2` or migrate it to `3` after reviewing capability, MCP, and subagent defaults.
124
+ - Named subagents are enabled by default. Pass an empty `subagentProfiles` array from the library, or set `ZHIVEX_HARNESS_SUBAGENTS=` for a parent-only run.
125
+ - The harness fingerprint now includes required capabilities, child policy, profile selection, and normalized MCP configuration. A paused `0.4.x` run with an existing fingerprint must be completed with the `0.4.x` binary; it is not silently rebound to `0.5.x`.
126
+ - Existing scoped SQLite data remains readable. No database rewrite is required.
127
+ - MCP configuration must be placed inside the workspace and must not contain raw secrets.
128
+
129
+ ## Known limits
130
+
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
+ - MCP prompt-injection detection is a safety filter, not a proof that remote content is trustworthy.
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.
136
+ - Provider-specific orchestration behavior requires date-bound live certification and is separate from deterministic implementation evidence.
@@ -0,0 +1,117 @@
1
+ # Live provider certification
2
+
3
+ The live provider smoke is an explicit release gate. It is not part of the deterministic unit-test suite because it makes billable upstream requests.
4
+
5
+ ## What it proves
6
+
7
+ For each selected provider, the smoke:
8
+
9
+ 1. starts a fresh process and asks the real model to create one exact digest-bound proposal and apply that returned proposal;
10
+ 2. verifies that interrupt approval persists while the target file is still absent;
11
+ 3. exits that process and starts a second process against the same scoped SQLite run store;
12
+ 4. approves and resumes the saved run;
13
+ 5. verifies the completion token, one successful patch result, one completed tool-journal entry, and the exact file contents.
14
+
15
+ The temporary workspace and state store are removed after each provider. Credential values are never written to output, prompts, fixtures, or results. Error output is redacted against every configured provider credential, custom endpoint, and Qwen workspace identifier before it is printed.
16
+
17
+ Success and failure evidence is emitted as JSON. A success record identifies the provider and model and records the approval, restart, tool-execution, and journal checks; it never contains a credential value. The complete default matrix continues after an individual provider failure, reports every provider result, and exits non-zero when any entry fails.
18
+
19
+ Meta supports only automatic tool choice, and Qwen 3.8 thinking cannot use named or required tool choice. The complete matrix therefore uses automatic selection and an exact two-tool prompt: `propose_edits` must run first, and its returned `proposalId` must then be passed unchanged to `apply_patch`. Qwen and OpenAI run through Responses. Qwen Responses cannot accept `maxTokens`, so the harness enforces Qwen token budgets before and after each provider step without transporting that ceiling upstream; one step can cross the measured limit before the output guard observes it. Meta intentionally runs through Chat streaming to cover the fragmented tool-call assembler fixed in `@zhivex-ai/meta@0.2.1`.
20
+
21
+ ## Run it
22
+
23
+ Keep provider credentials in the repository `.env`; Bun loads that file when the script starts. The gate refuses to make requests without the explicit opt-in variable:
24
+
25
+ ```bash
26
+ ZHIVEX_HARNESS_LIVE=1 bun run scripts/live-provider-smoke.ts
27
+ ```
28
+
29
+ The default gate requires and tests Meta, Qwen, and OpenAI. To certify one provider while diagnosing an upstream or account issue:
30
+
31
+ ```bash
32
+ ZHIVEX_HARNESS_LIVE=1 \
33
+ ZHIVEX_HARNESS_LIVE_PROVIDERS=qwen \
34
+ bun run scripts/live-provider-smoke.ts
35
+ ```
36
+
37
+ Optional model overrides are:
38
+
39
+ - `ZHIVEX_HARNESS_LIVE_META_MODEL`
40
+ - `ZHIVEX_HARNESS_LIVE_QWEN_MODEL`
41
+ - `ZHIVEX_HARNESS_LIVE_OPENAI_MODEL`
42
+
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
+
45
+ The separate `0.5.x` delegation matrix uses the same opt-in, provider selection, credentials, and model overrides:
46
+
47
+ ```bash
48
+ ZHIVEX_HARNESS_LIVE=1 bun run smoke:live:orchestration
49
+ ```
50
+
51
+ For every provider it requires exactly one `delegate_reviewer` call, verifies the bounded child response and aggregate token accounting, closes and reopens SQLite, and confirms the persisted parent/child link through the redacted hierarchical inspection. It does not make the legacy reviewed-edit smoke pass through delegation.
52
+
53
+ Certification evidence is date-bound and account-bound. A local deterministic pass, installed-package pass, or one provider's live pass does not certify the other providers.
54
+
55
+ Because `0.4.0` adds the production safety policy, harness binding, scoped SQLite persistence, required leases, budgets, and exactly-once journal recovery, `0.3.0` live evidence does not certify the new runtime path. The supported providers must pass the refreshed `apply_patch` approval/restart gate before the private milestone is considered complete.
56
+
57
+ ## 0.4.0 private-milestone evidence
58
+
59
+ Evidence collected on 2026-08-17 with the default models and locally configured account. The complete matrix passed together at `2026-08-17T00:53:17.752Z` against the final scoped SQLite, fingerprint, and production-policy candidate.
60
+
61
+ | Provider | Model | Result | Evidence |
62
+ | --- | --- | --- | --- |
63
+ | Meta | `muse-spark-1.2` | Certified | Approval persisted in scoped SQLite, the process restarted, and exactly one patch execution and completed journal entry were observed. |
64
+ | Qwen | `qwen3.8-max` | Certified | Responses completed the proposal-first workflow with durable token enforcement, process restart, and exactly-once patch journaling. |
65
+ | OpenAI | `gpt-5.4` | Certified | Responses completed the proposal-first workflow with an upstream-compatible output ceiling, process restart, and exactly-once patch journaling. |
66
+
67
+ This evidence certifies provider interaction for the private `0.4.0` candidate only. It does not prove registry publication, provenance, or availability of a public artifact.
68
+
69
+ ## 0.5.0 orchestration status
70
+
71
+ The `0.4.0` matrix remains valid evidence for the shared proposal, approval, SQLite restart, and exactly-once patch path, but it does not certify model-directed delegation or provider behavior with the expanded MCP/subagent tool surface.
72
+
73
+ `0.5.0` has deterministic evidence for capability rejection, MCP discovery/approval/resume, prompt-injection and output bounds, durable child approval promotion, exactly-once child mutation, cancellation propagation, scoped hierarchical inspection, aggregate budgets, and application-owned parallel review.
74
+
75
+ The complete delegation matrix passed at `2026-08-17T02:21:45.553Z`. Each provider made exactly one model-directed `delegate_reviewer` call, completed the bounded child, accounted for aggregate tokens, persisted parent and child, reopened SQLite, and exposed a redacted two-run hierarchy.
76
+
77
+ | Provider | Model | Result | Evidence |
78
+ | --- | --- | --- | --- |
79
+ | Meta | `muse-spark-1.2` | Certified | One reviewer delegation completed; parent and child survived reopen with a two-run hierarchy and aggregate usage. |
80
+ | Qwen | `qwen3.8-max` | Certified | Responses parent delegation and generated child output completed; persistence, hierarchy, and aggregate usage passed. |
81
+ | OpenAI | `gpt-5.4` | Certified | Responses parent delegation and generated child output completed; persistence, hierarchy, and aggregate usage passed. |
82
+
83
+ This certifies the bounded reviewer-delegation path, not arbitrary task quality or every subagent profile.
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:
86
+
87
+ ```bash
88
+ bun run smoke:mcp
89
+ ```
90
+
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
+
93
+ ## 0.3.0 private-milestone evidence
94
+
95
+ 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`.
96
+
97
+ | Provider | Model | Result | Evidence |
98
+ | --- | --- | --- | --- |
99
+ | Qwen | `qwen3.8-max` | Certified | Digest-bound patch approval persisted, the process restarted, and exactly one patch execution and completed journal entry were observed. |
100
+ | OpenAI | `gpt-5.4` | Certified | Digest-bound patch approval persisted through Responses, the process restarted, and exactly one patch execution and completed journal entry were observed. |
101
+ | Meta | `muse-spark-1.2` | Certified | Four consecutive proposal-first runs produced complete tool arguments, persisted approval, restarted the process, and observed exactly one patch execution and completed journal entry. |
102
+
103
+ The supported `0.3.0` live matrix is Meta, Qwen, and OpenAI. Earlier Meta failures remain relevant historical evidence: `@zhivex-ai/meta@0.2.0` split one streamed Chat tool call across `id` and `index` buffers, while a direct-apply smoke prompt could also be rejected because it skipped `propose_edits`. The adapter and gate now cover those separate failures.
104
+
105
+ ## 0.2.0 release-candidate evidence
106
+
107
+ Evidence collected on 2026-08-16 with the default models and the locally configured account:
108
+
109
+ The supported Qwen/OpenAI matrix passed again at `2026-08-16T19:47:49.773Z` after the final release-candidate changes.
110
+
111
+ | Provider | Model | Result | Evidence |
112
+ | --- | --- | --- | --- |
113
+ | Qwen | `qwen3.8-max` | Certified | Approval persisted, process restarted, one tool execution, and one completed journal entry. |
114
+ | OpenAI | `gpt-5.4` | Certified | Approval persisted, process restarted, one tool execution, and one completed journal entry through Responses. |
115
+ | Meta | `muse-spark-1.2` | Provisional | One isolated run completed the full path, but the complete-matrix rerun emitted an empty `{}` argument object for `write_file`; schema validation failed closed before any side effect. |
116
+
117
+ The supported `0.2.0` release matrix is therefore Qwen and OpenAI. Meta remains integrated but provisional until the automatic tool-call path passes repeatably. The failed Meta attempt did not write a file or consume an approval.
@@ -0,0 +1,107 @@
1
+ # Release process
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.
4
+
5
+ ## Deterministic gates
6
+
7
+ From a clean checkout on `main`:
8
+
9
+ ```bash
10
+ bun install --frozen-lockfile --ignore-scripts
11
+ bun run release:check
12
+ git diff --check
13
+ git status --short
14
+ ```
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.
17
+
18
+ CI repeats the deterministic and installed-package gates on Linux and macOS. Build output is ignored and must not create tracked changes.
19
+
20
+ ## Live gate
21
+
22
+ Provider behavior is certified separately because it is credential-, account-, model-, endpoint-, and date-dependent:
23
+
24
+ ```bash
25
+ ZHIVEX_HARNESS_LIVE=1 bun run scripts/live-provider-smoke.ts
26
+ ZHIVEX_HARNESS_LIVE=1 bun run smoke:live:orchestration
27
+ ```
28
+
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).
30
+
31
+ ## Exact artifact gate
32
+
33
+ The release workflow performs this sequence across an unprivileged validation job and a protected publication job:
34
+
35
+ 1. check out an existing annotated `v<package-version>` tag with complete history;
36
+ 2. prove that the tag resolves to `main`, the worktree is clean, and the version is absent from npm;
37
+ 3. run the complete Bun release gate;
38
+ 4. create one tarball with `bun pm pack --ignore-scripts`;
39
+ 5. allow only the documented package roots, verify the packed manifest, and write `SHA512SUMS`;
40
+ 6. install that same tarball in an isolated consumer and execute its CLI and public API;
41
+ 7. transfer only the tarball and `SHA512SUMS` into the `npm` environment, then revalidate the checksum and artifact contract;
42
+ 8. pass that same file to the npm CLI for the registry transaction; and
43
+ 9. retry through registry propagation, then verify the distribution tag, byte-identical SHA-512 integrity, and SLSA subject/repository/workflow/branch/commit evidence.
44
+
45
+ For a local artifact rehearsal after the source gate:
46
+
47
+ ```bash
48
+ 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
52
+ ```
53
+
54
+ `release-artifacts/`, `.npmrc`, `.env`, source tests, Git metadata, and local run state are excluded from the package.
55
+
56
+ ## External prerequisites
57
+
58
+ Before the first dispatch:
59
+
60
+ - make `Zhivex/zhivex-harness` public; npm cannot generate public provenance from a private repository;
61
+ - enable GitHub private vulnerability reporting;
62
+ - 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
+
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.
74
+
75
+ 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
+
77
+ ## Tag and dispatch
78
+
79
+ After the release commit is reviewed, merged, and pushed to `main`:
80
+
81
+ ```bash
82
+ git tag -a v0.5.0 -m "Release v0.5.0"
83
+ git push origin v0.5.0
84
+ gh workflow run release.yml \
85
+ -f tag=v0.5.0 \
86
+ -f channel=latest \
87
+ -f confirm_publication=true
88
+ ```
89
+
90
+ The boolean confirmation is intentional because npm versions are immutable. The `npm` environment should add a second human approval boundary. Do not use `bun publish`, a local npm session, or a manual registry upload as an alternate path.
91
+
92
+ If npm accepted the immutable version but the post-publication verifier failed during propagation, rerun only the failed `publish` job. It downloads the already validated artifact, skips `npm publish` only when the registry version has byte-identical integrity, and repeats the registry/provenance verification. Never rebuild, bump, or republish the same version to recover a post-publication false negative.
93
+
94
+ ## Publication stop conditions
95
+
96
+ Do not dispatch or approve publication when any of these is true:
97
+
98
+ - the repository is not public, the tag is not annotated, the tagged commit is not on `main`, or the worktree used to create it was dirty;
99
+ - deterministic, installed-artifact, required live-provider, or release-artifact evidence failed;
100
+ - package scope ownership, 2FA, the intended `public` access level, or the protected environment is unclear;
101
+ - the inspected package contents and the to-be-published artifact are not the same file;
102
+ - the package version already exists in npm;
103
+ - the temporary first-release credential is broader or longer-lived than necessary;
104
+ - Trusted Publishing is expected but its repository, workflow filename, environment, or allowed action disagrees with the workflow; or
105
+ - version, changelog, tag, registry metadata, source commit, integrity, or provenance disagree.
106
+
107
+ Current npm requirements should be revalidated against the official [Trusted Publishing guide](https://docs.npmjs.com/trusted-publishers/), [provenance guide](https://docs.npmjs.com/generating-provenance-statements/), and [Bun packaging documentation](https://bun.com/docs/pm/cli/publish) before any registry mutation.
@@ -0,0 +1,118 @@
1
+ # Trusted repository editing
2
+
3
+ Zhivex Harness `0.3.x` adds conflict-safe multi-file editing while preserving the `0.2.x` workspace boundary. Discovery is read-only. Every mutation requires interrupt approval, validates the content the operator reviewed, and produces an audit entry.
4
+
5
+ ## Safety model
6
+
7
+ Repository editing does not grant arbitrary shell access or Git write access. The harness never stages, commits, resets, pushes, or permanently deletes a file on behalf of the model.
8
+
9
+ The following rules apply to every operation:
10
+
11
+ - paths are workspace-relative and must remain inside the canonical workspace;
12
+ - symbolic-link escapes and special files are rejected;
13
+ - hierarchical `.gitignore` files, `.zhivex-harnessignore`, built-in build/state exclusions, and hard secret exclusions are applied during discovery;
14
+ - hard secret exclusions such as `.env`, `.npmrc`, private keys, Git internals, and harness state cannot be re-enabled by an ignore rule;
15
+ - output, file size, page size, check, and execution-time limits remain bounded;
16
+ - writes, moves, quarantine operations, restores, and checks require an interruptible approval.
17
+
18
+ These controls prevent silent workspace drift; they do not isolate the host. Run autonomous work in a disposable workspace or enforced environment.
19
+
20
+ ## Discovery and digests
21
+
22
+ `list_files` and `search_files` return deterministic pages. Each response includes `truncated` and, when another page exists, an opaque `nextCursor`. Supply that cursor unchanged to request the next page. A cursor is bound to the original operation and parameters; it must not be edited or reused for a different path, query, case-sensitivity setting, or page size.
23
+
24
+ Listed files and every search match include a content digest. `read_file` also returns the digest of the complete file, even when only a line range was requested. Digests are the concurrency contract for later edits: reading content and then editing it without carrying the observed digest does not provide stale-workspace protection.
25
+
26
+ Ignore rules affect discovery, not direct authorization. A direct request for a hard-protected path still fails. An ignored ordinary source file can only be addressed when the workspace policy explicitly permits the direct operation.
27
+
28
+ ## Propose and apply
29
+
30
+ Multi-file edits use two phases:
31
+
32
+ 1. `propose_edits` receives the intended final content for every target plus the digest observed during inspection. Use `expectedDigest: null` only when the target must not exist.
33
+ 2. The proposal result identifies the canonical proposal and summarizes every target without modifying the workspace.
34
+ 3. `apply_patch` repeats the reviewed changes and proposal identifier. The harness verifies the canonical proposal, rechecks every precondition, and pauses for approval before writing.
35
+ 4. If any target was created, removed, replaced, or otherwise changed after inspection, the complete apply is rejected as stale before publishing the proposed changes.
36
+
37
+ Successful file replacement uses same-directory staging and atomic per-file publication. Every target is preflighted before publication begins, existing file modes are preserved, and a new file receives the harness default regular-file mode. If later publication fails, the harness attempts to roll back the already-published targets and reports the failure. The patch result contains the proposal identifier and one mutation audit entry per changed path.
38
+
39
+ Structured editing documents use schema version `1`:
40
+
41
+ | Tool | `kind` | Payload |
42
+ | --- | --- | --- |
43
+ | `propose_edits` | `edit-proposal` | `proposalId`, `digestAlgorithm`, and redacted change summaries. |
44
+ | `apply_patch` | `patch-result` | Workspace mutation result. |
45
+ | `move_file` | `move-result` | Workspace move result. |
46
+ | `quarantine_file` | `quarantine-result` | Workspace quarantine result and recovery identifier. |
47
+ | `restore_file` | `restore-result` | Workspace restore result. |
48
+ | `mutation_audit` | `mutation-audit` | Mutation audit entries for this harness instance. |
49
+ | `git_diff` | `workspace-diff` | Status, diff evidence, and mutation audit entries. |
50
+
51
+ The proposal document never returns file contents. Its `proposalId` binds the normalized paths, expected digests, resulting content digests, and byte counts that were reviewed.
52
+
53
+ `expectedDigest` is not an optional optimization. It distinguishes three cases:
54
+
55
+ | Value | Required precondition |
56
+ | --- | --- |
57
+ | Existing file digest | The regular file must still contain exactly the inspected bytes. |
58
+ | `null` | The path must still be absent. |
59
+ | Missing field | Invalid mutation request. |
60
+
61
+ The harness does not merge conflicting edits. Reinspect the file, review the new content, and create a new proposal.
62
+
63
+ The terminal prints the complete `apply_patch` approval arguments rather than truncating them, including when a paused run is resumed. This is intentionally more verbose than other approvals: approving a patch confirms the exact final contents shown. `--yes` bypasses interactive review and should only be used in a disposable or isolated workspace.
64
+
65
+ ## Move, quarantine, and restore
66
+
67
+ `move_file` requires the current source digest and a destination that does not already exist. It preserves the regular-file mode and records both paths. It does not invoke `git mv`; Git detects the resulting rename from repository contents.
68
+
69
+ `quarantine_file` requires the current digest and moves the file into harness-owned state. The result includes a `quarantineId` used for recovery. The model has no permanent-delete tool.
70
+
71
+ `restore_file` accepts a quarantine identifier and an optional workspace destination. Restore is conflict-safe: it never overwrites an existing destination, and an optional expected digest can bind the operation to the quarantined bytes the operator reviewed. A successful restore is recorded independently from the quarantine operation.
72
+
73
+ Quarantine is a recovery boundary, not a backup system. Retention and permanent cleanup remain operator responsibilities. Do not manually edit quarantine manifests or payloads while a run is active.
74
+
75
+ ## Checks
76
+
77
+ Checks remain explicit package scripts executed through Bun. `test`, `typecheck`, `lint`, and `build` are the default allowlist. `--allow-check` and `ZHIVEX_HARNESS_ALLOWED_CHECKS` replace that default with an explicit set of declared package-script names; they do not accept command text. The requested script text must still exactly match the current `package.json`; a changed script fails closed.
78
+
79
+ Checks do not load the workspace `.env` automatically. A non-zero exit, timeout, or truncated output is recorded as returned evidence and must not be summarized as a successful validation.
80
+
81
+ ## Git inspection and final summary
82
+
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
+
85
+ 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
+
87
+ Before completion, an editing run should report:
88
+
89
+ - files inspected and whether discovery was truncated;
90
+ - proposal and mutation results;
91
+ - stale conflicts or denied approvals;
92
+ - checks executed with their exit status;
93
+ - final staged, unstaged, renamed, deleted, and untracked state;
94
+ - quarantine identifiers that the operator may need for recovery.
95
+
96
+ Audit entries document harness operations. They do not prove that another process did not modify the repository, so the final Git inspection remains required.
97
+
98
+ ## Migration from 0.2.x
99
+
100
+ `0.3.0` is a pre-1.0 minor release and deliberately tightens mutation contracts:
101
+
102
+ - replace overwrite-oriented editing with inspect plus digest-bound proposal/apply for multi-file changes;
103
+ - consume paginated discovery until `nextCursor` is absent instead of assuming one list/search result is complete;
104
+ - configure the allowed check subset explicitly when the default set is too broad;
105
+ - use quarantine and restore instead of deleting or manually moving a file out of the workspace;
106
+ - include mutation audit evidence and the expanded Git status in final summaries.
107
+
108
+ Existing source files need no migration. Existing Git state is not modified during upgrade. Persisted `0.2.x` runs should be completed with the version that created them before beginning `0.3.x` editing work; do not assume a paused approval created under an older tool schema can be resumed after upgrading.
109
+
110
+ The new quarantine and audit state is harness-owned and must remain excluded from model discovery and Git. Back up any recovery payloads that must outlive the local retention window before cleaning harness state.
111
+
112
+ ## Known limits
113
+
114
+ - Atomic publication protects each file and failed batches use best-effort rollback; the workspace is not a database transaction across power loss, rollback failure, or external concurrent processes.
115
+ - Git rename detection is heuristic and may display a delete plus add for heavily rewritten content.
116
+ - Ignore evaluation and filesystem behavior can differ by platform; Linux and macOS fixtures are required release gates.
117
+ - 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`.
@@ -0,0 +1,40 @@
1
+ {
2
+ "schemaVersion": 1,
3
+ "cases": [
4
+ {
5
+ "name": "analysis-only",
6
+ "status": "completed",
7
+ "toolCalls": []
8
+ },
9
+ {
10
+ "name": "edit-and-test",
11
+ "status": "completed",
12
+ "toolCalls": ["propose_edits", "apply_patch", "run_check"]
13
+ },
14
+ {
15
+ "name": "denied-approval",
16
+ "status": "failed",
17
+ "toolCalls": ["propose_edits", "apply_patch"]
18
+ },
19
+ {
20
+ "name": "failure-recovery",
21
+ "status": "completed",
22
+ "toolCalls": ["propose_edits", "apply_patch"]
23
+ },
24
+ {
25
+ "name": "provider-switch",
26
+ "status": "completed",
27
+ "toolCalls": []
28
+ },
29
+ {
30
+ "name": "governed-mcp",
31
+ "status": "completed",
32
+ "toolCalls": ["remote_lookup"]
33
+ },
34
+ {
35
+ "name": "bounded-subagent",
36
+ "status": "completed",
37
+ "toolCalls": ["delegate_reviewer"]
38
+ }
39
+ ]
40
+ }
@@ -0,0 +1,17 @@
1
+ {
2
+ "schemaVersion": 1,
3
+ "servers": [
4
+ {
5
+ "name": "docs",
6
+ "transport": "http",
7
+ "url": "https://mcp.example.com/rpc",
8
+ "includeTools": ["search_docs", "read_page"],
9
+ "permissions": ["read", "network"],
10
+ "headerEnv": {
11
+ "x-api-key": "DOCS_MCP_API_KEY"
12
+ },
13
+ "callToolTimeoutMs": 30000,
14
+ "maxOutputBytes": 262144
15
+ }
16
+ ]
17
+ }
package/package.json ADDED
@@ -0,0 +1,85 @@
1
+ {
2
+ "name": "@zhivex-ai/harness",
3
+ "version": "0.5.0",
4
+ "description": "Provider-portable coding agent harness powered by Zhivex AI SDK.",
5
+ "type": "module",
6
+ "license": "MIT",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/Zhivex/zhivex-harness.git"
10
+ },
11
+ "bugs": {
12
+ "url": "https://github.com/Zhivex/zhivex-harness/issues"
13
+ },
14
+ "homepage": "https://github.com/Zhivex/zhivex-harness#readme",
15
+ "publishConfig": {
16
+ "access": "public",
17
+ "provenance": true,
18
+ "registry": "https://registry.npmjs.org/"
19
+ },
20
+ "keywords": [
21
+ "ai",
22
+ "agents",
23
+ "coding-agent",
24
+ "harness",
25
+ "zhivex"
26
+ ],
27
+ "bin": {
28
+ "zhivex-harness": "./dist/cli.js"
29
+ },
30
+ "exports": {
31
+ ".": {
32
+ "types": "./dist/index.d.ts",
33
+ "import": "./dist/index.js"
34
+ }
35
+ },
36
+ "files": [
37
+ "dist",
38
+ "README.md",
39
+ "ROADMAP.md",
40
+ "CHANGELOG.md",
41
+ "SECURITY.md",
42
+ "SUPPORT.md",
43
+ "LICENSE",
44
+ "docs",
45
+ "evaluations",
46
+ "examples"
47
+ ],
48
+ "scripts": {
49
+ "dev": "bun run src/cli.ts",
50
+ "start": "bun run dist/cli.js",
51
+ "build": "bun build ./src/index.ts ./src/cli.ts --outdir ./dist --target bun --packages external && tsc --emitDeclarationOnly",
52
+ "prepack": "bun run build",
53
+ "docs:check": "bun run scripts/check-docs.ts",
54
+ "typecheck": "tsc --noEmit",
55
+ "test": "bun test",
56
+ "evaluate": "bun run scripts/evaluate.ts",
57
+ "smoke:package": "bun run build && bun run scripts/package-smoke.ts",
58
+ "smoke:artifact": "bun run scripts/package-smoke.ts",
59
+ "smoke:mcp": "bun run scripts/mcp-interoperability-smoke.ts",
60
+ "smoke:live": "bun --env-file=.env run scripts/live-provider-smoke.ts",
61
+ "smoke:live:orchestration": "bun --env-file=.env run scripts/live-orchestration-smoke.ts",
62
+ "artifact:check": "bun run scripts/check-release-artifact.ts",
63
+ "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",
65
+ "release:check": "bun run check && bun audit && bun pm untrusted && bun run pack:inspect && bun run scripts/check-release-readiness.ts",
66
+ "release:status": "bun run scripts/check-registry-release-status.ts",
67
+ "release:verify": "bun run scripts/verify-registry-release.ts"
68
+ },
69
+ "dependencies": {
70
+ "@zhivex-ai/agents": "1.2.0",
71
+ "@zhivex-ai/core": "1.5.0",
72
+ "@zhivex-ai/meta": "0.2.1",
73
+ "@zhivex-ai/openai": "0.9.4",
74
+ "@zhivex-ai/qwen": "0.10.1",
75
+ "zod": "4.4.3"
76
+ },
77
+ "devDependencies": {
78
+ "@types/bun": "1.3.14",
79
+ "typescript": "6.0.3"
80
+ },
81
+ "engines": {
82
+ "bun": ">=1.3.7"
83
+ },
84
+ "packageManager": "bun@1.3.7"
85
+ }