@smartergpt/lexrunner 2.0.2 → 2.2.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.
Files changed (41) hide show
  1. package/BRAND.md +14 -0
  2. package/CHANGELOG.md +49 -0
  3. package/GOVERNANCE.md +18 -0
  4. package/LICENSE.md +201 -110
  5. package/NOTICE.md +12 -1
  6. package/README.mcp.md +5 -1
  7. package/README.md +48 -35
  8. package/dist/{api-QBPBKYOC.js → api-UIWVFU7M.js} +1 -1
  9. package/dist/{audit-SKMMC2U4.js → audit-HVB2HJPU.js} +2 -2
  10. package/dist/{autopilot-3OHEUTHD.js → autopilot-7PX6YG55.js} +2 -2
  11. package/dist/{chunk-6PZDSWCG.js → chunk-37UC53OG.js} +2 -2
  12. package/dist/{chunk-ARDKZW7F.js → chunk-M6AAYMHH.js} +363 -293
  13. package/dist/{chunk-V3BU2VDU.js → chunk-PDDULIDL.js} +13 -1
  14. package/dist/cli.cjs +3672 -2774
  15. package/dist/cli.d.ts +201 -24
  16. package/dist/cli.js +1073 -275
  17. package/dist/{commandValidator-LVEMJTZP.js → commandValidator-XFVNCZXX.js} +1 -1
  18. package/dist/{constraints-2ZK5FJFA.js → constraints-LE2MW5NS.js} +1 -1
  19. package/dist/errors/index.js +1 -1
  20. package/dist/frames/index.js +1 -1
  21. package/dist/{gateMapping-R3RJYKMS.js → gateMapping-V4DTL5WD.js} +1 -1
  22. package/dist/hooks/events.js +1 -1
  23. package/dist/{jsonEnvelope-K2U5CWKU.js → jsonEnvelope-MXJM5ZQH.js} +1 -1
  24. package/dist/{mergeTreeSimulator-QCFSOU25.js → mergeTreeSimulator-GWZ77NF2.js} +1 -1
  25. package/dist/package-schemas/behavior-rule.js +1 -1
  26. package/dist/package-schemas/execution-plan-v1.js +1 -1
  27. package/dist/package-schemas/gates.js +1 -1
  28. package/dist/package-schemas/runner-scope.js +1 -1
  29. package/dist/package-schemas/runner-stack.js +1 -1
  30. package/dist/{planDiff-IHLFNZUT.js → planDiff-4D3AERAW.js} +1 -1
  31. package/dist/{planHistory-GLRI356L.js → planHistory-VPV4WDPW.js} +1 -1
  32. package/dist/{planReview-UUMCGZJ6.js → planReview-FV6INFLQ.js} +1 -1
  33. package/dist/{planViewer-TRSQVMH4.js → planViewer-WOV6A2HZ.js} +1 -1
  34. package/dist/{sarif-2C6RKOUX.js → sarif-QXVE3LYD.js} +1 -1
  35. package/dist/sdk/index.d.ts +5 -5
  36. package/dist/sdk/index.js +1 -1
  37. package/dist/{security-OE4VLUFK.js → security-W7TOUXSB.js} +1 -1
  38. package/dist/{signing-KLZYZZMP.js → signing-WGVPHJGG.js} +1 -1
  39. package/dist/{verify-3UVMA62I.js → verify-Y34CJAKB.js} +1 -1
  40. package/package.json +8 -6
  41. package/schemas/plan.schema.json +203 -73
@@ -31,7 +31,7 @@ import {
31
31
  } from "./chunk-AXOAVRTU.js";
32
32
  import {
33
33
  __require
34
- } from "./chunk-V3BU2VDU.js";
34
+ } from "./chunk-PDDULIDL.js";
35
35
 
36
36
  // src/autopilot/types.ts
37
37
  import { z } from "zod";
@@ -1441,6 +1441,44 @@ function emitFailureReceipt(params, options = {}) {
1441
1441
  return emitActionReceipt({ ...params, outcome: "failure" }, options);
1442
1442
  }
1443
1443
 
