opencode-swarm 7.162.0 → 7.163.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/dist/background/pr-review-contract.d.ts +1 -24
- package/dist/cli/authorization-vstrh7ra.js +23 -0
- package/dist/cli/{coder-settlement-s8cskxk7.js → coder-settlement-g2g5kkv5.js} +10 -10
- package/dist/cli/{config-doctor-636h188h.js → config-doctor-p16xr78z.js} +2 -2
- package/dist/cli/{core-h3hsczyq.js → core-g088v0zt.js} +1 -1
- package/dist/cli/{curation-policy-ayq5kmnf.js → curation-policy-j12j2gvc.js} +6 -6
- package/dist/cli/{curator-p0dwpn2x.js → curator-3m8a8qsn.js} +33 -31
- package/dist/cli/curator-llm-factory-p00hks4v.js +69 -0
- package/dist/cli/{evidence-summary-service-hvbqyb4g.js → evidence-summary-service-4ghqakhx.js} +13 -13
- package/dist/cli/{gate-evidence-dhgmnsh0.js → gate-evidence-4v8apasx.js} +6 -6
- package/dist/cli/guardrail-explain-smqenqtm.js +70 -0
- package/dist/cli/{guardrail-log-qc7rfhv2.js → guardrail-log-mmh4b4k4.js} +7 -7
- package/dist/cli/{guardrail-reset-cxkf5h0x.js → guardrail-reset-zge5hg4p.js} +33 -31
- package/dist/cli/{hive-promoter-ppbrv8m1.js → hive-promoter-vxez5s7m.js} +33 -31
- package/dist/cli/{index-jw7z3gem.js → index-0103w5pf.js} +2 -2
- package/dist/cli/{index-fx3em0dr.js → index-2zgjcmmc.js} +139 -45
- package/dist/cli/{index-qw893zqp.js → index-3ab9tczn.js} +8 -8
- package/dist/cli/{index-q87ht62k.js → index-3b762978.js} +5 -2
- package/dist/cli/{index-5wq0dd30.js → index-3rjxbe1p.js} +2 -2
- package/dist/cli/{index-z4n60b0a.js → index-453tzvkg.js} +1 -1
- package/dist/cli/{index-pde4zn7j.js → index-4t68xs0p.js} +3 -3
- package/dist/cli/{index-sjkxrf06.js → index-4xggfhge.js} +4 -4
- package/dist/cli/{index-8vwe2qjh.js → index-5hgn302x.js} +9 -9
- package/dist/cli/{index-bdmg6yvj.js → index-7n9jznv0.js} +4 -4
- package/dist/cli/{index-2rhs7j4r.js → index-7wb2v7jg.js} +2152 -2622
- package/dist/cli/{index-kk9yk7an.js → index-8ada7ag7.js} +2 -2
- package/dist/cli/{index-nqbqkx4c.js → index-9crtmnqg.js} +1 -1
- package/dist/cli/{index-3gwkmq53.js → index-axx3t3k7.js} +2 -2
- package/dist/cli/{index-80pmq6q2.js → index-cqgpvx2d.js} +2 -2
- package/dist/cli/{index-vcv9m2q5.js → index-eqkdjfqa.js} +4 -4
- package/dist/cli/{index-77syzssw.js → index-f7t5fn4z.js} +4 -4
- package/dist/cli/{index-9wrmzsnk.js → index-fckfgptr.js} +1 -1
- package/dist/cli/{index-0h63swrc.js → index-g4bvsapf.js} +5 -5
- package/dist/cli/{index-ydbd41sv.js → index-hm239n1p.js} +1 -1
- package/dist/cli/{index-qn4w0gar.js → index-m4nhy4fp.js} +1 -1
- package/dist/cli/{index-2ze7yqm8.js → index-m7yt3xmk.js} +1 -1
- package/dist/cli/index-mmngnxev.js +883 -0
- package/dist/cli/{index-7z9gyts0.js → index-n2mhyect.js} +1 -1
- package/dist/cli/{index-db520vnn.js → index-n67vx5zw.js} +2 -2
- package/dist/cli/{index-25xvw7hq.js → index-nwa7ctyf.js} +35 -33
- package/dist/cli/{index-4wmpv2kn.js → index-ptsmms01.js} +6 -6
- package/dist/cli/{index-mfewnd7j.js → index-pykfqsk0.js} +5 -5
- package/dist/cli/{index-r7rn6e5f.js → index-qy2rm1f6.js} +6 -6
- package/dist/cli/{index-tnj464kq.js → index-rqh25ns3.js} +1 -1
- package/dist/cli/{index-tjaawnws.js → index-s8c6f9rr.js} +6 -4
- package/dist/cli/{index-vkaqrrsc.js → index-t4hs3qk6.js} +15 -644
- package/dist/cli/{index-1wapt173.js → index-w0yn4rmh.js} +3 -3
- package/dist/cli/{index-1mbwgw4p.js → index-w1mc7gcm.js} +2 -2
- package/dist/cli/index-w7ekntej.js +643 -0
- package/dist/cli/{index-acnwj4pc.js → index-xyhmt813.js} +1 -1
- package/dist/cli/{index-6w468bjy.js → index-zgz81a8x.js} +1 -1
- package/dist/cli/index.js +33 -31
- package/dist/cli/{knowledge-escalator-nyeg4ndw.js → knowledge-escalator-91d1n291.js} +12 -12
- package/dist/cli/{knowledge-events-z7smbnff.js → knowledge-events-xrd9es3p.js} +10 -10
- package/dist/cli/{knowledge-link-0byjmj0w.js → knowledge-link-vmdj5e5d.js} +5 -5
- package/dist/cli/{knowledge-store-p14t72y5.js → knowledge-store-2brg88cx.js} +6 -6
- package/dist/cli/{knowledge-validator-jg6zhx9s.js → knowledge-validator-s1v7kry2.js} +8 -8
- package/dist/cli/{pending-delegations-0111ywd2.js → pending-delegations-b341397j.js} +6 -5
- package/dist/cli/{pr-subscriptions-4e64sbwg.js → pr-subscriptions-2mkdt0ak.js} +5 -5
- package/dist/cli/{runner-rddddxmq.js → runner-3gw2njnx.js} +6 -6
- package/dist/cli/{scan-cursor-wjad4yd7.js → scan-cursor-jm7j3w1c.js} +7 -7
- package/dist/cli/{schema-9ebqj7mv.js → schema-6cpgnq4s.js} +1 -1
- package/dist/cli/{scope-persistence-j5hz4mnd.js → scope-persistence-q713ck5n.js} +9 -9
- package/dist/cli/{skill-generator-x6b05jz6.js → skill-generator-z9bs6vdt.js} +14 -14
- package/dist/cli/{telemetry-cmbjv240.js → telemetry-x4zggfd7.js} +1 -1
- package/dist/cli/{worktree-collision-ownership-g5n5xbqy.js → worktree-collision-ownership-drtv7jjp.js} +7 -6
- package/dist/cli/{worktree-isolation-ha70bwes.js → worktree-isolation-534h3c2f.js} +33 -31
- package/dist/council/council-observability.d.ts +42 -0
- package/dist/hooks/pr-workflow-gate.d.ts +20 -245
- package/dist/index.js +374 -374
- package/dist/observability/catalog.d.ts +8 -4
- package/dist/observability/ids.d.ts +1 -1
- package/dist/observability/legacy.d.ts +6 -4
- package/dist/observability/observe.d.ts +1 -1
- package/dist/{hooks/pr-review-reentry-authorization.d.ts → pr-review/authorization.d.ts} +32 -10
- package/dist/{hooks/pr-review-resilience-circuit.d.ts → pr-review/circuit.d.ts} +60 -3
- package/dist/pr-review/completion.d.ts +373 -0
- package/dist/pr-review/critic-routing.d.ts +37 -0
- package/dist/pr-review/guardrails.d.ts +67 -0
- package/dist/pr-review/legacy-transcript-adapter.d.ts +276 -0
- package/dist/pr-review/persistence.d.ts +107 -0
- package/dist/pr-review/reducer.d.ts +54 -0
- package/dist/pr-review/types.d.ts +225 -0
- package/dist/telemetry.d.ts +1 -1
- package/package.json +1 -1
- package/dist/cli/curator-llm-factory-g65xmh8f.js +0 -67
- package/dist/cli/guardrail-explain-s0dzn8c6.js +0 -68
- package/dist/cli/pr-review-reentry-authorization-b7ceja9y.js +0 -301
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PR-review typed state boundary (issue #2385).
|
|
3
|
+
*
|
|
4
|
+
* The closed event/effect vocabulary for the PR-review transition authority
|
|
5
|
+
* (`reducer.ts`) plus the PR-review slice of the workflow gate state. The
|
|
6
|
+
* owning gate's full `PrWorkflowGateState` satisfies this slice structurally
|
|
7
|
+
* (a compile-time assertion in the gate enforces it), so there is ONE field
|
|
8
|
+
* definition — the gate adds only non-PR-review fields.
|
|
9
|
+
*
|
|
10
|
+
* Invalid transitions from issue #2385 are rejected with typed codes
|
|
11
|
+
* (`PrReviewTransitionRejectionCode`) rather than made representable-by-type
|
|
12
|
+
* alone: several of them depend on runtime evidence (generations, digests,
|
|
13
|
+
* ledger state), so the reducer is the enforcement point.
|
|
14
|
+
*/
|
|
15
|
+
import type { PrReviewBaseDimensionId } from '../background/pr-review-contract.js';
|
|
16
|
+
import type { PrReviewCircuitSignal, PrReviewResiliencePolicyRecord } from './circuit.js';
|
|
17
|
+
/** A declared base-dispatch lane (subset the reducer governs). */
|
|
18
|
+
export interface PrReviewBaseDispatchLane {
|
|
19
|
+
laneId: string;
|
|
20
|
+
workflowLane: PrReviewBaseDimensionId;
|
|
21
|
+
ownedWorkflowLanes?: PrReviewBaseDimensionId[];
|
|
22
|
+
}
|
|
23
|
+
export interface PrReviewBaseDispatchRecordLite {
|
|
24
|
+
batchId: string;
|
|
25
|
+
lanes: PrReviewBaseDispatchLane[];
|
|
26
|
+
validatedAt: string;
|
|
27
|
+
}
|
|
28
|
+
export interface PrReviewDimensionCancellationLite {
|
|
29
|
+
reason: string;
|
|
30
|
+
cancelledAt: string;
|
|
31
|
+
source: 'armed_recovery';
|
|
32
|
+
}
|
|
33
|
+
export interface PrReviewResilienceSlice {
|
|
34
|
+
policy: PrReviewResiliencePolicyRecord;
|
|
35
|
+
/** Attempt bookkeeping is adapter-owned; the reducer carries it opaquely. */
|
|
36
|
+
attempts: readonly unknown[];
|
|
37
|
+
circuit?: import('./circuit.js').PrReviewCircuitRecord | undefined;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* The PR-review slice of the workflow gate state. The gate's full state type
|
|
41
|
+
* satisfies this structurally; the reducer may therefore be applied to the
|
|
42
|
+
* live gate state object without a projection step.
|
|
43
|
+
*/
|
|
44
|
+
export interface PrReviewWorkflowState {
|
|
45
|
+
sessionID: string;
|
|
46
|
+
workflowInstanceId?: string | undefined;
|
|
47
|
+
revision: number;
|
|
48
|
+
prHeadSha?: string | undefined;
|
|
49
|
+
prReviewBaseSha?: string | undefined;
|
|
50
|
+
prReviewBaseDispatches?: PrReviewBaseDispatchRecordLite[] | undefined;
|
|
51
|
+
prReviewBaseDispatch?: PrReviewBaseDispatchRecordLite | undefined;
|
|
52
|
+
prReviewResilience?: PrReviewResilienceSlice | undefined;
|
|
53
|
+
prReviewContractRetryDimensions?: PrReviewBaseDimensionId[] | undefined;
|
|
54
|
+
prReviewDimensionCancellations?: Partial<Record<PrReviewBaseDimensionId, PrReviewDimensionCancellationLite>> | undefined;
|
|
55
|
+
/** Coverage disclosure fields are carried opaquely (owned by completion.ts). */
|
|
56
|
+
prReviewPartialBaseCoverage?: unknown | undefined;
|
|
57
|
+
}
|
|
58
|
+
export type PrReviewTerminalCoverageKind = 'COMPLETE' | 'PARTIAL' | 'NO_COVERAGE';
|
|
59
|
+
export type PrReviewReportVerdict = 'APPROVE' | 'INCOMPLETE' | 'REQUEST_CHANGES';
|
|
60
|
+
export interface PrReviewCoverageSettlementInput {
|
|
61
|
+
kind: PrReviewTerminalCoverageKind;
|
|
62
|
+
coveredDimensions: PrReviewBaseDimensionId[];
|
|
63
|
+
unresolvedDimensions: Array<{
|
|
64
|
+
dimension: PrReviewBaseDimensionId;
|
|
65
|
+
terminalState: 'FAILED' | 'CANCELLED' | 'NOT_LAUNCHED';
|
|
66
|
+
reasonKind: string;
|
|
67
|
+
}>;
|
|
68
|
+
/** Dimensions with a live (non-terminal) lane — blocks finalization. */
|
|
69
|
+
liveDimensions: PrReviewBaseDimensionId[];
|
|
70
|
+
}
|
|
71
|
+
export type PrReviewEffect = {
|
|
72
|
+
kind: 'persist_state';
|
|
73
|
+
} | {
|
|
74
|
+
kind: 'settle_delegation';
|
|
75
|
+
batchId: string;
|
|
76
|
+
laneId: string;
|
|
77
|
+
status: 'completed' | 'error' | 'cancelled' | 'stale';
|
|
78
|
+
replay?: boolean;
|
|
79
|
+
} | {
|
|
80
|
+
kind: 'emit_diagnostic';
|
|
81
|
+
source: 'collection_observer' | 'legacy_transcript_adapter';
|
|
82
|
+
code: string;
|
|
83
|
+
boundedDetail?: string | undefined;
|
|
84
|
+
} | {
|
|
85
|
+
kind: 'block_dispatch';
|
|
86
|
+
reason: 'circuit_open' | 'probe_in_flight';
|
|
87
|
+
};
|
|
88
|
+
/**
|
|
89
|
+
* Effect kinds map to executors that exist in production (issue #2385
|
|
90
|
+
* Phase 8b review): `persist_state` is executed by the gate through the
|
|
91
|
+
* persistence CAS write; `settle_delegation` describes the settlement the
|
|
92
|
+
* dispatch/collect adapters perform via `pending-delegations.ts`;
|
|
93
|
+
* `emit_diagnostic` describes the collect observer's bounded diagnostics
|
|
94
|
+
* channel; `block_dispatch` describes the circuit-open admission refusal.
|
|
95
|
+
* A kind with no executor is not emitted and not declared.
|
|
96
|
+
*/
|
|
97
|
+
export type PrReviewCircuitProbeOutcome = {
|
|
98
|
+
result: 'typed_success';
|
|
99
|
+
} | {
|
|
100
|
+
result: 'provider_failure';
|
|
101
|
+
providerClass: string;
|
|
102
|
+
} | {
|
|
103
|
+
result: 'ignored';
|
|
104
|
+
} | {
|
|
105
|
+
result: 'rolled_back_admission';
|
|
106
|
+
};
|
|
107
|
+
export type PrReviewEvent = {
|
|
108
|
+
type: 'base_admission_requested';
|
|
109
|
+
batchId: string;
|
|
110
|
+
lanes: PrReviewBaseDispatchLane[];
|
|
111
|
+
depthTier: 'S' | 'M' | 'L';
|
|
112
|
+
maxBatches: number;
|
|
113
|
+
validatedAt: string;
|
|
114
|
+
} | {
|
|
115
|
+
type: 'base_admission_rolled_back';
|
|
116
|
+
batchId: string;
|
|
117
|
+
batchDelegationRecordsExist: boolean;
|
|
118
|
+
} | {
|
|
119
|
+
type: 'collection_observed';
|
|
120
|
+
diagnostic: 'busy' | 'retry' | 'idle_unknown' | 'host_unavailable' | 'probe_error' | 'wait_expired';
|
|
121
|
+
pendingLaneIds: readonly string[];
|
|
122
|
+
boundedDetail?: string | undefined;
|
|
123
|
+
} | {
|
|
124
|
+
type: 'lane_structured_result_submitted';
|
|
125
|
+
batchId: string;
|
|
126
|
+
laneId: string;
|
|
127
|
+
generation: number;
|
|
128
|
+
semanticEnvelopeDigest: string;
|
|
129
|
+
outcome: 'CLEAN' | 'FINDINGS' | 'INCOMPLETE';
|
|
130
|
+
existingReceiptDigest?: string | undefined;
|
|
131
|
+
} | {
|
|
132
|
+
type: 'transcript_evidence_presented';
|
|
133
|
+
batchId: string;
|
|
134
|
+
laneId: string;
|
|
135
|
+
laneHasStructuredReceipt: boolean;
|
|
136
|
+
} | {
|
|
137
|
+
type: 'provider_terminal_observed';
|
|
138
|
+
batchId: string;
|
|
139
|
+
laneId: string;
|
|
140
|
+
generation: number;
|
|
141
|
+
evidence: {
|
|
142
|
+
source: 'typed_terminal_error_class';
|
|
143
|
+
category: string;
|
|
144
|
+
kind: string;
|
|
145
|
+
} | {
|
|
146
|
+
source: 'observer_deadline';
|
|
147
|
+
} | {
|
|
148
|
+
source: 'client_unavailable';
|
|
149
|
+
} | {
|
|
150
|
+
source: 'parser_or_transcript';
|
|
151
|
+
} | {
|
|
152
|
+
source: 'stale_observation';
|
|
153
|
+
};
|
|
154
|
+
} | {
|
|
155
|
+
type: 'lane_cancelled';
|
|
156
|
+
batchId: string;
|
|
157
|
+
laneId: string;
|
|
158
|
+
generation: number;
|
|
159
|
+
} | {
|
|
160
|
+
type: 'circuit_advance_requested';
|
|
161
|
+
nowMs: number;
|
|
162
|
+
laneSignals: readonly PrReviewCircuitSignal[];
|
|
163
|
+
probeObservation?: {
|
|
164
|
+
terminalStatus: string;
|
|
165
|
+
signal: PrReviewCircuitSignal | null;
|
|
166
|
+
terminalAtMs: number;
|
|
167
|
+
} | undefined;
|
|
168
|
+
admission?: {
|
|
169
|
+
batchId: string;
|
|
170
|
+
laneId: string;
|
|
171
|
+
} | undefined;
|
|
172
|
+
policy: PrReviewResiliencePolicyRecord;
|
|
173
|
+
} | {
|
|
174
|
+
type: 'circuit_probe_settled';
|
|
175
|
+
outcome: PrReviewCircuitProbeOutcome;
|
|
176
|
+
nowMs: number;
|
|
177
|
+
policy: PrReviewResiliencePolicyRecord;
|
|
178
|
+
} | {
|
|
179
|
+
type: 'resilience_config_changed';
|
|
180
|
+
enabled: boolean;
|
|
181
|
+
policy?: import('../config/schema.js').PrReviewResilienceConfig | undefined;
|
|
182
|
+
nowMs: number;
|
|
183
|
+
} | {
|
|
184
|
+
type: 'coverage_finalization_requested';
|
|
185
|
+
settlement: PrReviewCoverageSettlementInput;
|
|
186
|
+
requestedVerdict?: PrReviewReportVerdict;
|
|
187
|
+
} | {
|
|
188
|
+
type: 'critic_result_recorded';
|
|
189
|
+
criticRequiredFindingIds: readonly string[];
|
|
190
|
+
criticConfirmedFindingIds: readonly string[];
|
|
191
|
+
} | {
|
|
192
|
+
type: 'publication_armed';
|
|
193
|
+
coverageKind: PrReviewTerminalCoverageKind;
|
|
194
|
+
verdict: PrReviewReportVerdict;
|
|
195
|
+
} | {
|
|
196
|
+
type: 'publication_published';
|
|
197
|
+
binding: PrReviewAuthorizationBinding;
|
|
198
|
+
} | {
|
|
199
|
+
type: 'armed_recovery_requested';
|
|
200
|
+
binding: PrReviewAuthorizationBinding;
|
|
201
|
+
dimensionsToCancel: PrReviewBaseDimensionId[];
|
|
202
|
+
nowIso: string;
|
|
203
|
+
} | {
|
|
204
|
+
type: 'reviewer_authorization_consumed';
|
|
205
|
+
binding: PrReviewAuthorizationBinding;
|
|
206
|
+
expectedRole: 'reviewer' | 'test_engineer';
|
|
207
|
+
role: 'reviewer' | 'test_engineer';
|
|
208
|
+
};
|
|
209
|
+
/**
|
|
210
|
+
* The exact-identity binding an armed recovery, publication, or re-entry
|
|
211
|
+
* authorization must carry (issue #2383/#2385). Stale or foreign values are
|
|
212
|
+
* rejected with `stale_foreign_authorization`.
|
|
213
|
+
*/
|
|
214
|
+
export interface PrReviewAuthorizationBinding {
|
|
215
|
+
sessionID: string;
|
|
216
|
+
workflowInstanceId?: string | undefined;
|
|
217
|
+
prHeadSha: string;
|
|
218
|
+
revisionDigest?: string;
|
|
219
|
+
generation: number;
|
|
220
|
+
}
|
|
221
|
+
export type PrReviewTransitionRejectionCode = 'observer_deadline_not_terminal_evidence' | 'client_absence_not_terminal_evidence' | 'parser_failure_not_provider_signal' | 'stale_observation_not_provider_signal' | 'live_lane_blocks_coverage' | 'partial_coverage_cannot_approve' | 'no_coverage_cannot_approve' | 'critic_required_unfulfilled' | 'stale_foreign_authorization' | 'stale_generation_result' | 'receipt_cannot_be_downgraded' | 'duplicate_conflicting_result' | 'base_batch_limit_reached' | 'rollback_preconditions_failed' | 'lane_not_stale_eligible' | 'unknown_event';
|
|
222
|
+
export interface PrReviewTransitionRejection {
|
|
223
|
+
code: PrReviewTransitionRejectionCode;
|
|
224
|
+
detail: string;
|
|
225
|
+
}
|
package/dist/telemetry.d.ts
CHANGED
|
@@ -32,7 +32,7 @@ export type TelemetryEvent = 'session_started' | 'session_ended' | 'agent_activa
|
|
|
32
32
|
* `prm_hard_stop` TRIGGER emitted by `src/prm/escalation.ts`. A trigger with
|
|
33
33
|
* no matching delivery means the containment never reached the agent.
|
|
34
34
|
*/
|
|
35
|
-
| 'prm_hard_stop_delivered' | 'agent_conflict_detected' | 'close_archive_result' | 'knowledge_receipt_transition' | 'knowledge_maintenance' | 'residue_health' | 'context_telemetry_health' | 'skill_usage_health' | 'core_events_health' | 'shell_audit_health' | 'trajectory_health' | 'learning_health_alarm' | 'pr_subscription_health';
|
|
35
|
+
| 'prm_hard_stop_delivered' | 'agent_conflict_detected' | 'close_archive_result' | 'knowledge_receipt_transition' | 'knowledge_maintenance' | 'residue_health' | 'context_telemetry_health' | 'skill_usage_health' | 'core_events_health' | 'shell_audit_health' | 'trajectory_health' | 'learning_health_alarm' | 'pr_subscription_health' | 'council_attempt' | 'council_round_transition' | 'council_attempt_unscoped';
|
|
36
36
|
/** Stable classification for how a reviewer-gate decision was established. */
|
|
37
37
|
export type ReviewerGateEvidenceKind = 'genuine' | 'fallback' | 'data_quality' | 'block';
|
|
38
38
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "opencode-swarm",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.163.0",
|
|
4
4
|
"description": "Architect-centric agentic swarm plugin for OpenCode - hub-and-spoke orchestration with SME consultation, code generation, and QA review",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import {
|
|
3
|
-
createCuratorLLMDelegate
|
|
4
|
-
} from "./index-2rhs7j4r.js";
|
|
5
|
-
import"./index-acnwj4pc.js";
|
|
6
|
-
import"./index-tjaawnws.js";
|
|
7
|
-
import"./index-z4n60b0a.js";
|
|
8
|
-
import"./index-8vwe2qjh.js";
|
|
9
|
-
import"./index-jw7z3gem.js";
|
|
10
|
-
import"./index-txdagbh7.js";
|
|
11
|
-
import"./index-n249fbw7.js";
|
|
12
|
-
import"./index-3146wmgv.js";
|
|
13
|
-
import"./index-sjkxrf06.js";
|
|
14
|
-
import"./index-0h63swrc.js";
|
|
15
|
-
import"./index-3gwkmq53.js";
|
|
16
|
-
import"./index-70ha9e09.js";
|
|
17
|
-
import"./index-c8s9a3zh.js";
|
|
18
|
-
import"./index-9ss2m4rs.js";
|
|
19
|
-
import"./index-bdmg6yvj.js";
|
|
20
|
-
import"./index-zsrtt42s.js";
|
|
21
|
-
import"./index-r7rn6e5f.js";
|
|
22
|
-
import"./index-3f7hqtgg.js";
|
|
23
|
-
import"./index-9wrmzsnk.js";
|
|
24
|
-
import"./index-77syzssw.js";
|
|
25
|
-
import"./index-ydbd41sv.js";
|
|
26
|
-
import"./index-rtry5xyf.js";
|
|
27
|
-
import"./index-vcv9m2q5.js";
|
|
28
|
-
import"./index-6w468bjy.js";
|
|
29
|
-
import"./index-vkaqrrsc.js";
|
|
30
|
-
import"./index-ddszzne4.js";
|
|
31
|
-
import"./index-mfewnd7j.js";
|
|
32
|
-
import"./index-pde4zn7j.js";
|
|
33
|
-
import"./index-kk9yk7an.js";
|
|
34
|
-
import"./index-556ja8an.js";
|
|
35
|
-
import"./index-4fwbbad3.js";
|
|
36
|
-
import"./index-b43rt5ph.js";
|
|
37
|
-
import"./index-q7sjgr1y.js";
|
|
38
|
-
import"./index-4wmpv2kn.js";
|
|
39
|
-
import"./index-qw893zqp.js";
|
|
40
|
-
import"./index-5wq0dd30.js";
|
|
41
|
-
import"./index-zg9d392c.js";
|
|
42
|
-
import"./index-n832052r.js";
|
|
43
|
-
import"./index-dtn0pne5.js";
|
|
44
|
-
import"./index-z6xqpmqg.js";
|
|
45
|
-
import"./index-r3mvsbtq.js";
|
|
46
|
-
import"./index-tnj464kq.js";
|
|
47
|
-
import"./index-2ze7yqm8.js";
|
|
48
|
-
import"./index-9e6fdz2h.js";
|
|
49
|
-
import"./index-4rhhvd1a.js";
|
|
50
|
-
import"./index-80pmq6q2.js";
|
|
51
|
-
import"./index-9xd073d4.js";
|
|
52
|
-
import"./index-zjygnfay.js";
|
|
53
|
-
import"./index-ae75rja9.js";
|
|
54
|
-
import"./index-7z9gyts0.js";
|
|
55
|
-
import"./index-db520vnn.js";
|
|
56
|
-
import"./index-bk5tah7q.js";
|
|
57
|
-
import"./index-nqbqkx4c.js";
|
|
58
|
-
import"./index-q87ht62k.js";
|
|
59
|
-
import"./index-ed5ykebp.js";
|
|
60
|
-
import"./index-fx3em0dr.js";
|
|
61
|
-
import"./index-7g4c7s5r.js";
|
|
62
|
-
import"./index-bpmtbmy9.js";
|
|
63
|
-
import"./index-zgwm4ryv.js";
|
|
64
|
-
import"./index-a76rekgs.js";
|
|
65
|
-
export {
|
|
66
|
-
createCuratorLLMDelegate
|
|
67
|
-
};
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import {
|
|
3
|
-
handleGuardrailExplain
|
|
4
|
-
} from "./index-1mbwgw4p.js";
|
|
5
|
-
import"./index-2rhs7j4r.js";
|
|
6
|
-
import"./index-acnwj4pc.js";
|
|
7
|
-
import"./index-tjaawnws.js";
|
|
8
|
-
import"./index-z4n60b0a.js";
|
|
9
|
-
import"./index-8vwe2qjh.js";
|
|
10
|
-
import"./index-jw7z3gem.js";
|
|
11
|
-
import"./index-txdagbh7.js";
|
|
12
|
-
import"./index-n249fbw7.js";
|
|
13
|
-
import"./index-3146wmgv.js";
|
|
14
|
-
import"./index-sjkxrf06.js";
|
|
15
|
-
import"./index-0h63swrc.js";
|
|
16
|
-
import"./index-3gwkmq53.js";
|
|
17
|
-
import"./index-70ha9e09.js";
|
|
18
|
-
import"./index-c8s9a3zh.js";
|
|
19
|
-
import"./index-9ss2m4rs.js";
|
|
20
|
-
import"./index-bdmg6yvj.js";
|
|
21
|
-
import"./index-zsrtt42s.js";
|
|
22
|
-
import"./index-r7rn6e5f.js";
|
|
23
|
-
import"./index-3f7hqtgg.js";
|
|
24
|
-
import"./index-9wrmzsnk.js";
|
|
25
|
-
import"./index-77syzssw.js";
|
|
26
|
-
import"./index-ydbd41sv.js";
|
|
27
|
-
import"./index-rtry5xyf.js";
|
|
28
|
-
import"./index-vcv9m2q5.js";
|
|
29
|
-
import"./index-6w468bjy.js";
|
|
30
|
-
import"./index-vkaqrrsc.js";
|
|
31
|
-
import"./index-ddszzne4.js";
|
|
32
|
-
import"./index-mfewnd7j.js";
|
|
33
|
-
import"./index-pde4zn7j.js";
|
|
34
|
-
import"./index-kk9yk7an.js";
|
|
35
|
-
import"./index-556ja8an.js";
|
|
36
|
-
import"./index-4fwbbad3.js";
|
|
37
|
-
import"./index-b43rt5ph.js";
|
|
38
|
-
import"./index-q7sjgr1y.js";
|
|
39
|
-
import"./index-4wmpv2kn.js";
|
|
40
|
-
import"./index-qw893zqp.js";
|
|
41
|
-
import"./index-5wq0dd30.js";
|
|
42
|
-
import"./index-zg9d392c.js";
|
|
43
|
-
import"./index-n832052r.js";
|
|
44
|
-
import"./index-dtn0pne5.js";
|
|
45
|
-
import"./index-z6xqpmqg.js";
|
|
46
|
-
import"./index-r3mvsbtq.js";
|
|
47
|
-
import"./index-tnj464kq.js";
|
|
48
|
-
import"./index-2ze7yqm8.js";
|
|
49
|
-
import"./index-9e6fdz2h.js";
|
|
50
|
-
import"./index-4rhhvd1a.js";
|
|
51
|
-
import"./index-80pmq6q2.js";
|
|
52
|
-
import"./index-9xd073d4.js";
|
|
53
|
-
import"./index-zjygnfay.js";
|
|
54
|
-
import"./index-ae75rja9.js";
|
|
55
|
-
import"./index-7z9gyts0.js";
|
|
56
|
-
import"./index-db520vnn.js";
|
|
57
|
-
import"./index-bk5tah7q.js";
|
|
58
|
-
import"./index-nqbqkx4c.js";
|
|
59
|
-
import"./index-q87ht62k.js";
|
|
60
|
-
import"./index-ed5ykebp.js";
|
|
61
|
-
import"./index-fx3em0dr.js";
|
|
62
|
-
import"./index-7g4c7s5r.js";
|
|
63
|
-
import"./index-bpmtbmy9.js";
|
|
64
|
-
import"./index-zgwm4ryv.js";
|
|
65
|
-
import"./index-a76rekgs.js";
|
|
66
|
-
export {
|
|
67
|
-
handleGuardrailExplain
|
|
68
|
-
};
|
|
@@ -1,301 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import {
|
|
3
|
-
prWorkflowSessionFileStem,
|
|
4
|
-
readPrReviewReentryBindingContext
|
|
5
|
-
} from "./index-2rhs7j4r.js";
|
|
6
|
-
import"./index-acnwj4pc.js";
|
|
7
|
-
import"./index-tjaawnws.js";
|
|
8
|
-
import"./index-z4n60b0a.js";
|
|
9
|
-
import"./index-8vwe2qjh.js";
|
|
10
|
-
import"./index-jw7z3gem.js";
|
|
11
|
-
import"./index-txdagbh7.js";
|
|
12
|
-
import"./index-n249fbw7.js";
|
|
13
|
-
import"./index-3146wmgv.js";
|
|
14
|
-
import"./index-sjkxrf06.js";
|
|
15
|
-
import"./index-0h63swrc.js";
|
|
16
|
-
import"./index-3gwkmq53.js";
|
|
17
|
-
import"./index-70ha9e09.js";
|
|
18
|
-
import"./index-c8s9a3zh.js";
|
|
19
|
-
import"./index-9ss2m4rs.js";
|
|
20
|
-
import"./index-bdmg6yvj.js";
|
|
21
|
-
import"./index-zsrtt42s.js";
|
|
22
|
-
import"./index-r7rn6e5f.js";
|
|
23
|
-
import"./index-3f7hqtgg.js";
|
|
24
|
-
import"./index-9wrmzsnk.js";
|
|
25
|
-
import"./index-77syzssw.js";
|
|
26
|
-
import"./index-ydbd41sv.js";
|
|
27
|
-
import"./index-rtry5xyf.js";
|
|
28
|
-
import"./index-vcv9m2q5.js";
|
|
29
|
-
import"./index-6w468bjy.js";
|
|
30
|
-
import {
|
|
31
|
-
PrReviewRunIdSchema
|
|
32
|
-
} from "./index-vkaqrrsc.js";
|
|
33
|
-
import"./index-ddszzne4.js";
|
|
34
|
-
import"./index-mfewnd7j.js";
|
|
35
|
-
import"./index-pde4zn7j.js";
|
|
36
|
-
import"./index-kk9yk7an.js";
|
|
37
|
-
import"./index-556ja8an.js";
|
|
38
|
-
import"./index-4fwbbad3.js";
|
|
39
|
-
import"./index-b43rt5ph.js";
|
|
40
|
-
import"./index-q7sjgr1y.js";
|
|
41
|
-
import"./index-4wmpv2kn.js";
|
|
42
|
-
import"./index-qw893zqp.js";
|
|
43
|
-
import"./index-5wq0dd30.js";
|
|
44
|
-
import"./index-zg9d392c.js";
|
|
45
|
-
import"./index-n832052r.js";
|
|
46
|
-
import {
|
|
47
|
-
validateSwarmPath
|
|
48
|
-
} from "./index-dtn0pne5.js";
|
|
49
|
-
import"./index-z6xqpmqg.js";
|
|
50
|
-
import"./index-r3mvsbtq.js";
|
|
51
|
-
import"./index-tnj464kq.js";
|
|
52
|
-
import"./index-2ze7yqm8.js";
|
|
53
|
-
import"./index-9e6fdz2h.js";
|
|
54
|
-
import"./index-4rhhvd1a.js";
|
|
55
|
-
import"./index-80pmq6q2.js";
|
|
56
|
-
import"./index-9xd073d4.js";
|
|
57
|
-
import"./index-zjygnfay.js";
|
|
58
|
-
import"./index-ae75rja9.js";
|
|
59
|
-
import"./index-7z9gyts0.js";
|
|
60
|
-
import"./index-db520vnn.js";
|
|
61
|
-
import"./index-bk5tah7q.js";
|
|
62
|
-
import"./index-nqbqkx4c.js";
|
|
63
|
-
import"./index-q87ht62k.js";
|
|
64
|
-
import"./index-ed5ykebp.js";
|
|
65
|
-
import"./index-fx3em0dr.js";
|
|
66
|
-
import {
|
|
67
|
-
require_proper_lockfile
|
|
68
|
-
} from "./index-7g4c7s5r.js";
|
|
69
|
-
import {
|
|
70
|
-
exports_external,
|
|
71
|
-
init_zod
|
|
72
|
-
} from "./index-bpmtbmy9.js";
|
|
73
|
-
import"./index-zgwm4ryv.js";
|
|
74
|
-
import {
|
|
75
|
-
__toESM
|
|
76
|
-
} from "./index-a76rekgs.js";
|
|
77
|
-
|
|
78
|
-
// src/hooks/pr-review-reentry-authorization.ts
|
|
79
|
-
init_zod();
|
|
80
|
-
var import_proper_lockfile = __toESM(require_proper_lockfile(), 1);
|
|
81
|
-
import { randomUUID } from "crypto";
|
|
82
|
-
import * as fsp from "fs/promises";
|
|
83
|
-
import * as path from "path";
|
|
84
|
-
var AUTHORIZATION_TTL_MS = 10 * 60 * 1000;
|
|
85
|
-
var MAX_ACTIVE_AUTHORIZATIONS = 8;
|
|
86
|
-
var MAX_PERSISTED_AUTHORIZATIONS = 32;
|
|
87
|
-
var REENTRY_AUTHORIZATIONS_MAX_BYTES = 64 * 1024;
|
|
88
|
-
var PrReviewReentryAuthorizationRecordSchema = exports_external.object({
|
|
89
|
-
schemaVersion: exports_external.literal(1),
|
|
90
|
-
authorizationId: exports_external.string().min(1).max(64),
|
|
91
|
-
sessionId: exports_external.string().min(1).max(256),
|
|
92
|
-
workflowInstanceId: exports_external.string().min(1).max(128).optional(),
|
|
93
|
-
runId: PrReviewRunIdSchema.optional(),
|
|
94
|
-
prHeadSha: exports_external.string().regex(/^[0-9a-f]{6,64}$/i),
|
|
95
|
-
revisionDigest: exports_external.string().min(1).max(256),
|
|
96
|
-
role: exports_external.enum(["reviewer", "test_engineer"]),
|
|
97
|
-
generation: exports_external.number().int().nonnegative(),
|
|
98
|
-
createdAt: exports_external.string().datetime(),
|
|
99
|
-
expiresAt: exports_external.string().datetime(),
|
|
100
|
-
consumedAt: exports_external.string().datetime().optional(),
|
|
101
|
-
consumedCallId: exports_external.string().min(1).max(128).optional()
|
|
102
|
-
}).strict();
|
|
103
|
-
var AuthorizationFileSchema = exports_external.object({
|
|
104
|
-
schemaVersion: exports_external.literal(1),
|
|
105
|
-
sessionId: exports_external.string().min(1).max(256),
|
|
106
|
-
authorizations: exports_external.array(PrReviewReentryAuthorizationRecordSchema).max(MAX_PERSISTED_AUTHORIZATIONS)
|
|
107
|
-
}).strict();
|
|
108
|
-
function reentryAuthorizationFilePath(directory, sessionID) {
|
|
109
|
-
const relative = path.join("pr-review", "reentry-authorizations", `${prWorkflowSessionFileStem(sessionID)}.json`);
|
|
110
|
-
return validateSwarmPath(directory, relative);
|
|
111
|
-
}
|
|
112
|
-
async function readAuthorizationFile(filePath) {
|
|
113
|
-
let raw;
|
|
114
|
-
try {
|
|
115
|
-
const stat2 = await fsp.stat(filePath);
|
|
116
|
-
if (!stat2.isFile() || stat2.size > REENTRY_AUTHORIZATIONS_MAX_BYTES) {
|
|
117
|
-
throw new Error("reentry authorization store is not a bounded regular file");
|
|
118
|
-
}
|
|
119
|
-
raw = await fsp.readFile(filePath, "utf8");
|
|
120
|
-
} catch (error) {
|
|
121
|
-
if (error.code === "ENOENT")
|
|
122
|
-
return null;
|
|
123
|
-
throw error;
|
|
124
|
-
}
|
|
125
|
-
const decoded = JSON.parse(raw);
|
|
126
|
-
const parsed = AuthorizationFileSchema.safeParse(decoded);
|
|
127
|
-
if (!parsed.success) {
|
|
128
|
-
throw new Error(`reentry authorization store is invalid: ${parsed.error.issues.map((issue) => `${issue.path.join(".")}: ${issue.message}`).join("; ")}`);
|
|
129
|
-
}
|
|
130
|
-
return parsed.data;
|
|
131
|
-
}
|
|
132
|
-
var RENAME_RETRY_DELAYS_MS = [10, 25, 50, 100, 200];
|
|
133
|
-
var RETRYABLE_RENAME_CODES = new Set(["EPERM", "EBUSY", "EACCES", "EEXIST"]);
|
|
134
|
-
async function renameWithRetryAsync(tempPath, targetPath) {
|
|
135
|
-
let lastError;
|
|
136
|
-
for (let attempt = 0;attempt <= _internals.renameRetryDelaysMs.length; attempt++) {
|
|
137
|
-
try {
|
|
138
|
-
await _internals.renameImpl(tempPath, targetPath);
|
|
139
|
-
return;
|
|
140
|
-
} catch (err) {
|
|
141
|
-
lastError = err;
|
|
142
|
-
const code = err?.code;
|
|
143
|
-
if (!code || !RETRYABLE_RENAME_CODES.has(code))
|
|
144
|
-
throw err;
|
|
145
|
-
if (attempt < _internals.renameRetryDelaysMs.length) {
|
|
146
|
-
await new Promise((resolve) => setTimeout(resolve, _internals.renameRetryDelaysMs[attempt]));
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
throw lastError;
|
|
151
|
-
}
|
|
152
|
-
async function writeAuthorizationFile(filePath, file) {
|
|
153
|
-
const serialized = `${JSON.stringify(file, null, 2)}
|
|
154
|
-
`;
|
|
155
|
-
if (Buffer.byteLength(serialized, "utf8") > REENTRY_AUTHORIZATIONS_MAX_BYTES) {
|
|
156
|
-
throw new Error("reentry authorization store exceeds its write bound");
|
|
157
|
-
}
|
|
158
|
-
await fsp.mkdir(path.dirname(filePath), { recursive: true });
|
|
159
|
-
const tempPath = path.join(path.dirname(filePath), `.${path.basename(filePath)}.${randomUUID()}.tmp`);
|
|
160
|
-
try {
|
|
161
|
-
await fsp.writeFile(tempPath, serialized, { encoding: "utf8", flag: "wx" });
|
|
162
|
-
await renameWithRetryAsync(tempPath, filePath);
|
|
163
|
-
} finally {
|
|
164
|
-
await fsp.rm(tempPath, { force: true }).catch(() => {
|
|
165
|
-
return;
|
|
166
|
-
});
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
function pruneAuthorizations(records, nowMs) {
|
|
170
|
-
const kept = [];
|
|
171
|
-
for (const record of [...records].sort((left, right) => right.createdAt.localeCompare(left.createdAt)).slice(0, MAX_PERSISTED_AUTHORIZATIONS)) {
|
|
172
|
-
if (record.consumedAt)
|
|
173
|
-
continue;
|
|
174
|
-
if (Date.parse(record.expiresAt) <= nowMs)
|
|
175
|
-
continue;
|
|
176
|
-
kept.push(record);
|
|
177
|
-
}
|
|
178
|
-
return kept;
|
|
179
|
-
}
|
|
180
|
-
var lf = import_proper_lockfile.default;
|
|
181
|
-
async function withAuthorizationLock(filePath, write) {
|
|
182
|
-
await fsp.mkdir(path.dirname(filePath), { recursive: true });
|
|
183
|
-
const release = await lf.lock(path.dirname(filePath), {
|
|
184
|
-
lockfilePath: `${filePath}.lock`,
|
|
185
|
-
retries: { retries: 8, minTimeout: 10, maxTimeout: 100 },
|
|
186
|
-
stale: 1e4,
|
|
187
|
-
update: 1000,
|
|
188
|
-
realpath: false
|
|
189
|
-
});
|
|
190
|
-
try {
|
|
191
|
-
return await write();
|
|
192
|
-
} finally {
|
|
193
|
-
await release().catch(() => {
|
|
194
|
-
return;
|
|
195
|
-
});
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
async function issuePrReviewReentryAuthorization(directory, sessionID, request) {
|
|
199
|
-
const trimmedSession = sessionID.trim();
|
|
200
|
-
if (!trimmedSession) {
|
|
201
|
-
throw new Error("BLOCKED: re-entry authorization requires an active sessionID");
|
|
202
|
-
}
|
|
203
|
-
const binding = await readPrReviewReentryBindingContext(directory, trimmedSession);
|
|
204
|
-
if (!binding || binding.prHeadSha !== request.prHeadSha.toLowerCase()) {
|
|
205
|
-
throw new Error(`BLOCKED: re-entry authorization requires an active PR_REVIEW workflow bound to the declared head (active: ${binding?.prHeadSha ?? "(none)"})`);
|
|
206
|
-
}
|
|
207
|
-
if (request.runId && binding.runId && request.runId !== binding.runId) {
|
|
208
|
-
throw new Error("BLOCKED: re-entry authorization run does not match the active PR-review run");
|
|
209
|
-
}
|
|
210
|
-
const filePath = reentryAuthorizationFilePath(directory, trimmedSession);
|
|
211
|
-
return withAuthorizationLock(filePath, async () => {
|
|
212
|
-
const existing = await readAuthorizationFile(filePath);
|
|
213
|
-
const nowMs = Date.now();
|
|
214
|
-
const now = new Date(nowMs).toISOString();
|
|
215
|
-
const records = pruneAuthorizations(existing?.authorizations ?? [], nowMs);
|
|
216
|
-
const active = records.filter((record2) => !record2.consumedAt && record2.role === request.role && record2.generation === binding.generation);
|
|
217
|
-
if (active.length > 0) {
|
|
218
|
-
throw new Error(`BLOCKED: an unconsumed re-entry authorization for role "${request.role}" at generation ${binding.generation} already exists; use it (one immediate Task dispatch) before issuing another`);
|
|
219
|
-
}
|
|
220
|
-
if (records.length >= MAX_ACTIVE_AUTHORIZATIONS) {
|
|
221
|
-
throw new Error(`BLOCKED: re-entry authorization store is at its bound of ${MAX_ACTIVE_AUTHORIZATIONS} active authorizations`);
|
|
222
|
-
}
|
|
223
|
-
const record = {
|
|
224
|
-
schemaVersion: 1,
|
|
225
|
-
authorizationId: randomUUID(),
|
|
226
|
-
sessionId: trimmedSession,
|
|
227
|
-
...binding.workflowInstanceId ? { workflowInstanceId: binding.workflowInstanceId } : {},
|
|
228
|
-
...binding.runId ? { runId: binding.runId } : {},
|
|
229
|
-
prHeadSha: binding.prHeadSha,
|
|
230
|
-
revisionDigest: binding.revisionDigest,
|
|
231
|
-
role: request.role,
|
|
232
|
-
generation: binding.generation,
|
|
233
|
-
createdAt: now,
|
|
234
|
-
expiresAt: new Date(nowMs + AUTHORIZATION_TTL_MS).toISOString()
|
|
235
|
-
};
|
|
236
|
-
await writeAuthorizationFile(filePath, {
|
|
237
|
-
schemaVersion: 1,
|
|
238
|
-
sessionId: trimmedSession,
|
|
239
|
-
authorizations: [record, ...records]
|
|
240
|
-
});
|
|
241
|
-
return record;
|
|
242
|
-
});
|
|
243
|
-
}
|
|
244
|
-
async function consumePrReviewReentryAuthorization(directory, sessionID, request) {
|
|
245
|
-
const trimmedSession = sessionID.trim();
|
|
246
|
-
if (!trimmedSession)
|
|
247
|
-
return null;
|
|
248
|
-
const filePath = reentryAuthorizationFilePath(directory, trimmedSession);
|
|
249
|
-
try {
|
|
250
|
-
return await withAuthorizationLock(filePath, async () => {
|
|
251
|
-
const existing = await readAuthorizationFile(filePath);
|
|
252
|
-
if (!existing)
|
|
253
|
-
return null;
|
|
254
|
-
const nowMs = Date.now();
|
|
255
|
-
const records = pruneAuthorizations(existing.authorizations, nowMs);
|
|
256
|
-
const index = records.findIndex((record) => !record.consumedAt && record.role === request.role && record.sessionId === trimmedSession && Date.parse(record.expiresAt) > nowMs);
|
|
257
|
-
if (index < 0) {
|
|
258
|
-
if (records.length !== existing.authorizations.length) {
|
|
259
|
-
await writeAuthorizationFile(filePath, {
|
|
260
|
-
...existing,
|
|
261
|
-
authorizations: records
|
|
262
|
-
});
|
|
263
|
-
}
|
|
264
|
-
return null;
|
|
265
|
-
}
|
|
266
|
-
const binding = await readPrReviewReentryBindingContext(directory, trimmedSession);
|
|
267
|
-
const candidate = records[index];
|
|
268
|
-
if (!binding || binding.prHeadSha !== candidate.prHeadSha || binding.revisionDigest !== candidate.revisionDigest || binding.generation !== candidate.generation || candidate.workflowInstanceId !== undefined && binding.workflowInstanceId !== candidate.workflowInstanceId || candidate.workflowInstanceId === undefined && binding.workflowInstanceId !== undefined) {
|
|
269
|
-
return null;
|
|
270
|
-
}
|
|
271
|
-
const consumed = {
|
|
272
|
-
...candidate,
|
|
273
|
-
consumedAt: new Date(nowMs).toISOString(),
|
|
274
|
-
consumedCallId: request.callID
|
|
275
|
-
};
|
|
276
|
-
records[index] = consumed;
|
|
277
|
-
await writeAuthorizationFile(filePath, {
|
|
278
|
-
...existing,
|
|
279
|
-
authorizations: records
|
|
280
|
-
});
|
|
281
|
-
return consumed;
|
|
282
|
-
});
|
|
283
|
-
} catch {
|
|
284
|
-
return null;
|
|
285
|
-
}
|
|
286
|
-
}
|
|
287
|
-
var _internals = {
|
|
288
|
-
AUTHORIZATION_TTL_MS,
|
|
289
|
-
MAX_ACTIVE_AUTHORIZATIONS,
|
|
290
|
-
reentryAuthorizationFilePath,
|
|
291
|
-
pruneAuthorizations,
|
|
292
|
-
renameImpl: (from, to) => fsp.rename(from, to),
|
|
293
|
-
renameRetryDelaysMs: RENAME_RETRY_DELAYS_MS,
|
|
294
|
-
renameWithRetryAsync,
|
|
295
|
-
writeAuthorizationFile
|
|
296
|
-
};
|
|
297
|
-
export {
|
|
298
|
-
issuePrReviewReentryAuthorization,
|
|
299
|
-
consumePrReviewReentryAuthorization,
|
|
300
|
-
_internals
|
|
301
|
-
};
|