@claudexor/orchestrator 1.0.1 → 2.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. package/dist/attemptTelemetry.d.ts +38 -2
  2. package/dist/attemptTelemetry.d.ts.map +1 -1
  3. package/dist/attemptTelemetry.js +75 -2
  4. package/dist/attemptTelemetry.js.map +1 -1
  5. package/dist/contract-gates.d.ts +21 -0
  6. package/dist/contract-gates.d.ts.map +1 -0
  7. package/dist/contract-gates.js +93 -0
  8. package/dist/contract-gates.js.map +1 -0
  9. package/dist/credential-profiles.d.ts +152 -0
  10. package/dist/credential-profiles.d.ts.map +1 -0
  11. package/dist/credential-profiles.js +270 -0
  12. package/dist/credential-profiles.js.map +1 -0
  13. package/dist/diffReview.d.ts +9 -1
  14. package/dist/diffReview.d.ts.map +1 -1
  15. package/dist/diffReview.js +114 -18
  16. package/dist/diffReview.js.map +1 -1
  17. package/dist/index.d.ts +1 -0
  18. package/dist/index.d.ts.map +1 -1
  19. package/dist/index.js +1 -0
  20. package/dist/index.js.map +1 -1
  21. package/dist/modelGovernance.d.ts +6 -1
  22. package/dist/modelGovernance.d.ts.map +1 -1
  23. package/dist/modelGovernance.js +8 -2
  24. package/dist/modelGovernance.js.map +1 -1
  25. package/dist/orchestrateExecutor.d.ts +43 -0
  26. package/dist/orchestrateExecutor.d.ts.map +1 -0
  27. package/dist/orchestrateExecutor.js +207 -0
  28. package/dist/orchestrateExecutor.js.map +1 -0
  29. package/dist/orchestratePlanner.d.ts.map +1 -1
  30. package/dist/orchestratePlanner.js.map +1 -1
  31. package/dist/orchestrator.d.ts +100 -83
  32. package/dist/orchestrator.d.ts.map +1 -1
  33. package/dist/orchestrator.js +1008 -993
  34. package/dist/orchestrator.js.map +1 -1
  35. package/dist/outcomeReducer.d.ts +25 -0
  36. package/dist/outcomeReducer.d.ts.map +1 -0
  37. package/dist/outcomeReducer.js +121 -0
  38. package/dist/outcomeReducer.js.map +1 -0
  39. package/dist/policyFindings.d.ts +18 -0
  40. package/dist/policyFindings.d.ts.map +1 -0
  41. package/dist/policyFindings.js +166 -0
  42. package/dist/policyFindings.js.map +1 -0
  43. package/dist/requestRequirements.d.ts +38 -0
  44. package/dist/requestRequirements.d.ts.map +1 -0
  45. package/dist/requestRequirements.js +127 -0
  46. package/dist/requestRequirements.js.map +1 -0
  47. package/dist/reviewerPanel.d.ts +15 -1
  48. package/dist/reviewerPanel.d.ts.map +1 -1
  49. package/dist/reviewerPanel.js +85 -2
  50. package/dist/reviewerPanel.js.map +1 -1
  51. package/dist/routeContext.d.ts +37 -0
  52. package/dist/routeContext.d.ts.map +1 -0
  53. package/dist/routeContext.js +38 -0
  54. package/dist/routeContext.js.map +1 -0
  55. package/dist/runSupport.d.ts +37 -21
  56. package/dist/runSupport.d.ts.map +1 -1
  57. package/dist/runSupport.js +102 -78
  58. package/dist/runSupport.js.map +1 -1
  59. package/dist/runTelemetryWriter.d.ts +20 -0
  60. package/dist/runTelemetryWriter.d.ts.map +1 -0
  61. package/dist/runTelemetryWriter.js +68 -0
  62. package/dist/runTelemetryWriter.js.map +1 -0
  63. package/dist/runTerminals.d.ts +7 -1
  64. package/dist/runTerminals.d.ts.map +1 -1
  65. package/dist/runTerminals.js +42 -4
  66. package/dist/runTerminals.js.map +1 -1
  67. package/dist/structuredOutput.d.ts +33 -0
  68. package/dist/structuredOutput.d.ts.map +1 -0
  69. package/dist/structuredOutput.js +106 -0
  70. package/dist/structuredOutput.js.map +1 -0
  71. package/package.json +19 -18
  72. package/dist/finalVerifier.d.ts +0 -25
  73. package/dist/finalVerifier.d.ts.map +0 -1
  74. package/dist/finalVerifier.js +0 -110
  75. package/dist/finalVerifier.js.map +0 -1
