@claudexor/orchestrator 1.0.1 → 2.1.3
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/dist/attemptTelemetry.d.ts +47 -2
- package/dist/attemptTelemetry.d.ts.map +1 -1
- package/dist/attemptTelemetry.js +100 -2
- package/dist/attemptTelemetry.js.map +1 -1
- package/dist/attemptUsage.d.ts +19 -0
- package/dist/attemptUsage.d.ts.map +1 -0
- package/dist/attemptUsage.js +29 -0
- package/dist/attemptUsage.js.map +1 -0
- package/dist/candidateEvidence.d.ts +22 -0
- package/dist/candidateEvidence.d.ts.map +1 -0
- package/dist/candidateEvidence.js +42 -0
- package/dist/candidateEvidence.js.map +1 -0
- package/dist/candidateOutputs.d.ts +43 -0
- package/dist/candidateOutputs.d.ts.map +1 -0
- package/dist/candidateOutputs.js +146 -0
- package/dist/candidateOutputs.js.map +1 -0
- package/dist/contract-gates.d.ts +21 -0
- package/dist/contract-gates.d.ts.map +1 -0
- package/dist/contract-gates.js +93 -0
- package/dist/contract-gates.js.map +1 -0
- package/dist/credential-profiles.d.ts +162 -0
- package/dist/credential-profiles.d.ts.map +1 -0
- package/dist/credential-profiles.js +357 -0
- package/dist/credential-profiles.js.map +1 -0
- package/dist/diffReview.d.ts +12 -1
- package/dist/diffReview.d.ts.map +1 -1
- package/dist/diffReview.js +117 -18
- package/dist/diffReview.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/modelGovernance.d.ts +6 -1
- package/dist/modelGovernance.d.ts.map +1 -1
- package/dist/modelGovernance.js +8 -2
- package/dist/modelGovernance.js.map +1 -1
- package/dist/orchestrateExecutor.d.ts +43 -0
- package/dist/orchestrateExecutor.d.ts.map +1 -0
- package/dist/orchestrateExecutor.js +207 -0
- package/dist/orchestrateExecutor.js.map +1 -0
- package/dist/orchestratePlanner.d.ts.map +1 -1
- package/dist/orchestratePlanner.js.map +1 -1
- package/dist/orchestrator.d.ts +97 -85
- package/dist/orchestrator.d.ts.map +1 -1
- package/dist/orchestrator.js +1056 -1090
- package/dist/orchestrator.js.map +1 -1
- package/dist/outcomeReducer.d.ts +25 -0
- package/dist/outcomeReducer.d.ts.map +1 -0
- package/dist/outcomeReducer.js +121 -0
- package/dist/outcomeReducer.js.map +1 -0
- package/dist/policyFindings.d.ts +18 -0
- package/dist/policyFindings.d.ts.map +1 -0
- package/dist/policyFindings.js +166 -0
- package/dist/policyFindings.js.map +1 -0
- package/dist/requestRequirements.d.ts +38 -0
- package/dist/requestRequirements.d.ts.map +1 -0
- package/dist/requestRequirements.js +127 -0
- package/dist/requestRequirements.js.map +1 -0
- package/dist/reviewerPanel.d.ts +15 -1
- package/dist/reviewerPanel.d.ts.map +1 -1
- package/dist/reviewerPanel.js +85 -2
- package/dist/reviewerPanel.js.map +1 -1
- package/dist/routeContext.d.ts +37 -0
- package/dist/routeContext.d.ts.map +1 -0
- package/dist/routeContext.js +38 -0
- package/dist/routeContext.js.map +1 -0
- package/dist/runSupport.d.ts +37 -21
- package/dist/runSupport.d.ts.map +1 -1
- package/dist/runSupport.js +102 -78
- package/dist/runSupport.js.map +1 -1
- package/dist/runTelemetryWriter.d.ts +20 -0
- package/dist/runTelemetryWriter.d.ts.map +1 -0
- package/dist/runTelemetryWriter.js +68 -0
- package/dist/runTelemetryWriter.js.map +1 -0
- package/dist/runTerminals.d.ts +7 -1
- package/dist/runTerminals.d.ts.map +1 -1
- package/dist/runTerminals.js +42 -4
- package/dist/runTerminals.js.map +1 -1
- package/dist/structuredOutput.d.ts +33 -0
- package/dist/structuredOutput.d.ts.map +1 -0
- package/dist/structuredOutput.js +106 -0
- package/dist/structuredOutput.js.map +1 -0
- package/package.json +19 -18
- package/dist/finalVerifier.d.ts +0 -25
- package/dist/finalVerifier.d.ts.map +0 -1
- package/dist/finalVerifier.js +0 -110
- package/dist/finalVerifier.js.map +0 -1
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { join } from "node:path";
|
|
2
|
+
import AjvModule from "ajv";
|
|
3
|
+
// ajv ships CJS; under NodeNext the default import resolves to the module
|
|
4
|
+
// namespace whose `.default` is the constructor (module.exports.default is set
|
|
5
|
+
// by ajv itself, so this is correct at runtime in both ESM and CJS).
|
|
6
|
+
const Ajv = AjvModule.default ?? AjvModule;
|
|
7
|
+
import { SCHEMA_VERSION, StructuredOutputConformance } from "@claudexor/schema";
|
|
8
|
+
import { nowIso } from "@claudexor/util";
|
|
9
|
+
/** Preflight: prove a caller schema COMPILES under the same ajv the validator
|
|
10
|
+
* uses, so a malformed schema is refused before any run dir exists instead of
|
|
11
|
+
* crashing the validator mid-run. Throws on a schema ajv cannot build. */
|
|
12
|
+
export function assertOutputSchemaCompiles(schema) {
|
|
13
|
+
const ajv = new Ajv({ allErrors: true, strict: false });
|
|
14
|
+
try {
|
|
15
|
+
ajv.compile(schema);
|
|
16
|
+
}
|
|
17
|
+
catch (err) {
|
|
18
|
+
throw new Error(`outputSchema is not a compilable JSON Schema: ${err instanceof Error ? err.message : String(err)}`);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* The ONE engine validator for a run's structured-output contract (Quiz-6a).
|
|
23
|
+
* The `schema` here is the CALLER's ORIGINAL contract (the conformance
|
|
24
|
+
* authority) — NEVER the vendor-strictified transport form, which would falsely
|
|
25
|
+
* pass e.g. `{"field":null}` for an optional string. Every capable lane was
|
|
26
|
+
* constrained natively at preflight; this turns the winner's answer text into a
|
|
27
|
+
* typed conformance receipt (final/structured_output.yaml). A non-conformant
|
|
28
|
+
* answer is a FAILED receipt, never a failed run — the run stays
|
|
29
|
+
* success-with-warnings and the embedder retries on the receipt.
|
|
30
|
+
*
|
|
31
|
+
* Only a CONFORMANT answer becomes final/output.json (the primary
|
|
32
|
+
* structured_output artifact must never surface known-invalid data). A
|
|
33
|
+
* parsed-but-non-conformant answer is preserved under final/output.invalid.json
|
|
34
|
+
* (diagnostic) for the embedder to inspect; an unparsable answer writes nothing.
|
|
35
|
+
*/
|
|
36
|
+
export function finalizeStructuredOutput(opts) {
|
|
37
|
+
const text = opts.answerText?.trim() ?? "";
|
|
38
|
+
let value;
|
|
39
|
+
let parsed = false;
|
|
40
|
+
let reason = null;
|
|
41
|
+
if (!text) {
|
|
42
|
+
reason = "the run produced no final answer text to validate";
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
try {
|
|
46
|
+
value = JSON.parse(text);
|
|
47
|
+
parsed = true;
|
|
48
|
+
}
|
|
49
|
+
catch {
|
|
50
|
+
// Mandatory native constraining means the answer SHOULD be pure JSON;
|
|
51
|
+
// anything else is honestly non-conformant (no fenced-block salvage).
|
|
52
|
+
reason = "final answer is not valid JSON";
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
let status = "failed";
|
|
56
|
+
if (parsed) {
|
|
57
|
+
// strict:false — accept the JSON Schema dialect as-authored; do not
|
|
58
|
+
// re-litigate meta-schema strictness (the boundary already proved it
|
|
59
|
+
// compiles). This validates the ORIGINAL caller schema.
|
|
60
|
+
const ajv = new Ajv({ allErrors: true, strict: false });
|
|
61
|
+
try {
|
|
62
|
+
const validate = ajv.compile(opts.schema);
|
|
63
|
+
if (validate(value) === true) {
|
|
64
|
+
status = "passed";
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
reason =
|
|
68
|
+
(validate.errors ?? [])
|
|
69
|
+
.map((e) => `${e.instancePath || "/"}: ${e.message ?? "invalid"}`)
|
|
70
|
+
.join("; ")
|
|
71
|
+
.slice(0, 1000) || "schema validation failed";
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
catch (err) {
|
|
75
|
+
reason = `output schema failed to compile: ${err instanceof Error ? err.message : String(err)}`;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
// Conformant → the canonical output.json (a valid primary artifact).
|
|
79
|
+
// Parsed-but-invalid → a DIAGNOSTIC file, never the primary structured output.
|
|
80
|
+
let outputPath = null;
|
|
81
|
+
if (parsed && status === "passed") {
|
|
82
|
+
opts.store.writeText(join(opts.finalDir, "output.json"), JSON.stringify(value, null, 2) + "\n");
|
|
83
|
+
outputPath = "final/output.json";
|
|
84
|
+
}
|
|
85
|
+
else if (parsed) {
|
|
86
|
+
opts.store.writeText(join(opts.finalDir, "output.invalid.json"), JSON.stringify(value, null, 2) + "\n");
|
|
87
|
+
outputPath = "final/output.invalid.json";
|
|
88
|
+
}
|
|
89
|
+
const receipt = StructuredOutputConformance.parse({
|
|
90
|
+
schema_version: SCHEMA_VERSION,
|
|
91
|
+
status,
|
|
92
|
+
reason: status === "passed" ? null : reason,
|
|
93
|
+
output_path: outputPath,
|
|
94
|
+
generated_at: nowIso(),
|
|
95
|
+
});
|
|
96
|
+
opts.store.writeYaml(join(opts.finalDir, "structured_output.yaml"), receipt);
|
|
97
|
+
if (outputPath) {
|
|
98
|
+
opts.log.emit("output.ready", {
|
|
99
|
+
kind: "structured_output",
|
|
100
|
+
path: outputPath,
|
|
101
|
+
...(status === "passed" ? {} : { state: "diagnostic" }),
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
return { status, reason: receipt.reason };
|
|
105
|
+
}
|
|
106
|
+
//# sourceMappingURL=structuredOutput.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"structuredOutput.js","sourceRoot":"","sources":["../src/structuredOutput.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,SAAS,MAAM,KAAK,CAAC;AAG5B,0EAA0E;AAC1E,+EAA+E;AAC/E,qEAAqE;AACrE,MAAM,GAAG,GAAG,SAAS,CAAC,OAAO,IAAK,SAAiD,CAAC;AAGpF,OAAO,EAAE,cAAc,EAAE,2BAA2B,EAAE,MAAM,mBAAmB,CAAC;AAChF,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAOzC;;2EAE2E;AAC3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I,CACtC,CAAC;QACF,UAAU,GAAG,2BAA2B,CAAC;IAC3C,CAAC;IACD,MAAM,OAAO,GAAG,2BAA2B,CAAC,KAAK,CAAC;QAChD,cAAc,EAAE,cAAc;QAC9B,MAAM;QACN,MAAM,EAAE,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM;QAC3C,WAAW,EAAE,UAAU;QACvB,YAAY,EAAE,MAAM,EAAE;KACvB,CAAC,CAAC;IACH,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,wBAAwB,CAAC,EAAE,OAAO,CAAC,CAAC;IAC7E,IAAI,UAAU,EAAE,CAAC;QACf,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,cAAc,EAAE;YAC5B,IAAI,EAAE,mBAAmB;YACzB,IAAI,EAAE,UAAU;YAChB,GAAG,CAAC,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,YAAY,EAAE,CAAC;SACxD,CAAC,CAAC;IACL,CAAC;IACD,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,CAAC;AAC5C,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@claudexor/orchestrator",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "2.1.3",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "Hub that composes all subsystems and implements the five canonical modes (ask, plan, audit, agent, orchestrate) with their strategy flags (best-of-N race, attempt caps, until-clean, swarm, create).",
|
|
6
6
|
"type": "module",
|
|
@@ -16,25 +16,26 @@
|
|
|
16
16
|
"dist"
|
|
17
17
|
],
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"
|
|
20
|
-
"@claudexor/
|
|
21
|
-
"@claudexor/
|
|
22
|
-
"@claudexor/
|
|
23
|
-
"@claudexor/
|
|
24
|
-
"@claudexor/
|
|
25
|
-
"@claudexor/
|
|
26
|
-
"@claudexor/
|
|
27
|
-
"@claudexor/
|
|
28
|
-
"@claudexor/
|
|
29
|
-
"@claudexor/
|
|
30
|
-
"@claudexor/
|
|
31
|
-
"@claudexor/schema": "1.
|
|
32
|
-
"@claudexor/
|
|
33
|
-
"@claudexor/
|
|
34
|
-
"@claudexor/
|
|
19
|
+
"ajv": "^8.20.0",
|
|
20
|
+
"@claudexor/arbitration": "2.1.3",
|
|
21
|
+
"@claudexor/artifact-store": "2.1.3",
|
|
22
|
+
"@claudexor/budget": "2.1.3",
|
|
23
|
+
"@claudexor/config": "2.1.3",
|
|
24
|
+
"@claudexor/context": "2.1.3",
|
|
25
|
+
"@claudexor/core": "2.1.3",
|
|
26
|
+
"@claudexor/event-log": "2.1.3",
|
|
27
|
+
"@claudexor/delivery": "2.1.3",
|
|
28
|
+
"@claudexor/interview": "2.1.3",
|
|
29
|
+
"@claudexor/gateway": "2.1.3",
|
|
30
|
+
"@claudexor/policy": "2.1.3",
|
|
31
|
+
"@claudexor/schema": "2.1.3",
|
|
32
|
+
"@claudexor/synthesis": "2.1.3",
|
|
33
|
+
"@claudexor/review": "2.1.3",
|
|
34
|
+
"@claudexor/util": "2.1.3",
|
|
35
|
+
"@claudexor/workspace": "2.1.3"
|
|
35
36
|
},
|
|
36
37
|
"devDependencies": {
|
|
37
|
-
"@claudexor/harness-fake": "1.
|
|
38
|
+
"@claudexor/harness-fake": "2.1.3"
|
|
38
39
|
},
|
|
39
40
|
"repository": {
|
|
40
41
|
"type": "git",
|
package/dist/finalVerifier.d.ts
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { FinalVerifyRecord } from "@claudexor/schema";
|
|
2
|
-
import { type GateSpec } from "@claudexor/review";
|
|
3
|
-
interface VerifiableWinner {
|
|
4
|
-
baseSha?: string;
|
|
5
|
-
diff: string;
|
|
6
|
-
}
|
|
7
|
-
interface VerifyEventLog {
|
|
8
|
-
emit(type: "gate.completed", payload: Record<string, unknown>): unknown;
|
|
9
|
-
}
|
|
10
|
-
/** FAIL-CLOSED verdict (INV-115): an attempted verify that did not PROVE
|
|
11
|
-
* applied_cleanly (false OR null/errored) or whose gates failed blocks the
|
|
12
|
-
* run. One owner — race and convergence consume the same rule. */
|
|
13
|
-
export declare function finalVerifyBlocks(finalVerify: FinalVerifyRecord | null): boolean;
|
|
14
|
-
/** The persisted decision must AGREE with a blocked terminal: status/outcome
|
|
15
|
-
* blocked, human_review recommendation, and an evidence fact naming the cause.
|
|
16
|
-
* One owner for the race and convergence decision writes. */
|
|
17
|
-
export declare function blockedDecisionOverride(evidenceFacts: string[], finalVerify: FinalVerifyRecord | null): {
|
|
18
|
-
status: "blocked";
|
|
19
|
-
outcome: "blocked";
|
|
20
|
-
apply_recommendation: "human_review";
|
|
21
|
-
evidence_facts: string[];
|
|
22
|
-
};
|
|
23
|
-
export declare function finalVerifyPatch(execRoot: string, winner: VerifiableWinner, specs: GateSpec[], log: VerifyEventLog): Promise<FinalVerifyRecord>;
|
|
24
|
-
export {};
|
|
25
|
-
//# sourceMappingURL=finalVerifier.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"finalVerifier.d.ts","sourceRoot":"","sources":["../src/finalVerifier.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,KAAK,QAAQ,EAAyB,MAAM,mBAAmB,CAAC;AAIzE,UAAU,gBAAgB;IACxB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;CACd;AAED,UAAU,cAAc;IACtB,IAAI,CAAC,IAAI,EAAE,gBAAgB,EAAE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC;CACzE;AAED;;kEAEkE;AAClE,wBAAgB,iBAAiB,CAAC,WAAW,EAAE,iBAAiB,GAAG,IAAI,GAAG,OAAO,CAMhF;AAED;;6DAE6D;AAC7D,wBAAgB,uBAAuB,CACrC,aAAa,EAAE,MAAM,EAAE,EACvB,WAAW,EAAE,iBAAiB,GAAG,IAAI,GACpC;IACD,MAAM,EAAE,SAAS,CAAC;IAClB,OAAO,EAAE,SAAS,CAAC;IACnB,oBAAoB,EAAE,cAAc,CAAC;IACrC,cAAc,EAAE,MAAM,EAAE,CAAC;CAC1B,CAYA;AAED,wBAAsB,gBAAgB,CACpC,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,gBAAgB,EACxB,KAAK,EAAE,QAAQ,EAAE,EACjB,GAAG,EAAE,cAAc,GAClB,OAAO,CAAC,iBAAiB,CAAC,CAgE5B"}
|
package/dist/finalVerifier.js
DELETED
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* FinalVerifier (INV-115): before a race winner becomes adoptable/
|
|
3
|
-
* applyable, its patch is applied onto a FRESH worktree at the winner's own
|
|
4
|
-
* base sha and the deterministic gates re-run there. This catches the class
|
|
5
|
-
* of "reviewed green in the candidate tree, broken against the real base"
|
|
6
|
-
* failures (stale envelope, gate side effects) with zero model spend.
|
|
7
|
-
* Deterministic-first: no model involvement; gates cost no USD, so the
|
|
8
|
-
* candidate ledger is trivially respected.
|
|
9
|
-
*/
|
|
10
|
-
import { mkdtempSync, rmSync } from "node:fs";
|
|
11
|
-
import { tmpdir } from "node:os";
|
|
12
|
-
import { join } from "node:path";
|
|
13
|
-
import { FinalVerifyRecord } from "@claudexor/schema";
|
|
14
|
-
import { gatesPassed, runGates } from "@claudexor/review";
|
|
15
|
-
import { applyPatchProtected, branchDelete, worktreeAdd, worktreeRemove } from "@claudexor/workspace";
|
|
16
|
-
import { newId, redactSecrets } from "@claudexor/util";
|
|
17
|
-
/** FAIL-CLOSED verdict (INV-115): an attempted verify that did not PROVE
|
|
18
|
-
* applied_cleanly (false OR null/errored) or whose gates failed blocks the
|
|
19
|
-
* run. One owner — race and convergence consume the same rule. */
|
|
20
|
-
export function finalVerifyBlocks(finalVerify) {
|
|
21
|
-
return (finalVerify !== null &&
|
|
22
|
-
finalVerify.attempted &&
|
|
23
|
-
(finalVerify.applied_cleanly !== true || finalVerify.gates_passed === false));
|
|
24
|
-
}
|
|
25
|
-
/** The persisted decision must AGREE with a blocked terminal: status/outcome
|
|
26
|
-
* blocked, human_review recommendation, and an evidence fact naming the cause.
|
|
27
|
-
* One owner for the race and convergence decision writes. */
|
|
28
|
-
export function blockedDecisionOverride(evidenceFacts, finalVerify) {
|
|
29
|
-
const fact = finalVerifyBlocks(finalVerify)
|
|
30
|
-
? finalVerify?.applied_cleanly !== true
|
|
31
|
-
? `final verify failed: ${finalVerify?.reason ?? "patch did not survive a fresh tree at its base"}`
|
|
32
|
-
: "final verify failed: deterministic gates failed on the fresh verify tree"
|
|
33
|
-
: "reviewer escalated blocking NEEDS_HUMAN findings; a typed operator decision is required";
|
|
34
|
-
return {
|
|
35
|
-
status: "blocked",
|
|
36
|
-
outcome: "blocked",
|
|
37
|
-
apply_recommendation: "human_review",
|
|
38
|
-
evidence_facts: [...evidenceFacts, fact],
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
export async function finalVerifyPatch(execRoot, winner, specs, log) {
|
|
42
|
-
const started = Date.now();
|
|
43
|
-
const done = (fields) => FinalVerifyRecord.parse({
|
|
44
|
-
attempted: true,
|
|
45
|
-
base_sha: winner.baseSha ?? null,
|
|
46
|
-
duration_ms: Date.now() - started,
|
|
47
|
-
...fields,
|
|
48
|
-
});
|
|
49
|
-
if (!winner.baseSha) {
|
|
50
|
-
// FAIL CLOSED: the in-place exemption is a CALLER-level decision (the
|
|
51
|
-
// orchestrator skips in-place turns before calling). An ENVELOPE patch
|
|
52
|
-
// reaching this point without a recorded base sha cannot be proven
|
|
53
|
-
// against a clean base — that blocks like any other verifier error,
|
|
54
|
-
// never silently bypasses INV-115.
|
|
55
|
-
return FinalVerifyRecord.parse({
|
|
56
|
-
attempted: true,
|
|
57
|
-
applied_cleanly: null,
|
|
58
|
-
reason: "no base sha recorded for the winner envelope; cannot verify against a clean base",
|
|
59
|
-
duration_ms: Date.now() - started,
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
const verifyBase = mkdtempSync(join(tmpdir(), "claudexor-verify-"));
|
|
63
|
-
const verifyTree = join(verifyBase, "tree");
|
|
64
|
-
const branch = `claudexor/verify-${newId("fv").slice(3)}`;
|
|
65
|
-
try {
|
|
66
|
-
await worktreeAdd(execRoot, verifyTree, branch, winner.baseSha);
|
|
67
|
-
const applied = await applyPatchProtected(verifyTree, winner.diff);
|
|
68
|
-
if (!applied.ok) {
|
|
69
|
-
return done({ applied_cleanly: false, reason: applied.detail ?? "apply failed on the verify tree" });
|
|
70
|
-
}
|
|
71
|
-
if (specs.length === 0) {
|
|
72
|
-
return done({ applied_cleanly: true, gates_passed: null, reason: "no deterministic gates configured" });
|
|
73
|
-
}
|
|
74
|
-
const gates = await runGates(specs, { cwd: verifyTree });
|
|
75
|
-
log.emit("gate.completed", {
|
|
76
|
-
attempt_id: "final-verify",
|
|
77
|
-
gates: gates.map((g) => ({ id: g.id, status: g.status, exit_code: g.exit_code, duration_ms: g.duration_ms })),
|
|
78
|
-
passed: gatesPassed(gates),
|
|
79
|
-
});
|
|
80
|
-
return done({
|
|
81
|
-
applied_cleanly: true,
|
|
82
|
-
gates_passed: gatesPassed(gates),
|
|
83
|
-
gates: gates.map((g) => ({ id: g.id, status: g.status })),
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
catch (err) {
|
|
87
|
-
return done({ applied_cleanly: null, reason: redactSecrets(err instanceof Error ? err.message : String(err)) });
|
|
88
|
-
}
|
|
89
|
-
finally {
|
|
90
|
-
try {
|
|
91
|
-
await worktreeRemove(execRoot, verifyTree);
|
|
92
|
-
}
|
|
93
|
-
catch {
|
|
94
|
-
/* best-effort */
|
|
95
|
-
}
|
|
96
|
-
try {
|
|
97
|
-
await branchDelete(execRoot, branch);
|
|
98
|
-
}
|
|
99
|
-
catch {
|
|
100
|
-
/* best-effort */
|
|
101
|
-
}
|
|
102
|
-
try {
|
|
103
|
-
rmSync(verifyBase, { recursive: true, force: true });
|
|
104
|
-
}
|
|
105
|
-
catch {
|
|
106
|
-
/* best-effort */
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
//# sourceMappingURL=finalVerifier.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"finalVerifier.js","sourceRoot":"","sources":["../src/finalVerifier.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAC9C,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAiB,WAAW,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AACzE,OAAO,EAAE,mBAAmB,EAAE,YAAY,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtG,OAAO,EAAE,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAWvD;;kEAEkE;AAClE,MAAM,UAAU,iBAAiB,CAAC,WAAqC;IACrE,OAAO,CACL,WAAW,KAAK,IAAI;QACpB,WAAW,CAAC,SAAS;QACrB,CAAC,WAAW,CAAC,eAAe,KAAK,IAAI,IAAI,WAAW,CAAC,YAAY,KAAK,KAAK,CAAC,CAC7E,CAAC;AACJ,CAAC;AAED;;6DAE6D;AAC7D,MAAM,UAAU,uBAAuB,CACrC,aAAuB,EACvB,WAAqC;IAOrC,MAAM,IAAI,GAAG,iBAAiB,CAAC,WAAW,CAAC;QACzC,CAAC,CAAC,WAAW,EAAE,eAAe,KAAK,IAAI;YACrC,CAAC,CA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