@zhivex-ai/harness 1.4.0 → 1.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.
- package/CHANGELOG.md +32 -10
- package/README.md +7 -5
- package/SUPPORT.md +2 -2
- package/contracts/client-protocol-v1.schema.json +593 -0
- package/contracts/engine-api.json +156 -0
- package/contracts/public-api.json +12 -0
- package/contracts/stable-api-signatures.json +36 -36
- package/dist/acp-cli.js +54 -20
- package/dist/approvals/approval-diff.d.ts +2 -1
- package/dist/approvals/approval-preview.d.ts +1 -1
- package/dist/audit/index.d.ts +3 -0
- package/dist/audit/index.js +482 -0
- package/dist/audit/pack.d.ts +72 -0
- package/dist/audit-pack-kvw7ng34.js +532 -0
- package/dist/cli/arguments.d.ts +3 -1
- package/dist/cli/audit-pack.d.ts +24 -0
- package/dist/cli/cli-credentials.d.ts +6 -0
- package/dist/cli/cli-profiles.d.ts +4 -2
- package/dist/cli/node-engine.d.ts +2 -0
- package/dist/cli-entry-75j3r49b.js +484 -0
- package/dist/cli-entry-928p8h41.js +10067 -0
- package/dist/cli-entry-h2yc9x37.js +10350 -0
- package/dist/{cli-entry-20w6nh0k.js → cli-entry-hdtfef27.js} +439 -19
- package/dist/{cli-entry-w0hterjs.js → cli-entry-q8bgkn9m.js} +40 -13
- package/dist/{cli-2h37qyvg.js → cli-vyrytn3m.js} +253 -644
- package/dist/cli.js +27 -2
- package/dist/client/json-contracts.d.ts +4 -0
- package/dist/client/protocol.d.ts +133 -0
- package/dist/client/task-control-host.d.ts +400 -0
- package/dist/client/task-projection-host.d.ts +12 -0
- package/dist/client/task-projection.d.ts +168 -0
- package/dist/compat/code-support.js +28 -22
- package/dist/{config-qt69hkqj.js → config-r9fdhce6.js} +3 -3
- package/dist/{config-j9624t6t.js → config-vyajmksy.js} +1 -1
- package/dist/engine/acp.js +15 -11
- package/dist/engine/client.js +14 -10
- package/dist/engine/desktop-providers-v1.d.ts +2 -0
- package/dist/engine/desktop-providers-v1.js +23 -3
- package/dist/engine/desktop-state-v1.js +11 -8
- package/dist/engine/index.d.ts +3 -0
- package/dist/engine/index.js +101 -554
- package/dist/engine/mcp-stdio-v1.js +8 -6
- package/dist/engine/models.js +76 -4
- package/dist/engine/protocol.d.ts +2 -0
- package/dist/engine/protocol.js +110 -0
- package/dist/engine/service.js +15 -11
- package/dist/hostile-repository-demo.js +1232 -564
- package/dist/{index-8zjmnyw5.js → index-1265j7t2.js} +73 -6
- package/dist/{index-nmjdwd4p.js → index-4gt045j0.js} +109 -1
- package/dist/{index-pdmevfxv.js → index-5zbq9ztj.js} +5 -259
- package/dist/{index-6dft2vev.js → index-63gbp0cz.js} +5 -3
- package/dist/index-6dxrbnxm.js +719 -0
- package/dist/{index-pp474137.js → index-6fp7kdpx.js} +769 -933
- package/dist/{index-61gthdz6.js → index-8sm2a1wa.js} +1 -1
- package/dist/{index-rkbf7dqg.js → index-96ezrvg2.js} +57 -13
- package/dist/index-bt2p8x7r.js +329 -0
- package/dist/index-c39197wq.js +552 -0
- package/dist/{index-m82cfspw.js → index-eps3c3g6.js} +877 -963
- package/dist/{index-s2k2edts.js → index-fqqz1yt8.js} +110 -1544
- package/dist/{index-m34q25jj.js → index-ggstwr0v.js} +192 -838
- package/dist/index-jpdvn09j.js +490 -0
- package/dist/{index-xqxeypt5.js → index-mzydbzp8.js} +76 -4
- package/dist/index-pq3kz1r8.js +269 -0
- package/dist/{index-wg1sd3at.js → index-qfsrrnz6.js} +1 -1
- package/dist/{index-937cb7y8.js → index-vc7yxz50.js} +561 -35
- package/dist/{index-5jhgatga.js → index-vvzc5ezz.js} +7 -6
- package/dist/index-wwthv10a.js +1507 -0
- package/dist/{index-tfzta544.js → index-xfedewpt.js} +17 -9
- package/dist/index-yx52bt4a.js +511 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +93 -77
- package/dist/integrations/mcp-stdio-tools.d.ts +4 -1
- package/dist/internal/desktop/providers.d.ts +2 -0
- package/dist/models/catalog.d.ts +2 -0
- package/dist/persistence/sqlite-database.d.ts +1 -0
- package/dist/providers/azure-openai.d.ts +14 -0
- package/dist/providers/bedrock.d.ts +23 -0
- package/dist/providers/providers.d.ts +1 -1
- package/dist/runtime/budget-ledger-scope.d.ts +14 -0
- package/dist/runtime/durable-review-group.d.ts +33 -0
- package/dist/runtime/harness.d.ts +11 -0
- package/dist/runtime/run-interruption.d.ts +7 -0
- package/dist/runtime/shared-budget.d.ts +30 -0
- package/dist/runtime/task-continuity.d.ts +300 -77
- package/dist/service-cli.js +15 -11
- package/dist/{service-client-cli-fn54ev6w.js → service-client-cli-v6qptg9x.js} +400 -305
- package/dist/tools/workspace.d.ts +2 -2
- package/dist/verify-historical-migrations.js +1237 -566
- package/dist/workspace/edit-contracts.d.ts +2 -2
- package/dist/workspace/path-policy.d.ts +2 -1
- package/dist/workspace/workspace.d.ts +13 -0
- package/dist/zhx.js +27 -2
- package/docs/AUDIT_PACK.md +99 -0
- package/docs/AZURE_OPENAI.md +53 -0
- package/docs/BEDROCK.md +56 -0
- package/docs/CLI.md +15 -0
- package/docs/CLIENT_PROTOCOL.md +178 -0
- package/docs/CODE_RELEASE.md +59 -7
- package/docs/CODE_WEB_TASKS.md +116 -0
- package/docs/CONTEXT_ENGINEERING.md +59 -0
- package/docs/CREDENTIALS.md +21 -0
- package/docs/DURABLE_OPERATIONS.md +93 -1
- package/docs/ENGINE_API.md +5 -2
- package/docs/EXTENSIBILITY.md +8 -4
- package/docs/FIRST_USE.md +6 -6
- package/docs/MINIMUM_TASK_AUTHORITY.md +3 -3
- package/docs/PROJECT_MEMORY.md +1 -1
- package/docs/PUBLIC_SECURITY.md +14 -1
- package/docs/README.md +6 -1
- package/docs/REPOSITORY_EDITING.md +1 -1
- package/docs/STABILITY.md +3 -1
- package/docs/SUPPORT_MATRIX.md +1 -1
- package/docs/SUPPORT_MATRIX_1_1.md +1 -1
- package/docs/TOOL_POLICY.md +4 -1
- package/docs/USAGE.md +3 -1
- package/docs/VERTEX.md +2 -2
- package/docs/WEB_LIMITS.md +4 -3
- package/docs/adr/0002-isolated-mcp-stdio.md +7 -4
- package/docs/support-matrix-1.1.json +3 -1
- package/docs/support-matrix.json +6 -4
- package/evaluations/code-task-ui.json +20 -0
- package/evaluations/representative-assembly-matrix.json +19 -1
- package/evaluations/task-projection.json +10 -0
- package/evaluations/task-recovery-lab.json +60 -0
- package/examples/README.md +3 -3
- package/package.json +23 -13
- package/dist/cli-entry-4ngptr62.js +0 -19900
- package/dist/index-m49jx72n.js +0 -220
package/dist/engine/index.js
CHANGED
|
@@ -1,11 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
-
CHANGE_ENVELOPE_DIGEST_ALGORITHM,
|
|
3
|
-
CHANGE_ENVELOPE_SCHEMA_VERSION,
|
|
4
2
|
DEFAULT_TIME_TO_SAFE_FIX_GOAL,
|
|
5
|
-
MAX_CHANGE_ENVELOPE_APPROVALS,
|
|
6
|
-
MAX_CHANGE_ENVELOPE_APPROVAL_SCOPES,
|
|
7
|
-
MAX_CHANGE_ENVELOPE_ATTESTATIONS,
|
|
8
|
-
MAX_CHANGE_ENVELOPE_CHECKS,
|
|
9
3
|
TIME_TO_SAFE_FIX_CARRIERS,
|
|
10
4
|
TIME_TO_SAFE_FIX_DIAGNOSTIC_CODES,
|
|
11
5
|
TIME_TO_SAFE_FIX_FAILURE_ORIGINS,
|
|
@@ -13,16 +7,7 @@ import {
|
|
|
13
7
|
TIME_TO_SAFE_FIX_GOALS,
|
|
14
8
|
TIME_TO_SAFE_FIX_PROFILES,
|
|
15
9
|
TIME_TO_SAFE_FIX_SCHEMA_VERSION,
|
|
16
|
-
|
|
17
|
-
changeEnvelopeApprovalSchema,
|
|
18
|
-
changeEnvelopeBaseSchema,
|
|
19
|
-
changeEnvelopeCheckSchema,
|
|
20
|
-
changeEnvelopeEvidenceSchema,
|
|
21
|
-
changeEnvelopeFingerprintsSchema,
|
|
22
|
-
changeEnvelopeInputSchema,
|
|
23
|
-
changeEnvelopePatchSchema,
|
|
24
|
-
changeEnvelopePreconditionsSchema,
|
|
25
|
-
changeEnvelopeSchema,
|
|
10
|
+
cancelHarnessReviewGroup,
|
|
26
11
|
classifyTimeToSafeFixFailure,
|
|
27
12
|
cliChangeEnvelopeVerificationDocumentSchema,
|
|
28
13
|
cliDoctorDocumentSchema,
|
|
@@ -46,23 +31,19 @@ import {
|
|
|
46
31
|
cliStateStatusDocumentSchema,
|
|
47
32
|
cliStreamErrorDocumentSchema,
|
|
48
33
|
cliStreamResultDocumentSchema,
|
|
49
|
-
computeChangeEnvelopeDigest,
|
|
50
|
-
computeChangeEnvelopeEvidenceDigest,
|
|
51
|
-
createChangeEnvelope,
|
|
52
34
|
createTimeToSafeFixCases,
|
|
53
35
|
createTimeToSafeFixReport,
|
|
54
36
|
createTimeToSafeFixSample,
|
|
55
|
-
digestChangeEnvelopeArtifact,
|
|
56
|
-
externalAttestationReferenceSchema,
|
|
57
37
|
injectTimeToSafeFixAttack,
|
|
38
|
+
inspectHarnessReviewGroup,
|
|
58
39
|
parseCliJsonDocument,
|
|
59
40
|
parseCliJsonLineDocument,
|
|
60
41
|
recommendCompactionModels,
|
|
42
|
+
runHarnessDurableReviewGroup,
|
|
61
43
|
timeToSafeFixDriverResultSchema,
|
|
62
44
|
timeToSafeFixLatencyStatistics,
|
|
63
|
-
timeToSafeFixTaskSchema
|
|
64
|
-
|
|
65
|
-
} from "../index-m82cfspw.js";
|
|
45
|
+
timeToSafeFixTaskSchema
|
|
46
|
+
} from "../index-eps3c3g6.js";
|
|
66
47
|
import {
|
|
67
48
|
HARNESS_STATE_BACKUP_MAX_BYTES,
|
|
68
49
|
HARNESS_STATE_BACKUP_SCHEMA_VERSION,
|
|
@@ -73,7 +54,7 @@ import {
|
|
|
73
54
|
inspectHarnessState,
|
|
74
55
|
readHarnessStateBackup,
|
|
75
56
|
stateBackupBundleSchema
|
|
76
|
-
} from "../index-
|
|
57
|
+
} from "../index-xfedewpt.js";
|
|
77
58
|
import {
|
|
78
59
|
CLI_COMMAND_OPTION_CONTRACTS,
|
|
79
60
|
CLI_OPTION_DEFINITIONS,
|
|
@@ -83,7 +64,40 @@ import {
|
|
|
83
64
|
resolveHarnessModelRoutes,
|
|
84
65
|
serializeHarnessModelRoutes,
|
|
85
66
|
validateCliCommandOptions
|
|
86
|
-
} from "../index-
|
|
67
|
+
} from "../index-8sm2a1wa.js";
|
|
68
|
+
import {
|
|
69
|
+
createAcpConnection,
|
|
70
|
+
serveAcpStdio
|
|
71
|
+
} from "../index-3ah1f369.js";
|
|
72
|
+
import {
|
|
73
|
+
exportHarnessGovernanceReport,
|
|
74
|
+
harnessGovernanceReportSchema,
|
|
75
|
+
renderHarnessGovernanceMarkdown
|
|
76
|
+
} from "../index-jpdvn09j.js";
|
|
77
|
+
import {
|
|
78
|
+
CHANGE_ENVELOPE_DIGEST_ALGORITHM,
|
|
79
|
+
CHANGE_ENVELOPE_SCHEMA_VERSION,
|
|
80
|
+
MAX_CHANGE_ENVELOPE_APPROVALS,
|
|
81
|
+
MAX_CHANGE_ENVELOPE_APPROVAL_SCOPES,
|
|
82
|
+
MAX_CHANGE_ENVELOPE_ATTESTATIONS,
|
|
83
|
+
MAX_CHANGE_ENVELOPE_CHECKS,
|
|
84
|
+
canonicalizeChangeEnvelope,
|
|
85
|
+
changeEnvelopeApprovalSchema,
|
|
86
|
+
changeEnvelopeBaseSchema,
|
|
87
|
+
changeEnvelopeCheckSchema,
|
|
88
|
+
changeEnvelopeEvidenceSchema,
|
|
89
|
+
changeEnvelopeFingerprintsSchema,
|
|
90
|
+
changeEnvelopeInputSchema,
|
|
91
|
+
changeEnvelopePatchSchema,
|
|
92
|
+
changeEnvelopePreconditionsSchema,
|
|
93
|
+
changeEnvelopeSchema,
|
|
94
|
+
computeChangeEnvelopeDigest,
|
|
95
|
+
computeChangeEnvelopeEvidenceDigest,
|
|
96
|
+
createChangeEnvelope,
|
|
97
|
+
digestChangeEnvelopeArtifact,
|
|
98
|
+
externalAttestationReferenceSchema,
|
|
99
|
+
verifyChangeEnvelope
|
|
100
|
+
} from "../index-yx52bt4a.js";
|
|
87
101
|
import {
|
|
88
102
|
harnessLocalCredentialsSchema,
|
|
89
103
|
openHarnessActivityStore,
|
|
@@ -91,19 +105,14 @@ import {
|
|
|
91
105
|
recoverHarnessLocalService,
|
|
92
106
|
requestHarnessLocalService,
|
|
93
107
|
startHarnessLocalService
|
|
94
|
-
} from "../index-
|
|
95
|
-
import {
|
|
96
|
-
createAcpConnection,
|
|
97
|
-
serveAcpStdio
|
|
98
|
-
} from "../index-3ah1f369.js";
|
|
108
|
+
} from "../index-vvzc5ezz.js";
|
|
99
109
|
import {
|
|
100
110
|
createHarnessClientAdapter
|
|
101
|
-
} from "../index-
|
|
111
|
+
} from "../index-vc7yxz50.js";
|
|
102
112
|
import {
|
|
103
113
|
openWorkspaceCheckpointStore
|
|
104
|
-
} from "../index-
|
|
114
|
+
} from "../index-63gbp0cz.js";
|
|
105
115
|
import {
|
|
106
|
-
APPROVAL_HISTORY_KEY,
|
|
107
116
|
DEFAULT_HARNESS_CONTEXT_MANIFEST,
|
|
108
117
|
DEFAULT_HARNESS_PROJECT_INSTRUCTIONS,
|
|
109
118
|
HARNESS_CONTEXT_BUNDLE_SCHEMA_VERSION,
|
|
@@ -119,8 +128,6 @@ import {
|
|
|
119
128
|
MAX_HARNESS_SKILL_FILE_BYTES,
|
|
120
129
|
SEMANTIC_COMPACTION_VERSION,
|
|
121
130
|
appendUserMessage,
|
|
122
|
-
applyHarnessToolPolicy,
|
|
123
|
-
approvalDecisionViews,
|
|
124
131
|
assertHarnessModelCapabilities,
|
|
125
132
|
compactHarnessMessages,
|
|
126
133
|
createEmptyHarnessContextBundle,
|
|
@@ -128,18 +135,14 @@ import {
|
|
|
128
135
|
createHarness,
|
|
129
136
|
createHarnessLifecycleDispatcher,
|
|
130
137
|
createHarnessSubagents,
|
|
131
|
-
createHarnessToolPolicy,
|
|
132
138
|
createProgressMonitor,
|
|
133
139
|
createSemanticCompactor,
|
|
134
140
|
estimateMessageTokens,
|
|
135
141
|
harnessContextConfigurationSchema,
|
|
136
142
|
harnessContextFingerprintInput,
|
|
137
143
|
harnessLifecycleFingerprintInput,
|
|
138
|
-
harnessPolicyDecisionEventSchema,
|
|
139
144
|
harnessSkillLoadInputSchema,
|
|
140
|
-
harnessToolPolicySchema,
|
|
141
145
|
inspectHarnessModelCapabilities,
|
|
142
|
-
inspectHarnessPolicy,
|
|
143
146
|
inspectHarnessTaskAcceptance,
|
|
144
147
|
isHarnessContextDigest,
|
|
145
148
|
loadHarnessProjectContext,
|
|
@@ -149,80 +152,41 @@ import {
|
|
|
149
152
|
runHarness,
|
|
150
153
|
runHarnessReviewGroup,
|
|
151
154
|
selectHarnessModel
|
|
152
|
-
} from "../index-
|
|
155
|
+
} from "../index-6fp7kdpx.js";
|
|
153
156
|
import {
|
|
154
157
|
HARNESS_OPERATIONS_SCHEMA_VERSION,
|
|
155
158
|
HARNESS_PROJECT_MEMORY_LIMITS,
|
|
156
159
|
HARNESS_PROJECT_MEMORY_SCHEMA_VERSION,
|
|
157
|
-
HARNESS_SESSION_INDEX_FILE,
|
|
158
|
-
HARNESS_SESSION_SCHEMA_VERSION,
|
|
159
160
|
HARNESS_SQLITE_FILE,
|
|
160
|
-
SESSION_RUN_STATUSES,
|
|
161
|
-
TASK_ACCEPTANCE_EVIDENCE_KEY,
|
|
162
161
|
TERMINAL_RUN_STATUSES,
|
|
163
|
-
TERMINAL_SESSION_RUN_STATUSES,
|
|
164
|
-
USAGE_LEDGER_KEY,
|
|
165
162
|
cancelHarnessRun,
|
|
166
163
|
cleanupHarnessRuns,
|
|
167
|
-
compileTaskAcceptanceContract,
|
|
168
164
|
inspectHarnessRun,
|
|
169
|
-
inspectRuntimeManifest,
|
|
170
|
-
inspectUsageLedger,
|
|
171
165
|
listHarnessRuns,
|
|
172
166
|
migrateLegacyFileRuns,
|
|
173
|
-
openCliSessionStore,
|
|
174
167
|
openHarnessPersistence,
|
|
175
|
-
openHarnessProjectMemory
|
|
176
|
-
|
|
177
|
-
readTaskAcceptanceLedger,
|
|
178
|
-
taskAcceptanceContractSchema,
|
|
179
|
-
validateStateDirectory
|
|
180
|
-
} from "../index-s2k2edts.js";
|
|
168
|
+
openHarnessProjectMemory
|
|
169
|
+
} from "../index-wwthv10a.js";
|
|
181
170
|
import {
|
|
182
|
-
BUN_ENGINE_RANGE,
|
|
183
171
|
HARNESS_MCP_CONFIG_SCHEMA_VERSION,
|
|
184
172
|
HARNESS_MCP_PERMISSIONS,
|
|
185
|
-
HARNESS_VERSION,
|
|
186
|
-
NODE_ENGINE_RANGE,
|
|
187
173
|
createHarnessMcpTools,
|
|
188
174
|
createHttpMcpClient,
|
|
189
175
|
loadHarnessMcpConfiguration,
|
|
190
176
|
normalizeHarnessMcpConfiguration
|
|
191
|
-
} from "../index-
|
|
177
|
+
} from "../index-5zbq9ztj.js";
|
|
192
178
|
import {
|
|
193
179
|
CliOciRuntimeAdapter,
|
|
194
|
-
EDIT_CONTRACT_SCHEMA_VERSION,
|
|
195
|
-
EDIT_DIGEST_ALGORITHM,
|
|
196
180
|
HARNESS_EXECUTION_ARTIFACT_SCHEMA_VERSION,
|
|
197
181
|
HARNESS_OCI_LABEL,
|
|
198
182
|
HARNESS_OCI_LABEL_VALUE,
|
|
199
|
-
MAX_EDIT_CHANGES,
|
|
200
|
-
MAX_EDIT_FILE_BYTES,
|
|
201
|
-
MAX_EDIT_PROPOSAL_BYTES,
|
|
202
183
|
Workspace,
|
|
203
|
-
applyEditProposalInputSchema,
|
|
204
184
|
cleanupHarnessExecutionArtifacts,
|
|
205
|
-
createEditProposal,
|
|
206
185
|
createHarnessOciExecutionEnvironment,
|
|
207
186
|
describeOciCommand,
|
|
208
|
-
editChangeSchema,
|
|
209
|
-
editChangesSchema,
|
|
210
|
-
editContractDocument,
|
|
211
|
-
editProposalChangeSchema,
|
|
212
|
-
editProposalInputSchema,
|
|
213
|
-
editProposalSchema,
|
|
214
187
|
executionFingerprintInput,
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
moveFileInputSchema,
|
|
218
|
-
mutationAuditEntrySchema,
|
|
219
|
-
mutationOperationSchema,
|
|
220
|
-
quarantineFileInputSchema,
|
|
221
|
-
restoreFileInputSchema,
|
|
222
|
-
taskCheckReceiptSchema,
|
|
223
|
-
validateEditProposal,
|
|
224
|
-
workspaceFilePathSchema
|
|
225
|
-
} from "../index-m34q25jj.js";
|
|
188
|
+
harnessExecutionSession
|
|
189
|
+
} from "../index-ggstwr0v.js";
|
|
226
190
|
import {
|
|
227
191
|
BUILTIN_PROVIDER_REGISTRATIONS,
|
|
228
192
|
DEFAULT_ALLOWED_CHECKS,
|
|
@@ -247,9 +211,54 @@ import {
|
|
|
247
211
|
providerAvailability,
|
|
248
212
|
providerDescriptor,
|
|
249
213
|
resolveHarnessConfig
|
|
250
|
-
} from "../index-
|
|
251
|
-
import"../index-
|
|
252
|
-
import"../index-
|
|
214
|
+
} from "../index-1265j7t2.js";
|
|
215
|
+
import"../index-c39197wq.js";
|
|
216
|
+
import"../index-mzydbzp8.js";
|
|
217
|
+
import {
|
|
218
|
+
applyHarnessToolPolicy,
|
|
219
|
+
createHarnessToolPolicy,
|
|
220
|
+
harnessToolPolicySchema,
|
|
221
|
+
inspectHarnessPolicy
|
|
222
|
+
} from "../index-bt2p8x7r.js";
|
|
223
|
+
import {
|
|
224
|
+
HARNESS_SESSION_INDEX_FILE,
|
|
225
|
+
HARNESS_SESSION_SCHEMA_VERSION,
|
|
226
|
+
SESSION_RUN_STATUSES,
|
|
227
|
+
TERMINAL_SESSION_RUN_STATUSES,
|
|
228
|
+
compileTaskAcceptanceContract,
|
|
229
|
+
openCliSessionStore,
|
|
230
|
+
openSessionStore,
|
|
231
|
+
taskAcceptanceContractSchema,
|
|
232
|
+
validateStateDirectory
|
|
233
|
+
} from "../index-fqqz1yt8.js";
|
|
234
|
+
import {
|
|
235
|
+
BUN_ENGINE_RANGE,
|
|
236
|
+
HARNESS_VERSION,
|
|
237
|
+
NODE_ENGINE_RANGE
|
|
238
|
+
} from "../index-pq3kz1r8.js";
|
|
239
|
+
import {
|
|
240
|
+
EDIT_CONTRACT_SCHEMA_VERSION,
|
|
241
|
+
EDIT_DIGEST_ALGORITHM,
|
|
242
|
+
MAX_EDIT_CHANGES,
|
|
243
|
+
MAX_EDIT_FILE_BYTES,
|
|
244
|
+
MAX_EDIT_PROPOSAL_BYTES,
|
|
245
|
+
applyEditProposalInputSchema,
|
|
246
|
+
createEditProposal,
|
|
247
|
+
editChangeSchema,
|
|
248
|
+
editChangesSchema,
|
|
249
|
+
editContractDocument,
|
|
250
|
+
editProposalChangeSchema,
|
|
251
|
+
editProposalInputSchema,
|
|
252
|
+
editProposalSchema,
|
|
253
|
+
fileDigestSchema,
|
|
254
|
+
moveFileInputSchema,
|
|
255
|
+
mutationAuditEntrySchema,
|
|
256
|
+
mutationOperationSchema,
|
|
257
|
+
quarantineFileInputSchema,
|
|
258
|
+
restoreFileInputSchema,
|
|
259
|
+
validateEditProposal,
|
|
260
|
+
workspaceFilePathSchema
|
|
261
|
+
} from "../index-6dxrbnxm.js";
|
|
253
262
|
import {
|
|
254
263
|
CLI_EVENT_SCHEMA_VERSION,
|
|
255
264
|
CLI_JSON_SCHEMA_VERSION,
|
|
@@ -260,7 +269,7 @@ import {
|
|
|
260
269
|
serializeStreamResult,
|
|
261
270
|
streamEventDocument,
|
|
262
271
|
streamResultDocument
|
|
263
|
-
} from "../index-
|
|
272
|
+
} from "../index-4gt045j0.js";
|
|
264
273
|
import {
|
|
265
274
|
HARNESS_ERROR_CODES,
|
|
266
275
|
HARNESS_ERROR_SCHEMA_VERSION,
|
|
@@ -345,471 +354,6 @@ async function executeHarnessMemoryCommand(options, command, args, source = "Exp
|
|
|
345
354
|
memory.close();
|
|
346
355
|
}
|
|
347
356
|
}
|
|
348
|
-
// src/persistence/governance-report.ts
|
|
349
|
-
import { createHash as createHash2 } from "node:crypto";
|
|
350
|
-
import { z as z2 } from "zod";
|
|
351
|
-
|
|
352
|
-
// src/persistence/governance-context.ts
|
|
353
|
-
import { createHash } from "node:crypto";
|
|
354
|
-
import { z } from "zod";
|
|
355
|
-
var digest = z.string().regex(/^sha256:[a-f0-9]{64}$/);
|
|
356
|
-
var count = z.number().int().nonnegative().safe();
|
|
357
|
-
var governanceReference = (kind, value) => "sha256:" + createHash("sha256").update(JSON.stringify([kind, value])).digest("hex");
|
|
358
|
-
var governanceSessionSchema = z.strictObject({ availability: z.enum(["recorded", "unavailable"]), reference: digest.nullable(), revision: count.nullable() });
|
|
359
|
-
var governanceHistorySchema = z.strictObject({
|
|
360
|
-
availability: z.enum(["recorded", "unavailable"]),
|
|
361
|
-
retention: z.enum(["unknown", "retained", "expired"]),
|
|
362
|
-
incomplete: z.boolean(),
|
|
363
|
-
policyDecisions: z.array(z.strictObject({
|
|
364
|
-
runReference: digest,
|
|
365
|
-
sequence: count,
|
|
366
|
-
toolReference: digest,
|
|
367
|
-
phase: z.enum(["approval-request", "tool-entry"]),
|
|
368
|
-
decision: z.enum(["allow", "ask_user", "deny"]),
|
|
369
|
-
policyDigest: digest.nullable(),
|
|
370
|
-
source: z.enum(["operator-file", "application", "baseline"]),
|
|
371
|
-
ruleReferences: z.array(digest).max(128),
|
|
372
|
-
explicitReviewRequired: z.boolean()
|
|
373
|
-
})).max(512)
|
|
374
|
-
});
|
|
375
|
-
var governanceEnvelopeSchema = z.strictObject({
|
|
376
|
-
source: z.literal("caller-supplied"),
|
|
377
|
-
envelopeId: digest.nullable(),
|
|
378
|
-
patchReference: digest.nullable(),
|
|
379
|
-
patchDigest: digest.nullable(),
|
|
380
|
-
linkedRunReferences: z.array(digest).max(64),
|
|
381
|
-
schemaValid: z.boolean(),
|
|
382
|
-
integrity: z.enum(["valid", "invalid"]),
|
|
383
|
-
expiration: z.enum(["unknown", "current", "expired", "not-yet-valid"]),
|
|
384
|
-
checkedAt: z.iso.datetime(),
|
|
385
|
-
expiredApprovals: count,
|
|
386
|
-
authenticity: z.literal("not-verified"),
|
|
387
|
-
patchBytes: z.literal("not-verified")
|
|
388
|
-
});
|
|
389
|
-
async function readGovernanceSession(source, rootRunId, runIds) {
|
|
390
|
-
const session = { availability: "unavailable", reference: null, revision: null };
|
|
391
|
-
const history = { availability: "unavailable", retention: "unknown", incomplete: true, policyDecisions: [] };
|
|
392
|
-
if (!source)
|
|
393
|
-
return { session, history, verify: async () => {} };
|
|
394
|
-
const initial = await source.index.get(source.id);
|
|
395
|
-
if (!initial || initial.sessionId !== source.id || !initial.runs.some((run) => run.runId === rootRunId))
|
|
396
|
-
throw new Error("GOVERNANCE_SESSION_MISMATCH");
|
|
397
|
-
const captured = JSON.stringify(initial);
|
|
398
|
-
session.availability = "recorded";
|
|
399
|
-
session.reference = governanceReference("session", initial.sessionId);
|
|
400
|
-
session.revision = initial.revision;
|
|
401
|
-
const pages = [];
|
|
402
|
-
if (source.history) {
|
|
403
|
-
let cursor = 0;
|
|
404
|
-
history.availability = "recorded";
|
|
405
|
-
history.retention = "retained";
|
|
406
|
-
history.incomplete = false;
|
|
407
|
-
for (let pageIndex = 0;pageIndex < 50; pageIndex++) {
|
|
408
|
-
const page = source.history.replay(source.id, cursor);
|
|
409
|
-
pages.push({ cursor, digest: governanceReference("history-page", JSON.stringify(page)) });
|
|
410
|
-
if (page.schemaVersion !== 1 || !Number.isSafeInteger(page.nextCursor) || page.nextCursor < cursor || page.events.length > 200)
|
|
411
|
-
throw new Error("GOVERNANCE_HISTORY_INVALID");
|
|
412
|
-
if (page.cursorExpired || page.policyEvidenceIncomplete) {
|
|
413
|
-
history.retention = "expired";
|
|
414
|
-
history.incomplete = true;
|
|
415
|
-
}
|
|
416
|
-
let lastSequence = cursor;
|
|
417
|
-
for (const event of page.events) {
|
|
418
|
-
if (event.sessionId !== source.id || !Number.isSafeInteger(event.sequence) || event.sequence <= lastSequence || event.sequence > page.nextCursor)
|
|
419
|
-
throw new Error("GOVERNANCE_HISTORY_INVALID");
|
|
420
|
-
lastSequence = event.sequence;
|
|
421
|
-
if (!runIds.has(event.runId) || event.activity.type !== "policy-decision")
|
|
422
|
-
continue;
|
|
423
|
-
const parsed = harnessPolicyDecisionEventSchema.safeParse(event.activity);
|
|
424
|
-
if (!parsed.success) {
|
|
425
|
-
history.incomplete = true;
|
|
426
|
-
continue;
|
|
427
|
-
}
|
|
428
|
-
if (history.policyDecisions.length === 512) {
|
|
429
|
-
history.incomplete = true;
|
|
430
|
-
continue;
|
|
431
|
-
}
|
|
432
|
-
const value = parsed.data;
|
|
433
|
-
history.policyDecisions.push({
|
|
434
|
-
runReference: governanceReference("run", event.runId),
|
|
435
|
-
sequence: event.sequence,
|
|
436
|
-
toolReference: governanceReference("tool", value.toolName),
|
|
437
|
-
phase: value.phase,
|
|
438
|
-
decision: value.decision,
|
|
439
|
-
policyDigest: value.policyDigest,
|
|
440
|
-
source: value.source,
|
|
441
|
-
ruleReferences: value.ruleIds.map((rule) => governanceReference("rule", rule)),
|
|
442
|
-
explicitReviewRequired: value.explicitReviewRequired
|
|
443
|
-
});
|
|
444
|
-
}
|
|
445
|
-
if (page.cursorExpired || !page.hasMore)
|
|
446
|
-
break;
|
|
447
|
-
if (page.nextCursor === cursor)
|
|
448
|
-
throw new Error("GOVERNANCE_HISTORY_INVALID");
|
|
449
|
-
cursor = page.nextCursor;
|
|
450
|
-
if (pageIndex === 49)
|
|
451
|
-
history.incomplete = true;
|
|
452
|
-
}
|
|
453
|
-
}
|
|
454
|
-
return { session, history, verify: async () => {
|
|
455
|
-
for (const page of pages)
|
|
456
|
-
if (governanceReference("history-page", JSON.stringify(source.history.replay(source.id, page.cursor))) !== page.digest)
|
|
457
|
-
throw new Error("GOVERNANCE_STATE_CHANGED");
|
|
458
|
-
if (JSON.stringify(await source.index.get(source.id)) !== captured)
|
|
459
|
-
throw new Error("GOVERNANCE_STATE_CHANGED");
|
|
460
|
-
} };
|
|
461
|
-
}
|
|
462
|
-
function projectGovernanceEnvelopes(envelopes, patches, now) {
|
|
463
|
-
if (envelopes.length > 32)
|
|
464
|
-
throw new Error("GOVERNANCE_ENVELOPE_LIMIT");
|
|
465
|
-
return envelopes.map((input) => {
|
|
466
|
-
if (Buffer.byteLength(JSON.stringify(input) ?? "") > 256 * 1024)
|
|
467
|
-
throw new Error("GOVERNANCE_ENVELOPE_LIMIT");
|
|
468
|
-
const parsed = changeEnvelopeSchema.safeParse(input);
|
|
469
|
-
const proof = verifyChangeEnvelope(input, { now });
|
|
470
|
-
const envelope = parsed.success ? parsed.data : undefined;
|
|
471
|
-
return governanceEnvelopeSchema.parse({
|
|
472
|
-
source: "caller-supplied",
|
|
473
|
-
envelopeId: envelope?.envelopeId ?? null,
|
|
474
|
-
patchReference: envelope ? governanceReference("patch", envelope.patch.patchId) : null,
|
|
475
|
-
patchDigest: envelope?.patch.patchDigest ?? null,
|
|
476
|
-
linkedRunReferences: envelope ? [...patches.get(envelope.patch.patchId) ?? []] : [],
|
|
477
|
-
schemaValid: parsed.success,
|
|
478
|
-
integrity: proof.integrity.envelopeDigestValid && proof.integrity.evidenceDigestValid ? "valid" : "invalid",
|
|
479
|
-
expiration: !envelope ? "unknown" : proof.expiration.envelopeNotYetValid ? "not-yet-valid" : proof.expiration.envelopeExpired ? "expired" : "current",
|
|
480
|
-
checkedAt: proof.expiration.checkedAt,
|
|
481
|
-
expiredApprovals: proof.expiration.expiredApprovalIds.length,
|
|
482
|
-
authenticity: "not-verified",
|
|
483
|
-
patchBytes: "not-verified"
|
|
484
|
-
});
|
|
485
|
-
});
|
|
486
|
-
}
|
|
487
|
-
|
|
488
|
-
// src/persistence/governance-report.ts
|
|
489
|
-
var digest2 = z2.string().regex(/^sha256:[a-f0-9]{64}$/);
|
|
490
|
-
var version = z2.string().regex(/^\d+\.\d+\.\d+(?:[-+][a-zA-Z0-9.-]+)?$/);
|
|
491
|
-
var bindingSchema = z2.object({ schemaVersion: z2.literal(1), id: z2.literal("zhivex-harness"), version, fingerprint: digest2, algorithm: z2.literal("sha256") });
|
|
492
|
-
var count2 = z2.number().int().nonnegative().safe();
|
|
493
|
-
var status = z2.enum(["created", "running", "waiting_approval", "cancel_requested", "completed", "failed", "cancelled", "timed_out", "unknown"]);
|
|
494
|
-
var availability = z2.enum(["recorded", "unavailable", "invalid"]);
|
|
495
|
-
var providerReason = z2.enum(["empty_arguments", "invalid_json", "arguments_too_large", "incomplete_arguments", "inconsistent_metadata", "response_failed", "response_incomplete", "stream_truncated"]);
|
|
496
|
-
var deliveryReason = z2.enum(["TASK_ACCEPTANCE_NO_DELIVERY_EVIDENCE", "TASK_ACCEPTANCE_SCOPE_VIOLATION", "TASK_ACCEPTANCE_RUN_NOT_COMPLETED", "TASK_ACCEPTANCE_RUN_NOT_FINISHED", "TASK_ACCEPTANCE_IMPORT_UNCONFIRMED", "TASK_ACCEPTANCE_CHECKS_MISSING", "TASK_ACCEPTANCE_DELIVERY_DRIFT", "TASK_ACCEPTANCE_DELIVERY_INSPECTION_FAILED", "TASK_ACCEPTANCE_HUMAN_REVIEW_REQUIRED", "TASK_ACCEPTANCE_VERIFIED"]);
|
|
497
|
-
var deliveryStatus = z2.enum(["pending", "incomplete", "failed", "pending_review", "verified", "unknown"]);
|
|
498
|
-
var checkSchema = z2.strictObject({
|
|
499
|
-
reference: digest2,
|
|
500
|
-
argvDigest: digest2,
|
|
501
|
-
patchId: digest2,
|
|
502
|
-
snapshotDigest: digest2,
|
|
503
|
-
exitCode: z2.number().int(),
|
|
504
|
-
timedOut: z2.boolean(),
|
|
505
|
-
unchanged: z2.boolean()
|
|
506
|
-
});
|
|
507
|
-
var deliverySchema = z2.object({
|
|
508
|
-
schemaVersion: z2.literal(1),
|
|
509
|
-
contractRevision: count2,
|
|
510
|
-
contractDigest: digest2,
|
|
511
|
-
status: deliveryStatus,
|
|
512
|
-
checks: z2.array(taskCheckReceiptSchema).max(32),
|
|
513
|
-
delivery: z2.object({ runId: z2.string().max(512), executionIdentity: z2.string().max(512), patchId: digest2, snapshotDigest: digest2 }).optional()
|
|
514
|
-
});
|
|
515
|
-
var approvalSchema = z2.strictObject({
|
|
516
|
-
reference: digest2,
|
|
517
|
-
toolReference: digest2,
|
|
518
|
-
approved: z2.boolean(),
|
|
519
|
-
origin: z2.enum(["interactive", "automatic", "application", "unknown"]),
|
|
520
|
-
channelReference: digest2,
|
|
521
|
-
policyDigest: digest2.nullable(),
|
|
522
|
-
status: z2.enum(["rejected", "approved", "applied", "succeeded", "failed", "unknown"]),
|
|
523
|
-
proposalId: digest2.nullable(),
|
|
524
|
-
exitCode: z2.number().int().nullable(),
|
|
525
|
-
timedOut: z2.boolean().nullable(),
|
|
526
|
-
effects: z2.array(z2.strictObject({ pathReference: digest2, beforeDigest: digest2.nullable(), afterDigest: digest2.nullable() })).max(50)
|
|
527
|
-
});
|
|
528
|
-
var delegationReason = z2.enum(["valid", "invalid_json", "invalid_schema", "task_mismatch", "incomplete", "duplicate_claim", "path_denied", "evidence_missing", "coverage_missing", "missing_child", "child_identity_unavailable"]);
|
|
529
|
-
var delegationSchema = z2.strictObject({
|
|
530
|
-
taskReference: digest2,
|
|
531
|
-
childReference: digest2.nullable(),
|
|
532
|
-
recordedAcceptance: z2.boolean(),
|
|
533
|
-
reason: delegationReason,
|
|
534
|
-
semanticReview: z2.enum(["pending", "not_requested"]),
|
|
535
|
-
correctionsUsed: count2.nullable()
|
|
536
|
-
});
|
|
537
|
-
var delegationInput = z2.object({ schemaVersion: z2.literal(1), evaluations: z2.array(z2.object({
|
|
538
|
-
taskId: z2.string().max(128),
|
|
539
|
-
childRunId: z2.string().max(512).nullable(),
|
|
540
|
-
childStatus: z2.string().max(32),
|
|
541
|
-
accepted: z2.boolean(),
|
|
542
|
-
reason: delegationReason,
|
|
543
|
-
semanticReview: z2.enum(["pending", "not_requested"]),
|
|
544
|
-
correctionsUsed: count2.optional()
|
|
545
|
-
})).max(64) });
|
|
546
|
-
var runSchema = z2.strictObject({
|
|
547
|
-
reference: digest2,
|
|
548
|
-
parentReference: digest2.nullable(),
|
|
549
|
-
revision: count2.nullable(),
|
|
550
|
-
status,
|
|
551
|
-
finalized: z2.boolean(),
|
|
552
|
-
failure: z2.enum(["run_failed", "cancelled", "timed_out", "not_reported"]).nullable(),
|
|
553
|
-
failureDetails: z2.strictObject({ providerToolReason: providerReason.nullable(), diagnosticReference: digest2.nullable(), deliveryReason: deliveryReason.nullable() }),
|
|
554
|
-
identity: z2.literal("not-verified"),
|
|
555
|
-
runtimePolicy: z2.enum(["assistant-v3-durable-closure"]).nullable(),
|
|
556
|
-
contract: z2.strictObject({
|
|
557
|
-
availability,
|
|
558
|
-
digest: digest2.nullable(),
|
|
559
|
-
revision: count2.nullable(),
|
|
560
|
-
requiredChecks: count2.nullable(),
|
|
561
|
-
humanReviewsPending: count2.nullable(),
|
|
562
|
-
allowedWritePathReferences: z2.array(digest2).max(256),
|
|
563
|
-
protectedPathReferences: z2.array(digest2).max(256),
|
|
564
|
-
checks: z2.array(z2.strictObject({ reference: digest2, argvDigest: digest2, kind: z2.enum(["argv", "package-script"]), backend: z2.enum(["none", "oci"]), approval: z2.literal("required") })).max(32),
|
|
565
|
-
humanReviewReferences: z2.array(digest2).max(32)
|
|
566
|
-
}),
|
|
567
|
-
delivery: z2.strictObject({
|
|
568
|
-
availability,
|
|
569
|
-
status: deliveryStatus,
|
|
570
|
-
patchId: digest2.nullable(),
|
|
571
|
-
snapshotDigest: digest2.nullable(),
|
|
572
|
-
interpretation: z2.literal("recorded-checkpoint-not-current-workspace-verification"),
|
|
573
|
-
checks: z2.array(checkSchema).max(32)
|
|
574
|
-
}),
|
|
575
|
-
approvals: z2.strictObject({ availability, items: z2.array(approvalSchema).max(512) }),
|
|
576
|
-
usage: z2.strictObject({
|
|
577
|
-
availability: z2.enum(["recorded", "unavailable"]),
|
|
578
|
-
calls: count2.nullable(),
|
|
579
|
-
inputTokens: count2.nullable(),
|
|
580
|
-
outputTokens: count2.nullable(),
|
|
581
|
-
complete: z2.boolean().nullable(),
|
|
582
|
-
estimatedUsd: z2.number().finite().nonnegative().nullable(),
|
|
583
|
-
costKind: z2.literal("estimate-not-invoice")
|
|
584
|
-
}),
|
|
585
|
-
journal: z2.strictObject({ availability: z2.enum(["recorded", "unavailable"]), entries: count2, failed: count2, unfinished: count2 }),
|
|
586
|
-
delegations: z2.strictObject({ availability, interpretation: z2.literal("recorded-checkpoint-not-semantic-review"), items: z2.array(delegationSchema).max(64) }),
|
|
587
|
-
children: z2.array(digest2).max(64)
|
|
588
|
-
});
|
|
589
|
-
var harnessGovernanceReportSchema = z2.strictObject({
|
|
590
|
-
schemaVersion: z2.literal(1),
|
|
591
|
-
kind: z2.literal("harness-governance-report"),
|
|
592
|
-
exporterVersion: z2.string().regex(/^\d+\.\d+\.\d+(?:[-+][a-zA-Z0-9.-]+)?$/),
|
|
593
|
-
executionArtifact: z2.strictObject({ version: version.nullable(), digest: z2.null(), availability: z2.enum(["recorded-version", "unavailable"]), configurationFingerprint: digest2.nullable(), authenticity: z2.literal("not-verified") }),
|
|
594
|
-
rootReference: digest2,
|
|
595
|
-
identity: z2.literal("not-verified"),
|
|
596
|
-
referencePolicy: z2.literal("sha256-domain-separated-pseudonyms-not-anonymity"),
|
|
597
|
-
session: governanceSessionSchema,
|
|
598
|
-
eventHistory: governanceHistorySchema,
|
|
599
|
-
changeEnvelopes: z2.array(governanceEnvelopeSchema).max(32),
|
|
600
|
-
runs: z2.array(runSchema).max(64),
|
|
601
|
-
missingChildren: z2.array(digest2).max(64),
|
|
602
|
-
limitations: z2.array(z2.enum(["tree_limit", "missing_child", "invalid_contract", "invalid_delivery", "invalid_approvals", "journal_unavailable"])).max(6)
|
|
603
|
-
});
|
|
604
|
-
var MAX_JOURNAL = 2048;
|
|
605
|
-
var MAX_REPORT_BYTES = 2 * 1024 * 1024;
|
|
606
|
-
var sameScope = (state, scope) => !state.scope || state.scope.tenantId === scope?.tenantId && state.scope.userId === scope?.userId && state.scope.namespace === scope?.namespace;
|
|
607
|
-
function projectRun(state, journal, limitations) {
|
|
608
|
-
const runStatus = status.safeParse(state.status);
|
|
609
|
-
const stateStatus = runStatus.success ? runStatus.data : "unknown";
|
|
610
|
-
let ledger;
|
|
611
|
-
let contractAvailability = "unavailable";
|
|
612
|
-
try {
|
|
613
|
-
ledger = readTaskAcceptanceLedger(state);
|
|
614
|
-
if (ledger)
|
|
615
|
-
contractAvailability = "recorded";
|
|
616
|
-
} catch {
|
|
617
|
-
contractAvailability = "invalid";
|
|
618
|
-
limitations.add("invalid_contract");
|
|
619
|
-
}
|
|
620
|
-
const contract = ledger?.revisions.at(-1);
|
|
621
|
-
const rawDelivery = state.metadata?.[TASK_ACCEPTANCE_EVIDENCE_KEY];
|
|
622
|
-
const parsedDelivery = deliverySchema.safeParse(rawDelivery);
|
|
623
|
-
const bound = parsedDelivery.success && contract && parsedDelivery.data.contractDigest === contract.digest && parsedDelivery.data.contractRevision === contract.revision && (!parsedDelivery.data.delivery || parsedDelivery.data.delivery.runId === state.runId);
|
|
624
|
-
const candidate = bound ? parsedDelivery.data : undefined;
|
|
625
|
-
const verified = candidate?.status === "verified" || candidate?.status === "pending_review";
|
|
626
|
-
const validSuccess = !verified || stateStatus === "completed" && candidate.delivery && contract && contract.contract.requiredChecks.every((required) => candidate.checks.some((check) => check.checkId === required.id && check.runId === state.runId && check.argvDigest === "sha256:" + createHash2("sha256").update(JSON.stringify([required.command, ...required.args])).digest("hex") && check.contractDigest === contract.digest && check.contractRevision === contract.revision && check.exitCode === 0 && !check.timedOut && check.unchanged && check.patchId === candidate.delivery.patchId && check.snapshotDigest === candidate.delivery.snapshotDigest && check.executionIdentity === candidate.delivery.executionIdentity)) && candidate.status === "pending_review" === contract.contract.humanReview.length > 0;
|
|
627
|
-
const delivery = validSuccess ? candidate : undefined;
|
|
628
|
-
if (rawDelivery !== undefined && !delivery)
|
|
629
|
-
limitations.add("invalid_delivery");
|
|
630
|
-
const approvals = { availability: state.metadata?.[APPROVAL_HISTORY_KEY] === undefined ? "unavailable" : "recorded", items: [] };
|
|
631
|
-
try {
|
|
632
|
-
for (let offset = 0;offset < 512; offset += 25) {
|
|
633
|
-
const rows = approvalDecisionViews(state, journal ?? [], offset);
|
|
634
|
-
for (const row of rows)
|
|
635
|
-
approvals.items.push({
|
|
636
|
-
reference: governanceReference("approval", row.approvalId),
|
|
637
|
-
toolReference: governanceReference("tool", row.name),
|
|
638
|
-
approved: row.approved,
|
|
639
|
-
origin: row.provenance?.origin ?? "unknown",
|
|
640
|
-
channelReference: governanceReference("channel", row.provenance?.channel ?? "unknown"),
|
|
641
|
-
policyDigest: row.provenance?.policyDigest ?? null,
|
|
642
|
-
status: row.status,
|
|
643
|
-
proposalId: row.evidence?.proposalId ?? null,
|
|
644
|
-
exitCode: row.evidence?.exitCode ?? null,
|
|
645
|
-
timedOut: row.evidence?.timedOut ?? null,
|
|
646
|
-
effects: (row.evidence?.effects ?? []).map((effect) => ({ pathReference: governanceReference("path", effect.path), beforeDigest: effect.beforeDigest, afterDigest: effect.afterDigest }))
|
|
647
|
-
});
|
|
648
|
-
if (rows.length < 25)
|
|
649
|
-
break;
|
|
650
|
-
}
|
|
651
|
-
} catch {
|
|
652
|
-
approvals.availability = "invalid";
|
|
653
|
-
approvals.items = [];
|
|
654
|
-
limitations.add("invalid_approvals");
|
|
655
|
-
}
|
|
656
|
-
const parsedUsage = inspectUsageLedger(state.metadata?.[USAGE_LEDGER_KEY]);
|
|
657
|
-
const usage = parsedUsage?.runId === state.runId ? parsedUsage : null;
|
|
658
|
-
const rawDelegations = state.metadata?.zhivexDelegationAcceptanceV1;
|
|
659
|
-
const delegations = delegationInput.safeParse(rawDelegations);
|
|
660
|
-
const manifest = inspectRuntimeManifest(state.metadata?.effectiveRuntime);
|
|
661
|
-
return {
|
|
662
|
-
reference: governanceReference("run", state.runId),
|
|
663
|
-
parentReference: state.parentRunId ? governanceReference("run", state.parentRunId) : null,
|
|
664
|
-
revision: count2.safeParse(state.revision).success ? state.revision : null,
|
|
665
|
-
status: stateStatus,
|
|
666
|
-
finalized: ["completed", "failed", "cancelled", "timed_out"].includes(stateStatus),
|
|
667
|
-
failure: stateStatus === "failed" ? "run_failed" : stateStatus === "cancelled" ? "cancelled" : stateStatus === "timed_out" ? "timed_out" : state.error ? "not_reported" : null,
|
|
668
|
-
failureDetails: {
|
|
669
|
-
providerToolReason: providerReason.safeParse(state.error?.reason).success ? state.error.reason : null,
|
|
670
|
-
diagnosticReference: state.error?.diagnosticCode ? governanceReference("diagnostic", state.error.diagnosticCode) : null,
|
|
671
|
-
deliveryReason: deliveryReason.safeParse(rawDelivery && typeof rawDelivery === "object" && !Array.isArray(rawDelivery) ? rawDelivery.reason : undefined).success ? rawDelivery.reason : null
|
|
672
|
-
},
|
|
673
|
-
identity: "not-verified",
|
|
674
|
-
runtimePolicy: manifest?.policyVersion ?? null,
|
|
675
|
-
contract: {
|
|
676
|
-
availability: contractAvailability,
|
|
677
|
-
digest: contract?.digest ?? null,
|
|
678
|
-
revision: contract?.revision ?? null,
|
|
679
|
-
requiredChecks: contract?.contract.requiredChecks.length ?? null,
|
|
680
|
-
humanReviewsPending: contract?.contract.humanReview.length ?? null,
|
|
681
|
-
allowedWritePathReferences: contract?.contract.allowedWritePaths.map((file) => governanceReference("path", file)) ?? [],
|
|
682
|
-
protectedPathReferences: contract?.contract.protectedFiles.map((file) => governanceReference("path", file)) ?? [],
|
|
683
|
-
checks: contract?.contract.requiredChecks.map((check) => ({ reference: governanceReference("check", check.id), argvDigest: "sha256:" + createHash2("sha256").update(JSON.stringify([check.command, ...check.args])).digest("hex"), kind: check.kind, backend: check.execution.backend, approval: check.execution.approval })) ?? [],
|
|
684
|
-
humanReviewReferences: contract?.contract.humanReview.map((review) => governanceReference("review", review.id)) ?? []
|
|
685
|
-
},
|
|
686
|
-
delivery: {
|
|
687
|
-
availability: delivery ? "recorded" : rawDelivery === undefined ? "unavailable" : "invalid",
|
|
688
|
-
status: delivery?.status ?? "unknown",
|
|
689
|
-
patchId: delivery?.delivery?.patchId ?? null,
|
|
690
|
-
snapshotDigest: delivery?.delivery?.snapshotDigest ?? null,
|
|
691
|
-
interpretation: "recorded-checkpoint-not-current-workspace-verification",
|
|
692
|
-
checks: (delivery?.checks ?? []).filter((check) => check.runId === state.runId && check.contractDigest === contract?.digest && check.contractRevision === contract?.revision).map((check) => ({ reference: governanceReference("check", check.checkId), argvDigest: check.argvDigest, patchId: check.patchId, snapshotDigest: check.snapshotDigest, exitCode: check.exitCode, timedOut: check.timedOut, unchanged: check.unchanged }))
|
|
693
|
-
},
|
|
694
|
-
approvals,
|
|
695
|
-
usage: {
|
|
696
|
-
availability: usage ? "recorded" : "unavailable",
|
|
697
|
-
calls: usage?.calls ?? null,
|
|
698
|
-
inputTokens: usage?.inputTokens ?? null,
|
|
699
|
-
outputTokens: usage?.outputTokens ?? null,
|
|
700
|
-
complete: usage?.usageComplete ?? null,
|
|
701
|
-
estimatedUsd: usage?.estimatedUsd ?? null,
|
|
702
|
-
costKind: "estimate-not-invoice"
|
|
703
|
-
},
|
|
704
|
-
journal: {
|
|
705
|
-
availability: journal ? "recorded" : "unavailable",
|
|
706
|
-
entries: journal?.length ?? 0,
|
|
707
|
-
failed: journal?.filter((entry) => entry.status === "failed").length ?? 0,
|
|
708
|
-
unfinished: journal?.filter((entry) => entry.status !== "completed" && entry.status !== "failed").length ?? 0
|
|
709
|
-
},
|
|
710
|
-
delegations: {
|
|
711
|
-
availability: rawDelegations === undefined ? "unavailable" : delegations.success ? "recorded" : "invalid",
|
|
712
|
-
interpretation: "recorded-checkpoint-not-semantic-review",
|
|
713
|
-
items: delegations.success ? delegations.data.evaluations.map((item) => ({
|
|
714
|
-
taskReference: governanceReference("task", item.taskId),
|
|
715
|
-
childReference: item.childRunId ? governanceReference("run", item.childRunId) : null,
|
|
716
|
-
recordedAcceptance: item.accepted,
|
|
717
|
-
reason: item.reason,
|
|
718
|
-
semanticReview: item.semanticReview,
|
|
719
|
-
correctionsUsed: item.correctionsUsed ?? null
|
|
720
|
-
})) : []
|
|
721
|
-
},
|
|
722
|
-
children: (state.childRuns ?? []).slice(0, 64).map((child) => governanceReference("run", child.runId))
|
|
723
|
-
};
|
|
724
|
-
}
|
|
725
|
-
async function exportHarnessGovernanceReport(store, scope, runId, options = {}) {
|
|
726
|
-
const limitations = new Set;
|
|
727
|
-
const runs = [], missingChildren = [];
|
|
728
|
-
const observed = [];
|
|
729
|
-
const queue = [{ id: runId }], seen = new Set;
|
|
730
|
-
while (queue.length && runs.length + missingChildren.length < 64) {
|
|
731
|
-
const item = queue.shift();
|
|
732
|
-
if (seen.has(item.id))
|
|
733
|
-
continue;
|
|
734
|
-
seen.add(item.id);
|
|
735
|
-
const loaded = await store.load(item.id, scope);
|
|
736
|
-
const state = loaded ? structuredClone(loaded) : undefined;
|
|
737
|
-
if (!state || state.runId !== item.id || !sameScope(state, scope) || item.parent !== undefined && state.parentRunId !== item.parent) {
|
|
738
|
-
if (item.parent === undefined)
|
|
739
|
-
throw new Error("GOVERNANCE_RUN_UNAVAILABLE");
|
|
740
|
-
missingChildren.push(governanceReference("run", item.id));
|
|
741
|
-
limitations.add("missing_child");
|
|
742
|
-
continue;
|
|
743
|
-
}
|
|
744
|
-
const loadedJournal = await store.listToolCalls?.(state.runId, scope);
|
|
745
|
-
const journal = loadedJournal ? structuredClone(loadedJournal) : undefined;
|
|
746
|
-
if (journal && journal.length > MAX_JOURNAL)
|
|
747
|
-
throw new Error("GOVERNANCE_JOURNAL_LIMIT");
|
|
748
|
-
if (journal?.some((entry) => entry.runId !== state.runId))
|
|
749
|
-
throw new Error("GOVERNANCE_JOURNAL_SCOPE");
|
|
750
|
-
if (!journal)
|
|
751
|
-
limitations.add("journal_unavailable");
|
|
752
|
-
observed.push({ state, journal });
|
|
753
|
-
runs.push(projectRun(state, journal, limitations));
|
|
754
|
-
if ((state.childRuns?.length ?? 0) > 64)
|
|
755
|
-
limitations.add("tree_limit");
|
|
756
|
-
for (const child of (state.childRuns ?? []).slice(0, 64))
|
|
757
|
-
queue.push({ id: child.runId, parent: state.runId });
|
|
758
|
-
}
|
|
759
|
-
if (queue.length)
|
|
760
|
-
limitations.add("tree_limit");
|
|
761
|
-
const context = await readGovernanceSession(options.session, runId, new Set(observed.map((item) => item.state.runId)));
|
|
762
|
-
for (const { state, journal } of observed) {
|
|
763
|
-
const current = await store.load(state.runId, scope);
|
|
764
|
-
const currentJournal = await store.listToolCalls?.(state.runId, scope);
|
|
765
|
-
if (!current || JSON.stringify(current) !== JSON.stringify(state) || JSON.stringify(currentJournal) !== JSON.stringify(journal))
|
|
766
|
-
throw new Error("GOVERNANCE_STATE_CHANGED");
|
|
767
|
-
}
|
|
768
|
-
await context.verify();
|
|
769
|
-
const patches = new Map;
|
|
770
|
-
for (const run of runs)
|
|
771
|
-
for (const patch of new Set([run.delivery.patchId, ...run.approvals.items.map((row) => row.proposalId)].filter((id) => id !== null)))
|
|
772
|
-
patches.set(patch, [...patches.get(patch) ?? [], run.reference]);
|
|
773
|
-
const binding = bindingSchema.safeParse(observed[0]?.state.harness);
|
|
774
|
-
const report = harnessGovernanceReportSchema.parse({
|
|
775
|
-
schemaVersion: 1,
|
|
776
|
-
kind: "harness-governance-report",
|
|
777
|
-
exporterVersion: HARNESS_VERSION,
|
|
778
|
-
executionArtifact: { version: binding.success ? binding.data.version : null, digest: null, availability: binding.success ? "recorded-version" : "unavailable", configurationFingerprint: binding.success ? binding.data.fingerprint : null, authenticity: "not-verified" },
|
|
779
|
-
rootReference: governanceReference("run", runId),
|
|
780
|
-
identity: "not-verified",
|
|
781
|
-
referencePolicy: "sha256-domain-separated-pseudonyms-not-anonymity",
|
|
782
|
-
session: context.session,
|
|
783
|
-
eventHistory: context.history,
|
|
784
|
-
changeEnvelopes: projectGovernanceEnvelopes(options.changeEnvelopes ?? [], patches, options.now ?? Date.now()),
|
|
785
|
-
runs,
|
|
786
|
-
missingChildren,
|
|
787
|
-
limitations: [...limitations].sort()
|
|
788
|
-
});
|
|
789
|
-
if (Buffer.byteLength(JSON.stringify(report)) > MAX_REPORT_BYTES)
|
|
790
|
-
throw new Error("GOVERNANCE_REPORT_LIMIT");
|
|
791
|
-
return report;
|
|
792
|
-
}
|
|
793
|
-
function renderHarnessGovernanceMarkdown(input) {
|
|
794
|
-
const report = harnessGovernanceReportSchema.parse(input);
|
|
795
|
-
return [
|
|
796
|
-
"# Execution and governance report",
|
|
797
|
-
"",
|
|
798
|
-
`Schema: ${report.schemaVersion}. Exporter: ${report.exporterVersion}.`,
|
|
799
|
-
`Identity: not verified. Recorded execution version: ${report.executionArtifact.version ?? "unavailable"}. Artifact digest: unavailable. Hash references are pseudonyms, not signatures.`,
|
|
800
|
-
"Delivery describes a recorded checkpoint; export does not recheck the workspace.",
|
|
801
|
-
"",
|
|
802
|
-
"| Run reference | Execution | Recorded delivery | Usage |",
|
|
803
|
-
"| --- | --- | --- | --- |",
|
|
804
|
-
...report.runs.map((run) => `| ${run.reference} | ${run.status} | ${run.delivery.status} | ${run.usage.availability === "unavailable" ? "unavailable" : `${run.usage.inputTokens} input / ${run.usage.outputTokens} output (${run.usage.complete ? "complete" : "incomplete"})`} |`),
|
|
805
|
-
"",
|
|
806
|
-
`Missing children: ${report.missingChildren.length}. Limitations: ${report.limitations.join(", ") || "none detected"}.`,
|
|
807
|
-
`Session: ${report.session.availability}. Event history: ${report.eventHistory.availability}. Retention: ${report.eventHistory.retention}. Incomplete: ${report.eventHistory.incomplete}.`,
|
|
808
|
-
`Change envelopes: ${report.changeEnvelopes.length}. Envelope integrity does not verify patch bytes or authenticity. Estimates are not invoices.`,
|
|
809
|
-
""
|
|
810
|
-
].join(`
|
|
811
|
-
`);
|
|
812
|
-
}
|
|
813
357
|
export {
|
|
814
358
|
BUILTIN_PROVIDER_REGISTRATIONS,
|
|
815
359
|
BUN_ENGINE_RANGE,
|
|
@@ -900,6 +444,7 @@ export {
|
|
|
900
444
|
applyEditProposalInputSchema,
|
|
901
445
|
applyHarnessToolPolicy,
|
|
902
446
|
assertHarnessModelCapabilities,
|
|
447
|
+
cancelHarnessReviewGroup,
|
|
903
448
|
cancelHarnessRun,
|
|
904
449
|
canonicalizeChangeEnvelope,
|
|
905
450
|
changeEnvelopeApprovalSchema,
|
|
@@ -994,6 +539,7 @@ export {
|
|
|
994
539
|
injectTimeToSafeFixAttack,
|
|
995
540
|
inspectHarnessModelCapabilities,
|
|
996
541
|
inspectHarnessPolicy,
|
|
542
|
+
inspectHarnessReviewGroup,
|
|
997
543
|
inspectHarnessRun,
|
|
998
544
|
inspectHarnessState,
|
|
999
545
|
inspectHarnessTaskAcceptance,
|
|
@@ -1034,6 +580,7 @@ export {
|
|
|
1034
580
|
restoreFileInputSchema,
|
|
1035
581
|
reviseHarnessTaskAcceptance,
|
|
1036
582
|
runHarness,
|
|
583
|
+
runHarnessDurableReviewGroup,
|
|
1037
584
|
runHarnessReviewGroup,
|
|
1038
585
|
selectHarnessModel,
|
|
1039
586
|
serializeHarnessModelRoutes,
|