@@ -0,0 +1,25 @@
1
+ import { type DeliveryReceipt, type RunStatus } from "@claudexor/schema";
2
+ export interface OrchestrateStepOutcome {
3
+ required: boolean;
4
+ executionStatus: "pending" | "running" | "done" | "skipped" | "blocked" | "failed";
5
+ terminalStatus: RunStatus | null;
6
+ }
7
+ export declare function isSuccessfulOrchestrateTerminal(status: RunStatus | null): boolean;
8
+ /** Parent success is legal only when every required step has a successful terminal. */
9
+ export declare function reduceOrchestrateOutcome(steps: readonly OrchestrateStepOutcome[]): RunStatus;
10
+ /** Delivery receipts, not the requested autonomy, determine whether execution mutated state. */
11
+ export declare function deliveryReceiptMutated(receipt: DeliveryReceipt): boolean;
12
+ export interface ReferencedRunStatus {
13
+ status: RunStatus | null;
14
+ detail: string;
15
+ evidenceRefs: string[];
16
+ }
17
+ export declare function readRunStatus(repoRoot: string, runId: string): ReferencedRunStatus | null;
18
+ export interface OrchestrateFailureDescriptor {
19
+ phase: "plan" | "executor";
20
+ category: "policy" | "internal" | "harness_error" | "budget";
21
+ safeMessage: string;
22
+ nextActions: string[];
23
+ }
24
+ export declare function orchestrateFailureFor(status: RunStatus): OrchestrateFailureDescriptor | null;
25
+ //# sourceMappingURL=outcomeReducer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"outcomeReducer.d.ts","sourceRoot":"","sources":["../src/outcomeReducer.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,eAAe,EACpB,KAAK,SAAS,EACf,MAAM,mBAAmB,CAAC;AAE3B,MAAM,WAAW,sBAAsB;IACrC,QAAQ,EAAE,OAAO,CAAC;IAClB,eAAe,EAAE,SAAS,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,GAAG,SAAS,GAAG,QAAQ,CAAC;IACnF,cAAc,EAAE,SAAS,GAAG,IAAI,CAAC;CAClC;AAqCD,wBAAgB,+BAA+B,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,GAAG,OAAO,CAEjF;AAED,uFAAuF;AACvF,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,SAAS,sBAAsB,EAAE,GAAG,SAAS,CAG5F;AAED,gGAAgG;AAChG,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAExE;AAED,MAAM,WAAW,mBAAmB;IAClC,MAAM,EAAE,SAAS,GAAG,IAAI,CAAC;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,MAAM,EAAE,CAAC;CACxB;AAED,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,mBAAmB,GAAG,IAAI,CA0BzF;AAED,MAAM,WAAW,4BAA4B;IAC3C,KAAK,EAAE,MAAM,GAAG,UAAU,CAAC;IAC3B,QAAQ,EAAE,QAAQ,GAAG,UAAU,GAAG,eAAe,GAAG,QAAQ,CAAC;IAC7D,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,EAAE,CAAC;CACvB;AAED,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,SAAS,GAAG,4BAA4B,GAAG,IAAI,CA4C5F"}
@@ -0,0 +1,121 @@
1
+ import { join } from "node:path";
2
+ import { ArtifactStore } from "@claudexor/artifact-store";
3
+ import { RunStatus as RunStatusSchema, } from "@claudexor/schema";
4
+ const PRECEDENCE = [
5
+ "failed",
6
+ "interrupted_unknown",
7
+ "blocked",
8
+ "cost_unverifiable",
9
+ "exhausted_overshoot",
10
+ "exhausted",
11
+ "not_converged",
12
+ "stuck_no_progress",
13
+ "cancelled",
14
+ "success",
15
+ ];
16
+ function normalizedTerminal(step) {
17
+ if (!step.required)
18
+ return null;
19
+ if (step.executionStatus === "failed")
20
+ return "failed";
21
+ if (step.executionStatus === "blocked")
22
+ return "blocked";
23
+ if (step.executionStatus === "skipped") {
24
+ if (step.terminalStatus === "cancelled" ||
25
+ step.terminalStatus === "interrupted_unknown" ||
26
+ step.terminalStatus === "cost_unverifiable" ||
27
+ step.terminalStatus === "exhausted_overshoot" ||
28
+ step.terminalStatus === "exhausted")
29
+ return step.terminalStatus;
30
+ return "blocked";
31
+ }
32
+ if (step.executionStatus === "pending" || step.executionStatus === "running")
33
+ return "blocked";
34
+ if (step.terminalStatus === "no_op")
35
+ return "success";
36
+ if (step.terminalStatus === "ungated" || step.terminalStatus === "review_not_run")
37
+ return "blocked";
38
+ return step.terminalStatus ?? "blocked";
39
+ }
40
+ export function isSuccessfulOrchestrateTerminal(status) {
41
+ return status === "success" || status === "no_op";
42
+ }
43
+ /** Parent success is legal only when every required step has a successful terminal. */
44
+ export function reduceOrchestrateOutcome(steps) {
45
+ const actual = steps.map(normalizedTerminal).filter((status) => !!status);
46
+ return PRECEDENCE.find((status) => actual.includes(status)) ?? "success";
47
+ }
48
+ /** Delivery receipts, not the requested autonomy, determine whether execution mutated state. */
49
+ export function deliveryReceiptMutated(receipt) {
50
+ return receipt.treeMutated ?? (receipt.applied && receipt.mode !== "artifact_only");
51
+ }
52
+ export function readRunStatus(repoRoot, runId) {
53
+ const store = new ArtifactStore(repoRoot);
54
+ const paths = store.runPaths(runId);
55
+ const decision = store.readYaml(join(paths.arbitrationDir, "decision.yaml"));
56
+ const workProduct = store.readYaml(join(paths.finalDir, "work_product.yaml"));
57
+ if (!decision && !workProduct)
58
+ return null;
59
+ const status = RunStatusSchema.safeParse(decision?.status);
60
+ const details = [
61
+ decision?.status ? `decision=${decision.status}` : null,
62
+ workProduct?.meta?.["result_kind"]
63
+ ? `result_kind=${String(workProduct.meta["result_kind"])}`
64
+ : null,
65
+ workProduct?.meta?.["apply_state"]
66
+ ? `apply_state=${String(workProduct.meta["apply_state"])}`
67
+ : null,
68
+ ].filter((value) => !!value);
69
+ return {
70
+ status: status.success ? status.data : null,
71
+ detail: details.join(", ") || `run ${runId}: artifacts present`,
72
+ evidenceRefs: [
73
+ ...(decision ? [`run:${runId}/arbitration/decision.yaml`] : []),
74
+ ...(workProduct ? [`run:${runId}/final/work_product.yaml`] : []),
75
+ ],
76
+ };
77
+ }
78
+ export function orchestrateFailureFor(status) {
79
+ switch (status) {
80
+ case "blocked":
81
+ return {
82
+ phase: "executor",
83
+ category: "policy",
84
+ safeMessage: "orchestrate has required work that did not succeed (including skipped, ungated, missing-review, or risky steps); inspect the typed progress record",
85
+ nextActions: [
86
+ "Inspect final/orchestration_progress.yaml",
87
+ "Resolve or retry the blocked step",
88
+ ],
89
+ };
90
+ case "failed":
91
+ case "interrupted_unknown":
92
+ return {
93
+ phase: "executor",
94
+ category: "internal",
95
+ safeMessage: `orchestrate ended ${status}; inspect the typed progress record`,
96
+ nextActions: ["Inspect final/orchestration_progress.yaml", "Retry the failed step"],
97
+ };
98
+ case "not_converged":
99
+ case "stuck_no_progress":
100
+ return {
101
+ phase: "plan",
102
+ category: "harness_error",
103
+ safeMessage: status === "not_converged"
104
+ ? "orchestrate produced no valid typed plan or a required child did not converge"
105
+ : "orchestrate made no progress on a required step",
106
+ nextActions: ["Inspect orchestration artifacts", "Re-run orchestrate"],
107
+ };
108
+ case "cost_unverifiable":
109
+ case "exhausted_overshoot":
110
+ case "exhausted":
111
+ return {
112
+ phase: "executor",
113
+ category: "budget",
114
+ safeMessage: `orchestrate ended ${status}; inspect its budget and progress evidence`,
115
+ nextActions: ["Inspect final/orchestration_progress.yaml", "Adjust the budget and retry"],
116
+ };
117
+ default:
118
+ return null;
119
+ }
120
+ }
121
+ //# sourceMappingURL=outcomeReducer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"outcomeReducer.js","sourceRoot":"","sources":["../src/outcomeReducer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,EACL,SAAS,IAAI,eAAe,GAG7B,MAAM,mBAAmB,CAAC;AAQ3B,MAAM,UAAU,GAAyB;IACvC,QAAQ;IACR,qBAAqB;IACrB,SAAS;IACT,mBAAmB;IACnB,qBAAqB;IACrB,WAAW;IACX,eAAe;IACf,mBAAmB;IACnB,WAAW;IACX,SAAS;CACV,CAAC;AAEF,SAAS,kBAAkB,CAAC,IAA4B;IACtD,IAAI,CAAC,IAAI,CAAC,QAAQ;QAAE,OAAO,IAAI,CAAC;IA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ACzB,KAAK,qBAAqB,CAAC;QAC3B,KAAK,WAAW;YACd,OAAO;gBACL,KAAK,EAAE,UAAU;gBACjB,QAAQ,EAAE,QAAQ;gBAClB,WAAW,EAAE,qBAAqB,MAAM,4CAA4C;gBACpF,WAAW,EAAE,CAAC,2CAA2C,EAAE,6BAA6B,CAAC;aAC1F,CAAC;QACJ;YACE,OAAO,IAAI,CAAC;IAChB,CAAC;AACH,CAAC"}
@@ -0,0 +1,18 @@
1
+ import type { ProtectedPathApproval, ReviewFinding } from "@claudexor/schema";
2
+ /**
3
+ * Deterministic policy findings from the typed diff (no LLM, no regex over
4
+ * prose): protected-path changes and critical-risk diffs escalate NEEDS_HUMAN;
5
+ * a high-risk diff without a cross-family panel escalates as well. Each
6
+ * finding cites the matched files as evidence (BIBLE: evidence beats summaries).
7
+ */
8
+ export declare function policyFindings(run: {
9
+ diff: string;
10
+ }, reviewVerified: boolean, protectedPaths?: string[], autoProtectedPaths?: string[], protectedPathApprovals?: ProtectedPathApproval[], denyPaths?: string[]): {
11
+ findings: ReviewFinding[];
12
+ risk: {
13
+ level: string;
14
+ reasons: string[];
15
+ changedFiles: number;
16
+ };
17
+ };
18
+ //# sourceMappingURL=policyFindings.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"policyFindings.d.ts","sourceRoot":"","sources":["../src/policyFindings.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,qBAAqB,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAI9E;;;;;GAKG;AACH,wBAAgB,cAAc,CAC5B,GAAG,EAAE;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,EACrB,cAAc,EAAE,OAAO,EACvB,cAAc,GAAE,MAAM,EAAO,EAC7B,kBAAkB,GAAE,MAAM,EAAO,EACjC,sBAAsB,GAAE,qBAAqB,EAAO,EACpD,SAAS,GAAE,MAAM,EAAO,GACvB;IACD,QAAQ,EAAE,aAAa,EAAE,CAAC;IAC1B,IAAI,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,EAAE,CAAC;QAAC,YAAY,EAAE,MAAM,CAAA;KAAE,CAAC;CAClE,CAyKA"}
@@ -0,0 +1,166 @@
1
+ import { matchAny } from "@claudexor/context";
2
+ import { classifyRisk, DEFAULT_REQUIRE_HUMAN_PATHS, requireHuman, reviewDepthForRisk, } from "@claudexor/policy";
3
+ import { summarizeDiffPaths as diffStats } from "@claudexor/core";
4
+ import { ReviewFinding as ReviewFindingSchema } from "@claudexor/schema";
5
+ import { newId } from "@claudexor/util";
6
+ /**
7
+ * Deterministic policy findings from the typed diff (no LLM, no regex over
8
+ * prose): protected-path changes and critical-risk diffs escalate NEEDS_HUMAN;
9
+ * a high-risk diff without a cross-family panel escalates as well. Each
10
+ * finding cites the matched files as evidence (BIBLE: evidence beats summaries).
11
+ */
12
+ export function policyFindings(run, reviewVerified, protectedPaths = [], autoProtectedPaths = [], protectedPathApprovals = [], denyPaths = []) {
13
+ const stats = diffStats(run.diff);
14
+ // Path policy gates match stats.touchedPaths — the one owner of "what the
15
+ // diff touches" (core diff.ts, G1 class); a gate matching a narrower
16
+ // projection is an EXPLICIT decision, never an accident. deny_paths: ANY
17
+ // touch of a denied glob is a violation — create, modify, delete, or
18
+ // either end of a rename. Contract protected_paths: creating a NEW file
19
+ // under a protected glob (or renaming into it) is tamper exactly like
20
+ // editing an existing one. Same matcher as every other path policy
21
+ // (INV-122).
22
+ const denyViolation = requireHuman(stats.touchedPaths, denyPaths);
23
+ const approvalPatterns = protectedPathApprovals.map((approval) => approval.path);
24
+ // AUTO-protected (gate/test files) deliberately matches existingPaths
25
+ // only: creating a new test/package file is the normal create/test-
26
+ // authoring flow, not tamper (pinned by test) — only touching an EXISTING
27
+ // gate input escalates.
28
+ const unapprovedAutoProtectedPaths = stats.existingPaths.filter((path) => !matchAny(path, approvalPatterns));
29
+ const specProtectedOnly = requireHuman(stats.touchedPaths, protectedPaths);
30
+ const autoProtectedOnly = requireHuman(unapprovedAutoProtectedPaths, autoProtectedPaths);
31
+ const protectedOnly = {
32
+ required: specProtectedOnly.required || autoProtectedOnly.required,
33
+ reasons: [...new Set([...specProtectedOnly.reasons, ...autoProtectedOnly.reasons])],
34
+ matchedPaths: [
35
+ ...new Set([...specProtectedOnly.matchedPaths, ...autoProtectedOnly.matchedPaths]),
36
+ ],
37
+ };
38
+ // classifyRisk's built-in pattern sets (sensitive resources, critical/high
39
+ // paths) are themselves a human-approval gate, so they match the TOUCHED
40
+ // set like every other path policy — `git mv .env config/settings.txt`
41
+ // must stay critical, and no other gate would recover it (G1 class,
42
+ // security commit 4e9e2270). Its file COUNT is a separate fact: renames
43
+ // touch two paths but change one file.
44
+ const risk = classifyRisk({
45
+ changedPaths: stats.touchedPaths,
46
+ fileCount: stats.paths.length,
47
+ additions: stats.additions,
48
+ deletions: stats.deletions,
49
+ protectedPaths: protectedOnly.matchedPaths,
50
+ });
51
+ const findings = [];
52
+ const reviewer = {
53
+ harness_id: "policy",
54
+ requested_model: null,
55
+ requested_effort: null,
56
+ observed_model: null,
57
+ route_proof_status: "verified",
58
+ };
59
+ const evidenceFor = (reasons) => ({
60
+ files: stats.touchedPaths
61
+ .filter((p) => reasons.some((r) => r.includes(p)))
62
+ .map((path) => ({ path, lines: null })),
63
+ });
64
+ // Structured matched-path evidence (never reconstructed from prose).
65
+ const evidenceFromPaths = (paths) => ({
66
+ files: paths.map((path) => ({ path, lines: null })),
67
+ });
68
+ const denyReasons = denyViolation.matchedPaths.map((path) => `candidate touched denied path ${path}`);
69
+ const reportedRisk = protectedOnly.required || denyViolation.required
70
+ ? {
71
+ level: "critical",
72
+ reasons: [
73
+ ...new Set([
74
+ ...risk.reasons,
75
+ ...protectedOnly.reasons,
76
+ ...(denyViolation.required ? denyReasons : []),
77
+ ]),
78
+ ],
79
+ matchedPaths: [
80
+ ...new Set([
81
+ ...risk.matchedPaths,
82
+ ...protectedOnly.matchedPaths,
83
+ ...denyViolation.matchedPaths,
84
+ ]),
85
+ ],
86
+ }
87
+ : risk;
88
+ if (denyViolation.required) {
89
+ // Authoritative post-diff deny gate: a BLOCK finding keeps the patch
90
+ // undelivered (blocked); only an operator accept_risk decision may still
91
+ // deliver it (INV-111 — the human is the final authority).
92
+ findings.push(ReviewFindingSchema.parse({
93
+ id: newId("find"),
94
+ severity: "BLOCK",
95
+ category: "security",
96
+ claim: `candidate touched denied path(s) (deny_paths): ${denyViolation.matchedPaths.join(", ")}`,
97
+ evidence: evidenceFromPaths(denyViolation.matchedPaths),
98
+ reviewer,
99
+ status: "accepted",
100
+ }));
101
+ }
102
+ if (protectedOnly.required) {
103
+ findings.push(ReviewFindingSchema.parse({
104
+ id: newId("find"),
105
+ severity: "BLOCK",
106
+ category: "test_gap",
107
+ claim: `candidate changed protected path(s): ${protectedOnly.matchedPaths.join(", ")}`,
108
+ evidence: evidenceFromPaths(protectedOnly.matchedPaths),
109
+ reviewer,
110
+ status: "accepted",
111
+ }));
112
+ }
113
+ const builtInHuman = requireHuman(stats.touchedPaths, DEFAULT_REQUIRE_HUMAN_PATHS);
114
+ const human = {
115
+ required: builtInHuman.required || protectedOnly.required,
116
+ reasons: [...new Set([...builtInHuman.reasons, ...protectedOnly.reasons])],
117
+ matchedPaths: [...new Set([...builtInHuman.matchedPaths, ...protectedOnly.matchedPaths])],
118
+ };
119
+ if (human.required) {
120
+ findings.push(ReviewFindingSchema.parse({
121
+ id: newId("find"),
122
+ severity: "NEEDS_HUMAN",
123
+ category: "security",
124
+ claim: `protected-path change requires human approval: ${human.reasons.join("; ")}`,
125
+ evidence: evidenceFromPaths(human.matchedPaths),
126
+ reviewer,
127
+ status: "accepted",
128
+ }));
129
+ }
130
+ const depth = reviewDepthForRisk(reportedRisk.level);
131
+ if (depth.humanApproval) {
132
+ findings.push(ReviewFindingSchema.parse({
133
+ id: newId("find"),
134
+ severity: "NEEDS_HUMAN",
135
+ category: "security",
136
+ claim: `critical-risk diff requires human approval: ${reportedRisk.reasons.join("; ")}`,
137
+ evidence: reportedRisk.matchedPaths.length > 0
138
+ ? evidenceFromPaths(reportedRisk.matchedPaths)
139
+ : evidenceFor(reportedRisk.reasons),
140
+ reviewer,
141
+ status: "accepted",
142
+ }));
143
+ }
144
+ else if (depth.crossFamily && !reviewVerified) {
145
+ findings.push(ReviewFindingSchema.parse({
146
+ id: newId("find"),
147
+ severity: "NEEDS_HUMAN",
148
+ category: "architecture",
149
+ claim: `high-risk diff requires a cross-family review panel (>=2 provider families), which is not available: ${reportedRisk.reasons.join("; ")}`,
150
+ evidence: reportedRisk.matchedPaths.length > 0
151
+ ? evidenceFromPaths(reportedRisk.matchedPaths)
152
+ : evidenceFor(reportedRisk.reasons),
153
+ reviewer,
154
+ status: "accepted",
155
+ }));
156
+ }
157
+ return {
158
+ findings,
159
+ risk: {
160
+ level: reportedRisk.level,
161
+ reasons: reportedRisk.reasons,
162
+ changedFiles: stats.paths.length,
163
+ },
164
+ };
165
+ }
166
+ //# sourceMappingURL=policyFindings.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"policyFindings.js","sourceRoot":"","sources":["../src/policyFindings.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EACL,YAAY,EACZ,2BAA2B,EAC3B,YAAY,EACZ,kBAAkB,GACnB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,kBAAkB,IAAI,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAElE,OAAO,EAAE,aAAa,IAAI,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACzE,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAExC;;;;;GAKG;AACH,MAAM,UAAU,cAAc,CAC5B,GAAqB,EACrB,cAAuB,EACvB,iBAA2B,EAAE,EAC7B,qBAA+B,EAAE,EACjC,yBAAkD,EAAE,EACpD,YAAsB,EAAE;IAKxB,MAAM,KAAK,GAAG,SAAS,CAAC,GAAG,CAAC,IAAI,C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AClC,CAAC,CAAC,iBAAiB,CAAC,YAAY,CAAC,YAAY,CAAC;gBAC9C,CAAC,CAAC,WAAW,CAAC,YAAY,CAAC,OAAO,CAAC;YACvC,QAAQ;YACR,MAAM,EAAE,UAAU;SACnB,CAAC,CACH,CAAC;IACJ,CAAC;SAAM,IAAI,KAAK,CAAC,WAAW,IAAI,CAAC,cAAc,EAAE,CAAC;QAChD,QAAQ,CAAC,IAAI,CACX,mBAAmB,CAAC,KAAK,CAAC;YACxB,EAAE,EAAE,KAAK,CAAC,MAAM,CAAC;YACjB,QAAQ,EAAE,aAAa;YACvB,QAAQ,EAAE,cAAc;YACxB,KAAK,EAAE,wGAAwG,YAAY,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;YAChJ,QAAQ,EACN,YAAY,CAAC,YAAY,CAAC,MAAM,GAAG,CAAC;gBAClC,CAAC,CAAC,iBAAiB,CAAC,YAAY,CAAC,YAAY,CAAC;gBAC9C,CAAC,CAAC,WAAW,CAAC,YAAY,CAAC,OAAO,CAAC;YACvC,QAAQ;YACR,MAAM,EAAE,UAAU;SACnB,CAAC,CACH,CAAC;IACJ,CAAC;IACD,OAAO;QACL,QAAQ;QACR,IAAI,EAAE;YACJ,KAAK,EAAE,YAAY,CAAC,KAAK;YACzB,OAAO,EAAE,YAAY,CAAC,OAAO;YAC7B,YAAY,EAAE,KAAK,CAAC,KAAK,CAAC,MAAM;SACjC;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,38 @@
1
+ import type { AccessProfile, Attachment, AttachmentInputClass, ExternalContextPolicy, ImplementationTransport, Intent, RequestRequirementResolution } from "@claudexor/schema";
2
+ import { HarnessUnavailableError } from "@claudexor/core";
3
+ export interface BrowserLaneRequirementInput {
4
+ harnessId: string;
5
+ requested: boolean;
6
+ manifestCapable: boolean;
7
+ webPolicy: ExternalContextPolicy;
8
+ access: AccessProfile;
9
+ }
10
+ export declare class RequestRequirementsError extends HarnessUnavailableError {
11
+ readonly resolutions: RequestRequirementResolution[];
12
+ readonly code = "browser_unavailable";
13
+ constructor(message: string, resolutions: RequestRequirementResolution[]);
14
+ }
15
+ /** One preflight owner for requested-vs-effective lane capability truth. */
16
+ export declare class RequestRequirementsResolver {
17
+ /** Patch producers only read; the engine owns materialization and delivery. */
18
+ adapterAccess(intent: Intent, implementationTransport: ImplementationTransport, requestedAccess: AccessProfile): AccessProfile;
19
+ assertConvergenceWorkspace(inPlace: boolean, routes: {
20
+ implementationTransport: ImplementationTransport;
21
+ }[]): void;
22
+ attachmentRefusal(harnessId: string, attachments: Attachment[], declarations: AttachmentInputClass[]): string | null;
23
+ browserSpec(resolution: RequestRequirementResolution, outputDir: string): {
24
+ output_dir: string;
25
+ headless: boolean;
26
+ } | null;
27
+ resolveBrowser(input: BrowserLaneRequirementInput): RequestRequirementResolution;
28
+ /**
29
+ * Per-lane deny-path enforcement receipt. No pinned adapter supports native
30
+ * pre-write path deny today (claude needs >=2.1.208), so an eligible lane
31
+ * does not exist and the engine's post-diff policy gate is the authoritative
32
+ * enforcement — the receipt discloses exactly that (`postdiff_only`), never
33
+ * implying OS/native containment that is not there.
34
+ */
35
+ resolveDenyPaths(harnessId: string, requested: boolean): RequestRequirementResolution;
36
+ requireEffectiveBrowser(requested: boolean, resolutions: RequestRequirementResolution[]): void;
37
+ }
38
+ //# sourceMappingURL=requestRequirements.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"requestRequirements.d.ts","sourceRoot":"","sources":["../src/requestRequirements.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,aAAa,EACb,UAAU,EACV,oBAAoB,EACpB,qBAAqB,EACrB,uBAAuB,EACvB,MAAM,EACN,4BAA4B,EAC7B,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AAE1D,MAAM,WAAW,2BAA2B;IAC1C,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,OAAO,CAAC;IACnB,eAAe,EAAE,OAAO,CAAC;IACzB,SAAS,EAAE,qBAAqB,CAAC;IACjC,MAAM,EAAE,aAAa,CAAC;CACvB;AAED,qBAAa,wBAAyB,SAAQ,uBAAuB;IAKjE,QAAQ,CAAC,WAAW,EAAE,4BAA4B,EAAE;IAJtD,QAAQ,CAAC,IAAI,yBAAyB;gBAGpC,OAAO,EAAE,MAAM,EACN,WAAW,EAAE,4BAA4B,EAAE;CAIvD;AAED,4EAA4E;AAC5E,qBAAa,2BAA2B;IACtC,+EAA+E;IAC/E,aAAa,CACX,MAAM,EAAE,MAAM,EACd,uBAAuB,EAAE,uBAAuB,EAChD,eAAe,EAAE,aAAa,GAC7B,aAAa;IAOhB,0BAA0B,CACxB,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE;QAAE,uBAAuB,EAAE,uBAAuB,CAAA;KAAE,EAAE,GAC7D,IAAI;IAQP,iBAAiB,CACf,SAAS,EAAE,MAAM,EACjB,WAAW,EAAE,UAAU,EAAE,EACzB,YAAY,EAAE,oBAAoB,EAAE,GACnC,MAAM,GAAG,IAAI;IAmBhB,WAAW,CACT,UAAU,EAAE,4BAA4B,EACxC,SAAS,EAAE,MAAM,GAChB;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,OAAO,CAAA;KAAE,GAAG,IAAI;IAInD,cAAc,CAAC,KAAK,EAAE,2BAA2B,GAAG,4BAA4B;IA6DhF;;;;;;OAMG;IACH,gBAAgB,CAAC,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,GAAG,4BAA4B;IAYrF,uBAAuB,CAAC,SAAS,EAAE,OAAO,EAAE,WAAW,EAAE,4BAA4B,EAAE,GAAG,IAAI;CAU/F"}
@@ -0,0 +1,127 @@
1
+ import { HarnessUnavailableError } from "@claudexor/core";
2
+ export class RequestRequirementsError extends HarnessUnavailableError {
3
+ resolutions;
4
+ code = "browser_unavailable";
5
+ constructor(message, resolutions) {
6
+ super(message);
7
+ this.resolutions = resolutions;
8
+ }
9
+ }
10
+ /** One preflight owner for requested-vs-effective lane capability truth. */
11
+ export class RequestRequirementsResolver {
12
+ /** Patch producers only read; the engine owns materialization and delivery. */
13
+ adapterAccess(intent, implementationTransport, requestedAccess) {
14
+ return implementationTransport === "git_patch_envelope" &&
15
+ (intent === "implement" || intent === "synthesize")
16
+ ? "readonly"
17
+ : requestedAccess;
18
+ }
19
+ assertConvergenceWorkspace(inPlace, routes) {
20
+ if (inPlace && routes.some((route) => route.implementationTransport === "git_patch_envelope")) {
21
+ throw new HarnessUnavailableError("in-place convergence is unavailable for git_patch_envelope adapters; use an isolated run or a single agent attempt");
22
+ }
23
+ }
24
+ attachmentRefusal(harnessId, attachments, declarations) {
25
+ for (const attachment of attachments) {
26
+ const declaration = declarations.find((candidate) => candidate.kind === attachment.kind && candidate.mime_types.includes(attachment.mime));
27
+ if (!declaration)
28
+ return `${harnessId} cannot receive every mandatory attachment: ${attachment.kind} ${attachment.mime} is unsupported; choose a compatible harness pool or remove the attachment`;
29
+ if (attachment.size_bytes > declaration.max_bytes)
30
+ return `${harnessId} cannot receive every mandatory attachment: ${attachment.name || attachment.resource_id} is ${attachment.size_bytes} bytes (max ${declaration.max_bytes} for ${attachment.mime}); choose a compatible harness pool or remove the attachment`;
31
+ const count = attachments.filter((item) => item.kind === declaration.kind && declaration.mime_types.includes(item.mime)).length;
32
+ if (count > declaration.max_count)
33
+ return `${harnessId} cannot receive every mandatory attachment: ${count} ${declaration.kind} attachments exceed max_count ${declaration.max_count}; choose a compatible harness pool or remove the attachment`;
34
+ }
35
+ return null;
36
+ }
37
+ browserSpec(resolution, outputDir) {
38
+ return resolution.effective ? { output_dir: outputDir, headless: false } : null;
39
+ }
40
+ resolveBrowser(input) {
41
+ const eligible = input.manifestCapable;
42
+ if (!input.requested) {
43
+ return {
44
+ capability: "browser",
45
+ harness_id: input.harnessId,
46
+ eligible,
47
+ requested: false,
48
+ effective: false,
49
+ reason: "not_requested",
50
+ evidence_refs: ["request.browser"],
51
+ };
52
+ }
53
+ if (!eligible) {
54
+ return {
55
+ capability: "browser",
56
+ harness_id: input.harnessId,
57
+ eligible: false,
58
+ requested: true,
59
+ effective: false,
60
+ reason: "manifest_unsupported",
61
+ evidence_refs: ["manifest.capabilities.browser_tool"],
62
+ };
63
+ }
64
+ if (input.webPolicy === "off") {
65
+ return {
66
+ capability: "browser",
67
+ harness_id: input.harnessId,
68
+ eligible: true,
69
+ requested: true,
70
+ effective: false,
71
+ reason: "web_policy_off",
72
+ evidence_refs: ["request.external_context_policy"],
73
+ };
74
+ }
75
+ if (input.access !== "full" && input.access !== "external_sandbox_full") {
76
+ return {
77
+ capability: "browser",
78
+ harness_id: input.harnessId,
79
+ eligible: true,
80
+ requested: true,
81
+ effective: false,
82
+ reason: "access_profile_incompatible",
83
+ evidence_refs: ["task.access.effective_profile"],
84
+ };
85
+ }
86
+ return {
87
+ capability: "browser",
88
+ harness_id: input.harnessId,
89
+ eligible: true,
90
+ requested: true,
91
+ effective: true,
92
+ reason: "effective",
93
+ evidence_refs: [
94
+ "manifest.capabilities.browser_tool",
95
+ "request.external_context_policy",
96
+ "task.access.effective_profile",
97
+ ],
98
+ };
99
+ }
100
+ /**
101
+ * Per-lane deny-path enforcement receipt. No pinned adapter supports native
102
+ * pre-write path deny today (claude needs >=2.1.208), so an eligible lane
103
+ * does not exist and the engine's post-diff policy gate is the authoritative
104
+ * enforcement — the receipt discloses exactly that (`postdiff_only`), never
105
+ * implying OS/native containment that is not there.
106
+ */
107
+ resolveDenyPaths(harnessId, requested) {
108
+ return {
109
+ capability: "path_deny",
110
+ harness_id: harnessId,
111
+ eligible: false,
112
+ requested,
113
+ effective: false,
114
+ reason: requested ? "postdiff_only" : "not_requested",
115
+ evidence_refs: ["request.deny_paths"],
116
+ };
117
+ }
118
+ requireEffectiveBrowser(requested, resolutions) {
119
+ if (!requested || resolutions.some((resolution) => resolution.effective))
120
+ return;
121
+ const detail = resolutions
122
+ .map((resolution) => `${resolution.harness_id}: ${resolution.reason}`)
123
+ .join("; ");
124
+ throw new RequestRequirementsError(`browser was requested but no selected harness lane can receive it${detail ? ` (${detail})` : ""}; choose a browser-capable lane with web enabled and full access`, resolutions);
125
+ }
126
+ }
127
+ //# sourceMappingURL=requestRequirements.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"requestRequirements.js","sourceRoot":"","sources":["../src/requestRequirements.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AAU1D,MAAM,OAAO,wBAAyB,SAAQ,uBAAuB;IAKxD;IAJF,IAAI,GAAG,qBAAqB,CAAC;IAEtC,YACE,OAAe,EACN,WAA2C;QAEpD,KAAK,CAAC,OAAO,CAAC,CAAC;QAFN,gBAAW,GAAX,WAAW,CAAgC;IAGtD,CAAC;CACF;AAED,4EAA4E;AAC5E,MAAM,OAAO,2BAA2B;IACtC,+EAA+E;IAC/E,aAAa,CACX,MAAc,EACd,uBAAgD,EAChD,eAA8B;QAE9B,OAAO,uBAAuB,KAAK,oBAAoB;YACrD,CAAC,MAAM,KAAK,WAAW,IAAI,MAAM,KAAK,YAAY,CAAC;YACnD,CAAC,CAAC,UAAU;YACZ,CAAC,CAAC,eAAe,CAAC;IACtB,CAAC;IAED,0BAA0B,CACxB,OAAgB,EAChB,MAA8D;QAE9D,IAAI,OAAO,IAAI,MAAM,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,uBAAuB,KAAK,oBAAoB,CAAC,EAAE,CAAC;YAC9F,MAAM,IAAI,uBAAuB,CAC/B,oHAAoH,CACrH,CAAC;QACJ,CAAC;IACH,CAAC;IAED,iBAAiB,CACf,SAAiB,EACjB,WAAyB,EACzB,YAAoC;QAEpC,KAAK,MAAM,UAAU,IAAI,WAAW,EAAE,CAAC;YACrC,MAAM,WAAW,GAAG,YAAY,CAAC,IAAI,CACnC,CAAC,SAAS,EAAE,EAAE,CACZ,SAAS,CAAC,IAAI,KAAK,UAAU,CA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pC,iCAAiC;gBACjC,+BAA+B;aAChC;SACF,CAAC;IACJ,CAAC;IAED;;;;;;OAMG;IACH,gBAAgB,CAAC,SAAiB,EAAE,SAAkB;QACpD,OAAO;YACL,UAAU,EAAE,WAAW;YACvB,UAAU,EAAE,SAAS;YACrB,QAAQ,EAAE,KAAK;YACf,SAAS;YACT,SAAS,EAAE,KAAK;YAChB,MAAM,EAAE,SAAS,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,eAAe;YACrD,aAAa,EAAE,CAAC,oBAAoB,CAAC;SACtC,CAAC;IACJ,CAAC;IAED,uBAAuB,CAAC,SAAkB,EAAE,WAA2C;QACrF,IAAI,CAAC,SAAS,IAAI,WAAW,CAAC,IAAI,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,CAAC,SAAS,CAAC;YAAE,OAAO;QACjF,MAAM,MAAM,GAAG,WAAW;aACvB,GAAG,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,GAAG,UAAU,CAAC,UAAU,KAAK,UAAU,CAAC,MAAM,EAAE,CAAC;aACrE,IAAI,CAAC,IAAI,CAAC,CAAC;QACd,MAAM,IAAI,wBAAwB,CAChC,oEAAoE,MAAM,CAAC,CAAC,CAAC,KAAK,MAAM,GAAG,CAAC,CAAC,CAAC,EAAE,kEAAkE,EAClK,WAAW,CACZ,CAAC;IACJ,CAAC;CACF"}
@@ -8,7 +8,7 @@
8
8
  * HarnessUnavailableError; the orchestrator turns them into review_preflight