1444
+ // src/git/input-schema.ts
1445
+ import { z as z3 } from "zod";
1446
+ function repositoryIdentity(value) {
1447
+ const scp = /^git@([^/:]+):(.+)$/.exec(value);
1448
+ const url = new URL(scp ? `ssh://git@${scp[1]}/${scp[2]}` : value);
1449
+ if (!["https:", "ssh:", "file:"].includes(url.protocol) || url.password || url.search || url.hash || url.username && !(url.protocol === "ssh:" && url.username === "git"))
1450
+ throw new Error("Repository must be an explicit HTTPS, SSH or file URL without credentials");
1451
+ if (url.protocol === "file:") return url.href.replace(/\/$/, "");
1452
+ if (!url.hostname || !/^\/[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+\/?$/.test(url.pathname)) {
1453
+ throw new Error("Repository URL must identify an owner and repository");
1454
+ }
1455
+ const path11 = url.pathname.replace(/\/$/, "").replace(/\.git$/, "");
1456
+ return `${url.hostname.toLowerCase()}${url.port ? `:${url.port}` : ""}${url.hostname.toLowerCase() === "github.com" ? path11.toLowerCase() : path11}`;
1457
+ }
1458
+ var GitCommitId = z3.string().regex(/^(?:[0-9a-f]{40}|[0-9a-f]{64})$/);
1459
+ var GitRef = z3.string().max(512).regex(/^refs\/(?:heads\/.+|pull\/[1-9][0-9]*\/head)$/).refine(
1460
+ (ref) => !/[\x00-\x20\x7f~^:?*\[\\]/.test(ref) && !ref.includes("..") && !ref.includes("@{") && ref.split("/").every(
1461
+ (part) => !!part && !part.startsWith(".") && !part.endsWith(".") && !part.endsWith(".lock")
1462
+ ),
1463
+ "Invalid fully qualified Git ref"
1464
+ );
1465
+ var GitInput = z3.object({ ref: GitRef, commit: GitCommitId }).strict();
1466
+ var FrozenGitInputs = z3.object({
1467
+ schemaVersion: z3.literal("1.0.0"),
1468
+ repository: z3.string().max(2048).refine((value) => {
1469
+ try {
1470
+ repositoryIdentity(value);
1471
+ return true;
1472
+ } catch {
1473
+ return false;
1474
+ }
1475
+ }, "An explicit repository URL without credentials is required"),
1476
+ checkoutRemote: z3.string().max(64).regex(/^[A-Za-z0-9][A-Za-z0-9._-]*$/),
1477
+ acquisition: z3.enum(["local-only", "fetch"]),
1478
+ target: GitInput,
1479
+ sources: z3.array(GitInput.extend({ item: z3.string().min(1).max(512) }).strict()).max(256)
1480
+ }).strict();
1481
+
1444
1482
  // src/git/operations.ts
1445
1483
  var GitOperations = class {
1446
1484
  constructor(workingDir = process.cwd()) {
@@ -1539,38 +1577,46 @@ var GitOperations = class {
1539
1577
  const branchName = item.name;
1540
1578
  const premergeLog = await this.git.log(["-1"]);
1541
1579
  previousHead = premergeLog.latest?.hash || "HEAD";
1542
- const branches = await this.git.branch(["-a"]);
1543
- const branchExists = branches.all.some(
1544
- (branch) => branch === branchName || branch === `origin/${branchName}` || branch === `remotes/origin/${branchName}`
1545
- );
1546
- if (!branchExists) {
1547
- profiler.end(operationId);
1548
- metrics.incrementCounter(METRICS.MERGE_FAILURE_TOTAL, { reason: "branch_not_found" });
1549
- return {
1550
- success: false,
1551
- item,
1552
- message: `Branch ${branchName} not found`
1553
- };
1580
+ let sourceRef = `origin/${branchName}`;
1581
+ if (operation.sourceCommit !== void 0) {
1582
+ sourceRef = GitCommitId.parse(operation.sourceCommit);
1583
+ if ((await this.git.raw(["cat-file", "-t", sourceRef])).trim() !== "commit") {
1584
+ throw new Error("Frozen merge source is not a commit object");
1585
+ }
1586
+ } else {
1587
+ const branches = await this.git.branch(["-a"]);
1588
+ const branchExists = branches.all.some(
1589
+ (branch) => branch === branchName || branch === `origin/${branchName}` || branch === `remotes/origin/${branchName}`
1590
+ );
1591
+ if (!branchExists) {
1592
+ profiler.end(operationId);
1593
+ metrics.incrementCounter(METRICS.MERGE_FAILURE_TOTAL, { reason: "branch_not_found" });
1594
+ return {
1595
+ success: false,
1596
+ item,
1597
+ message: `Branch ${branchName} not found`
1598
+ };
1599
+ }
1600
+ await this.git.fetch("origin", branchName);
1554
1601
  }
1555
- await this.git.fetch("origin", branchName);
1556
1602
  let gitMergeResult;
1557
1603
  let sha;
1558
1604
  let mergeError = null;
1559
1605
  try {
1560
1606
  switch (strategy) {
1561
1607
  case "merge-weave":
1562
- gitMergeResult = await this.git.merge([`origin/${branchName}`, "--no-ff"]);
1608
+ gitMergeResult = await this.git.merge([sourceRef, "--no-ff"]);
1563
1609
  break;
1564
1610
  case "squash-weave":
1565
- gitMergeResult = await this.git.merge([`origin/${branchName}`, "--squash"]);
1611
+ gitMergeResult = await this.git.merge([sourceRef, "--squash"]);
1566
1612
  if (gitMergeResult && !gitMergeResult.failed) {
1567
1613
  await this.git.commit(`Squash merge: ${item.name}`);
1568
1614
  }
1569
1615
  break;
1570
1616
  case "rebase-weave":
1571
1617
  try {
1572
- await this.git.rebase([`origin/${branchName}`]);
1573
- gitMergeResult = await this.git.merge([`origin/${branchName}`, "--ff-only"]);
1618
+ await this.git.rebase([sourceRef]);
1619
+ gitMergeResult = await this.git.merge([sourceRef, "--ff-only"]);
1574
1620
  } catch (rebaseError) {
1575
1621
  const conflictedFiles2 = await this.getConflictedFiles();
1576
1622
  profiler.end(operationId);
@@ -1690,6 +1736,9 @@ var GitOperations = class {
1690
1736
  * Execute merge pyramid with dependency ordering
1691
1737
  */
1692
1738
  async executeWeave(plan, levels, progressReporter) {
1739
+ if (plan.gitInputs) {
1740
+ throw new Error("Frozen Git inputs require the shared merge application/resume service");
1741
+ }
1693
1742
  const results = [];
1694
1743
  let successful = 0;
1695
1744
  let failed = 0;
@@ -2115,7 +2164,7 @@ function validateGateInput(gateName, input) {
2115
2164
  }
2116
2165
 
2117
2166
  // src/runs/failures.ts
2118
- import { z as z3 } from "zod";
2167
+ import { z as z4 } from "zod";
2119
2168
 
2120
2169
  // src/runs/storage.ts
2121
2170
  import * as fs6 from "fs";
@@ -2280,57 +2329,57 @@ var RETRYABLE_ERROR_CODES = /* @__PURE__ */ new Set([
2280
2329
  FailureErrorCode.NETWORK_ERROR,
2281
2330
  FailureErrorCode.RATE_LIMITED
2282
2331
  ]);
2283
- var FailureErrorSchema = z3.object({
2332
+ var FailureErrorSchema = z4.object({
2284
2333
  /** Error code for classification */
2285
- code: z3.string(),
2334
+ code: z4.string(),
2286
2335
  /** Human-readable error message */
2287
- message: z3.string(),
2336
+ message: z4.string(),
2288
2337
  /** Whether the error is retryable */
2289
- retryable: z3.boolean(),
2338
+ retryable: z4.boolean(),
2290
2339
  /** Optional hint for recovery */
2291
- hint: z3.string().optional()
2340
+ hint: z4.string().optional()
2292
2341
  });
2293
- var RecommendedActionSchema = z3.object({
2342
+ var RecommendedActionSchema = z4.object({
2294
2343
  /** Action identifier */
2295
- action: z3.string(),
2344
+ action: z4.string(),
2296
2345
  /** Action description */
2297
- description: z3.string(),
2346
+ description: z4.string(),
2298
2347
  /** Whether this action requires LLM decision */
2299
- requiresLLMDecision: z3.boolean().optional(),
2348
+ requiresLLMDecision: z4.boolean().optional(),
2300
2349
  /** Prompt for LLM decision */
2301
- prompt: z3.string().optional(),
2350
+ prompt: z4.string().optional(),
2302
2351
  /** JSON schema for response */
2303
- responseSchema: z3.record(z3.string(), z3.unknown()).optional(),
2352
+ responseSchema: z4.record(z4.string(), z4.unknown()).optional(),
2304
2353
  /** Risk level assessment */
2305
- riskLevel: z3.enum(["low", "medium", "high"]).optional()
2354
+ riskLevel: z4.enum(["low", "medium", "high"]).optional()
2306
2355
  });
2307
- var FailureRecordSchema = z3.object({
2356
+ var FailureRecordSchema = z4.object({
2308
2357
  /** ISO 8601 timestamp */
2309
- timestamp: z3.string(),
2358
+ timestamp: z4.string(),
2310
2359
  /** Run identifier */
2311
- runId: z3.string(),
2360
+ runId: z4.string(),
2312
2361
  /** Gate name that failed */
2313
- gate: z3.string(),
2362
+ gate: z4.string(),
2314
2363
  /** Structured error information */
2315
2364
  error: FailureErrorSchema,
2316
2365
  /** Whether the error was retryable */
2317
- retryable: z3.boolean(),
2366
+ retryable: z4.boolean(),
2318
2367
  /** Action taken to handle the failure */
2319
- actionTaken: z3.string().optional(),
2368
+ actionTaken: z4.string().optional(),
2320
2369
  /** Rationale for the action taken */
2321
- rationale: z3.string().optional(),
2370
+ rationale: z4.string().optional(),
2322
2371
  /** Exit code from gate execution */
2323
- exitCode: z3.number().optional(),
2372
+ exitCode: z4.number().optional(),
2324
2373
  /** Duration in milliseconds */
2325
- duration_ms: z3.number().optional()
2374
+ duration_ms: z4.number().optional()
2326
2375
  });
2327
- var FailureHandlingPayloadSchema = z3.object({
2376
+ var FailureHandlingPayloadSchema = z4.object({
2328
2377
  /** Structured error information */
2329
2378
  error: FailureErrorSchema,
2330
2379
  /** Recommended actions for recovery */
2331
- recommendedActions: z3.array(RecommendedActionSchema),
2380
+ recommendedActions: z4.array(RecommendedActionSchema),
2332
2381
  /** Schema for failure record logging */
2333
- failureRecordSchema: z3.record(z3.string(), z3.unknown()).optional()
2382
+ failureRecordSchema: z4.record(z4.string(), z4.unknown()).optional()
2334
2383
  });
2335
2384
  function classifyGateError(gateName, stderr, exitCode, isFlaky) {
2336
2385
  const errorMessage = stderr.toLowerCase();
@@ -2565,17 +2614,17 @@ function emitGateReceipt(gateName, itemName, passed, duration, runId, options =
2565
2614
  }
2566
2615
 
2567
2616
  // src/hostility/score.ts
2568
- import { z as z4 } from "zod";
2569
- var HostilityComponentSchema = z4.object({
2570
- score: z4.number().min(0).max(1),
2571
- status: z4.enum(["good", "warning", "critical"]),
2572
- details: z4.string(),
2573
- recommendation: z4.string().optional()
2617
+ import { z as z5 } from "zod";
2618
+ var HostilityComponentSchema = z5.object({
2619
+ score: z5.number().min(0).max(1),
2620
+ status: z5.enum(["good", "warning", "critical"]),
2621
+ details: z5.string(),
2622
+ recommendation: z5.string().optional()
2574
2623
  });
2575
- var HostilityScoreSchema = z4.object({
2576
- total: z4.number().min(0).max(1),
2577
- status: z4.enum(["low", "medium", "high"]),
2578
- components: z4.object({
2624
+ var HostilityScoreSchema = z5.object({
2625
+ total: z5.number().min(0).max(1),
2626
+ status: z5.enum(["low", "medium", "high"]),
2627
+ components: z5.object({
2579
2628
  constraintClarity: HostilityComponentSchema,
2580
2629
  requirementExplicitness: HostilityComponentSchema,
2581
2630
  problemBoundedness: HostilityComponentSchema,
@@ -2584,7 +2633,7 @@ var HostilityScoreSchema = z4.object({
2584
2633
  stateCoherence: HostilityComponentSchema,
2585
2634
  modelContinuity: HostilityComponentSchema
2586
2635
  }),
2587
- recommendations: z4.array(z4.string())
2636
+ recommendations: z5.array(z5.string())
2588
2637
  });
2589
2638
  var COMPONENT_LABELS = {
2590
2639
  constraintClarity: "Constraint Clarity",
@@ -3220,29 +3269,29 @@ import {
3220
3269
  writeFileSync as writeFileSync5
3221
3270
  } from "fs";
3222
3271
  import { basename as basename2, delimiter, dirname, extname, isAbsolute as isAbsolute2, join as join9, resolve as resolve5 } from "path";
3223
- import { z as z8 } from "zod";
3272
+ import { z as z9 } from "zod";
3224
3273
 
3225
3274
  // src/schema.ts
3226
- import { z as z6 } from "zod";
3275
+ import { z as z7 } from "zod";
3227
3276
 
3228
3277
  // src/tiers/schema.ts
3229
- import { z as z5 } from "zod";
3230
- var CapabilityTier = z5.enum(["senior", "mid", "junior"]);
3231
- var TierAssignment = z5.object({
3278
+ import { z as z6 } from "zod";
3279
+ var CapabilityTier = z6.enum(["senior", "mid", "junior"]);
3280
+ var TierAssignment = z6.object({
3232
3281
  /** Suggested tier based on heuristics */
3233
3282
  suggested: CapabilityTier,
3234
3283
  /** Actual tier used during execution (may differ due to override) */
3235
3284
  actual: CapabilityTier.optional(),
3236
3285
  /** Whether the task was escalated to a higher tier */
3237
- escalated: z5.boolean().default(false),
3286
+ escalated: z6.boolean().default(false),
3238
3287
  /** Reason for escalation if applicable */
3239
- escalationReason: z5.string().optional(),
3288
+ escalationReason: z6.string().optional(),
3240
3289
  /** Whether actual tier differs from suggested tier */
3241
- mismatch: z5.boolean().optional()
3290
+ mismatch: z6.boolean().optional()
3242
3291
  });
3243
- var TierOverride = z5.object({
3292
+ var TierOverride = z6.object({
3244
3293
  /** Item name to override */
3245
- itemName: z5.string(),
3294
+ itemName: z6.string(),
3246
3295
  /** Tier to assign */
3247
3296
  tier: CapabilityTier
3248
3297
  });
@@ -3274,38 +3323,38 @@ function parseTierOverrides(overrides) {
3274
3323
  }
3275
3324
 
3276
3325
  // src/schema.ts
3277
- var GateStatus = z6.enum(["pass", "fail", "blocked", "skipped", "retrying"]);
3278
- var NodeStatus = z6.enum(["pass", "fail", "blocked", "skipped", "retrying"]);
3279
- var GateResult = z6.object({
3280
- gate: z6.string(),
3326
+ var GateStatus = z7.enum(["pass", "fail", "blocked", "skipped", "retrying"]);
3327
+ var NodeStatus = z7.enum(["pass", "fail", "blocked", "skipped", "retrying"]);
3328
+ var GateResult = z7.object({
3329
+ gate: z7.string(),
3281
3330
  status: GateStatus,
3282
- exitCode: z6.number().optional(),
3283
- duration: z6.number().optional(),
3331
+ exitCode: z7.number().optional(),
3332
+ duration: z7.number().optional(),
3284
3333
  // milliseconds
3285
- timeoutMs: z6.number().int().positive().optional(),
3334
+ timeoutMs: z7.number().int().positive().optional(),
3286
3335
  // effective timeout used for this gate
3287
- stdout: z6.string().optional(),
3288
- stderr: z6.string().optional(),
3289
- failureKind: z6.enum(["nonzero_exit", "spawn_error", "timeout", "evidence_error"]).optional(),
3290
- timeoutCleanup: z6.object({
3291
- method: z6.enum(["process-group", "taskkill", "direct-child"]),
3292
- forceKilled: z6.boolean(),
3293
- descendantsReaped: z6.boolean()
3336
+ stdout: z7.string().optional(),
3337
+ stderr: z7.string().optional(),
3338
+ failureKind: z7.enum(["nonzero_exit", "spawn_error", "timeout", "evidence_error"]).optional(),
3339
+ timeoutCleanup: z7.object({
3340
+ method: z7.enum(["process-group", "taskkill", "direct-child"]),
3341
+ forceKilled: z7.boolean(),
3342
+ descendantsReaped: z7.boolean()
3294
3343
  }).optional(),
3295
- artifacts: z6.array(z6.string()).optional(),
3296
- attempts: z6.number().default(1),
3297
- lastAttempt: z6.string().optional()
3344
+ artifacts: z7.array(z7.string()).optional(),
3345
+ attempts: z7.number().default(1),
3346
+ lastAttempt: z7.string().optional()
3298
3347
  // ISO timestamp
3299
3348
  });
3300
- var NodeResult = z6.object({
3301
- name: z6.string(),
3349
+ var NodeResult = z7.object({
3350
+ name: z7.string(),
3302
3351
  status: NodeStatus,
3303
- gates: z6.array(GateResult).default([]),
3304
- blockedBy: z6.array(z6.string()).optional(),
3352
+ gates: z7.array(GateResult).default([]),
3353
+ blockedBy: z7.array(z7.string()).optional(),
3305
3354
  // names of nodes that blocked this one
3306
- eligibleForMerge: z6.boolean().default(false)
3355
+ eligibleForMerge: z7.boolean().default(false)
3307
3356
  });
3308
- var SchemaVersion = z6.string().regex(/^1\.\d+\.\d+$/, "Schema version must be 1.x.y format");
3357
+ var SchemaVersion = z7.string().regex(/^1\.\d+\.\d+$/, "Schema version must be 1.x.y format");
3309
3358
  function validateSchemaVersion(version) {
3310
3359
  const parsed = SchemaVersion.safeParse(version);
3311
3360
  if (!parsed.success) {
@@ -3324,30 +3373,30 @@ function validateSchemaVersion(version) {
3324
3373
  throw new AXErrorException(axError.code, axError.message, axError.nextActions, axError.context);
3325
3374
  }
3326
3375
  }
3327
- var RetryConfig = z6.object({
3328
- maxAttempts: z6.number().int().min(1).default(1),
3329
- backoffSeconds: z6.number().min(0).default(0)
3376
+ var RetryConfig = z7.object({
3377
+ maxAttempts: z7.number().int().min(1).default(1),
3378
+ backoffSeconds: z7.number().min(0).default(0)
3330
3379
  });
3331
- var AdminOverride = z6.object({
3332
- allowedUsers: z6.array(z6.string()).optional(),
3333
- requireReason: z6.boolean().default(false)
3380
+ var AdminOverride = z7.object({
3381
+ allowedUsers: z7.array(z7.string()).optional(),
3382
+ requireReason: z7.boolean().default(false)
3334
3383
  });
3335
- var MergeRule = z6.object({
3336
- type: z6.enum(["strict-required"]).default("strict-required")
3384
+ var MergeRule = z7.object({
3385
+ type: z7.enum(["strict-required"]).default("strict-required")
3337
3386
  // Future: could add "best-effort", "admin-override-allowed", etc.
3338
3387
  });
3339
- var PerformanceConfig = z6.object({
3340
- maxMemoryMB: z6.number().int().min(128).optional(),
3388
+ var PerformanceConfig = z7.object({
3389
+ maxMemoryMB: z7.number().int().min(128).optional(),
3341
3390
  // Memory limit in MB
3342
- batchSize: z6.number().int().min(1).default(50),
3391
+ batchSize: z7.number().int().min(1).default(50),
3343
3392
  // Batch size for large plans
3344
- cacheTTLSeconds: z6.number().int().min(0).default(3600),
3393
+ cacheTTLSeconds: z7.number().int().min(0).default(3600),
3345
3394
  // Cache TTL in seconds
3346
- enableCaching: z6.boolean().default(true),
3395
+ enableCaching: z7.boolean().default(true),
3347
3396
  // Enable operation caching
3348
- throttleOnMemory: z6.boolean().default(true),
3397
+ throttleOnMemory: z7.boolean().default(true),
3349
3398
  // Throttle workers when memory high
3350
- memoryThresholdPercent: z6.number().min(0).max(100).default(80)
3399
+ memoryThresholdPercent: z7.number().min(0).max(100).default(80)
3351
3400
  // Memory threshold %
3352
3401
  }).default(() => ({
3353
3402
  batchSize: 50,
@@ -3356,73 +3405,84 @@ var PerformanceConfig = z6.object({
3356
3405
  throttleOnMemory: true,
3357
3406
  memoryThresholdPercent: 80
3358
3407
  }));
3359
- var VulnPolicy = z6.object({
3360
- blockCritical: z6.boolean().default(true),
3361
- blockHigh: z6.boolean().default(true),
3362
- maxMedium: z6.number().int().min(0).default(5),
3363
- maxLow: z6.number().int().min(0).default(10)
3408
+ var VulnPolicy = z7.object({
3409
+ blockCritical: z7.boolean().default(true),
3410
+ blockHigh: z7.boolean().default(true),
3411
+ maxMedium: z7.number().int().min(0).default(5),
3412
+ maxLow: z7.number().int().min(0).default(10)
3364
3413
  }).default(() => ({
3365
3414
  blockCritical: true,
3366
3415
  blockHigh: true,
3367
3416
  maxMedium: 5,
3368
3417
  maxLow: 10
3369
3418
  }));
3370
- var Policy = z6.object({
3371
- requiredGates: z6.array(z6.string()).default([]),
3372
- optionalGates: z6.array(z6.string()).default([]),
3373
- maxWorkers: z6.number().int().min(1).default(1),
3374
- retries: z6.record(z6.string(), RetryConfig).default(() => ({})),
3375
- overrides: z6.object({
3419
+ var Policy = z7.object({
3420
+ requiredGates: z7.array(z7.string()).default([]),
3421
+ optionalGates: z7.array(z7.string()).default([]),
3422
+ maxWorkers: z7.number().int().min(1).default(1),
3423
+ retries: z7.record(z7.string(), RetryConfig).default(() => ({})),
3424
+ overrides: z7.object({
3376
3425
  adminGreen: AdminOverride.optional()
3377
3426
  }).default(() => ({})),
3378
- blockOn: z6.array(z6.string()).default([]),
3427
+ blockOn: z7.array(z7.string()).default([]),
3379
3428
  mergeRule: MergeRule.default({ type: "strict-required" }),
3380
3429
  performance: PerformanceConfig.optional(),
3381
3430
  // Performance tuning options
3382
3431
  security: VulnPolicy.optional()
3383
3432
  // Security/vulnerability thresholds for vuln gate
3384
3433
  });
3385
- var ContainerMount = z6.object({
3386
- source: z6.string(),
3387
- target: z6.string(),
3388
- type: z6.enum(["bind", "volume"]).default("bind")
3434
+ var ContainerMount = z7.object({
3435
+ source: z7.string(),
3436
+ target: z7.string(),
3437
+ type: z7.enum(["bind", "volume"]).default("bind")
3389
3438
  });
3390
- var ContainerSpec = z6.object({
3391
- image: z6.string(),
3392
- entrypoint: z6.array(z6.string()).optional(),
3393
- mounts: z6.array(ContainerMount).optional()
3439
+ var ContainerSpec = z7.object({
3440
+ image: z7.string(),
3441
+ entrypoint: z7.array(z7.string()).optional(),
3442
+ mounts: z7.array(ContainerMount).optional()
3394
3443
  });
3395
- var Gate = z6.object({
3396
- name: z6.string(),
3397
- run: z6.string(),
3398
- cwd: z6.string().optional(),
3399
- env: z6.record(z6.string(), z6.string()).default(() => ({})),
3444
+ var Gate = z7.object({
3445
+ name: z7.string(),
3446
+ run: z7.string(),
3447
+ cwd: z7.string().optional(),
3448
+ env: z7.record(z7.string(), z7.string()).default(() => ({})),
3400
3449
  // Runtime configuration
3401
- runtime: z6.enum(["local", "container", "ci-service"]).default("local"),
3450
+ runtime: z7.enum(["local", "container", "ci-service"]).default("local"),
3402
3451
  // Container spec (only used when runtime is "container")
3403
3452
  container: ContainerSpec.optional(),
3404
3453
  // Expected artifact paths (for output collection)
3405
- artifacts: z6.array(z6.string()).default([]),
3454
+ artifacts: z7.array(z7.string()).default([]),
3406
3455
  // Optional input data for gates that require structured inputs (validated against gate-specific schemas)
3407
- input: z6.record(z6.string(), z6.unknown()).optional(),
3456
+ input: z7.record(z7.string(), z7.unknown()).optional(),
3408
3457
  // Exact per-gate timeout. Overrides the operation default after hostility adjustment.
3409
- timeoutMs: z6.number().int().positive().max(24 * 60 * 60 * 1e3).optional()
3458
+ timeoutMs: z7.number().int().positive().max(24 * 60 * 60 * 1e3).optional()
3410
3459
  }).strict();
3411
- var PlanItem = z6.object({
3412
- name: z6.string(),
3413
- deps: z6.string().array().default([]),
3460
+ var PlanItem = z7.object({
3461
+ name: z7.string(),
3462
+ deps: z7.string().array().default([]),
3414
3463
  // Dependency references by item name
3415
- gates: z6.array(Gate).default([]),
3464
+ gates: z7.array(Gate).default([]),
3416
3465
  // Tier routing for governance (optional - added during plan generation or execution)
3417
3466
  tier: TierAssignment.optional()
3418
3467
  }).strict();
3419
- var Plan = z6.object({
3468
+ var Plan = z7.object({
3420
3469
  schemaVersion: SchemaVersion,
3421
- target: z6.string().default("main"),
3470
+ target: z7.string().default("main"),
3422
3471
  policy: Policy.optional(),
3423
- items: z6.array(PlanItem).default([])
3472
+ items: z7.array(PlanItem).default([]),
3473
+ gitInputs: FrozenGitInputs.optional()
3424
3474
  }).strict().superRefine((plan, context) => {
3425
3475
  const itemNames = /* @__PURE__ */ new Set();
3476
+ if (plan.gitInputs) {
3477
+ const sources = plan.gitInputs.sources.map((source) => source.item);
3478
+ if (plan.gitInputs.target.ref !== `refs/heads/${plan.target}` || new Set(sources).size !== sources.length || sources.length !== plan.items.length || plan.items.some((item) => !sources.includes(item.name))) {
3479
+ context.addIssue({
3480
+ code: "custom",
3481
+ path: ["gitInputs"],
3482
+ message: "Git inputs must bind the target and every plan item exactly once"
3483
+ });
3484
+ }
3485
+ }
3426
3486
  let duplicateItemNameFound = false;
3427
3487
  const duplicateGateNameItemIndexes = [];
3428
3488
  for (const [itemIndex, item] of plan.items.entries()) {
@@ -3647,7 +3707,7 @@ function loadPlan(planContent) {
3647
3707
 
3648
3708
  // src/schemas/task-contract.ts
3649
3709
  import { createHash } from "crypto";
3650
- import { z as z7 } from "zod";
3710
+ import { z as z8 } from "zod";
3651
3711
  var TASK_CONTRACT_VERSION = "1.0.0";
3652
3712
  function computeCanonicalHash(obj) {
3653
3713
  const canonical = JSON.stringify(obj, sortedReplacer);
@@ -3669,111 +3729,111 @@ function sortedReplacer(_key, value) {
3669
3729
  }
3670
3730
  return value;
3671
3731
  }
3672
- var DeterminismLevel = z7.enum(["D1", "D2", "D3"]);
3673
- var ConfidenceLevel2 = z7.enum(["high", "medium", "low"]);
3674
- var SourceOfTruthKind = z7.enum(["symbol", "file", "registry"]);
3675
- var AssumptionType = z7.enum(["scope", "codebase", "env", "intent", "dependency", "test"]);
3676
- var RepoRelativePath = z7.string().refine((p) => !p.startsWith("/"), {
3732
+ var DeterminismLevel = z8.enum(["D1", "D2", "D3"]);
3733
+ var ConfidenceLevel2 = z8.enum(["high", "medium", "low"]);
3734
+ var SourceOfTruthKind = z8.enum(["symbol", "file", "registry"]);
3735
+ var AssumptionType = z8.enum(["scope", "codebase", "env", "intent", "dependency", "test"]);
3736
+ var RepoRelativePath = z8.string().refine((p) => !p.startsWith("/"), {
3677
3737
  message: "Path must be repo-relative (no leading slash)"
3678
3738
  }).refine((p) => !p.includes(":\\") && !p.includes(":/"), {
3679
3739
  message: "Path must not be absolute (no drive letters)"
3680
3740
  }).refine((p) => !p.startsWith(".."), {
3681
3741
  message: "Path must not escape repo root"
3682
3742
  });
3683
- var GlobPattern = z7.string().min(1);
3684
- var SHA256Hash = z7.string().regex(/^sha256:[a-f0-9]{64}$/, "Must be sha256:<64-hex-chars>");
3685
- var SHA256HashOrPlaceholder = z7.string().refine((h) => h.startsWith("sha256:"), {
3743
+ var GlobPattern = z8.string().min(1);
3744
+ var SHA256Hash = z8.string().regex(/^sha256:[a-f0-9]{64}$/, "Must be sha256:<64-hex-chars>");
3745
+ var SHA256HashOrPlaceholder = z8.string().refine((h) => h.startsWith("sha256:"), {
3686
3746
  message: "Must start with sha256:"
3687
3747
  });
3688
- var RepoProvenance = z7.object({
3748
+ var RepoProvenance = z8.object({
3689
3749
  /** Repository identifier (owner/name) */
3690
- id: z7.string().regex(/^[^/]+\/[^/]+$/, "Must be owner/repo format"),
3750
+ id: z8.string().regex(/^[^/]+\/[^/]+$/, "Must be owner/repo format"),
3691
3751
  /** Absolute path to repo root (engine-local, for resolution) */
3692
- root: z7.string(),
3752
+ root: z8.string(),
3693
3753
  /** Pinned commit SHA */
3694
- commit_sha: z7.string().min(7)
3754
+ commit_sha: z8.string().min(7)
3695
3755
  });
3696
- var ScopeBoundary = z7.object({
3756
+ var ScopeBoundary = z8.object({
3697
3757
  /** Globs for files agent can read */
3698
- read_globs: z7.array(GlobPattern),
3758
+ read_globs: z8.array(GlobPattern),
3699
3759
  /** Globs for files agent can modify */
3700
- write_globs: z7.array(GlobPattern),
3760
+ write_globs: z8.array(GlobPattern),
3701
3761
  /** Globs for files explicitly denied (always applied) */
3702
- deny_globs: z7.array(GlobPattern),
3762
+ deny_globs: z8.array(GlobPattern),
3703
3763
  /** Whether cross-repo operations are permitted */
3704
- cross_repo_allowed: z7.boolean()
3764
+ cross_repo_allowed: z8.boolean()
3705
3765
  });
3706
- var FailureEvidence = z7.object({
3766
+ var FailureEvidence = z8.object({
3707
3767
  /** Short error description */
3708
- message: z7.string(),
3768
+ message: z8.string(),
3709
3769
  /** Repo-relative path to failed file */
3710
3770
  file_rel: RepoRelativePath,
3711
3771
  /** Line number if available */
3712
- line: z7.number().int().positive().optional(),
3772
+ line: z8.number().int().positive().optional(),
3713
3773
  /** Actual test runner output snippet */
3714
- runner_output_snip: z7.string(),
3774
+ runner_output_snip: z8.string(),
3715
3775
  /** Code context around failure */
3716
- excerpt: z7.string().optional()
3776
+ excerpt: z8.string().optional()
3717
3777
  });
3718
- var HintEdit = z7.object({
3719
- find: z7.string(),
3720
- replace: z7.string()
3778
+ var HintEdit = z8.object({
3779
+ find: z8.string(),
3780
+ replace: z8.string()
3721
3781
  });
3722
- var Target = z7.object({
3782
+ var Target = z8.object({
3723
3783
  /** Repo-relative file path */
3724
3784
  path_rel: RepoRelativePath,
3725
3785
  /** Anchored code context (±N lines) */
3726
- hunk: z7.string(),
3786
+ hunk: z8.string(),
3727
3787
  /** SHA256 of hunk for drift detection */
3728
3788
  hunk_sha256: SHA256HashOrPlaceholder,
3729
3789
  /** Optional find/replace suggestion */
3730
3790
  hint_edit: HintEdit.optional()
3731
3791
  });
3732
- var IntroducingChange = z7.object({
3733
- commit_sha: z7.string().min(7),
3734
- diff_hunk: z7.string()
3792
+ var IntroducingChange = z8.object({
3793
+ commit_sha: z8.string().min(7),
3794
+ diff_hunk: z8.string()
3735
3795
  });
3736
- var SourceOfTruth = z7.object({
3796
+ var SourceOfTruth = z8.object({
3737
3797
  /** Kind of source */
3738
3798
  kind: SourceOfTruthKind,
3739
3799
  /** Repo-relative path */
3740
3800
  path_rel: RepoRelativePath,
3741
3801
  /** Repository ID (defaults to snapshot repo if omitted) */
3742
- repo_id: z7.string().optional(),
3802
+ repo_id: z8.string().optional(),
3743
3803
  /** Commit SHA (defaults to snapshot commit if omitted) */
3744
- commit_sha: z7.string().optional(),
3804
+ commit_sha: z8.string().optional(),
3745
3805
  /** Canonical excerpt */
3746
- excerpt: z7.string(),
3806
+ excerpt: z8.string(),
3747
3807
  /** Lexmap module ID if applicable */
3748
- lexmap_module_id: z7.string().optional(),
3808
+ lexmap_module_id: z8.string().optional(),
3749
3809
  /** Change that introduced this */
3750
3810
  introducing_change: IntroducingChange.optional()
3751
3811
  });
3752
- var VerificationExpectations = z7.object({
3812
+ var VerificationExpectations = z8.object({
3753
3813
  /** Command to run */
3754
- cmd: z7.string(),
3814
+ cmd: z8.string(),
3755
3815
  /** Expected results */
3756
- expect: z7.object({
3816
+ expect: z8.object({
3757
3817
  /** Expected exit code (usually 0) */
3758
- exit_code: z7.number().int(),
3818
+ exit_code: z8.number().int(),
3759
3819
  /** Strings that must appear in output */
3760
- must_include: z7.array(z7.string()).optional(),
3820
+ must_include: z8.array(z8.string()).optional(),
3761
3821
  /** Strings that must not appear */
3762
- must_not_include: z7.array(z7.string()).optional()
3822
+ must_not_include: z8.array(z8.string()).optional()
3763
3823
  })
3764
3824
  });
3765
- var Budget = z7.object({
3825
+ var Budget = z8.object({
3766
3826
  /** Token budget hint in bytes */
3767
- max_bytes: z7.number().int().positive().optional(),
3827
+ max_bytes: z8.number().int().positive().optional(),
3768
3828
  /** Fields that were truncated (empty if none) */
3769
- truncated_fields: z7.array(z7.string())
3829
+ truncated_fields: z8.array(z8.string())
3770
3830
  });
3771
- var TaskSnapshot_v1 = z7.object({
3831
+ var TaskSnapshot_v1 = z8.object({
3772
3832
  // Schema version
3773
- schema_version: z7.literal(TASK_CONTRACT_VERSION),
3833
+ schema_version: z8.literal(TASK_CONTRACT_VERSION),
3774
3834
  // Identity
3775
- task_id: z7.string().min(1),
3776
- procedure: z7.string().min(1),
3835
+ task_id: z8.string().min(1),
3836
+ procedure: z8.string().min(1),
3777
3837
  determinism: DeterminismLevel,
3778
3838
  snapshot_hash: SHA256HashOrPlaceholder,
3779
3839
  // Provenance (MUST)
@@ -3783,9 +3843,9 @@ var TaskSnapshot_v1 = z7.object({
3783
3843
  // Failure evidence (MUST)
3784
3844
  failure: FailureEvidence,
3785
3845
  // Invariants (SHOULD) - anti-brittleness constraints
3786
- invariants: z7.array(z7.string()).optional(),
3846
+ invariants: z8.array(z8.string()).optional(),
3787
3847
  // Targets (MUST, array)
3788
- targets: z7.array(Target).min(1),
3848
+ targets: z8.array(Target).min(1),
3789
3849
  // Source of truth (SHOULD)
3790
3850
  source_of_truth: SourceOfTruth.optional(),
3791
3851
  // Verification expectations (MUST)
@@ -3793,183 +3853,183 @@ var TaskSnapshot_v1 = z7.object({
3793
3853
  // Budget/truncation (MUST)
3794
3854
  budget: Budget,
3795
3855
  // Output contract
3796
- receipt_schema_id: z7.string()
3856
+ receipt_schema_id: z8.string()
3797
3857
  });
3798
- var StructuredAssumption = z7.object({
3858
+ var StructuredAssumption = z8.object({
3799
3859
  /** Type of assumption */
3800
3860
  type: AssumptionType,
3801
3861
  /** Assumption text */
3802
- text: z7.string(),
3862
+ text: z8.string(),
3803
3863
  /** Whether it was validated */
3804
- validated: z7.boolean().optional(),
3864
+ validated: z8.boolean().optional(),
3805
3865
  /** Evidence supporting validation */
3806
- evidence: z7.string().optional()
3866
+ evidence: z8.string().optional()
3807
3867
  });
3808
- var AgentClaims = z7.object({
3868
+ var AgentClaims = z8.object({
3809
3869
  /** Whether the task succeeded */
3810
- success: z7.boolean(),
3870
+ success: z8.boolean(),
3811
3871
  /** Unified diff patch */
3812
- patch: z7.string().optional(),
3872
+ patch: z8.string().optional(),
3813
3873
  /** Files touched (repo-relative) */
3814
- files_touched: z7.array(RepoRelativePath),
3874
+ files_touched: z8.array(RepoRelativePath),
3815
3875
  /** Rationale for the fix */
3816
- rationale: z7.string(),
3876
+ rationale: z8.string(),
3817
3877
  /** Confidence level */
3818
3878
  confidence: ConfidenceLevel2,
3819
3879
  /** Which invariants were respected */
3820
- invariants_respected: z7.array(z7.string()).optional(),
3880
+ invariants_respected: z8.array(z8.string()).optional(),
3821
3881
  /** Structured assumptions made */
3822
- assumptions_made: z7.array(StructuredAssumption)
3882
+ assumptions_made: z8.array(StructuredAssumption)
3823
3883
  });
3824
- var SearchActivity = z7.object({
3884
+ var SearchActivity = z8.object({
3825
3885
  /** Search query */
3826
- query: z7.string(),
3886
+ query: z8.string(),
3827
3887
  /** Search method used */
3828
- method: z7.string().optional(),
3888
+ method: z8.string().optional(),
3829
3889
  /** Roots searched (repo-relative) */
3830
- roots: z7.array(z7.string()),
3890
+ roots: z8.array(z8.string()),
3831
3891
  /** Number of results found */
3832
- results_count: z7.number().int().nonnegative().optional(),
3892
+ results_count: z8.number().int().nonnegative().optional(),
3833
3893
  /** Time taken in milliseconds */
3834
- time_ms: z7.number().nonnegative().optional()
3894
+ time_ms: z8.number().nonnegative().optional()
3835
3895
  });
3836
- var TokenUsage = z7.object({
3837
- input: z7.number().int().nonnegative(),
3838
- output: z7.number().int().nonnegative(),
3839
- total: z7.number().int().nonnegative()
3896
+ var TokenUsage = z8.object({
3897
+ input: z8.number().int().nonnegative(),
3898
+ output: z8.number().int().nonnegative(),
3899
+ total: z8.number().int().nonnegative()
3840
3900
  });
3841
- var CostTracking = z7.object({
3901
+ var CostTracking = z8.object({
3842
3902
  /** Token usage breakdown */
3843
3903
  token_usage: TokenUsage.optional(),
3844
3904
  /** Number of tool calls made */
3845
- tool_calls_count: z7.number().int().nonnegative().optional(),
3905
+ tool_calls_count: z8.number().int().nonnegative().optional(),
3846
3906
  /** Elapsed time in milliseconds */
3847
- elapsed_ms: z7.number().nonnegative().optional()
3907
+ elapsed_ms: z8.number().nonnegative().optional()
3848
3908
  });
3849
- var AgentVerification = z7.object({
3909
+ var AgentVerification = z8.object({
3850
3910
  /** Whether verification command was run */
3851
- cmd_ran: z7.boolean(),
3911
+ cmd_ran: z8.boolean(),
3852
3912
  /** Exit code if run */
3853
- exit_code: z7.number().int().optional(),
3913
+ exit_code: z8.number().int().optional(),
3854
3914
  /** Output snippet */
3855
- output_snip: z7.string().optional()
3915
+ output_snip: z8.string().optional()
3856
3916
  });
3857
- var TaskReceipt_v1 = z7.object({
3917
+ var TaskReceipt_v1 = z8.object({
3858
3918
  // Schema version
3859
- schema_version: z7.literal(TASK_CONTRACT_VERSION),
3919
+ schema_version: z8.literal(TASK_CONTRACT_VERSION),
3860
3920
  // Identity (echo from snapshot)
3861
- task_id: z7.string().min(1),
3921
+ task_id: z8.string().min(1),
3862
3922
  snapshot_hash: SHA256HashOrPlaceholder,
3863
3923
  // Claims (what agent says it did)
3864
3924
  claims: AgentClaims,
3865
3925
  // Search activity (if agent searched)
3866
- search_activity: z7.array(SearchActivity),
3926
+ search_activity: z8.array(SearchActivity),
3867
3927
  // Cost tracking
3868
3928
  cost: CostTracking,
3869
3929
  // Agent's verification attempt (still a claim)
3870
3930
  agent_verification: AgentVerification.optional(),
3871
3931
  // Blockers (if not successful)
3872
- blockers: z7.array(z7.string())
3932
+ blockers: z8.array(z8.string())
3873
3933
  });
3874
- var DetectedFailure = z7.object({
3875
- type: z7.string(),
3876
- message: z7.string(),
3877
- file: z7.string().optional(),
3878
- line: z7.number().int().positive().optional()
3934
+ var DetectedFailure = z8.object({
3935
+ type: z8.string(),
3936
+ message: z8.string(),
3937
+ file: z8.string().optional(),
3938
+ line: z8.number().int().positive().optional()
3879
3939
  });
3880
- var EngineVerification_v1 = z7.object({
3940
+ var EngineVerification_v1 = z8.object({
3881
3941
  // Identity
3882
- task_id: z7.string().min(1),
3883
- timestamp: z7.string().datetime(),
3942
+ task_id: z8.string().min(1),
3943
+ timestamp: z8.string().datetime(),
3884
3944
  // Hash binding (audit trail)
3885
3945
  snapshot_hash: SHA256HashOrPlaceholder,
3886
3946
  receipt_hash: SHA256HashOrPlaceholder,
3887
3947
  // Verification result
3888
- verified: z7.boolean(),
3948
+ verified: z8.boolean(),
3889
3949
  // What engine ran
3890
- cmd_ran: z7.string(),
3891
- exit_code: z7.number().int(),
3892
- stdout_snip: z7.string(),
3893
- stderr_snip: z7.string(),
3950
+ cmd_ran: z8.string(),
3951
+ exit_code: z8.number().int(),
3952
+ stdout_snip: z8.string(),
3953
+ stderr_snip: z8.string(),
3894
3954
  // Patch verification
3895
3955
  patch_hash: SHA256HashOrPlaceholder.optional(),
3896
- patch_applied: z7.boolean(),
3956
+ patch_applied: z8.boolean(),
3897
3957
  // Comparison with agent claim
3898
- agent_claimed: z7.boolean(),
3899
- trust_gap: z7.boolean(),
3958
+ agent_claimed: z8.boolean(),
3959
+ trust_gap: z8.boolean(),
3900
3960
  // Failures detected
3901
- failures: z7.array(DetectedFailure)
3961
+ failures: z8.array(DetectedFailure)
3902
3962
  });
3903
3963
 
3904
3964
  // src/gates/execution-receipt.ts
3905
3965
  var GATE_EXECUTION_RECEIPT_SCHEMA_VERSION = "lexrunner-gate-execution-receipt/v2";
3906
3966
  var MAX_GATE_RECEIPT_OUTPUT_BYTES = 64 * 1024;
3907
- var FileIdentitySchema = z8.object({
3908
- path: z8.string(),
3909
- realPath: z8.string(),
3910
- bytes: z8.number().int().nonnegative(),
3911
- mtimeMs: z8.number().nonnegative(),
3912
- sha256: z8.string().regex(/^sha256:[a-f0-9]{64}$/u)
3967
+ var FileIdentitySchema = z9.object({
3968
+ path: z9.string(),
3969
+ realPath: z9.string(),
3970
+ bytes: z9.number().int().nonnegative(),
3971
+ mtimeMs: z9.number().nonnegative(),
3972
+ sha256: z9.string().regex(/^sha256:[a-f0-9]{64}$/u)
3913
3973
  }).strict();
3914
- var OutputEvidenceSchema = z8.object({
3915
- bytes: z8.number().int().nonnegative(),
3916
- sha256: z8.string().regex(/^sha256:[a-f0-9]{64}$/u),
3917
- truncated: z8.boolean(),
3918
- content: z8.string().max(MAX_GATE_RECEIPT_OUTPUT_BYTES)
3974
+ var OutputEvidenceSchema = z9.object({
3975
+ bytes: z9.number().int().nonnegative(),
3976
+ sha256: z9.string().regex(/^sha256:[a-f0-9]{64}$/u),
3977
+ truncated: z9.boolean(),
3978
+ content: z9.string().max(MAX_GATE_RECEIPT_OUTPUT_BYTES)
3919
3979
  }).strict();
3920
- var ArtifactIdentitySchema = z8.object({
3921
- declaredPath: z8.string(),
3922
- resolvedPath: z8.string(),
3923
- status: z8.enum(["collected", "missing", "stale", "unsupported", "collection_error"]),
3980
+ var ArtifactIdentitySchema = z9.object({
3981
+ declaredPath: z9.string(),
3982
+ resolvedPath: z9.string(),
3983
+ status: z9.enum(["collected", "missing", "stale", "unsupported", "collection_error"]),
3924
3984
  before: FileIdentitySchema.nullable(),
3925
3985
  source: FileIdentitySchema.nullable(),
3926
- retainedPath: z8.string().optional(),
3986
+ retainedPath: z9.string().optional(),
3927
3987
  retained: FileIdentitySchema.optional(),
3928
- error: z8.string().optional()
3988
+ error: z9.string().optional()
3929
3989
  }).strict();
3930
- var LocalGateExecutionReceiptSchema = z8.object({
3931
- schemaVersion: z8.literal(GATE_EXECUTION_RECEIPT_SCHEMA_VERSION),
3932
- attempt: z8.number().int().positive(),
3933
- binding: z8.object({
3934
- item: z8.string().min(1).nullable(),
3935
- declaredGateDigest: z8.string().regex(/^sha256:[a-f0-9]{64}$/u),
3936
- candidateDigest: z8.string().regex(/^sha256:[a-f0-9]{64}$/u).nullable(),
3937
- timeoutMs: z8.number().int().positive()
3990
+ var LocalGateExecutionReceiptSchema = z9.object({
3991
+ schemaVersion: z9.literal(GATE_EXECUTION_RECEIPT_SCHEMA_VERSION),
3992
+ attempt: z9.number().int().positive(),
3993
+ binding: z9.object({
3994
+ item: z9.string().min(1).nullable(),
3995
+ declaredGateDigest: z9.string().regex(/^sha256:[a-f0-9]{64}$/u),
3996
+ candidateDigest: z9.string().regex(/^sha256:[a-f0-9]{64}$/u).nullable(),
3997
+ timeoutMs: z9.number().int().positive()
3938
3998
  }).strict(),
3939
- declaredGate: z8.object({
3940
- name: z8.string(),
3941
- run: z8.string(),
3942
- cwd: z8.string().nullable(),
3943
- runtime: z8.enum(["local", "container", "ci-service"]),
3944
- artifacts: z8.array(z8.string())
3999
+ declaredGate: z9.object({
4000
+ name: z9.string(),
4001
+ run: z9.string(),
4002
+ cwd: z9.string().nullable(),
4003
+ runtime: z9.enum(["local", "container", "ci-service"]),
4004
+ artifacts: z9.array(z9.string())
3945
4005
  }).strict(),
3946
- execution: z8.object({
3947
- cwd: z8.string(),
3948
- startedAt: z8.string(),
3949
- finishedAt: z8.string(),
3950
- durationMs: z8.number().nonnegative(),
3951
- shell: z8.object({
3952
- command: z8.enum(["bash", "pwsh"]),
4006
+ execution: z9.object({
4007
+ cwd: z9.string(),
4008
+ startedAt: z9.string(),
4009
+ finishedAt: z9.string(),
4010
+ durationMs: z9.number().nonnegative(),
4011
+ shell: z9.object({
4012
+ command: z9.enum(["bash", "pwsh"]),
3953
4013
  executable: FileIdentitySchema.nullable(),
3954
- argv: z8.array(z8.string()),
4014
+ argv: z9.array(z9.string()),
3955
4015
  identityAfter: FileIdentitySchema.nullable(),
3956
- unchanged: z8.boolean(),
3957
- spawned: z8.boolean()
4016
+ unchanged: z9.boolean(),
4017
+ spawned: z9.boolean()
3958
4018
  }).strict()
3959
4019
  }).strict(),
3960
- outcome: z8.object({
3961
- status: z8.enum(["pass", "fail", "blocked", "skipped", "retrying"]),
3962
- exitCode: z8.number().int().nullable(),
3963
- failureKind: z8.enum(["nonzero_exit", "spawn_error", "timeout", "evidence_error"]).nullable(),
3964
- timeoutCleanup: z8.object({
3965
- method: z8.enum(["process-group", "taskkill", "direct-child"]),
3966
- forceKilled: z8.boolean(),
3967
- descendantsReaped: z8.boolean()
4020
+ outcome: z9.object({
4021
+ status: z9.enum(["pass", "fail", "blocked", "skipped", "retrying"]),
4022
+ exitCode: z9.number().int().nullable(),
4023
+ failureKind: z9.enum(["nonzero_exit", "spawn_error", "timeout", "evidence_error"]).nullable(),
4024
+ timeoutCleanup: z9.object({
4025
+ method: z9.enum(["process-group", "taskkill", "direct-child"]),
4026
+ forceKilled: z9.boolean(),
4027
+ descendantsReaped: z9.boolean()
3968
4028
  }).strict().nullable(),
3969
- evidenceComplete: z8.boolean()
4029
+ evidenceComplete: z9.boolean()
3970
4030
  }).strict(),
3971
- output: z8.object({ stdout: OutputEvidenceSchema, stderr: OutputEvidenceSchema }).strict(),
3972
- artifacts: z8.array(ArtifactIdentitySchema)
4031
+ output: z9.object({ stdout: OutputEvidenceSchema, stderr: OutputEvidenceSchema }).strict(),
4032
+ artifacts: z9.array(ArtifactIdentitySchema)
3973
4033
  }).strict();
3974
4034
  function parseLocalGateExecutionReceipt(value) {
3975
4035
  return LocalGateExecutionReceiptSchema.parse(value);
@@ -4377,7 +4437,7 @@ async function executeLocalGate(gate, artifactDir, attempt, startedAt, startTime
4377
4437
  });
4378
4438
  }
4379
4439
  try {
4380
- const { getCommandValidator } = await import("./commandValidator-LVEMJTZP.js");
4440
+ const { getCommandValidator } = await import("./commandValidator-XFVNCZXX.js");
4381
4441
  const validator = getCommandValidator();
4382
4442
  validator.validate(gate.run);
4383
4443
  } catch (validationError) {
@@ -6038,6 +6098,14 @@ var GitHubClientImpl = class {
6038
6098
  }
6039
6099
  return void 0;
6040
6100
  }
6101
+ async getBranchHead(branch) {
6102
+ const response = await this.octokit.rest.repos.getBranch({
6103
+ owner: this.owner,
6104
+ repo: this.repo,
6105
+ branch
6106
+ });
6107
+ return response.data.commit.sha;
6108
+ }
6041
6109
  async validateRepository() {
6042
6110
  try {
6043
6111
  const response = await this.octokit.rest.repos.get({
@@ -6704,6 +6772,8 @@ var AutopilotLevel4 = class extends AutopilotLevel3 {
6704
6772
 
6705
6773
  export {
6706
6774
  parseTierOverrides,
6775
+ repositoryIdentity,
6776
+ FrozenGitInputs,
6707
6777
  Policy,
6708
6778
  Plan,
6709
6779
  SchemaValidationError,