@smartergpt/lexrunner 1.3.0 → 1.4.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 +30 -0
- package/README.md +3 -2
- package/dist/cli.cjs +3450 -2017
- package/dist/cli.d.ts +16 -7
- package/dist/cli.js +2136 -1015
- package/dist/frames/index.cjs +328 -129
- package/dist/sdk/index.d.ts +6 -6
- package/package.json +8 -2
package/dist/cli.js
CHANGED
|
@@ -455,7 +455,7 @@ import "dotenv/config";
|
|
|
455
455
|
// package.json
|
|
456
456
|
var package_default = {
|
|
457
457
|
name: "@smartergpt/lexrunner",
|
|
458
|
-
version: "1.
|
|
458
|
+
version: "1.4.0",
|
|
459
459
|
type: "module",
|
|
460
460
|
engines: {
|
|
461
461
|
node: ">=24"
|
|
@@ -548,6 +548,7 @@ var package_default = {
|
|
|
548
548
|
"validate:manifests": "tsx scripts/validate-manifests.ts",
|
|
549
549
|
"validate:build-artifacts": "tsx scripts/validate-build-artifacts.ts",
|
|
550
550
|
"validate:package": "tsx scripts/validate-package-boundary.ts",
|
|
551
|
+
"check:install-scripts": "node scripts/check-install-script-policy.mjs",
|
|
551
552
|
"test:package": "node scripts/smoke-packed-package.mjs",
|
|
552
553
|
"docs:check": "node scripts/check-doc-links.mjs",
|
|
553
554
|
"docs:surface": "node scripts/render-doc-surfaces.mjs",
|
|
@@ -584,7 +585,7 @@ var package_default = {
|
|
|
584
585
|
"@modelcontextprotocol/sdk": "^1.18.2",
|
|
585
586
|
"@octokit/auth-token": "^6.0.0",
|
|
586
587
|
"@octokit/rest": "^22.0.0",
|
|
587
|
-
"@smartergpt/lex": "^
|
|
588
|
+
"@smartergpt/lex": "^4.0.0",
|
|
588
589
|
"@types/babel__traverse": "^7.28.0",
|
|
589
590
|
ajv: "^8.20.0",
|
|
590
591
|
"better-sqlite3-multiple-ciphers": "^12.6.2",
|
|
@@ -621,6 +622,11 @@ var package_default = {
|
|
|
621
622
|
"*.{json,md,yaml,yml}": [
|
|
622
623
|
"prettier --check"
|
|
623
624
|
]
|
|
625
|
+
},
|
|
626
|
+
allowScripts: {
|
|
627
|
+
"better-sqlite3-multiple-ciphers@12.11.1": true,
|
|
628
|
+
"esbuild@0.28.1": true,
|
|
629
|
+
"@smartergpt/lex": false
|
|
624
630
|
}
|
|
625
631
|
};
|
|
626
632
|
|
|
@@ -18504,7 +18510,7 @@ function evaluateDirectoryIdentityBoundarySupport(facts) {
|
|
|
18504
18510
|
supported: false,
|
|
18505
18511
|
platform: facts.platform,
|
|
18506
18512
|
pathComparison: facts.pathComparison,
|
|
18507
|
-
reasonCode: "
|
|
18513
|
+
reasonCode: "windows_native_boundary_unavailable"
|
|
18508
18514
|
};
|
|
18509
18515
|
}
|
|
18510
18516
|
if (facts.platform === "darwin") {
|
|
@@ -18797,6 +18803,8 @@ function boundaryPathError(label, error) {
|
|
|
18797
18803
|
}
|
|
18798
18804
|
function boundarySupportMessage(reasonCode) {
|
|
18799
18805
|
switch (reasonCode) {
|
|
18806
|
+
case "windows_native_boundary_unavailable":
|
|
18807
|
+
return "Physical worktree containment requires the native Windows workspace boundary";
|
|
18800
18808
|
case "case_insensitive_runtime":
|
|
18801
18809
|
return "Physical worktree containment currently requires a case-sensitive Linux Git runtime";
|
|
18802
18810
|
case "procfs_unavailable":
|
|
@@ -18883,14 +18891,14 @@ var AgentWorkContainmentCapabilityService = class {
|
|
|
18883
18891
|
});
|
|
18884
18892
|
}
|
|
18885
18893
|
if (!support.supported) {
|
|
18886
|
-
const brokerRequired = support.reasonCode === "
|
|
18894
|
+
const brokerRequired = support.reasonCode === "windows_native_boundary_unavailable";
|
|
18887
18895
|
return capabilityResult({
|
|
18888
18896
|
bindingDigest,
|
|
18889
18897
|
support,
|
|
18890
18898
|
paths: syntacticPaths,
|
|
18891
18899
|
state: brokerRequired ? "broker_required" : "unsupported",
|
|
18892
18900
|
reasonCode: support.reasonCode,
|
|
18893
|
-
nextActions: brokerRequired ? ["
|
|
18901
|
+
nextActions: brokerRequired ? ["install_native_windows_boundary", "rerun_containment_preflight"] : ["select_native_case_sensitive_linux_runtime", "rerun_containment_preflight"]
|
|
18894
18902
|
});
|
|
18895
18903
|
}
|
|
18896
18904
|
const repositoryRoot = evaluatePath(this.pathProbe(runtime.repositoryRoot, "repositoryRoot"));
|
|
@@ -18914,7 +18922,8 @@ var AgentWorkContainmentCapabilityService = class {
|
|
|
18914
18922
|
paths,
|
|
18915
18923
|
state: "broker_required",
|
|
18916
18924
|
reasonCode: wslReason,
|
|
18917
|
-
nextActions: ["provision_native_wsl_projection", "rerun_containment_preflight"]
|
|
18925
|
+
nextActions: ["provision_native_wsl_projection", "rerun_containment_preflight"],
|
|
18926
|
+
projectionRequired: true
|
|
18918
18927
|
});
|
|
18919
18928
|
}
|
|
18920
18929
|
const pathFailure = firstPathFailure(repositoryRoot, repositoryGitDirectory, worktreeRoot);
|
|
@@ -18959,7 +18968,7 @@ function capabilityResult(input) {
|
|
|
18959
18968
|
state: input.state,
|
|
18960
18969
|
reasonCode: input.reasonCode,
|
|
18961
18970
|
physicalContainmentAvailable: false,
|
|
18962
|
-
projectionRequired: input.
|
|
18971
|
+
projectionRequired: input.projectionRequired ?? false,
|
|
18963
18972
|
runtime: {
|
|
18964
18973
|
platform: publicPlatform(input.support.platform),
|
|
18965
18974
|
pathComparison: input.support.pathComparison
|
|
@@ -19101,14 +19110,39 @@ function isJsonSafe(value, seen = /* @__PURE__ */ new Set(), depth = 0) {
|
|
|
19101
19110
|
}
|
|
19102
19111
|
|
|
19103
19112
|
// src/runs/agent-work-projection-lifecycle.ts
|
|
19104
|
-
import { z as
|
|
19113
|
+
import { z as z19 } from "zod";
|
|
19105
19114
|
|
|
19106
19115
|
// src/schemas/agent-work-projection.ts
|
|
19107
|
-
import { z as
|
|
19116
|
+
import { z as z16 } from "zod";
|
|
19117
|
+
|
|
19118
|
+
// src/schemas/bounded-strict-object.ts
|
|
19119
|
+
import { z as z14 } from "zod";
|
|
19120
|
+
function boundedStrictObject(shape) {
|
|
19121
|
+
const allowedKeys = new Set(Object.keys(shape));
|
|
19122
|
+
return z14.preprocess((input) => {
|
|
19123
|
+
if (input === null || typeof input !== "object" || Array.isArray(input)) {
|
|
19124
|
+
return input;
|
|
19125
|
+
}
|
|
19126
|
+
try {
|
|
19127
|
+
const prototype = Object.getPrototypeOf(input);
|
|
19128
|
+
if (prototype !== Object.prototype && prototype !== null) {
|
|
19129
|
+
return null;
|
|
19130
|
+
}
|
|
19131
|
+
for (const key of Reflect.ownKeys(input)) {
|
|
19132
|
+
if (typeof key !== "string" || !allowedKeys.has(key)) {
|
|
19133
|
+
return null;
|
|
19134
|
+
}
|
|
19135
|
+
}
|
|
19136
|
+
} catch {
|
|
19137
|
+
return null;
|
|
19138
|
+
}
|
|
19139
|
+
return input;
|
|
19140
|
+
}, z14.object(shape));
|
|
19141
|
+
}
|
|
19108
19142
|
|
|
19109
19143
|
// src/schemas/task-contract.ts
|
|
19110
19144
|
import { createHash as createHash6 } from "crypto";
|
|
19111
|
-
import { z as
|
|
19145
|
+
import { z as z15 } from "zod";
|
|
19112
19146
|
var TASK_CONTRACT_VERSION = "1.0.0";
|
|
19113
19147
|
function computeCanonicalHash(obj) {
|
|
19114
19148
|
const canonical = JSON.stringify(obj, sortedReplacer);
|
|
@@ -19130,111 +19164,111 @@ function sortedReplacer(_key, value) {
|
|
|
19130
19164
|
}
|
|
19131
19165
|
return value;
|
|
19132
19166
|
}
|
|
19133
|
-
var DeterminismLevel2 =
|
|
19134
|
-
var ConfidenceLevel =
|
|
19135
|
-
var SourceOfTruthKind =
|
|
19136
|
-
var AssumptionType =
|
|
19137
|
-
var RepoRelativePath =
|
|
19167
|
+
var DeterminismLevel2 = z15.enum(["D1", "D2", "D3"]);
|
|
19168
|
+
var ConfidenceLevel = z15.enum(["high", "medium", "low"]);
|
|
19169
|
+
var SourceOfTruthKind = z15.enum(["symbol", "file", "registry"]);
|
|
19170
|
+
var AssumptionType = z15.enum(["scope", "codebase", "env", "intent", "dependency", "test"]);
|
|
19171
|
+
var RepoRelativePath = z15.string().refine((p) => !p.startsWith("/"), {
|
|
19138
19172
|
message: "Path must be repo-relative (no leading slash)"
|
|
19139
19173
|
}).refine((p) => !p.includes(":\\") && !p.includes(":/"), {
|
|
19140
19174
|
message: "Path must not be absolute (no drive letters)"
|
|
19141
19175
|
}).refine((p) => !p.startsWith(".."), {
|
|
19142
19176
|
message: "Path must not escape repo root"
|
|
19143
19177
|
});
|
|
19144
|
-
var GlobPattern =
|
|
19145
|
-
var SHA256Hash =
|
|
19146
|
-
var SHA256HashOrPlaceholder =
|
|
19178
|
+
var GlobPattern = z15.string().min(1);
|
|
19179
|
+
var SHA256Hash = z15.string().regex(/^sha256:[a-f0-9]{64}$/, "Must be sha256:<64-hex-chars>");
|
|
19180
|
+
var SHA256HashOrPlaceholder = z15.string().refine((h) => h.startsWith("sha256:"), {
|
|
19147
19181
|
message: "Must start with sha256:"
|
|
19148
19182
|
});
|
|
19149
|
-
var RepoProvenance =
|
|
19183
|
+
var RepoProvenance = z15.object({
|
|
19150
19184
|
/** Repository identifier (owner/name) */
|
|
19151
|
-
id:
|
|
19185
|
+
id: z15.string().regex(/^[^/]+\/[^/]+$/, "Must be owner/repo format"),
|
|
19152
19186
|
/** Absolute path to repo root (engine-local, for resolution) */
|
|
19153
|
-
root:
|
|
19187
|
+
root: z15.string(),
|
|
19154
19188
|
/** Pinned commit SHA */
|
|
19155
|
-
commit_sha:
|
|
19189
|
+
commit_sha: z15.string().min(7)
|
|
19156
19190
|
});
|
|
19157
|
-
var ScopeBoundary =
|
|
19191
|
+
var ScopeBoundary = z15.object({
|
|
19158
19192
|
/** Globs for files agent can read */
|
|
19159
|
-
read_globs:
|
|
19193
|
+
read_globs: z15.array(GlobPattern),
|
|
19160
19194
|
/** Globs for files agent can modify */
|
|
19161
|
-
write_globs:
|
|
19195
|
+
write_globs: z15.array(GlobPattern),
|
|
19162
19196
|
/** Globs for files explicitly denied (always applied) */
|
|
19163
|
-
deny_globs:
|
|
19197
|
+
deny_globs: z15.array(GlobPattern),
|
|
19164
19198
|
/** Whether cross-repo operations are permitted */
|
|
19165
|
-
cross_repo_allowed:
|
|
19199
|
+
cross_repo_allowed: z15.boolean()
|
|
19166
19200
|
});
|
|
19167
|
-
var FailureEvidence =
|
|
19201
|
+
var FailureEvidence = z15.object({
|
|
19168
19202
|
/** Short error description */
|
|
19169
|
-
message:
|
|
19203
|
+
message: z15.string(),
|
|
19170
19204
|
/** Repo-relative path to failed file */
|
|
19171
19205
|
file_rel: RepoRelativePath,
|
|
19172
19206
|
/** Line number if available */
|
|
19173
|
-
line:
|
|
19207
|
+
line: z15.number().int().positive().optional(),
|
|
19174
19208
|
/** Actual test runner output snippet */
|
|
19175
|
-
runner_output_snip:
|
|
19209
|
+
runner_output_snip: z15.string(),
|
|
19176
19210
|
/** Code context around failure */
|
|
19177
|
-
excerpt:
|
|
19211
|
+
excerpt: z15.string().optional()
|
|
19178
19212
|
});
|
|
19179
|
-
var HintEdit =
|
|
19180
|
-
find:
|
|
19181
|
-
replace:
|
|
19213
|
+
var HintEdit = z15.object({
|
|
19214
|
+
find: z15.string(),
|
|
19215
|
+
replace: z15.string()
|
|
19182
19216
|
});
|
|
19183
|
-
var Target =
|
|
19217
|
+
var Target = z15.object({
|
|
19184
19218
|
/** Repo-relative file path */
|
|
19185
19219
|
path_rel: RepoRelativePath,
|
|
19186
19220
|
/** Anchored code context (±N lines) */
|
|
19187
|
-
hunk:
|
|
19221
|
+
hunk: z15.string(),
|
|
19188
19222
|
/** SHA256 of hunk for drift detection */
|
|
19189
19223
|
hunk_sha256: SHA256HashOrPlaceholder,
|
|
19190
19224
|
/** Optional find/replace suggestion */
|
|
19191
19225
|
hint_edit: HintEdit.optional()
|
|
19192
19226
|
});
|
|
19193
|
-
var IntroducingChange =
|
|
19194
|
-
commit_sha:
|
|
19195
|
-
diff_hunk:
|
|
19227
|
+
var IntroducingChange = z15.object({
|
|
19228
|
+
commit_sha: z15.string().min(7),
|
|
19229
|
+
diff_hunk: z15.string()
|
|
19196
19230
|
});
|
|
19197
|
-
var SourceOfTruth =
|
|
19231
|
+
var SourceOfTruth = z15.object({
|
|
19198
19232
|
/** Kind of source */
|
|
19199
19233
|
kind: SourceOfTruthKind,
|
|
19200
19234
|
/** Repo-relative path */
|
|
19201
19235
|
path_rel: RepoRelativePath,
|
|
19202
19236
|
/** Repository ID (defaults to snapshot repo if omitted) */
|
|
19203
|
-
repo_id:
|
|
19237
|
+
repo_id: z15.string().optional(),
|
|
19204
19238
|
/** Commit SHA (defaults to snapshot commit if omitted) */
|
|
19205
|
-
commit_sha:
|
|
19239
|
+
commit_sha: z15.string().optional(),
|
|
19206
19240
|
/** Canonical excerpt */
|
|
19207
|
-
excerpt:
|
|
19241
|
+
excerpt: z15.string(),
|
|
19208
19242
|
/** Lexmap module ID if applicable */
|
|
19209
|
-
lexmap_module_id:
|
|
19243
|
+
lexmap_module_id: z15.string().optional(),
|
|
19210
19244
|
/** Change that introduced this */
|
|
19211
19245
|
introducing_change: IntroducingChange.optional()
|
|
19212
19246
|
});
|
|
19213
|
-
var VerificationExpectations =
|
|
19247
|
+
var VerificationExpectations = z15.object({
|
|
19214
19248
|
/** Command to run */
|
|
19215
|
-
cmd:
|
|
19249
|
+
cmd: z15.string(),
|
|
19216
19250
|
/** Expected results */
|
|
19217
|
-
expect:
|
|
19251
|
+
expect: z15.object({
|
|
19218
19252
|
/** Expected exit code (usually 0) */
|
|
19219
|
-
exit_code:
|
|
19253
|
+
exit_code: z15.number().int(),
|
|
19220
19254
|
/** Strings that must appear in output */
|
|
19221
|
-
must_include:
|
|
19255
|
+
must_include: z15.array(z15.string()).optional(),
|
|
19222
19256
|
/** Strings that must not appear */
|
|
19223
|
-
must_not_include:
|
|
19257
|
+
must_not_include: z15.array(z15.string()).optional()
|
|
19224
19258
|
})
|
|
19225
19259
|
});
|
|
19226
|
-
var Budget =
|
|
19260
|
+
var Budget = z15.object({
|
|
19227
19261
|
/** Token budget hint in bytes */
|
|
19228
|
-
max_bytes:
|
|
19262
|
+
max_bytes: z15.number().int().positive().optional(),
|
|
19229
19263
|
/** Fields that were truncated (empty if none) */
|
|
19230
|
-
truncated_fields:
|
|
19264
|
+
truncated_fields: z15.array(z15.string())
|
|
19231
19265
|
});
|
|
19232
|
-
var TaskSnapshot_v1 =
|
|
19266
|
+
var TaskSnapshot_v1 = z15.object({
|
|
19233
19267
|
// Schema version
|
|
19234
|
-
schema_version:
|
|
19268
|
+
schema_version: z15.literal(TASK_CONTRACT_VERSION),
|
|
19235
19269
|
// Identity
|
|
19236
|
-
task_id:
|
|
19237
|
-
procedure:
|
|
19270
|
+
task_id: z15.string().min(1),
|
|
19271
|
+
procedure: z15.string().min(1),
|
|
19238
19272
|
determinism: DeterminismLevel2,
|
|
19239
19273
|
snapshot_hash: SHA256HashOrPlaceholder,
|
|
19240
19274
|
// Provenance (MUST)
|
|
@@ -19244,9 +19278,9 @@ var TaskSnapshot_v1 = z14.object({
|
|
|
19244
19278
|
// Failure evidence (MUST)
|
|
19245
19279
|
failure: FailureEvidence,
|
|
19246
19280
|
// Invariants (SHOULD) - anti-brittleness constraints
|
|
19247
|
-
invariants:
|
|
19281
|
+
invariants: z15.array(z15.string()).optional(),
|
|
19248
19282
|
// Targets (MUST, array)
|
|
19249
|
-
targets:
|
|
19283
|
+
targets: z15.array(Target).min(1),
|
|
19250
19284
|
// Source of truth (SHOULD)
|
|
19251
19285
|
source_of_truth: SourceOfTruth.optional(),
|
|
19252
19286
|
// Verification expectations (MUST)
|
|
@@ -19254,112 +19288,112 @@ var TaskSnapshot_v1 = z14.object({
|
|
|
19254
19288
|
// Budget/truncation (MUST)
|
|
19255
19289
|
budget: Budget,
|
|
19256
19290
|
// Output contract
|
|
19257
|
-
receipt_schema_id:
|
|
19291
|
+
receipt_schema_id: z15.string()
|
|
19258
19292
|
});
|
|
19259
|
-
var StructuredAssumption =
|
|
19293
|
+
var StructuredAssumption = z15.object({
|
|
19260
19294
|
/** Type of assumption */
|
|
19261
19295
|
type: AssumptionType,
|
|
19262
19296
|
/** Assumption text */
|
|
19263
|
-
text:
|
|
19297
|
+
text: z15.string(),
|
|
19264
19298
|
/** Whether it was validated */
|
|
19265
|
-
validated:
|
|
19299
|
+
validated: z15.boolean().optional(),
|
|
19266
19300
|
/** Evidence supporting validation */
|
|
19267
|
-
evidence:
|
|
19301
|
+
evidence: z15.string().optional()
|
|
19268
19302
|
});
|
|
19269
|
-
var AgentClaims =
|
|
19303
|
+
var AgentClaims = z15.object({
|
|
19270
19304
|
/** Whether the task succeeded */
|
|
19271
|
-
success:
|
|
19305
|
+
success: z15.boolean(),
|
|
19272
19306
|
/** Unified diff patch */
|
|
19273
|
-
patch:
|
|
19307
|
+
patch: z15.string().optional(),
|
|
19274
19308
|
/** Files touched (repo-relative) */
|
|
19275
|
-
files_touched:
|
|
19309
|
+
files_touched: z15.array(RepoRelativePath),
|
|
19276
19310
|
/** Rationale for the fix */
|
|
19277
|
-
rationale:
|
|
19311
|
+
rationale: z15.string(),
|
|
19278
19312
|
/** Confidence level */
|
|
19279
19313
|
confidence: ConfidenceLevel,
|
|
19280
19314
|
/** Which invariants were respected */
|
|
19281
|
-
invariants_respected:
|
|
19315
|
+
invariants_respected: z15.array(z15.string()).optional(),
|
|
19282
19316
|
/** Structured assumptions made */
|
|
19283
|
-
assumptions_made:
|
|
19317
|
+
assumptions_made: z15.array(StructuredAssumption)
|
|
19284
19318
|
});
|
|
19285
|
-
var SearchActivity =
|
|
19319
|
+
var SearchActivity = z15.object({
|
|
19286
19320
|
/** Search query */
|
|
19287
|
-
query:
|
|
19321
|
+
query: z15.string(),
|
|
19288
19322
|
/** Search method used */
|
|
19289
|
-
method:
|
|
19323
|
+
method: z15.string().optional(),
|
|
19290
19324
|
/** Roots searched (repo-relative) */
|
|
19291
|
-
roots:
|
|
19325
|
+
roots: z15.array(z15.string()),
|
|
19292
19326
|
/** Number of results found */
|
|
19293
|
-
results_count:
|
|
19327
|
+
results_count: z15.number().int().nonnegative().optional(),
|
|
19294
19328
|
/** Time taken in milliseconds */
|
|
19295
|
-
time_ms:
|
|
19329
|
+
time_ms: z15.number().nonnegative().optional()
|
|
19296
19330
|
});
|
|
19297
|
-
var TokenUsage =
|
|
19298
|
-
input:
|
|
19299
|
-
output:
|
|
19300
|
-
total:
|
|
19331
|
+
var TokenUsage = z15.object({
|
|
19332
|
+
input: z15.number().int().nonnegative(),
|
|
19333
|
+
output: z15.number().int().nonnegative(),
|
|
19334
|
+
total: z15.number().int().nonnegative()
|
|
19301
19335
|
});
|
|
19302
|
-
var CostTracking =
|
|
19336
|
+
var CostTracking = z15.object({
|
|
19303
19337
|
/** Token usage breakdown */
|
|
19304
19338
|
token_usage: TokenUsage.optional(),
|
|
19305
19339
|
/** Number of tool calls made */
|
|
19306
|
-
tool_calls_count:
|
|
19340
|
+
tool_calls_count: z15.number().int().nonnegative().optional(),
|
|
19307
19341
|
/** Elapsed time in milliseconds */
|
|
19308
|
-
elapsed_ms:
|
|
19342
|
+
elapsed_ms: z15.number().nonnegative().optional()
|
|
19309
19343
|
});
|
|
19310
|
-
var AgentVerification =
|
|
19344
|
+
var AgentVerification = z15.object({
|
|
19311
19345
|
/** Whether verification command was run */
|
|
19312
|
-
cmd_ran:
|
|
19346
|
+
cmd_ran: z15.boolean(),
|
|
19313
19347
|
/** Exit code if run */
|
|
19314
|
-
exit_code:
|
|
19348
|
+
exit_code: z15.number().int().optional(),
|
|
19315
19349
|
/** Output snippet */
|
|
19316
|
-
output_snip:
|
|
19350
|
+
output_snip: z15.string().optional()
|
|
19317
19351
|
});
|
|
19318
|
-
var TaskReceipt_v1 =
|
|
19352
|
+
var TaskReceipt_v1 = z15.object({
|
|
19319
19353
|
// Schema version
|
|
19320
|
-
schema_version:
|
|
19354
|
+
schema_version: z15.literal(TASK_CONTRACT_VERSION),
|
|
19321
19355
|
// Identity (echo from snapshot)
|
|
19322
|
-
task_id:
|
|
19356
|
+
task_id: z15.string().min(1),
|
|
19323
19357
|
snapshot_hash: SHA256HashOrPlaceholder,
|
|
19324
19358
|
// Claims (what agent says it did)
|
|
19325
19359
|
claims: AgentClaims,
|
|
19326
19360
|
// Search activity (if agent searched)
|
|
19327
|
-
search_activity:
|
|
19361
|
+
search_activity: z15.array(SearchActivity),
|
|
19328
19362
|
// Cost tracking
|
|
19329
19363
|
cost: CostTracking,
|
|
19330
19364
|
// Agent's verification attempt (still a claim)
|
|
19331
19365
|
agent_verification: AgentVerification.optional(),
|
|
19332
19366
|
// Blockers (if not successful)
|
|
19333
|
-
blockers:
|
|
19367
|
+
blockers: z15.array(z15.string())
|
|
19334
19368
|
});
|
|
19335
|
-
var DetectedFailure =
|
|
19336
|
-
type:
|
|
19337
|
-
message:
|
|
19338
|
-
file:
|
|
19339
|
-
line:
|
|
19369
|
+
var DetectedFailure = z15.object({
|
|
19370
|
+
type: z15.string(),
|
|
19371
|
+
message: z15.string(),
|
|
19372
|
+
file: z15.string().optional(),
|
|
19373
|
+
line: z15.number().int().positive().optional()
|
|
19340
19374
|
});
|
|
19341
|
-
var EngineVerification_v1 =
|
|
19375
|
+
var EngineVerification_v1 = z15.object({
|
|
19342
19376
|
// Identity
|
|
19343
|
-
task_id:
|
|
19344
|
-
timestamp:
|
|
19377
|
+
task_id: z15.string().min(1),
|
|
19378
|
+
timestamp: z15.string().datetime(),
|
|
19345
19379
|
// Hash binding (audit trail)
|
|
19346
19380
|
snapshot_hash: SHA256HashOrPlaceholder,
|
|
19347
19381
|
receipt_hash: SHA256HashOrPlaceholder,
|
|
19348
19382
|
// Verification result
|
|
19349
|
-
verified:
|
|
19383
|
+
verified: z15.boolean(),
|
|
19350
19384
|
// What engine ran
|
|
19351
|
-
cmd_ran:
|
|
19352
|
-
exit_code:
|
|
19353
|
-
stdout_snip:
|
|
19354
|
-
stderr_snip:
|
|
19385
|
+
cmd_ran: z15.string(),
|
|
19386
|
+
exit_code: z15.number().int(),
|
|
19387
|
+
stdout_snip: z15.string(),
|
|
19388
|
+
stderr_snip: z15.string(),
|
|
19355
19389
|
// Patch verification
|
|
19356
19390
|
patch_hash: SHA256HashOrPlaceholder.optional(),
|
|
19357
|
-
patch_applied:
|
|
19391
|
+
patch_applied: z15.boolean(),
|
|
19358
19392
|
// Comparison with agent claim
|
|
19359
|
-
agent_claimed:
|
|
19360
|
-
trust_gap:
|
|
19393
|
+
agent_claimed: z15.boolean(),
|
|
19394
|
+
trust_gap: z15.boolean(),
|
|
19361
19395
|
// Failures detected
|
|
19362
|
-
failures:
|
|
19396
|
+
failures: z15.array(DetectedFailure)
|
|
19363
19397
|
});
|
|
19364
19398
|
|
|
19365
19399
|
// src/schemas/agent-work-projection.ts
|
|
@@ -19370,15 +19404,15 @@ var MAX_PATH_LENGTH = 16384;
|
|
|
19370
19404
|
var MAX_RUNTIME_LENGTH = 512;
|
|
19371
19405
|
var MAX_TIMESTAMP_LENGTH = 64;
|
|
19372
19406
|
var MAX_DECIMAL_IDENTITY_LENGTH = 32;
|
|
19373
|
-
var BoundedIdentifier =
|
|
19374
|
-
var BoundedRuntime =
|
|
19375
|
-
var Timestamp =
|
|
19376
|
-
var CanonicalGitObjectId =
|
|
19377
|
-
var WindowsAbsolutePath =
|
|
19407
|
+
var BoundedIdentifier = z16.string().min(1).max(MAX_IDENTIFIER_LENGTH).refine((value) => !value.includes("\0"), { message: "must not contain NUL bytes" });
|
|
19408
|
+
var BoundedRuntime = z16.string().min(1).max(MAX_RUNTIME_LENGTH).refine((value) => !value.includes("\0"), { message: "must not contain NUL bytes" });
|
|
19409
|
+
var Timestamp = z16.string().max(MAX_TIMESTAMP_LENGTH).datetime({ offset: true });
|
|
19410
|
+
var CanonicalGitObjectId = z16.string().regex(/^(?:[a-f0-9]{40}|[a-f0-9]{64})$/, "Must be a lowercase full Git object ID");
|
|
19411
|
+
var WindowsAbsolutePath = z16.string().min(3).max(MAX_PATH_LENGTH).refine((value) => !value.includes("\0"), { message: "must not contain NUL bytes" }).refine(
|
|
19378
19412
|
(value) => /^[a-z]:[\\/]/iu.test(value) || /^\\\\[^\\/\0]+[\\/][^\\/\0]+(?:[\\/]|$)/u.test(value),
|
|
19379
19413
|
{ message: "must be an absolute Windows drive or UNC path" }
|
|
19380
19414
|
);
|
|
19381
|
-
var LinuxAbsolutePath =
|
|
19415
|
+
var LinuxAbsolutePath = z16.string().min(1).max(MAX_PATH_LENGTH).refine((value) => !value.includes("\0"), { message: "must not contain NUL bytes" }).refine((value) => value.startsWith("/") && !value.startsWith("//"), {
|
|
19382
19416
|
message: "must be an absolute native Linux path"
|
|
19383
19417
|
}).refine((value) => !value.includes("\\"), {
|
|
19384
19418
|
message: "must use native Linux path separators"
|
|
@@ -19389,35 +19423,13 @@ var LinuxAbsolutePath = z15.string().min(1).max(MAX_PATH_LENGTH).refine((value)
|
|
|
19389
19423
|
}).refine((value) => value === "/" || !value.endsWith("/"), {
|
|
19390
19424
|
message: "must not contain a trailing path separator"
|
|
19391
19425
|
});
|
|
19392
|
-
var DecimalIdentity =
|
|
19393
|
-
function boundedStrictObject(shape) {
|
|
19394
|
-
const allowedKeys = new Set(Object.keys(shape));
|
|
19395
|
-
return z15.preprocess((input) => {
|
|
19396
|
-
if (input === null || typeof input !== "object" || Array.isArray(input)) {
|
|
19397
|
-
return input;
|
|
19398
|
-
}
|
|
19399
|
-
try {
|
|
19400
|
-
const prototype = Object.getPrototypeOf(input);
|
|
19401
|
-
if (prototype !== Object.prototype && prototype !== null) {
|
|
19402
|
-
return null;
|
|
19403
|
-
}
|
|
19404
|
-
for (const key of Reflect.ownKeys(input)) {
|
|
19405
|
-
if (typeof key !== "string" || !allowedKeys.has(key)) {
|
|
19406
|
-
return null;
|
|
19407
|
-
}
|
|
19408
|
-
}
|
|
19409
|
-
} catch {
|
|
19410
|
-
return null;
|
|
19411
|
-
}
|
|
19412
|
-
return input;
|
|
19413
|
-
}, z15.object(shape));
|
|
19414
|
-
}
|
|
19426
|
+
var DecimalIdentity = z16.string().max(MAX_DECIMAL_IDENTITY_LENGTH).regex(/^(?:0|[1-9][0-9]*)$/, "must be a decimal integer");
|
|
19415
19427
|
var NativeDirectoryIdentityClaim_v1 = boundedStrictObject({
|
|
19416
19428
|
device: DecimalIdentity,
|
|
19417
19429
|
inode: DecimalIdentity
|
|
19418
19430
|
});
|
|
19419
19431
|
var ProjectionRequestShape = {
|
|
19420
|
-
schema_version:
|
|
19432
|
+
schema_version: z16.literal(NATIVE_WSL_PROJECTION_CONTRACT_VERSION),
|
|
19421
19433
|
request_id: BoundedIdentifier,
|
|
19422
19434
|
repository: boundedStrictObject({
|
|
19423
19435
|
id: BoundedIdentifier,
|
|
@@ -19429,8 +19441,8 @@ var ProjectionRequestShape = {
|
|
|
19429
19441
|
wsl_distribution: BoundedRuntime,
|
|
19430
19442
|
wsl_git_runtime: BoundedRuntime,
|
|
19431
19443
|
wsl_repository_path: LinuxAbsolutePath,
|
|
19432
|
-
head_policy:
|
|
19433
|
-
dirty_policy:
|
|
19444
|
+
head_policy: z16.enum(["observe", "require_base"]),
|
|
19445
|
+
dirty_policy: z16.enum(["require_clean", "committed_base_only"])
|
|
19434
19446
|
}),
|
|
19435
19447
|
native: boundedStrictObject({
|
|
19436
19448
|
host_id: BoundedIdentifier,
|
|
@@ -19456,7 +19468,7 @@ var NativeWslProjectionRequest_v1 = boundedStrictObject({
|
|
|
19456
19468
|
);
|
|
19457
19469
|
});
|
|
19458
19470
|
var NativeWslProjectionRequestJsonSchema = closeJsonSchemaObjects(
|
|
19459
|
-
|
|
19471
|
+
z16.toJSONSchema(NativeWslProjectionRequest_v1, {
|
|
19460
19472
|
target: "draft-7"
|
|
19461
19473
|
})
|
|
19462
19474
|
);
|
|
@@ -19468,14 +19480,14 @@ function createNativeWslProjectionRequest(input) {
|
|
|
19468
19480
|
});
|
|
19469
19481
|
}
|
|
19470
19482
|
var SourceObservationShape = {
|
|
19471
|
-
schema_version:
|
|
19483
|
+
schema_version: z16.literal(NATIVE_WSL_PROJECTION_CONTRACT_VERSION),
|
|
19472
19484
|
repository_id: BoundedIdentifier,
|
|
19473
19485
|
request_digest: SHA256Hash,
|
|
19474
19486
|
observed_remote_hash: SHA256Hash,
|
|
19475
19487
|
source_head_sha: CanonicalGitObjectId,
|
|
19476
19488
|
requested_object_sha: CanonicalGitObjectId,
|
|
19477
|
-
requested_object_type:
|
|
19478
|
-
cleanliness:
|
|
19489
|
+
requested_object_type: z16.enum(["commit", "missing", "other"]),
|
|
19490
|
+
cleanliness: z16.enum(["clean", "dirty", "unknown"]),
|
|
19479
19491
|
observed_at: Timestamp
|
|
19480
19492
|
};
|
|
19481
19493
|
var SourceObservationBody = boundedStrictObject(SourceObservationShape);
|
|
@@ -19501,22 +19513,22 @@ function createNativeWslSourceObservation(input) {
|
|
|
19501
19513
|
var DeclaredWindowsRoot = boundedStrictObject({
|
|
19502
19514
|
runtime_id: BoundedRuntime,
|
|
19503
19515
|
path: WindowsAbsolutePath,
|
|
19504
|
-
verification:
|
|
19516
|
+
verification: z16.literal("declared")
|
|
19505
19517
|
});
|
|
19506
19518
|
var ObservedWslRoot = boundedStrictObject({
|
|
19507
19519
|
runtime_id: BoundedRuntime,
|
|
19508
19520
|
path: LinuxAbsolutePath,
|
|
19509
|
-
verification:
|
|
19521
|
+
verification: z16.literal("git_observed"),
|
|
19510
19522
|
observation_digest: SHA256Hash
|
|
19511
19523
|
});
|
|
19512
19524
|
var VerifiedNativeRoot = boundedStrictObject({
|
|
19513
19525
|
runtime_id: BoundedRuntime,
|
|
19514
19526
|
path: LinuxAbsolutePath,
|
|
19515
|
-
verification:
|
|
19527
|
+
verification: z16.literal("directory_identity"),
|
|
19516
19528
|
directory_identity: NativeDirectoryIdentityClaim_v1
|
|
19517
19529
|
});
|
|
19518
19530
|
var ProjectionPathMappingShape = {
|
|
19519
|
-
schema_version:
|
|
19531
|
+
schema_version: z16.literal(NATIVE_WSL_PROJECTION_CONTRACT_VERSION),
|
|
19520
19532
|
projection_id: BoundedIdentifier,
|
|
19521
19533
|
repository_id: BoundedIdentifier,
|
|
19522
19534
|
base_sha: CanonicalGitObjectId,
|
|
@@ -19551,7 +19563,7 @@ function createNativeWslProjectionPathMapping(input) {
|
|
|
19551
19563
|
});
|
|
19552
19564
|
}
|
|
19553
19565
|
var ProjectionManifestShape = {
|
|
19554
|
-
schema_version:
|
|
19566
|
+
schema_version: z16.literal(NATIVE_WSL_PROJECTION_CONTRACT_VERSION),
|
|
19555
19567
|
projection_id: BoundedIdentifier,
|
|
19556
19568
|
repository_id: BoundedIdentifier,
|
|
19557
19569
|
base_sha: CanonicalGitObjectId,
|
|
@@ -19681,7 +19693,7 @@ function requireValidProjectionManifest(manifest, context) {
|
|
|
19681
19693
|
);
|
|
19682
19694
|
}
|
|
19683
19695
|
var ExecutionPathMappingShape = {
|
|
19684
|
-
schema_version:
|
|
19696
|
+
schema_version: z16.literal(NATIVE_WSL_PROJECTION_CONTRACT_VERSION),
|
|
19685
19697
|
projection_id: BoundedIdentifier,
|
|
19686
19698
|
repository_id: BoundedIdentifier,
|
|
19687
19699
|
base_sha: CanonicalGitObjectId,
|
|
@@ -19720,8 +19732,8 @@ function createNativeWslExecutionPathMapping(input) {
|
|
|
19720
19732
|
});
|
|
19721
19733
|
}
|
|
19722
19734
|
var NativeExecutionPathMappingShape = {
|
|
19723
|
-
schema_version:
|
|
19724
|
-
mapping_kind:
|
|
19735
|
+
schema_version: z16.literal(NATIVE_WSL_PROJECTION_CONTRACT_VERSION),
|
|
19736
|
+
mapping_kind: z16.literal("native_linux"),
|
|
19725
19737
|
repository_id: BoundedIdentifier,
|
|
19726
19738
|
base_sha: CanonicalGitObjectId,
|
|
19727
19739
|
native_host_id: BoundedIdentifier,
|
|
@@ -19754,7 +19766,7 @@ function createNativeExecutionPathMapping(input) {
|
|
|
19754
19766
|
mapping_digest: projectionHash("native-execution-path-mapping", body)
|
|
19755
19767
|
});
|
|
19756
19768
|
}
|
|
19757
|
-
var AgentExecutionPathMapping_v1 =
|
|
19769
|
+
var AgentExecutionPathMapping_v1 = z16.union([
|
|
19758
19770
|
NativeWslExecutionPathMapping_v1,
|
|
19759
19771
|
NativeExecutionPathMapping_v1
|
|
19760
19772
|
]);
|
|
@@ -19789,8 +19801,8 @@ function validateAgentExecutionPathBinding(mappings, context) {
|
|
|
19789
19801
|
mappingDigest: mapping.mapping_digest
|
|
19790
19802
|
};
|
|
19791
19803
|
}
|
|
19792
|
-
var NativeWslProjectionOutcome =
|
|
19793
|
-
var NativeWslProjectionReasonCode =
|
|
19804
|
+
var NativeWslProjectionOutcome = z16.enum(["prepared", "reused", "rejected", "quarantined"]);
|
|
19805
|
+
var NativeWslProjectionReasonCode = z16.enum([
|
|
19794
19806
|
"projection_prepared",
|
|
19795
19807
|
"projection_reused",
|
|
19796
19808
|
"source_dirty",
|
|
@@ -19809,7 +19821,7 @@ var NativeWslProjectionReasonCode = z15.enum([
|
|
|
19809
19821
|
"operation_failed"
|
|
19810
19822
|
]);
|
|
19811
19823
|
var ProjectionReceiptShape = {
|
|
19812
|
-
schema_version:
|
|
19824
|
+
schema_version: z16.literal(NATIVE_WSL_PROJECTION_CONTRACT_VERSION),
|
|
19813
19825
|
request_id: BoundedIdentifier,
|
|
19814
19826
|
request_digest: SHA256Hash,
|
|
19815
19827
|
outcome: NativeWslProjectionOutcome,
|
|
@@ -19842,7 +19854,7 @@ function createNativeWslProjectionReceipt(input) {
|
|
|
19842
19854
|
});
|
|
19843
19855
|
}
|
|
19844
19856
|
var ProjectionSelectionShape = {
|
|
19845
|
-
schema_version:
|
|
19857
|
+
schema_version: z16.literal(NATIVE_WSL_PROJECTION_CONTRACT_VERSION),
|
|
19846
19858
|
manifest_digest: SHA256Hash,
|
|
19847
19859
|
receipt: NativeWslProjectionReceipt_v1,
|
|
19848
19860
|
source_observation: NativeWslSourceObservation_v1
|
|
@@ -19947,7 +19959,7 @@ function requireValidProjectionSelection(selection, context) {
|
|
|
19947
19959
|
);
|
|
19948
19960
|
}
|
|
19949
19961
|
}
|
|
19950
|
-
var NativeWslProjectionInventoryState =
|
|
19962
|
+
var NativeWslProjectionInventoryState = z16.enum([
|
|
19951
19963
|
"absent",
|
|
19952
19964
|
"ready",
|
|
19953
19965
|
"staging",
|
|
@@ -19956,7 +19968,7 @@ var NativeWslProjectionInventoryState = z15.enum([
|
|
|
19956
19968
|
"interrupted",
|
|
19957
19969
|
"conflicting"
|
|
19958
19970
|
]);
|
|
19959
|
-
var NativeWslProjectionPlanAction =
|
|
19971
|
+
var NativeWslProjectionPlanAction = z16.enum([
|
|
19960
19972
|
"prepare_staging",
|
|
19961
19973
|
"reuse_ready",
|
|
19962
19974
|
"wait_for_same_request",
|
|
@@ -19964,7 +19976,7 @@ var NativeWslProjectionPlanAction = z15.enum([
|
|
|
19964
19976
|
"cleanup_quarantine_then_prepare",
|
|
19965
19977
|
"refuse_conflict"
|
|
19966
19978
|
]);
|
|
19967
|
-
var NativeWslProjectionPlanReason =
|
|
19979
|
+
var NativeWslProjectionPlanReason = z16.enum([
|
|
19968
19980
|
"projection_absent",
|
|
19969
19981
|
"projection_exact_match",
|
|
19970
19982
|
"projection_staging_same_request",
|
|
@@ -20183,68 +20195,46 @@ import { lstat, open as open2, readFile as readFile4, readdir, rename, rmdir, un
|
|
|
20183
20195
|
import path34 from "path";
|
|
20184
20196
|
|
|
20185
20197
|
// src/runs/agent-work-projection-planner.ts
|
|
20186
|
-
import { z as
|
|
20187
|
-
var ProjectionId =
|
|
20188
|
-
var Timestamp2 =
|
|
20189
|
-
|
|
20190
|
-
|
|
20191
|
-
|
|
20192
|
-
|
|
20193
|
-
return input;
|
|
20194
|
-
}
|
|
20195
|
-
try {
|
|
20196
|
-
const prototype = Object.getPrototypeOf(input);
|
|
20197
|
-
if (prototype !== Object.prototype && prototype !== null) {
|
|
20198
|
-
return null;
|
|
20199
|
-
}
|
|
20200
|
-
for (const key of Reflect.ownKeys(input)) {
|
|
20201
|
-
if (typeof key !== "string" || !allowedKeys.has(key)) {
|
|
20202
|
-
return null;
|
|
20203
|
-
}
|
|
20204
|
-
}
|
|
20205
|
-
} catch {
|
|
20206
|
-
return null;
|
|
20207
|
-
}
|
|
20208
|
-
return input;
|
|
20209
|
-
}, z16.object(shape));
|
|
20210
|
-
}
|
|
20211
|
-
var NativeWslProjectionInventoryObservation_v1 = z16.union([
|
|
20212
|
-
boundedStrictObject2({ state: z16.literal("absent") }),
|
|
20213
|
-
boundedStrictObject2({
|
|
20214
|
-
state: z16.literal("ready"),
|
|
20198
|
+
import { z as z17 } from "zod";
|
|
20199
|
+
var ProjectionId = z17.string().min(1).max(4096);
|
|
20200
|
+
var Timestamp2 = z17.string().max(64).datetime({ offset: true });
|
|
20201
|
+
var NativeWslProjectionInventoryObservation_v1 = z17.union([
|
|
20202
|
+
boundedStrictObject({ state: z17.literal("absent") }),
|
|
20203
|
+
boundedStrictObject({
|
|
20204
|
+
state: z17.literal("ready"),
|
|
20215
20205
|
manifest: NativeWslProjectionManifest_v1
|
|
20216
20206
|
}),
|
|
20217
|
-
|
|
20218
|
-
state:
|
|
20207
|
+
boundedStrictObject({
|
|
20208
|
+
state: z17.literal("staging"),
|
|
20219
20209
|
projection_id: ProjectionId,
|
|
20220
20210
|
request_digest: SHA256Hash,
|
|
20221
20211
|
started_at: Timestamp2
|
|
20222
20212
|
}),
|
|
20223
|
-
|
|
20224
|
-
state:
|
|
20213
|
+
boundedStrictObject({
|
|
20214
|
+
state: z17.literal("quarantined"),
|
|
20225
20215
|
projection_id: ProjectionId.optional(),
|
|
20226
20216
|
request_digest: SHA256Hash.optional(),
|
|
20227
20217
|
quarantined_at: Timestamp2
|
|
20228
20218
|
}),
|
|
20229
|
-
|
|
20230
|
-
state:
|
|
20219
|
+
boundedStrictObject({
|
|
20220
|
+
state: z17.literal("invalid"),
|
|
20231
20221
|
projection_id: ProjectionId.optional(),
|
|
20232
20222
|
request_digest: SHA256Hash.optional()
|
|
20233
20223
|
}),
|
|
20234
|
-
|
|
20235
|
-
state:
|
|
20224
|
+
boundedStrictObject({
|
|
20225
|
+
state: z17.literal("interrupted"),
|
|
20236
20226
|
projection_id: ProjectionId,
|
|
20237
20227
|
request_digest: SHA256Hash,
|
|
20238
20228
|
started_at: Timestamp2
|
|
20239
20229
|
}),
|
|
20240
|
-
|
|
20241
|
-
state:
|
|
20230
|
+
boundedStrictObject({
|
|
20231
|
+
state: z17.literal("conflicting"),
|
|
20242
20232
|
projection_id: ProjectionId,
|
|
20243
20233
|
request_digest: SHA256Hash.optional(),
|
|
20244
20234
|
observed_at: Timestamp2
|
|
20245
20235
|
})
|
|
20246
20236
|
]);
|
|
20247
|
-
var NativeWslProjectionNextAction =
|
|
20237
|
+
var NativeWslProjectionNextAction = z17.enum([
|
|
20248
20238
|
"prepare_projection_staging",
|
|
20249
20239
|
"reuse_projection",
|
|
20250
20240
|
"retry_after_active_request",
|
|
@@ -20252,17 +20242,17 @@ var NativeWslProjectionNextAction = z16.enum([
|
|
|
20252
20242
|
"cleanup_quarantined_projection",
|
|
20253
20243
|
"stop_and_report_conflict"
|
|
20254
20244
|
]);
|
|
20255
|
-
var NativeWslProjectionPlan_v1 =
|
|
20256
|
-
schema_version:
|
|
20245
|
+
var NativeWslProjectionPlan_v1 = boundedStrictObject({
|
|
20246
|
+
schema_version: z17.literal(NATIVE_WSL_PROJECTION_CONTRACT_VERSION),
|
|
20257
20247
|
projection_id: ProjectionId,
|
|
20258
20248
|
request_digest: SHA256Hash,
|
|
20259
20249
|
inventory_state: NativeWslProjectionInventoryState,
|
|
20260
20250
|
action: NativeWslProjectionPlanAction,
|
|
20261
20251
|
reason: NativeWslProjectionPlanReason,
|
|
20262
|
-
selection_allowed:
|
|
20263
|
-
mutation_required:
|
|
20252
|
+
selection_allowed: z17.boolean(),
|
|
20253
|
+
mutation_required: z17.boolean(),
|
|
20264
20254
|
selected_manifest_digest: SHA256Hash.optional(),
|
|
20265
|
-
next_actions:
|
|
20255
|
+
next_actions: z17.array(NativeWslProjectionNextAction).min(1).max(2)
|
|
20266
20256
|
}).superRefine((plan, context) => {
|
|
20267
20257
|
const reusesReady = plan.action === "reuse_ready";
|
|
20268
20258
|
const mutates = plan.action === "prepare_staging" || plan.action === "quarantine_then_prepare" || plan.action === "cleanup_quarantine_then_prepare";
|
|
@@ -20568,8 +20558,6 @@ function boundOutput(value, maxBytes) {
|
|
|
20568
20558
|
}
|
|
20569
20559
|
|
|
20570
20560
|
// src/workspaces/node-git-worktree-broker.ts
|
|
20571
|
-
import { constants as constants2 } from "fs";
|
|
20572
|
-
import { open } from "fs/promises";
|
|
20573
20561
|
import path33 from "path";
|
|
20574
20562
|
|
|
20575
20563
|
// src/workspaces/git-worktree-porcelain.ts
|
|
@@ -20703,6 +20691,999 @@ function setOnce(record, key, value) {
|
|
|
20703
20691
|
record[key] = value;
|
|
20704
20692
|
}
|
|
20705
20693
|
|
|
20694
|
+
// src/workspaces/workspace-boundary-resolver.ts
|
|
20695
|
+
import { randomUUID as randomUUID4 } from "crypto";
|
|
20696
|
+
import { arch, platform as platform2 } from "os";
|
|
20697
|
+
|
|
20698
|
+
// src/workspaces/linux-workspace-boundary.ts
|
|
20699
|
+
import { randomUUID as randomUUID3 } from "crypto";
|
|
20700
|
+
import { constants as constants2 } from "fs";
|
|
20701
|
+
import { open } from "fs/promises";
|
|
20702
|
+
|
|
20703
|
+
// src/workspaces/workspace-boundary.ts
|
|
20704
|
+
import { z as z18 } from "zod";
|
|
20705
|
+
var WORKSPACE_BOUNDARY_CONTRACT_VERSION = "1.0.0";
|
|
20706
|
+
var MAX_IDENTIFIER_LENGTH2 = 4096;
|
|
20707
|
+
var MAX_PATH_LENGTH2 = 32768;
|
|
20708
|
+
var MAX_MESSAGE_LENGTH = 4096;
|
|
20709
|
+
var BoundedIdentifier2 = z18.string().min(1).max(MAX_IDENTIFIER_LENGTH2).refine((value) => !value.includes("\0"), { message: "must not contain NUL bytes" });
|
|
20710
|
+
var BoundedPath = z18.string().min(1).max(MAX_PATH_LENGTH2).refine((value) => !value.includes("\0"), { message: "must not contain NUL bytes" });
|
|
20711
|
+
var Timestamp3 = z18.string().max(64).datetime({ offset: true });
|
|
20712
|
+
var DecimalIdentity2 = z18.string().max(32).regex(/^(?:0|[1-9][0-9]*)$/u, "must be a decimal integer");
|
|
20713
|
+
var HexIdentity = z18.string().min(1).max(64).regex(/^[a-f0-9]+$/u, "must be lowercase hexadecimal");
|
|
20714
|
+
var WorkspaceBoundaryBackendKind = z18.enum([
|
|
20715
|
+
"linux-native",
|
|
20716
|
+
"windows-native",
|
|
20717
|
+
"native-wsl-projection"
|
|
20718
|
+
]);
|
|
20719
|
+
var WorkspaceBoundarySelectionRequest_v1 = z18.union([
|
|
20720
|
+
boundedStrictObject({ mode: z18.literal("native") }),
|
|
20721
|
+
boundedStrictObject({
|
|
20722
|
+
mode: z18.literal("explicit_projection"),
|
|
20723
|
+
profile_id: BoundedIdentifier2
|
|
20724
|
+
})
|
|
20725
|
+
]);
|
|
20726
|
+
var BoundaryClaims = boundedStrictObject({
|
|
20727
|
+
held_directory_identity: z18.boolean(),
|
|
20728
|
+
no_follow_open: z18.boolean(),
|
|
20729
|
+
final_path_from_handle: z18.boolean(),
|
|
20730
|
+
held_ancestor_chain: z18.boolean(),
|
|
20731
|
+
replacement_resistant_process_binding: z18.boolean(),
|
|
20732
|
+
rename_delete_exclusion: z18.boolean(),
|
|
20733
|
+
durable_directory_mutation: z18.boolean()
|
|
20734
|
+
});
|
|
20735
|
+
var InProcessBackend = boundedStrictObject({
|
|
20736
|
+
transport: z18.literal("in_process"),
|
|
20737
|
+
implementation: BoundedIdentifier2,
|
|
20738
|
+
implementation_version: BoundedIdentifier2
|
|
20739
|
+
});
|
|
20740
|
+
var NativeHelperBackend = boundedStrictObject({
|
|
20741
|
+
transport: z18.literal("native_helper"),
|
|
20742
|
+
implementation: BoundedIdentifier2,
|
|
20743
|
+
implementation_version: BoundedIdentifier2,
|
|
20744
|
+
protocol_version: BoundedIdentifier2,
|
|
20745
|
+
artifact_digest: SHA256Hash.optional(),
|
|
20746
|
+
signature: z18.union([
|
|
20747
|
+
boundedStrictObject({
|
|
20748
|
+
status: z18.literal("verified"),
|
|
20749
|
+
signer_identity: BoundedIdentifier2
|
|
20750
|
+
}),
|
|
20751
|
+
boundedStrictObject({
|
|
20752
|
+
status: z18.literal("development_unverified")
|
|
20753
|
+
}),
|
|
20754
|
+
boundedStrictObject({
|
|
20755
|
+
status: z18.literal("not_available")
|
|
20756
|
+
})
|
|
20757
|
+
])
|
|
20758
|
+
});
|
|
20759
|
+
var CapabilityDecisionShape = {
|
|
20760
|
+
schema_version: z18.literal(WORKSPACE_BOUNDARY_CONTRACT_VERSION),
|
|
20761
|
+
decision_id: BoundedIdentifier2,
|
|
20762
|
+
selection: WorkspaceBoundarySelectionRequest_v1,
|
|
20763
|
+
backend_kind: WorkspaceBoundaryBackendKind,
|
|
20764
|
+
state: z18.enum(["ready", "unavailable", "unsupported"]),
|
|
20765
|
+
reason_code: z18.enum([
|
|
20766
|
+
"native_backend_ready",
|
|
20767
|
+
"explicit_projection_ready",
|
|
20768
|
+
"unsupported_host",
|
|
20769
|
+
"unsupported_filesystem",
|
|
20770
|
+
"backend_unavailable",
|
|
20771
|
+
"helper_missing",
|
|
20772
|
+
"helper_integrity_failure",
|
|
20773
|
+
"helper_protocol_mismatch",
|
|
20774
|
+
"helper_signature_unverified",
|
|
20775
|
+
"projection_not_requested",
|
|
20776
|
+
"projection_unavailable"
|
|
20777
|
+
]),
|
|
20778
|
+
host: boundedStrictObject({
|
|
20779
|
+
platform: z18.enum(["linux", "windows", "other"]),
|
|
20780
|
+
architecture: BoundedIdentifier2,
|
|
20781
|
+
path_comparison: z18.enum(["case-sensitive", "case-insensitive"])
|
|
20782
|
+
}),
|
|
20783
|
+
backend: z18.union([InProcessBackend, NativeHelperBackend]),
|
|
20784
|
+
claims: BoundaryClaims,
|
|
20785
|
+
observed_at: Timestamp3
|
|
20786
|
+
};
|
|
20787
|
+
var CapabilityDecisionBody = boundedStrictObject(CapabilityDecisionShape).superRefine(
|
|
20788
|
+
requireValidCapabilityDecision
|
|
20789
|
+
);
|
|
20790
|
+
var WorkspaceBoundaryCapabilityDecision_v1 = boundedStrictObject({
|
|
20791
|
+
...CapabilityDecisionShape,
|
|
20792
|
+
decision_digest: SHA256Hash
|
|
20793
|
+
}).superRefine(requireValidCapabilityDecision).superRefine((decision, context) => {
|
|
20794
|
+
const { decision_digest: _digest, ...body } = decision;
|
|
20795
|
+
requireDigest2(
|
|
20796
|
+
decision.decision_digest,
|
|
20797
|
+
boundaryHash("capability-decision", body),
|
|
20798
|
+
"decision_digest",
|
|
20799
|
+
context
|
|
20800
|
+
);
|
|
20801
|
+
});
|
|
20802
|
+
function createWorkspaceBoundaryCapabilityDecision(input) {
|
|
20803
|
+
const body = CapabilityDecisionBody.parse(input);
|
|
20804
|
+
return WorkspaceBoundaryCapabilityDecision_v1.parse({
|
|
20805
|
+
...body,
|
|
20806
|
+
decision_digest: boundaryHash("capability-decision", body)
|
|
20807
|
+
});
|
|
20808
|
+
}
|
|
20809
|
+
var DirectoryIdentityCommon = {
|
|
20810
|
+
schema_version: z18.literal(WORKSPACE_BOUNDARY_CONTRACT_VERSION),
|
|
20811
|
+
backend_kind: WorkspaceBoundaryBackendKind,
|
|
20812
|
+
canonical_path: BoundedPath,
|
|
20813
|
+
path_comparison: z18.enum(["case-sensitive", "case-insensitive"])
|
|
20814
|
+
};
|
|
20815
|
+
var LinuxDirectoryIdentityShape = {
|
|
20816
|
+
...DirectoryIdentityCommon,
|
|
20817
|
+
identity_kind: z18.literal("linux-device-inode"),
|
|
20818
|
+
device: DecimalIdentity2,
|
|
20819
|
+
inode: DecimalIdentity2
|
|
20820
|
+
};
|
|
20821
|
+
var WindowsDirectoryIdentityShape = {
|
|
20822
|
+
...DirectoryIdentityCommon,
|
|
20823
|
+
identity_kind: z18.literal("windows-volume-file-id"),
|
|
20824
|
+
volume_serial_number: HexIdentity,
|
|
20825
|
+
file_id: HexIdentity
|
|
20826
|
+
};
|
|
20827
|
+
var LinuxDirectoryIdentityBody = boundedStrictObject(LinuxDirectoryIdentityShape).superRefine(
|
|
20828
|
+
(identity, context) => {
|
|
20829
|
+
if (identity.backend_kind === "windows-native") {
|
|
20830
|
+
addIssue(context, ["backend_kind"], "Windows native identities require a Windows file ID");
|
|
20831
|
+
}
|
|
20832
|
+
if (identity.path_comparison !== "case-sensitive") {
|
|
20833
|
+
addIssue(context, ["path_comparison"], "Linux directory identities are case-sensitive");
|
|
20834
|
+
}
|
|
20835
|
+
if (!identity.canonical_path.startsWith("/") || identity.canonical_path.startsWith("//")) {
|
|
20836
|
+
addIssue(context, ["canonical_path"], "Linux identities require an absolute native path");
|
|
20837
|
+
}
|
|
20838
|
+
}
|
|
20839
|
+
);
|
|
20840
|
+
var WindowsDirectoryIdentityBody = boundedStrictObject(WindowsDirectoryIdentityShape).superRefine(
|
|
20841
|
+
(identity, context) => {
|
|
20842
|
+
if (identity.backend_kind !== "windows-native") {
|
|
20843
|
+
addIssue(context, ["backend_kind"], "Windows file IDs require the Windows native backend");
|
|
20844
|
+
}
|
|
20845
|
+
if (identity.path_comparison !== "case-insensitive") {
|
|
20846
|
+
addIssue(context, ["path_comparison"], "Windows directory identities are case-insensitive");
|
|
20847
|
+
}
|
|
20848
|
+
if (!isWindowsAbsolutePath(identity.canonical_path)) {
|
|
20849
|
+
addIssue(context, ["canonical_path"], "Windows identities require an absolute native path");
|
|
20850
|
+
}
|
|
20851
|
+
}
|
|
20852
|
+
);
|
|
20853
|
+
var WorkspaceBoundaryDirectoryIdentity_v1 = z18.union([
|
|
20854
|
+
boundedStrictObject({
|
|
20855
|
+
...LinuxDirectoryIdentityShape,
|
|
20856
|
+
identity_digest: SHA256Hash
|
|
20857
|
+
}).superRefine((identity, context) => {
|
|
20858
|
+
const { identity_digest: _digest, ...body } = identity;
|
|
20859
|
+
const parsed = LinuxDirectoryIdentityBody.safeParse(body);
|
|
20860
|
+
copyIssues(parsed, context);
|
|
20861
|
+
requireDigest2(
|
|
20862
|
+
identity.identity_digest,
|
|
20863
|
+
boundaryHash("directory-identity", body),
|
|
20864
|
+
"identity_digest",
|
|
20865
|
+
context
|
|
20866
|
+
);
|
|
20867
|
+
}),
|
|
20868
|
+
boundedStrictObject({
|
|
20869
|
+
...WindowsDirectoryIdentityShape,
|
|
20870
|
+
identity_digest: SHA256Hash
|
|
20871
|
+
}).superRefine((identity, context) => {
|
|
20872
|
+
const { identity_digest: _digest, ...body } = identity;
|
|
20873
|
+
const parsed = WindowsDirectoryIdentityBody.safeParse(body);
|
|
20874
|
+
copyIssues(parsed, context);
|
|
20875
|
+
requireDigest2(
|
|
20876
|
+
identity.identity_digest,
|
|
20877
|
+
boundaryHash("directory-identity", body),
|
|
20878
|
+
"identity_digest",
|
|
20879
|
+
context
|
|
20880
|
+
);
|
|
20881
|
+
})
|
|
20882
|
+
]);
|
|
20883
|
+
function createWorkspaceBoundaryDirectoryIdentity(input) {
|
|
20884
|
+
const body = input.identity_kind === "linux-device-inode" ? LinuxDirectoryIdentityBody.parse(input) : WindowsDirectoryIdentityBody.parse(input);
|
|
20885
|
+
return WorkspaceBoundaryDirectoryIdentity_v1.parse({
|
|
20886
|
+
...body,
|
|
20887
|
+
identity_digest: boundaryHash("directory-identity", body)
|
|
20888
|
+
});
|
|
20889
|
+
}
|
|
20890
|
+
var WorkspaceBoundaryError_v1 = boundedStrictObject({
|
|
20891
|
+
schema_version: z18.literal(WORKSPACE_BOUNDARY_CONTRACT_VERSION),
|
|
20892
|
+
code: z18.enum([
|
|
20893
|
+
"unsupported_host",
|
|
20894
|
+
"unsupported_filesystem",
|
|
20895
|
+
"backend_unavailable",
|
|
20896
|
+
"helper_integrity_failure",
|
|
20897
|
+
"helper_protocol_mismatch",
|
|
20898
|
+
"invalid_path",
|
|
20899
|
+
"reparse_point_rejected",
|
|
20900
|
+
"identity_changed",
|
|
20901
|
+
"lease_stale",
|
|
20902
|
+
"containment_violation",
|
|
20903
|
+
"sharing_violation",
|
|
20904
|
+
"operation_failed",
|
|
20905
|
+
"durability_indeterminate"
|
|
20906
|
+
]),
|
|
20907
|
+
message: z18.string().min(1).max(MAX_MESSAGE_LENGTH),
|
|
20908
|
+
retryable: z18.boolean(),
|
|
20909
|
+
effect_state: z18.enum(["no_effect", "effect_recorded", "effect_unknown"]),
|
|
20910
|
+
operation_id: BoundedIdentifier2.optional()
|
|
20911
|
+
});
|
|
20912
|
+
var LeaseReceiptShape = {
|
|
20913
|
+
schema_version: z18.literal(WORKSPACE_BOUNDARY_CONTRACT_VERSION),
|
|
20914
|
+
lease_id: BoundedIdentifier2,
|
|
20915
|
+
orchestration_lease_id: BoundedIdentifier2,
|
|
20916
|
+
orchestration_lease_revision: z18.number().int().nonnegative(),
|
|
20917
|
+
owner_id: BoundedIdentifier2,
|
|
20918
|
+
backend_kind: WorkspaceBoundaryBackendKind,
|
|
20919
|
+
capability_decision_digest: SHA256Hash,
|
|
20920
|
+
root_identity_digests: z18.array(SHA256Hash).min(1).max(16),
|
|
20921
|
+
phase: z18.enum(["acquired", "released", "expired", "reconciled"]),
|
|
20922
|
+
observed_at: Timestamp3
|
|
20923
|
+
};
|
|
20924
|
+
var LeaseReceiptBody = boundedStrictObject(LeaseReceiptShape);
|
|
20925
|
+
var WorkspaceBoundaryLeaseReceipt_v1 = boundedStrictObject({
|
|
20926
|
+
...LeaseReceiptShape,
|
|
20927
|
+
receipt_digest: SHA256Hash
|
|
20928
|
+
}).superRefine((receipt, context) => {
|
|
20929
|
+
const { receipt_digest: _digest, ...body } = receipt;
|
|
20930
|
+
requireDigest2(
|
|
20931
|
+
receipt.receipt_digest,
|
|
20932
|
+
boundaryHash("lease-receipt", body),
|
|
20933
|
+
"receipt_digest",
|
|
20934
|
+
context
|
|
20935
|
+
);
|
|
20936
|
+
});
|
|
20937
|
+
function createWorkspaceBoundaryLeaseReceipt(input) {
|
|
20938
|
+
const parsed = LeaseReceiptBody.parse(input);
|
|
20939
|
+
const body = LeaseReceiptBody.parse({
|
|
20940
|
+
...parsed,
|
|
20941
|
+
root_identity_digests: canonicalDigestSet(parsed.root_identity_digests)
|
|
20942
|
+
});
|
|
20943
|
+
return WorkspaceBoundaryLeaseReceipt_v1.parse({
|
|
20944
|
+
...body,
|
|
20945
|
+
receipt_digest: boundaryHash("lease-receipt", body)
|
|
20946
|
+
});
|
|
20947
|
+
}
|
|
20948
|
+
var WorkspaceBoundaryOperationKind = z18.enum([
|
|
20949
|
+
"capture-root",
|
|
20950
|
+
"open-child",
|
|
20951
|
+
"create-child",
|
|
20952
|
+
"assert-current",
|
|
20953
|
+
"read-owned-file",
|
|
20954
|
+
"write-owned-file",
|
|
20955
|
+
"rename-owned",
|
|
20956
|
+
"remove-owned",
|
|
20957
|
+
"sync-directory",
|
|
20958
|
+
"spawn-process"
|
|
20959
|
+
]);
|
|
20960
|
+
var OperationReceiptShape = {
|
|
20961
|
+
schema_version: z18.literal(WORKSPACE_BOUNDARY_CONTRACT_VERSION),
|
|
20962
|
+
operation_id: BoundedIdentifier2,
|
|
20963
|
+
lease_id: BoundedIdentifier2,
|
|
20964
|
+
backend_kind: WorkspaceBoundaryBackendKind,
|
|
20965
|
+
operation: WorkspaceBoundaryOperationKind,
|
|
20966
|
+
mutation: z18.boolean(),
|
|
20967
|
+
outcome: z18.enum(["completed", "rejected", "indeterminate"]),
|
|
20968
|
+
durability: z18.enum(["not_applicable", "not_requested", "committed", "indeterminate"]),
|
|
20969
|
+
identity_digests: z18.array(SHA256Hash).min(1).max(32),
|
|
20970
|
+
started_at: Timestamp3,
|
|
20971
|
+
completed_at: Timestamp3,
|
|
20972
|
+
error: WorkspaceBoundaryError_v1.optional()
|
|
20973
|
+
};
|
|
20974
|
+
var OperationReceiptBody = boundedStrictObject(OperationReceiptShape).superRefine(
|
|
20975
|
+
requireValidOperationReceipt
|
|
20976
|
+
);
|
|
20977
|
+
var WorkspaceBoundaryOperationReceipt_v1 = boundedStrictObject({
|
|
20978
|
+
...OperationReceiptShape,
|
|
20979
|
+
receipt_digest: SHA256Hash
|
|
20980
|
+
}).superRefine(requireValidOperationReceipt).superRefine((receipt, context) => {
|
|
20981
|
+
const { receipt_digest: _digest, ...body } = receipt;
|
|
20982
|
+
requireDigest2(
|
|
20983
|
+
receipt.receipt_digest,
|
|
20984
|
+
boundaryHash("operation-receipt", body),
|
|
20985
|
+
"receipt_digest",
|
|
20986
|
+
context
|
|
20987
|
+
);
|
|
20988
|
+
});
|
|
20989
|
+
function createWorkspaceBoundaryOperationReceipt(input) {
|
|
20990
|
+
const parsed = OperationReceiptBody.parse(input);
|
|
20991
|
+
const body = OperationReceiptBody.parse({
|
|
20992
|
+
...parsed,
|
|
20993
|
+
identity_digests: canonicalDigestSet(parsed.identity_digests)
|
|
20994
|
+
});
|
|
20995
|
+
return WorkspaceBoundaryOperationReceipt_v1.parse({
|
|
20996
|
+
...body,
|
|
20997
|
+
receipt_digest: boundaryHash("operation-receipt", body)
|
|
20998
|
+
});
|
|
20999
|
+
}
|
|
21000
|
+
function canonicalDigestSet(digests) {
|
|
21001
|
+
return [...new Set(digests)].sort();
|
|
21002
|
+
}
|
|
21003
|
+
var workspaceBoundaryLeaseBrand = /* @__PURE__ */ Symbol("WorkspaceBoundaryLease");
|
|
21004
|
+
function requireValidCapabilityDecision(decision, context) {
|
|
21005
|
+
const readyReason = decision.reason_code === "native_backend_ready" || decision.reason_code === "explicit_projection_ready";
|
|
21006
|
+
if (decision.state === "ready" !== readyReason) {
|
|
21007
|
+
addIssue(context, ["reason_code"], "ready state and reason code must agree");
|
|
21008
|
+
}
|
|
21009
|
+
if (decision.state === "ready" && decision.selection.mode === "native" && decision.reason_code !== "native_backend_ready") {
|
|
21010
|
+
addIssue(context, ["reason_code"], "native selection requires the native ready reason");
|
|
21011
|
+
}
|
|
21012
|
+
if (decision.state === "ready" && decision.selection.mode === "explicit_projection" && decision.reason_code !== "explicit_projection_ready") {
|
|
21013
|
+
addIssue(context, ["reason_code"], "projection selection requires the projection ready reason");
|
|
21014
|
+
}
|
|
21015
|
+
if (decision.selection.mode === "explicit_projection") {
|
|
21016
|
+
if (decision.backend_kind !== "native-wsl-projection") {
|
|
21017
|
+
addIssue(context, ["backend_kind"], "explicit projection must select the projection backend");
|
|
21018
|
+
}
|
|
21019
|
+
} else if (decision.backend_kind === "native-wsl-projection") {
|
|
21020
|
+
addIssue(context, ["backend_kind"], "projection selection must be explicit");
|
|
21021
|
+
}
|
|
21022
|
+
if (decision.state === "ready" && decision.backend_kind === "linux-native") {
|
|
21023
|
+
if (decision.host.platform !== "linux") {
|
|
21024
|
+
addIssue(context, ["host", "platform"], "Linux native requires a Linux host probe");
|
|
21025
|
+
}
|
|
21026
|
+
if (decision.host.path_comparison !== "case-sensitive") {
|
|
21027
|
+
addIssue(context, ["host", "path_comparison"], "Linux native requires case-sensitive paths");
|
|
21028
|
+
}
|
|
21029
|
+
if (decision.backend.transport !== "in_process") {
|
|
21030
|
+
addIssue(context, ["backend", "transport"], "Linux native uses the in-process boundary");
|
|
21031
|
+
}
|
|
21032
|
+
}
|
|
21033
|
+
if (decision.state === "ready" && decision.backend_kind === "windows-native") {
|
|
21034
|
+
if (decision.host.platform !== "windows") {
|
|
21035
|
+
addIssue(context, ["host", "platform"], "Windows native requires a Windows host probe");
|
|
21036
|
+
}
|
|
21037
|
+
if (decision.host.path_comparison !== "case-insensitive") {
|
|
21038
|
+
addIssue(
|
|
21039
|
+
context,
|
|
21040
|
+
["host", "path_comparison"],
|
|
21041
|
+
"Windows native requires case-insensitive paths"
|
|
21042
|
+
);
|
|
21043
|
+
}
|
|
21044
|
+
if (decision.backend.transport !== "native_helper") {
|
|
21045
|
+
addIssue(context, ["backend", "transport"], "Windows native requires the native helper");
|
|
21046
|
+
}
|
|
21047
|
+
}
|
|
21048
|
+
if (decision.state === "ready") {
|
|
21049
|
+
const requiredClaims = [
|
|
21050
|
+
"held_directory_identity",
|
|
21051
|
+
"no_follow_open",
|
|
21052
|
+
"final_path_from_handle",
|
|
21053
|
+
"held_ancestor_chain",
|
|
21054
|
+
"replacement_resistant_process_binding"
|
|
21055
|
+
];
|
|
21056
|
+
for (const claim of requiredClaims) {
|
|
21057
|
+
if (!decision.claims[claim]) {
|
|
21058
|
+
addIssue(context, ["claims", claim], "ready backends must enforce this claim");
|
|
21059
|
+
}
|
|
21060
|
+
}
|
|
21061
|
+
}
|
|
21062
|
+
if (decision.state === "ready" && decision.backend.transport === "native_helper" && (decision.backend.signature.status !== "verified" || !decision.backend.artifact_digest)) {
|
|
21063
|
+
addIssue(
|
|
21064
|
+
context,
|
|
21065
|
+
["backend", "signature"],
|
|
21066
|
+
"a ready native helper must have a verified signature and artifact digest"
|
|
21067
|
+
);
|
|
21068
|
+
}
|
|
21069
|
+
}
|
|
21070
|
+
function requireValidOperationReceipt(receipt, context) {
|
|
21071
|
+
if (receipt.outcome === "completed" === Boolean(receipt.error)) {
|
|
21072
|
+
addIssue(context, ["error"], "completed operations omit errors; other outcomes require one");
|
|
21073
|
+
}
|
|
21074
|
+
if (receipt.error?.operation_id !== void 0 && receipt.error.operation_id !== receipt.operation_id) {
|
|
21075
|
+
addIssue(
|
|
21076
|
+
context,
|
|
21077
|
+
["error", "operation_id"],
|
|
21078
|
+
"error operation_id must match receipt operation_id"
|
|
21079
|
+
);
|
|
21080
|
+
}
|
|
21081
|
+
if (!receipt.mutation && receipt.durability !== "not_applicable") {
|
|
21082
|
+
addIssue(context, ["durability"], "read-only operations use not_applicable durability");
|
|
21083
|
+
}
|
|
21084
|
+
if (receipt.outcome === "indeterminate" && receipt.durability !== "indeterminate") {
|
|
21085
|
+
addIssue(context, ["durability"], "indeterminate operations require indeterminate durability");
|
|
21086
|
+
}
|
|
21087
|
+
if (receipt.outcome === "completed" && receipt.durability === "indeterminate") {
|
|
21088
|
+
addIssue(context, ["durability"], "completed operations cannot have indeterminate durability");
|
|
21089
|
+
}
|
|
21090
|
+
if (receipt.outcome === "rejected" && receipt.error?.effect_state !== "no_effect") {
|
|
21091
|
+
addIssue(context, ["error", "effect_state"], "rejected operations must report no effect");
|
|
21092
|
+
}
|
|
21093
|
+
if (Date.parse(receipt.completed_at) < Date.parse(receipt.started_at)) {
|
|
21094
|
+
addIssue(context, ["completed_at"], "completed_at must not precede started_at");
|
|
21095
|
+
}
|
|
21096
|
+
if (receipt.mutation !== isMutationOperation(receipt.operation)) {
|
|
21097
|
+
addIssue(context, ["mutation"], "mutation must match the operation kind");
|
|
21098
|
+
}
|
|
21099
|
+
}
|
|
21100
|
+
function isMutationOperation(operation) {
|
|
21101
|
+
return operation === "create-child" || operation === "write-owned-file" || operation === "rename-owned" || operation === "remove-owned" || operation === "sync-directory";
|
|
21102
|
+
}
|
|
21103
|
+
function isWindowsAbsolutePath(value) {
|
|
21104
|
+
return /^[a-z]:[\\/]/iu.test(value) || /^\\\\[^\\/\0]+[\\/][^\\/\0]+(?:[\\/]|$)/u.test(value) || /^\\\\\?\\/u.test(value);
|
|
21105
|
+
}
|
|
21106
|
+
function boundaryHash(domain, body) {
|
|
21107
|
+
return computeCanonicalHash(["lexrunner-workspace-boundary-v1", domain, body]);
|
|
21108
|
+
}
|
|
21109
|
+
function requireDigest2(actual, expected, field, context) {
|
|
21110
|
+
if (actual !== expected) addIssue(context, [field], `${field} does not match canonical content`);
|
|
21111
|
+
}
|
|
21112
|
+
function copyIssues(result, context) {
|
|
21113
|
+
if (result.success) return;
|
|
21114
|
+
for (const issue of result.error.issues) {
|
|
21115
|
+
context.addIssue({ code: "custom", path: issue.path, message: issue.message });
|
|
21116
|
+
}
|
|
21117
|
+
}
|
|
21118
|
+
function addIssue(context, path50, message) {
|
|
21119
|
+
context.addIssue({ code: "custom", path: path50, message });
|
|
21120
|
+
}
|
|
21121
|
+
|
|
21122
|
+
// src/workspaces/linux-workspace-boundary.ts
|
|
21123
|
+
var DEFAULT_FILE_MODE = 384;
|
|
21124
|
+
var LinuxWorkspaceBoundary = class {
|
|
21125
|
+
constructor(options) {
|
|
21126
|
+
this.capability = WorkspaceBoundaryCapabilityDecision_v1.parse(options.capability);
|
|
21127
|
+
if (this.capability.state !== "ready" || this.capability.backend_kind !== "linux-native" || this.capability.backend.transport !== "in_process") {
|
|
21128
|
+
throw new Error("LinuxWorkspaceBoundary requires a verified ready Linux capability decision");
|
|
21129
|
+
}
|
|
21130
|
+
this.runner = options.runner ?? new ExecaCommandRunner();
|
|
21131
|
+
this.clock = options.clock ?? (() => /* @__PURE__ */ new Date());
|
|
21132
|
+
this.createId = options.createId ?? randomUUID3;
|
|
21133
|
+
}
|
|
21134
|
+
acquire(request) {
|
|
21135
|
+
const opened = [];
|
|
21136
|
+
try {
|
|
21137
|
+
if (request.roots.length === 0 || request.roots.length > 16) {
|
|
21138
|
+
throw new DirectoryBoundaryError("invalid_path", "A boundary lease requires 1-16 roots");
|
|
21139
|
+
}
|
|
21140
|
+
const roles = /* @__PURE__ */ new Set();
|
|
21141
|
+
const roots = /* @__PURE__ */ new Map();
|
|
21142
|
+
const directories = /* @__PURE__ */ new Map();
|
|
21143
|
+
const leaseId = this.createId();
|
|
21144
|
+
for (const root of request.roots) {
|
|
21145
|
+
if (!root.role || roles.has(root.role)) {
|
|
21146
|
+
throw new DirectoryBoundaryError(
|
|
21147
|
+
"invalid_path",
|
|
21148
|
+
"Boundary root roles must be non-empty and unique"
|
|
21149
|
+
);
|
|
21150
|
+
}
|
|
21151
|
+
roles.add(root.role);
|
|
21152
|
+
const captured = captureDirectoryIdentity(root.absolutePath, root.role);
|
|
21153
|
+
const directory = reopenDirectoryIdentity(captured, root.role);
|
|
21154
|
+
opened.push(directory);
|
|
21155
|
+
const capability = linuxCapability(leaseId, directory);
|
|
21156
|
+
roots.set(root.role, capability);
|
|
21157
|
+
directories.set(capability, directory);
|
|
21158
|
+
}
|
|
21159
|
+
const acquired = createWorkspaceBoundaryLeaseReceipt({
|
|
21160
|
+
schema_version: WORKSPACE_BOUNDARY_CONTRACT_VERSION,
|
|
21161
|
+
lease_id: leaseId,
|
|
21162
|
+
orchestration_lease_id: request.orchestrationLeaseId,
|
|
21163
|
+
orchestration_lease_revision: request.orchestrationLeaseRevision,
|
|
21164
|
+
owner_id: request.ownerId,
|
|
21165
|
+
backend_kind: "linux-native",
|
|
21166
|
+
capability_decision_digest: this.capability.decision_digest,
|
|
21167
|
+
root_identity_digests: [...roots.values()].map((root) => root.identity.identity_digest),
|
|
21168
|
+
phase: "acquired",
|
|
21169
|
+
observed_at: this.clock().toISOString()
|
|
21170
|
+
});
|
|
21171
|
+
return Promise.resolve({
|
|
21172
|
+
ok: true,
|
|
21173
|
+
lease: new LinuxWorkspaceBoundaryLease({
|
|
21174
|
+
acquired,
|
|
21175
|
+
roots,
|
|
21176
|
+
directories,
|
|
21177
|
+
runner: this.runner,
|
|
21178
|
+
clock: this.clock
|
|
21179
|
+
})
|
|
21180
|
+
});
|
|
21181
|
+
} catch (error) {
|
|
21182
|
+
for (const directory of opened.reverse()) directory.close();
|
|
21183
|
+
return Promise.resolve({
|
|
21184
|
+
ok: false,
|
|
21185
|
+
error: boundaryError(error, request.operationId, "no_effect")
|
|
21186
|
+
});
|
|
21187
|
+
}
|
|
21188
|
+
}
|
|
21189
|
+
};
|
|
21190
|
+
var _a;
|
|
21191
|
+
_a = workspaceBoundaryLeaseBrand;
|
|
21192
|
+
var LinuxWorkspaceBoundaryLease = class {
|
|
21193
|
+
constructor(options) {
|
|
21194
|
+
this[_a] = true;
|
|
21195
|
+
this.directories = /* @__PURE__ */ new Map();
|
|
21196
|
+
this.closed = false;
|
|
21197
|
+
this.acquired = options.acquired;
|
|
21198
|
+
this.roots = options.roots;
|
|
21199
|
+
this.runner = options.runner;
|
|
21200
|
+
this.clock = options.clock;
|
|
21201
|
+
for (const [capability, directory] of options.directories) {
|
|
21202
|
+
this.directories.set(capability, directory);
|
|
21203
|
+
}
|
|
21204
|
+
}
|
|
21205
|
+
root(role) {
|
|
21206
|
+
this.assertOpen();
|
|
21207
|
+
const root = this.roots.get(role);
|
|
21208
|
+
if (!root) throw new Error(`Boundary lease does not contain root role ${role}`);
|
|
21209
|
+
return root;
|
|
21210
|
+
}
|
|
21211
|
+
async openChild(parent, component, operationId) {
|
|
21212
|
+
return this.directoryOperation(
|
|
21213
|
+
"open-child",
|
|
21214
|
+
parent,
|
|
21215
|
+
operationId,
|
|
21216
|
+
() => this.register(openChildDirectory(this.requireCapability(parent), component, "boundary child"))
|
|
21217
|
+
);
|
|
21218
|
+
}
|
|
21219
|
+
async tryOpenChild(parent, component, operationId) {
|
|
21220
|
+
return this.directoryOperation("open-child", parent, operationId, () => {
|
|
21221
|
+
const directory = tryOpenChildDirectory(
|
|
21222
|
+
this.requireCapability(parent),
|
|
21223
|
+
component,
|
|
21224
|
+
"boundary child"
|
|
21225
|
+
);
|
|
21226
|
+
return directory ? this.register(directory) : null;
|
|
21227
|
+
});
|
|
21228
|
+
}
|
|
21229
|
+
async createChild(parent, component, operationId) {
|
|
21230
|
+
return this.directoryOperation(
|
|
21231
|
+
"create-child",
|
|
21232
|
+
parent,
|
|
21233
|
+
operationId,
|
|
21234
|
+
() => this.register(
|
|
21235
|
+
createChildDirectory(this.requireCapability(parent), component, "boundary child")
|
|
21236
|
+
),
|
|
21237
|
+
true
|
|
21238
|
+
);
|
|
21239
|
+
}
|
|
21240
|
+
async assertCurrent(directories, operationId) {
|
|
21241
|
+
const startedAt = this.clock();
|
|
21242
|
+
try {
|
|
21243
|
+
this.assertOpen();
|
|
21244
|
+
if (directories.length === 0) throw new Error("assertCurrent requires a directory");
|
|
21245
|
+
const capabilities = directories.map((directory) => this.requireCapability(directory));
|
|
21246
|
+
for (const directory of capabilities) {
|
|
21247
|
+
assertAnchoredDirectoryLocation(directory, "boundary directory");
|
|
21248
|
+
}
|
|
21249
|
+
const identities = capabilities.map((directory) => linuxIdentity(directory));
|
|
21250
|
+
return this.success("assert-current", operationId, identities, directories, startedAt);
|
|
21251
|
+
} catch (error) {
|
|
21252
|
+
return this.failure("assert-current", operationId, directories, error, startedAt, false);
|
|
21253
|
+
}
|
|
21254
|
+
}
|
|
21255
|
+
async readFile(request) {
|
|
21256
|
+
const startedAt = this.clock();
|
|
21257
|
+
try {
|
|
21258
|
+
this.assertOpen();
|
|
21259
|
+
if (!Number.isSafeInteger(request.maxBytes) || request.maxBytes <= 0) {
|
|
21260
|
+
throw new Error("maxBytes must be a positive safe integer");
|
|
21261
|
+
}
|
|
21262
|
+
const directory = this.requireCapability(request.directory);
|
|
21263
|
+
assertAnchoredDirectoryLocation(directory, "owned file parent");
|
|
21264
|
+
const handle = await open(
|
|
21265
|
+
procChildPath(directory, request.component),
|
|
21266
|
+
constants2.O_RDONLY | constants2.O_NOFOLLOW
|
|
21267
|
+
);
|
|
21268
|
+
try {
|
|
21269
|
+
const stats = await handle.stat();
|
|
21270
|
+
if (!stats.isFile()) throw new Error("Owned file is not a regular file");
|
|
21271
|
+
const buffer = Buffer.alloc(request.maxBytes + 1);
|
|
21272
|
+
let offset = 0;
|
|
21273
|
+
while (offset < buffer.byteLength) {
|
|
21274
|
+
const { bytesRead } = await handle.read(
|
|
21275
|
+
buffer,
|
|
21276
|
+
offset,
|
|
21277
|
+
buffer.byteLength - offset,
|
|
21278
|
+
offset
|
|
21279
|
+
);
|
|
21280
|
+
if (bytesRead === 0) break;
|
|
21281
|
+
offset += bytesRead;
|
|
21282
|
+
}
|
|
21283
|
+
if (offset > request.maxBytes) {
|
|
21284
|
+
throw new Error(`Owned file exceeds ${request.maxBytes} bytes`);
|
|
21285
|
+
}
|
|
21286
|
+
return this.success(
|
|
21287
|
+
"read-owned-file",
|
|
21288
|
+
request.operationId,
|
|
21289
|
+
buffer.subarray(0, offset),
|
|
21290
|
+
[request.directory],
|
|
21291
|
+
startedAt
|
|
21292
|
+
);
|
|
21293
|
+
} finally {
|
|
21294
|
+
await handle.close();
|
|
21295
|
+
}
|
|
21296
|
+
} catch (error) {
|
|
21297
|
+
return this.failure(
|
|
21298
|
+
"read-owned-file",
|
|
21299
|
+
request.operationId,
|
|
21300
|
+
[request.directory],
|
|
21301
|
+
error,
|
|
21302
|
+
startedAt,
|
|
21303
|
+
false
|
|
21304
|
+
);
|
|
21305
|
+
}
|
|
21306
|
+
}
|
|
21307
|
+
async writeFile(request) {
|
|
21308
|
+
const startedAt = this.clock();
|
|
21309
|
+
try {
|
|
21310
|
+
this.assertOpen();
|
|
21311
|
+
const directory = this.requireCapability(request.directory);
|
|
21312
|
+
assertAnchoredDirectoryLocation(directory, "owned file parent");
|
|
21313
|
+
const flags = constants2.O_WRONLY | constants2.O_CREAT | constants2.O_NOFOLLOW | (request.exclusive ? constants2.O_EXCL : constants2.O_TRUNC);
|
|
21314
|
+
const handle = await open(
|
|
21315
|
+
procChildPath(directory, request.component),
|
|
21316
|
+
flags,
|
|
21317
|
+
request.mode ?? DEFAULT_FILE_MODE
|
|
21318
|
+
);
|
|
21319
|
+
try {
|
|
21320
|
+
await handle.writeFile(request.content);
|
|
21321
|
+
} finally {
|
|
21322
|
+
await handle.close();
|
|
21323
|
+
}
|
|
21324
|
+
return this.success(
|
|
21325
|
+
"write-owned-file",
|
|
21326
|
+
request.operationId,
|
|
21327
|
+
void 0,
|
|
21328
|
+
[request.directory],
|
|
21329
|
+
startedAt,
|
|
21330
|
+
"not_requested"
|
|
21331
|
+
);
|
|
21332
|
+
} catch (error) {
|
|
21333
|
+
return this.failure(
|
|
21334
|
+
"write-owned-file",
|
|
21335
|
+
request.operationId,
|
|
21336
|
+
[request.directory],
|
|
21337
|
+
error,
|
|
21338
|
+
startedAt,
|
|
21339
|
+
true
|
|
21340
|
+
);
|
|
21341
|
+
}
|
|
21342
|
+
}
|
|
21343
|
+
async runProcess(request) {
|
|
21344
|
+
const startedAt = this.clock();
|
|
21345
|
+
const temporaryDirectories = [];
|
|
21346
|
+
try {
|
|
21347
|
+
this.assertOpen();
|
|
21348
|
+
const cwd = this.requireCapability(request.cwd);
|
|
21349
|
+
const rendered = request.args.map(
|
|
21350
|
+
(argument) => this.renderArgument(argument, request.cwd, temporaryDirectories)
|
|
21351
|
+
);
|
|
21352
|
+
const asserted = [
|
|
21353
|
+
...this.roots.values(),
|
|
21354
|
+
request.cwd,
|
|
21355
|
+
...request.args.filter(
|
|
21356
|
+
(argument) => argument.kind === "directory"
|
|
21357
|
+
).map((argument) => argument.directory)
|
|
21358
|
+
];
|
|
21359
|
+
const command = {
|
|
21360
|
+
executable: request.executable,
|
|
21361
|
+
args: rendered,
|
|
21362
|
+
cwd: cwd.procPath,
|
|
21363
|
+
timeoutMs: request.timeoutMs,
|
|
21364
|
+
...request.env ? { env: request.env } : {},
|
|
21365
|
+
...request.extendEnv !== void 0 ? { extendEnv: request.extendEnv } : {},
|
|
21366
|
+
...request.signal ? { signal: request.signal } : {},
|
|
21367
|
+
...request.maxOutputBytes ? { maxOutputBytes: request.maxOutputBytes } : {},
|
|
21368
|
+
preflight: () => {
|
|
21369
|
+
for (const capability of asserted) {
|
|
21370
|
+
assertAnchoredDirectoryLocation(
|
|
21371
|
+
this.requireCapability(capability),
|
|
21372
|
+
"process directory"
|
|
21373
|
+
);
|
|
21374
|
+
}
|
|
21375
|
+
for (const directory of temporaryDirectories) {
|
|
21376
|
+
assertAnchoredDirectoryLocation(directory, "process directory component");
|
|
21377
|
+
}
|
|
21378
|
+
}
|
|
21379
|
+
};
|
|
21380
|
+
const result = await this.runner.run(command);
|
|
21381
|
+
return this.success("spawn-process", request.operationId, result, asserted, startedAt);
|
|
21382
|
+
} catch (error) {
|
|
21383
|
+
return this.failure(
|
|
21384
|
+
"spawn-process",
|
|
21385
|
+
request.operationId,
|
|
21386
|
+
[request.cwd],
|
|
21387
|
+
error,
|
|
21388
|
+
startedAt,
|
|
21389
|
+
false
|
|
21390
|
+
);
|
|
21391
|
+
} finally {
|
|
21392
|
+
for (const directory of temporaryDirectories.reverse()) directory.close();
|
|
21393
|
+
}
|
|
21394
|
+
}
|
|
21395
|
+
async close(reason) {
|
|
21396
|
+
if (this.terminalReceipt) return this.terminalReceipt;
|
|
21397
|
+
this.closed = true;
|
|
21398
|
+
for (const directory of [...this.directories.values()].reverse()) directory.close();
|
|
21399
|
+
this.directories.clear();
|
|
21400
|
+
this.terminalReceipt = createWorkspaceBoundaryLeaseReceipt({
|
|
21401
|
+
schema_version: WORKSPACE_BOUNDARY_CONTRACT_VERSION,
|
|
21402
|
+
lease_id: this.acquired.lease_id,
|
|
21403
|
+
orchestration_lease_id: this.acquired.orchestration_lease_id,
|
|
21404
|
+
orchestration_lease_revision: this.acquired.orchestration_lease_revision,
|
|
21405
|
+
owner_id: this.acquired.owner_id,
|
|
21406
|
+
backend_kind: "linux-native",
|
|
21407
|
+
capability_decision_digest: this.acquired.capability_decision_digest,
|
|
21408
|
+
root_identity_digests: this.acquired.root_identity_digests,
|
|
21409
|
+
phase: reason === "expired" ? "expired" : reason === "reconcile" ? "reconciled" : "released",
|
|
21410
|
+
observed_at: this.clock().toISOString()
|
|
21411
|
+
});
|
|
21412
|
+
return this.terminalReceipt;
|
|
21413
|
+
}
|
|
21414
|
+
async directoryOperation(operation, parent, operationId, effect, mutation4 = false) {
|
|
21415
|
+
const startedAt = this.clock();
|
|
21416
|
+
try {
|
|
21417
|
+
this.assertOpen();
|
|
21418
|
+
const value = effect();
|
|
21419
|
+
const identities = value && typeof value === "object" && "identity" in value ? [parent, value] : [parent];
|
|
21420
|
+
return this.success(
|
|
21421
|
+
operation,
|
|
21422
|
+
operationId,
|
|
21423
|
+
value,
|
|
21424
|
+
identities,
|
|
21425
|
+
startedAt,
|
|
21426
|
+
mutation4 ? "not_requested" : "not_applicable"
|
|
21427
|
+
);
|
|
21428
|
+
} catch (error) {
|
|
21429
|
+
return this.failure(operation, operationId, [parent], error, startedAt, mutation4);
|
|
21430
|
+
}
|
|
21431
|
+
}
|
|
21432
|
+
renderArgument(argument, cwd, temporaryDirectories) {
|
|
21433
|
+
if (argument.kind === "literal") return argument.value;
|
|
21434
|
+
if (argument.relativeToCwd) {
|
|
21435
|
+
if (argument.directory !== cwd || (argument.components?.length ?? 0) > 0) {
|
|
21436
|
+
throw new DirectoryBoundaryError(
|
|
21437
|
+
"invalid_path",
|
|
21438
|
+
"A cwd-relative process argument must reference the exact cwd capability without components"
|
|
21439
|
+
);
|
|
21440
|
+
}
|
|
21441
|
+
this.requireCapability(argument.directory);
|
|
21442
|
+
return `${argument.prefix ?? ""}.${argument.suffix ?? ""}`;
|
|
21443
|
+
}
|
|
21444
|
+
let directory = this.requireCapability(argument.directory);
|
|
21445
|
+
for (const component of argument.components ?? []) {
|
|
21446
|
+
directory = openChildDirectory(directory, component, "process directory component");
|
|
21447
|
+
temporaryDirectories.push(directory);
|
|
21448
|
+
}
|
|
21449
|
+
return `${argument.prefix ?? ""}${directory.procPath}${argument.suffix ?? ""}`;
|
|
21450
|
+
}
|
|
21451
|
+
register(directory) {
|
|
21452
|
+
const capability = linuxCapability(this.acquired.lease_id, directory);
|
|
21453
|
+
this.directories.set(capability, directory);
|
|
21454
|
+
return capability;
|
|
21455
|
+
}
|
|
21456
|
+
requireCapability(capability) {
|
|
21457
|
+
this.assertOpen();
|
|
21458
|
+
const candidate = capability;
|
|
21459
|
+
const directory = this.directories.get(candidate);
|
|
21460
|
+
if (candidate.leaseId !== this.acquired.lease_id || !directory) {
|
|
21461
|
+
throw new DirectoryBoundaryError(
|
|
21462
|
+
"identity_changed",
|
|
21463
|
+
"Directory capability is stale, foreign, or forged"
|
|
21464
|
+
);
|
|
21465
|
+
}
|
|
21466
|
+
return directory;
|
|
21467
|
+
}
|
|
21468
|
+
assertOpen() {
|
|
21469
|
+
if (this.closed) {
|
|
21470
|
+
throw new DirectoryBoundaryError("identity_changed", "Workspace boundary lease is closed");
|
|
21471
|
+
}
|
|
21472
|
+
}
|
|
21473
|
+
success(operation, operationId, value, directories, startedAt, durability = "not_applicable") {
|
|
21474
|
+
return {
|
|
21475
|
+
ok: true,
|
|
21476
|
+
value,
|
|
21477
|
+
receipt: this.receipt(operation, operationId, directories, startedAt, {
|
|
21478
|
+
outcome: "completed",
|
|
21479
|
+
durability
|
|
21480
|
+
})
|
|
21481
|
+
};
|
|
21482
|
+
}
|
|
21483
|
+
failure(operation, operationId, directories, error, startedAt, mutation4) {
|
|
21484
|
+
const effectState = mutation4 && !knownNoEffect(error) ? "effect_unknown" : "no_effect";
|
|
21485
|
+
const boundary = boundaryError(error, operationId, effectState);
|
|
21486
|
+
return {
|
|
21487
|
+
ok: false,
|
|
21488
|
+
error: boundary,
|
|
21489
|
+
receipt: this.receipt(operation, operationId, directories, startedAt, {
|
|
21490
|
+
outcome: effectState === "effect_unknown" ? "indeterminate" : "rejected",
|
|
21491
|
+
durability: effectState === "effect_unknown" ? "indeterminate" : "not_applicable",
|
|
21492
|
+
error: boundary
|
|
21493
|
+
})
|
|
21494
|
+
};
|
|
21495
|
+
}
|
|
21496
|
+
receipt(operation, operationId, directories, startedAt, result) {
|
|
21497
|
+
const identities = directories.map((directory) => directory.identity?.identity_digest).filter((digest) => Boolean(digest));
|
|
21498
|
+
const completedAt = new Date(Math.max(startedAt.getTime(), this.clock().getTime()));
|
|
21499
|
+
return createWorkspaceBoundaryOperationReceipt({
|
|
21500
|
+
schema_version: WORKSPACE_BOUNDARY_CONTRACT_VERSION,
|
|
21501
|
+
operation_id: operationId,
|
|
21502
|
+
lease_id: this.acquired.lease_id,
|
|
21503
|
+
backend_kind: "linux-native",
|
|
21504
|
+
operation,
|
|
21505
|
+
mutation: operation === "create-child" || operation === "write-owned-file" || operation === "rename-owned" || operation === "remove-owned" || operation === "sync-directory",
|
|
21506
|
+
outcome: result.outcome,
|
|
21507
|
+
durability: result.durability,
|
|
21508
|
+
identity_digests: [
|
|
21509
|
+
...new Set(identities.length > 0 ? identities : this.acquired.root_identity_digests)
|
|
21510
|
+
],
|
|
21511
|
+
started_at: startedAt.toISOString(),
|
|
21512
|
+
completed_at: completedAt.toISOString(),
|
|
21513
|
+
...result.outcome === "completed" ? {} : { error: result.error }
|
|
21514
|
+
});
|
|
21515
|
+
}
|
|
21516
|
+
};
|
|
21517
|
+
function linuxCapability(leaseId, directory) {
|
|
21518
|
+
return {
|
|
21519
|
+
leaseId,
|
|
21520
|
+
identity: linuxIdentity(directory)
|
|
21521
|
+
};
|
|
21522
|
+
}
|
|
21523
|
+
function linuxIdentity(directory) {
|
|
21524
|
+
const identity = identityOf(directory);
|
|
21525
|
+
return createWorkspaceBoundaryDirectoryIdentity({
|
|
21526
|
+
schema_version: WORKSPACE_BOUNDARY_CONTRACT_VERSION,
|
|
21527
|
+
backend_kind: "linux-native",
|
|
21528
|
+
canonical_path: identity.path,
|
|
21529
|
+
path_comparison: "case-sensitive",
|
|
21530
|
+
identity_kind: "linux-device-inode",
|
|
21531
|
+
device: identity.device.toString(10),
|
|
21532
|
+
inode: identity.inode.toString(10)
|
|
21533
|
+
});
|
|
21534
|
+
}
|
|
21535
|
+
function boundaryError(error, operationId, effectState) {
|
|
21536
|
+
const nodeCode = isNodeError2(error) ? error.code : void 0;
|
|
21537
|
+
const code = error instanceof DirectoryBoundaryError ? error.code === "identity_changed" ? "identity_changed" : error.code === "unsupported_platform" ? "unsupported_filesystem" : "invalid_path" : nodeCode === "ENOENT" ? "invalid_path" : nodeCode === "EACCES" || nodeCode === "EPERM" ? "sharing_violation" : "operation_failed";
|
|
21538
|
+
return {
|
|
21539
|
+
schema_version: WORKSPACE_BOUNDARY_CONTRACT_VERSION,
|
|
21540
|
+
code,
|
|
21541
|
+
message: boundedMessage(error),
|
|
21542
|
+
retryable: false,
|
|
21543
|
+
effect_state: effectState,
|
|
21544
|
+
operation_id: operationId
|
|
21545
|
+
};
|
|
21546
|
+
}
|
|
21547
|
+
function knownNoEffect(error) {
|
|
21548
|
+
if (error instanceof DirectoryBoundaryError) {
|
|
21549
|
+
const cause = error.originalCause;
|
|
21550
|
+
return isNodeError2(cause) && cause.code === "EEXIST";
|
|
21551
|
+
}
|
|
21552
|
+
return isNodeError2(error) && error.code === "EEXIST";
|
|
21553
|
+
}
|
|
21554
|
+
function boundedMessage(error) {
|
|
21555
|
+
const message = isNodeError2(error) && error.code === "ENOENT" ? "Boundary path does not exist" : isNodeError2(error) && (error.code === "EACCES" || error.code === "EPERM") ? "Boundary operation was denied by the host" : (error instanceof Error ? error.message : String(error)).replace(
|
|
21556
|
+
/\/proc\/\d+\/fd\/\d+/gu,
|
|
21557
|
+
"<held-directory>"
|
|
21558
|
+
);
|
|
21559
|
+
return message.length <= 4096 ? message : message.slice(0, 4096);
|
|
21560
|
+
}
|
|
21561
|
+
function isNodeError2(error) {
|
|
21562
|
+
return error instanceof Error && "code" in error;
|
|
21563
|
+
}
|
|
21564
|
+
|
|
21565
|
+
// src/workspaces/workspace-boundary-resolver.ts
|
|
21566
|
+
var EMPTY_CLAIMS = Object.freeze({
|
|
21567
|
+
held_directory_identity: false,
|
|
21568
|
+
no_follow_open: false,
|
|
21569
|
+
final_path_from_handle: false,
|
|
21570
|
+
held_ancestor_chain: false,
|
|
21571
|
+
replacement_resistant_process_binding: false,
|
|
21572
|
+
rename_delete_exclusion: false,
|
|
21573
|
+
durable_directory_mutation: false
|
|
21574
|
+
});
|
|
21575
|
+
var LINUX_CLAIMS = Object.freeze({
|
|
21576
|
+
held_directory_identity: true,
|
|
21577
|
+
no_follow_open: true,
|
|
21578
|
+
final_path_from_handle: true,
|
|
21579
|
+
held_ancestor_chain: true,
|
|
21580
|
+
replacement_resistant_process_binding: true,
|
|
21581
|
+
rename_delete_exclusion: false,
|
|
21582
|
+
durable_directory_mutation: false
|
|
21583
|
+
});
|
|
21584
|
+
function resolveWorkspaceBoundary(request, options = {}) {
|
|
21585
|
+
const selection = WorkspaceBoundarySelectionRequest_v1.parse(request);
|
|
21586
|
+
const runtimePlatform = platform2();
|
|
21587
|
+
const observedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
21588
|
+
const decisionId = randomUUID4();
|
|
21589
|
+
if (selection.mode === "explicit_projection") {
|
|
21590
|
+
return {
|
|
21591
|
+
ok: false,
|
|
21592
|
+
decision: createWorkspaceBoundaryCapabilityDecision({
|
|
21593
|
+
schema_version: WORKSPACE_BOUNDARY_CONTRACT_VERSION,
|
|
21594
|
+
decision_id: decisionId,
|
|
21595
|
+
selection,
|
|
21596
|
+
backend_kind: "native-wsl-projection",
|
|
21597
|
+
state: "unavailable",
|
|
21598
|
+
reason_code: "projection_unavailable",
|
|
21599
|
+
host: host(runtimePlatform),
|
|
21600
|
+
backend: {
|
|
21601
|
+
transport: "in_process",
|
|
21602
|
+
implementation: "native-wsl-projection",
|
|
21603
|
+
implementation_version: WORKSPACE_BOUNDARY_CONTRACT_VERSION
|
|
21604
|
+
},
|
|
21605
|
+
claims: EMPTY_CLAIMS,
|
|
21606
|
+
observed_at: observedAt
|
|
21607
|
+
})
|
|
21608
|
+
};
|
|
21609
|
+
}
|
|
21610
|
+
if (runtimePlatform === "linux") {
|
|
21611
|
+
const support = probeDirectoryIdentityBoundarySupport("case-sensitive");
|
|
21612
|
+
const capability = createWorkspaceBoundaryCapabilityDecision({
|
|
21613
|
+
schema_version: WORKSPACE_BOUNDARY_CONTRACT_VERSION,
|
|
21614
|
+
decision_id: decisionId,
|
|
21615
|
+
selection,
|
|
21616
|
+
backend_kind: "linux-native",
|
|
21617
|
+
state: support.supported ? "ready" : "unavailable",
|
|
21618
|
+
reason_code: support.supported ? "native_backend_ready" : "backend_unavailable",
|
|
21619
|
+
host: host(runtimePlatform),
|
|
21620
|
+
backend: {
|
|
21621
|
+
transport: "in_process",
|
|
21622
|
+
implementation: "linux-directory-identity",
|
|
21623
|
+
implementation_version: WORKSPACE_BOUNDARY_CONTRACT_VERSION
|
|
21624
|
+
},
|
|
21625
|
+
claims: support.supported ? LINUX_CLAIMS : EMPTY_CLAIMS,
|
|
21626
|
+
observed_at: observedAt
|
|
21627
|
+
});
|
|
21628
|
+
return support.supported ? {
|
|
21629
|
+
ok: true,
|
|
21630
|
+
boundary: new LinuxWorkspaceBoundary({
|
|
21631
|
+
capability,
|
|
21632
|
+
...options.runner ? { runner: options.runner } : {}
|
|
21633
|
+
})
|
|
21634
|
+
} : { ok: false, decision: capability };
|
|
21635
|
+
}
|
|
21636
|
+
if (runtimePlatform === "win32") {
|
|
21637
|
+
return {
|
|
21638
|
+
ok: false,
|
|
21639
|
+
decision: createWorkspaceBoundaryCapabilityDecision({
|
|
21640
|
+
schema_version: WORKSPACE_BOUNDARY_CONTRACT_VERSION,
|
|
21641
|
+
decision_id: decisionId,
|
|
21642
|
+
selection,
|
|
21643
|
+
backend_kind: "windows-native",
|
|
21644
|
+
state: "unavailable",
|
|
21645
|
+
reason_code: "helper_missing",
|
|
21646
|
+
host: host(runtimePlatform),
|
|
21647
|
+
backend: {
|
|
21648
|
+
transport: "native_helper",
|
|
21649
|
+
implementation: "windows-workspace-boundary",
|
|
21650
|
+
implementation_version: WORKSPACE_BOUNDARY_CONTRACT_VERSION,
|
|
21651
|
+
protocol_version: WORKSPACE_BOUNDARY_CONTRACT_VERSION,
|
|
21652
|
+
signature: { status: "not_available" }
|
|
21653
|
+
},
|
|
21654
|
+
claims: EMPTY_CLAIMS,
|
|
21655
|
+
observed_at: observedAt
|
|
21656
|
+
})
|
|
21657
|
+
};
|
|
21658
|
+
}
|
|
21659
|
+
return {
|
|
21660
|
+
ok: false,
|
|
21661
|
+
decision: createWorkspaceBoundaryCapabilityDecision({
|
|
21662
|
+
schema_version: WORKSPACE_BOUNDARY_CONTRACT_VERSION,
|
|
21663
|
+
decision_id: decisionId,
|
|
21664
|
+
selection,
|
|
21665
|
+
backend_kind: "linux-native",
|
|
21666
|
+
state: "unsupported",
|
|
21667
|
+
reason_code: "unsupported_host",
|
|
21668
|
+
host: host(runtimePlatform),
|
|
21669
|
+
backend: {
|
|
21670
|
+
transport: "in_process",
|
|
21671
|
+
implementation: "linux-directory-identity",
|
|
21672
|
+
implementation_version: WORKSPACE_BOUNDARY_CONTRACT_VERSION
|
|
21673
|
+
},
|
|
21674
|
+
claims: EMPTY_CLAIMS,
|
|
21675
|
+
observed_at: observedAt
|
|
21676
|
+
})
|
|
21677
|
+
};
|
|
21678
|
+
}
|
|
21679
|
+
function host(runtimePlatform) {
|
|
21680
|
+
return {
|
|
21681
|
+
platform: runtimePlatform === "linux" ? "linux" : runtimePlatform === "win32" ? "windows" : "other",
|
|
21682
|
+
architecture: arch(),
|
|
21683
|
+
path_comparison: runtimePlatform === "win32" ? "case-insensitive" : "case-sensitive"
|
|
21684
|
+
};
|
|
21685
|
+
}
|
|
21686
|
+
|
|
20706
21687
|
// src/workspaces/node-git-worktree-broker.ts
|
|
20707
21688
|
var FULL_GIT_OBJECT_ID = /^(?:[0-9a-f]{40}|[0-9a-f]{64})$/;
|
|
20708
21689
|
var DEFAULT_TIMEOUT_MS = 3e4;
|
|
@@ -20736,7 +21717,23 @@ var NodeGitWorktreeBroker = class {
|
|
|
20736
21717
|
if (nativePathsOverlap2(options.repositoryRoot, options.worktreeRoot, options.pathComparison)) {
|
|
20737
21718
|
throw new Error("repositoryRoot and worktreeRoot must not overlap");
|
|
20738
21719
|
}
|
|
20739
|
-
|
|
21720
|
+
const resolution = resolveWorkspaceBoundary(
|
|
21721
|
+
{ mode: "native" },
|
|
21722
|
+
options.runner ? { runner: options.runner } : {}
|
|
21723
|
+
);
|
|
21724
|
+
if (!resolution.ok) {
|
|
21725
|
+
throw new DirectoryBoundaryError(
|
|
21726
|
+
"unsupported_platform",
|
|
21727
|
+
`Native workspace boundary is unavailable (${resolution.decision.reason_code})`
|
|
21728
|
+
);
|
|
21729
|
+
}
|
|
21730
|
+
if (resolution.boundary.capability.host.path_comparison !== options.pathComparison) {
|
|
21731
|
+
throw new DirectoryBoundaryError(
|
|
21732
|
+
"unsupported_platform",
|
|
21733
|
+
"Physical worktree containment currently requires a case-sensitive Linux Git runtime"
|
|
21734
|
+
);
|
|
21735
|
+
}
|
|
21736
|
+
this.boundary = resolution.boundary;
|
|
20740
21737
|
this.repositoryIdentity = captureDirectoryIdentity(options.repositoryRoot, "repositoryRoot");
|
|
20741
21738
|
this.worktreeRootIdentity = captureDirectoryIdentity(options.worktreeRoot, "worktreeRoot");
|
|
20742
21739
|
const repository = reopenDirectoryIdentity(this.repositoryIdentity, "repositoryRoot");
|
|
@@ -20757,9 +21754,9 @@ var NodeGitWorktreeBroker = class {
|
|
|
20757
21754
|
this.gitRuntime = options.gitRuntime;
|
|
20758
21755
|
this.pathComparison = options.pathComparison;
|
|
20759
21756
|
this.gitExecutable = options.gitExecutable ?? "git";
|
|
20760
|
-
this.runner = options.runner ?? new ExecaCommandRunner();
|
|
20761
21757
|
this.defaultTimeoutMs = options.defaultTimeoutMs ?? DEFAULT_TIMEOUT_MS;
|
|
20762
21758
|
this.maxDirtyPaths = options.maxDirtyPaths ?? DEFAULT_MAX_DIRTY_PATHS;
|
|
21759
|
+
this.testOnlyAllowUnboundBoundaryAuthority = options.testOnlyAllowUnboundBoundaryAuthority ?? false;
|
|
20763
21760
|
}
|
|
20764
21761
|
async create(target, options = {}) {
|
|
20765
21762
|
const runtimeFailure = this.runtimeFailure(target, "create");
|
|
@@ -20771,7 +21768,7 @@ var NodeGitWorktreeBroker = class {
|
|
|
20771
21768
|
"baseSha must be a lowercase full SHA-1 or SHA-256 object ID"
|
|
20772
21769
|
);
|
|
20773
21770
|
}
|
|
20774
|
-
const boundary = this.openOperationBoundary(target, "create");
|
|
21771
|
+
const boundary = await this.openOperationBoundary(target, "create", options);
|
|
20775
21772
|
if ("ok" in boundary) return boundary;
|
|
20776
21773
|
try {
|
|
20777
21774
|
const branchValidation = await this.gitMain(
|
|
@@ -20856,12 +21853,13 @@ var NodeGitWorktreeBroker = class {
|
|
|
20856
21853
|
);
|
|
20857
21854
|
}
|
|
20858
21855
|
try {
|
|
20859
|
-
const targetDirectory2 =
|
|
21856
|
+
const targetDirectory2 = await boundary.lease.createChild(
|
|
20860
21857
|
boundary.targetParent,
|
|
20861
21858
|
boundary.targetName,
|
|
20862
|
-
"
|
|
21859
|
+
nextBoundaryOperationId(boundary, "create-target")
|
|
20863
21860
|
);
|
|
20864
|
-
|
|
21861
|
+
if (!targetDirectory2.ok) return this.containmentFailure("create", targetDirectory2.error);
|
|
21862
|
+
boundary.target = targetDirectory2.value;
|
|
20865
21863
|
} catch (error) {
|
|
20866
21864
|
return this.containmentFailure("create", error);
|
|
20867
21865
|
}
|
|
@@ -20876,7 +21874,14 @@ var NodeGitWorktreeBroker = class {
|
|
|
20876
21874
|
const created = await this.gitMain(
|
|
20877
21875
|
boundary,
|
|
20878
21876
|
"create",
|
|
20879
|
-
[
|
|
21877
|
+
[
|
|
21878
|
+
{ kind: "literal", value: "worktree" },
|
|
21879
|
+
{ kind: "literal", value: "add" },
|
|
21880
|
+
{ kind: "literal", value: "-b" },
|
|
21881
|
+
{ kind: "literal", value: target.branch },
|
|
21882
|
+
{ kind: "directory", directory: targetDirectory },
|
|
21883
|
+
{ kind: "literal", value: target.baseSha }
|
|
21884
|
+
],
|
|
20880
21885
|
options
|
|
20881
21886
|
);
|
|
20882
21887
|
if (!created.ok) {
|
|
@@ -20898,18 +21903,18 @@ var NodeGitWorktreeBroker = class {
|
|
|
20898
21903
|
}
|
|
20899
21904
|
return { ok: true, outcome: "created", observation: after.observation };
|
|
20900
21905
|
} finally {
|
|
20901
|
-
closeOperationBoundary(boundary);
|
|
21906
|
+
await closeOperationBoundary(boundary);
|
|
20902
21907
|
}
|
|
20903
21908
|
}
|
|
20904
21909
|
async observe(target, options = {}) {
|
|
20905
21910
|
const runtimeFailure = this.runtimeFailure(target, "observe");
|
|
20906
21911
|
if (runtimeFailure) return runtimeFailure;
|
|
20907
|
-
const boundary = this.openOperationBoundary(target, "observe");
|
|
21912
|
+
const boundary = await this.openOperationBoundary(target, "observe", options);
|
|
20908
21913
|
if ("ok" in boundary) return boundary;
|
|
20909
21914
|
try {
|
|
20910
21915
|
return await this.observeAnchored(target, boundary, options);
|
|
20911
21916
|
} finally {
|
|
20912
|
-
closeOperationBoundary(boundary);
|
|
21917
|
+
await closeOperationBoundary(boundary);
|
|
20913
21918
|
}
|
|
20914
21919
|
}
|
|
20915
21920
|
async observeAnchored(target, boundary, options) {
|
|
@@ -20984,11 +21989,10 @@ var NodeGitWorktreeBroker = class {
|
|
|
20984
21989
|
status
|
|
20985
21990
|
);
|
|
20986
21991
|
}
|
|
20987
|
-
const marker = await this.readAttemptMarker(target, worktreeGit);
|
|
21992
|
+
const marker = await this.readAttemptMarker(target, worktreeGit, boundary);
|
|
20988
21993
|
markerVerified = marker.matches;
|
|
20989
21994
|
markerReason = marker.reason ?? markerReason;
|
|
20990
21995
|
} finally {
|
|
20991
|
-
worktreeGit.close();
|
|
20992
21996
|
}
|
|
20993
21997
|
}
|
|
20994
21998
|
const identityVerified = exists && !record.bare && !record.detached && !record.locked && !record.prunable && observedBranch === target.branch && markerVerified;
|
|
@@ -21016,7 +22020,7 @@ var NodeGitWorktreeBroker = class {
|
|
|
21016
22020
|
async remove(target, options = {}) {
|
|
21017
22021
|
const runtimeFailure = this.runtimeFailure(target, "remove");
|
|
21018
22022
|
if (runtimeFailure) return runtimeFailure;
|
|
21019
|
-
const boundary = this.openOperationBoundary(target, "remove");
|
|
22023
|
+
const boundary = await this.openOperationBoundary(target, "remove", options);
|
|
21020
22024
|
if ("ok" in boundary) return boundary;
|
|
21021
22025
|
try {
|
|
21022
22026
|
const observed = await this.observeAnchored(target, boundary, options);
|
|
@@ -21033,21 +22037,22 @@ var NodeGitWorktreeBroker = class {
|
|
|
21033
22037
|
const removed = await this.gitMain(
|
|
21034
22038
|
boundary,
|
|
21035
22039
|
"remove",
|
|
21036
|
-
[
|
|
22040
|
+
[
|
|
22041
|
+
{ kind: "literal", value: "worktree" },
|
|
22042
|
+
{ kind: "literal", value: "remove" },
|
|
22043
|
+
{ kind: "directory", directory: targetDirectory }
|
|
22044
|
+
],
|
|
21037
22045
|
options
|
|
21038
22046
|
);
|
|
21039
22047
|
if (!removed.ok) return removed;
|
|
21040
|
-
targetDirectory.close();
|
|
21041
22048
|
boundary.target = null;
|
|
21042
|
-
|
|
21043
|
-
boundary.
|
|
21044
|
-
|
|
21045
|
-
|
|
21046
|
-
|
|
21047
|
-
|
|
21048
|
-
|
|
21049
|
-
return this.containmentFailure("remove", error);
|
|
21050
|
-
}
|
|
22049
|
+
const reopened = await boundary.lease.tryOpenChild(
|
|
22050
|
+
boundary.targetParent,
|
|
22051
|
+
boundary.targetName,
|
|
22052
|
+
nextBoundaryOperationId(boundary, "reopen-removed-target")
|
|
22053
|
+
);
|
|
22054
|
+
if (!reopened.ok) return this.containmentFailure("remove", reopened.error);
|
|
22055
|
+
boundary.target = reopened.value;
|
|
21051
22056
|
const after = await this.observeAnchored(target, boundary, options);
|
|
21052
22057
|
if (!after.ok) return { ...after, operation: "remove" };
|
|
21053
22058
|
if (after.observation.registered || after.observation.exists) {
|
|
@@ -21061,7 +22066,7 @@ var NodeGitWorktreeBroker = class {
|
|
|
21061
22066
|
}
|
|
21062
22067
|
return { ok: true, outcome: "removed", observation: after.observation };
|
|
21063
22068
|
} finally {
|
|
21064
|
-
closeOperationBoundary(boundary);
|
|
22069
|
+
await closeOperationBoundary(boundary);
|
|
21065
22070
|
}
|
|
21066
22071
|
}
|
|
21067
22072
|
runtimeFailure(target, operation) {
|
|
@@ -21095,74 +22100,129 @@ var NodeGitWorktreeBroker = class {
|
|
|
21095
22100
|
}
|
|
21096
22101
|
return null;
|
|
21097
22102
|
}
|
|
21098
|
-
openOperationBoundary(target, operation) {
|
|
21099
|
-
|
|
21100
|
-
|
|
21101
|
-
|
|
21102
|
-
|
|
22103
|
+
async openOperationBoundary(target, operation, options) {
|
|
22104
|
+
const authority2 = this.boundaryAuthority(target, operation, options);
|
|
22105
|
+
if (!authority2) {
|
|
22106
|
+
return this.failure(
|
|
22107
|
+
operation,
|
|
22108
|
+
"containment_violation",
|
|
22109
|
+
"Workspace boundary authority lineage is required"
|
|
22110
|
+
);
|
|
22111
|
+
}
|
|
22112
|
+
const acquired = await this.boundary.acquire({
|
|
22113
|
+
operationId: authority2.operationId,
|
|
22114
|
+
orchestrationLeaseId: authority2.orchestrationLeaseId,
|
|
22115
|
+
orchestrationLeaseRevision: authority2.orchestrationLeaseRevision,
|
|
22116
|
+
ownerId: authority2.ownerId,
|
|
22117
|
+
roots: [
|
|
22118
|
+
{ role: "repository", absolutePath: this.repositoryRoot },
|
|
22119
|
+
{ role: "allocation", absolutePath: this.worktreeRoot }
|
|
22120
|
+
]
|
|
22121
|
+
});
|
|
22122
|
+
if (!acquired.ok) return this.containmentFailure(operation, acquired.error);
|
|
22123
|
+
const lease = acquired.lease;
|
|
22124
|
+
const boundary = {
|
|
22125
|
+
lease,
|
|
22126
|
+
repository: lease.root("repository"),
|
|
22127
|
+
repositoryGit: lease.root("repository"),
|
|
22128
|
+
targetParent: lease.root("allocation"),
|
|
22129
|
+
targetName: "",
|
|
22130
|
+
target: null,
|
|
22131
|
+
operationId: authority2.operationId,
|
|
22132
|
+
operationSequence: 0
|
|
22133
|
+
};
|
|
21103
22134
|
try {
|
|
21104
|
-
repository
|
|
21105
|
-
|
|
21106
|
-
|
|
22135
|
+
if (!sameBoundaryIdentity(boundary.repository, this.repositoryIdentity)) {
|
|
22136
|
+
throw new DirectoryBoundaryError(
|
|
22137
|
+
"identity_changed",
|
|
22138
|
+
"The repository root was replaced after broker initialization"
|
|
22139
|
+
);
|
|
22140
|
+
}
|
|
22141
|
+
const repositoryGit = await lease.openChild(
|
|
22142
|
+
boundary.repository,
|
|
22143
|
+
".git",
|
|
22144
|
+
nextBoundaryOperationId(boundary, "open-repository-git")
|
|
22145
|
+
);
|
|
22146
|
+
if (!repositoryGit.ok) throw new Error(repositoryGit.error.message);
|
|
22147
|
+
boundary.repositoryGit = repositoryGit.value;
|
|
22148
|
+
if (!sameBoundaryIdentity(boundary.repositoryGit, this.repositoryGitIdentity)) {
|
|
21107
22149
|
throw new DirectoryBoundaryError(
|
|
21108
22150
|
"identity_changed",
|
|
21109
22151
|
"The repository Git directory was replaced after broker initialization"
|
|
21110
22152
|
);
|
|
21111
22153
|
}
|
|
21112
|
-
|
|
22154
|
+
if (!sameBoundaryIdentity(boundary.targetParent, this.worktreeRootIdentity)) {
|
|
22155
|
+
throw new DirectoryBoundaryError(
|
|
22156
|
+
"identity_changed",
|
|
22157
|
+
"The worktree root was replaced after broker initialization"
|
|
22158
|
+
);
|
|
22159
|
+
}
|
|
21113
22160
|
const relative = path33.relative(this.worktreeRoot, path33.resolve(target.worktreePath));
|
|
21114
22161
|
const components = relative.split(path33.sep);
|
|
21115
22162
|
const targetName = components.pop();
|
|
21116
22163
|
if (!targetName) {
|
|
21117
|
-
allocationRoot.close();
|
|
21118
22164
|
throw new DirectoryBoundaryError("invalid_path", "The worktree target has no basename");
|
|
21119
22165
|
}
|
|
21120
|
-
|
|
22166
|
+
boundary.targetName = targetName;
|
|
21121
22167
|
for (const component of components) {
|
|
21122
|
-
const child =
|
|
21123
|
-
|
|
21124
|
-
|
|
22168
|
+
const child = await lease.openChild(
|
|
22169
|
+
boundary.targetParent,
|
|
22170
|
+
component,
|
|
22171
|
+
nextBoundaryOperationId(boundary, "open-target-ancestor")
|
|
22172
|
+
);
|
|
22173
|
+
if (!child.ok) throw new Error(child.error.message);
|
|
22174
|
+
boundary.targetParent = child.value;
|
|
21125
22175
|
}
|
|
21126
|
-
targetDirectory =
|
|
21127
|
-
|
|
21128
|
-
repository,
|
|
21129
|
-
repositoryGit,
|
|
21130
|
-
targetParent,
|
|
22176
|
+
const targetDirectory = await lease.tryOpenChild(
|
|
22177
|
+
boundary.targetParent,
|
|
21131
22178
|
targetName,
|
|
21132
|
-
target
|
|
21133
|
-
|
|
22179
|
+
nextBoundaryOperationId(boundary, "open-target")
|
|
22180
|
+
);
|
|
22181
|
+
if (!targetDirectory.ok) throw new Error(targetDirectory.error.message);
|
|
22182
|
+
boundary.target = targetDirectory.value;
|
|
22183
|
+
return boundary;
|
|
21134
22184
|
} catch (error) {
|
|
21135
|
-
|
|
21136
|
-
targetParent?.close();
|
|
21137
|
-
repositoryGit?.close();
|
|
21138
|
-
repository?.close();
|
|
22185
|
+
await lease.close("cancelled");
|
|
21139
22186
|
return this.containmentFailure(operation, error);
|
|
21140
22187
|
}
|
|
21141
22188
|
}
|
|
22189
|
+
boundaryAuthority(target, operation, options) {
|
|
22190
|
+
if (options.boundaryAuthority) return options.boundaryAuthority;
|
|
22191
|
+
if (!this.testOnlyAllowUnboundBoundaryAuthority) return null;
|
|
22192
|
+
return {
|
|
22193
|
+
operationId: `test-${target.attemptId}-${operation}`,
|
|
22194
|
+
orchestrationLeaseId: `test-${target.attemptId}`,
|
|
22195
|
+
orchestrationLeaseRevision: 0,
|
|
22196
|
+
ownerId: `test-${target.hostId}`
|
|
22197
|
+
};
|
|
22198
|
+
}
|
|
21142
22199
|
containmentFailure(operation, error) {
|
|
21143
22200
|
const message = error instanceof DirectoryBoundaryError ? error.message : `Directory identity containment failed: ${errorMessage(error)}`;
|
|
21144
22201
|
return this.failure(operation, "containment_violation", message);
|
|
21145
22202
|
}
|
|
21146
22203
|
gitMain(boundary, operation, args, options, allowedNonzeroExitCodes = []) {
|
|
21147
|
-
const
|
|
21148
|
-
|
|
21149
|
-
|
|
21150
|
-
|
|
22204
|
+
const boundaryArgs = [
|
|
22205
|
+
{
|
|
22206
|
+
kind: "directory",
|
|
22207
|
+
directory: boundary.repositoryGit,
|
|
22208
|
+
prefix: "--git-dir=",
|
|
22209
|
+
relativeToCwd: true
|
|
22210
|
+
},
|
|
22211
|
+
{ kind: "directory", directory: boundary.repository, prefix: "--work-tree=" },
|
|
22212
|
+
...args.map(boundaryArgument)
|
|
21151
22213
|
];
|
|
21152
22214
|
const evidenceArgs = [
|
|
21153
22215
|
`--git-dir=${this.repositoryGitIdentity.path}`,
|
|
21154
22216
|
`--work-tree=${this.repositoryRoot}`,
|
|
21155
|
-
...args.map(
|
|
21156
|
-
(arg) => boundary.target && arg === boundary.target.procPath ? boundary.target.path : arg
|
|
21157
|
-
)
|
|
22217
|
+
...args.map(evidenceArgument)
|
|
21158
22218
|
];
|
|
21159
22219
|
return this.git(
|
|
22220
|
+
boundary,
|
|
21160
22221
|
operation,
|
|
21161
|
-
|
|
21162
|
-
boundary.
|
|
22222
|
+
boundaryArgs,
|
|
22223
|
+
boundary.repositoryGit,
|
|
21163
22224
|
options,
|
|
21164
22225
|
allowedNonzeroExitCodes,
|
|
21165
|
-
() => this.assertOperationBoundary(boundary),
|
|
21166
22226
|
{ args: evidenceArgs, cwd: this.repositoryRoot }
|
|
21167
22227
|
);
|
|
21168
22228
|
}
|
|
@@ -21176,38 +22236,24 @@ var NodeGitWorktreeBroker = class {
|
|
|
21176
22236
|
)
|
|
21177
22237
|
);
|
|
21178
22238
|
}
|
|
21179
|
-
const
|
|
21180
|
-
|
|
21181
|
-
|
|
21182
|
-
...args
|
|
22239
|
+
const boundaryArgs = [
|
|
22240
|
+
{ kind: "directory", directory: worktreeGit, prefix: "--git-dir=" },
|
|
22241
|
+
{ kind: "directory", directory: boundary.target, prefix: "--work-tree=" },
|
|
22242
|
+
...args.map(boundaryArgument)
|
|
21183
22243
|
];
|
|
21184
22244
|
const evidenceArgs = [
|
|
21185
22245
|
`--git-dir=${path33.join(
|
|
21186
22246
|
this.repositoryGitIdentity.path,
|
|
21187
22247
|
"worktrees",
|
|
21188
|
-
path33.basename(boundary.target.
|
|
22248
|
+
path33.basename(boundary.target.identity.canonical_path)
|
|
21189
22249
|
)}`,
|
|
21190
|
-
`--work-tree=${boundary.target.
|
|
22250
|
+
`--work-tree=${boundary.target.identity.canonical_path}`,
|
|
21191
22251
|
...args
|
|
21192
22252
|
];
|
|
21193
|
-
return this.git(
|
|
21194
|
-
|
|
21195
|
-
|
|
21196
|
-
|
|
21197
|
-
options,
|
|
21198
|
-
[],
|
|
21199
|
-
() => this.assertOperationBoundary(boundary, worktreeGit),
|
|
21200
|
-
{ args: evidenceArgs, cwd: boundary.target.path }
|
|
21201
|
-
);
|
|
21202
|
-
}
|
|
21203
|
-
assertOperationBoundary(boundary, worktreeGit) {
|
|
21204
|
-
assertAnchoredDirectoryLocation(boundary.repository, "repositoryRoot");
|
|
21205
|
-
assertAnchoredDirectoryLocation(boundary.repositoryGit, "repository Git directory");
|
|
21206
|
-
assertAnchoredDirectoryLocation(boundary.targetParent, "worktree target parent");
|
|
21207
|
-
if (boundary.target) assertAnchoredDirectoryLocation(boundary.target, "worktree target");
|
|
21208
|
-
if (worktreeGit) {
|
|
21209
|
-
assertAnchoredDirectoryLocation(worktreeGit, "worktree Git directory");
|
|
21210
|
-
}
|
|
22253
|
+
return this.git(boundary, operation, boundaryArgs, boundary.target, options, [], {
|
|
22254
|
+
args: evidenceArgs,
|
|
22255
|
+
cwd: boundary.target.identity.canonical_path
|
|
22256
|
+
});
|
|
21211
22257
|
}
|
|
21212
22258
|
async writeAttemptMarker(target, boundary) {
|
|
21213
22259
|
const gitDirectory = await this.openWorktreeGitDirectory(boundary, "create");
|
|
@@ -21224,18 +22270,16 @@ var NodeGitWorktreeBroker = class {
|
|
|
21224
22270
|
baseSha: target.baseSha
|
|
21225
22271
|
};
|
|
21226
22272
|
try {
|
|
21227
|
-
|
|
21228
|
-
|
|
21229
|
-
|
|
21230
|
-
|
|
21231
|
-
|
|
21232
|
-
|
|
21233
|
-
|
|
21234
|
-
|
|
21235
|
-
|
|
21236
|
-
|
|
21237
|
-
await handle.close();
|
|
21238
|
-
}
|
|
22273
|
+
const written = await boundary.lease.writeFile({
|
|
22274
|
+
operationId: nextBoundaryOperationId(boundary, "write-attempt-marker"),
|
|
22275
|
+
directory: gitDirectory,
|
|
22276
|
+
component: ATTEMPT_MARKER_FILE,
|
|
22277
|
+
content: Buffer.from(`${JSON.stringify(marker)}
|
|
22278
|
+
`, "utf8"),
|
|
22279
|
+
mode: 384,
|
|
22280
|
+
exclusive: true
|
|
22281
|
+
});
|
|
22282
|
+
if (!written.ok) throw new Error(written.error.message);
|
|
21239
22283
|
return null;
|
|
21240
22284
|
} catch (error) {
|
|
21241
22285
|
return this.failure(
|
|
@@ -21243,27 +22287,32 @@ var NodeGitWorktreeBroker = class {
|
|
|
21243
22287
|
"containment_violation",
|
|
21244
22288
|
`Worktree was created but its Attempt marker could not be written: ${errorMessage(error)}`
|
|
21245
22289
|
);
|
|
21246
|
-
} finally {
|
|
21247
|
-
gitDirectory.close();
|
|
21248
22290
|
}
|
|
21249
22291
|
}
|
|
21250
|
-
async readAttemptMarker(target, gitDirectory) {
|
|
22292
|
+
async readAttemptMarker(target, gitDirectory, boundary) {
|
|
21251
22293
|
let marker;
|
|
21252
22294
|
try {
|
|
21253
|
-
const
|
|
21254
|
-
|
|
21255
|
-
|
|
21256
|
-
|
|
21257
|
-
|
|
21258
|
-
);
|
|
22295
|
+
const read = await boundary.lease.readFile({
|
|
22296
|
+
operationId: nextBoundaryOperationId(boundary, "read-attempt-marker"),
|
|
22297
|
+
directory: gitDirectory,
|
|
22298
|
+
component: ATTEMPT_MARKER_FILE,
|
|
22299
|
+
maxBytes: MAX_ATTEMPT_MARKER_BYTES
|
|
22300
|
+
});
|
|
22301
|
+
if (!read.ok) {
|
|
22302
|
+
if (read.error.code === "invalid_path") {
|
|
22303
|
+
return { matches: false, reason: "worktree Attempt marker is missing" };
|
|
22304
|
+
}
|
|
22305
|
+
return {
|
|
22306
|
+
matches: false,
|
|
22307
|
+
reason: `worktree Attempt marker is unreadable: ${read.error.message}`
|
|
22308
|
+
};
|
|
22309
|
+
}
|
|
22310
|
+
const parsed = JSON.parse(Buffer.from(read.value).toString("utf8"));
|
|
21259
22311
|
if (!isAttemptMarker(parsed)) {
|
|
21260
22312
|
return { matches: false, reason: "worktree Attempt marker is malformed" };
|
|
21261
22313
|
}
|
|
21262
22314
|
marker = parsed;
|
|
21263
22315
|
} catch (error) {
|
|
21264
|
-
if (isNodeError2(error) && error.code === "ENOENT") {
|
|
21265
|
-
return { matches: false, reason: "worktree Attempt marker is missing" };
|
|
21266
|
-
}
|
|
21267
22316
|
return {
|
|
21268
22317
|
matches: false,
|
|
21269
22318
|
reason: `worktree Attempt marker is unreadable: ${errorMessage(error)}`
|
|
@@ -21283,17 +22332,16 @@ var NodeGitWorktreeBroker = class {
|
|
|
21283
22332
|
"The worktree target directory identity is unavailable"
|
|
21284
22333
|
);
|
|
21285
22334
|
}
|
|
21286
|
-
try {
|
|
21287
|
-
this.assertOperationBoundary(boundary);
|
|
21288
|
-
} catch (error) {
|
|
21289
|
-
return this.containmentFailure(operation, error);
|
|
21290
|
-
}
|
|
21291
22335
|
let gitFile;
|
|
21292
22336
|
try {
|
|
21293
|
-
|
|
21294
|
-
|
|
21295
|
-
|
|
21296
|
-
|
|
22337
|
+
const read = await boundary.lease.readFile({
|
|
22338
|
+
operationId: nextBoundaryOperationId(boundary, "read-worktree-git-file"),
|
|
22339
|
+
directory: boundary.target,
|
|
22340
|
+
component: ".git",
|
|
22341
|
+
maxBytes: MAX_GITDIR_FILE_BYTES
|
|
22342
|
+
});
|
|
22343
|
+
if (!read.ok) throw new Error(read.error.message);
|
|
22344
|
+
gitFile = Buffer.from(read.value).toString("utf8");
|
|
21297
22345
|
} catch (error) {
|
|
21298
22346
|
return this.containmentFailure(operation, error);
|
|
21299
22347
|
}
|
|
@@ -21325,18 +22373,17 @@ var NodeGitWorktreeBroker = class {
|
|
|
21325
22373
|
let current = null;
|
|
21326
22374
|
try {
|
|
21327
22375
|
for (const component of relative.split(path33.sep)) {
|
|
21328
|
-
const child =
|
|
22376
|
+
const child = await boundary.lease.openChild(
|
|
21329
22377
|
current ?? boundary.repositoryGit,
|
|
21330
22378
|
component,
|
|
21331
|
-
"worktree
|
|
22379
|
+
nextBoundaryOperationId(boundary, "open-worktree-git-directory")
|
|
21332
22380
|
);
|
|
21333
|
-
|
|
21334
|
-
current = child;
|
|
22381
|
+
if (!child.ok) throw new Error(child.error.message);
|
|
22382
|
+
current = child.value;
|
|
21335
22383
|
}
|
|
21336
22384
|
if (!current) throw new DirectoryBoundaryError("invalid_path", "Missing worktree Git path");
|
|
21337
22385
|
return current;
|
|
21338
22386
|
} catch (error) {
|
|
21339
|
-
current?.close();
|
|
21340
22387
|
return this.containmentFailure(operation, error);
|
|
21341
22388
|
}
|
|
21342
22389
|
}
|
|
@@ -21382,32 +22429,36 @@ var NodeGitWorktreeBroker = class {
|
|
|
21382
22429
|
const relative = path33.relative(comparedRoot, comparedCandidate);
|
|
21383
22430
|
return relative.length > 0 && relative !== ".." && !relative.startsWith(`..${path33.sep}`);
|
|
21384
22431
|
}
|
|
21385
|
-
async git(operation, args, cwd, options, allowedNonzeroExitCodes = [],
|
|
21386
|
-
const
|
|
22432
|
+
async git(boundary, operation, args, cwd, options, allowedNonzeroExitCodes = [], evidence) {
|
|
22433
|
+
const result = await boundary.lease.runProcess({
|
|
22434
|
+
operationId: nextBoundaryOperationId(boundary, "run-git"),
|
|
21387
22435
|
executable: this.gitExecutable,
|
|
21388
22436
|
args,
|
|
21389
22437
|
cwd,
|
|
21390
22438
|
timeoutMs: options.timeoutMs ?? this.defaultTimeoutMs,
|
|
21391
|
-
...
|
|
22439
|
+
...options.signal ? { signal: options.signal } : {}
|
|
22440
|
+
});
|
|
22441
|
+
if (!result.ok) return this.containmentFailure(operation, result.error);
|
|
22442
|
+
const commandResult = result.value;
|
|
22443
|
+
const commandEvidence = {
|
|
22444
|
+
executable: this.gitExecutable,
|
|
22445
|
+
args: evidence?.args ?? args.map(evidenceArgument),
|
|
22446
|
+
cwd: evidence?.cwd ?? cwd.identity.canonical_path,
|
|
22447
|
+
timeoutMs: options.timeoutMs ?? this.defaultTimeoutMs,
|
|
21392
22448
|
...options.signal ? { signal: options.signal } : {}
|
|
21393
22449
|
};
|
|
21394
|
-
|
|
21395
|
-
if (result.ok || result.kind === "nonzero_exit" && result.exitCode !== null && allowedNonzeroExitCodes.includes(result.exitCode)) {
|
|
22450
|
+
if (commandResult.ok || commandResult.kind === "nonzero_exit" && commandResult.exitCode !== null && allowedNonzeroExitCodes.includes(commandResult.exitCode)) {
|
|
21396
22451
|
return {
|
|
21397
22452
|
ok: true,
|
|
21398
|
-
exitCode:
|
|
21399
|
-
stdout:
|
|
21400
|
-
stderr:
|
|
21401
|
-
executable:
|
|
21402
|
-
args: [...
|
|
21403
|
-
cwd:
|
|
22453
|
+
exitCode: commandResult.exitCode ?? 0,
|
|
22454
|
+
stdout: commandResult.stdout,
|
|
22455
|
+
stderr: commandResult.stderr,
|
|
22456
|
+
executable: commandEvidence.executable,
|
|
22457
|
+
args: [...commandEvidence.args],
|
|
22458
|
+
cwd: commandEvidence.cwd
|
|
21404
22459
|
};
|
|
21405
22460
|
}
|
|
21406
|
-
return this.commandFailure(
|
|
21407
|
-
operation,
|
|
21408
|
-
evidence ? { ...request, args: evidence.args, cwd: evidence.cwd } : request,
|
|
21409
|
-
result
|
|
21410
|
-
);
|
|
22461
|
+
return this.commandFailure(operation, commandEvidence, commandResult);
|
|
21411
22462
|
}
|
|
21412
22463
|
commandFailure(operation, request, result) {
|
|
21413
22464
|
if (result.kind === "preflight_error") {
|
|
@@ -21447,11 +22498,29 @@ var NodeGitWorktreeBroker = class {
|
|
|
21447
22498
|
};
|
|
21448
22499
|
}
|
|
21449
22500
|
};
|
|
21450
|
-
function closeOperationBoundary(boundary) {
|
|
21451
|
-
boundary.
|
|
21452
|
-
|
|
21453
|
-
|
|
21454
|
-
boundary.
|
|
22501
|
+
async function closeOperationBoundary(boundary) {
|
|
22502
|
+
await boundary.lease.close("completed");
|
|
22503
|
+
}
|
|
22504
|
+
function nextBoundaryOperationId(boundary, label) {
|
|
22505
|
+
boundary.operationSequence += 1;
|
|
22506
|
+
const suffix = `:${boundary.operationSequence}:${label}`;
|
|
22507
|
+
return `${boundary.operationId.slice(0, 4096 - suffix.length)}${suffix}`;
|
|
22508
|
+
}
|
|
22509
|
+
function boundaryArgument(argument) {
|
|
22510
|
+
return typeof argument === "string" ? { kind: "literal", value: argument } : argument;
|
|
22511
|
+
}
|
|
22512
|
+
function evidenceArgument(argument) {
|
|
22513
|
+
if (typeof argument === "string") return argument;
|
|
22514
|
+
if (argument.kind === "literal") return argument.value;
|
|
22515
|
+
const rendered = path33.join(
|
|
22516
|
+
argument.directory.identity.canonical_path,
|
|
22517
|
+
...argument.components ?? []
|
|
22518
|
+
);
|
|
22519
|
+
return `${argument.prefix ?? ""}${rendered}${argument.suffix ?? ""}`;
|
|
22520
|
+
}
|
|
22521
|
+
function sameBoundaryIdentity(capability, identity) {
|
|
22522
|
+
const observed = capability.identity;
|
|
22523
|
+
return observed.identity_kind === "linux-device-inode" && observed.device === identity.device.toString(10) && observed.inode === identity.inode.toString(10);
|
|
21455
22524
|
}
|
|
21456
22525
|
function nativePathsOverlap2(left, right, comparison) {
|
|
21457
22526
|
const normalize2 = (value) => {
|
|
@@ -21471,35 +22540,18 @@ function branchName(ref) {
|
|
|
21471
22540
|
const prefix = "refs/heads/";
|
|
21472
22541
|
return ref.startsWith(prefix) ? ref.slice(prefix.length) : ref;
|
|
21473
22542
|
}
|
|
21474
|
-
function isNodeError2(error) {
|
|
21475
|
-
return error instanceof Error && "code" in error;
|
|
21476
|
-
}
|
|
21477
22543
|
function errorMessage(error) {
|
|
21478
|
-
|
|
22544
|
+
if (error instanceof Error) return error.message;
|
|
22545
|
+
if (typeof error === "object" && error !== null && "message" in error && typeof error.message === "string") {
|
|
22546
|
+
return error.message;
|
|
22547
|
+
}
|
|
22548
|
+
return String(error);
|
|
21479
22549
|
}
|
|
21480
22550
|
function isAttemptMarker(value) {
|
|
21481
22551
|
if (typeof value !== "object" || value === null || Array.isArray(value)) return false;
|
|
21482
22552
|
const marker = value;
|
|
21483
22553
|
return marker.schemaVersion === 1 && typeof marker.repositoryId === "string" && typeof marker.attemptId === "string" && typeof marker.hostId === "string" && typeof marker.gitRuntime === "string" && typeof marker.projectRoot === "string" && typeof marker.worktreePath === "string" && typeof marker.branch === "string" && typeof marker.baseSha === "string";
|
|
21484
22554
|
}
|
|
21485
|
-
async function readBoundedText(filePath, maxBytes) {
|
|
21486
|
-
const handle = await open(filePath, constants2.O_RDONLY | constants2.O_NOFOLLOW);
|
|
21487
|
-
try {
|
|
21488
|
-
const stats = await handle.stat();
|
|
21489
|
-
if (!stats.isFile()) throw new Error(`${filePath} is not a regular file`);
|
|
21490
|
-
const buffer = Buffer.alloc(maxBytes + 1);
|
|
21491
|
-
let offset = 0;
|
|
21492
|
-
while (offset < buffer.byteLength) {
|
|
21493
|
-
const { bytesRead } = await handle.read(buffer, offset, buffer.byteLength - offset, offset);
|
|
21494
|
-
if (bytesRead === 0) break;
|
|
21495
|
-
offset += bytesRead;
|
|
21496
|
-
}
|
|
21497
|
-
if (offset > maxBytes) throw new Error(`Attempt marker exceeds ${maxBytes} bytes`);
|
|
21498
|
-
return buffer.subarray(0, offset).toString("utf8");
|
|
21499
|
-
} finally {
|
|
21500
|
-
await handle.close();
|
|
21501
|
-
}
|
|
21502
|
-
}
|
|
21503
22555
|
function tail(value, maxBytes) {
|
|
21504
22556
|
const bytes = Buffer.from(value, "utf8");
|
|
21505
22557
|
if (bytes.byteLength <= maxBytes) return value;
|
|
@@ -23391,7 +24443,7 @@ async function writeExclusiveText(directory, file, content) {
|
|
|
23391
24443
|
async function readOwnerMarker(directory) {
|
|
23392
24444
|
try {
|
|
23393
24445
|
const parsed = JSON.parse(
|
|
23394
|
-
await
|
|
24446
|
+
await readBoundedText(path34.join(directory.procPath, OWNER_FILE))
|
|
23395
24447
|
);
|
|
23396
24448
|
return isOwnerMarker(parsed) ? parsed : null;
|
|
23397
24449
|
} catch {
|
|
@@ -23401,7 +24453,7 @@ async function readOwnerMarker(directory) {
|
|
|
23401
24453
|
async function readQuarantineOwnerMarker(directory) {
|
|
23402
24454
|
try {
|
|
23403
24455
|
const parsed = JSON.parse(
|
|
23404
|
-
await
|
|
24456
|
+
await readBoundedText(path34.join(directory.procPath, QUARANTINE_OWNER_FILE))
|
|
23405
24457
|
);
|
|
23406
24458
|
return isQuarantineOwnerMarker(parsed) ? parsed : null;
|
|
23407
24459
|
} catch {
|
|
@@ -23581,7 +24633,7 @@ async function readProjectionManifest(repository) {
|
|
|
23581
24633
|
try {
|
|
23582
24634
|
gitDirectory = openChildDirectory(repository, ".git", "native projection Git directory");
|
|
23583
24635
|
const parsed = JSON.parse(
|
|
23584
|
-
await
|
|
24636
|
+
await readBoundedText(path34.join(gitDirectory.procPath, MANIFEST_FILE))
|
|
23585
24637
|
);
|
|
23586
24638
|
const result = NativeWslProjectionManifest_v1.safeParse(parsed);
|
|
23587
24639
|
return result.success ? result.data : null;
|
|
@@ -23591,7 +24643,7 @@ async function readProjectionManifest(repository) {
|
|
|
23591
24643
|
gitDirectory?.close();
|
|
23592
24644
|
}
|
|
23593
24645
|
}
|
|
23594
|
-
async function
|
|
24646
|
+
async function readBoundedText(file) {
|
|
23595
24647
|
const stats = await lstat(file);
|
|
23596
24648
|
if (!stats.isFile() || stats.size > MAX_STATE_FILE_BYTES) {
|
|
23597
24649
|
throw new Error("projection state file is invalid");
|
|
@@ -23727,35 +24779,35 @@ function isNodeError3(error) {
|
|
|
23727
24779
|
// src/runs/agent-work-projection-lifecycle.ts
|
|
23728
24780
|
var MAX_INPUT_BYTES2 = 256 * 1024;
|
|
23729
24781
|
var MAX_ISSUES2 = 20;
|
|
23730
|
-
var text =
|
|
23731
|
-
var mutationAuthority =
|
|
23732
|
-
authorized:
|
|
24782
|
+
var text = z19.string().min(1).max(4096);
|
|
24783
|
+
var mutationAuthority = z19.object({
|
|
24784
|
+
authorized: z19.literal(true),
|
|
23733
24785
|
reason: text.optional()
|
|
23734
24786
|
}).strict();
|
|
23735
|
-
var NativeWslProjectionPrepareRequestSchema =
|
|
24787
|
+
var NativeWslProjectionPrepareRequestSchema = z19.object({
|
|
23736
24788
|
request: NativeWslProjectionRequest_v1,
|
|
23737
24789
|
mutation: mutationAuthority
|
|
23738
24790
|
}).strict();
|
|
23739
|
-
var NativeWslProjectionStatusRequestSchema =
|
|
23740
|
-
var NativeWslProjectionCleanupRequestSchema =
|
|
24791
|
+
var NativeWslProjectionStatusRequestSchema = z19.object({ request: NativeWslProjectionRequest_v1 }).strict();
|
|
24792
|
+
var NativeWslProjectionCleanupRequestSchema = z19.object({
|
|
23741
24793
|
request: NativeWslProjectionRequest_v1,
|
|
23742
24794
|
mutation: mutationAuthority,
|
|
23743
|
-
includeQuarantine:
|
|
24795
|
+
includeQuarantine: z19.boolean().optional()
|
|
23744
24796
|
}).strict();
|
|
23745
|
-
var NativeWslProjectionQuarantineRequestSchema =
|
|
23746
|
-
var NativeWslProjectionPrepareRequestJsonSchema =
|
|
24797
|
+
var NativeWslProjectionQuarantineRequestSchema = z19.object({ request: NativeWslProjectionRequest_v1 }).strict();
|
|
24798
|
+
var NativeWslProjectionPrepareRequestJsonSchema = z19.toJSONSchema(
|
|
23747
24799
|
NativeWslProjectionPrepareRequestSchema,
|
|
23748
24800
|
{ target: "draft-7" }
|
|
23749
24801
|
);
|
|
23750
|
-
var NativeWslProjectionStatusRequestJsonSchema =
|
|
24802
|
+
var NativeWslProjectionStatusRequestJsonSchema = z19.toJSONSchema(
|
|
23751
24803
|
NativeWslProjectionStatusRequestSchema,
|
|
23752
24804
|
{ target: "draft-7" }
|
|
23753
24805
|
);
|
|
23754
|
-
var NativeWslProjectionCleanupRequestJsonSchema =
|
|
24806
|
+
var NativeWslProjectionCleanupRequestJsonSchema = z19.toJSONSchema(
|
|
23755
24807
|
NativeWslProjectionCleanupRequestSchema,
|
|
23756
24808
|
{ target: "draft-7" }
|
|
23757
24809
|
);
|
|
23758
|
-
var NativeWslProjectionQuarantineRequestJsonSchema =
|
|
24810
|
+
var NativeWslProjectionQuarantineRequestJsonSchema = z19.toJSONSchema(
|
|
23759
24811
|
NativeWslProjectionQuarantineRequestSchema,
|
|
23760
24812
|
{ target: "draft-7" }
|
|
23761
24813
|
);
|
|
@@ -23951,17 +25003,17 @@ function isJsonSafe2(value, seen = /* @__PURE__ */ new Set(), depth = 0) {
|
|
|
23951
25003
|
// src/runs/agent-work-adapters.ts
|
|
23952
25004
|
import path38 from "path";
|
|
23953
25005
|
import { stat as stat3 } from "fs/promises";
|
|
23954
|
-
import { z as
|
|
25006
|
+
import { z as z26 } from "zod";
|
|
23955
25007
|
|
|
23956
25008
|
// src/schemas/agent-work.ts
|
|
23957
|
-
import { z as
|
|
25009
|
+
import { z as z20 } from "zod";
|
|
23958
25010
|
var AGENT_WORK_CONTRACT_VERSION = "1.0.0";
|
|
23959
25011
|
var AGENT_TASK_RECEIPT_V2_VERSION = "2.0.0";
|
|
23960
25012
|
var AGENT_TASK_RECEIPT_PATCH_PROFILE = "git-diff-binary-v1";
|
|
23961
25013
|
var AGENT_ENGINE_VERIFICATION_V2_VERSION = "2.0.0";
|
|
23962
|
-
var Id =
|
|
23963
|
-
var
|
|
23964
|
-
var Revision =
|
|
25014
|
+
var Id = z20.string().min(1);
|
|
25015
|
+
var Timestamp4 = z20.string().datetime();
|
|
25016
|
+
var Revision = z20.number().int().nonnegative();
|
|
23965
25017
|
function timestampMillis(value) {
|
|
23966
25018
|
return Date.parse(value);
|
|
23967
25019
|
}
|
|
@@ -23974,15 +25026,15 @@ function requireTimestampOrder(earlier, later, laterPath, ctx) {
|
|
|
23974
25026
|
});
|
|
23975
25027
|
}
|
|
23976
25028
|
}
|
|
23977
|
-
var GitObjectId =
|
|
23978
|
-
var CanonicalGitObjectId2 =
|
|
23979
|
-
var ReceiptTimestampV2 =
|
|
23980
|
-
var PortableRepository =
|
|
25029
|
+
var GitObjectId = z20.string().regex(/^(?:[a-f0-9]{40}|[a-f0-9]{64})$/i, "Must be a full SHA-1 or SHA-256 Git object ID");
|
|
25030
|
+
var CanonicalGitObjectId2 = z20.string().regex(/^(?:[a-f0-9]{40}|[a-f0-9]{64})$/, "Must be a lowercase full Git object ID");
|
|
25031
|
+
var ReceiptTimestampV2 = z20.string().datetime({ offset: true });
|
|
25032
|
+
var PortableRepository = z20.object({
|
|
23981
25033
|
id: Id,
|
|
23982
|
-
remote_url:
|
|
23983
|
-
default_branch:
|
|
25034
|
+
remote_url: z20.string().url().optional(),
|
|
25035
|
+
default_branch: z20.string().min(1).optional()
|
|
23984
25036
|
}).strict();
|
|
23985
|
-
var PortableGlob =
|
|
25037
|
+
var PortableGlob = z20.string().min(1).refine((value) => !isMachineLocalAbsolutePath(value), {
|
|
23986
25038
|
message: "Glob must be repository-relative"
|
|
23987
25039
|
}).refine((value) => !value.split(/[\\/]/u).includes(".."), {
|
|
23988
25040
|
message: "Glob must not escape the repository root"
|
|
@@ -23998,24 +25050,24 @@ var CanonicalAgentRepoPathV2 = AgentRepoRelativePath.refine((value) => !value.in
|
|
|
23998
25050
|
}).refine((value) => value.split("/").every((segment) => segment.length > 0 && segment !== "."), {
|
|
23999
25051
|
message: "Path must not contain empty or dot segments"
|
|
24000
25052
|
});
|
|
24001
|
-
var PortableScope =
|
|
24002
|
-
read_globs:
|
|
24003
|
-
write_globs:
|
|
24004
|
-
deny_globs:
|
|
24005
|
-
cross_repo_allowed:
|
|
25053
|
+
var PortableScope = z20.object({
|
|
25054
|
+
read_globs: z20.array(PortableGlob),
|
|
25055
|
+
write_globs: z20.array(PortableGlob),
|
|
25056
|
+
deny_globs: z20.array(PortableGlob),
|
|
25057
|
+
cross_repo_allowed: z20.boolean()
|
|
24006
25058
|
}).strict();
|
|
24007
|
-
var AuthorityEnvelope =
|
|
24008
|
-
edit:
|
|
24009
|
-
git_write:
|
|
24010
|
-
github_write:
|
|
24011
|
-
external_runtime:
|
|
24012
|
-
secrets:
|
|
24013
|
-
signing:
|
|
24014
|
-
release:
|
|
25059
|
+
var AuthorityEnvelope = z20.object({
|
|
25060
|
+
edit: z20.boolean(),
|
|
25061
|
+
git_write: z20.boolean(),
|
|
25062
|
+
github_write: z20.boolean(),
|
|
25063
|
+
external_runtime: z20.boolean(),
|
|
25064
|
+
secrets: z20.boolean(),
|
|
25065
|
+
signing: z20.boolean(),
|
|
25066
|
+
release: z20.boolean()
|
|
24015
25067
|
}).strict();
|
|
24016
|
-
var AcceptanceCriterion =
|
|
25068
|
+
var AcceptanceCriterion = z20.object({
|
|
24017
25069
|
id: Id,
|
|
24018
|
-
text:
|
|
25070
|
+
text: z20.string().min(1)
|
|
24019
25071
|
}).strict();
|
|
24020
25072
|
function isMachineLocalAbsolutePath(value) {
|
|
24021
25073
|
return /(?:^|\s)\/(?!\/)[^\s]*/.test(value) || /(?:^|\s)~\/[^\s]*/.test(value) || /(?:^|\s)\\\\[^\s]*/.test(value) || /(?:^|\s)[a-z]:[\\/][^\s]*/i.test(value) || /(?:^|\s)file:/i.test(value);
|
|
@@ -24070,27 +25122,27 @@ function requireUniqueStrings(values, field, ctx) {
|
|
|
24070
25122
|
function compareCanonicalStrings(left, right) {
|
|
24071
25123
|
return left < right ? -1 : left > right ? 1 : 0;
|
|
24072
25124
|
}
|
|
24073
|
-
var WorkItem_v1 =
|
|
24074
|
-
schema_version:
|
|
25125
|
+
var WorkItem_v1 = z20.object({
|
|
25126
|
+
schema_version: z20.literal(AGENT_WORK_CONTRACT_VERSION),
|
|
24075
25127
|
work_item_id: Id,
|
|
24076
25128
|
revision: Revision,
|
|
24077
|
-
source:
|
|
24078
|
-
kind:
|
|
25129
|
+
source: z20.object({
|
|
25130
|
+
kind: z20.enum(["jira", "github", "manual"]),
|
|
24079
25131
|
external_id: Id,
|
|
24080
|
-
revision:
|
|
24081
|
-
url:
|
|
24082
|
-
captured_at:
|
|
25132
|
+
revision: z20.string().min(1),
|
|
25133
|
+
url: z20.string().url().optional(),
|
|
25134
|
+
captured_at: Timestamp4
|
|
24083
25135
|
}).strict(),
|
|
24084
25136
|
repository: PortableRepository,
|
|
24085
|
-
title:
|
|
24086
|
-
objective:
|
|
24087
|
-
description:
|
|
24088
|
-
acceptance_criteria:
|
|
24089
|
-
constraints:
|
|
24090
|
-
labels:
|
|
24091
|
-
dependencies:
|
|
25137
|
+
title: z20.string().min(1),
|
|
25138
|
+
objective: z20.string().min(1),
|
|
25139
|
+
description: z20.string(),
|
|
25140
|
+
acceptance_criteria: z20.array(AcceptanceCriterion),
|
|
25141
|
+
constraints: z20.array(z20.string()),
|
|
25142
|
+
labels: z20.array(z20.string()),
|
|
25143
|
+
dependencies: z20.array(Id)
|
|
24092
25144
|
}).strict();
|
|
24093
|
-
var RunStatus =
|
|
25145
|
+
var RunStatus = z20.enum([
|
|
24094
25146
|
"created",
|
|
24095
25147
|
"planning",
|
|
24096
25148
|
"ready",
|
|
@@ -24104,25 +25156,25 @@ var RunStatus = z18.enum([
|
|
|
24104
25156
|
"failed",
|
|
24105
25157
|
"cancelled"
|
|
24106
25158
|
]);
|
|
24107
|
-
var RunResumeStatus =
|
|
25159
|
+
var RunResumeStatus = z20.enum(["planning", "ready", "executing", "verifying", "delivering"]);
|
|
24108
25160
|
var INTERRUPTED_RUN_STATUSES = /* @__PURE__ */ new Set(["awaiting_human", "paused", "blocked"]);
|
|
24109
25161
|
var TERMINAL_RUN_STATUSES = /* @__PURE__ */ new Set(["completed", "failed", "cancelled"]);
|
|
24110
|
-
var Run_v1 =
|
|
24111
|
-
schema_version:
|
|
25162
|
+
var Run_v1 = z20.object({
|
|
25163
|
+
schema_version: z20.literal(AGENT_WORK_CONTRACT_VERSION),
|
|
24112
25164
|
run_id: Id,
|
|
24113
25165
|
revision: Revision,
|
|
24114
25166
|
work_item_id: Id,
|
|
24115
25167
|
work_item_revision: Revision,
|
|
24116
|
-
control_mode:
|
|
25168
|
+
control_mode: z20.enum(["assisted", "headless"]),
|
|
24117
25169
|
authority_ceiling: AuthorityEnvelope,
|
|
24118
25170
|
status: RunStatus,
|
|
24119
25171
|
active_controller_lease_id: Id.optional(),
|
|
24120
|
-
attempt_ids:
|
|
25172
|
+
attempt_ids: z20.array(Id),
|
|
24121
25173
|
current_attempt_id: Id.optional(),
|
|
24122
25174
|
resume_status: RunResumeStatus.optional(),
|
|
24123
|
-
created_at:
|
|
24124
|
-
updated_at:
|
|
24125
|
-
completed_at:
|
|
25175
|
+
created_at: Timestamp4,
|
|
25176
|
+
updated_at: Timestamp4,
|
|
25177
|
+
completed_at: Timestamp4.optional()
|
|
24126
25178
|
}).strict().superRefine((run, ctx) => {
|
|
24127
25179
|
requireTimestampOrder(run.created_at, run.updated_at, "updated_at", ctx);
|
|
24128
25180
|
if (run.completed_at !== void 0) {
|
|
@@ -24158,7 +25210,7 @@ var Run_v1 = z18.object({
|
|
|
24158
25210
|
});
|
|
24159
25211
|
}
|
|
24160
25212
|
});
|
|
24161
|
-
var AttemptStatus =
|
|
25213
|
+
var AttemptStatus = z20.enum([
|
|
24162
25214
|
"prepared",
|
|
24163
25215
|
"leased",
|
|
24164
25216
|
"launching",
|
|
@@ -24223,8 +25275,8 @@ function attemptStatusRequiresVerification(status) {
|
|
|
24223
25275
|
function isTerminalAttemptStatus(status) {
|
|
24224
25276
|
return TERMINAL_ATTEMPT_STATUSES.has(status);
|
|
24225
25277
|
}
|
|
24226
|
-
var Attempt_v1 =
|
|
24227
|
-
schema_version:
|
|
25278
|
+
var Attempt_v1 = z20.object({
|
|
25279
|
+
schema_version: z20.literal(AGENT_WORK_CONTRACT_VERSION),
|
|
24228
25280
|
attempt_id: Id,
|
|
24229
25281
|
revision: Revision,
|
|
24230
25282
|
run_id: Id,
|
|
@@ -24238,9 +25290,9 @@ var Attempt_v1 = z18.object({
|
|
|
24238
25290
|
receipt_id: Id.optional(),
|
|
24239
25291
|
verification_id: Id.optional(),
|
|
24240
25292
|
status: AttemptStatus,
|
|
24241
|
-
created_at:
|
|
24242
|
-
updated_at:
|
|
24243
|
-
completed_at:
|
|
25293
|
+
created_at: Timestamp4,
|
|
25294
|
+
updated_at: Timestamp4,
|
|
25295
|
+
completed_at: Timestamp4.optional()
|
|
24244
25296
|
}).strict().superRefine((attempt, ctx) => {
|
|
24245
25297
|
requireTimestampOrder(attempt.created_at, attempt.updated_at, "updated_at", ctx);
|
|
24246
25298
|
if (attempt.completed_at !== void 0) {
|
|
@@ -24283,7 +25335,7 @@ var Attempt_v1 = z18.object({
|
|
|
24283
25335
|
});
|
|
24284
25336
|
}
|
|
24285
25337
|
});
|
|
24286
|
-
var AttemptRetryDeltaDimension_v1 =
|
|
25338
|
+
var AttemptRetryDeltaDimension_v1 = z20.enum([
|
|
24287
25339
|
"evidence",
|
|
24288
25340
|
"premise",
|
|
24289
25341
|
"strategy",
|
|
@@ -24292,15 +25344,15 @@ var AttemptRetryDeltaDimension_v1 = z18.enum([
|
|
|
24292
25344
|
"authority",
|
|
24293
25345
|
"worker_runtime"
|
|
24294
25346
|
]);
|
|
24295
|
-
var AttemptRetryDeltaChange_v1 =
|
|
25347
|
+
var AttemptRetryDeltaChange_v1 = z20.object({
|
|
24296
25348
|
dimension: AttemptRetryDeltaDimension_v1,
|
|
24297
25349
|
before_hash: SHA256Hash,
|
|
24298
25350
|
after_hash: SHA256Hash
|
|
24299
25351
|
}).strict().refine((change) => change.before_hash !== change.after_hash, {
|
|
24300
25352
|
message: "A retry change must identify a different durable premise"
|
|
24301
25353
|
});
|
|
24302
|
-
var AttemptRetryEvidenceReference_v1 =
|
|
24303
|
-
kind:
|
|
25354
|
+
var AttemptRetryEvidenceReference_v1 = z20.object({
|
|
25355
|
+
kind: z20.enum([
|
|
24304
25356
|
"receipt",
|
|
24305
25357
|
"verification",
|
|
24306
25358
|
"fan_in_decision",
|
|
@@ -24311,20 +25363,20 @@ var AttemptRetryEvidenceReference_v1 = z18.object({
|
|
|
24311
25363
|
id: Id.max(256),
|
|
24312
25364
|
hash: SHA256Hash
|
|
24313
25365
|
}).strict();
|
|
24314
|
-
var AttemptRetryDelta_v1 =
|
|
24315
|
-
schema_version:
|
|
25366
|
+
var AttemptRetryDelta_v1 = z20.object({
|
|
25367
|
+
schema_version: z20.literal(AGENT_WORK_CONTRACT_VERSION),
|
|
24316
25368
|
previous_attempt_id: Id.max(256),
|
|
24317
25369
|
next_attempt_id: Id.max(256),
|
|
24318
25370
|
work_item_id: Id.max(256),
|
|
24319
25371
|
work_item_revision: Revision,
|
|
24320
|
-
changes:
|
|
24321
|
-
inherited_evidence:
|
|
24322
|
-
policy_exception:
|
|
25372
|
+
changes: z20.array(AttemptRetryDeltaChange_v1).max(16),
|
|
25373
|
+
inherited_evidence: z20.array(AttemptRetryEvidenceReference_v1).max(64),
|
|
25374
|
+
policy_exception: z20.object({
|
|
24323
25375
|
policy_id: Id.max(256),
|
|
24324
|
-
reason:
|
|
25376
|
+
reason: z20.string().min(1).max(1024)
|
|
24325
25377
|
}).strict().optional(),
|
|
24326
|
-
summary:
|
|
24327
|
-
created_at:
|
|
25378
|
+
summary: z20.string().min(1).max(1024),
|
|
25379
|
+
created_at: Timestamp4
|
|
24328
25380
|
}).strict().superRefine((delta, context) => {
|
|
24329
25381
|
if (delta.changes.length === 0 && !delta.policy_exception) {
|
|
24330
25382
|
context.addIssue({
|
|
@@ -24350,14 +25402,14 @@ var AttemptRetryDelta_v1 = z18.object({
|
|
|
24350
25402
|
});
|
|
24351
25403
|
}
|
|
24352
25404
|
});
|
|
24353
|
-
var FanoutRationale_v1 =
|
|
25405
|
+
var FanoutRationale_v1 = z20.enum([
|
|
24354
25406
|
"separable_work",
|
|
24355
25407
|
"hypothesis_diversity",
|
|
24356
25408
|
"independent_review",
|
|
24357
25409
|
"risk_reduction",
|
|
24358
25410
|
"best_of_n"
|
|
24359
25411
|
]);
|
|
24360
|
-
var FanoutSelectionCriterion_v1 =
|
|
25412
|
+
var FanoutSelectionCriterion_v1 = z20.enum([
|
|
24361
25413
|
"verification_outcome",
|
|
24362
25414
|
"trust_gap_count",
|
|
24363
25415
|
"verified_result_identity"
|
|
@@ -24367,30 +25419,30 @@ var STRICT_FANOUT_SELECTION_CRITERIA = [
|
|
|
24367
25419
|
"trust_gap_count",
|
|
24368
25420
|
"verified_result_identity"
|
|
24369
25421
|
];
|
|
24370
|
-
var FanoutPremise_v1 =
|
|
25422
|
+
var FanoutPremise_v1 = z20.object({
|
|
24371
25423
|
premise_id: Id.max(256),
|
|
24372
25424
|
attempt_id: Id.max(256),
|
|
24373
25425
|
strategy_hash: SHA256Hash,
|
|
24374
|
-
summary:
|
|
25426
|
+
summary: z20.string().min(1).max(1024)
|
|
24375
25427
|
}).strict();
|
|
24376
|
-
var AgentWorkFanoutPlan_v1 =
|
|
24377
|
-
schema_version:
|
|
25428
|
+
var AgentWorkFanoutPlan_v1 = z20.object({
|
|
25429
|
+
schema_version: z20.literal(AGENT_WORK_CONTRACT_VERSION),
|
|
24378
25430
|
fanout_id: Id.max(256),
|
|
24379
25431
|
run_id: Id.max(256),
|
|
24380
25432
|
work_item_id: Id.max(256),
|
|
24381
25433
|
work_item_revision: Revision,
|
|
24382
25434
|
rationale: FanoutRationale_v1,
|
|
24383
|
-
selection_criteria:
|
|
24384
|
-
budget:
|
|
24385
|
-
max_attempts:
|
|
24386
|
-
max_concurrency:
|
|
24387
|
-
max_elapsed_ms:
|
|
24388
|
-
max_context_bytes_per_attempt:
|
|
24389
|
-
max_judging_cost_units:
|
|
25435
|
+
selection_criteria: z20.array(FanoutSelectionCriterion_v1).length(3),
|
|
25436
|
+
budget: z20.object({
|
|
25437
|
+
max_attempts: z20.number().int().min(2).max(16),
|
|
25438
|
+
max_concurrency: z20.number().int().min(1).max(16),
|
|
25439
|
+
max_elapsed_ms: z20.number().int().positive().max(7 * 24 * 60 * 60 * 1e3),
|
|
25440
|
+
max_context_bytes_per_attempt: z20.number().int().positive().max(1024 * 1024),
|
|
25441
|
+
max_judging_cost_units: z20.number().int().nonnegative().max(1e6)
|
|
24390
25442
|
}).strict(),
|
|
24391
|
-
premises:
|
|
24392
|
-
direct_worker_communication:
|
|
24393
|
-
created_at:
|
|
25443
|
+
premises: z20.array(FanoutPremise_v1).min(2).max(16),
|
|
25444
|
+
direct_worker_communication: z20.enum(["forbidden", "brokered"]),
|
|
25445
|
+
created_at: Timestamp4
|
|
24394
25446
|
}).strict().superRefine((plan, context) => {
|
|
24395
25447
|
if (plan.premises.length > plan.budget.max_attempts) {
|
|
24396
25448
|
context.addIssue({
|
|
@@ -24439,22 +25491,22 @@ var AgentWorkFanoutPlan_v1 = z18.object({
|
|
|
24439
25491
|
(left, right) => compareCanonicalStrings(left.attempt_id, right.attempt_id)
|
|
24440
25492
|
)
|
|
24441
25493
|
}));
|
|
24442
|
-
var FanoutAttemptBinding_v1 =
|
|
24443
|
-
schema_version:
|
|
25494
|
+
var FanoutAttemptBinding_v1 = z20.object({
|
|
25495
|
+
schema_version: z20.literal(AGENT_WORK_CONTRACT_VERSION),
|
|
24444
25496
|
fanout_id: Id.max(256),
|
|
24445
25497
|
fanout_plan_hash: SHA256Hash,
|
|
24446
25498
|
premise_id: Id.max(256),
|
|
24447
25499
|
premise_hash: SHA256Hash,
|
|
24448
25500
|
attempt_id: Id.max(256)
|
|
24449
25501
|
}).strict();
|
|
24450
|
-
var FanInCandidateConclusion_v1 =
|
|
25502
|
+
var FanInCandidateConclusion_v1 = z20.enum([
|
|
24451
25503
|
"selected",
|
|
24452
25504
|
"equivalent",
|
|
24453
25505
|
"unselected",
|
|
24454
25506
|
"rejected",
|
|
24455
25507
|
"missing_evidence"
|
|
24456
25508
|
]);
|
|
24457
|
-
var FanInCandidateEvidence_v1 =
|
|
25509
|
+
var FanInCandidateEvidence_v1 = z20.object({
|
|
24458
25510
|
attempt_id: Id.max(256),
|
|
24459
25511
|
premise_id: Id.max(256),
|
|
24460
25512
|
attempt_status: AttemptStatus,
|
|
@@ -24462,12 +25514,12 @@ var FanInCandidateEvidence_v1 = z18.object({
|
|
|
24462
25514
|
receipt_hash: SHA256Hash.optional(),
|
|
24463
25515
|
verification_id: Id.max(256).optional(),
|
|
24464
25516
|
verification_hash: SHA256Hash.optional(),
|
|
24465
|
-
verification_outcome:
|
|
24466
|
-
verified_result_identity:
|
|
24467
|
-
trust_gap_count:
|
|
25517
|
+
verification_outcome: z20.enum(["pass", "fail", "inconclusive", "infrastructure_error", "cancelled"]).optional(),
|
|
25518
|
+
verified_result_identity: z20.union([CanonicalGitObjectId2, SHA256Hash]).optional(),
|
|
25519
|
+
trust_gap_count: z20.number().int().nonnegative().max(64),
|
|
24468
25520
|
conclusion: FanInCandidateConclusion_v1,
|
|
24469
|
-
reason_codes:
|
|
24470
|
-
artifact_refs:
|
|
25521
|
+
reason_codes: z20.array(Id.max(256)).max(16),
|
|
25522
|
+
artifact_refs: z20.array(Id.max(256)).max(64)
|
|
24471
25523
|
}).strict().superRefine((candidate, context) => {
|
|
24472
25524
|
if (candidate.receipt_id === void 0 !== (candidate.receipt_hash === void 0)) {
|
|
24473
25525
|
context.addIssue({
|
|
@@ -24492,25 +25544,25 @@ var FanInCandidateEvidence_v1 = z18.object({
|
|
|
24492
25544
|
requireUniqueStrings(candidate.reason_codes, "reason_codes", context);
|
|
24493
25545
|
requireUniqueStrings(candidate.artifact_refs, "artifact_refs", context);
|
|
24494
25546
|
});
|
|
24495
|
-
var AgentWorkFanInDecision_v1 =
|
|
24496
|
-
schema_version:
|
|
25547
|
+
var AgentWorkFanInDecision_v1 = z20.object({
|
|
25548
|
+
schema_version: z20.literal(AGENT_WORK_CONTRACT_VERSION),
|
|
24497
25549
|
decision_id: Id.max(256),
|
|
24498
25550
|
fanout_id: Id.max(256),
|
|
24499
25551
|
fanout_plan_hash: SHA256Hash,
|
|
24500
25552
|
run_id: Id.max(256),
|
|
24501
25553
|
work_item_id: Id.max(256),
|
|
24502
25554
|
work_item_revision: Revision,
|
|
24503
|
-
policy_id:
|
|
24504
|
-
policy_version:
|
|
24505
|
-
selection_criteria:
|
|
24506
|
-
decision:
|
|
25555
|
+
policy_id: z20.literal("lexrunner.engine-fanin.strict"),
|
|
25556
|
+
policy_version: z20.literal("1.0.0"),
|
|
25557
|
+
selection_criteria: z20.array(FanoutSelectionCriterion_v1).length(3),
|
|
25558
|
+
decision: z20.enum(["selected", "escalated", "no_viable_candidate"]),
|
|
24507
25559
|
selected_attempt_id: Id.max(256).optional(),
|
|
24508
|
-
candidates:
|
|
24509
|
-
conflicts:
|
|
24510
|
-
uncertainty:
|
|
25560
|
+
candidates: z20.array(FanInCandidateEvidence_v1).min(2).max(16),
|
|
25561
|
+
conflicts: z20.array(Id.max(256)).max(32),
|
|
25562
|
+
uncertainty: z20.array(z20.string().min(1).max(1024)).max(32),
|
|
24511
25563
|
evidence_set_hash: SHA256Hash,
|
|
24512
|
-
summary:
|
|
24513
|
-
created_at:
|
|
25564
|
+
summary: z20.string().min(1).max(2048),
|
|
25565
|
+
created_at: Timestamp4
|
|
24514
25566
|
}).strict().superRefine((decision, context) => {
|
|
24515
25567
|
if (decision.decision === "selected" !== (decision.selected_attempt_id !== void 0)) {
|
|
24516
25568
|
context.addIssue({
|
|
@@ -24564,11 +25616,11 @@ function computeFanInEvidenceSetHash(candidates) {
|
|
|
24564
25616
|
)
|
|
24565
25617
|
);
|
|
24566
25618
|
}
|
|
24567
|
-
var AgentTaskPacketBase =
|
|
24568
|
-
schema_version:
|
|
25619
|
+
var AgentTaskPacketBase = z20.object({
|
|
25620
|
+
schema_version: z20.literal(AGENT_WORK_CONTRACT_VERSION),
|
|
24569
25621
|
packet_id: Id,
|
|
24570
25622
|
run_id: Id,
|
|
24571
|
-
work_item:
|
|
25623
|
+
work_item: z20.object({
|
|
24572
25624
|
work_item_id: Id,
|
|
24573
25625
|
revision: Revision
|
|
24574
25626
|
}).strict(),
|
|
@@ -24576,17 +25628,17 @@ var AgentTaskPacketBase = z18.object({
|
|
|
24576
25628
|
repository: PortableRepository.extend({
|
|
24577
25629
|
base_sha: GitObjectId
|
|
24578
25630
|
}).strict(),
|
|
24579
|
-
objective:
|
|
24580
|
-
acceptance_criteria:
|
|
24581
|
-
instructions:
|
|
25631
|
+
objective: z20.string().min(1),
|
|
25632
|
+
acceptance_criteria: z20.array(AcceptanceCriterion),
|
|
25633
|
+
instructions: z20.array(z20.string()),
|
|
24582
25634
|
scope: PortableScope,
|
|
24583
25635
|
authority: AuthorityEnvelope,
|
|
24584
|
-
preparation:
|
|
24585
|
-
policy:
|
|
24586
|
-
network:
|
|
24587
|
-
registries:
|
|
24588
|
-
cache:
|
|
24589
|
-
lifecycle_scripts:
|
|
25636
|
+
preparation: z20.object({
|
|
25637
|
+
policy: z20.object({
|
|
25638
|
+
network: z20.enum(["forbidden", "registry_only"]),
|
|
25639
|
+
registries: z20.array(z20.string().url()).max(8),
|
|
25640
|
+
cache: z20.enum(["disabled", "read_only", "read_write"]),
|
|
25641
|
+
lifecycle_scripts: z20.enum(["forbidden", "allowed"])
|
|
24590
25642
|
}).strict().superRefine((policy, context) => {
|
|
24591
25643
|
if (policy.network === "forbidden" && policy.registries.length > 0) {
|
|
24592
25644
|
context.addIssue({
|
|
@@ -24604,14 +25656,14 @@ var AgentTaskPacketBase = z18.object({
|
|
|
24604
25656
|
}
|
|
24605
25657
|
requireUniqueStrings(policy.registries, "registries", context);
|
|
24606
25658
|
}),
|
|
24607
|
-
steps:
|
|
24608
|
-
|
|
25659
|
+
steps: z20.array(
|
|
25660
|
+
z20.object({
|
|
24609
25661
|
id: Id,
|
|
24610
|
-
kind:
|
|
24611
|
-
argv:
|
|
25662
|
+
kind: z20.enum(["provision", "build"]),
|
|
25663
|
+
argv: z20.array(z20.string()).min(1).max(128),
|
|
24612
25664
|
cwd_rel: AgentRepoRelativePath.optional(),
|
|
24613
|
-
depends_on:
|
|
24614
|
-
expected_exit_codes:
|
|
25665
|
+
depends_on: z20.array(Id).max(64),
|
|
25666
|
+
expected_exit_codes: z20.array(z20.number().int()).min(1).max(32)
|
|
24615
25667
|
}).strict().superRefine((step, context) => {
|
|
24616
25668
|
requireUniqueStrings(step.depends_on, "depends_on", context);
|
|
24617
25669
|
if (new Set(step.expected_exit_codes).size !== step.expected_exit_codes.length) {
|
|
@@ -24624,23 +25676,23 @@ var AgentTaskPacketBase = z18.object({
|
|
|
24624
25676
|
})
|
|
24625
25677
|
).min(1).max(64)
|
|
24626
25678
|
}).strict().optional(),
|
|
24627
|
-
verification:
|
|
24628
|
-
|
|
25679
|
+
verification: z20.array(
|
|
25680
|
+
z20.object({
|
|
24629
25681
|
id: Id,
|
|
24630
|
-
argv:
|
|
25682
|
+
argv: z20.array(z20.string()).min(1),
|
|
24631
25683
|
cwd_rel: AgentRepoRelativePath.optional(),
|
|
24632
|
-
depends_on:
|
|
24633
|
-
expected_exit_codes:
|
|
25684
|
+
depends_on: z20.array(Id).max(64).optional(),
|
|
25685
|
+
expected_exit_codes: z20.array(z20.number().int()).min(1)
|
|
24634
25686
|
}).strict().superRefine((step, context) => {
|
|
24635
25687
|
requireUniqueStrings(step.depends_on ?? [], "depends_on", context);
|
|
24636
25688
|
})
|
|
24637
25689
|
),
|
|
24638
|
-
budget:
|
|
24639
|
-
max_tokens:
|
|
24640
|
-
max_tool_calls:
|
|
24641
|
-
max_elapsed_ms:
|
|
25690
|
+
budget: z20.object({
|
|
25691
|
+
max_tokens: z20.number().int().positive().optional(),
|
|
25692
|
+
max_tool_calls: z20.number().int().positive().optional(),
|
|
25693
|
+
max_elapsed_ms: z20.number().int().positive().optional()
|
|
24642
25694
|
}).strict(),
|
|
24643
|
-
created_at:
|
|
25695
|
+
created_at: Timestamp4,
|
|
24644
25696
|
packet_hash: SHA256Hash
|
|
24645
25697
|
}).strict();
|
|
24646
25698
|
var AgentTaskPacketHashInput_v1 = AgentTaskPacketBase.omit({ packet_hash: true });
|
|
@@ -24736,8 +25788,8 @@ function validatePacketExecutionGraph(packet, context) {
|
|
|
24736
25788
|
});
|
|
24737
25789
|
}
|
|
24738
25790
|
}
|
|
24739
|
-
var AgentWorkPreparationReceipt_v1 =
|
|
24740
|
-
schema_version:
|
|
25791
|
+
var AgentWorkPreparationReceipt_v1 = z20.object({
|
|
25792
|
+
schema_version: z20.literal(AGENT_WORK_CONTRACT_VERSION),
|
|
24741
25793
|
receipt_id: Id,
|
|
24742
25794
|
run_id: Id,
|
|
24743
25795
|
attempt_id: Id,
|
|
@@ -24745,12 +25797,12 @@ var AgentWorkPreparationReceipt_v1 = z18.object({
|
|
|
24745
25797
|
packet_hash: SHA256Hash,
|
|
24746
25798
|
preparation_plan_hash: SHA256Hash,
|
|
24747
25799
|
policy_hash: SHA256Hash,
|
|
24748
|
-
outcome:
|
|
24749
|
-
steps:
|
|
24750
|
-
|
|
25800
|
+
outcome: z20.enum(["passed", "failed"]),
|
|
25801
|
+
steps: z20.array(
|
|
25802
|
+
z20.object({
|
|
24751
25803
|
id: Id,
|
|
24752
|
-
outcome:
|
|
24753
|
-
exit_code:
|
|
25804
|
+
outcome: z20.enum(["passed", "failed", "blocked"]),
|
|
25805
|
+
exit_code: z20.number().int().optional(),
|
|
24754
25806
|
stdout_hash: SHA256Hash.optional(),
|
|
24755
25807
|
stderr_hash: SHA256Hash.optional(),
|
|
24756
25808
|
policy_hash: SHA256Hash.optional()
|
|
@@ -24766,8 +25818,8 @@ var AgentWorkPreparationReceipt_v1 = z18.object({
|
|
|
24766
25818
|
}
|
|
24767
25819
|
})
|
|
24768
25820
|
).max(64),
|
|
24769
|
-
started_at:
|
|
24770
|
-
completed_at:
|
|
25821
|
+
started_at: Timestamp4,
|
|
25822
|
+
completed_at: Timestamp4,
|
|
24771
25823
|
receipt_hash: SHA256Hash
|
|
24772
25824
|
}).strict().superRefine((receipt, context) => {
|
|
24773
25825
|
requireTimestampOrder(receipt.started_at, receipt.completed_at, "completed_at", context);
|
|
@@ -24789,12 +25841,12 @@ var AgentWorkPreparationReceipt_v1 = z18.object({
|
|
|
24789
25841
|
});
|
|
24790
25842
|
}
|
|
24791
25843
|
});
|
|
24792
|
-
var AbsolutePath =
|
|
25844
|
+
var AbsolutePath = z20.string().min(1).refine(isMachineLocalAbsolutePath, {
|
|
24793
25845
|
message: "Must be an absolute machine-local path"
|
|
24794
25846
|
});
|
|
24795
|
-
var ExecutionEnvironmentOS =
|
|
24796
|
-
var ExecutionEnvelope_v1 =
|
|
24797
|
-
schema_version:
|
|
25847
|
+
var ExecutionEnvironmentOS = z20.enum(["linux", "windows", "darwin", "other"]);
|
|
25848
|
+
var ExecutionEnvelope_v1 = z20.object({
|
|
25849
|
+
schema_version: z20.literal(AGENT_WORK_CONTRACT_VERSION),
|
|
24798
25850
|
envelope_id: Id,
|
|
24799
25851
|
run_id: Id,
|
|
24800
25852
|
attempt_id: Id,
|
|
@@ -24804,15 +25856,15 @@ var ExecutionEnvelope_v1 = z18.object({
|
|
|
24804
25856
|
workspace_lease_revision: Revision,
|
|
24805
25857
|
expected_head_sha: GitObjectId,
|
|
24806
25858
|
/** Emitted by Stage 3 launch bundles; optional for pre-Stage-3 v1 envelopes. */
|
|
24807
|
-
branch:
|
|
24808
|
-
runtime:
|
|
25859
|
+
branch: z20.string().min(1).optional(),
|
|
25860
|
+
runtime: z20.object({
|
|
24809
25861
|
host_id: Id,
|
|
24810
25862
|
os: ExecutionEnvironmentOS,
|
|
24811
|
-
architecture:
|
|
24812
|
-
worker_runtime:
|
|
24813
|
-
git_runtime:
|
|
25863
|
+
architecture: z20.string().min(1),
|
|
25864
|
+
worker_runtime: z20.string().min(1),
|
|
25865
|
+
git_runtime: z20.string().min(1)
|
|
24814
25866
|
}).strict(),
|
|
24815
|
-
paths:
|
|
25867
|
+
paths: z20.object({
|
|
24816
25868
|
project_root: AbsolutePath,
|
|
24817
25869
|
execution_root: AbsolutePath,
|
|
24818
25870
|
/** Required on new envelopes; optional only so legacy v1 records can be read fail-closed. */
|
|
@@ -24823,27 +25875,27 @@ var ExecutionEnvelope_v1 = z18.object({
|
|
|
24823
25875
|
* New launch bindings require exactly one mapping. Empty legacy arrays remain
|
|
24824
25876
|
* structurally readable, but lifecycle evidence validation rejects them.
|
|
24825
25877
|
*/
|
|
24826
|
-
path_mappings:
|
|
24827
|
-
exposed_environment_keys:
|
|
24828
|
-
created_at:
|
|
25878
|
+
path_mappings: z20.array(AgentExecutionPathMapping_v1).max(1),
|
|
25879
|
+
exposed_environment_keys: z20.array(z20.string().min(1)),
|
|
25880
|
+
created_at: Timestamp4
|
|
24829
25881
|
}).strict();
|
|
24830
|
-
var ControllerLease_v1 =
|
|
24831
|
-
schema_version:
|
|
25882
|
+
var ControllerLease_v1 = z20.object({
|
|
25883
|
+
schema_version: z20.literal(AGENT_WORK_CONTRACT_VERSION),
|
|
24832
25884
|
lease_id: Id,
|
|
24833
25885
|
run_id: Id,
|
|
24834
25886
|
controller_id: Id,
|
|
24835
|
-
control_mode:
|
|
25887
|
+
control_mode: z20.enum(["assisted", "headless"]),
|
|
24836
25888
|
/** Monotonic token used to reject operations from superseded controllers. */
|
|
24837
|
-
fence:
|
|
25889
|
+
fence: z20.number().int().positive(),
|
|
24838
25890
|
revision: Revision,
|
|
24839
25891
|
run_revision: Revision,
|
|
24840
|
-
status:
|
|
24841
|
-
acquired_at:
|
|
24842
|
-
heartbeat_at:
|
|
24843
|
-
expires_at:
|
|
24844
|
-
released_at:
|
|
25892
|
+
status: z20.enum(["active", "released", "expired", "revoked"]),
|
|
25893
|
+
acquired_at: Timestamp4,
|
|
25894
|
+
heartbeat_at: Timestamp4,
|
|
25895
|
+
expires_at: Timestamp4,
|
|
25896
|
+
released_at: Timestamp4.optional()
|
|
24845
25897
|
}).strict();
|
|
24846
|
-
var WorkspaceLeaseStatus =
|
|
25898
|
+
var WorkspaceLeaseStatus = z20.enum([
|
|
24847
25899
|
"reserved",
|
|
24848
25900
|
"acquired",
|
|
24849
25901
|
"active",
|
|
@@ -24855,14 +25907,14 @@ var WorkspaceLeaseStatus = z18.enum([
|
|
|
24855
25907
|
"expired",
|
|
24856
25908
|
"abandoned"
|
|
24857
25909
|
]);
|
|
24858
|
-
var WorkspaceCleanupDisposition =
|
|
25910
|
+
var WorkspaceCleanupDisposition = z20.enum([
|
|
24859
25911
|
"integrated",
|
|
24860
25912
|
"preserved",
|
|
24861
25913
|
"abandoned",
|
|
24862
25914
|
"discarded"
|
|
24863
25915
|
]);
|
|
24864
|
-
var WorkspaceLease_v1 =
|
|
24865
|
-
schema_version:
|
|
25916
|
+
var WorkspaceLease_v1 = z20.object({
|
|
25917
|
+
schema_version: z20.literal(AGENT_WORK_CONTRACT_VERSION),
|
|
24866
25918
|
lease_id: Id,
|
|
24867
25919
|
revision: Revision,
|
|
24868
25920
|
run_id: Id,
|
|
@@ -24871,19 +25923,19 @@ var WorkspaceLease_v1 = z18.object({
|
|
|
24871
25923
|
work_item_revision: Revision,
|
|
24872
25924
|
attempt_id: Id,
|
|
24873
25925
|
controller_lease_id: Id,
|
|
24874
|
-
controller_fence:
|
|
25926
|
+
controller_fence: z20.number().int().positive(),
|
|
24875
25927
|
packet_id: Id,
|
|
24876
25928
|
packet_hash: SHA256Hash,
|
|
24877
25929
|
repository: PortableRepository,
|
|
24878
25930
|
base_sha: GitObjectId,
|
|
24879
|
-
branch:
|
|
25931
|
+
branch: z20.string().min(1),
|
|
24880
25932
|
scope: PortableScope,
|
|
24881
25933
|
authority: AuthorityEnvelope,
|
|
24882
25934
|
status: WorkspaceLeaseStatus,
|
|
24883
|
-
acquired_at:
|
|
24884
|
-
heartbeat_at:
|
|
24885
|
-
expires_at:
|
|
24886
|
-
released_at:
|
|
25935
|
+
acquired_at: Timestamp4,
|
|
25936
|
+
heartbeat_at: Timestamp4,
|
|
25937
|
+
expires_at: Timestamp4,
|
|
25938
|
+
released_at: Timestamp4.optional(),
|
|
24887
25939
|
cleanup_disposition: WorkspaceCleanupDisposition.optional()
|
|
24888
25940
|
}).strict().superRefine((lease, ctx) => {
|
|
24889
25941
|
requireTimestampOrder(lease.acquired_at, lease.heartbeat_at, "heartbeat_at", ctx);
|
|
@@ -24941,9 +25993,9 @@ var WorkspaceLease_v1 = z18.object({
|
|
|
24941
25993
|
});
|
|
24942
25994
|
}
|
|
24943
25995
|
});
|
|
24944
|
-
var WorkspaceAllocationStatus =
|
|
24945
|
-
var WorkspaceAllocation_v1 =
|
|
24946
|
-
schema_version:
|
|
25996
|
+
var WorkspaceAllocationStatus = z20.enum(["allocated", "active", "released", "quarantined"]);
|
|
25997
|
+
var WorkspaceAllocation_v1 = z20.object({
|
|
25998
|
+
schema_version: z20.literal(AGENT_WORK_CONTRACT_VERSION),
|
|
24947
25999
|
allocation_id: Id,
|
|
24948
26000
|
revision: Revision,
|
|
24949
26001
|
run_id: Id,
|
|
@@ -24951,30 +26003,30 @@ var WorkspaceAllocation_v1 = z18.object({
|
|
|
24951
26003
|
workspace_lease_id: Id,
|
|
24952
26004
|
repository: PortableRepository,
|
|
24953
26005
|
base_sha: GitObjectId,
|
|
24954
|
-
branch:
|
|
26006
|
+
branch: z20.string().min(1),
|
|
24955
26007
|
host_id: Id,
|
|
24956
|
-
git_runtime:
|
|
24957
|
-
paths:
|
|
26008
|
+
git_runtime: z20.string().min(1),
|
|
26009
|
+
paths: z20.object({
|
|
24958
26010
|
project_root: AbsolutePath,
|
|
24959
26011
|
worktree_root: AbsolutePath,
|
|
24960
26012
|
repository_git_common_dir: AbsolutePath,
|
|
24961
26013
|
worktree_git_dir: AbsolutePath
|
|
24962
26014
|
}).strict(),
|
|
24963
26015
|
status: WorkspaceAllocationStatus,
|
|
24964
|
-
observation:
|
|
24965
|
-
registration:
|
|
26016
|
+
observation: z20.object({
|
|
26017
|
+
registration: z20.enum([
|
|
24966
26018
|
"registered",
|
|
24967
26019
|
"missing",
|
|
24968
26020
|
"unregistered",
|
|
24969
26021
|
"wrong_repository",
|
|
24970
26022
|
"wrong_branch"
|
|
24971
26023
|
]),
|
|
24972
|
-
cleanliness:
|
|
24973
|
-
observed_branch:
|
|
26024
|
+
cleanliness: z20.enum(["clean", "dirty", "unknown"]),
|
|
26025
|
+
observed_branch: z20.string().min(1).optional(),
|
|
24974
26026
|
observed_head_sha: GitObjectId.optional(),
|
|
24975
|
-
observed_at:
|
|
26027
|
+
observed_at: Timestamp4
|
|
24976
26028
|
}).strict().optional(),
|
|
24977
|
-
quarantine_reason:
|
|
26029
|
+
quarantine_reason: z20.enum([
|
|
24978
26030
|
"dirty",
|
|
24979
26031
|
"missing",
|
|
24980
26032
|
"unregistered",
|
|
@@ -24984,11 +26036,11 @@ var WorkspaceAllocation_v1 = z18.object({
|
|
|
24984
26036
|
"expired",
|
|
24985
26037
|
"other"
|
|
24986
26038
|
]).optional(),
|
|
24987
|
-
quarantine_evidence:
|
|
24988
|
-
allocated_at:
|
|
24989
|
-
updated_at:
|
|
24990
|
-
released_at:
|
|
24991
|
-
quarantined_at:
|
|
26039
|
+
quarantine_evidence: z20.array(z20.string().min(1)).min(1).optional(),
|
|
26040
|
+
allocated_at: Timestamp4,
|
|
26041
|
+
updated_at: Timestamp4,
|
|
26042
|
+
released_at: Timestamp4.optional(),
|
|
26043
|
+
quarantined_at: Timestamp4.optional()
|
|
24992
26044
|
}).strict().superRefine((allocation, ctx) => {
|
|
24993
26045
|
requireTimestampOrder(allocation.allocated_at, allocation.updated_at, "updated_at", ctx);
|
|
24994
26046
|
if (allocation.observation !== void 0) {
|
|
@@ -25071,8 +26123,8 @@ var WorkspaceAllocation_v1 = z18.object({
|
|
|
25071
26123
|
requireTimestampOrder(allocation.quarantined_at, allocation.updated_at, "updated_at", ctx);
|
|
25072
26124
|
}
|
|
25073
26125
|
});
|
|
25074
|
-
var WorkerSessionBackend =
|
|
25075
|
-
var WorkerSessionStatus =
|
|
26126
|
+
var WorkerSessionBackend = z20.enum(["host-subagent", "codex-cli", "external"]);
|
|
26127
|
+
var WorkerSessionStatus = z20.enum([
|
|
25076
26128
|
"starting",
|
|
25077
26129
|
"running",
|
|
25078
26130
|
"awaiting_human",
|
|
@@ -25081,8 +26133,8 @@ var WorkerSessionStatus = z18.enum([
|
|
|
25081
26133
|
"cancelled",
|
|
25082
26134
|
"lost"
|
|
25083
26135
|
]);
|
|
25084
|
-
var WorkerSession_v1 =
|
|
25085
|
-
schema_version:
|
|
26136
|
+
var WorkerSession_v1 = z20.object({
|
|
26137
|
+
schema_version: z20.literal(AGENT_WORK_CONTRACT_VERSION),
|
|
25086
26138
|
session_id: Id,
|
|
25087
26139
|
run_id: Id,
|
|
25088
26140
|
attempt_id: Id,
|
|
@@ -25091,26 +26143,26 @@ var WorkerSession_v1 = z18.object({
|
|
|
25091
26143
|
workspace_lease_id: Id,
|
|
25092
26144
|
workspace_lease_revision: Revision,
|
|
25093
26145
|
execution_envelope_id: Id,
|
|
25094
|
-
worker:
|
|
26146
|
+
worker: z20.object({
|
|
25095
26147
|
backend: WorkerSessionBackend,
|
|
25096
26148
|
worker_id: Id,
|
|
25097
|
-
model:
|
|
26149
|
+
model: z20.string().min(1).optional()
|
|
25098
26150
|
}).strict(),
|
|
25099
26151
|
status: WorkerSessionStatus,
|
|
25100
|
-
started_at:
|
|
25101
|
-
heartbeat_at:
|
|
25102
|
-
ended_at:
|
|
26152
|
+
started_at: Timestamp4,
|
|
26153
|
+
heartbeat_at: Timestamp4,
|
|
26154
|
+
ended_at: Timestamp4.optional()
|
|
25103
26155
|
}).strict();
|
|
25104
|
-
var ClaimedCheckOutcome =
|
|
25105
|
-
var ClaimedCheck =
|
|
26156
|
+
var ClaimedCheckOutcome = z20.enum(["pass", "fail", "not_run"]);
|
|
26157
|
+
var ClaimedCheck = z20.object({
|
|
25106
26158
|
id: Id,
|
|
25107
26159
|
outcome: ClaimedCheckOutcome,
|
|
25108
|
-
exit_code:
|
|
25109
|
-
output_snippet:
|
|
26160
|
+
exit_code: z20.number().int().optional(),
|
|
26161
|
+
output_snippet: z20.string().optional()
|
|
25110
26162
|
}).strict();
|
|
25111
|
-
var AgentTaskReceiptOutcome =
|
|
25112
|
-
var AgentTaskReceipt_v1 =
|
|
25113
|
-
schema_version:
|
|
26163
|
+
var AgentTaskReceiptOutcome = z20.enum(["completed", "blocked", "failed", "cancelled"]);
|
|
26164
|
+
var AgentTaskReceipt_v1 = z20.object({
|
|
26165
|
+
schema_version: z20.literal(AGENT_WORK_CONTRACT_VERSION),
|
|
25114
26166
|
receipt_id: Id,
|
|
25115
26167
|
run_id: Id,
|
|
25116
26168
|
work_item_id: Id,
|
|
@@ -25123,21 +26175,21 @@ var AgentTaskReceipt_v1 = z18.object({
|
|
|
25123
26175
|
base_sha: GitObjectId,
|
|
25124
26176
|
final_head_sha: GitObjectId.optional(),
|
|
25125
26177
|
outcome: AgentTaskReceiptOutcome,
|
|
25126
|
-
summary:
|
|
25127
|
-
files_touched:
|
|
25128
|
-
commits:
|
|
25129
|
-
acceptance_criteria_addressed:
|
|
25130
|
-
claimed_checks:
|
|
25131
|
-
assumptions:
|
|
25132
|
-
blockers:
|
|
25133
|
-
human_action_request_ids:
|
|
25134
|
-
cost:
|
|
25135
|
-
input_tokens:
|
|
25136
|
-
output_tokens:
|
|
25137
|
-
tool_calls:
|
|
25138
|
-
elapsed_ms:
|
|
26178
|
+
summary: z20.string().min(1),
|
|
26179
|
+
files_touched: z20.array(RepoRelativePath),
|
|
26180
|
+
commits: z20.array(GitObjectId),
|
|
26181
|
+
acceptance_criteria_addressed: z20.array(Id),
|
|
26182
|
+
claimed_checks: z20.array(ClaimedCheck),
|
|
26183
|
+
assumptions: z20.array(z20.string()),
|
|
26184
|
+
blockers: z20.array(z20.string()),
|
|
26185
|
+
human_action_request_ids: z20.array(Id),
|
|
26186
|
+
cost: z20.object({
|
|
26187
|
+
input_tokens: z20.number().int().nonnegative().optional(),
|
|
26188
|
+
output_tokens: z20.number().int().nonnegative().optional(),
|
|
26189
|
+
tool_calls: z20.number().int().nonnegative().optional(),
|
|
26190
|
+
elapsed_ms: z20.number().int().nonnegative().optional()
|
|
25139
26191
|
}).strict(),
|
|
25140
|
-
submitted_at:
|
|
26192
|
+
submitted_at: Timestamp4
|
|
25141
26193
|
}).strict().superRefine((receipt, ctx) => {
|
|
25142
26194
|
if (receipt.outcome === "completed" && receipt.final_head_sha === void 0) {
|
|
25143
26195
|
ctx.addIssue({
|
|
@@ -25154,8 +26206,8 @@ var AgentTaskReceipt_v1 = z18.object({
|
|
|
25154
26206
|
});
|
|
25155
26207
|
}
|
|
25156
26208
|
});
|
|
25157
|
-
var AgentTaskReceipt_v2 =
|
|
25158
|
-
schema_version:
|
|
26209
|
+
var AgentTaskReceipt_v2 = z20.object({
|
|
26210
|
+
schema_version: z20.literal(AGENT_TASK_RECEIPT_V2_VERSION),
|
|
25159
26211
|
receipt_id: Id,
|
|
25160
26212
|
run_id: Id,
|
|
25161
26213
|
work_item_id: Id,
|
|
@@ -25179,19 +26231,19 @@ var AgentTaskReceipt_v2 = z18.object({
|
|
|
25179
26231
|
patch_hash: SHA256Hash.optional(),
|
|
25180
26232
|
outcome: AgentTaskReceiptOutcome,
|
|
25181
26233
|
exit_reason: Id,
|
|
25182
|
-
summary:
|
|
25183
|
-
files_touched:
|
|
25184
|
-
commits:
|
|
25185
|
-
acceptance_criteria_addressed:
|
|
25186
|
-
claimed_checks:
|
|
25187
|
-
assumptions:
|
|
25188
|
-
blockers:
|
|
25189
|
-
human_action_request_ids:
|
|
25190
|
-
cost:
|
|
25191
|
-
input_tokens:
|
|
25192
|
-
output_tokens:
|
|
25193
|
-
tool_calls:
|
|
25194
|
-
elapsed_ms:
|
|
26234
|
+
summary: z20.string().min(1),
|
|
26235
|
+
files_touched: z20.array(CanonicalAgentRepoPathV2),
|
|
26236
|
+
commits: z20.array(CanonicalGitObjectId2),
|
|
26237
|
+
acceptance_criteria_addressed: z20.array(Id),
|
|
26238
|
+
claimed_checks: z20.array(ClaimedCheck),
|
|
26239
|
+
assumptions: z20.array(z20.string()),
|
|
26240
|
+
blockers: z20.array(z20.string()),
|
|
26241
|
+
human_action_request_ids: z20.array(Id),
|
|
26242
|
+
cost: z20.object({
|
|
26243
|
+
input_tokens: z20.number().int().nonnegative().optional(),
|
|
26244
|
+
output_tokens: z20.number().int().nonnegative().optional(),
|
|
26245
|
+
tool_calls: z20.number().int().nonnegative().optional(),
|
|
26246
|
+
elapsed_ms: z20.number().int().nonnegative().optional()
|
|
25195
26247
|
}).strict(),
|
|
25196
26248
|
worker_started_at: ReceiptTimestampV2,
|
|
25197
26249
|
worker_completed_at: ReceiptTimestampV2,
|
|
@@ -25250,15 +26302,15 @@ function validateAgentTaskReceiptV2PacketReferences(packet, receipt) {
|
|
|
25250
26302
|
];
|
|
25251
26303
|
return { valid: errors.length === 0, errors };
|
|
25252
26304
|
}
|
|
25253
|
-
var VerificationOutcome =
|
|
26305
|
+
var VerificationOutcome = z20.enum([
|
|
25254
26306
|
"pass",
|
|
25255
26307
|
"fail",
|
|
25256
26308
|
"inconclusive",
|
|
25257
26309
|
"infrastructure_error",
|
|
25258
26310
|
"cancelled"
|
|
25259
26311
|
]);
|
|
25260
|
-
var AgentEngineVerification_v1 =
|
|
25261
|
-
schema_version:
|
|
26312
|
+
var AgentEngineVerification_v1 = z20.object({
|
|
26313
|
+
schema_version: z20.literal(AGENT_WORK_CONTRACT_VERSION),
|
|
25262
26314
|
verification_id: Id,
|
|
25263
26315
|
run_id: Id,
|
|
25264
26316
|
work_item_id: Id,
|
|
@@ -25273,55 +26325,55 @@ var AgentEngineVerification_v1 = z18.object({
|
|
|
25273
26325
|
base_sha: GitObjectId,
|
|
25274
26326
|
verified_head_sha: GitObjectId.optional(),
|
|
25275
26327
|
outcome: VerificationOutcome,
|
|
25276
|
-
summary:
|
|
25277
|
-
checks:
|
|
25278
|
-
|
|
26328
|
+
summary: z20.string().min(1),
|
|
26329
|
+
checks: z20.array(
|
|
26330
|
+
z20.object({
|
|
25279
26331
|
id: Id,
|
|
25280
26332
|
outcome: VerificationOutcome,
|
|
25281
|
-
exit_code:
|
|
25282
|
-
stdout_snippet:
|
|
25283
|
-
stderr_snippet:
|
|
25284
|
-
artifact_refs:
|
|
26333
|
+
exit_code: z20.number().int().optional(),
|
|
26334
|
+
stdout_snippet: z20.string().optional(),
|
|
26335
|
+
stderr_snippet: z20.string().optional(),
|
|
26336
|
+
artifact_refs: z20.array(z20.string())
|
|
25285
26337
|
}).strict()
|
|
25286
26338
|
),
|
|
25287
|
-
failures:
|
|
25288
|
-
trust_gap:
|
|
26339
|
+
failures: z20.array(z20.string()),
|
|
26340
|
+
trust_gap: z20.boolean(),
|
|
25289
26341
|
verifier_id: Id,
|
|
25290
|
-
started_at:
|
|
25291
|
-
completed_at:
|
|
26342
|
+
started_at: Timestamp4,
|
|
26343
|
+
completed_at: Timestamp4
|
|
25292
26344
|
}).strict();
|
|
25293
|
-
var EngineVerificationCheckSource_v2 =
|
|
25294
|
-
var EngineVerificationDeterminism_v2 =
|
|
26345
|
+
var EngineVerificationCheckSource_v2 = z20.enum(["packet", "engine_extra"]);
|
|
26346
|
+
var EngineVerificationDeterminism_v2 = z20.enum([
|
|
25295
26347
|
"deterministic",
|
|
25296
26348
|
"externally_nondeterministic",
|
|
25297
26349
|
"unknown"
|
|
25298
26350
|
]);
|
|
25299
|
-
var EngineVerificationTrustGapReason_v2 =
|
|
26351
|
+
var EngineVerificationTrustGapReason_v2 = z20.enum([
|
|
25300
26352
|
"worker_outcome_disagrees",
|
|
25301
26353
|
"head_identity_disagrees",
|
|
25302
26354
|
"patch_identity_disagrees",
|
|
25303
26355
|
"claimed_check_disagrees",
|
|
25304
26356
|
"authority_deviation"
|
|
25305
26357
|
]);
|
|
25306
|
-
var AgentEngineVerificationCheck_v2 =
|
|
26358
|
+
var AgentEngineVerificationCheck_v2 = z20.object({
|
|
25307
26359
|
id: Id,
|
|
25308
26360
|
source: EngineVerificationCheckSource_v2,
|
|
25309
26361
|
outcome: VerificationOutcome,
|
|
25310
26362
|
command_hash: SHA256Hash,
|
|
25311
26363
|
cwd_rel: CanonicalAgentRepoPathV2.optional(),
|
|
25312
26364
|
environment_fingerprint: SHA256Hash,
|
|
25313
|
-
exit_code:
|
|
26365
|
+
exit_code: z20.number().int().optional(),
|
|
25314
26366
|
stdout_hash: SHA256Hash.optional(),
|
|
25315
26367
|
stderr_hash: SHA256Hash.optional(),
|
|
25316
|
-
stdout_snippet:
|
|
25317
|
-
stderr_snippet:
|
|
25318
|
-
duration_ms:
|
|
25319
|
-
retry_count:
|
|
25320
|
-
artifact_refs:
|
|
26368
|
+
stdout_snippet: z20.string().max(4096).optional(),
|
|
26369
|
+
stderr_snippet: z20.string().max(4096).optional(),
|
|
26370
|
+
duration_ms: z20.number().int().nonnegative(),
|
|
26371
|
+
retry_count: z20.number().int().nonnegative(),
|
|
26372
|
+
artifact_refs: z20.array(z20.string().min(1).max(1024)).max(512),
|
|
25321
26373
|
determinism: EngineVerificationDeterminism_v2
|
|
25322
26374
|
}).strict();
|
|
25323
|
-
var AgentEngineVerification_v2 =
|
|
25324
|
-
schema_version:
|
|
26375
|
+
var AgentEngineVerification_v2 = z20.object({
|
|
26376
|
+
schema_version: z20.literal(AGENT_ENGINE_VERIFICATION_V2_VERSION),
|
|
25325
26377
|
verification_id: Id,
|
|
25326
26378
|
run_id: Id,
|
|
25327
26379
|
work_item_id: Id,
|
|
@@ -25340,10 +26392,10 @@ var AgentEngineVerification_v2 = z18.object({
|
|
|
25340
26392
|
verified_patch_hash: SHA256Hash.optional(),
|
|
25341
26393
|
workspace_observation_hash: SHA256Hash,
|
|
25342
26394
|
outcome: VerificationOutcome,
|
|
25343
|
-
summary:
|
|
25344
|
-
checks:
|
|
25345
|
-
failures:
|
|
25346
|
-
trust_gap_reasons:
|
|
26395
|
+
summary: z20.string().min(1).max(4096),
|
|
26396
|
+
checks: z20.array(AgentEngineVerificationCheck_v2).max(1024),
|
|
26397
|
+
failures: z20.array(z20.string().min(1).max(2048)).max(1024),
|
|
26398
|
+
trust_gap_reasons: z20.array(EngineVerificationTrustGapReason_v2).max(16),
|
|
25347
26399
|
verifier_id: Id,
|
|
25348
26400
|
verifier_version: Id,
|
|
25349
26401
|
started_at: ReceiptTimestampV2,
|
|
@@ -25489,19 +26541,19 @@ function mismatchErrors(values) {
|
|
|
25489
26541
|
([field, expectedValue, actualValue]) => `${field} mismatch: expected=${String(expectedValue)}, actual=${String(actualValue)}`
|
|
25490
26542
|
);
|
|
25491
26543
|
}
|
|
25492
|
-
var HumanActionPreconditions =
|
|
26544
|
+
var HumanActionPreconditions = z20.object({
|
|
25493
26545
|
run_revision: Revision,
|
|
25494
26546
|
workspace_lease_revision: Revision,
|
|
25495
26547
|
expected_head_sha: GitObjectId
|
|
25496
26548
|
}).strict();
|
|
25497
|
-
var HumanActionRequest_v1 =
|
|
25498
|
-
schema_version:
|
|
26549
|
+
var HumanActionRequest_v1 = z20.object({
|
|
26550
|
+
schema_version: z20.literal(AGENT_WORK_CONTRACT_VERSION),
|
|
25499
26551
|
request_id: Id,
|
|
25500
26552
|
run_id: Id,
|
|
25501
26553
|
attempt_id: Id,
|
|
25502
26554
|
workspace_lease_id: Id,
|
|
25503
26555
|
worker_session_id: Id,
|
|
25504
|
-
action:
|
|
26556
|
+
action: z20.enum([
|
|
25505
26557
|
"approve_scope",
|
|
25506
26558
|
"sign_commit",
|
|
25507
26559
|
"authenticate",
|
|
@@ -25509,15 +26561,15 @@ var HumanActionRequest_v1 = z18.object({
|
|
|
25509
26561
|
"approve_merge",
|
|
25510
26562
|
"other"
|
|
25511
26563
|
]),
|
|
25512
|
-
summary:
|
|
25513
|
-
instructions:
|
|
25514
|
-
suggested_commands:
|
|
26564
|
+
summary: z20.string().min(1),
|
|
26565
|
+
instructions: z20.array(z20.string()).min(1),
|
|
26566
|
+
suggested_commands: z20.array(z20.string()),
|
|
25515
26567
|
preconditions: HumanActionPreconditions,
|
|
25516
|
-
requested_at:
|
|
25517
|
-
expires_at:
|
|
26568
|
+
requested_at: Timestamp4,
|
|
26569
|
+
expires_at: Timestamp4.optional()
|
|
25518
26570
|
}).strict();
|
|
25519
|
-
var HumanActionReceipt_v1 =
|
|
25520
|
-
schema_version:
|
|
26571
|
+
var HumanActionReceipt_v1 = z20.object({
|
|
26572
|
+
schema_version: z20.literal(AGENT_WORK_CONTRACT_VERSION),
|
|
25521
26573
|
receipt_id: Id,
|
|
25522
26574
|
request_id: Id,
|
|
25523
26575
|
run_id: Id,
|
|
@@ -25525,11 +26577,11 @@ var HumanActionReceipt_v1 = z18.object({
|
|
|
25525
26577
|
workspace_lease_id: Id,
|
|
25526
26578
|
worker_session_id: Id,
|
|
25527
26579
|
observed_preconditions: HumanActionPreconditions,
|
|
25528
|
-
outcome:
|
|
26580
|
+
outcome: z20.enum(["completed", "declined", "expired", "failed"]),
|
|
25529
26581
|
actor_id: Id,
|
|
25530
|
-
summary:
|
|
26582
|
+
summary: z20.string().min(1),
|
|
25531
26583
|
resulting_head_sha: GitObjectId.optional(),
|
|
25532
|
-
completed_at:
|
|
26584
|
+
completed_at: Timestamp4
|
|
25533
26585
|
}).strict();
|
|
25534
26586
|
function validateHumanActionReceiptBinding(request, receipt) {
|
|
25535
26587
|
const expected = [
|
|
@@ -25606,125 +26658,125 @@ function parseHumanActionReceipt(data) {
|
|
|
25606
26658
|
}
|
|
25607
26659
|
|
|
25608
26660
|
// src/runs/types.ts
|
|
25609
|
-
import { z as
|
|
26661
|
+
import { z as z22 } from "zod";
|
|
25610
26662
|
|
|
25611
26663
|
// src/schemas/runCentric.ts
|
|
25612
|
-
import { z as
|
|
25613
|
-
var PersonaSnapshotSchema =
|
|
26664
|
+
import { z as z21 } from "zod";
|
|
26665
|
+
var PersonaSnapshotSchema = z21.object({
|
|
25614
26666
|
/** Persona mode identifier, e.g. "senior-dev", "reviewer", "security-auditor" */
|
|
25615
|
-
mode:
|
|
26667
|
+
mode: z21.string(),
|
|
25616
26668
|
/** Actions that are forbidden under this persona */
|
|
25617
|
-
forbidden:
|
|
26669
|
+
forbidden: z21.array(z21.string()),
|
|
25618
26670
|
/** Gates that must pass before completion */
|
|
25619
|
-
completionGates:
|
|
26671
|
+
completionGates: z21.array(z21.string()),
|
|
25620
26672
|
/** Decision-making style preferences */
|
|
25621
|
-
decisionStyle:
|
|
26673
|
+
decisionStyle: z21.object({
|
|
25622
26674
|
/** Prefer small, incremental diffs over large changes */
|
|
25623
|
-
preferSmallDiffs:
|
|
26675
|
+
preferSmallDiffs: z21.boolean().optional(),
|
|
25624
26676
|
/** Require explicit rationale when skipping steps */
|
|
25625
|
-
requireRationaleForSkips:
|
|
26677
|
+
requireRationaleForSkips: z21.boolean().optional(),
|
|
25626
26678
|
/** Escalate security findings to higher attention */
|
|
25627
|
-
escalateSecurityFindings:
|
|
26679
|
+
escalateSecurityFindings: z21.boolean().optional()
|
|
25628
26680
|
}).optional(),
|
|
25629
26681
|
/** Output formatting preferences */
|
|
25630
|
-
outputFormat:
|
|
26682
|
+
outputFormat: z21.object({
|
|
25631
26683
|
/** Severity levels for findings, e.g. ["critical", "high", "medium", "low"] */
|
|
25632
|
-
severityLevels:
|
|
26684
|
+
severityLevels: z21.array(z21.string()).optional(),
|
|
25633
26685
|
/** Whether findings must include a severity level */
|
|
25634
|
-
requireSeverityOnFindings:
|
|
26686
|
+
requireSeverityOnFindings: z21.boolean().optional()
|
|
25635
26687
|
}).optional()
|
|
25636
26688
|
});
|
|
25637
|
-
var NextOptionSchema =
|
|
26689
|
+
var NextOptionSchema = z21.object({
|
|
25638
26690
|
/** Action identifier, e.g. "merge_next", "abort_run", "resolve_conflict" */
|
|
25639
|
-
action:
|
|
26691
|
+
action: z21.string(),
|
|
25640
26692
|
/** Verb-first description, at most one sentence */
|
|
25641
|
-
description:
|
|
26693
|
+
description: z21.string(),
|
|
25642
26694
|
// Decision point fields
|
|
25643
26695
|
/** Whether this action requires an LLM decision */
|
|
25644
|
-
requiresLLMDecision:
|
|
26696
|
+
requiresLLMDecision: z21.boolean().optional(),
|
|
25645
26697
|
/** Prompt to present to the LLM for decision-making */
|
|
25646
|
-
prompt:
|
|
26698
|
+
prompt: z21.string().optional(),
|
|
25647
26699
|
/** JSON Schema describing the expected response format */
|
|
25648
|
-
responseSchema:
|
|
26700
|
+
responseSchema: z21.record(z21.string(), z21.unknown()).optional(),
|
|
25649
26701
|
// Guidance
|
|
25650
26702
|
/** The objective to achieve with this action */
|
|
25651
|
-
objective:
|
|
26703
|
+
objective: z21.string().optional(),
|
|
25652
26704
|
/** Constraints that must be respected */
|
|
25653
|
-
constraints:
|
|
26705
|
+
constraints: z21.array(z21.string()).optional(),
|
|
25654
26706
|
/** Output style preference */
|
|
25655
|
-
style:
|
|
26707
|
+
style: z21.enum(["brief", "detailed"]).optional(),
|
|
25656
26708
|
/** Risk level assessment for this action */
|
|
25657
|
-
riskLevel:
|
|
26709
|
+
riskLevel: z21.enum(["low", "medium", "high"]).optional()
|
|
25658
26710
|
});
|
|
25659
|
-
var StatusResponseSchema =
|
|
26711
|
+
var StatusResponseSchema = z21.object({
|
|
25660
26712
|
/** Unique run identifier */
|
|
25661
|
-
runId:
|
|
26713
|
+
runId: z21.string(),
|
|
25662
26714
|
// Core run identity
|
|
25663
26715
|
/** Current state, e.g. "planning", "gated", "executing", "completed", "failed" */
|
|
25664
|
-
state:
|
|
26716
|
+
state: z21.string(),
|
|
25665
26717
|
/** Persona mode, e.g. "senior-dev" */
|
|
25666
|
-
mode:
|
|
26718
|
+
mode: z21.string(),
|
|
25667
26719
|
/** Procedure identifier, e.g. "merge-weave-main" */
|
|
25668
|
-
procedure:
|
|
26720
|
+
procedure: z21.string(),
|
|
25669
26721
|
// Human-readable recap
|
|
25670
26722
|
/** Single sentence orientation summary */
|
|
25671
|
-
summary:
|
|
26723
|
+
summary: z21.string(),
|
|
25672
26724
|
// Progress tracking
|
|
25673
26725
|
/** Progress information with completed, current, and remaining steps */
|
|
25674
|
-
progress:
|
|
26726
|
+
progress: z21.object({
|
|
25675
26727
|
/** List of completed step identifiers */
|
|
25676
|
-
completed:
|
|
26728
|
+
completed: z21.array(z21.string()),
|
|
25677
26729
|
/** Current step identifier, or null if between steps */
|
|
25678
|
-
current:
|
|
26730
|
+
current: z21.string().nullable(),
|
|
25679
26731
|
/** List of remaining step identifiers */
|
|
25680
|
-
remaining:
|
|
26732
|
+
remaining: z21.array(z21.string())
|
|
25681
26733
|
}).optional(),
|
|
25682
26734
|
// Canonical action set
|
|
25683
26735
|
/** Available next actions - the ONLY source of allowed actions */
|
|
25684
|
-
nextOptions:
|
|
26736
|
+
nextOptions: z21.array(NextOptionSchema),
|
|
25685
26737
|
// Additional context
|
|
25686
26738
|
/** Additional context as key-value pairs */
|
|
25687
|
-
context:
|
|
26739
|
+
context: z21.record(z21.string(), z21.unknown()).optional(),
|
|
25688
26740
|
/** Risk flags for the current state */
|
|
25689
|
-
riskFlags:
|
|
26741
|
+
riskFlags: z21.array(z21.string()).optional(),
|
|
25690
26742
|
/** Blocking issues that prevent progress */
|
|
25691
|
-
blockers:
|
|
26743
|
+
blockers: z21.array(z21.string()).optional(),
|
|
25692
26744
|
// Persona snapshot
|
|
25693
26745
|
/** Snapshot of the active persona configuration */
|
|
25694
26746
|
persona: PersonaSnapshotSchema.optional()
|
|
25695
26747
|
});
|
|
25696
26748
|
|
|
25697
26749
|
// src/runs/types.ts
|
|
25698
|
-
var RunStateSchema =
|
|
26750
|
+
var RunStateSchema = z22.object({
|
|
25699
26751
|
/** Unique run identifier (ULID) */
|
|
25700
|
-
runId:
|
|
26752
|
+
runId: z22.string(),
|
|
25701
26753
|
/** Persona mode, e.g. "senior-dev", "eager-pm" */
|
|
25702
|
-
mode:
|
|
26754
|
+
mode: z22.string(),
|
|
25703
26755
|
/** Procedure being executed, e.g. "merge-weave-main", "pr-review" */
|
|
25704
|
-
procedure:
|
|
26756
|
+
procedure: z22.string(),
|
|
25705
26757
|
/** Repository identifier (owner/repo or path) */
|
|
25706
|
-
repo:
|
|
26758
|
+
repo: z22.string(),
|
|
25707
26759
|
/** Optional task description */
|
|
25708
|
-
task:
|
|
26760
|
+
task: z22.string().optional(),
|
|
25709
26761
|
// Lifecycle
|
|
25710
26762
|
/** Current state in procedure state machine */
|
|
25711
|
-
state:
|
|
26763
|
+
state: z22.string(),
|
|
25712
26764
|
/** ISO 8601 timestamp when run was created */
|
|
25713
|
-
createdAt:
|
|
26765
|
+
createdAt: z22.string(),
|
|
25714
26766
|
/** ISO 8601 timestamp when run was last updated */
|
|
25715
|
-
updatedAt:
|
|
26767
|
+
updatedAt: z22.string(),
|
|
25716
26768
|
/** ISO 8601 timestamp when run completed (if applicable) */
|
|
25717
|
-
completedAt:
|
|
26769
|
+
completedAt: z22.string().optional(),
|
|
25718
26770
|
// Progress
|
|
25719
26771
|
/** List of completed step identifiers */
|
|
25720
|
-
completedSteps:
|
|
26772
|
+
completedSteps: z22.array(z22.string()),
|
|
25721
26773
|
/** Current step identifier, or null if between steps */
|
|
25722
|
-
currentStep:
|
|
26774
|
+
currentStep: z22.string().nullable(),
|
|
25723
26775
|
// Context
|
|
25724
26776
|
/** Runtime parameters for the run */
|
|
25725
|
-
params:
|
|
26777
|
+
params: z22.record(z22.string(), z22.unknown()),
|
|
25726
26778
|
/** Additional metadata for the run */
|
|
25727
|
-
metadata:
|
|
26779
|
+
metadata: z22.record(z22.string(), z22.unknown()),
|
|
25728
26780
|
// Persona snapshot (frozen at run start)
|
|
25729
26781
|
/** Snapshot of the active persona configuration */
|
|
25730
26782
|
persona: PersonaSnapshotSchema.optional()
|
|
@@ -25732,20 +26784,20 @@ var RunStateSchema = z20.object({
|
|
|
25732
26784
|
function parseRunState(data) {
|
|
25733
26785
|
return RunStateSchema.parse(data);
|
|
25734
26786
|
}
|
|
25735
|
-
var StartRunInputSchema =
|
|
26787
|
+
var StartRunInputSchema = z22.object({
|
|
25736
26788
|
/** Persona mode, e.g. "senior-dev", "eager-pm" */
|
|
25737
|
-
mode:
|
|
26789
|
+
mode: z22.string(),
|
|
25738
26790
|
/** Procedure identifier, e.g. "merge-weave-main", "pr-review" */
|
|
25739
|
-
procedure:
|
|
26791
|
+
procedure: z22.string(),
|
|
25740
26792
|
/** Repository in "owner/repo" format */
|
|
25741
|
-
repo:
|
|
26793
|
+
repo: z22.string(),
|
|
25742
26794
|
/** Human-readable task description */
|
|
25743
|
-
task:
|
|
26795
|
+
task: z22.string().optional(),
|
|
25744
26796
|
/** Procedure-specific parameters */
|
|
25745
|
-
params:
|
|
26797
|
+
params: z22.record(z22.string(), z22.unknown()).optional()
|
|
25746
26798
|
});
|
|
25747
|
-
var GetStatusInputSchema =
|
|
25748
|
-
runId:
|
|
26799
|
+
var GetStatusInputSchema = z22.object({
|
|
26800
|
+
runId: z22.string()
|
|
25749
26801
|
});
|
|
25750
26802
|
var RunNotFoundError = class extends Error {
|
|
25751
26803
|
constructor(runId) {
|
|
@@ -26121,6 +27173,14 @@ function boundedControllerLease(lease) {
|
|
|
26121
27173
|
import path35 from "path";
|
|
26122
27174
|
import { realpath, stat } from "fs/promises";
|
|
26123
27175
|
|
|
27176
|
+
// src/workspaces/git-worktree-broker.ts
|
|
27177
|
+
function withBrokerBoundaryAuthority(options, authority2) {
|
|
27178
|
+
return {
|
|
27179
|
+
...options,
|
|
27180
|
+
boundaryAuthority: { ...authority2 }
|
|
27181
|
+
};
|
|
27182
|
+
}
|
|
27183
|
+
|
|
26124
27184
|
// src/runs/agent-work-path-mapping.ts
|
|
26125
27185
|
function createAttemptExecutionPathMapping(input) {
|
|
26126
27186
|
const identities = captureBoundIdentities(input);
|
|
@@ -26342,7 +27402,12 @@ async function assertCurrentWorkspace(runtime, lifecycle, input) {
|
|
|
26342
27402
|
attemptId: lifecycle.attempt.attemptId,
|
|
26343
27403
|
baseSha: lifecycle.attempt.baseSha
|
|
26344
27404
|
},
|
|
26345
|
-
input.attempt.broker
|
|
27405
|
+
withBrokerBoundaryAuthority(input.attempt.broker, {
|
|
27406
|
+
operationId: input.attempt.mutations.authorizeLaunch.mutationId,
|
|
27407
|
+
orchestrationLeaseId: lifecycle.workspace.leaseId,
|
|
27408
|
+
orchestrationLeaseRevision: lifecycle.workspace.revision,
|
|
27409
|
+
ownerId: lifecycle.controllerLease.controllerId
|
|
27410
|
+
})
|
|
26346
27411
|
);
|
|
26347
27412
|
if (!observation.ok) {
|
|
26348
27413
|
throw new Error(`Launch workspace observation failed: ${observation.reason}`);
|
|
@@ -26388,7 +27453,7 @@ function assertAuthorizedBinding(lifecycle, input, runtime, packet) {
|
|
|
26388
27453
|
|
|
26389
27454
|
// src/runs/agent-work-runtime.ts
|
|
26390
27455
|
import path37 from "path";
|
|
26391
|
-
import { z as
|
|
27456
|
+
import { z as z25 } from "zod";
|
|
26392
27457
|
|
|
26393
27458
|
// src/store/sqlite/workspace-lifecycle-store.ts
|
|
26394
27459
|
import { readFileSync as readFileSync27 } from "fs";
|
|
@@ -26506,8 +27571,8 @@ function credentialFailureReason(lease, credential2) {
|
|
|
26506
27571
|
}
|
|
26507
27572
|
|
|
26508
27573
|
// src/store/workspace-lifecycle-domains.ts
|
|
26509
|
-
import { z as
|
|
26510
|
-
var WorkspaceLifecycleLeaseStatus =
|
|
27574
|
+
import { z as z23 } from "zod";
|
|
27575
|
+
var WorkspaceLifecycleLeaseStatus = z23.enum([
|
|
26511
27576
|
"reserved",
|
|
26512
27577
|
"active",
|
|
26513
27578
|
"released",
|
|
@@ -26524,8 +27589,8 @@ var ReleaseWorkspaceDisposition = WorkspaceCleanupDisposition.extract([
|
|
|
26524
27589
|
"integrated",
|
|
26525
27590
|
"discarded"
|
|
26526
27591
|
]);
|
|
26527
|
-
var WorkspaceReconciliationAction =
|
|
26528
|
-
var WorkspaceLifecycleEventType =
|
|
27592
|
+
var WorkspaceReconciliationAction = z23.enum(["resume", "release", "preserve", "abandon"]);
|
|
27593
|
+
var WorkspaceLifecycleEventType = z23.enum([
|
|
26529
27594
|
"attempt_created",
|
|
26530
27595
|
"attempt_transitioned",
|
|
26531
27596
|
"workspace_acquired",
|
|
@@ -26534,23 +27599,23 @@ var WorkspaceLifecycleEventType = z21.enum([
|
|
|
26534
27599
|
"workspace_reconciled",
|
|
26535
27600
|
"workspace_quarantined"
|
|
26536
27601
|
]);
|
|
26537
|
-
var WorkerSessionEventType =
|
|
27602
|
+
var WorkerSessionEventType = z23.enum([
|
|
26538
27603
|
"worker_session_attached",
|
|
26539
27604
|
"worker_session_heartbeat",
|
|
26540
27605
|
"worker_session_ended"
|
|
26541
27606
|
]);
|
|
26542
|
-
var AttemptReceiptDisposition =
|
|
26543
|
-
var AttemptReceiptEventType =
|
|
27607
|
+
var AttemptReceiptDisposition = z23.enum(["verification_pending", "retained_late"]);
|
|
27608
|
+
var AttemptReceiptEventType = z23.enum([
|
|
26544
27609
|
"attempt_receipt_submitted",
|
|
26545
27610
|
"attempt_receipt_retained_late",
|
|
26546
27611
|
"attempt_receipt_replayed"
|
|
26547
27612
|
]);
|
|
26548
|
-
var AttemptVerificationEventType =
|
|
27613
|
+
var AttemptVerificationEventType = z23.enum([
|
|
26549
27614
|
"attempt_verification_started",
|
|
26550
27615
|
"attempt_verification_recorded",
|
|
26551
27616
|
"attempt_verification_replayed"
|
|
26552
27617
|
]);
|
|
26553
|
-
var WorkerAuthorityDimension =
|
|
27618
|
+
var WorkerAuthorityDimension = z23.enum([
|
|
26554
27619
|
"edit",
|
|
26555
27620
|
"git_write",
|
|
26556
27621
|
"github_write",
|
|
@@ -26559,15 +27624,15 @@ var WorkerAuthorityDimension = z21.enum([
|
|
|
26559
27624
|
"signing",
|
|
26560
27625
|
"release"
|
|
26561
27626
|
]);
|
|
26562
|
-
var WorkerAuthorityDecision =
|
|
26563
|
-
var WorkerAuthorityEnforcement =
|
|
26564
|
-
var WorkerAuthorityReason =
|
|
27627
|
+
var WorkerAuthorityDecision = z23.enum(["allowed", "denied", "deviation"]);
|
|
27628
|
+
var WorkerAuthorityEnforcement = z23.enum(["enforced", "brokered", "unenforced"]);
|
|
27629
|
+
var WorkerAuthorityReason = z23.enum([
|
|
26565
27630
|
"packet_granted",
|
|
26566
27631
|
"packet_denied",
|
|
26567
27632
|
"backend_unenforceable",
|
|
26568
27633
|
"observed_after_execution"
|
|
26569
27634
|
]);
|
|
26570
|
-
var WorkspaceMutationFailureReason =
|
|
27635
|
+
var WorkspaceMutationFailureReason = z23.enum([
|
|
26571
27636
|
"not_found",
|
|
26572
27637
|
"no_active_lease",
|
|
26573
27638
|
"lease_mismatch",
|
|
@@ -26593,38 +27658,38 @@ var WorkspaceMutationFailureReason = z21.enum([
|
|
|
26593
27658
|
"retry_delta_invalid",
|
|
26594
27659
|
"fanout_invalid"
|
|
26595
27660
|
]);
|
|
26596
|
-
var WorkerSessionMutationFailureReason =
|
|
27661
|
+
var WorkerSessionMutationFailureReason = z23.enum([
|
|
26597
27662
|
...WorkspaceMutationFailureReason.options,
|
|
26598
27663
|
"stale_session_revision",
|
|
26599
27664
|
"worker_session_not_active",
|
|
26600
27665
|
"worker_session_conflict"
|
|
26601
27666
|
]);
|
|
26602
|
-
var AttemptReceiptFailureReason =
|
|
27667
|
+
var AttemptReceiptFailureReason = z23.enum([
|
|
26603
27668
|
...WorkspaceMutationFailureReason.options,
|
|
26604
27669
|
"stale_session_revision",
|
|
26605
27670
|
"worker_session_not_active",
|
|
26606
27671
|
"receipt_conflict"
|
|
26607
27672
|
]);
|
|
26608
|
-
var AttemptVerificationFailureReason =
|
|
27673
|
+
var AttemptVerificationFailureReason = z23.enum([
|
|
26609
27674
|
...WorkspaceMutationFailureReason.options,
|
|
26610
27675
|
"stale_session_revision",
|
|
26611
27676
|
"verification_conflict"
|
|
26612
27677
|
]);
|
|
26613
|
-
var WorkspaceObservationCleanliness =
|
|
26614
|
-
var WorkspaceObservation =
|
|
26615
|
-
exists:
|
|
26616
|
-
registered:
|
|
26617
|
-
repositoryId:
|
|
26618
|
-
hostId:
|
|
26619
|
-
gitRuntime:
|
|
26620
|
-
projectRoot:
|
|
26621
|
-
branch:
|
|
26622
|
-
worktreePath:
|
|
26623
|
-
attemptId:
|
|
26624
|
-
headSha:
|
|
27678
|
+
var WorkspaceObservationCleanliness = z23.enum(["clean", "dirty"]);
|
|
27679
|
+
var WorkspaceObservation = z23.object({
|
|
27680
|
+
exists: z23.boolean(),
|
|
27681
|
+
registered: z23.boolean(),
|
|
27682
|
+
repositoryId: z23.string().nullable(),
|
|
27683
|
+
hostId: z23.string(),
|
|
27684
|
+
gitRuntime: z23.string(),
|
|
27685
|
+
projectRoot: z23.string().nullable(),
|
|
27686
|
+
branch: z23.string().nullable(),
|
|
27687
|
+
worktreePath: z23.string(),
|
|
27688
|
+
attemptId: z23.string().nullable(),
|
|
27689
|
+
headSha: z23.string().nullable(),
|
|
26625
27690
|
cleanliness: WorkspaceObservationCleanliness,
|
|
26626
|
-
dirtyPaths:
|
|
26627
|
-
reason:
|
|
27691
|
+
dirtyPaths: z23.array(z23.string()).optional(),
|
|
27692
|
+
reason: z23.string().optional()
|
|
26628
27693
|
}).strict();
|
|
26629
27694
|
var ATTEMPT_TRANSITIONS = {
|
|
26630
27695
|
prepared: ["cancelled"],
|
|
@@ -30682,7 +31747,15 @@ var WorkspaceCoordinator = class {
|
|
|
30682
31747
|
return reconciliation("reserve", current);
|
|
30683
31748
|
}
|
|
30684
31749
|
const target = targetFrom(current.lease);
|
|
30685
|
-
const created = await this.create(
|
|
31750
|
+
const created = await this.create(
|
|
31751
|
+
target,
|
|
31752
|
+
boundaryBrokerOptions(
|
|
31753
|
+
input.broker,
|
|
31754
|
+
current.lease,
|
|
31755
|
+
input.mutations.reserve.mutationId,
|
|
31756
|
+
input.controller.controllerId
|
|
31757
|
+
)
|
|
31758
|
+
);
|
|
30686
31759
|
if (!created.ok) {
|
|
30687
31760
|
return this.quarantineAfterFailure(
|
|
30688
31761
|
input,
|
|
@@ -30742,7 +31815,15 @@ var WorkspaceCoordinator = class {
|
|
|
30742
31815
|
const records = await this.readExpected(input, false, true);
|
|
30743
31816
|
if (!records.ok) return records.failure;
|
|
30744
31817
|
const target = targetFrom(records.lease);
|
|
30745
|
-
const observed = await this.observe(
|
|
31818
|
+
const observed = await this.observe(
|
|
31819
|
+
target,
|
|
31820
|
+
boundaryBrokerOptions(
|
|
31821
|
+
input.broker,
|
|
31822
|
+
records.lease,
|
|
31823
|
+
input.mutations.heartbeat.mutationId,
|
|
31824
|
+
input.controller.controllerId
|
|
31825
|
+
)
|
|
31826
|
+
);
|
|
30746
31827
|
if (!observed.ok) {
|
|
30747
31828
|
if (records.replayCandidate) {
|
|
30748
31829
|
return {
|
|
@@ -30800,7 +31881,15 @@ var WorkspaceCoordinator = class {
|
|
|
30800
31881
|
const records = await this.readExpected(input, true, true);
|
|
30801
31882
|
if (!records.ok) return records.failure;
|
|
30802
31883
|
const target = targetFrom(records.lease);
|
|
30803
|
-
const observed = await this.observe(
|
|
31884
|
+
const observed = await this.observe(
|
|
31885
|
+
target,
|
|
31886
|
+
boundaryBrokerOptions(
|
|
31887
|
+
input.broker,
|
|
31888
|
+
records.lease,
|
|
31889
|
+
input.mutation.mutationId,
|
|
31890
|
+
input.controller.controllerId
|
|
31891
|
+
)
|
|
31892
|
+
);
|
|
30804
31893
|
const observation = observed.ok ? observed.observation : observed.observation ?? syntheticObservation(target, observed);
|
|
30805
31894
|
const safeResume = observed.ok && ownedObservation(records.lease, observation) && observation.cleanliness === "clean";
|
|
30806
31895
|
if (!safeResume && records.replayCandidate) {
|
|
@@ -30921,7 +32010,15 @@ var WorkspaceCoordinator = class {
|
|
|
30921
32010
|
return reconciliation("release_prepare", current);
|
|
30922
32011
|
}
|
|
30923
32012
|
}
|
|
30924
|
-
const observed = await this.observe(
|
|
32013
|
+
const observed = await this.observe(
|
|
32014
|
+
target,
|
|
32015
|
+
boundaryBrokerOptions(
|
|
32016
|
+
input.broker,
|
|
32017
|
+
current.lease,
|
|
32018
|
+
input.mutations.prepare.mutationId,
|
|
32019
|
+
input.controller.controllerId
|
|
32020
|
+
)
|
|
32021
|
+
);
|
|
30925
32022
|
if (!observed.ok) {
|
|
30926
32023
|
return this.quarantineAfterFailure(
|
|
30927
32024
|
input,
|
|
@@ -30967,7 +32064,15 @@ var WorkspaceCoordinator = class {
|
|
|
30967
32064
|
const preparedAttempt = preparedRevisions ? current.attempt : prepared.attempt;
|
|
30968
32065
|
const preparedLease = preparedRevisions ? current.lease : prepared.workspaceLease;
|
|
30969
32066
|
const releaseEvidence = preparedRevisions ? current.lease.lastObservation ?? observed.observation : observed.observation;
|
|
30970
|
-
const removed = await this.remove(
|
|
32067
|
+
const removed = await this.remove(
|
|
32068
|
+
target,
|
|
32069
|
+
boundaryBrokerOptions(
|
|
32070
|
+
input.broker,
|
|
32071
|
+
preparedLease,
|
|
32072
|
+
input.mutations.finalize.mutationId,
|
|
32073
|
+
input.controller.controllerId
|
|
32074
|
+
)
|
|
32075
|
+
);
|
|
30971
32076
|
if (!removed.ok || removed.outcome === "preserved") {
|
|
30972
32077
|
const failure2 = removed.ok ? void 0 : removed;
|
|
30973
32078
|
const observation = removed.ok ? removed.observation : removed.observation ?? syntheticObservation(target, removed);
|
|
@@ -31152,6 +32257,14 @@ function targetFrom(lease) {
|
|
|
31152
32257
|
baseSha: lease.baseSha
|
|
31153
32258
|
};
|
|
31154
32259
|
}
|
|
32260
|
+
function boundaryBrokerOptions(options, lease, operationId, ownerId) {
|
|
32261
|
+
return withBrokerBoundaryAuthority(options, {
|
|
32262
|
+
operationId,
|
|
32263
|
+
orchestrationLeaseId: lease.leaseId,
|
|
32264
|
+
orchestrationLeaseRevision: lease.revision,
|
|
32265
|
+
ownerId
|
|
32266
|
+
});
|
|
32267
|
+
}
|
|
31155
32268
|
function boundPair(attempt, lease) {
|
|
31156
32269
|
return attempt.attemptId === lease.attemptId && attempt.workspaceLeaseId === lease.leaseId;
|
|
31157
32270
|
}
|
|
@@ -31350,16 +32463,24 @@ var AgentWorkWorkerSessionService = class {
|
|
|
31350
32463
|
envelope.paths.project_root,
|
|
31351
32464
|
"execution_root"
|
|
31352
32465
|
);
|
|
31353
|
-
const observation = await this.runtime.observeWorkspace(
|
|
31354
|
-
|
|
31355
|
-
|
|
31356
|
-
|
|
31357
|
-
|
|
31358
|
-
|
|
31359
|
-
|
|
31360
|
-
|
|
31361
|
-
|
|
31362
|
-
|
|
32466
|
+
const observation = await this.runtime.observeWorkspace(
|
|
32467
|
+
{
|
|
32468
|
+
repositoryId: lease.repositoryId,
|
|
32469
|
+
hostId: lease.hostId,
|
|
32470
|
+
gitRuntime: lease.gitRuntime,
|
|
32471
|
+
projectRoot: lease.projectRoot,
|
|
32472
|
+
branch: lease.branch,
|
|
32473
|
+
worktreePath: lease.worktreePath,
|
|
32474
|
+
attemptId: attempt.attemptId,
|
|
32475
|
+
baseSha: attempt.baseSha
|
|
32476
|
+
},
|
|
32477
|
+
withBrokerBoundaryAuthority(void 0, {
|
|
32478
|
+
operationId: input.mutationId,
|
|
32479
|
+
orchestrationLeaseId: lease.leaseId,
|
|
32480
|
+
orchestrationLeaseRevision: lease.revision,
|
|
32481
|
+
ownerId: input.controller.controllerId
|
|
32482
|
+
})
|
|
32483
|
+
);
|
|
31363
32484
|
if (!observation.ok || !observation.observation.exists || !observation.observation.registered || observation.observation.attemptId !== attempt.attemptId || observation.observation.headSha !== attempt.baseSha || observation.observation.cleanliness !== "clean") {
|
|
31364
32485
|
return failure("evidence_mismatch", attempt.revision, lease.revision);
|
|
31365
32486
|
}
|
|
@@ -31498,9 +32619,9 @@ function failure(reason, attemptRevision, workspaceRevision) {
|
|
|
31498
32619
|
}
|
|
31499
32620
|
|
|
31500
32621
|
// src/runs/agent-work-worker-runtime.ts
|
|
31501
|
-
import { z as
|
|
32622
|
+
import { z as z24 } from "zod";
|
|
31502
32623
|
var WORKER_ADAPTER_CONTRACT_VERSION = "1.0.0";
|
|
31503
|
-
var WorkerAdapterAuthorityDimension =
|
|
32624
|
+
var WorkerAdapterAuthorityDimension = z24.enum([
|
|
31504
32625
|
"filesystem_read",
|
|
31505
32626
|
"filesystem_write",
|
|
31506
32627
|
"git_write",
|
|
@@ -31512,14 +32633,14 @@ var WorkerAdapterAuthorityDimension = z22.enum([
|
|
|
31512
32633
|
"release",
|
|
31513
32634
|
"nested_delegation"
|
|
31514
32635
|
]);
|
|
31515
|
-
var WorkerAdapterEnforcement =
|
|
32636
|
+
var WorkerAdapterEnforcement = z24.enum([
|
|
31516
32637
|
"enforced",
|
|
31517
32638
|
"brokered",
|
|
31518
32639
|
"unenforced",
|
|
31519
32640
|
"unsupported"
|
|
31520
32641
|
]);
|
|
31521
|
-
var boundedText =
|
|
31522
|
-
var authorityMatrix =
|
|
32642
|
+
var boundedText = z24.string().min(1).max(256);
|
|
32643
|
+
var authorityMatrix = z24.object(
|
|
31523
32644
|
Object.fromEntries(
|
|
31524
32645
|
WorkerAdapterAuthorityDimension.options.map((dimension) => [
|
|
31525
32646
|
dimension,
|
|
@@ -31527,40 +32648,40 @@ var authorityMatrix = z22.object(
|
|
|
31527
32648
|
])
|
|
31528
32649
|
)
|
|
31529
32650
|
);
|
|
31530
|
-
var WorkerAdapterManifest_v1 =
|
|
31531
|
-
schema_version:
|
|
31532
|
-
adapter:
|
|
32651
|
+
var WorkerAdapterManifest_v1 = z24.object({
|
|
32652
|
+
schema_version: z24.literal(WORKER_ADAPTER_CONTRACT_VERSION),
|
|
32653
|
+
adapter: z24.object({
|
|
31533
32654
|
id: boundedText,
|
|
31534
32655
|
version: boundedText,
|
|
31535
|
-
kind:
|
|
32656
|
+
kind: z24.enum(["assisted", "subprocess", "remote"]),
|
|
31536
32657
|
session_backend: WorkerSessionBackend
|
|
31537
32658
|
}).strict(),
|
|
31538
|
-
lifecycle:
|
|
31539
|
-
prepare:
|
|
31540
|
-
launch:
|
|
31541
|
-
assisted_attach:
|
|
31542
|
-
heartbeat:
|
|
31543
|
-
cancellation:
|
|
31544
|
-
teardown:
|
|
31545
|
-
artifact_collection:
|
|
31546
|
-
receipt_collection:
|
|
32659
|
+
lifecycle: z24.object({
|
|
32660
|
+
prepare: z24.boolean(),
|
|
32661
|
+
launch: z24.boolean(),
|
|
32662
|
+
assisted_attach: z24.boolean(),
|
|
32663
|
+
heartbeat: z24.boolean(),
|
|
32664
|
+
cancellation: z24.boolean(),
|
|
32665
|
+
teardown: z24.boolean(),
|
|
32666
|
+
artifact_collection: z24.boolean(),
|
|
32667
|
+
receipt_collection: z24.boolean()
|
|
31547
32668
|
}).strict(),
|
|
31548
32669
|
authority: authorityMatrix.strict(),
|
|
31549
|
-
signals:
|
|
31550
|
-
structured:
|
|
31551
|
-
max_bytes:
|
|
32670
|
+
signals: z24.object({
|
|
32671
|
+
structured: z24.boolean(),
|
|
32672
|
+
max_bytes: z24.number().int().positive().max(1024 * 1024)
|
|
31552
32673
|
}).strict(),
|
|
31553
|
-
reproducibility:
|
|
32674
|
+
reproducibility: z24.object({
|
|
31554
32675
|
backend_identity: boundedText,
|
|
31555
32676
|
backend_version: boundedText
|
|
31556
32677
|
}).strict()
|
|
31557
32678
|
}).strict();
|
|
31558
|
-
var WorkerAdapterSelection_v1 =
|
|
31559
|
-
schema_version:
|
|
32679
|
+
var WorkerAdapterSelection_v1 = z24.object({
|
|
32680
|
+
schema_version: z24.literal(WORKER_ADAPTER_CONTRACT_VERSION),
|
|
31560
32681
|
adapter_id: boundedText,
|
|
31561
32682
|
adapter_version: boundedText,
|
|
31562
|
-
mode:
|
|
31563
|
-
accepted_trust_gaps:
|
|
32683
|
+
mode: z24.enum(["launch", "assisted_attach"]),
|
|
32684
|
+
accepted_trust_gaps: z24.array(WorkerAdapterAuthorityDimension).max(16)
|
|
31564
32685
|
}).strict().superRefine((value, context) => {
|
|
31565
32686
|
if (new Set(value.accepted_trust_gaps).size !== value.accepted_trust_gaps.length) {
|
|
31566
32687
|
context.addIssue({
|
|
@@ -31571,52 +32692,52 @@ var WorkerAdapterSelection_v1 = z22.object({
|
|
|
31571
32692
|
}
|
|
31572
32693
|
});
|
|
31573
32694
|
var workerSignalBase = {
|
|
31574
|
-
summary:
|
|
31575
|
-
at:
|
|
32695
|
+
summary: z24.string().min(1).max(4096),
|
|
32696
|
+
at: z24.string().datetime({ offset: true })
|
|
31576
32697
|
};
|
|
31577
|
-
var WorkerRuntimeSignalSchema =
|
|
31578
|
-
|
|
31579
|
-
type:
|
|
32698
|
+
var WorkerRuntimeSignalSchema = z24.discriminatedUnion("type", [
|
|
32699
|
+
z24.object({
|
|
32700
|
+
type: z24.enum(["heartbeat", "progress", "completed", "failed"]),
|
|
31580
32701
|
...workerSignalBase
|
|
31581
32702
|
}).strict(),
|
|
31582
|
-
|
|
31583
|
-
type:
|
|
32703
|
+
z24.object({
|
|
32704
|
+
type: z24.literal("blocked"),
|
|
31584
32705
|
...workerSignalBase,
|
|
31585
|
-
blocker:
|
|
32706
|
+
blocker: z24.object({
|
|
31586
32707
|
code: boundedText,
|
|
31587
|
-
retryable:
|
|
32708
|
+
retryable: z24.boolean()
|
|
31588
32709
|
}).strict()
|
|
31589
32710
|
}).strict(),
|
|
31590
|
-
|
|
31591
|
-
type:
|
|
32711
|
+
z24.object({
|
|
32712
|
+
type: z24.literal("dependency_discovered"),
|
|
31592
32713
|
...workerSignalBase,
|
|
31593
|
-
dependency:
|
|
32714
|
+
dependency: z24.object({
|
|
31594
32715
|
work_item_id: boundedText,
|
|
31595
|
-
relationship:
|
|
31596
|
-
evidence_hash:
|
|
32716
|
+
relationship: z24.enum(["blocks", "blocked_by", "related"]),
|
|
32717
|
+
evidence_hash: z24.string().regex(/^sha256:[0-9a-f]{64}$/u)
|
|
31597
32718
|
}).strict()
|
|
31598
32719
|
}).strict(),
|
|
31599
|
-
|
|
31600
|
-
type:
|
|
32720
|
+
z24.object({
|
|
32721
|
+
type: z24.literal("evidence_discovered"),
|
|
31601
32722
|
...workerSignalBase,
|
|
31602
|
-
evidence:
|
|
31603
|
-
kind:
|
|
32723
|
+
evidence: z24.object({
|
|
32724
|
+
kind: z24.enum(["artifact", "observation", "decision", "eliminated_hypothesis"]),
|
|
31604
32725
|
id: boundedText,
|
|
31605
|
-
hash:
|
|
32726
|
+
hash: z24.string().regex(/^sha256:[0-9a-f]{64}$/u)
|
|
31606
32727
|
}).strict()
|
|
31607
32728
|
}).strict(),
|
|
31608
|
-
|
|
31609
|
-
type:
|
|
32729
|
+
z24.object({
|
|
32730
|
+
type: z24.literal("human_action_requested"),
|
|
31610
32731
|
...workerSignalBase,
|
|
31611
|
-
request:
|
|
32732
|
+
request: z24.object({
|
|
31612
32733
|
request_id: boundedText,
|
|
31613
32734
|
action_class: boundedText
|
|
31614
32735
|
}).strict()
|
|
31615
32736
|
}).strict()
|
|
31616
32737
|
]);
|
|
31617
|
-
var WorkerRuntimeArtifactSchema =
|
|
32738
|
+
var WorkerRuntimeArtifactSchema = z24.object({
|
|
31618
32739
|
id: boundedText,
|
|
31619
|
-
hash:
|
|
32740
|
+
hash: z24.string().regex(/^sha256:[0-9a-f]{64}$/u)
|
|
31620
32741
|
}).strict();
|
|
31621
32742
|
var WorkerAdapterRegistry = class {
|
|
31622
32743
|
constructor(manifests = [HOST_ASSISTED_ADAPTER_MANIFEST]) {
|
|
@@ -31749,21 +32870,21 @@ function deepFreeze(value) {
|
|
|
31749
32870
|
}
|
|
31750
32871
|
|
|
31751
32872
|
// src/runs/agent-work-runtime.ts
|
|
31752
|
-
var required =
|
|
32873
|
+
var required = z25.string().min(1).max(16384).refine((value) => !value.includes("\0"));
|
|
31753
32874
|
var absolutePath = required.refine((value) => path37.isAbsolute(value), {
|
|
31754
32875
|
message: "must be a runtime-native absolute path"
|
|
31755
32876
|
});
|
|
31756
|
-
var AgentWorkRuntimeConfigSchema =
|
|
32877
|
+
var AgentWorkRuntimeConfigSchema = z25.object({
|
|
31757
32878
|
databasePath: absolutePath,
|
|
31758
|
-
repositoryId:
|
|
32879
|
+
repositoryId: z25.string().min(1).max(4096),
|
|
31759
32880
|
repositoryRoot: absolutePath,
|
|
31760
32881
|
worktreeRoot: absolutePath,
|
|
31761
|
-
hostId:
|
|
31762
|
-
gitRuntime:
|
|
31763
|
-
pathComparison:
|
|
32882
|
+
hostId: z25.string().min(1).max(4096),
|
|
32883
|
+
gitRuntime: z25.string().min(1).max(4096),
|
|
32884
|
+
pathComparison: z25.enum(["case-sensitive", "case-insensitive"]),
|
|
31764
32885
|
gitExecutable: required.optional(),
|
|
31765
|
-
timeoutMs:
|
|
31766
|
-
maxDirtyPaths:
|
|
32886
|
+
timeoutMs: z25.number().int().positive().max(24 * 60 * 60 * 1e3).optional(),
|
|
32887
|
+
maxDirtyPaths: z25.number().int().positive().max(1e4).optional()
|
|
31767
32888
|
}).strict();
|
|
31768
32889
|
function createAgentWorkRuntime(input) {
|
|
31769
32890
|
const config = AgentWorkRuntimeConfigSchema.parse(input);
|
|
@@ -31808,30 +32929,30 @@ var MAX_INPUT_BYTES3 = 256 * 1024;
|
|
|
31808
32929
|
var MAX_TEXT = 4096;
|
|
31809
32930
|
var MAX_PATH = 16384;
|
|
31810
32931
|
var MAX_ISSUES3 = 20;
|
|
31811
|
-
var text2 =
|
|
31812
|
-
var nativePath =
|
|
32932
|
+
var text2 = z26.string().min(1).max(MAX_TEXT);
|
|
32933
|
+
var nativePath = z26.string().min(1).max(MAX_PATH).refine((value) => !value.includes("\0"), {
|
|
31813
32934
|
message: "must not contain NUL bytes"
|
|
31814
32935
|
});
|
|
31815
32936
|
var absoluteNativePath = nativePath.refine((value) => path38.isAbsolute(value), {
|
|
31816
32937
|
message: "must be a runtime-native absolute path"
|
|
31817
32938
|
});
|
|
31818
|
-
var instant2 =
|
|
31819
|
-
var revision =
|
|
31820
|
-
var positiveTtl =
|
|
31821
|
-
var mutation =
|
|
31822
|
-
var AttemptStartInputSchema =
|
|
32939
|
+
var instant2 = z26.string().datetime({ offset: true });
|
|
32940
|
+
var revision = z26.number().int().nonnegative();
|
|
32941
|
+
var positiveTtl = z26.number().int().positive().max(24 * 60 * 60 * 1e3);
|
|
32942
|
+
var mutation = z26.object({ mutationId: text2, now: instant2 }).strict();
|
|
32943
|
+
var AttemptStartInputSchema = z26.object({
|
|
31823
32944
|
runId: text2,
|
|
31824
32945
|
initialRunState: RunStateSchema,
|
|
31825
|
-
controller:
|
|
31826
|
-
attempt:
|
|
32946
|
+
controller: z26.object({ controllerId: text2, leaseId: text2, now: instant2, ttlMs: positiveTtl }).strict(),
|
|
32947
|
+
attempt: z26.object({
|
|
31827
32948
|
attemptId: text2,
|
|
31828
32949
|
workItemId: text2,
|
|
31829
32950
|
workItemRevision: revision,
|
|
31830
32951
|
packetId: text2,
|
|
31831
|
-
packetHash:
|
|
31832
|
-
baseSha:
|
|
32952
|
+
packetHash: z26.string().regex(/^sha256:[0-9a-f]{64}$/),
|
|
32953
|
+
baseSha: z26.string().regex(/^(?:[0-9a-f]{40}|[0-9a-f]{64})$/)
|
|
31833
32954
|
}).strict(),
|
|
31834
|
-
workspace:
|
|
32955
|
+
workspace: z26.object({
|
|
31835
32956
|
workspaceLeaseId: text2,
|
|
31836
32957
|
repositoryId: text2,
|
|
31837
32958
|
hostId: text2,
|
|
@@ -31841,7 +32962,7 @@ var AttemptStartInputSchema = z24.object({
|
|
|
31841
32962
|
worktreePath: nativePath,
|
|
31842
32963
|
ttlMs: positiveTtl
|
|
31843
32964
|
}).strict(),
|
|
31844
|
-
mutations:
|
|
32965
|
+
mutations: z26.object({
|
|
31845
32966
|
createAttempt: mutation,
|
|
31846
32967
|
reserveWorkspace: mutation,
|
|
31847
32968
|
activateWorkspace: mutation,
|
|
@@ -31849,16 +32970,16 @@ var AttemptStartInputSchema = z24.object({
|
|
|
31849
32970
|
quarantineWorkspace: mutation,
|
|
31850
32971
|
authorizeLaunch: mutation
|
|
31851
32972
|
}).strict(),
|
|
31852
|
-
broker:
|
|
32973
|
+
broker: z26.object({ timeoutMs: positiveTtl }).strict().optional()
|
|
31853
32974
|
}).strict();
|
|
31854
|
-
var AttemptStatusInputSchema =
|
|
32975
|
+
var AttemptStatusInputSchema = z26.object({
|
|
31855
32976
|
databasePath: nativePath.refine((value) => path38.isAbsolute(value), {
|
|
31856
32977
|
message: "must be a runtime-native absolute path"
|
|
31857
32978
|
}),
|
|
31858
32979
|
runId: text2,
|
|
31859
32980
|
attemptId: text2
|
|
31860
32981
|
}).strict();
|
|
31861
|
-
var AttemptStartRequestSchema =
|
|
32982
|
+
var AttemptStartRequestSchema = z26.object({ runtime: AgentWorkRuntimeConfigSchema, attempt: AttemptStartInputSchema }).strict();
|
|
31862
32983
|
var AttemptPrepareLifecycleInputSchema = AttemptStartInputSchema.omit({
|
|
31863
32984
|
runId: true,
|
|
31864
32985
|
attempt: true,
|
|
@@ -31873,26 +32994,26 @@ var AttemptLaunchPacketPolicySchema = AgentTaskPacketHashInput_v1.pick({
|
|
|
31873
32994
|
verification: true,
|
|
31874
32995
|
budget: true
|
|
31875
32996
|
}).extend({ packetId: text2, createdAt: instant2 }).strict();
|
|
31876
|
-
var AttemptLaunchEnvelopePolicySchema =
|
|
32997
|
+
var AttemptLaunchEnvelopePolicySchema = z26.object({
|
|
31877
32998
|
envelopeId: text2,
|
|
31878
32999
|
os: ExecutionEnvironmentOS,
|
|
31879
33000
|
architecture: text2,
|
|
31880
33001
|
workerRuntime: text2,
|
|
31881
33002
|
projectRoot: absoluteNativePath,
|
|
31882
33003
|
executionRoot: absoluteNativePath,
|
|
31883
|
-
exposedEnvironmentKeys:
|
|
33004
|
+
exposedEnvironmentKeys: z26.array(text2).max(256),
|
|
31884
33005
|
createdAt: instant2,
|
|
31885
|
-
projection:
|
|
33006
|
+
projection: z26.object({
|
|
31886
33007
|
selectionDigest: SHA256Hash
|
|
31887
33008
|
}).strict().optional()
|
|
31888
33009
|
}).strict();
|
|
31889
|
-
var AttemptPrepareRequestSchema =
|
|
33010
|
+
var AttemptPrepareRequestSchema = z26.object({
|
|
31890
33011
|
runtime: AgentWorkRuntimeConfigSchema,
|
|
31891
33012
|
workItem: WorkItem_v1,
|
|
31892
|
-
identity:
|
|
33013
|
+
identity: z26.object({
|
|
31893
33014
|
runId: text2,
|
|
31894
33015
|
attemptId: text2,
|
|
31895
|
-
baseSha:
|
|
33016
|
+
baseSha: z26.string().regex(/^(?:[0-9a-f]{40}|[0-9a-f]{64})$/)
|
|
31896
33017
|
}).strict(),
|
|
31897
33018
|
packet: AttemptLaunchPacketPolicySchema,
|
|
31898
33019
|
envelope: AttemptLaunchEnvelopePolicySchema,
|
|
@@ -31984,7 +33105,7 @@ var AttemptPrepareRequestSchema = z24.object({
|
|
|
31984
33105
|
created_at: value.packet.createdAt
|
|
31985
33106
|
});
|
|
31986
33107
|
} catch (error) {
|
|
31987
|
-
if (error instanceof
|
|
33108
|
+
if (error instanceof z26.ZodError) {
|
|
31988
33109
|
for (const issue of error.issues.slice(0, MAX_ISSUES3)) {
|
|
31989
33110
|
context.addIssue({
|
|
31990
33111
|
code: "custom",
|
|
@@ -31997,13 +33118,13 @@ var AttemptPrepareRequestSchema = z24.object({
|
|
|
31997
33118
|
}
|
|
31998
33119
|
}
|
|
31999
33120
|
});
|
|
32000
|
-
var AttemptStartRequestJsonSchema =
|
|
33121
|
+
var AttemptStartRequestJsonSchema = z26.toJSONSchema(AttemptStartRequestSchema, {
|
|
32001
33122
|
target: "draft-7"
|
|
32002
33123
|
});
|
|
32003
|
-
var AttemptPrepareRequestJsonSchema =
|
|
33124
|
+
var AttemptPrepareRequestJsonSchema = z26.toJSONSchema(AttemptPrepareRequestSchema, {
|
|
32004
33125
|
target: "draft-7"
|
|
32005
33126
|
});
|
|
32006
|
-
var AttemptStatusInputJsonSchema =
|
|
33127
|
+
var AttemptStatusInputJsonSchema = z26.toJSONSchema(AttemptStatusInputSchema, {
|
|
32007
33128
|
target: "draft-7"
|
|
32008
33129
|
});
|
|
32009
33130
|
function createAttemptLifecycleHandlers() {
|
|
@@ -32235,22 +33356,22 @@ function safeError(error) {
|
|
|
32235
33356
|
// src/runs/agent-work-worker-adapters.ts
|
|
32236
33357
|
import path39 from "path";
|
|
32237
33358
|
import { stat as stat4 } from "fs/promises";
|
|
32238
|
-
import { z as
|
|
33359
|
+
import { z as z27 } from "zod";
|
|
32239
33360
|
var MAX_INPUT_BYTES4 = 256 * 1024;
|
|
32240
33361
|
var MAX_ISSUES4 = 20;
|
|
32241
|
-
var text3 =
|
|
32242
|
-
var shortText =
|
|
32243
|
-
var nativePath2 =
|
|
33362
|
+
var text3 = z27.string().min(1).max(4096);
|
|
33363
|
+
var shortText = z27.string().min(1).max(1024);
|
|
33364
|
+
var nativePath2 = z27.string().min(1).max(16384).refine((value) => !value.includes("\0") && path39.isAbsolute(value), {
|
|
32244
33365
|
message: "must be a runtime-native absolute path"
|
|
32245
33366
|
});
|
|
32246
|
-
var instant3 =
|
|
32247
|
-
var revision2 =
|
|
32248
|
-
var mutation2 =
|
|
32249
|
-
var controller =
|
|
33367
|
+
var instant3 = z27.string().datetime({ offset: true });
|
|
33368
|
+
var revision2 = z27.number().int().nonnegative();
|
|
33369
|
+
var mutation2 = z27.object({ mutationId: text3, now: instant3 }).strict();
|
|
33370
|
+
var controller = z27.object({
|
|
32250
33371
|
runId: text3,
|
|
32251
33372
|
controllerId: text3,
|
|
32252
33373
|
leaseId: text3,
|
|
32253
|
-
fencingToken:
|
|
33374
|
+
fencingToken: z27.number().int().positive()
|
|
32254
33375
|
}).strict();
|
|
32255
33376
|
var common = {
|
|
32256
33377
|
runId: text3,
|
|
@@ -32263,32 +33384,32 @@ var common = {
|
|
|
32263
33384
|
workerSessionId: text3,
|
|
32264
33385
|
mutation: mutation2
|
|
32265
33386
|
};
|
|
32266
|
-
var BoundedExecutionEnvelopeSchema =
|
|
32267
|
-
schema_version:
|
|
33387
|
+
var BoundedExecutionEnvelopeSchema = z27.object({
|
|
33388
|
+
schema_version: z27.literal("1.0.0"),
|
|
32268
33389
|
envelope_id: text3,
|
|
32269
33390
|
run_id: text3,
|
|
32270
33391
|
attempt_id: text3,
|
|
32271
33392
|
packet_id: text3,
|
|
32272
|
-
packet_hash:
|
|
33393
|
+
packet_hash: z27.string().regex(/^sha256:[0-9a-f]{64}$/),
|
|
32273
33394
|
workspace_lease_id: text3,
|
|
32274
33395
|
workspace_lease_revision: revision2,
|
|
32275
|
-
expected_head_sha:
|
|
33396
|
+
expected_head_sha: z27.string().regex(/^(?:[0-9a-f]{40}|[0-9a-f]{64})$/i),
|
|
32276
33397
|
branch: text3,
|
|
32277
|
-
runtime:
|
|
33398
|
+
runtime: z27.object({
|
|
32278
33399
|
host_id: text3,
|
|
32279
33400
|
os: ExecutionEnvironmentOS,
|
|
32280
33401
|
architecture: text3,
|
|
32281
33402
|
worker_runtime: text3,
|
|
32282
33403
|
git_runtime: text3
|
|
32283
33404
|
}).strict(),
|
|
32284
|
-
paths:
|
|
33405
|
+
paths: z27.object({
|
|
32285
33406
|
project_root: nativePath2,
|
|
32286
33407
|
execution_root: nativePath2,
|
|
32287
33408
|
allocation_root: nativePath2.optional(),
|
|
32288
33409
|
worktree_root: nativePath2
|
|
32289
33410
|
}).strict(),
|
|
32290
|
-
path_mappings:
|
|
32291
|
-
exposed_environment_keys:
|
|
33411
|
+
path_mappings: z27.array(AgentExecutionPathMapping_v1).max(1),
|
|
33412
|
+
exposed_environment_keys: z27.array(text3).max(256),
|
|
32292
33413
|
created_at: instant3
|
|
32293
33414
|
}).strict().superRefine((value, context) => {
|
|
32294
33415
|
const parsed = ExecutionEnvelope_v1.safeParse(value);
|
|
@@ -32298,12 +33419,12 @@ var BoundedExecutionEnvelopeSchema = z25.object({
|
|
|
32298
33419
|
}
|
|
32299
33420
|
}
|
|
32300
33421
|
});
|
|
32301
|
-
var AttemptWorkerAttachRequestSchema =
|
|
33422
|
+
var AttemptWorkerAttachRequestSchema = z27.object({
|
|
32302
33423
|
runtime: AgentWorkRuntimeConfigSchema,
|
|
32303
|
-
attach:
|
|
33424
|
+
attach: z27.object({
|
|
32304
33425
|
...common,
|
|
32305
33426
|
envelope: BoundedExecutionEnvelopeSchema,
|
|
32306
|
-
worker:
|
|
33427
|
+
worker: z27.object({
|
|
32307
33428
|
backend: WorkerSessionBackend,
|
|
32308
33429
|
workerId: text3,
|
|
32309
33430
|
model: text3.optional(),
|
|
@@ -32334,40 +33455,40 @@ var AttemptWorkerAttachRequestSchema = z25.object({
|
|
|
32334
33455
|
});
|
|
32335
33456
|
}
|
|
32336
33457
|
});
|
|
32337
|
-
var WorkerHeartbeatInputSchema =
|
|
33458
|
+
var WorkerHeartbeatInputSchema = z27.object({
|
|
32338
33459
|
...common,
|
|
32339
33460
|
expectedWorkerSessionRevision: revision2,
|
|
32340
33461
|
status: HeartbeatWorkerSessionStatus.optional()
|
|
32341
33462
|
}).strict();
|
|
32342
|
-
var AttemptWorkerHeartbeatRequestSchema =
|
|
33463
|
+
var AttemptWorkerHeartbeatRequestSchema = z27.object({ databasePath: nativePath2, heartbeat: WorkerHeartbeatInputSchema }).strict().superRefine((value, context) => {
|
|
32343
33464
|
requireControllerRun(value.heartbeat, "heartbeat", context);
|
|
32344
33465
|
});
|
|
32345
|
-
var WorkerEndInputSchema =
|
|
33466
|
+
var WorkerEndInputSchema = z27.object({
|
|
32346
33467
|
...common,
|
|
32347
33468
|
expectedWorkerSessionRevision: revision2,
|
|
32348
33469
|
status: EndWorkerSessionStatus,
|
|
32349
|
-
exit:
|
|
32350
|
-
code:
|
|
32351
|
-
signal:
|
|
33470
|
+
exit: z27.object({
|
|
33471
|
+
code: z27.number().int().optional(),
|
|
33472
|
+
signal: z27.string().min(1).max(128).optional(),
|
|
32352
33473
|
summary: shortText.optional()
|
|
32353
33474
|
}).strict()
|
|
32354
33475
|
}).strict();
|
|
32355
|
-
var AttemptWorkerEndRequestSchema =
|
|
33476
|
+
var AttemptWorkerEndRequestSchema = z27.object({ databasePath: nativePath2, end: WorkerEndInputSchema }).strict().superRefine((value, context) => {
|
|
32356
33477
|
requireControllerRun(value.end, "end", context);
|
|
32357
33478
|
});
|
|
32358
|
-
var AttemptWorkerStatusRequestSchema =
|
|
32359
|
-
var AttemptWorkerAttachRequestJsonSchema =
|
|
33479
|
+
var AttemptWorkerStatusRequestSchema = z27.object({ databasePath: nativePath2, runId: text3, attemptId: text3 }).strict();
|
|
33480
|
+
var AttemptWorkerAttachRequestJsonSchema = z27.toJSONSchema(
|
|
32360
33481
|
AttemptWorkerAttachRequestSchema,
|
|
32361
33482
|
{ target: "draft-7" }
|
|
32362
33483
|
);
|
|
32363
|
-
var AttemptWorkerHeartbeatRequestJsonSchema =
|
|
33484
|
+
var AttemptWorkerHeartbeatRequestJsonSchema = z27.toJSONSchema(
|
|
32364
33485
|
AttemptWorkerHeartbeatRequestSchema,
|
|
32365
33486
|
{ target: "draft-7" }
|
|
32366
33487
|
);
|
|
32367
|
-
var AttemptWorkerEndRequestJsonSchema =
|
|
33488
|
+
var AttemptWorkerEndRequestJsonSchema = z27.toJSONSchema(AttemptWorkerEndRequestSchema, {
|
|
32368
33489
|
target: "draft-7"
|
|
32369
33490
|
});
|
|
32370
|
-
var AttemptWorkerStatusRequestJsonSchema =
|
|
33491
|
+
var AttemptWorkerStatusRequestJsonSchema = z27.toJSONSchema(
|
|
32371
33492
|
AttemptWorkerStatusRequestSchema,
|
|
32372
33493
|
{ target: "draft-7" }
|
|
32373
33494
|
);
|
|
@@ -32592,7 +33713,7 @@ function operationFailed3(error) {
|
|
|
32592
33713
|
// src/runs/agent-work-attempt-receipt-adapters.ts
|
|
32593
33714
|
import path40 from "path";
|
|
32594
33715
|
import { stat as stat5 } from "fs/promises";
|
|
32595
|
-
import { z as
|
|
33716
|
+
import { z as z28 } from "zod";
|
|
32596
33717
|
|
|
32597
33718
|
// src/runs/agent-work-attempt-receipt-service.ts
|
|
32598
33719
|
var MAX_OUTPUT_BYTES2 = 4096;
|
|
@@ -32701,28 +33822,28 @@ function bounded7(value) {
|
|
|
32701
33822
|
// src/runs/agent-work-attempt-receipt-adapters.ts
|
|
32702
33823
|
var MAX_INPUT_BYTES5 = 256 * 1024;
|
|
32703
33824
|
var MAX_ISSUES5 = 20;
|
|
32704
|
-
var text4 =
|
|
32705
|
-
var shortText2 =
|
|
32706
|
-
var instant4 =
|
|
32707
|
-
var revision3 =
|
|
32708
|
-
var gitObjectId =
|
|
32709
|
-
var sha2564 =
|
|
32710
|
-
var nativePath3 =
|
|
33825
|
+
var text4 = z28.string().min(1).max(4096);
|
|
33826
|
+
var shortText2 = z28.string().min(1).max(1024);
|
|
33827
|
+
var instant4 = z28.string().datetime({ offset: true });
|
|
33828
|
+
var revision3 = z28.number().int().nonnegative();
|
|
33829
|
+
var gitObjectId = z28.string().regex(/^(?:[a-f0-9]{40}|[a-f0-9]{64})$/);
|
|
33830
|
+
var sha2564 = z28.string().regex(/^sha256:[a-f0-9]{64}$/);
|
|
33831
|
+
var nativePath3 = z28.string().min(1).max(16384).refine((value) => !value.includes("\0") && path40.isAbsolute(value), {
|
|
32711
33832
|
message: "must be a runtime-native absolute path"
|
|
32712
33833
|
});
|
|
32713
|
-
var receiptPath =
|
|
33834
|
+
var receiptPath = z28.string().min(1).max(4096).refine(
|
|
32714
33835
|
(value) => !value.includes("\0") && !value.includes("\\") && value.split("/").every((part) => part.length > 0 && part !== "." && part !== "..") && !value.startsWith("/"),
|
|
32715
33836
|
{ message: "must be a canonical slash-separated repository path" }
|
|
32716
33837
|
);
|
|
32717
|
-
var controller2 =
|
|
33838
|
+
var controller2 = z28.object({
|
|
32718
33839
|
runId: text4,
|
|
32719
33840
|
controllerId: text4,
|
|
32720
33841
|
leaseId: text4,
|
|
32721
|
-
fencingToken:
|
|
33842
|
+
fencingToken: z28.number().int().positive()
|
|
32722
33843
|
}).strict();
|
|
32723
|
-
var mutation3 =
|
|
32724
|
-
var BoundedAgentTaskReceiptV2Schema =
|
|
32725
|
-
schema_version:
|
|
33844
|
+
var mutation3 = z28.object({ mutationId: text4, now: instant4 }).strict();
|
|
33845
|
+
var BoundedAgentTaskReceiptV2Schema = z28.object({
|
|
33846
|
+
schema_version: z28.literal("2.0.0"),
|
|
32726
33847
|
receipt_id: text4,
|
|
32727
33848
|
run_id: text4,
|
|
32728
33849
|
work_item_id: text4,
|
|
@@ -32739,26 +33860,26 @@ var BoundedAgentTaskReceiptV2Schema = z26.object({
|
|
|
32739
33860
|
patch_hash: sha2564.optional(),
|
|
32740
33861
|
outcome: AgentTaskReceiptOutcome,
|
|
32741
33862
|
exit_reason: text4,
|
|
32742
|
-
summary:
|
|
32743
|
-
files_touched:
|
|
32744
|
-
commits:
|
|
32745
|
-
acceptance_criteria_addressed:
|
|
32746
|
-
claimed_checks:
|
|
32747
|
-
|
|
33863
|
+
summary: z28.string().min(1).max(4096),
|
|
33864
|
+
files_touched: z28.array(receiptPath).max(2048),
|
|
33865
|
+
commits: z28.array(gitObjectId).max(1024),
|
|
33866
|
+
acceptance_criteria_addressed: z28.array(text4).max(1024),
|
|
33867
|
+
claimed_checks: z28.array(
|
|
33868
|
+
z28.object({
|
|
32748
33869
|
id: text4,
|
|
32749
33870
|
outcome: ClaimedCheckOutcome,
|
|
32750
|
-
exit_code:
|
|
33871
|
+
exit_code: z28.number().int().optional(),
|
|
32751
33872
|
output_snippet: shortText2.optional()
|
|
32752
33873
|
}).strict()
|
|
32753
33874
|
).max(512),
|
|
32754
|
-
assumptions:
|
|
32755
|
-
blockers:
|
|
32756
|
-
human_action_request_ids:
|
|
32757
|
-
cost:
|
|
32758
|
-
input_tokens:
|
|
32759
|
-
output_tokens:
|
|
32760
|
-
tool_calls:
|
|
32761
|
-
elapsed_ms:
|
|
33875
|
+
assumptions: z28.array(shortText2).max(512),
|
|
33876
|
+
blockers: z28.array(shortText2).max(512),
|
|
33877
|
+
human_action_request_ids: z28.array(text4).max(512),
|
|
33878
|
+
cost: z28.object({
|
|
33879
|
+
input_tokens: z28.number().int().nonnegative().optional(),
|
|
33880
|
+
output_tokens: z28.number().int().nonnegative().optional(),
|
|
33881
|
+
tool_calls: z28.number().int().nonnegative().optional(),
|
|
33882
|
+
elapsed_ms: z28.number().int().nonnegative().optional()
|
|
32762
33883
|
}).strict(),
|
|
32763
33884
|
worker_started_at: instant4,
|
|
32764
33885
|
worker_completed_at: instant4,
|
|
@@ -32771,9 +33892,9 @@ var BoundedAgentTaskReceiptV2Schema = z26.object({
|
|
|
32771
33892
|
}
|
|
32772
33893
|
}
|
|
32773
33894
|
});
|
|
32774
|
-
var AttemptReceiptSubmitRequestSchema =
|
|
33895
|
+
var AttemptReceiptSubmitRequestSchema = z28.object({
|
|
32775
33896
|
databasePath: nativePath3,
|
|
32776
|
-
submission:
|
|
33897
|
+
submission: z28.object({
|
|
32777
33898
|
runId: text4,
|
|
32778
33899
|
expectedRunRevision: revision3,
|
|
32779
33900
|
controller: controller2,
|
|
@@ -32803,12 +33924,12 @@ var AttemptReceiptSubmitRequestSchema = z26.object({
|
|
|
32803
33924
|
});
|
|
32804
33925
|
}
|
|
32805
33926
|
});
|
|
32806
|
-
var AttemptReceiptStatusRequestSchema =
|
|
32807
|
-
var AttemptReceiptSubmitRequestJsonSchema =
|
|
33927
|
+
var AttemptReceiptStatusRequestSchema = z28.object({ databasePath: nativePath3, runId: text4, attemptId: text4 }).strict();
|
|
33928
|
+
var AttemptReceiptSubmitRequestJsonSchema = z28.toJSONSchema(
|
|
32808
33929
|
AttemptReceiptSubmitRequestSchema,
|
|
32809
33930
|
{ target: "draft-7" }
|
|
32810
33931
|
);
|
|
32811
|
-
var AttemptReceiptStatusRequestJsonSchema =
|
|
33932
|
+
var AttemptReceiptStatusRequestJsonSchema = z28.toJSONSchema(
|
|
32812
33933
|
AttemptReceiptStatusRequestSchema,
|
|
32813
33934
|
{ target: "draft-7" }
|
|
32814
33935
|
);
|
|
@@ -32934,7 +34055,7 @@ function isJsonSafe5(value, depth = 0) {
|
|
|
32934
34055
|
// src/runs/agent-work-attempt-verification-adapters.ts
|
|
32935
34056
|
import { stat as stat6 } from "fs/promises";
|
|
32936
34057
|
import path42 from "path";
|
|
32937
|
-
import { z as
|
|
34058
|
+
import { z as z29 } from "zod";
|
|
32938
34059
|
|
|
32939
34060
|
// src/runs/agent-work-attempt-verification-service.ts
|
|
32940
34061
|
var DEFAULT_CHECK_TIMEOUT_MS = 6e4;
|
|
@@ -33701,17 +34822,17 @@ function hashBytes(bytes) {
|
|
|
33701
34822
|
// src/runs/agent-work-attempt-verification-adapters.ts
|
|
33702
34823
|
var MAX_INPUT_BYTES6 = 256 * 1024;
|
|
33703
34824
|
var MAX_ISSUES6 = 20;
|
|
33704
|
-
var text6 =
|
|
33705
|
-
var revision4 =
|
|
33706
|
-
var sha2565 =
|
|
33707
|
-
var nativePath4 =
|
|
34825
|
+
var text6 = z29.string().min(1).max(4096);
|
|
34826
|
+
var revision4 = z29.number().int().nonnegative();
|
|
34827
|
+
var sha2565 = z29.string().regex(/^sha256:[a-f0-9]{64}$/);
|
|
34828
|
+
var nativePath4 = z29.string().min(1).max(16384).refine((value) => !value.includes("\0") && path42.isAbsolute(value), {
|
|
33708
34829
|
message: "must be a runtime-native absolute path"
|
|
33709
34830
|
});
|
|
33710
|
-
var controller3 =
|
|
34831
|
+
var controller3 = z29.object({
|
|
33711
34832
|
runId: text6,
|
|
33712
34833
|
controllerId: text6,
|
|
33713
34834
|
leaseId: text6,
|
|
33714
|
-
fencingToken:
|
|
34835
|
+
fencingToken: z29.number().int().positive()
|
|
33715
34836
|
}).strict();
|
|
33716
34837
|
var verificationBinding = {
|
|
33717
34838
|
runId: text6,
|
|
@@ -33727,9 +34848,9 @@ var verificationBinding = {
|
|
|
33727
34848
|
receiptId: text6,
|
|
33728
34849
|
receiptHash: sha2565
|
|
33729
34850
|
};
|
|
33730
|
-
var AttemptVerificationRunRequestSchema =
|
|
34851
|
+
var AttemptVerificationRunRequestSchema = z29.object({
|
|
33731
34852
|
databasePath: nativePath4,
|
|
33732
|
-
verification:
|
|
34853
|
+
verification: z29.object({
|
|
33733
34854
|
...verificationBinding,
|
|
33734
34855
|
beginMutationId: text6,
|
|
33735
34856
|
completeMutationId: text6
|
|
@@ -33750,15 +34871,15 @@ var AttemptVerificationRunRequestSchema = z27.object({
|
|
|
33750
34871
|
});
|
|
33751
34872
|
}
|
|
33752
34873
|
});
|
|
33753
|
-
var AttemptVerificationStatusRequestSchema =
|
|
34874
|
+
var AttemptVerificationStatusRequestSchema = z29.object({
|
|
33754
34875
|
databasePath: nativePath4,
|
|
33755
34876
|
runId: text6,
|
|
33756
34877
|
attemptId: text6,
|
|
33757
|
-
diagnostics:
|
|
34878
|
+
diagnostics: z29.boolean().optional()
|
|
33758
34879
|
}).strict();
|
|
33759
|
-
var AttemptAcceptanceApplyRequestSchema =
|
|
34880
|
+
var AttemptAcceptanceApplyRequestSchema = z29.object({
|
|
33760
34881
|
databasePath: nativePath4,
|
|
33761
|
-
acceptance:
|
|
34882
|
+
acceptance: z29.object({
|
|
33762
34883
|
...verificationBinding,
|
|
33763
34884
|
verificationHash: sha2565,
|
|
33764
34885
|
mutationId: text6
|
|
@@ -33772,20 +34893,20 @@ var AttemptAcceptanceApplyRequestSchema = z27.object({
|
|
|
33772
34893
|
});
|
|
33773
34894
|
}
|
|
33774
34895
|
});
|
|
33775
|
-
var AttemptAcceptanceStatusRequestSchema =
|
|
33776
|
-
var AttemptVerificationRunRequestJsonSchema =
|
|
34896
|
+
var AttemptAcceptanceStatusRequestSchema = z29.object({ databasePath: nativePath4, runId: text6, attemptId: text6 }).strict();
|
|
34897
|
+
var AttemptVerificationRunRequestJsonSchema = z29.toJSONSchema(
|
|
33777
34898
|
AttemptVerificationRunRequestSchema,
|
|
33778
34899
|
{ target: "draft-7" }
|
|
33779
34900
|
);
|
|
33780
|
-
var AttemptVerificationStatusRequestJsonSchema =
|
|
34901
|
+
var AttemptVerificationStatusRequestJsonSchema = z29.toJSONSchema(
|
|
33781
34902
|
AttemptVerificationStatusRequestSchema,
|
|
33782
34903
|
{ target: "draft-7" }
|
|
33783
34904
|
);
|
|
33784
|
-
var AttemptAcceptanceApplyRequestJsonSchema =
|
|
34905
|
+
var AttemptAcceptanceApplyRequestJsonSchema = z29.toJSONSchema(
|
|
33785
34906
|
AttemptAcceptanceApplyRequestSchema,
|
|
33786
34907
|
{ target: "draft-7" }
|
|
33787
34908
|
);
|
|
33788
|
-
var AttemptAcceptanceStatusRequestJsonSchema =
|
|
34909
|
+
var AttemptAcceptanceStatusRequestJsonSchema = z29.toJSONSchema(
|
|
33789
34910
|
AttemptAcceptanceStatusRequestSchema,
|
|
33790
34911
|
{ target: "draft-7" }
|
|
33791
34912
|
);
|
|
@@ -34652,7 +35773,7 @@ import * as fs48 from "fs";
|
|
|
34652
35773
|
import * as path49 from "path";
|
|
34653
35774
|
|
|
34654
35775
|
// src/runs/enforcement.ts
|
|
34655
|
-
import { z as
|
|
35776
|
+
import { z as z30 } from "zod";
|
|
34656
35777
|
var ViolationType = {
|
|
34657
35778
|
/** Direct git command executed during active run */
|
|
34658
35779
|
DIRECT_GIT_COMMAND: "DIRECT_GIT_COMMAND",
|
|
@@ -34669,21 +35790,21 @@ var ViolationType = {
|
|
|
34669
35790
|
/** Used forbidden action under current persona */
|
|
34670
35791
|
FORBIDDEN_ACTION: "FORBIDDEN_ACTION"
|
|
34671
35792
|
};
|
|
34672
|
-
var ViolationEntrySchema =
|
|
35793
|
+
var ViolationEntrySchema = z30.object({
|
|
34673
35794
|
/** ISO 8601 timestamp of the violation */
|
|
34674
|
-
timestamp:
|
|
35795
|
+
timestamp: z30.string(),
|
|
34675
35796
|
/** Run identifier where violation occurred */
|
|
34676
|
-
runId:
|
|
35797
|
+
runId: z30.string(),
|
|
34677
35798
|
/** Type of violation */
|
|
34678
|
-
violation:
|
|
35799
|
+
violation: z30.string(),
|
|
34679
35800
|
/** Command or action that caused the violation */
|
|
34680
|
-
command:
|
|
35801
|
+
command: z30.string().optional(),
|
|
34681
35802
|
/** Additional context about the violation */
|
|
34682
|
-
context:
|
|
35803
|
+
context: z30.string().optional(),
|
|
34683
35804
|
/** Severity level */
|
|
34684
|
-
severity:
|
|
35805
|
+
severity: z30.enum(["warning", "error", "critical"]),
|
|
34685
35806
|
/** Whether the violation was blocked (hard enforcement) */
|
|
34686
|
-
blocked:
|
|
35807
|
+
blocked: z30.boolean().optional()
|
|
34687
35808
|
});
|
|
34688
35809
|
function getViolations(runId, baseDir = process.cwd()) {
|
|
34689
35810
|
const failures = readRunLog(runId, "failures", baseDir);
|
|
@@ -34906,26 +36027,26 @@ import { ulid as ulid3 } from "ulid";
|
|
|
34906
36027
|
// src/runs/artifacts.ts
|
|
34907
36028
|
import * as fs46 from "fs";
|
|
34908
36029
|
import * as path45 from "path";
|
|
34909
|
-
import { z as
|
|
36030
|
+
import { z as z31 } from "zod";
|
|
34910
36031
|
var DEFAULT_INLINE_THRESHOLD = 10 * 1024;
|
|
34911
|
-
var ListArtifactsInputSchema =
|
|
34912
|
-
runId:
|
|
34913
|
-
type:
|
|
34914
|
-
path:
|
|
34915
|
-
latestOnly:
|
|
34916
|
-
inline:
|
|
36032
|
+
var ListArtifactsInputSchema = z31.object({
|
|
36033
|
+
runId: z31.string().describe("The unique run identifier"),
|
|
36034
|
+
type: z31.enum(["plan", "decision", "failure", "gate", "report", "log"]).optional().describe('Filter by type: "plan", "decision", "failure", "gate", "report", "log"'),
|
|
36035
|
+
path: z31.string().optional().describe("Filter by path pattern (supports * and ** wildcards)"),
|
|
36036
|
+
latestOnly: z31.boolean().optional().describe("Only return the most recent artifact of each type"),
|
|
36037
|
+
inline: z31.boolean().optional().describe("Include content for small artifacts (< 10KB)")
|
|
34917
36038
|
});
|
|
34918
|
-
var ArtifactDescriptorSchema =
|
|
34919
|
-
path:
|
|
34920
|
-
type:
|
|
34921
|
-
size:
|
|
34922
|
-
createdAt:
|
|
34923
|
-
modifiedAt:
|
|
34924
|
-
content:
|
|
36039
|
+
var ArtifactDescriptorSchema = z31.object({
|
|
36040
|
+
path: z31.string().describe("Relative path within run directory"),
|
|
36041
|
+
type: z31.enum(["plan", "decision", "failure", "gate", "report", "log"]).describe("Artifact type"),
|
|
36042
|
+
size: z31.number().describe("File size in bytes"),
|
|
36043
|
+
createdAt: z31.string().describe("ISO 8601 creation timestamp"),
|
|
36044
|
+
modifiedAt: z31.string().describe("ISO 8601 modification timestamp"),
|
|
36045
|
+
content: z31.string().optional().describe("File content (included if inline=true and size < threshold)")
|
|
34925
36046
|
});
|
|
34926
|
-
var ListArtifactsOutputSchema =
|
|
34927
|
-
artifacts:
|
|
34928
|
-
totalCount:
|
|
36047
|
+
var ListArtifactsOutputSchema = z31.object({
|
|
36048
|
+
artifacts: z31.array(ArtifactDescriptorSchema),
|
|
36049
|
+
totalCount: z31.number().describe("Total number of artifacts found")
|
|
34929
36050
|
});
|
|
34930
36051
|
function getArtifactType(filePath) {
|
|
34931
36052
|
const normalizedPath = filePath.replace(/\\/g, "/");
|
|
@@ -35047,54 +36168,54 @@ function listArtifacts(input, baseDir = process.cwd(), inlineThreshold = DEFAULT
|
|
|
35047
36168
|
}
|
|
35048
36169
|
|
|
35049
36170
|
// src/store/run-store.ts
|
|
35050
|
-
import { z as
|
|
35051
|
-
var RunStateSchema2 =
|
|
35052
|
-
var StepStatusSchema =
|
|
35053
|
-
var RunRecordSchema =
|
|
36171
|
+
import { z as z32 } from "zod";
|
|
36172
|
+
var RunStateSchema2 = z32.enum(["pending", "running", "completed", "failed", "aborted"]);
|
|
36173
|
+
var StepStatusSchema = z32.enum(["pass", "fail", "skipped", "blocked"]);
|
|
36174
|
+
var RunRecordSchema = z32.object({
|
|
35054
36175
|
/** Caller-provided run identifier. Pre-generated by orchestration. */
|
|
35055
|
-
runId:
|
|
36176
|
+
runId: z32.string().min(1),
|
|
35056
36177
|
/** SHA256 hash of the frozen plan.json. */
|
|
35057
|
-
planHash:
|
|
36178
|
+
planHash: z32.string().min(1),
|
|
35058
36179
|
/** Current state of the run. */
|
|
35059
36180
|
state: RunStateSchema2,
|
|
35060
36181
|
/** When the run started. UTC ISO 8601. */
|
|
35061
|
-
startedAt:
|
|
36182
|
+
startedAt: z32.string().datetime({ message: "startedAt must be UTC ISO 8601 format" }),
|
|
35062
36183
|
/** When the run completed (if terminal state). UTC ISO 8601. */
|
|
35063
|
-
completedAt:
|
|
36184
|
+
completedAt: z32.string().datetime({ message: "completedAt must be UTC ISO 8601 format" }).optional(),
|
|
35064
36185
|
/** Arbitrary metadata for extensibility. */
|
|
35065
|
-
metadata:
|
|
36186
|
+
metadata: z32.record(z32.string(), z32.unknown()).optional()
|
|
35066
36187
|
});
|
|
35067
|
-
var StepOutcomeSchema =
|
|
36188
|
+
var StepOutcomeSchema = z32.object({
|
|
35068
36189
|
/** Unique step identifier. Caller-generated. */
|
|
35069
|
-
stepId:
|
|
36190
|
+
stepId: z32.string().min(1),
|
|
35070
36191
|
/** Parent run identifier. */
|
|
35071
|
-
runId:
|
|
36192
|
+
runId: z32.string().min(1),
|
|
35072
36193
|
/** Node (PR/item) identifier from plan. */
|
|
35073
|
-
nodeId:
|
|
36194
|
+
nodeId: z32.string().min(1),
|
|
35074
36195
|
/** Gate name (e.g., "lint", "typecheck", "test"). */
|
|
35075
|
-
gateName:
|
|
36196
|
+
gateName: z32.string().min(1),
|
|
35076
36197
|
/** Outcome status. */
|
|
35077
36198
|
status: StepStatusSchema,
|
|
35078
36199
|
/** Execution duration in milliseconds. */
|
|
35079
|
-
durationMs:
|
|
36200
|
+
durationMs: z32.number().int().nonnegative(),
|
|
35080
36201
|
/** Optional log output or path. */
|
|
35081
|
-
logs:
|
|
36202
|
+
logs: z32.string().optional(),
|
|
35082
36203
|
/** Optional artifact paths. */
|
|
35083
|
-
artifacts:
|
|
36204
|
+
artifacts: z32.array(z32.string()).optional(),
|
|
35084
36205
|
/** When this step was recorded. UTC ISO 8601. */
|
|
35085
|
-
timestamp:
|
|
36206
|
+
timestamp: z32.string().datetime({ message: "timestamp must be UTC ISO 8601 format" })
|
|
35086
36207
|
});
|
|
35087
|
-
var ReceiptSchema =
|
|
36208
|
+
var ReceiptSchema = z32.object({
|
|
35088
36209
|
/** Unique receipt identifier. Caller-generated. */
|
|
35089
|
-
receiptId:
|
|
36210
|
+
receiptId: z32.string().min(1),
|
|
35090
36211
|
/** Parent run identifier. */
|
|
35091
|
-
runId:
|
|
36212
|
+
runId: z32.string().min(1),
|
|
35092
36213
|
/** Reason for the scope/risk escalation. */
|
|
35093
|
-
reason:
|
|
36214
|
+
reason: z32.string().min(1),
|
|
35094
36215
|
/** Human who approved (if applicable). */
|
|
35095
|
-
approver:
|
|
36216
|
+
approver: z32.string().optional(),
|
|
35096
36217
|
/** When this receipt was created. UTC ISO 8601. */
|
|
35097
|
-
timestamp:
|
|
36218
|
+
timestamp: z32.string().datetime({ message: "timestamp must be UTC ISO 8601 format" })
|
|
35098
36219
|
});
|
|
35099
36220
|
function safeParseStepOutcome(data) {
|
|
35100
36221
|
return StepOutcomeSchema.safeParse(data);
|
|
@@ -35760,16 +36881,16 @@ import { existsSync as existsSync24, readFileSync as readFileSync29, renameSync
|
|
|
35760
36881
|
import { join as join30 } from "path";
|
|
35761
36882
|
|
|
35762
36883
|
// src/runs/agent-work-supervisor.ts
|
|
35763
|
-
import { z as
|
|
35764
|
-
var instant5 =
|
|
35765
|
-
var HeadlessSupervisorConfig =
|
|
35766
|
-
controllerTtlMs:
|
|
35767
|
-
workspaceTtlMs:
|
|
35768
|
-
heartbeatTimeoutMs:
|
|
35769
|
-
maxAttemptsPerWorkItem:
|
|
35770
|
-
maxConcurrency:
|
|
35771
|
-
retryBaseDelayMs:
|
|
35772
|
-
retryMaxDelayMs:
|
|
36884
|
+
import { z as z33 } from "zod";
|
|
36885
|
+
var instant5 = z33.string().datetime({ offset: true });
|
|
36886
|
+
var HeadlessSupervisorConfig = z33.object({
|
|
36887
|
+
controllerTtlMs: z33.number().int().positive().max(24 * 60 * 60 * 1e3),
|
|
36888
|
+
workspaceTtlMs: z33.number().int().positive().max(24 * 60 * 60 * 1e3),
|
|
36889
|
+
heartbeatTimeoutMs: z33.number().int().positive().max(24 * 60 * 60 * 1e3),
|
|
36890
|
+
maxAttemptsPerWorkItem: z33.number().int().positive().max(100),
|
|
36891
|
+
maxConcurrency: z33.number().int().positive().max(16),
|
|
36892
|
+
retryBaseDelayMs: z33.number().int().nonnegative().max(24 * 60 * 60 * 1e3),
|
|
36893
|
+
retryMaxDelayMs: z33.number().int().nonnegative().max(7 * 24 * 60 * 60 * 1e3)
|
|
35773
36894
|
}).strict().refine((value) => value.retryMaxDelayMs >= value.retryBaseDelayMs, {
|
|
35774
36895
|
message: "retryMaxDelayMs must be at least retryBaseDelayMs"
|
|
35775
36896
|
});
|
|
@@ -36115,28 +37236,28 @@ import { execa as execa4 } from "execa";
|
|
|
36115
37236
|
var MAX_COMMAND_OUTPUT_BYTES3 = 64 * 1024;
|
|
36116
37237
|
|
|
36117
37238
|
// src/runs/decisions.ts
|
|
36118
|
-
import { z as
|
|
36119
|
-
var SubmitDecisionInputSchema =
|
|
37239
|
+
import { z as z34 } from "zod";
|
|
37240
|
+
var SubmitDecisionInputSchema = z34.object({
|
|
36120
37241
|
/** Unique run identifier */
|
|
36121
|
-
runId:
|
|
37242
|
+
runId: z34.string(),
|
|
36122
37243
|
/** Action to submit (must match a nextOptions[x].action) */
|
|
36123
|
-
action:
|
|
37244
|
+
action: z34.string(),
|
|
36124
37245
|
/** Response data (validated against nextOptions[x].responseSchema) */
|
|
36125
|
-
response:
|
|
37246
|
+
response: z34.unknown(),
|
|
36126
37247
|
/** Optional rationale for audit trail */
|
|
36127
|
-
rationale:
|
|
37248
|
+
rationale: z34.string().optional()
|
|
36128
37249
|
});
|
|
36129
|
-
var SubmitDecisionOutputSchema =
|
|
37250
|
+
var SubmitDecisionOutputSchema = z34.object({
|
|
36130
37251
|
/** Whether the decision was accepted */
|
|
36131
|
-
accepted:
|
|
37252
|
+
accepted: z34.boolean(),
|
|
36132
37253
|
/** Updated status after accepting the decision */
|
|
36133
37254
|
updatedStatus: StatusResponseSchema,
|
|
36134
37255
|
/** Error information if rejected */
|
|
36135
|
-
error:
|
|
37256
|
+
error: z34.object({
|
|
36136
37257
|
/** Error code from DecisionErrorCodes */
|
|
36137
|
-
code:
|
|
37258
|
+
code: z34.string(),
|
|
36138
37259
|
/** Human-readable error message */
|
|
36139
|
-
message:
|
|
37260
|
+
message: z34.string()
|
|
36140
37261
|
}).optional()
|
|
36141
37262
|
});
|
|
36142
37263
|
|