9
9
  * failure ARTIFACTS after run-dir creation, before candidates spend money.
10
10
  */
11
- import type { AuthPreference, ControlReviewerPanelEntry } from "@claudexor/schema";
11
+ import type { AuthPreference, ControlReviewerPanelEntry, EffortHint, ProviderFamily } from "@claudexor/schema";
12
12
  import type { HarnessAdapter } from "@claudexor/core";
13
13
  import type { ReviewerSpec } from "@claudexor/review";
14
14
  interface PanelHarnessSettings {
@@ -22,5 +22,19 @@ export interface ReviewerPanelDeps {
22
22
  authPreferenceFor: (harnessId: string) => AuthPreference;
23
23
  }
24
24
  export declare function resolveExplicitReviewerPanel(deps: ReviewerPanelDeps, panel: ControlReviewerPanelEntry[]): Promise<ReviewerSpec[]>;
25
+ export interface AutoReviewerPanelOverrides {
26
+ reviewerModels?: Partial<Record<ProviderFamily, string>>;
27
+ reviewerEfforts?: Partial<Record<ProviderFamily, EffortHint>>;
28
+ }
29
+ /**
30
+ * Auto reviewer-panel selection (no owner-configured panel): pick up to two
31
+ * doctor-ok, readonly-review-capable harnesses from DISTINCT provider
32
+ * families. Eligibility consumes a point-probe in the same scoped read-only
33
+ * env shape the reviewers later run with, and the STRICT model truth gate
34
+ * applies to any per-family/default model override — a doomed reviewer model
35
+ * is refused here, never forwarded to die as an opaque native error
36
+ * mid-review.
37
+ */
38
+ export declare function resolveAutoReviewerPanel(deps: ReviewerPanelDeps, overrides?: AutoReviewerPanelOverrides): Promise<ReviewerSpec[]>;
25
39
  export {};
26
40
  //# sourceMappingURL=reviewerPanel.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"reviewerPanel.d.ts","sourceRoot":"","sources":["../src/reviewerPanel.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,KAAK,EAAE,cAAc,EAAE,yBAAyB,EAAU,MAAM,mBAAmB,CAAC;AAC3F,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAGtD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAItD,UAAU,oBAAoB;IAC5B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC/B;AAED,MAAM,WAAW,iBAAiB;IAChC,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;IACtC,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,oBAAoB,GAAG,SAAS,CAAC,CAAC;IAClE,iBAAiB,EAAE,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