@smartergpt/lexrunner 2.0.1 → 2.1.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/BRAND.md +14 -0
- package/CHANGELOG.md +32 -0
- package/GOVERNANCE.md +18 -0
- package/LICENSE.md +201 -110
- package/NOTICE.md +12 -1
- package/README.md +13 -6
- package/dist/{api-QBPBKYOC.js → api-UIWVFU7M.js} +1 -1
- package/dist/{audit-SKMMC2U4.js → audit-HVB2HJPU.js} +2 -2
- package/dist/{autopilot-3OHEUTHD.js → autopilot-JWIOXBCZ.js} +2 -2
- package/dist/{chunk-6PZDSWCG.js → chunk-37UC53OG.js} +2 -2
- package/dist/{chunk-V3BU2VDU.js → chunk-PDDULIDL.js} +13 -1
- package/dist/{chunk-ARDKZW7F.js → chunk-SHSL643G.js} +2 -2
- package/dist/cli.cjs +990 -330
- package/dist/cli.d.ts +161 -7
- package/dist/cli.js +814 -173
- package/dist/{commandValidator-LVEMJTZP.js → commandValidator-XFVNCZXX.js} +1 -1
- package/dist/{constraints-2ZK5FJFA.js → constraints-LE2MW5NS.js} +1 -1
- package/dist/errors/index.js +1 -1
- package/dist/frames/index.js +1 -1
- package/dist/{gateMapping-R3RJYKMS.js → gateMapping-V4DTL5WD.js} +1 -1
- package/dist/hooks/events.js +1 -1
- package/dist/{jsonEnvelope-K2U5CWKU.js → jsonEnvelope-MXJM5ZQH.js} +1 -1
- package/dist/{mergeTreeSimulator-QCFSOU25.js → mergeTreeSimulator-GWZ77NF2.js} +1 -1
- package/dist/package-schemas/behavior-rule.js +1 -1
- package/dist/package-schemas/execution-plan-v1.js +1 -1
- package/dist/package-schemas/gates.js +1 -1
- package/dist/package-schemas/runner-scope.js +1 -1
- package/dist/package-schemas/runner-stack.js +1 -1
- package/dist/{planDiff-IHLFNZUT.js → planDiff-4D3AERAW.js} +1 -1
- package/dist/{planHistory-GLRI356L.js → planHistory-VPV4WDPW.js} +1 -1
- package/dist/{planReview-UUMCGZJ6.js → planReview-FV6INFLQ.js} +1 -1
- package/dist/{planViewer-TRSQVMH4.js → planViewer-WOV6A2HZ.js} +1 -1
- package/dist/{sarif-2C6RKOUX.js → sarif-QXVE3LYD.js} +1 -1
- package/dist/sdk/index.js +1 -1
- package/dist/{security-OE4VLUFK.js → security-W7TOUXSB.js} +1 -1
- package/dist/{signing-KLZYZZMP.js → signing-WGVPHJGG.js} +1 -1
- package/dist/{verify-3UVMA62I.js → verify-Y34CJAKB.js} +1 -1
- package/package.json +6 -4
package/dist/cli.js
CHANGED
|
@@ -24,7 +24,7 @@ import {
|
|
|
24
24
|
finalizeAudit,
|
|
25
25
|
initAuditEmitter,
|
|
26
26
|
redactSecrets
|
|
27
|
-
} from "./chunk-
|
|
27
|
+
} from "./chunk-37UC53OG.js";
|
|
28
28
|
import "./chunk-6KK5JFFE.js";
|
|
29
29
|
import {
|
|
30
30
|
simulateBatchMerges
|
|
@@ -83,7 +83,7 @@ import {
|
|
|
83
83
|
validateWriteOperation,
|
|
84
84
|
verifyToolchainPins,
|
|
85
85
|
writeRunState
|
|
86
|
-
} from "./chunk-
|
|
86
|
+
} from "./chunk-SHSL643G.js";
|
|
87
87
|
import {
|
|
88
88
|
ExecutionState,
|
|
89
89
|
generateMarkdownSummary,
|
|
@@ -135,9 +135,13 @@ import "./chunk-AXOAVRTU.js";
|
|
|
135
135
|
import {
|
|
136
136
|
__esm,
|
|
137
137
|
__export,
|
|
138
|
+
__privateAdd,
|
|
139
|
+
__privateGet,
|
|
140
|
+
__privateMethod,
|
|
141
|
+
__privateSet,
|
|
138
142
|
__require,
|
|
139
143
|
__toCommonJS
|
|
140
|
-
} from "./chunk-
|
|
144
|
+
} from "./chunk-PDDULIDL.js";
|
|
141
145
|
|
|
142
146
|
// src/metrics/export.ts
|
|
143
147
|
var export_exports = {};
|
|
@@ -470,7 +474,7 @@ import "dotenv/config";
|
|
|
470
474
|
// package.json
|
|
471
475
|
var package_default = {
|
|
472
476
|
name: "@smartergpt/lexrunner",
|
|
473
|
-
version: "2.0
|
|
477
|
+
version: "2.1.0",
|
|
474
478
|
type: "module",
|
|
475
479
|
engines: {
|
|
476
480
|
node: ">=24"
|
|
@@ -483,10 +487,10 @@ var package_default = {
|
|
|
483
487
|
url: "git+https://github.com/Guffawaffle/lexrunner.git"
|
|
484
488
|
},
|
|
485
489
|
publishConfig: {
|
|
486
|
-
access: "
|
|
490
|
+
access: "public",
|
|
487
491
|
registry: "https://registry.npmjs.org/"
|
|
488
492
|
},
|
|
489
|
-
license: "
|
|
493
|
+
license: "Apache-2.0",
|
|
490
494
|
files: [
|
|
491
495
|
"dist/",
|
|
492
496
|
"schemas/",
|
|
@@ -495,7 +499,9 @@ var package_default = {
|
|
|
495
499
|
"README.mcp.md",
|
|
496
500
|
"CHANGELOG.md",
|
|
497
501
|
"NOTICE.md",
|
|
498
|
-
"LICENSE.md"
|
|
502
|
+
"LICENSE.md",
|
|
503
|
+
"GOVERNANCE.md",
|
|
504
|
+
"BRAND.md"
|
|
499
505
|
],
|
|
500
506
|
bin: {
|
|
501
507
|
lexrunner: "dist/cli.js",
|
|
@@ -649,7 +655,7 @@ var package_default = {
|
|
|
649
655
|
// src/cli.ts
|
|
650
656
|
import { Command as Command6, CommanderError } from "commander";
|
|
651
657
|
import { fileURLToPath as fileURLToPath6 } from "url";
|
|
652
|
-
import { resolve as
|
|
658
|
+
import { resolve as resolve15 } from "path";
|
|
653
659
|
import chalk11 from "chalk";
|
|
654
660
|
|
|
655
661
|
// src/core/inputs.ts
|
|
@@ -1106,8 +1112,8 @@ function generateSnapshot(plan, inputs) {
|
|
|
1106
1112
|
}
|
|
1107
1113
|
function getPackageVersion() {
|
|
1108
1114
|
try {
|
|
1109
|
-
const
|
|
1110
|
-
const packageJson = JSON.parse(
|
|
1115
|
+
const fs51 = __require("fs");
|
|
1116
|
+
const packageJson = JSON.parse(fs51.readFileSync("package.json", "utf8"));
|
|
1111
1117
|
return packageJson.version || "unknown";
|
|
1112
1118
|
} catch {
|
|
1113
1119
|
return "unknown";
|
|
@@ -2432,10 +2438,10 @@ async function promptGitHubToken() {
|
|
|
2432
2438
|
input: process.stdin,
|
|
2433
2439
|
output: process.stdout
|
|
2434
2440
|
});
|
|
2435
|
-
return new Promise((
|
|
2441
|
+
return new Promise((resolve16) => {
|
|
2436
2442
|
rl.question("GitHub token (optional, press Enter to skip): ", (answer) => {
|
|
2437
2443
|
rl.close();
|
|
2438
|
-
|
|
2444
|
+
resolve16(answer.trim());
|
|
2439
2445
|
});
|
|
2440
2446
|
});
|
|
2441
2447
|
}
|
|
@@ -2639,6 +2645,7 @@ function installUnhandledRejectionHandler() {
|
|
|
2639
2645
|
}
|
|
2640
2646
|
|
|
2641
2647
|
// src/core/githubPlan.ts
|
|
2648
|
+
var STANDARD_TEST_GATE_TIMEOUT_MS = 5 * 60 * 1e3;
|
|
2642
2649
|
async function generatePlanFromGitHub(client, options = {}) {
|
|
2643
2650
|
const repoInfo = await client.validateRepository();
|
|
2644
2651
|
const target = options.target || repoInfo.defaultBranch;
|
|
@@ -2743,7 +2750,8 @@ function createStandardGate(gateName, pr) {
|
|
|
2743
2750
|
return {
|
|
2744
2751
|
...baseGate,
|
|
2745
2752
|
run: "npm test",
|
|
2746
|
-
artifacts: ["test-results.xml", "coverage/"]
|
|
2753
|
+
artifacts: ["test-results.xml", "coverage/"],
|
|
2754
|
+
timeoutMs: STANDARD_TEST_GATE_TIMEOUT_MS
|
|
2747
2755
|
};
|
|
2748
2756
|
case "typecheck":
|
|
2749
2757
|
return {
|
|
@@ -2792,6 +2800,7 @@ function validateGitHubDependencies(planItems, prDetails) {
|
|
|
2792
2800
|
}
|
|
2793
2801
|
|
|
2794
2802
|
// src/core/multiRepoPlan.ts
|
|
2803
|
+
var STANDARD_TEST_GATE_TIMEOUT_MS2 = 5 * 60 * 1e3;
|
|
2795
2804
|
async function generateMultiRepoPlan(repos, options = {}) {
|
|
2796
2805
|
if (repos.length === 0) {
|
|
2797
2806
|
throw new Error("At least one repository is required");
|
|
@@ -2928,7 +2937,8 @@ function generateGatesForMultiRepoPR(pr, options) {
|
|
|
2928
2937
|
REPO_NAME: pr.repoName
|
|
2929
2938
|
},
|
|
2930
2939
|
runtime: "local",
|
|
2931
|
-
artifacts: getGateArtifacts(gateName)
|
|
2940
|
+
artifacts: getGateArtifacts(gateName),
|
|
2941
|
+
...isStandardTestGate(gateName) ? { timeoutMs: STANDARD_TEST_GATE_TIMEOUT_MS2 } : {}
|
|
2932
2942
|
});
|
|
2933
2943
|
}
|
|
2934
2944
|
gates.sort((a, b) => a.name.localeCompare(b.name));
|
|
@@ -2938,6 +2948,7 @@ function getGateCommand(gateName) {
|
|
|
2938
2948
|
const commands = {
|
|
2939
2949
|
lint: "npm run lint",
|
|
2940
2950
|
test: "npm test",
|
|
2951
|
+
unit: "npm test",
|
|
2941
2952
|
typecheck: "npm run typecheck",
|
|
2942
2953
|
build: "npm run build"
|
|
2943
2954
|
};
|
|
@@ -2947,11 +2958,15 @@ function getGateArtifacts(gateName) {
|
|
|
2947
2958
|
const artifacts = {
|
|
2948
2959
|
lint: ["lint-results.txt"],
|
|
2949
2960
|
test: ["test-results.xml", "coverage/"],
|
|
2961
|
+
unit: ["test-results.xml", "coverage/"],
|
|
2950
2962
|
typecheck: ["typecheck-results.txt"],
|
|
2951
2963
|
build: ["dist/"]
|
|
2952
2964
|
};
|
|
2953
2965
|
return artifacts[gateName] || [];
|
|
2954
2966
|
}
|
|
2967
|
+
function isStandardTestGate(gateName) {
|
|
2968
|
+
return gateName === "test" || gateName === "unit";
|
|
2969
|
+
}
|
|
2955
2970
|
function createEmptyPlan(target, options) {
|
|
2956
2971
|
const plan = {
|
|
2957
2972
|
schemaVersion: "1.0.0",
|
|
@@ -3395,8 +3410,8 @@ function containedRegularFile(root, candidate) {
|
|
|
3395
3410
|
}
|
|
3396
3411
|
}
|
|
3397
3412
|
function isContained(root, candidate) {
|
|
3398
|
-
const
|
|
3399
|
-
return
|
|
3413
|
+
const relative5 = path8.relative(path8.resolve(root), path8.resolve(candidate));
|
|
3414
|
+
return relative5 !== ".." && !relative5.startsWith(`..${path8.sep}`) && !path8.isAbsolute(relative5);
|
|
3400
3415
|
}
|
|
3401
3416
|
function evidenceError(code, message) {
|
|
3402
3417
|
return new GateEvidenceServiceError(code, message);
|
|
@@ -4519,7 +4534,7 @@ function registerGateImportChecksCommand(program2) {
|
|
|
4519
4534
|
version: "1.0.0",
|
|
4520
4535
|
mappings: []
|
|
4521
4536
|
};
|
|
4522
|
-
const { DEFAULT_GATE_MAPPINGS } = await import("./gateMapping-
|
|
4537
|
+
const { DEFAULT_GATE_MAPPINGS } = await import("./gateMapping-V4DTL5WD.js");
|
|
4523
4538
|
mappingConfig.mappings = DEFAULT_GATE_MAPPINGS;
|
|
4524
4539
|
}
|
|
4525
4540
|
let githubClient;
|
|
@@ -4832,11 +4847,11 @@ function isTestFile(file) {
|
|
|
4832
4847
|
}
|
|
4833
4848
|
function directOwnerCandidates(file) {
|
|
4834
4849
|
if (!file.startsWith("src/") || !/\.[cm]?tsx?$/.test(file)) return [];
|
|
4835
|
-
const
|
|
4836
|
-
const basename4 = path12.posix.basename(
|
|
4850
|
+
const relative5 = file.replace(/^src\//, "").replace(/\.[cm]?tsx?$/, "");
|
|
4851
|
+
const basename4 = path12.posix.basename(relative5);
|
|
4837
4852
|
return [
|
|
4838
|
-
`tests/${
|
|
4839
|
-
`tests/${
|
|
4853
|
+
`tests/${relative5}.spec.ts`,
|
|
4854
|
+
`tests/${relative5}.test.ts`,
|
|
4840
4855
|
`tests/${basename4}.spec.ts`,
|
|
4841
4856
|
`tests/${basename4}.test.ts`
|
|
4842
4857
|
];
|
|
@@ -6062,10 +6077,10 @@ async function readInput(inputPath) {
|
|
|
6062
6077
|
}
|
|
6063
6078
|
return fs17.readFileSync(inputPath, "utf-8");
|
|
6064
6079
|
} else {
|
|
6065
|
-
return new Promise((
|
|
6080
|
+
return new Promise((resolve16, reject) => {
|
|
6066
6081
|
const chunks = [];
|
|
6067
6082
|
process.stdin.on("data", (chunk) => chunks.push(chunk));
|
|
6068
|
-
process.stdin.on("end", () =>
|
|
6083
|
+
process.stdin.on("end", () => resolve16(Buffer.concat(chunks).toString("utf-8")));
|
|
6069
6084
|
process.stdin.on("error", reject);
|
|
6070
6085
|
});
|
|
6071
6086
|
}
|
|
@@ -6702,20 +6717,20 @@ async function registerSecurityCommands(program2) {
|
|
|
6702
6717
|
program2.command("security").description("Security operations: token rotation, secrets scanning, validation").addCommand(
|
|
6703
6718
|
new Command3("check-rotation").description("Check if secrets need rotation based on age").argument("[secrets...]", "Secret IDs to check (without LEX_PR_ prefix)", ["GITHUB_TOKEN"]).option("--max-age <days>", "Maximum age in days before rotation needed", "90").option("--format <format>", "Output format: text or json", "text").option("--no-color", "Disable ANSI colors in text output").action(
|
|
6704
6719
|
async (secretIds, opts) => {
|
|
6705
|
-
const { checkRotation } = await import("./security-
|
|
6720
|
+
const { checkRotation } = await import("./security-W7TOUXSB.js");
|
|
6706
6721
|
const result = await checkRotation(secretIds, parseInt(opts.maxAge));
|
|
6707
6722
|
outputSecurityResult("check-rotation", result, opts.format, opts.color !== false);
|
|
6708
6723
|
}
|
|
6709
6724
|
)
|
|
6710
6725
|
).addCommand(
|
|
6711
6726
|
new Command3("scan-plan").description("Scan plan file for accidentally exposed secrets").argument("[plan-file]", "Path to plan file", "plan.json").option("--format <format>", "Output format: text or json", "text").option("--no-color", "Disable ANSI colors in text output").action(async (planFile, opts) => {
|
|
6712
|
-
const { scanPlan } = await import("./security-
|
|
6727
|
+
const { scanPlan } = await import("./security-W7TOUXSB.js");
|
|
6713
6728
|
const result = await scanPlan(planFile);
|
|
6714
6729
|
outputSecurityResult("scan-plan", result, opts.format, opts.color !== false);
|
|
6715
6730
|
})
|
|
6716
6731
|
).addCommand(
|
|
6717
6732
|
new Command3("validate-secrets").description("Validate that required secrets are present").argument("<secrets...>", "Required secret IDs (without LEX_PR_ prefix)").option("--format <format>", "Output format: text or json", "text").option("--no-color", "Disable ANSI colors in text output").action(async (secretIds, opts) => {
|
|
6718
|
-
const { validateSecrets } = await import("./security-
|
|
6733
|
+
const { validateSecrets } = await import("./security-W7TOUXSB.js");
|
|
6719
6734
|
const result = await validateSecrets(secretIds);
|
|
6720
6735
|
outputSecurityResult("validate-secrets", result, opts.format, opts.color !== false);
|
|
6721
6736
|
})
|
|
@@ -6756,7 +6771,7 @@ function outputAuditResult(command, result, format, color) {
|
|
|
6756
6771
|
async function registerAuditCommands(program2) {
|
|
6757
6772
|
program2.command("audit").description("Audit operations: signature verification, manifest validation").addCommand(
|
|
6758
6773
|
new Command4("verify").description("Verify audit manifest signature").argument("[manifest-file]", "Path to audit manifest file", "audit-manifest.json").option("--format <format>", "Output format: text or json", "text").option("--no-color", "Disable ANSI colors in text output").action(async (manifestFile, opts) => {
|
|
6759
|
-
const { verifyCommand } = await import("./verify-
|
|
6774
|
+
const { verifyCommand } = await import("./verify-Y34CJAKB.js");
|
|
6760
6775
|
const result = await verifyCommand(manifestFile);
|
|
6761
6776
|
outputAuditResult("verify", result, opts.format, opts.color !== false);
|
|
6762
6777
|
})
|
|
@@ -8378,8 +8393,8 @@ Details:`);
|
|
|
8378
8393
|
if (opts.json || deps.jsonModeActive()) {
|
|
8379
8394
|
const output = JSON.stringify(plan, null, 2);
|
|
8380
8395
|
if (opts.output) {
|
|
8381
|
-
const
|
|
8382
|
-
await
|
|
8396
|
+
const fs51 = await import("fs/promises");
|
|
8397
|
+
await fs51.writeFile(opts.output, output, "utf-8");
|
|
8383
8398
|
console.log(`Plan written to: ${opts.output}`);
|
|
8384
8399
|
} else {
|
|
8385
8400
|
console.log(output);
|
|
@@ -8402,8 +8417,8 @@ Details:`);
|
|
|
8402
8417
|
console.log(` ${phase}: ${count}`);
|
|
8403
8418
|
}
|
|
8404
8419
|
if (opts.output) {
|
|
8405
|
-
const
|
|
8406
|
-
await
|
|
8420
|
+
const fs51 = await import("fs/promises");
|
|
8421
|
+
await fs51.writeFile(opts.output, JSON.stringify(plan, null, 2), "utf-8");
|
|
8407
8422
|
console.log(`
|
|
8408
8423
|
Plan written to: ${opts.output}`);
|
|
8409
8424
|
}
|
|
@@ -8655,8 +8670,8 @@ function registerHarvestCommand(fanoutCommand) {
|
|
|
8655
8670
|
});
|
|
8656
8671
|
const output = JSON.stringify(harvestBundle, null, 2);
|
|
8657
8672
|
if (opts.output) {
|
|
8658
|
-
const
|
|
8659
|
-
await
|
|
8673
|
+
const fs51 = await import("fs/promises");
|
|
8674
|
+
await fs51.writeFile(opts.output, output, "utf-8");
|
|
8660
8675
|
console.error(`\u2713 Harvest bundle written to ${opts.output}`);
|
|
8661
8676
|
console.error(` ${harvestBundle.bundle.pullRequests.length} PRs`);
|
|
8662
8677
|
console.error(` ${harvestBundle.bundle.issues.length} issues`);
|
|
@@ -9045,10 +9060,10 @@ function analyzeBundle(harvest) {
|
|
|
9045
9060
|
function registerAnalyzeCommand(fanoutCommand) {
|
|
9046
9061
|
fanoutCommand.command("analyze").description("D1: Analyze harvest bundle into facts pool (deterministic)").option("--input <file>", "Path to harvest bundle JSON file (default: stdin)").option("--json", "Output JSON format (default)").option("--output <file>", "Write output to file").action(async (opts) => {
|
|
9047
9062
|
try {
|
|
9048
|
-
const
|
|
9063
|
+
const fs51 = await import("fs/promises");
|
|
9049
9064
|
let content;
|
|
9050
9065
|
if (opts.input) {
|
|
9051
|
-
content = await
|
|
9066
|
+
content = await fs51.readFile(opts.input, "utf-8");
|
|
9052
9067
|
} else {
|
|
9053
9068
|
const chunks = [];
|
|
9054
9069
|
for await (const chunk of process.stdin) {
|
|
@@ -9090,7 +9105,7 @@ function registerAnalyzeCommand(fanoutCommand) {
|
|
|
9090
9105
|
const analysisPool = analyzeBundle(harvest);
|
|
9091
9106
|
const output = JSON.stringify(analysisPool, null, 2);
|
|
9092
9107
|
if (opts.output) {
|
|
9093
|
-
await
|
|
9108
|
+
await fs51.writeFile(opts.output, output, "utf-8");
|
|
9094
9109
|
console.error(`\u2713 Analysis pool written to ${opts.output}`);
|
|
9095
9110
|
console.error(` ${analysisPool.pool.entities.length} entities`);
|
|
9096
9111
|
console.error(` ${analysisPool.pool.relations.length} relations`);
|
|
@@ -9187,9 +9202,9 @@ var DEFAULT_FANOUT_TEMPLATES_PATHS = [
|
|
|
9187
9202
|
"fanout-templates.yml"
|
|
9188
9203
|
];
|
|
9189
9204
|
var FanoutTemplatesLoadError = class extends Error {
|
|
9190
|
-
constructor(message,
|
|
9205
|
+
constructor(message, path60, cause) {
|
|
9191
9206
|
super(message);
|
|
9192
|
-
this.path =
|
|
9207
|
+
this.path = path60;
|
|
9193
9208
|
this.cause = cause;
|
|
9194
9209
|
this.name = "FanoutTemplatesLoadError";
|
|
9195
9210
|
}
|
|
@@ -9520,7 +9535,7 @@ function registerFanoutCommands(weaveCommand) {
|
|
|
9520
9535
|
}
|
|
9521
9536
|
});
|
|
9522
9537
|
fanout.command("validate").description("Validate fanout templates file").option("-f, --file <path>", "Path to templates file").action(async (options) => {
|
|
9523
|
-
const
|
|
9538
|
+
const fs51 = await import("fs/promises");
|
|
9524
9539
|
try {
|
|
9525
9540
|
let filePath;
|
|
9526
9541
|
if (options.file) {
|
|
@@ -9533,7 +9548,7 @@ function registerFanoutCommands(weaveCommand) {
|
|
|
9533
9548
|
}
|
|
9534
9549
|
filePath = result2.path;
|
|
9535
9550
|
}
|
|
9536
|
-
const content = await
|
|
9551
|
+
const content = await fs51.readFile(filePath, "utf-8");
|
|
9537
9552
|
const result = validateFanoutTemplatesContent(content);
|
|
9538
9553
|
if (result.valid) {
|
|
9539
9554
|
console.log(`\u2713 Valid: ${filePath}`);
|
|
@@ -10514,8 +10529,8 @@ function lastCompletedMergeSha(operations) {
|
|
|
10514
10529
|
(operation) => operation.phase === "merge" && operation.status === "completed" && operation.result?.externalId
|
|
10515
10530
|
)?.result?.externalId;
|
|
10516
10531
|
}
|
|
10517
|
-
function isRunnerStatePath(
|
|
10518
|
-
return
|
|
10532
|
+
function isRunnerStatePath(path60) {
|
|
10533
|
+
return path60 === ".lexrunner" || path60.startsWith(".lexrunner/") || path60 === "weave-lock.json" || path60.endsWith("/weave-lock.json");
|
|
10519
10534
|
}
|
|
10520
10535
|
|
|
10521
10536
|
// src/commands/weave.ts
|
|
@@ -10927,7 +10942,7 @@ async function runWeaveApply(opts, deps) {
|
|
|
10927
10942
|
if (json2) {
|
|
10928
10943
|
const output = { ...preview.summary };
|
|
10929
10944
|
if (showConstraints) {
|
|
10930
|
-
const { previewConstraints: previewConstraints2 } = await import("./constraints-
|
|
10945
|
+
const { previewConstraints: previewConstraints2 } = await import("./constraints-LE2MW5NS.js");
|
|
10931
10946
|
output.constraints = await previewConstraints2(plan);
|
|
10932
10947
|
}
|
|
10933
10948
|
console.log(canonicalJSONStringify(output));
|
|
@@ -10937,7 +10952,7 @@ async function runWeaveApply(opts, deps) {
|
|
|
10937
10952
|
\u{1F50D} Merge-Weave Dry Run
|
|
10938
10953
|
`);
|
|
10939
10954
|
if (showConstraints) {
|
|
10940
|
-
const { previewConstraints: previewConstraints2, formatConstraintPreview: formatConstraintPreview2 } = await import("./constraints-
|
|
10955
|
+
const { previewConstraints: previewConstraints2, formatConstraintPreview: formatConstraintPreview2 } = await import("./constraints-LE2MW5NS.js");
|
|
10941
10956
|
console.log(formatConstraintPreview2(await previewConstraints2(plan)));
|
|
10942
10957
|
}
|
|
10943
10958
|
console.log(`Plan: ${opts.plan}`);
|
|
@@ -11133,7 +11148,7 @@ function registerPlanDiffCommand(program2, deps) {
|
|
|
11133
11148
|
const plan2Content = fs24.readFileSync(plan2Path, "utf-8");
|
|
11134
11149
|
const plan1 = loadPlan(plan1Content);
|
|
11135
11150
|
const plan2 = loadPlan(plan2Content);
|
|
11136
|
-
const { comparePlans, formatPlanDiff } = await import("./planDiff-
|
|
11151
|
+
const { comparePlans, formatPlanDiff } = await import("./planDiff-4D3AERAW.js");
|
|
11137
11152
|
const diff = comparePlans(plan1, plan2);
|
|
11138
11153
|
if (opts.json || deps.jsonModeActive()) {
|
|
11139
11154
|
writeJsonOutput(diff);
|
|
@@ -11617,12 +11632,12 @@ ${prefix} Plan validation failed: ${error.message}`);
|
|
|
11617
11632
|
}
|
|
11618
11633
|
fs25.mkdirSync(outDir, { recursive: true });
|
|
11619
11634
|
const planPath = path16.join(outDir, "plan.json");
|
|
11620
|
-
const
|
|
11635
|
+
const snapshotPath2 = path16.join(outDir, "snapshot.md");
|
|
11621
11636
|
fs25.writeFileSync(planPath, planJSON);
|
|
11622
|
-
fs25.writeFileSync(
|
|
11637
|
+
fs25.writeFileSync(snapshotPath2, snapshot);
|
|
11623
11638
|
console.log(`\u2713 Generated plan artifacts:`);
|
|
11624
11639
|
console.log(` \u{1F4C1} ${planPath}`);
|
|
11625
|
-
console.log(` \u{1F4C1} ${
|
|
11640
|
+
console.log(` \u{1F4C1} ${snapshotPath2}`);
|
|
11626
11641
|
console.log("");
|
|
11627
11642
|
console.log(generatePlanSummary(validatedPlan));
|
|
11628
11643
|
return;
|
|
@@ -11763,7 +11778,7 @@ function registerAutopilotCommand(program2, deps) {
|
|
|
11763
11778
|
argv: process.argv.slice(2)
|
|
11764
11779
|
});
|
|
11765
11780
|
}
|
|
11766
|
-
const { AutopilotLevel0, AutopilotLevel1, AutopilotLevel2: AutopilotLevel22 } = await import("./autopilot-
|
|
11781
|
+
const { AutopilotLevel0, AutopilotLevel1, AutopilotLevel2: AutopilotLevel22 } = await import("./autopilot-JWIOXBCZ.js");
|
|
11767
11782
|
const context = {
|
|
11768
11783
|
plan,
|
|
11769
11784
|
profilePath: profile.path,
|
|
@@ -12788,7 +12803,7 @@ import * as fs28 from "fs";
|
|
|
12788
12803
|
import * as path18 from "path";
|
|
12789
12804
|
async function finalizeAuditGuard(emitter, status) {
|
|
12790
12805
|
try {
|
|
12791
|
-
const { finalizeAudit: finalizeAudit2 } = await import("./audit-
|
|
12806
|
+
const { finalizeAudit: finalizeAudit2 } = await import("./audit-HVB2HJPU.js");
|
|
12792
12807
|
await finalizeAudit2(emitter, status);
|
|
12793
12808
|
} catch (e) {
|
|
12794
12809
|
if (e instanceof Error && typeof e.message === "string" && e.message.startsWith("HIPAA:")) {
|
|
@@ -13354,8 +13369,8 @@ function registerPlanReviewCommand(program2, deps) {
|
|
|
13354
13369
|
}
|
|
13355
13370
|
const planContent = fs29.readFileSync(planFile, "utf-8");
|
|
13356
13371
|
const plan = loadPlan(planContent);
|
|
13357
|
-
const { reviewPlan } = await import("./planReview-
|
|
13358
|
-
const { savePlanVersion, getPlanHistoryPath } = await import("./planHistory-
|
|
13372
|
+
const { reviewPlan } = await import("./planReview-FV6INFLQ.js");
|
|
13373
|
+
const { savePlanVersion, getPlanHistoryPath } = await import("./planHistory-VPV4WDPW.js");
|
|
13359
13374
|
const result = await reviewPlan({
|
|
13360
13375
|
plan,
|
|
13361
13376
|
interactive: !opts.nonInteractive,
|
|
@@ -14055,7 +14070,7 @@ async function predictConflicts(options) {
|
|
|
14055
14070
|
const pr2Head = prHeads.get(edge.to);
|
|
14056
14071
|
if (pr1Head && pr2Head) {
|
|
14057
14072
|
const key = `${edge.from}-${edge.to}`;
|
|
14058
|
-
const result = await import("./mergeTreeSimulator-
|
|
14073
|
+
const result = await import("./mergeTreeSimulator-GWZ77NF2.js").then(
|
|
14059
14074
|
(m) => m.simulateMerge(baseBranch, pr1Head, pr2Head, workingDir)
|
|
14060
14075
|
);
|
|
14061
14076
|
mergeTreeSimulation[key] = result;
|
|
@@ -14131,7 +14146,7 @@ function generateRecommendations(misBatches, mergeTreeSimulation) {
|
|
|
14131
14146
|
|
|
14132
14147
|
// src/orchestration/agentAssigner.ts
|
|
14133
14148
|
function sleep(ms) {
|
|
14134
|
-
return new Promise((
|
|
14149
|
+
return new Promise((resolve16) => setTimeout(resolve16, ms));
|
|
14135
14150
|
}
|
|
14136
14151
|
async function assignAgentWithRetry(issueNumber, repo, assignFn, maxRetries = 4) {
|
|
14137
14152
|
let retries = 0;
|
|
@@ -14750,8 +14765,8 @@ function registerGenerateDeliverablesCommand(program2) {
|
|
|
14750
14765
|
console.log(`\u2705 Created: ${path23.join(outputDir, "GATE5_cleanup.md")}`);
|
|
14751
14766
|
console.log(`\u2705 Created: ${path23.join(outputDir, "SUMMARY.md")}`);
|
|
14752
14767
|
console.log("");
|
|
14753
|
-
const
|
|
14754
|
-
const planHashContent =
|
|
14768
|
+
const fs51 = await import("fs");
|
|
14769
|
+
const planHashContent = fs51.readFileSync(path23.join(outputDir, "plan-hash.txt"), "utf-8");
|
|
14755
14770
|
const planHashMatch = planHashContent.match(/SHA256: ([a-f0-9]+)/);
|
|
14756
14771
|
if (planHashMatch) {
|
|
14757
14772
|
console.log(`Plan hash: ${planHashMatch[1]}`);
|
|
@@ -15542,7 +15557,7 @@ function formatMonitor(monitor) {
|
|
|
15542
15557
|
async function runCheck(opts) {
|
|
15543
15558
|
let githubAPI = await createGitHubAPI();
|
|
15544
15559
|
if (opts.owner && opts.repo) {
|
|
15545
|
-
const { GitHubAPI: GitHubAPI2 } = await import("./api-
|
|
15560
|
+
const { GitHubAPI: GitHubAPI2 } = await import("./api-UIWVFU7M.js");
|
|
15546
15561
|
githubAPI = new GitHubAPI2({
|
|
15547
15562
|
owner: opts.owner,
|
|
15548
15563
|
repo: opts.repo,
|
|
@@ -16753,9 +16768,9 @@ async function promptInteractive(defaults) {
|
|
|
16753
16768
|
output: process.stdout
|
|
16754
16769
|
});
|
|
16755
16770
|
const question = (prompt) => {
|
|
16756
|
-
return new Promise((
|
|
16771
|
+
return new Promise((resolve16) => {
|
|
16757
16772
|
rl.question(prompt, (answer) => {
|
|
16758
|
-
|
|
16773
|
+
resolve16(answer.trim());
|
|
16759
16774
|
});
|
|
16760
16775
|
});
|
|
16761
16776
|
};
|
|
@@ -18612,8 +18627,8 @@ Total: ${entries.length} counter-examples (${entries.filter((e) => e.shouldLearn
|
|
|
18612
18627
|
counterExamples.command("export").description("Export counter-examples for analysis").option("--format <format>", "Export format (json|csv)", "json").option("--base-dir <dir>", "Base directory for lexrunner", process.cwd()).option("--output <file>", "Output file (prints to stdout if not specified)").action(async (options) => {
|
|
18613
18628
|
const output = exportCounterExamples(options.format, options.baseDir);
|
|
18614
18629
|
if (options.output) {
|
|
18615
|
-
const
|
|
18616
|
-
|
|
18630
|
+
const fs51 = await import("fs");
|
|
18631
|
+
fs51.writeFileSync(options.output, output, "utf-8");
|
|
18617
18632
|
console.log(chalk9.green(`\u2713 Exported counter-examples to ${options.output}`));
|
|
18618
18633
|
} else {
|
|
18619
18634
|
console.log(output);
|
|
@@ -19193,7 +19208,7 @@ function nativePathsOverlap(runtimePlatform, left, right, comparison) {
|
|
|
19193
19208
|
if (api.parse(normalizedLeft).root !== api.parse(normalizedRight).root) return false;
|
|
19194
19209
|
const relativeLeft = api.relative(normalizedLeft, normalizedRight);
|
|
19195
19210
|
const relativeRight = api.relative(normalizedRight, normalizedLeft);
|
|
19196
|
-
const isDescendant = (
|
|
19211
|
+
const isDescendant = (relative5) => relative5.length > 0 && relative5 !== ".." && !relative5.startsWith(`..${api.sep}`);
|
|
19197
19212
|
return isDescendant(relativeLeft) || isDescendant(relativeRight);
|
|
19198
19213
|
}
|
|
19199
19214
|
function digestBinding(runtime) {
|
|
@@ -20538,8 +20553,8 @@ function parseGitStatusPorcelainV1Z(input) {
|
|
|
20538
20553
|
}
|
|
20539
20554
|
const indexStatus = field[0];
|
|
20540
20555
|
const worktreeStatus = field[1];
|
|
20541
|
-
const
|
|
20542
|
-
if (
|
|
20556
|
+
const path60 = field.slice(3);
|
|
20557
|
+
if (path60.length === 0) {
|
|
20543
20558
|
throw new Error("Malformed git status porcelain: path is empty");
|
|
20544
20559
|
}
|
|
20545
20560
|
const renameOrCopy = [indexStatus, worktreeStatus].find(
|
|
@@ -20557,7 +20572,7 @@ function parseGitStatusPorcelainV1Z(input) {
|
|
|
20557
20572
|
records.push({
|
|
20558
20573
|
indexStatus,
|
|
20559
20574
|
worktreeStatus,
|
|
20560
|
-
path:
|
|
20575
|
+
path: path60,
|
|
20561
20576
|
...originalPath === void 0 ? {} : { originalPath },
|
|
20562
20577
|
kind
|
|
20563
20578
|
});
|
|
@@ -21009,8 +21024,8 @@ function copyIssues(result, context) {
|
|
|
21009
21024
|
context.addIssue({ code: "custom", path: issue.path, message: issue.message });
|
|
21010
21025
|
}
|
|
21011
21026
|
}
|
|
21012
|
-
function addIssue(context,
|
|
21013
|
-
context.addIssue({ code: "custom", path:
|
|
21027
|
+
function addIssue(context, path60, message) {
|
|
21028
|
+
context.addIssue({ code: "custom", path: path60, message });
|
|
21014
21029
|
}
|
|
21015
21030
|
|
|
21016
21031
|
// src/workspaces/linux-workspace-boundary.ts
|
|
@@ -22051,8 +22066,8 @@ var NodeGitWorktreeBroker = class {
|
|
|
22051
22066
|
"The worktree root was replaced after broker initialization"
|
|
22052
22067
|
);
|
|
22053
22068
|
}
|
|
22054
|
-
const
|
|
22055
|
-
const components =
|
|
22069
|
+
const relative5 = path34.relative(this.worktreeRoot, path34.resolve(target.worktreePath));
|
|
22070
|
+
const components = relative5.split(path34.sep);
|
|
22056
22071
|
const targetName = components.pop();
|
|
22057
22072
|
if (!targetName) {
|
|
22058
22073
|
throw new DirectoryBoundaryError("invalid_path", "The worktree target has no basename");
|
|
@@ -22256,8 +22271,8 @@ var NodeGitWorktreeBroker = class {
|
|
|
22256
22271
|
);
|
|
22257
22272
|
}
|
|
22258
22273
|
const normalized = path34.resolve(gitDirectoryPath);
|
|
22259
|
-
const
|
|
22260
|
-
if (!
|
|
22274
|
+
const relative5 = path34.relative(this.repositoryGitIdentity.path, normalized);
|
|
22275
|
+
if (!relative5 || relative5 === ".." || relative5.startsWith(`..${path34.sep}`)) {
|
|
22261
22276
|
return this.failure(
|
|
22262
22277
|
operation,
|
|
22263
22278
|
"containment_violation",
|
|
@@ -22266,7 +22281,7 @@ var NodeGitWorktreeBroker = class {
|
|
|
22266
22281
|
}
|
|
22267
22282
|
let current = null;
|
|
22268
22283
|
try {
|
|
22269
|
-
for (const component of
|
|
22284
|
+
for (const component of relative5.split(path34.sep)) {
|
|
22270
22285
|
const child = await boundary.lease.openChild(
|
|
22271
22286
|
current ?? boundary.repositoryGit,
|
|
22272
22287
|
component,
|
|
@@ -22320,8 +22335,8 @@ var NodeGitWorktreeBroker = class {
|
|
|
22320
22335
|
const normalizedRoot = path34.resolve(root);
|
|
22321
22336
|
const comparedCandidate = this.pathComparison === "case-insensitive" ? normalizedCandidate.toLocaleLowerCase("en-US") : normalizedCandidate;
|
|
22322
22337
|
const comparedRoot = this.pathComparison === "case-insensitive" ? normalizedRoot.toLocaleLowerCase("en-US") : normalizedRoot;
|
|
22323
|
-
const
|
|
22324
|
-
return
|
|
22338
|
+
const relative5 = path34.relative(comparedRoot, comparedCandidate);
|
|
22339
|
+
return relative5.length > 0 && relative5 !== ".." && !relative5.startsWith(`..${path34.sep}`);
|
|
22325
22340
|
}
|
|
22326
22341
|
async git(boundary, operation, args, cwd, options, allowedNonzeroExitCodes = [], evidence) {
|
|
22327
22342
|
const result = await boundary.lease.runProcess({
|
|
@@ -22426,7 +22441,7 @@ function nativePathsOverlap2(left, right, comparison) {
|
|
|
22426
22441
|
if (normalizedLeft === normalizedRight) return true;
|
|
22427
22442
|
const relativeLeft = path34.relative(normalizedLeft, normalizedRight);
|
|
22428
22443
|
const relativeRight = path34.relative(normalizedRight, normalizedLeft);
|
|
22429
|
-
const isDescendant = (
|
|
22444
|
+
const isDescendant = (relative5) => relative5.length > 0 && relative5 !== ".." && !relative5.startsWith(`..${path34.sep}`);
|
|
22430
22445
|
return isDescendant(relativeLeft) || isDescendant(relativeRight);
|
|
22431
22446
|
}
|
|
22432
22447
|
function branchName(ref) {
|
|
@@ -24966,24 +24981,24 @@ var AcceptanceCriterion = z19.object({
|
|
|
24966
24981
|
function isMachineLocalAbsolutePath(value) {
|
|
24967
24982
|
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);
|
|
24968
24983
|
}
|
|
24969
|
-
function rejectMachineLocalPaths(value, ctx,
|
|
24984
|
+
function rejectMachineLocalPaths(value, ctx, path60 = []) {
|
|
24970
24985
|
if (typeof value === "string") {
|
|
24971
24986
|
if (isMachineLocalAbsolutePath(value)) {
|
|
24972
24987
|
ctx.addIssue({
|
|
24973
24988
|
code: "custom",
|
|
24974
|
-
path:
|
|
24989
|
+
path: path60,
|
|
24975
24990
|
message: "AgentTaskPacket_v1 must not contain machine-local absolute paths"
|
|
24976
24991
|
});
|
|
24977
24992
|
}
|
|
24978
24993
|
return;
|
|
24979
24994
|
}
|
|
24980
24995
|
if (Array.isArray(value)) {
|
|
24981
|
-
value.forEach((item, index) => rejectMachineLocalPaths(item, ctx, [...
|
|
24996
|
+
value.forEach((item, index) => rejectMachineLocalPaths(item, ctx, [...path60, index]));
|
|
24982
24997
|
return;
|
|
24983
24998
|
}
|
|
24984
24999
|
if (value !== null && typeof value === "object") {
|
|
24985
25000
|
for (const [key, item] of Object.entries(value)) {
|
|
24986
|
-
rejectMachineLocalPaths(item, ctx, [...
|
|
25001
|
+
rejectMachineLocalPaths(item, ctx, [...path60, key]);
|
|
24987
25002
|
}
|
|
24988
25003
|
}
|
|
24989
25004
|
}
|
|
@@ -27157,10 +27172,10 @@ function captureBoundIdentities(input) {
|
|
|
27157
27172
|
worktree: captureDirectoryIdentity(input.worktreePath, "execution mapping worktree")
|
|
27158
27173
|
};
|
|
27159
27174
|
}
|
|
27160
|
-
function verifiedRoot(runtimeId,
|
|
27175
|
+
function verifiedRoot(runtimeId, path60, identity) {
|
|
27161
27176
|
return {
|
|
27162
27177
|
runtime_id: runtimeId,
|
|
27163
|
-
path:
|
|
27178
|
+
path: path60,
|
|
27164
27179
|
verification: "directory_identity",
|
|
27165
27180
|
directory_identity: identityClaim2(identity)
|
|
27166
27181
|
};
|
|
@@ -27279,8 +27294,8 @@ async function requireDirectoryWithin(directory, root, field) {
|
|
|
27279
27294
|
realpath(directory),
|
|
27280
27295
|
realpath(root)
|
|
27281
27296
|
]);
|
|
27282
|
-
const
|
|
27283
|
-
if (
|
|
27297
|
+
const relative5 = path36.relative(resolvedRoot, resolvedDirectory);
|
|
27298
|
+
if (relative5 === ".." || relative5.startsWith(`..${path36.sep}`) || path36.isAbsolute(relative5)) {
|
|
27284
27299
|
throw new Error(`${field} must resolve within its authorized root`);
|
|
27285
27300
|
}
|
|
27286
27301
|
}
|
|
@@ -32472,8 +32487,8 @@ async function requireDirectoryWithin2(directory, root, field) {
|
|
|
32472
32487
|
realpath2(directory),
|
|
32473
32488
|
realpath2(root)
|
|
32474
32489
|
]);
|
|
32475
|
-
const
|
|
32476
|
-
if (
|
|
32490
|
+
const relative5 = path37.relative(resolvedRoot, resolvedDirectory);
|
|
32491
|
+
if (relative5 === ".." || relative5.startsWith(`..${path37.sep}`) || path37.isAbsolute(relative5)) {
|
|
32477
32492
|
throw new Error(`${field} must resolve within the authorized worktree`);
|
|
32478
32493
|
}
|
|
32479
32494
|
}
|
|
@@ -35250,10 +35265,10 @@ var WorkerSessionDelegationBinding_v1 = z29.object({
|
|
|
35250
35265
|
function decisionReceiptMatchesOffer(receipt, offer, offerHash) {
|
|
35251
35266
|
return receipt.delegation_id === offer.delegation_id && receipt.attempt_id === offer.attempt_id && receipt.offer_hash === offerHash && receipt.worker_thread_id === offer.worker.thread_id && receipt.transcript_start_hash === offer.transcript_start_hash && Date.parse(receipt.decided_at) >= Date.parse(offer.offered_at);
|
|
35252
35267
|
}
|
|
35253
|
-
function requireTimeOrder(earlier, later,
|
|
35268
|
+
function requireTimeOrder(earlier, later, path60, context, equalAllowed = true) {
|
|
35254
35269
|
const ordered = equalAllowed ? Date.parse(earlier) <= Date.parse(later) : Date.parse(earlier) < Date.parse(later);
|
|
35255
35270
|
if (!ordered) {
|
|
35256
|
-
context.addIssue({ code: "custom", path: [
|
|
35271
|
+
context.addIssue({ code: "custom", path: [path60], message: `${path60} is out of order` });
|
|
35257
35272
|
}
|
|
35258
35273
|
}
|
|
35259
35274
|
|
|
@@ -36363,12 +36378,12 @@ function grantWithinRequirements(grant, requirements) {
|
|
|
36363
36378
|
);
|
|
36364
36379
|
return grant.authorized_model_provider === requirements.authorized_model_provider && grant.source_disclosure_allowed === requirements.source_disclosure_allowed && grant.max_duration_ms <= requirements.max_duration_ms && grant.max_output_bytes <= requirements.max_output_bytes && grant.controls.every((control) => required2.get(control.control) === control.minimum_strength) && grant.tools.length <= 1;
|
|
36365
36380
|
}
|
|
36366
|
-
function requireExactControls(controls, context,
|
|
36381
|
+
function requireExactControls(controls, context, path60) {
|
|
36367
36382
|
const actual = new Set(controls.map((control) => control.control));
|
|
36368
36383
|
if (actual.size !== GovernedControlId.options.length || GovernedControlId.options.some((control) => !actual.has(control))) {
|
|
36369
36384
|
context.addIssue({
|
|
36370
36385
|
code: "custom",
|
|
36371
|
-
path:
|
|
36386
|
+
path: path60,
|
|
36372
36387
|
message: "every governed denial control must appear exactly once"
|
|
36373
36388
|
});
|
|
36374
36389
|
}
|
|
@@ -37318,10 +37333,10 @@ function requireAbsent(value, fields, context) {
|
|
|
37318
37333
|
function addStateIssue(message, context) {
|
|
37319
37334
|
context.addIssue({ code: "custom", path: ["status"], message });
|
|
37320
37335
|
}
|
|
37321
|
-
function requireOrdered(earlier, later,
|
|
37336
|
+
function requireOrdered(earlier, later, path60, context, equalAllowed = true) {
|
|
37322
37337
|
const ordered = equalAllowed ? Date.parse(earlier) <= Date.parse(later) : Date.parse(earlier) < Date.parse(later);
|
|
37323
37338
|
if (!ordered) {
|
|
37324
|
-
context.addIssue({ code: "custom", path: [
|
|
37339
|
+
context.addIssue({ code: "custom", path: [path60], message: `${path60} is out of order` });
|
|
37325
37340
|
}
|
|
37326
37341
|
}
|
|
37327
37342
|
|
|
@@ -39041,8 +39056,8 @@ function normalizeInstant4(value) {
|
|
|
39041
39056
|
return new Date(timestamp).toISOString();
|
|
39042
39057
|
}
|
|
39043
39058
|
function assertDescendant(parent, candidate) {
|
|
39044
|
-
const
|
|
39045
|
-
if (
|
|
39059
|
+
const relative5 = path46.relative(path46.resolve(parent), path46.resolve(candidate));
|
|
39060
|
+
if (relative5.startsWith("..") || path46.isAbsolute(relative5)) {
|
|
39046
39061
|
throw new LocalProtectedEvidenceVerificationError("container_invalid");
|
|
39047
39062
|
}
|
|
39048
39063
|
}
|
|
@@ -39197,14 +39212,14 @@ var WindowsProtectedEvidenceAuthority = class {
|
|
|
39197
39212
|
this.child = null;
|
|
39198
39213
|
child?.stdin.end();
|
|
39199
39214
|
if (child && child.exitCode === null) {
|
|
39200
|
-
await new Promise((
|
|
39215
|
+
await new Promise((resolve16) => {
|
|
39201
39216
|
const timeout = setTimeout(() => {
|
|
39202
39217
|
child.kill();
|
|
39203
|
-
|
|
39218
|
+
resolve16();
|
|
39204
39219
|
}, 5e3);
|
|
39205
39220
|
child.once("close", () => {
|
|
39206
39221
|
clearTimeout(timeout);
|
|
39207
|
-
|
|
39222
|
+
resolve16();
|
|
39208
39223
|
});
|
|
39209
39224
|
});
|
|
39210
39225
|
}
|
|
@@ -39215,8 +39230,8 @@ var WindowsProtectedEvidenceAuthority = class {
|
|
|
39215
39230
|
const child = this.ensureChild();
|
|
39216
39231
|
const id = this.nextId;
|
|
39217
39232
|
this.nextId += 1;
|
|
39218
|
-
return new Promise((
|
|
39219
|
-
this.pending.set(id, { resolve:
|
|
39233
|
+
return new Promise((resolve16, reject) => {
|
|
39234
|
+
this.pending.set(id, { resolve: resolve16, reject });
|
|
39220
39235
|
child.stdin.write(`${JSON.stringify({ id, op: operation, path: target })}
|
|
39221
39236
|
`, (error) => {
|
|
39222
39237
|
if (!error) return;
|
|
@@ -39868,7 +39883,7 @@ var repositoryCorpusHeaderBody = z41.object({
|
|
|
39868
39883
|
var GovernedRepositoryCorpusHeader_v1 = repositoryCorpusHeaderBody.superRefine(
|
|
39869
39884
|
(value, context) => {
|
|
39870
39885
|
const paths = value.entries.map((entry) => entry.path);
|
|
39871
|
-
if (new Set(paths).size !== paths.length || paths.some((
|
|
39886
|
+
if (new Set(paths).size !== paths.length || paths.some((path60, index) => index > 0 && path60 <= paths[index - 1])) {
|
|
39872
39887
|
context.addIssue({
|
|
39873
39888
|
code: "custom",
|
|
39874
39889
|
path: ["entries"],
|
|
@@ -40295,7 +40310,7 @@ function sanitizedWslEnvironment() {
|
|
|
40295
40310
|
return environment;
|
|
40296
40311
|
}
|
|
40297
40312
|
function waitForExit(child, timeoutMs) {
|
|
40298
|
-
return new Promise((
|
|
40313
|
+
return new Promise((resolve16, reject) => {
|
|
40299
40314
|
const timeout = setTimeout(() => {
|
|
40300
40315
|
child.kill();
|
|
40301
40316
|
reject(new Error("WSL2 provider control request timed out"));
|
|
@@ -40306,7 +40321,7 @@ function waitForExit(child, timeoutMs) {
|
|
|
40306
40321
|
});
|
|
40307
40322
|
child.once("close", (code) => {
|
|
40308
40323
|
clearTimeout(timeout);
|
|
40309
|
-
|
|
40324
|
+
resolve16(code);
|
|
40310
40325
|
});
|
|
40311
40326
|
});
|
|
40312
40327
|
}
|
|
@@ -41421,8 +41436,8 @@ var LocalProtectedEvidenceStore = class {
|
|
|
41421
41436
|
exclusive(operation) {
|
|
41422
41437
|
const previous = this.queue;
|
|
41423
41438
|
let release;
|
|
41424
|
-
this.queue = new Promise((
|
|
41425
|
-
release =
|
|
41439
|
+
this.queue = new Promise((resolve16) => {
|
|
41440
|
+
release = resolve16;
|
|
41426
41441
|
});
|
|
41427
41442
|
return previous.then(operation).finally(release);
|
|
41428
41443
|
}
|
|
@@ -41585,8 +41600,8 @@ function sameToken(expected, candidate) {
|
|
|
41585
41600
|
return left.length === right.length && timingSafeEqual(left, right);
|
|
41586
41601
|
}
|
|
41587
41602
|
function assertDescendant2(root, candidate) {
|
|
41588
|
-
const
|
|
41589
|
-
if (!
|
|
41603
|
+
const relative5 = path50.relative(root, candidate);
|
|
41604
|
+
if (!relative5 || relative5.startsWith("..") || path50.isAbsolute(relative5)) {
|
|
41590
41605
|
throw new Error("protected evidence deletion target escaped its root");
|
|
41591
41606
|
}
|
|
41592
41607
|
}
|
|
@@ -42434,11 +42449,11 @@ async function launchDetachedSupervisor(input) {
|
|
|
42434
42449
|
env: sanitizedSupervisorEnvironment()
|
|
42435
42450
|
}
|
|
42436
42451
|
);
|
|
42437
|
-
return await new Promise((
|
|
42438
|
-
child.once("error", () =>
|
|
42452
|
+
return await new Promise((resolve16) => {
|
|
42453
|
+
child.once("error", () => resolve16(false));
|
|
42439
42454
|
child.once("spawn", () => {
|
|
42440
42455
|
child.unref();
|
|
42441
|
-
|
|
42456
|
+
resolve16(true);
|
|
42442
42457
|
});
|
|
42443
42458
|
});
|
|
42444
42459
|
} catch {
|
|
@@ -43184,10 +43199,10 @@ function commandPath(command) {
|
|
|
43184
43199
|
}
|
|
43185
43200
|
return components.join(" ");
|
|
43186
43201
|
}
|
|
43187
|
-
function aliasWarning(
|
|
43188
|
-
const policy = POLICY_BY_PATH.get(
|
|
43202
|
+
function aliasWarning(path60) {
|
|
43203
|
+
const policy = POLICY_BY_PATH.get(path60);
|
|
43189
43204
|
if (!policy) return null;
|
|
43190
|
-
return policy.disposition === "deprecated" ? `[lexrunner] deprecated alias "${
|
|
43205
|
+
return policy.disposition === "deprecated" ? `[lexrunner] deprecated alias "${path60}"; use "${policy.replacement}"; removal: ${policy.removeIn}.` : `[lexrunner] compatibility alias "${path60}"; use "${policy.replacement}"; supported through 2.x and reviewed at 3.0.0.`;
|
|
43191
43206
|
}
|
|
43192
43207
|
function emitAliasWarning(command, write = (message) => process.stderr.write(message)) {
|
|
43193
43208
|
const warning = aliasWarning(commandPath(command));
|
|
@@ -43293,8 +43308,8 @@ async function searchAttributions(query, runId) {
|
|
|
43293
43308
|
}
|
|
43294
43309
|
|
|
43295
43310
|
// src/cli.ts
|
|
43296
|
-
import * as
|
|
43297
|
-
import * as
|
|
43311
|
+
import * as fs50 from "fs";
|
|
43312
|
+
import * as path59 from "path";
|
|
43298
43313
|
|
|
43299
43314
|
// src/runs/enforcement.ts
|
|
43300
43315
|
import { z as z45 } from "zod";
|
|
@@ -44716,8 +44731,8 @@ async function executeAgentWorkPreparation(input) {
|
|
|
44716
44731
|
function passed(results, id) {
|
|
44717
44732
|
return results.some((result) => result.id === id && result.outcome === "passed");
|
|
44718
44733
|
}
|
|
44719
|
-
async function containedExistingDirectory(root,
|
|
44720
|
-
const candidate =
|
|
44734
|
+
async function containedExistingDirectory(root, relative5) {
|
|
44735
|
+
const candidate = relative5 ? path55.resolve(root, relative5) : root;
|
|
44721
44736
|
const resolved = await realpath6(candidate);
|
|
44722
44737
|
const relation = path55.relative(root, resolved);
|
|
44723
44738
|
if (relation === ".." || relation.startsWith(`..${path55.sep}`) || path55.isAbsolute(relation)) {
|
|
@@ -44800,7 +44815,7 @@ var workspaceFilesystemEntry = z49.discriminatedUnion("kind", [
|
|
|
44800
44815
|
}).strict()
|
|
44801
44816
|
]);
|
|
44802
44817
|
function requireStrictlyOrderedPaths(values, context, field) {
|
|
44803
|
-
if (values.some(({ path:
|
|
44818
|
+
if (values.some(({ path: path60 }, index) => index > 0 && path60 <= values[index - 1].path)) {
|
|
44804
44819
|
context.addIssue({
|
|
44805
44820
|
code: "custom",
|
|
44806
44821
|
path: [field],
|
|
@@ -44820,7 +44835,7 @@ var completeGitIdentity = z49.object({
|
|
|
44820
44835
|
kind: z49.enum(["absent", "present"]),
|
|
44821
44836
|
paths: z49.array(boundedRelativePath).max(4096)
|
|
44822
44837
|
}).strict().superRefine((identity, context) => {
|
|
44823
|
-
if (identity.paths.some((
|
|
44838
|
+
if (identity.paths.some((path60, index) => index > 0 && path60 <= identity.paths[index - 1]) || identity.kind === "absent" && identity.paths.length !== 0 || identity.kind === "present" && identity.paths.length === 0) {
|
|
44824
44839
|
context.addIssue({
|
|
44825
44840
|
code: "custom",
|
|
44826
44841
|
path: ["paths"],
|
|
@@ -45130,7 +45145,7 @@ var GovernedWorkspaceMutationRecoveryReceipt_v1 = z49.object({
|
|
|
45130
45145
|
});
|
|
45131
45146
|
}
|
|
45132
45147
|
if (receipt.changed_paths.some(
|
|
45133
|
-
(
|
|
45148
|
+
(path60, index) => index > 0 && path60 <= receipt.changed_paths[index - 1]
|
|
45134
45149
|
)) {
|
|
45135
45150
|
context.addIssue({
|
|
45136
45151
|
code: "custom",
|
|
@@ -45965,15 +45980,15 @@ var AttemptAwaitableSupervisor = class {
|
|
|
45965
45980
|
0,
|
|
45966
45981
|
Date.parse(record.observer_lease.expires_at) - Date.parse(this.now()) + 1
|
|
45967
45982
|
);
|
|
45968
|
-
let
|
|
45983
|
+
let resolve16;
|
|
45969
45984
|
const completion = new Promise((resolvePromise) => {
|
|
45970
|
-
|
|
45985
|
+
resolve16 = resolvePromise;
|
|
45971
45986
|
});
|
|
45972
45987
|
const timer = setTimeout(() => {
|
|
45973
45988
|
this.leaseExpiryWakeups.delete(record.awaitable_id);
|
|
45974
|
-
void this.attach(record.awaitable_id).finally(
|
|
45989
|
+
void this.attach(record.awaitable_id).finally(resolve16);
|
|
45975
45990
|
}, delayMs);
|
|
45976
|
-
this.leaseExpiryWakeups.set(record.awaitable_id, { timer, completion, resolve:
|
|
45991
|
+
this.leaseExpiryWakeups.set(record.awaitable_id, { timer, completion, resolve: resolve16 });
|
|
45977
45992
|
}
|
|
45978
45993
|
clearLeaseExpiryWakeup(awaitableId) {
|
|
45979
45994
|
const wakeup = this.leaseExpiryWakeups.get(awaitableId);
|
|
@@ -46078,14 +46093,14 @@ function normalizeRetryDelay(value, name) {
|
|
|
46078
46093
|
}
|
|
46079
46094
|
function waitForRetry(delayMs, signal) {
|
|
46080
46095
|
if (signal.aborted) return Promise.resolve(false);
|
|
46081
|
-
return new Promise((
|
|
46096
|
+
return new Promise((resolve16) => {
|
|
46082
46097
|
const timer = setTimeout(() => {
|
|
46083
46098
|
signal.removeEventListener("abort", onAbort);
|
|
46084
|
-
|
|
46099
|
+
resolve16(true);
|
|
46085
46100
|
}, delayMs);
|
|
46086
46101
|
const onAbort = () => {
|
|
46087
46102
|
clearTimeout(timer);
|
|
46088
|
-
|
|
46103
|
+
resolve16(false);
|
|
46089
46104
|
};
|
|
46090
46105
|
signal.addEventListener("abort", onAbort, { once: true });
|
|
46091
46106
|
});
|
|
@@ -49602,8 +49617,135 @@ function normalizeInstant8(value) {
|
|
|
49602
49617
|
// src/application/plan-artifact-service.ts
|
|
49603
49618
|
import * as fs48 from "fs";
|
|
49604
49619
|
import * as path57 from "path";
|
|
49605
|
-
|
|
49606
|
-
|
|
49620
|
+
import { isDeepStrictEqual } from "util";
|
|
49621
|
+
|
|
49622
|
+
// src/application/execution-plan-artifact.ts
|
|
49623
|
+
import { createHash as createHash13 } from "crypto";
|
|
49624
|
+
import { z as z54 } from "zod";
|
|
49625
|
+
var EXECUTION_PLAN_ARTIFACT_CONTRACT = "lexrunner.execution-plan-artifact.v1";
|
|
49626
|
+
var PLAN_ARTIFACT_REFERENCE_CONTRACT = "lexrunner.plan-artifact-reference.v1";
|
|
49627
|
+
var EXECUTION_PLAN_CANONICALIZATION_PROFILE = "lexrunner.execution-plan.canonical-json.v1";
|
|
49628
|
+
var EXECUTION_PLAN_HASH_PROFILE = "lexrunner.execution-plan-artifact.sha256.v1";
|
|
49629
|
+
var EXECUTION_PLAN_HASH_DOMAIN = "lexrunner:execution-plan-artifact:v1\0";
|
|
49630
|
+
var MAX_PLAN_ARTIFACT_BYTES = 4 * 1024 * 1024;
|
|
49631
|
+
var MAX_PLAN_RETRIEVAL_REFERENCE_BYTES = 4096;
|
|
49632
|
+
var MAX_SCOPE_LABEL_BYTES = 512;
|
|
49633
|
+
var Sha256Digest = z54.string().regex(/^sha256:[a-f0-9]{64}$/);
|
|
49634
|
+
var BoundedScopeLabel = z54.string().min(1).refine((value) => Buffer.byteLength(value, "utf8") <= MAX_SCOPE_LABEL_BYTES, {
|
|
49635
|
+
message: "Scope label exceeds the transport limit"
|
|
49636
|
+
});
|
|
49637
|
+
var BoundedIdentityLabel = z54.string().min(1).refine((value) => Buffer.byteLength(value, "utf8") <= MAX_SCOPE_LABEL_BYTES, {
|
|
49638
|
+
message: "Identity label exceeds the transport limit"
|
|
49639
|
+
});
|
|
49640
|
+
var PlanArtifactScope_v1Schema = z54.object({
|
|
49641
|
+
tenant: BoundedScopeLabel,
|
|
49642
|
+
workspace: BoundedScopeLabel,
|
|
49643
|
+
repository: BoundedScopeLabel,
|
|
49644
|
+
refNamespace: BoundedScopeLabel,
|
|
49645
|
+
policy: BoundedScopeLabel
|
|
49646
|
+
}).strict();
|
|
49647
|
+
var ExecutionPlanArtifactIdentity_v1Schema = z54.object({
|
|
49648
|
+
contract: z54.literal(EXECUTION_PLAN_ARTIFACT_CONTRACT),
|
|
49649
|
+
kind: z54.literal("execution-plan"),
|
|
49650
|
+
planSchema: z54.literal("lexrunner.execution-plan"),
|
|
49651
|
+
planSchemaVersion: BoundedIdentityLabel,
|
|
49652
|
+
canonicalizationProfile: z54.literal(EXECUTION_PLAN_CANONICALIZATION_PROFILE),
|
|
49653
|
+
hashProfile: z54.literal(EXECUTION_PLAN_HASH_PROFILE),
|
|
49654
|
+
digestAlgorithm: z54.literal("sha256"),
|
|
49655
|
+
digest: Sha256Digest,
|
|
49656
|
+
canonicalByteLength: z54.number().int().nonnegative().max(MAX_PLAN_ARTIFACT_BYTES),
|
|
49657
|
+
target: BoundedIdentityLabel,
|
|
49658
|
+
summary: z54.object({
|
|
49659
|
+
itemCount: z54.number().int().nonnegative().max(256),
|
|
49660
|
+
gateCount: z54.number().int().nonnegative().max(256 * 64)
|
|
49661
|
+
}).strict()
|
|
49662
|
+
}).strict();
|
|
49663
|
+
var ExecutionPlanArtifact_v1Schema = z54.object({
|
|
49664
|
+
identity: ExecutionPlanArtifactIdentity_v1Schema,
|
|
49665
|
+
canonicalBytes: z54.string()
|
|
49666
|
+
}).strict().superRefine((artifact, context) => {
|
|
49667
|
+
const byteLength = Buffer.byteLength(artifact.canonicalBytes, "utf8");
|
|
49668
|
+
if (byteLength > MAX_PLAN_ARTIFACT_BYTES) {
|
|
49669
|
+
context.addIssue({
|
|
49670
|
+
code: "custom",
|
|
49671
|
+
path: ["canonicalBytes"],
|
|
49672
|
+
message: "Canonical plan bytes exceed the artifact limit"
|
|
49673
|
+
});
|
|
49674
|
+
}
|
|
49675
|
+
if (byteLength !== artifact.identity.canonicalByteLength) {
|
|
49676
|
+
context.addIssue({
|
|
49677
|
+
code: "custom",
|
|
49678
|
+
path: ["identity", "canonicalByteLength"],
|
|
49679
|
+
message: "Canonical plan byte length does not match the artifact identity"
|
|
49680
|
+
});
|
|
49681
|
+
}
|
|
49682
|
+
if (computeExecutionPlanArtifactDigest(artifact.canonicalBytes) !== artifact.identity.digest) {
|
|
49683
|
+
context.addIssue({
|
|
49684
|
+
code: "custom",
|
|
49685
|
+
path: ["identity", "digest"],
|
|
49686
|
+
message: "Canonical plan digest does not match the artifact identity"
|
|
49687
|
+
});
|
|
49688
|
+
}
|
|
49689
|
+
try {
|
|
49690
|
+
const plan = loadPlan(artifact.canonicalBytes);
|
|
49691
|
+
if (canonicalJSONStringify(plan) !== artifact.canonicalBytes) {
|
|
49692
|
+
context.addIssue({
|
|
49693
|
+
code: "custom",
|
|
49694
|
+
path: ["canonicalBytes"],
|
|
49695
|
+
message: "Plan bytes are not in the declared canonical form"
|
|
49696
|
+
});
|
|
49697
|
+
}
|
|
49698
|
+
const gateCount = plan.items.reduce((count, item) => count + item.gates.length, 0);
|
|
49699
|
+
if (artifact.identity.planSchemaVersion !== plan.schemaVersion || artifact.identity.target !== plan.target || artifact.identity.summary.itemCount !== plan.items.length || artifact.identity.summary.gateCount !== gateCount) {
|
|
49700
|
+
context.addIssue({
|
|
49701
|
+
code: "custom",
|
|
49702
|
+
path: ["identity"],
|
|
49703
|
+
message: "Plan semantics do not match the artifact identity"
|
|
49704
|
+
});
|
|
49705
|
+
}
|
|
49706
|
+
} catch {
|
|
49707
|
+
context.addIssue({
|
|
49708
|
+
code: "custom",
|
|
49709
|
+
path: ["canonicalBytes"],
|
|
49710
|
+
message: "Canonical bytes do not contain a valid execution plan"
|
|
49711
|
+
});
|
|
49712
|
+
}
|
|
49713
|
+
});
|
|
49714
|
+
var PlanArtifactReference_v1Schema = z54.object({
|
|
49715
|
+
contract: z54.literal(PLAN_ARTIFACT_REFERENCE_CONTRACT),
|
|
49716
|
+
artifact: ExecutionPlanArtifactIdentity_v1Schema,
|
|
49717
|
+
expectedDigest: Sha256Digest,
|
|
49718
|
+
expectedCanonicalByteLength: z54.number().int().nonnegative().max(MAX_PLAN_ARTIFACT_BYTES),
|
|
49719
|
+
retrieval: z54.object({
|
|
49720
|
+
kind: z54.enum(["file", "registered"]),
|
|
49721
|
+
reference: z54.string().min(1).refine(
|
|
49722
|
+
(value) => !value.includes("\0") && Buffer.byteLength(value, "utf8") <= MAX_PLAN_RETRIEVAL_REFERENCE_BYTES,
|
|
49723
|
+
{ message: "Retrieval reference is invalid or exceeds the transport limit" }
|
|
49724
|
+
)
|
|
49725
|
+
}).strict(),
|
|
49726
|
+
scope: PlanArtifactScope_v1Schema.optional()
|
|
49727
|
+
}).strict().superRefine((reference, context) => {
|
|
49728
|
+
if (reference.expectedDigest !== reference.artifact.digest) {
|
|
49729
|
+
context.addIssue({
|
|
49730
|
+
code: "custom",
|
|
49731
|
+
path: ["expectedDigest"],
|
|
49732
|
+
message: "Expected digest does not match the embedded artifact identity"
|
|
49733
|
+
});
|
|
49734
|
+
}
|
|
49735
|
+
if (reference.expectedCanonicalByteLength !== reference.artifact.canonicalByteLength) {
|
|
49736
|
+
context.addIssue({
|
|
49737
|
+
code: "custom",
|
|
49738
|
+
path: ["expectedCanonicalByteLength"],
|
|
49739
|
+
message: "Expected byte length does not match the embedded artifact identity"
|
|
49740
|
+
});
|
|
49741
|
+
}
|
|
49742
|
+
});
|
|
49743
|
+
function computeExecutionPlanArtifactDigest(canonicalBytes2) {
|
|
49744
|
+
const digest = createHash13("sha256").update(EXECUTION_PLAN_HASH_DOMAIN, "utf8").update(canonicalBytes2, "utf8").digest("hex");
|
|
49745
|
+
return `sha256:${digest}`;
|
|
49746
|
+
}
|
|
49747
|
+
|
|
49748
|
+
// src/application/plan-artifact-service.ts
|
|
49607
49749
|
var MAX_PLAN_ITEMS = 256;
|
|
49608
49750
|
var MAX_GATES_PER_ITEM2 = 64;
|
|
49609
49751
|
var MAX_IDENTITY_LABEL_BYTES = 512;
|
|
@@ -49615,16 +49757,41 @@ var PlanArtifactServiceError = class extends Error {
|
|
|
49615
49757
|
this.name = "PlanArtifactServiceError";
|
|
49616
49758
|
}
|
|
49617
49759
|
};
|
|
49760
|
+
var _hooks;
|
|
49618
49761
|
var PlanArtifactService = class {
|
|
49762
|
+
constructor(options = {}) {
|
|
49763
|
+
__privateAdd(this, _hooks);
|
|
49764
|
+
__privateSet(this, _hooks, options.importHooks ?? {});
|
|
49765
|
+
}
|
|
49619
49766
|
resolve(input = {}) {
|
|
49620
49767
|
const workingDir = path57.resolve(input.workingDir ?? process.cwd());
|
|
49768
|
+
const scope = parseScope(input.scope);
|
|
49769
|
+
if (input.planReference !== void 0 && input.planFile !== void 0) {
|
|
49770
|
+
throw new PlanArtifactServiceError(
|
|
49771
|
+
"PLAN_REFERENCE_INVALID",
|
|
49772
|
+
"Provide either an immutable plan reference or an explicit plan path, not both",
|
|
49773
|
+
"explicit"
|
|
49774
|
+
);
|
|
49775
|
+
}
|
|
49776
|
+
if (input.planReference !== void 0 && input.scope !== void 0) {
|
|
49777
|
+
throw new PlanArtifactServiceError(
|
|
49778
|
+
"PLAN_REFERENCE_INVALID",
|
|
49779
|
+
"A separately supplied scope cannot override an immutable plan reference",
|
|
49780
|
+
"explicit"
|
|
49781
|
+
);
|
|
49782
|
+
}
|
|
49783
|
+
if (input.planReference !== void 0) {
|
|
49784
|
+
const reference = parseReference(input.planReference);
|
|
49785
|
+
const explicitPath = resolveExplicitReference(reference.retrieval.reference, workingDir);
|
|
49786
|
+
return readArtifact(explicitPath, "explicit", __privateGet(this, _hooks), reference);
|
|
49787
|
+
}
|
|
49621
49788
|
if (input.planFile !== void 0) {
|
|
49622
49789
|
const explicitPath = resolveExplicitReference(input.planFile, workingDir);
|
|
49623
|
-
return readArtifact(explicitPath, "explicit");
|
|
49790
|
+
return readArtifact(explicitPath, "explicit", __privateGet(this, _hooks), void 0, scope);
|
|
49624
49791
|
}
|
|
49625
49792
|
const repositoryPlan = path57.join(workingDir, "plan.json");
|
|
49626
|
-
if (
|
|
49627
|
-
return readArtifact(repositoryPlan, "repository-root");
|
|
49793
|
+
if (pathEntryExists(repositoryPlan)) {
|
|
49794
|
+
return readArtifact(repositoryPlan, "repository-root", __privateGet(this, _hooks), void 0, scope);
|
|
49628
49795
|
}
|
|
49629
49796
|
let profilePlan;
|
|
49630
49797
|
try {
|
|
@@ -49632,8 +49799,8 @@ var PlanArtifactService = class {
|
|
|
49632
49799
|
profilePlan = path57.join(profile.path, "runner", "plan.json");
|
|
49633
49800
|
} catch {
|
|
49634
49801
|
}
|
|
49635
|
-
if (profilePlan &&
|
|
49636
|
-
return readArtifact(profilePlan, "profile-runner");
|
|
49802
|
+
if (profilePlan && pathEntryExists(profilePlan)) {
|
|
49803
|
+
return readArtifact(profilePlan, "profile-runner", __privateGet(this, _hooks), void 0, scope);
|
|
49637
49804
|
}
|
|
49638
49805
|
throw new PlanArtifactServiceError(
|
|
49639
49806
|
"PLAN_NOT_FOUND",
|
|
@@ -49641,46 +49808,85 @@ var PlanArtifactService = class {
|
|
|
49641
49808
|
);
|
|
49642
49809
|
}
|
|
49643
49810
|
};
|
|
49644
|
-
|
|
49645
|
-
|
|
49811
|
+
_hooks = new WeakMap();
|
|
49812
|
+
function parseReference(reference) {
|
|
49813
|
+
const parsed = PlanArtifactReference_v1Schema.safeParse(reference);
|
|
49814
|
+
if (!parsed.success) {
|
|
49646
49815
|
throw new PlanArtifactServiceError(
|
|
49647
49816
|
"PLAN_REFERENCE_INVALID",
|
|
49648
|
-
"The
|
|
49817
|
+
"The immutable plan reference does not satisfy the bounded transport contract",
|
|
49649
49818
|
"explicit"
|
|
49650
49819
|
);
|
|
49651
49820
|
}
|
|
49652
|
-
return
|
|
49821
|
+
return parsed.data;
|
|
49653
49822
|
}
|
|
49654
|
-
function
|
|
49655
|
-
|
|
49656
|
-
|
|
49657
|
-
|
|
49658
|
-
} catch {
|
|
49823
|
+
function parseScope(scope) {
|
|
49824
|
+
if (scope === void 0) return void 0;
|
|
49825
|
+
const parsed = PlanArtifactScope_v1Schema.safeParse(scope);
|
|
49826
|
+
if (!parsed.success) {
|
|
49659
49827
|
throw new PlanArtifactServiceError(
|
|
49660
|
-
"
|
|
49661
|
-
"The
|
|
49662
|
-
|
|
49828
|
+
"PLAN_REFERENCE_INVALID",
|
|
49829
|
+
"The plan scope does not satisfy the bounded transport contract",
|
|
49830
|
+
"explicit"
|
|
49663
49831
|
);
|
|
49664
49832
|
}
|
|
49665
|
-
|
|
49833
|
+
return parsed.data;
|
|
49834
|
+
}
|
|
49835
|
+
function resolveExplicitReference(reference, workingDir) {
|
|
49836
|
+
if (reference.length === 0 || reference.includes("\0") || Buffer.byteLength(reference, "utf8") > MAX_PLAN_RETRIEVAL_REFERENCE_BYTES) {
|
|
49666
49837
|
throw new PlanArtifactServiceError(
|
|
49667
|
-
"
|
|
49668
|
-
"The
|
|
49838
|
+
"PLAN_REFERENCE_INVALID",
|
|
49839
|
+
"The explicit plan reference is empty, overlong, or contains an invalid character",
|
|
49840
|
+
"explicit"
|
|
49841
|
+
);
|
|
49842
|
+
}
|
|
49843
|
+
return path57.isAbsolute(reference) ? path57.normalize(reference) : path57.resolve(workingDir, reference);
|
|
49844
|
+
}
|
|
49845
|
+
function readArtifact(filePath, source, hooks, expected, scope) {
|
|
49846
|
+
const content = readPortableRaceDetectedFile(filePath, source, hooks);
|
|
49847
|
+
const plan = loadPlan(content);
|
|
49848
|
+
assertBoundedArtifact(plan, source);
|
|
49849
|
+
const canonicalBytes2 = canonicalJSONStringify(plan);
|
|
49850
|
+
const canonicalByteLength = Buffer.byteLength(canonicalBytes2, "utf8");
|
|
49851
|
+
if (canonicalByteLength > MAX_PLAN_ARTIFACT_BYTES) {
|
|
49852
|
+
throw new PlanArtifactServiceError(
|
|
49853
|
+
"PLAN_ARTIFACT_LIMIT_EXCEEDED",
|
|
49854
|
+
"The canonical integration plan exceeds the artifact byte limit",
|
|
49669
49855
|
source
|
|
49670
49856
|
);
|
|
49671
49857
|
}
|
|
49672
|
-
|
|
49673
|
-
|
|
49674
|
-
|
|
49675
|
-
|
|
49858
|
+
const artifactIdentity = {
|
|
49859
|
+
contract: EXECUTION_PLAN_ARTIFACT_CONTRACT,
|
|
49860
|
+
kind: "execution-plan",
|
|
49861
|
+
planSchema: "lexrunner.execution-plan",
|
|
49862
|
+
planSchemaVersion: plan.schemaVersion,
|
|
49863
|
+
canonicalizationProfile: EXECUTION_PLAN_CANONICALIZATION_PROFILE,
|
|
49864
|
+
hashProfile: EXECUTION_PLAN_HASH_PROFILE,
|
|
49865
|
+
digestAlgorithm: "sha256",
|
|
49866
|
+
digest: computeExecutionPlanArtifactDigest(canonicalBytes2),
|
|
49867
|
+
canonicalByteLength,
|
|
49868
|
+
target: plan.target,
|
|
49869
|
+
summary: {
|
|
49870
|
+
itemCount: plan.items.length,
|
|
49871
|
+
gateCount: plan.items.reduce((count, item) => count + item.gates.length, 0)
|
|
49872
|
+
}
|
|
49873
|
+
};
|
|
49874
|
+
const artifact = { identity: artifactIdentity, canonicalBytes: canonicalBytes2 };
|
|
49875
|
+
if (expected && !isDeepStrictEqual(expected.artifact, artifactIdentity)) {
|
|
49676
49876
|
throw new PlanArtifactServiceError(
|
|
49677
|
-
"
|
|
49678
|
-
"The
|
|
49877
|
+
"PLAN_REFERENCE_MISMATCH",
|
|
49878
|
+
"The retrieved integration plan does not match the immutable reference",
|
|
49679
49879
|
source
|
|
49680
49880
|
);
|
|
49681
49881
|
}
|
|
49682
|
-
const
|
|
49683
|
-
|
|
49882
|
+
const reference = expected ?? parseReference({
|
|
49883
|
+
contract: PLAN_ARTIFACT_REFERENCE_CONTRACT,
|
|
49884
|
+
artifact: artifactIdentity,
|
|
49885
|
+
expectedDigest: artifactIdentity.digest,
|
|
49886
|
+
expectedCanonicalByteLength: artifactIdentity.canonicalByteLength,
|
|
49887
|
+
retrieval: { kind: "file", reference: filePath },
|
|
49888
|
+
...scope ? { scope } : {}
|
|
49889
|
+
});
|
|
49684
49890
|
return {
|
|
49685
49891
|
plan,
|
|
49686
49892
|
identity: {
|
|
@@ -49692,10 +49898,167 @@ function readArtifact(filePath, source) {
|
|
|
49692
49898
|
target: plan.target,
|
|
49693
49899
|
itemCount: plan.items.length
|
|
49694
49900
|
},
|
|
49901
|
+
artifact,
|
|
49902
|
+
reference,
|
|
49903
|
+
acquisition: {
|
|
49904
|
+
contract: "lexrunner.plan-artifact-acquisition.v1",
|
|
49905
|
+
assurance: "portable-race-detection",
|
|
49906
|
+
authority: "unverified"
|
|
49907
|
+
},
|
|
49695
49908
|
source,
|
|
49696
49909
|
filePath
|
|
49697
49910
|
};
|
|
49698
49911
|
}
|
|
49912
|
+
function readPortableRaceDetectedFile(filePath, source, hooks) {
|
|
49913
|
+
const initialPath = snapshotPath(filePath, source);
|
|
49914
|
+
hooks.afterInitialPathSnapshot?.();
|
|
49915
|
+
const noFollow = typeof fs48.constants.O_NOFOLLOW === "number" ? fs48.constants.O_NOFOLLOW : 0;
|
|
49916
|
+
let descriptor;
|
|
49917
|
+
try {
|
|
49918
|
+
descriptor = fs48.openSync(filePath, fs48.constants.O_RDONLY | noFollow);
|
|
49919
|
+
} catch (error) {
|
|
49920
|
+
throw importError(error, source);
|
|
49921
|
+
}
|
|
49922
|
+
let bytes;
|
|
49923
|
+
try {
|
|
49924
|
+
const before = fs48.fstatSync(descriptor, { bigint: true });
|
|
49925
|
+
assertOpenedIdentity(initialPath[initialPath.length - 1].stats, before, source);
|
|
49926
|
+
hooks.afterOpen?.();
|
|
49927
|
+
if (before.size > BigInt(MAX_PLAN_ARTIFACT_BYTES)) {
|
|
49928
|
+
throw new PlanArtifactServiceError(
|
|
49929
|
+
"PLAN_ARTIFACT_LIMIT_EXCEEDED",
|
|
49930
|
+
"The referenced integration plan exceeds the artifact byte limit",
|
|
49931
|
+
source
|
|
49932
|
+
);
|
|
49933
|
+
}
|
|
49934
|
+
bytes = readAtMost(descriptor, MAX_PLAN_ARTIFACT_BYTES + 1);
|
|
49935
|
+
hooks.afterRead?.();
|
|
49936
|
+
const after = fs48.fstatSync(descriptor, { bigint: true });
|
|
49937
|
+
assertStableOpenedFile(before, after, bytes.length, source);
|
|
49938
|
+
} finally {
|
|
49939
|
+
fs48.closeSync(descriptor);
|
|
49940
|
+
}
|
|
49941
|
+
hooks.beforeFinalPathSnapshot?.();
|
|
49942
|
+
const finalPath = snapshotPath(filePath, source);
|
|
49943
|
+
assertStablePath(initialPath, finalPath, source);
|
|
49944
|
+
try {
|
|
49945
|
+
return new TextDecoder("utf-8", { fatal: true }).decode(bytes);
|
|
49946
|
+
} catch {
|
|
49947
|
+
throw new PlanArtifactServiceError(
|
|
49948
|
+
"PLAN_UNREADABLE",
|
|
49949
|
+
"The referenced integration plan is not valid UTF-8",
|
|
49950
|
+
source
|
|
49951
|
+
);
|
|
49952
|
+
}
|
|
49953
|
+
}
|
|
49954
|
+
function snapshotPath(filePath, source) {
|
|
49955
|
+
const absolute = path57.resolve(filePath);
|
|
49956
|
+
const root = path57.parse(absolute).root;
|
|
49957
|
+
const relative5 = path57.relative(root, absolute);
|
|
49958
|
+
const segments = relative5.length === 0 ? [] : relative5.split(path57.sep);
|
|
49959
|
+
const candidates = [root];
|
|
49960
|
+
let current = root;
|
|
49961
|
+
for (const segment of segments) {
|
|
49962
|
+
current = path57.join(current, segment);
|
|
49963
|
+
candidates.push(current);
|
|
49964
|
+
}
|
|
49965
|
+
return candidates.map((candidate, index) => {
|
|
49966
|
+
let stats;
|
|
49967
|
+
try {
|
|
49968
|
+
stats = fs48.lstatSync(candidate, { bigint: true });
|
|
49969
|
+
} catch (error) {
|
|
49970
|
+
throw importError(error, source);
|
|
49971
|
+
}
|
|
49972
|
+
const leaf = index === candidates.length - 1;
|
|
49973
|
+
if (stats.isSymbolicLink()) {
|
|
49974
|
+
throw new PlanArtifactServiceError(
|
|
49975
|
+
"PLAN_FILESYSTEM_UNSAFE",
|
|
49976
|
+
"The integration plan path contains an unsafe filesystem object",
|
|
49977
|
+
source
|
|
49978
|
+
);
|
|
49979
|
+
}
|
|
49980
|
+
if (leaf ? !stats.isFile() : !stats.isDirectory()) {
|
|
49981
|
+
throw new PlanArtifactServiceError(
|
|
49982
|
+
"PLAN_UNREADABLE",
|
|
49983
|
+
"The referenced integration plan is not a readable bounded file",
|
|
49984
|
+
source
|
|
49985
|
+
);
|
|
49986
|
+
}
|
|
49987
|
+
if (leaf && stats.nlink !== 1n) {
|
|
49988
|
+
throw new PlanArtifactServiceError(
|
|
49989
|
+
"PLAN_FILESYSTEM_UNSAFE",
|
|
49990
|
+
"The integration plan file has an ambiguous filesystem identity",
|
|
49991
|
+
source
|
|
49992
|
+
);
|
|
49993
|
+
}
|
|
49994
|
+
return { stats, leaf };
|
|
49995
|
+
});
|
|
49996
|
+
}
|
|
49997
|
+
function assertOpenedIdentity(pathStats, openedStats, source) {
|
|
49998
|
+
if (!openedStats.isFile() || openedStats.nlink !== 1n || !sameObject(pathStats, openedStats) || pathStats.size !== openedStats.size || pathStats.mtimeNs !== openedStats.mtimeNs || pathStats.ctimeNs !== openedStats.ctimeNs) {
|
|
49999
|
+
throw new PlanArtifactServiceError(
|
|
50000
|
+
"PLAN_FILESYSTEM_UNSAFE",
|
|
50001
|
+
"The integration plan filesystem identity changed during acquisition",
|
|
50002
|
+
source
|
|
50003
|
+
);
|
|
50004
|
+
}
|
|
50005
|
+
}
|
|
50006
|
+
function assertStableOpenedFile(before, after, bytesRead, source) {
|
|
50007
|
+
if (bytesRead > MAX_PLAN_ARTIFACT_BYTES) {
|
|
50008
|
+
throw new PlanArtifactServiceError(
|
|
50009
|
+
"PLAN_ARTIFACT_LIMIT_EXCEEDED",
|
|
50010
|
+
"The referenced integration plan exceeds the artifact byte limit",
|
|
50011
|
+
source
|
|
50012
|
+
);
|
|
50013
|
+
}
|
|
50014
|
+
if (!after.isFile() || after.nlink !== 1n || !sameObject(before, after) || before.size !== after.size || before.mtimeNs !== after.mtimeNs || before.ctimeNs !== after.ctimeNs || BigInt(bytesRead) !== before.size) {
|
|
50015
|
+
throw new PlanArtifactServiceError(
|
|
50016
|
+
"PLAN_FILESYSTEM_UNSAFE",
|
|
50017
|
+
"The integration plan changed while its bytes were being acquired",
|
|
50018
|
+
source
|
|
50019
|
+
);
|
|
50020
|
+
}
|
|
50021
|
+
}
|
|
50022
|
+
function assertStablePath(before, after, source) {
|
|
50023
|
+
if (before.length !== after.length || before.some((entry, index) => {
|
|
50024
|
+
const current = after[index];
|
|
50025
|
+
return !current || entry.leaf !== current.leaf || !sameObject(entry.stats, current.stats) || entry.leaf && (entry.stats.size !== current.stats.size || entry.stats.mtimeNs !== current.stats.mtimeNs || entry.stats.ctimeNs !== current.stats.ctimeNs || current.stats.nlink !== 1n);
|
|
50026
|
+
})) {
|
|
50027
|
+
throw new PlanArtifactServiceError(
|
|
50028
|
+
"PLAN_FILESYSTEM_UNSAFE",
|
|
50029
|
+
"The integration plan path changed while its bytes were being acquired",
|
|
50030
|
+
source
|
|
50031
|
+
);
|
|
50032
|
+
}
|
|
50033
|
+
}
|
|
50034
|
+
function sameObject(left, right) {
|
|
50035
|
+
return left.dev === right.dev && left.ino === right.ino && left.mode === right.mode;
|
|
50036
|
+
}
|
|
50037
|
+
function readAtMost(descriptor, maximumBytes) {
|
|
50038
|
+
const buffer = Buffer.allocUnsafe(maximumBytes);
|
|
50039
|
+
let offset = 0;
|
|
50040
|
+
while (offset < maximumBytes) {
|
|
50041
|
+
const count = fs48.readSync(descriptor, buffer, offset, maximumBytes - offset, null);
|
|
50042
|
+
if (count === 0) break;
|
|
50043
|
+
offset += count;
|
|
50044
|
+
}
|
|
50045
|
+
return buffer.subarray(0, offset);
|
|
50046
|
+
}
|
|
50047
|
+
function importError(error, source) {
|
|
50048
|
+
const code = error?.code;
|
|
50049
|
+
if (code === "ENOENT" || code === "ENOTDIR") {
|
|
50050
|
+
return new PlanArtifactServiceError(
|
|
50051
|
+
"PLAN_NOT_FOUND",
|
|
50052
|
+
"The referenced integration plan does not exist",
|
|
50053
|
+
source
|
|
50054
|
+
);
|
|
50055
|
+
}
|
|
50056
|
+
return new PlanArtifactServiceError(
|
|
50057
|
+
"PLAN_UNREADABLE",
|
|
50058
|
+
"The referenced integration plan could not be safely read",
|
|
50059
|
+
source
|
|
50060
|
+
);
|
|
50061
|
+
}
|
|
49699
50062
|
function assertBoundedArtifact(plan, source) {
|
|
49700
50063
|
const labels = [
|
|
49701
50064
|
plan.schemaVersion,
|
|
@@ -49710,11 +50073,277 @@ function assertBoundedArtifact(plan, source) {
|
|
|
49710
50073
|
);
|
|
49711
50074
|
}
|
|
49712
50075
|
}
|
|
49713
|
-
function
|
|
50076
|
+
function pathEntryExists(filePath) {
|
|
49714
50077
|
try {
|
|
49715
|
-
|
|
49716
|
-
|
|
49717
|
-
|
|
50078
|
+
fs48.lstatSync(filePath);
|
|
50079
|
+
return true;
|
|
50080
|
+
} catch (error) {
|
|
50081
|
+
const code = error?.code;
|
|
50082
|
+
if (code === "ENOENT" || code === "ENOTDIR") return false;
|
|
50083
|
+
return true;
|
|
50084
|
+
}
|
|
50085
|
+
}
|
|
50086
|
+
|
|
50087
|
+
// src/application/plan-artifact-registration-service.ts
|
|
50088
|
+
import * as fs49 from "fs";
|
|
50089
|
+
import * as path58 from "path";
|
|
50090
|
+
import { randomUUID as randomUUID9 } from "crypto";
|
|
50091
|
+
var PlanArtifactRegistrationError = class extends Error {
|
|
50092
|
+
constructor(code, message) {
|
|
50093
|
+
super(message);
|
|
50094
|
+
this.code = code;
|
|
50095
|
+
this.name = "PlanArtifactRegistrationError";
|
|
50096
|
+
}
|
|
50097
|
+
};
|
|
50098
|
+
var _PlanArtifactRegistrationService_instances, verifyExisting_fn;
|
|
50099
|
+
var PlanArtifactRegistrationService = class {
|
|
50100
|
+
constructor() {
|
|
50101
|
+
__privateAdd(this, _PlanArtifactRegistrationService_instances);
|
|
50102
|
+
}
|
|
50103
|
+
register(input) {
|
|
50104
|
+
const parsed = ExecutionPlanArtifact_v1Schema.safeParse(input.artifact);
|
|
50105
|
+
if (!parsed.success) {
|
|
50106
|
+
throw new PlanArtifactRegistrationError(
|
|
50107
|
+
"PLAN_REGISTRATION_INVALID",
|
|
50108
|
+
"The plan artifact does not satisfy the immutable artifact contract"
|
|
50109
|
+
);
|
|
50110
|
+
}
|
|
50111
|
+
const artifact = parsed.data;
|
|
50112
|
+
const scope = parseScope2(input.scope);
|
|
50113
|
+
const storeDirectory = validateStoreReference(input.storeDirectory);
|
|
50114
|
+
prepareControlledStore(storeDirectory);
|
|
50115
|
+
const digestName = `${artifact.identity.digest.slice("sha256:".length)}.json`;
|
|
50116
|
+
const artifactPath = path58.join(storeDirectory, digestName);
|
|
50117
|
+
const reference = createRegisteredReference(artifact, artifactPath, scope);
|
|
50118
|
+
if (pathEntryExists2(artifactPath)) {
|
|
50119
|
+
return __privateMethod(this, _PlanArtifactRegistrationService_instances, verifyExisting_fn).call(this, artifact, reference, false);
|
|
50120
|
+
}
|
|
50121
|
+
const temporaryPath = path58.join(storeDirectory, `.plan-${randomUUID9()}.tmp`);
|
|
50122
|
+
let temporaryCreated = false;
|
|
50123
|
+
try {
|
|
50124
|
+
const descriptor = fs49.openSync(
|
|
50125
|
+
temporaryPath,
|
|
50126
|
+
fs49.constants.O_WRONLY | fs49.constants.O_CREAT | fs49.constants.O_EXCL,
|
|
50127
|
+
384
|
|
50128
|
+
);
|
|
50129
|
+
temporaryCreated = true;
|
|
50130
|
+
try {
|
|
50131
|
+
writeAll(descriptor, Buffer.from(artifact.canonicalBytes, "utf8"));
|
|
50132
|
+
fs49.fsyncSync(descriptor);
|
|
50133
|
+
} finally {
|
|
50134
|
+
fs49.closeSync(descriptor);
|
|
50135
|
+
}
|
|
50136
|
+
try {
|
|
50137
|
+
fs49.linkSync(temporaryPath, artifactPath);
|
|
50138
|
+
} catch (error) {
|
|
50139
|
+
if (!pathEntryExists2(artifactPath)) throw error;
|
|
50140
|
+
return __privateMethod(this, _PlanArtifactRegistrationService_instances, verifyExisting_fn).call(this, artifact, reference, false);
|
|
50141
|
+
}
|
|
50142
|
+
try {
|
|
50143
|
+
fs49.unlinkSync(temporaryPath);
|
|
50144
|
+
} catch (error) {
|
|
50145
|
+
if (error.code !== "ENOENT") throw error;
|
|
50146
|
+
}
|
|
50147
|
+
temporaryCreated = false;
|
|
50148
|
+
flushDirectoryWhenSupported(storeDirectory);
|
|
50149
|
+
assertStoreDirectory(storeDirectory);
|
|
50150
|
+
return __privateMethod(this, _PlanArtifactRegistrationService_instances, verifyExisting_fn).call(this, artifact, reference, true);
|
|
50151
|
+
} catch (error) {
|
|
50152
|
+
if (error instanceof PlanArtifactRegistrationError) throw error;
|
|
50153
|
+
throw new PlanArtifactRegistrationError(
|
|
50154
|
+
"PLAN_REGISTRATION_UNSAFE",
|
|
50155
|
+
"The plan artifact could not be published without replacing existing bytes"
|
|
50156
|
+
);
|
|
50157
|
+
} finally {
|
|
50158
|
+
if (temporaryCreated) {
|
|
50159
|
+
try {
|
|
50160
|
+
fs49.unlinkSync(temporaryPath);
|
|
50161
|
+
} catch {
|
|
50162
|
+
}
|
|
50163
|
+
}
|
|
50164
|
+
}
|
|
50165
|
+
}
|
|
50166
|
+
};
|
|
50167
|
+
_PlanArtifactRegistrationService_instances = new WeakSet();
|
|
50168
|
+
verifyExisting_fn = function(artifact, reference, created) {
|
|
50169
|
+
try {
|
|
50170
|
+
waitForConcurrentPublisher(reference.retrieval.reference);
|
|
50171
|
+
const resolved = new PlanArtifactService().resolve({ planReference: reference });
|
|
50172
|
+
if (resolved.artifact.canonicalBytes !== artifact.canonicalBytes) {
|
|
50173
|
+
throw new PlanArtifactRegistrationError(
|
|
50174
|
+
"PLAN_REGISTRATION_CONFLICT",
|
|
50175
|
+
"The content-addressed plan object conflicts with the requested artifact"
|
|
50176
|
+
);
|
|
50177
|
+
}
|
|
50178
|
+
return {
|
|
50179
|
+
artifact: resolved.artifact,
|
|
50180
|
+
reference,
|
|
50181
|
+
created,
|
|
50182
|
+
storage: { assurance: "service-no-replace-verified", authority: "unverified" }
|
|
50183
|
+
};
|
|
50184
|
+
} catch (error) {
|
|
50185
|
+
if (error instanceof PlanArtifactRegistrationError) throw error;
|
|
50186
|
+
if (error instanceof PlanArtifactServiceError && error.code === "PLAN_REFERENCE_MISMATCH") {
|
|
50187
|
+
throw new PlanArtifactRegistrationError(
|
|
50188
|
+
"PLAN_REGISTRATION_CONFLICT",
|
|
50189
|
+
"The content-addressed plan object conflicts with the requested artifact"
|
|
50190
|
+
);
|
|
50191
|
+
}
|
|
50192
|
+
throw new PlanArtifactRegistrationError(
|
|
50193
|
+
"PLAN_REGISTRATION_VERIFY_FAILED",
|
|
50194
|
+
"The persisted plan artifact could not be reread and verified"
|
|
50195
|
+
);
|
|
50196
|
+
}
|
|
50197
|
+
};
|
|
50198
|
+
function createRegisteredReference(artifact, artifactPath, scope) {
|
|
50199
|
+
if (Buffer.byteLength(artifactPath, "utf8") > 4096) {
|
|
50200
|
+
throw new PlanArtifactRegistrationError(
|
|
50201
|
+
"PLAN_REGISTRATION_INVALID",
|
|
50202
|
+
"The artifact store cannot produce a bounded retrieval reference"
|
|
50203
|
+
);
|
|
50204
|
+
}
|
|
50205
|
+
const reference = {
|
|
50206
|
+
contract: PLAN_ARTIFACT_REFERENCE_CONTRACT,
|
|
50207
|
+
artifact: artifact.identity,
|
|
50208
|
+
expectedDigest: artifact.identity.digest,
|
|
50209
|
+
expectedCanonicalByteLength: artifact.identity.canonicalByteLength,
|
|
50210
|
+
retrieval: { kind: "registered", reference: artifactPath },
|
|
50211
|
+
...scope ? { scope } : {}
|
|
50212
|
+
};
|
|
50213
|
+
const parsed = PlanArtifactReference_v1Schema.safeParse(reference);
|
|
50214
|
+
if (!parsed.success) {
|
|
50215
|
+
throw new PlanArtifactRegistrationError(
|
|
50216
|
+
"PLAN_REGISTRATION_INVALID",
|
|
50217
|
+
"The registered artifact reference does not satisfy the bounded transport contract"
|
|
50218
|
+
);
|
|
50219
|
+
}
|
|
50220
|
+
return parsed.data;
|
|
50221
|
+
}
|
|
50222
|
+
function parseScope2(scope) {
|
|
50223
|
+
if (scope === void 0) return void 0;
|
|
50224
|
+
const parsed = PlanArtifactScope_v1Schema.safeParse(scope);
|
|
50225
|
+
if (!parsed.success) {
|
|
50226
|
+
throw new PlanArtifactRegistrationError(
|
|
50227
|
+
"PLAN_REGISTRATION_INVALID",
|
|
50228
|
+
"The plan scope does not satisfy the bounded transport contract"
|
|
50229
|
+
);
|
|
50230
|
+
}
|
|
50231
|
+
return parsed.data;
|
|
50232
|
+
}
|
|
50233
|
+
function validateStoreReference(reference) {
|
|
50234
|
+
if (reference.length === 0 || reference.includes("\0") || Buffer.byteLength(reference, "utf8") > 4096) {
|
|
50235
|
+
throw new PlanArtifactRegistrationError(
|
|
50236
|
+
"PLAN_REGISTRATION_INVALID",
|
|
50237
|
+
"The artifact store reference is invalid or exceeds its bound"
|
|
50238
|
+
);
|
|
50239
|
+
}
|
|
50240
|
+
return path58.resolve(reference);
|
|
50241
|
+
}
|
|
50242
|
+
function prepareControlledStore(storeDirectory) {
|
|
50243
|
+
const root = path58.parse(storeDirectory).root;
|
|
50244
|
+
const segments = path58.relative(root, storeDirectory).split(path58.sep).filter(Boolean);
|
|
50245
|
+
let current = root;
|
|
50246
|
+
for (const segment of segments) {
|
|
50247
|
+
current = path58.join(current, segment);
|
|
50248
|
+
try {
|
|
50249
|
+
const stats = fs49.lstatSync(current);
|
|
50250
|
+
if (stats.isSymbolicLink() || !stats.isDirectory()) {
|
|
50251
|
+
throw new PlanArtifactRegistrationError(
|
|
50252
|
+
"PLAN_REGISTRATION_UNSAFE",
|
|
50253
|
+
"The artifact store contains an unsafe filesystem object"
|
|
50254
|
+
);
|
|
50255
|
+
}
|
|
50256
|
+
} catch (error) {
|
|
50257
|
+
if (error instanceof PlanArtifactRegistrationError) throw error;
|
|
50258
|
+
if (error.code !== "ENOENT") {
|
|
50259
|
+
throw new PlanArtifactRegistrationError(
|
|
50260
|
+
"PLAN_REGISTRATION_UNSAFE",
|
|
50261
|
+
"The artifact store identity is unavailable"
|
|
50262
|
+
);
|
|
50263
|
+
}
|
|
50264
|
+
try {
|
|
50265
|
+
fs49.mkdirSync(current, { mode: 448 });
|
|
50266
|
+
} catch (mkdirError) {
|
|
50267
|
+
if (mkdirError.code !== "EEXIST") {
|
|
50268
|
+
throw new PlanArtifactRegistrationError(
|
|
50269
|
+
"PLAN_REGISTRATION_UNSAFE",
|
|
50270
|
+
"The artifact store could not be prepared"
|
|
50271
|
+
);
|
|
50272
|
+
}
|
|
50273
|
+
}
|
|
50274
|
+
const created = fs49.lstatSync(current);
|
|
50275
|
+
if (created.isSymbolicLink() || !created.isDirectory()) {
|
|
50276
|
+
throw new PlanArtifactRegistrationError(
|
|
50277
|
+
"PLAN_REGISTRATION_UNSAFE",
|
|
50278
|
+
"The artifact store contains an unsafe filesystem object"
|
|
50279
|
+
);
|
|
50280
|
+
}
|
|
50281
|
+
}
|
|
50282
|
+
}
|
|
50283
|
+
assertStoreDirectory(storeDirectory);
|
|
50284
|
+
}
|
|
50285
|
+
function assertStoreDirectory(storeDirectory) {
|
|
50286
|
+
const root = path58.parse(storeDirectory).root;
|
|
50287
|
+
const segments = path58.relative(root, storeDirectory).split(path58.sep).filter(Boolean);
|
|
50288
|
+
let current = root;
|
|
50289
|
+
for (const segment of segments) {
|
|
50290
|
+
current = path58.join(current, segment);
|
|
50291
|
+
let stats;
|
|
50292
|
+
try {
|
|
50293
|
+
stats = fs49.lstatSync(current);
|
|
50294
|
+
} catch {
|
|
50295
|
+
throw new PlanArtifactRegistrationError(
|
|
50296
|
+
"PLAN_REGISTRATION_UNSAFE",
|
|
50297
|
+
"The artifact store identity is unavailable"
|
|
50298
|
+
);
|
|
50299
|
+
}
|
|
50300
|
+
if (stats.isSymbolicLink() || !stats.isDirectory()) {
|
|
50301
|
+
throw new PlanArtifactRegistrationError(
|
|
50302
|
+
"PLAN_REGISTRATION_UNSAFE",
|
|
50303
|
+
"The artifact store contains an unsafe filesystem object"
|
|
50304
|
+
);
|
|
50305
|
+
}
|
|
50306
|
+
}
|
|
50307
|
+
}
|
|
50308
|
+
function writeAll(descriptor, bytes) {
|
|
50309
|
+
let offset = 0;
|
|
50310
|
+
while (offset < bytes.length) {
|
|
50311
|
+
offset += fs49.writeSync(descriptor, bytes, offset, bytes.length - offset, null);
|
|
50312
|
+
}
|
|
50313
|
+
}
|
|
50314
|
+
function flushDirectoryWhenSupported(directory) {
|
|
50315
|
+
let descriptor;
|
|
50316
|
+
try {
|
|
50317
|
+
descriptor = fs49.openSync(directory, fs49.constants.O_RDONLY);
|
|
50318
|
+
fs49.fsyncSync(descriptor);
|
|
50319
|
+
} catch (error) {
|
|
50320
|
+
const code = error?.code;
|
|
50321
|
+
if (process.platform !== "win32" || code !== "EISDIR" && code !== "EPERM") throw error;
|
|
50322
|
+
} finally {
|
|
50323
|
+
if (descriptor !== void 0) fs49.closeSync(descriptor);
|
|
50324
|
+
}
|
|
50325
|
+
}
|
|
50326
|
+
function pathEntryExists2(filePath) {
|
|
50327
|
+
try {
|
|
50328
|
+
fs49.lstatSync(filePath);
|
|
50329
|
+
return true;
|
|
50330
|
+
} catch (error) {
|
|
50331
|
+
const code = error?.code;
|
|
50332
|
+
return code !== "ENOENT" && code !== "ENOTDIR";
|
|
50333
|
+
}
|
|
50334
|
+
}
|
|
50335
|
+
function waitForConcurrentPublisher(artifactPath) {
|
|
50336
|
+
const deadline = Date.now() + 500;
|
|
50337
|
+
const signal = new Int32Array(new SharedArrayBuffer(4));
|
|
50338
|
+
while (Date.now() < deadline) {
|
|
50339
|
+
let stats;
|
|
50340
|
+
try {
|
|
50341
|
+
stats = fs49.lstatSync(artifactPath);
|
|
50342
|
+
} catch {
|
|
50343
|
+
return;
|
|
50344
|
+
}
|
|
50345
|
+
if (!stats.isFile() || stats.isSymbolicLink() || stats.nlink <= 1) return;
|
|
50346
|
+
Atomics.wait(signal, 0, 0, 10);
|
|
49718
50347
|
}
|
|
49719
50348
|
}
|
|
49720
50349
|
|
|
@@ -50273,7 +50902,7 @@ workspaceCmd.command("init").description("Initialize lexrunner workspace with in
|
|
|
50273
50902
|
force: opts.force
|
|
50274
50903
|
});
|
|
50275
50904
|
if (isJsonMode) {
|
|
50276
|
-
const { writeSuccessEnvelope } = await import("./jsonEnvelope-
|
|
50905
|
+
const { writeSuccessEnvelope } = await import("./jsonEnvelope-MXJM5ZQH.js");
|
|
50277
50906
|
writeSuccessEnvelope("lex-pr workspace init", initialized);
|
|
50278
50907
|
} else {
|
|
50279
50908
|
console.log(
|
|
@@ -50293,7 +50922,7 @@ workspaceCmd.command("init").description("Initialize lexrunner workspace with in
|
|
|
50293
50922
|
policyTemplate: opts.policyTemplate
|
|
50294
50923
|
});
|
|
50295
50924
|
if (isJsonMode) {
|
|
50296
|
-
const { writeSuccessEnvelope, writeErrorEnvelope } = await import("./jsonEnvelope-
|
|
50925
|
+
const { writeSuccessEnvelope, writeErrorEnvelope } = await import("./jsonEnvelope-MXJM5ZQH.js");
|
|
50297
50926
|
if (result.success) {
|
|
50298
50927
|
writeSuccessEnvelope("lex-pr workspace init", {
|
|
50299
50928
|
profileDir: result.profileDir,
|
|
@@ -50321,7 +50950,7 @@ workspaceCmd.command("init").description("Initialize lexrunner workspace with in
|
|
|
50321
50950
|
throw error;
|
|
50322
50951
|
}
|
|
50323
50952
|
if (isJsonMode) {
|
|
50324
|
-
const { writeErrorEnvelope, errorToJsonError } = await import("./jsonEnvelope-
|
|
50953
|
+
const { writeErrorEnvelope, errorToJsonError } = await import("./jsonEnvelope-MXJM5ZQH.js");
|
|
50325
50954
|
if (error instanceof WorkspaceConfigServiceError) {
|
|
50326
50955
|
writeErrorEnvelope("lex-pr workspace init", {
|
|
50327
50956
|
code: error.code,
|
|
@@ -50418,7 +51047,7 @@ program.command("init").description("Initialize lexrunner workspace with interac
|
|
|
50418
51047
|
jsonMode: isJsonMode
|
|
50419
51048
|
});
|
|
50420
51049
|
if (isJsonMode) {
|
|
50421
|
-
const { writeSuccessEnvelope, writeErrorEnvelope, errorToJsonError } = await import("./jsonEnvelope-
|
|
51050
|
+
const { writeSuccessEnvelope, writeErrorEnvelope, errorToJsonError } = await import("./jsonEnvelope-MXJM5ZQH.js");
|
|
50422
51051
|
if (result.success) {
|
|
50423
51052
|
writeSuccessEnvelope("lex-pr init", {
|
|
50424
51053
|
profileDir: result.profileDir,
|
|
@@ -50446,7 +51075,7 @@ program.command("init").description("Initialize lexrunner workspace with interac
|
|
|
50446
51075
|
throw error;
|
|
50447
51076
|
}
|
|
50448
51077
|
if (isJsonMode) {
|
|
50449
|
-
const { writeErrorEnvelope, errorToJsonError } = await import("./jsonEnvelope-
|
|
51078
|
+
const { writeErrorEnvelope, errorToJsonError } = await import("./jsonEnvelope-MXJM5ZQH.js");
|
|
50450
51079
|
if (error instanceof WriteProtectionError) {
|
|
50451
51080
|
writeErrorEnvelope("lex-pr init", {
|
|
50452
51081
|
code: "EWRITE_PROTECTED",
|
|
@@ -50642,8 +51271,8 @@ program.command("view").description("Interactive plan viewer with navigation and
|
|
|
50642
51271
|
throwExit(1);
|
|
50643
51272
|
}
|
|
50644
51273
|
try {
|
|
50645
|
-
const { InteractivePlanViewer } = await import("./planViewer-
|
|
50646
|
-
const planContent =
|
|
51274
|
+
const { InteractivePlanViewer } = await import("./planViewer-WOV6A2HZ.js");
|
|
51275
|
+
const planContent = fs50.readFileSync(planFile, "utf-8");
|
|
50647
51276
|
const plan = loadPlan(planContent);
|
|
50648
51277
|
const viewer = new InteractivePlanViewer(plan, {
|
|
50649
51278
|
filter: opts.filter,
|
|
@@ -50659,7 +51288,7 @@ program.command("view").description("Interactive plan viewer with navigation and
|
|
|
50659
51288
|
program.command("deliverables:list").description("List all autopilot deliverables with metadata").option("--profile-dir <dir>", "Profile directory (default: .smartergpt)").option("--json", "Output JSON format").action(async (opts) => {
|
|
50660
51289
|
try {
|
|
50661
51290
|
const profile = resolveProfile(opts.profileDir);
|
|
50662
|
-
const { DeliverablesManager } = await import("./autopilot-
|
|
51291
|
+
const { DeliverablesManager } = await import("./autopilot-JWIOXBCZ.js");
|
|
50663
51292
|
const manager = new DeliverablesManager(profile.path);
|
|
50664
51293
|
const deliverables = await manager.listDeliverables();
|
|
50665
51294
|
if (opts.json) {
|
|
@@ -50685,7 +51314,7 @@ program.command("deliverables:list").description("List all autopilot deliverable
|
|
|
50685
51314
|
});
|
|
50686
51315
|
const latest = manager.getLatestPath();
|
|
50687
51316
|
if (latest) {
|
|
50688
|
-
console.log(`\u{1F4CD} Latest: ${
|
|
51317
|
+
console.log(`\u{1F4CD} Latest: ${path59.basename(latest)}`);
|
|
50689
51318
|
}
|
|
50690
51319
|
}
|
|
50691
51320
|
} catch (error) {
|
|
@@ -50698,7 +51327,7 @@ program.command("deliverables:list").description("List all autopilot deliverable
|
|
|
50698
51327
|
program.command("deliverables:cleanup").description("Clean up old deliverables based on retention policy").option("--profile-dir <dir>", "Profile directory (default: .smartergpt)").option("--max-age <days>", "Maximum age in days (deletes older deliverables)").option("--max-count <count>", "Maximum number of deliverables to keep").option("--keep-latest", "Always keep the latest deliverables (default: true)", true).option("--dry-run", "Preview cleanup without deleting").option("--json", "Output JSON format").action(async (opts) => {
|
|
50699
51328
|
try {
|
|
50700
51329
|
const profile = resolveProfile(opts.profileDir);
|
|
50701
|
-
const { DeliverablesManager } = await import("./autopilot-
|
|
51330
|
+
const { DeliverablesManager } = await import("./autopilot-JWIOXBCZ.js");
|
|
50702
51331
|
const manager = new DeliverablesManager(profile.path);
|
|
50703
51332
|
const policy = {
|
|
50704
51333
|
maxAge: opts.maxAge ? parseInt(opts.maxAge) : void 0,
|
|
@@ -50759,8 +51388,8 @@ program.command("deliverables:cleanup").description("Clean up old deliverables b
|
|
|
50759
51388
|
console.log(`Freed space: ${(result.freedSpace / 1024).toFixed(2)} KB`);
|
|
50760
51389
|
if (result.removed.length > 0) {
|
|
50761
51390
|
console.log("\nRemoved:");
|
|
50762
|
-
result.removed.forEach((
|
|
50763
|
-
console.log(` - ${
|
|
51391
|
+
result.removed.forEach((path60) => {
|
|
51392
|
+
console.log(` - ${path60}`);
|
|
50764
51393
|
});
|
|
50765
51394
|
}
|
|
50766
51395
|
}
|
|
@@ -50831,8 +51460,8 @@ var isDirectExec = (() => {
|
|
|
50831
51460
|
try {
|
|
50832
51461
|
if (typeof import.meta === "undefined") return false;
|
|
50833
51462
|
if (!process.argv[1] || !import.meta.url) return false;
|
|
50834
|
-
const invokedPath =
|
|
50835
|
-
const modulePath =
|
|
51463
|
+
const invokedPath = fs50.realpathSync(resolve15(process.argv[1]));
|
|
51464
|
+
const modulePath = fs50.realpathSync(fileURLToPath6(import.meta.url));
|
|
50836
51465
|
return invokedPath === modulePath;
|
|
50837
51466
|
} catch {
|
|
50838
51467
|
return false;
|
|
@@ -50902,11 +51531,17 @@ export {
|
|
|
50902
51531
|
ConfigurationQueryService,
|
|
50903
51532
|
ControllerLease_v1,
|
|
50904
51533
|
DiscoveryQueryService,
|
|
51534
|
+
EXECUTION_PLAN_ARTIFACT_CONTRACT,
|
|
51535
|
+
EXECUTION_PLAN_CANONICALIZATION_PROFILE,
|
|
51536
|
+
EXECUTION_PLAN_HASH_DOMAIN,
|
|
51537
|
+
EXECUTION_PLAN_HASH_PROFILE,
|
|
50905
51538
|
EngineVerificationCheckSource_v2,
|
|
50906
51539
|
EngineVerificationDeterminism_v2,
|
|
50907
51540
|
EngineVerificationTrustGapReason_v2,
|
|
50908
51541
|
ExecutionEnvelope_v1,
|
|
50909
51542
|
ExecutionEnvironmentOS,
|
|
51543
|
+
ExecutionPlanArtifactIdentity_v1Schema,
|
|
51544
|
+
ExecutionPlanArtifact_v1Schema,
|
|
50910
51545
|
ExecutionState,
|
|
50911
51546
|
ExternalAwaitOutcome_v1,
|
|
50912
51547
|
ExternalAwaitableDescriptor_v1,
|
|
@@ -50962,6 +51597,11 @@ export {
|
|
|
50962
51597
|
NativeWslProjectionSelection_v1,
|
|
50963
51598
|
NativeWslProjectionStatusRequestJsonSchema,
|
|
50964
51599
|
NativeWslSourceObservation_v1,
|
|
51600
|
+
PLAN_ARTIFACT_REFERENCE_CONTRACT,
|
|
51601
|
+
PlanArtifactReference_v1Schema,
|
|
51602
|
+
PlanArtifactRegistrationError,
|
|
51603
|
+
PlanArtifactRegistrationService,
|
|
51604
|
+
PlanArtifactScope_v1Schema,
|
|
50965
51605
|
PlanArtifactService,
|
|
50966
51606
|
PlanArtifactServiceError,
|
|
50967
51607
|
PlanCreationService,
|
|
@@ -50991,6 +51631,7 @@ export {
|
|
|
50991
51631
|
completionForAttemptAwaitable,
|
|
50992
51632
|
computeAgentEngineVerificationV2Hash,
|
|
50993
51633
|
computeAgentTaskPacketHash,
|
|
51634
|
+
computeExecutionPlanArtifactDigest,
|
|
50994
51635
|
computeFanInEvidenceSetHash,
|
|
50995
51636
|
computeMergeOrder,
|
|
50996
51637
|
containsAttemptAwaitableCredentialValue,
|