opencode-swarm 7.161.1 → 7.162.1
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-2jteb5vy.js → coder-settlement-zrda71k0.js} +9 -9
- package/dist/cli/{config-doctor-1yn317qf.js → config-doctor-gjw4hdvt.js} +2 -2
- package/dist/cli/{core-k687jrr3.js → core-q5j5a7fh.js} +1 -1
- package/dist/cli/{curation-policy-ej9xc0cd.js → curation-policy-nv31cr6t.js} +5 -5
- package/dist/cli/{curator-llm-factory-m1ke17eq.js → curator-llm-factory-8d6kqsj1.js} +33 -31
- package/dist/cli/{curator-q017rjfk.js → curator-njskp28b.js} +33 -31
- package/dist/cli/{evidence-summary-service-6jzfa547.js → evidence-summary-service-5rry81jm.js} +13 -13
- package/dist/cli/{gate-evidence-j6nskaka.js → gate-evidence-b6k9wng8.js} +5 -5
- package/dist/cli/{guardrail-explain-xw3ma90f.js → guardrail-explain-5yw549sm.js} +34 -32
- package/dist/cli/{guardrail-log-etmzhbge.js → guardrail-log-nrnx87ac.js} +7 -7
- package/dist/cli/{guardrail-reset-z9fkxksy.js → guardrail-reset-zm5an5bw.js} +33 -31
- package/dist/cli/{hive-promoter-dmwjya83.js → hive-promoter-zzgnfhxr.js} +33 -31
- package/dist/cli/{index-32avgbyq.js → index-0myjf1y2.js} +2 -2
- package/dist/cli/{index-dq41vsf9.js → index-1eqbnwm6.js} +1 -1
- package/dist/cli/{index-dh5q6z7y.js → index-3b762978.js} +7 -4
- package/dist/cli/{index-qd9mrd7e.js → index-3fs3p6ck.js} +5 -5
- package/dist/cli/{index-cbcfpgz9.js → index-3gym3fjj.js} +6 -6
- package/dist/cli/{index-c6zyqgpq.js → index-3nsewz46.js} +1 -1
- package/dist/cli/{index-nm0cpfrv.js → index-5a8nk165.js} +4 -4
- package/dist/cli/{index-d8st72j7.js → index-63s6t3z4.js} +1 -1
- package/dist/cli/{index-7d79mj06.js → index-7322jr05.js} +9 -9
- package/dist/cli/{index-bn78ywnb.js → index-9cvfa8p8.js} +1 -1
- package/dist/cli/{index-k55td019.js → index-9m1ze4z4.js} +1 -1
- package/dist/cli/{index-hvfsz7e3.js → index-a1bh2e4f.js} +6 -6
- package/dist/cli/{index-c1geyan9.js → index-bgzdwkpe.js} +1 -1
- package/dist/cli/{index-epjvntnm.js → index-cjjcey0h.js} +1 -1
- package/dist/cli/{index-29f9te70.js → index-f18bqg18.js} +5 -3
- package/dist/cli/{index-awjx0wgk.js → index-fckfgptr.js} +1 -1
- package/dist/cli/{index-88wb0z9r.js → index-gss86tj3.js} +2 -2
- package/dist/cli/{index-za42r41w.js → index-gwbxeh8j.js} +14 -643
- package/dist/cli/{index-1j532307.js → index-hq1gdz0g.js} +2 -2
- package/dist/cli/{index-zhdfqz89.js → index-j1gq4qm8.js} +5 -5
- package/dist/cli/{index-4p6x3xxy.js → index-m24pv3f4.js} +4 -4
- package/dist/cli/{index-jm21vbyp.js → index-m516tpxe.js} +2 -2
- package/dist/cli/index-mmngnxev.js +883 -0
- package/dist/cli/{index-134d35c1.js → index-n249fbw7.js} +9 -0
- package/dist/cli/{index-s33ee2w3.js → index-nbfpnb0w.js} +1 -1
- package/dist/cli/{index-7619tk9a.js → index-rkr19fdv.js} +1 -1
- package/dist/cli/{index-9kp3cp5n.js → index-ttdjphep.js} +3 -3
- package/dist/cli/{index-f5axf6vq.js → index-v0t8z5ab.js} +1 -1
- package/dist/cli/{index-rracnf2y.js → index-vcen0ne4.js} +1 -1
- package/dist/cli/{index-y14mwbk8.js → index-w1sfjffe.js} +2 -2
- package/dist/cli/index-w7ekntej.js +643 -0
- package/dist/cli/{index-hq57ytm5.js → index-wvfgkms6.js} +1 -1
- package/dist/cli/{index-e0re84cx.js → index-xsv6zv7n.js} +35 -33
- package/dist/cli/{index-cs9w1hfs.js → index-xtjvg1wx.js} +2691 -2781
- package/dist/cli/{index-k4xey4kh.js → index-y3fgbx8g.js} +1 -1
- package/dist/cli/{index-yhadrxka.js → index-z74stz9p.js} +4 -4
- package/dist/cli/index.js +33 -31
- package/dist/cli/{knowledge-escalator-cqyxfjfh.js → knowledge-escalator-8y3adkn0.js} +11 -11
- package/dist/cli/{knowledge-events-g707awjf.js → knowledge-events-mnexhwe2.js} +9 -9
- package/dist/cli/{knowledge-link-8knefv8x.js → knowledge-link-jr8rqr39.js} +4 -4
- package/dist/cli/{knowledge-store-byhv66xq.js → knowledge-store-cp42ccd1.js} +5 -5
- package/dist/cli/{knowledge-validator-qfkr8eje.js → knowledge-validator-hwp1t6x3.js} +7 -7
- package/dist/cli/{pending-delegations-n3baz9m3.js → pending-delegations-jj5vaq9q.js} +5 -4
- package/dist/cli/{pr-subscriptions-3zwthnan.js → pr-subscriptions-mm6kyyv0.js} +4 -4
- package/dist/cli/{runner-fzgkd6m1.js → runner-d402vnq3.js} +5 -5
- package/dist/cli/{scan-cursor-fbtgyeft.js → scan-cursor-d75dh3hv.js} +6 -6
- package/dist/cli/{schema-xb7d31wq.js → schema-djm1bhb8.js} +1 -1
- package/dist/cli/{scope-persistence-5npzdfjf.js → scope-persistence-g0yc6dfa.js} +8 -8
- package/dist/cli/{skill-generator-k1e7nee3.js → skill-generator-9ppgxz4j.js} +13 -13
- package/dist/cli/{sqlite-loader-r1kgt2pq.js → sqlite-loader-c92413n7.js} +1 -1
- package/dist/cli/{worktree-collision-ownership-jfam09nj.js → worktree-collision-ownership-061zmyyp.js} +6 -5
- package/dist/cli/{worktree-isolation-avp3yxcs.js → worktree-isolation-vk82698z.js} +33 -31
- package/dist/db/sqlite-loader.d.ts +1 -0
- package/dist/hooks/pr-workflow-gate.d.ts +20 -245
- package/dist/index.js +392 -378
- package/dist/memory/curator-decision-helpers.d.ts +1 -0
- package/dist/memory/index.d.ts +1 -1
- package/dist/memory/local-jsonl-provider.d.ts +2 -0
- package/dist/memory/proposal-load.d.ts +15 -0
- package/dist/memory/relation-constants.d.ts +3 -0
- package/dist/memory/relations.d.ts +8 -0
- package/dist/memory/schema.d.ts +8 -0
- package/dist/memory/sqlite-provider.d.ts +3 -0
- package/dist/memory/types.d.ts +21 -0
- 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/package.json +1 -1
- package/dist/cli/pr-review-reentry-authorization-ttctn8xv.js +0 -301
|
@@ -8,6 +8,7 @@ export declare function markProposalReviewed(proposal: MemoryProposal, decision:
|
|
|
8
8
|
targetMemoryId?: string;
|
|
9
9
|
oldMemoryId?: string;
|
|
10
10
|
replacementMemoryId?: string;
|
|
11
|
+
relatedMemoryIds?: string[];
|
|
11
12
|
}): MemoryProposal;
|
|
12
13
|
export declare function curatorDecisionReason(decision: ResolvedCuratorMemoryDecision): string | undefined;
|
|
13
14
|
export declare function buildCuratorDecisionEvent(change: AppliedMemoryChange, proposal: MemoryProposal): AppliedMemoryChange & {
|
package/dist/memory/index.d.ts
CHANGED
|
@@ -21,4 +21,4 @@ export { appendMemoryRunLog, sanitizeRunId } from './run-log';
|
|
|
21
21
|
export { computeMemoryContentHash, createBundleId, createMemoryId, createProposalId, isExpired, MemoryAnchorSchema, normalizeMemoryAnchorFile, normalizeMemoryText, validateCuratorMemoryDecision, validateMemoryProposal, validateMemoryRecordRules, } from './schema';
|
|
22
22
|
export { EVENT_CHAIN_GENESIS, MEMORY_EVENTS_CHAIN_HEAD_KEY, type MemoryAuditVerificationReport, type MemoryEventRow, memoryEventRowHash, SQLiteMemoryProvider, verifyMemoryEventChainRows, } from './sqlite-provider';
|
|
23
23
|
export { isCohortRoot, isLocalRoot, resolveVettedMemoryRoot, rootStoragePath, type VettedMemoryRoot, wrapLocalRoot, } from './storage-root';
|
|
24
|
-
export type { AppliedMemoryChange, CuratorMemoryDecision, MemoryAnchor, MemoryContext, MemoryKind, MemoryListFilter, MemoryOutcome, MemoryPatch, MemoryProposal, MemoryRecord, MemoryScopeRef, MemoryScopeType, NewMemoryRecord, RecallBundle, RecallInjectionSkipReason, RecallMode, RecallRequest, RecallResultItem, ResolvedCuratorMemoryDecision, } from './types';
|
|
24
|
+
export type { AppliedMemoryChange, CuratorMemoryDecision, MemoryAnchor, MemoryContext, MemoryKind, MemoryListFilter, MemoryOutcome, MemoryPatch, MemoryProposal, MemoryRecord, MemoryRelation, MemoryScopeRef, MemoryScopeType, NewMemoryRecord, RecallBundle, RecallInjectionSkipReason, RecallMode, RecallRequest, RecallResultItem, ResolvedCuratorMemoryDecision, } from './types';
|
|
@@ -16,6 +16,7 @@ export declare class LocalJsonlMemoryProvider implements MemoryProvider, MemoryP
|
|
|
16
16
|
private initialized;
|
|
17
17
|
private memories;
|
|
18
18
|
private proposals;
|
|
19
|
+
private lastInvalidProposalLoadSignature;
|
|
19
20
|
constructor(rootDirectory: string, config?: Partial<MemoryConfig>, vettedCohortRoot?: string | null);
|
|
20
21
|
/**
|
|
21
22
|
* #1850 (critic GAP-5): explicit cohort-root path branch.
|
|
@@ -56,6 +57,7 @@ export declare class LocalJsonlMemoryProvider implements MemoryProvider, MemoryP
|
|
|
56
57
|
private refreshMemoriesUnlocked;
|
|
57
58
|
private appendMemoryUnlocked;
|
|
58
59
|
private refreshProposalsUnlocked;
|
|
60
|
+
private reportInvalidProposalLoad;
|
|
59
61
|
private readOutcomeEventsSync;
|
|
60
62
|
private appendOutcomeEventUnlocked;
|
|
61
63
|
private rewriteMemoryFamilyUnlocked;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { MemoryValidationError } from './errors';
|
|
2
|
+
import type { MemoryProposal } from './types';
|
|
3
|
+
export interface ProposalLoadIssue {
|
|
4
|
+
proposalId: string;
|
|
5
|
+
reason: string;
|
|
6
|
+
}
|
|
7
|
+
export declare const INVALID_PROPOSAL_LOAD_SAMPLE_LIMIT = 5;
|
|
8
|
+
export declare function parseLoadedProposal(value: unknown, rejectDurableSecrets: boolean): MemoryProposal;
|
|
9
|
+
export declare function proposalLoadIssueFromValue(value: unknown, error: unknown): ProposalLoadIssue;
|
|
10
|
+
export declare function proposalLoadIssueFromId(proposalId: string, error: unknown): ProposalLoadIssue;
|
|
11
|
+
export declare function buildProposalLoadDiagnostics(issues: readonly ProposalLoadIssue[]): {
|
|
12
|
+
invalidCount: number;
|
|
13
|
+
samples: ProposalLoadIssue[];
|
|
14
|
+
};
|
|
15
|
+
export declare function asStoredProposalValidationError(proposalId: string, error: unknown): MemoryValidationError;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { MAX_MERGE_PARTICIPANTS, MAX_RELATIONS_PER_MEMORY, RELATED_RECALL_FANOUT, } from './relation-constants';
|
|
2
|
+
import type { MemoryProposal, MemoryRecord, MemoryRelation, RecallRequest, RecallResultItem } from './types';
|
|
3
|
+
export declare function canonicalMemoryIds(ids: readonly string[]): string[];
|
|
4
|
+
export declare function buildMemoryRelationIndex(proposals: Iterable<MemoryProposal>): Map<string, MemoryRelation[]>;
|
|
5
|
+
export declare function projectMemoryRelations(records: readonly MemoryRecord[], proposals: Iterable<MemoryProposal>): MemoryRecord[];
|
|
6
|
+
export declare function stripDerivedRelations(record: MemoryRecord): MemoryRecord;
|
|
7
|
+
export declare function validateMergeParticipants(ids: readonly string[], records: Iterable<MemoryRecord>, proposals: Iterable<MemoryProposal>, now?: Date): string[];
|
|
8
|
+
export declare function expandRelatedRecallItems(items: readonly RecallResultItem[], allRecords: readonly MemoryRecord[], request: RecallRequest): RecallResultItem[];
|
package/dist/memory/schema.d.ts
CHANGED
|
@@ -134,6 +134,10 @@ export declare const MemoryRecordSchema: z.ZodObject<{
|
|
|
134
134
|
updatedAt: z.ZodString;
|
|
135
135
|
lastAccessedAt: z.ZodOptional<z.ZodString>;
|
|
136
136
|
expiresAt: z.ZodOptional<z.ZodString>;
|
|
137
|
+
relations: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
138
|
+
memoryId: z.ZodString;
|
|
139
|
+
type: z.ZodLiteral<"merged_with">;
|
|
140
|
+
}, z.core.$strict>>>;
|
|
137
141
|
qValue: z.ZodOptional<z.ZodNumber>;
|
|
138
142
|
supersedes: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
139
143
|
supersededBy: z.ZodOptional<z.ZodString>;
|
|
@@ -228,6 +232,10 @@ export declare const MemoryProposalSchema: z.ZodObject<{
|
|
|
228
232
|
updatedAt: z.ZodString;
|
|
229
233
|
lastAccessedAt: z.ZodOptional<z.ZodString>;
|
|
230
234
|
expiresAt: z.ZodOptional<z.ZodString>;
|
|
235
|
+
relations: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
236
|
+
memoryId: z.ZodString;
|
|
237
|
+
type: z.ZodLiteral<"merged_with">;
|
|
238
|
+
}, z.core.$strict>>>;
|
|
231
239
|
qValue: z.ZodOptional<z.ZodNumber>;
|
|
232
240
|
supersedes: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
233
241
|
supersededBy: z.ZodOptional<z.ZodString>;
|
|
@@ -123,6 +123,7 @@ export declare class SQLiteMemoryProvider implements MemoryProvider, MemoryPropo
|
|
|
123
123
|
items: RecallResultItem[];
|
|
124
124
|
diagnostics: RecallScoringDiagnostics;
|
|
125
125
|
}>;
|
|
126
|
+
private expandRelated;
|
|
126
127
|
recordRecallUsage(event: MemoryRecallUsageEvent): Promise<void>;
|
|
127
128
|
listRecallUsage(filter?: MemoryRecallUsageFilter): Promise<MemoryRecallUsageEvent[]>;
|
|
128
129
|
appendRewardEvent(event: Omit<MemoryRewardEvent, 'id'>): Promise<void>;
|
|
@@ -231,6 +232,8 @@ export declare class SQLiteMemoryProvider implements MemoryProvider, MemoryPropo
|
|
|
231
232
|
private parseMemoryRow;
|
|
232
233
|
private loadMemories;
|
|
233
234
|
private loadProposals;
|
|
235
|
+
private refreshProposalsFromStorage;
|
|
236
|
+
private projectRelationsFromStorage;
|
|
234
237
|
private writeMemory;
|
|
235
238
|
/** Raw row (WITH provenance columns) for a single memory item. */
|
|
236
239
|
private readMemoryItemRowById;
|
package/dist/memory/types.d.ts
CHANGED
|
@@ -34,6 +34,10 @@ export interface MemoryOutcome {
|
|
|
34
34
|
taskId?: string;
|
|
35
35
|
correction?: string;
|
|
36
36
|
}
|
|
37
|
+
export interface MemoryRelation {
|
|
38
|
+
memoryId: string;
|
|
39
|
+
type: 'merged_with';
|
|
40
|
+
}
|
|
37
41
|
export interface MemoryRecord {
|
|
38
42
|
id: string;
|
|
39
43
|
scope: MemoryScopeRef;
|
|
@@ -47,6 +51,8 @@ export interface MemoryRecord {
|
|
|
47
51
|
updatedAt: string;
|
|
48
52
|
lastAccessedAt?: string;
|
|
49
53
|
expiresAt?: string;
|
|
54
|
+
/** Provider-derived from applied curator proposals; never user-writable. */
|
|
55
|
+
relations?: MemoryRelation[];
|
|
50
56
|
supersedes?: string[];
|
|
51
57
|
supersededBy?: string;
|
|
52
58
|
contentHash: string;
|
|
@@ -130,6 +136,11 @@ export type CuratorMemoryDecision = {
|
|
|
130
136
|
oldMemoryId: string;
|
|
131
137
|
replacement: NewMemoryRecord;
|
|
132
138
|
reason: string;
|
|
139
|
+
} | {
|
|
140
|
+
action: 'merge';
|
|
141
|
+
proposalId: string;
|
|
142
|
+
relatedMemoryIds: string[];
|
|
143
|
+
reason: string;
|
|
133
144
|
} | {
|
|
134
145
|
action: 'reject';
|
|
135
146
|
proposalId: string;
|
|
@@ -155,6 +166,11 @@ export type ResolvedCuratorMemoryDecision = {
|
|
|
155
166
|
oldMemoryId: string;
|
|
156
167
|
replacement: MemoryRecord;
|
|
157
168
|
reason: string;
|
|
169
|
+
} | {
|
|
170
|
+
action: 'merge';
|
|
171
|
+
proposalId: string;
|
|
172
|
+
relatedMemoryIds: string[];
|
|
173
|
+
reason: string;
|
|
158
174
|
} | {
|
|
159
175
|
action: 'reject';
|
|
160
176
|
proposalId: string;
|
|
@@ -174,6 +190,7 @@ export interface AppliedMemoryChange {
|
|
|
174
190
|
targetMemoryId?: string;
|
|
175
191
|
oldMemoryId?: string;
|
|
176
192
|
replacementMemoryId?: string;
|
|
193
|
+
relatedMemoryIds?: string[];
|
|
177
194
|
reason?: string;
|
|
178
195
|
}
|
|
179
196
|
export type RecallMode = 'manual' | 'injection' | 'curator' | 'evaluation';
|
|
@@ -202,6 +219,10 @@ export interface RecallResultItem {
|
|
|
202
219
|
record: MemoryRecord;
|
|
203
220
|
score: number;
|
|
204
221
|
reason: string;
|
|
222
|
+
relation?: {
|
|
223
|
+
type: MemoryRelation['type'];
|
|
224
|
+
sourceMemoryId: string;
|
|
225
|
+
};
|
|
205
226
|
signals: {
|
|
206
227
|
textOverlap: number;
|
|
207
228
|
tagOverlap: number;
|
|
@@ -1,21 +1,29 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
1
|
/**
|
|
3
|
-
*
|
|
2
|
+
* PR-review authorization boundary (issues #2383, #2385).
|
|
3
|
+
*
|
|
4
|
+
* Correlated one-use reviewer re-entry authorization, moved behind the
|
|
5
|
+
* `src/pr-review/` boundary (issue #2385). This module replaces prompt-text
|
|
6
|
+
* inspection (`MODE: PR_REVIEW`) as the ONLY way a direct Task dispatch of
|
|
7
|
+
* `reviewer`/`test_engineer` may bypass the generic Stage-A task-workflow
|
|
8
|
+
* requirement. The PR workflow controller issues an authorization bound to
|
|
9
|
+
* the exact active session, workflow, run, base/head SHA, worktree revision
|
|
10
|
+
* digest, role, and gate generation; the Task delegation gate consumes it
|
|
11
|
+
* atomically, exactly once. Stale, cross-session, wrong-role, replayed,
|
|
12
|
+
* expired, or revision-drifted requests fail closed to the normal gating
|
|
13
|
+
* path.
|
|
4
14
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* delegation gate consumes it atomically, exactly once. Stale, cross-session,
|
|
11
|
-
* wrong-role, replayed, expired, or revision-drifted requests fail closed to
|
|
12
|
-
* the normal gating path.
|
|
15
|
+
* Binding verification: the CURRENT gate binding (head/revision/generation)
|
|
16
|
+
* is supplied by the owning gate through a bound reader
|
|
17
|
+
* (`bindPrReviewReentryBindingReader`) — the boundary must not import the
|
|
18
|
+
* orchestration gate back. The gate binds its
|
|
19
|
+
* `readPrReviewReentryBindingContext` at module init.
|
|
13
20
|
*
|
|
14
21
|
* Persistence: `.swarm/pr-review/reentry-authorizations/<session-stem>.json`,
|
|
15
22
|
* guarded by a `proper-lockfile` lock (the same dependency the candidate
|
|
16
23
|
* sidecar store uses). Bounded: at most MAX_ACTIVE_AUTHORIZATIONS unconsumed
|
|
17
24
|
* authorizations per session; expired/unconsumed records are pruned on write.
|
|
18
25
|
*/
|
|
26
|
+
import { z } from 'zod';
|
|
19
27
|
export type PrReviewReentryRole = 'reviewer' | 'test_engineer';
|
|
20
28
|
export interface PrReviewReentryAuthorizationRecord {
|
|
21
29
|
schemaVersion: 1;
|
|
@@ -32,6 +40,20 @@ export interface PrReviewReentryAuthorizationRecord {
|
|
|
32
40
|
consumedAt?: string;
|
|
33
41
|
consumedCallId?: string;
|
|
34
42
|
}
|
|
43
|
+
/**
|
|
44
|
+
* The CURRENT active-workflow binding an authorization must match at issue
|
|
45
|
+
* AND at consume time. Supplied by the owning gate (which reads state through
|
|
46
|
+
* the persistence boundary) via `bindPrReviewReentryBindingReader`.
|
|
47
|
+
*/
|
|
48
|
+
export interface PrReviewReentryBindingContext {
|
|
49
|
+
prHeadSha: string;
|
|
50
|
+
revisionDigest: string;
|
|
51
|
+
generation: number;
|
|
52
|
+
workflowInstanceId?: string;
|
|
53
|
+
runId?: string;
|
|
54
|
+
}
|
|
55
|
+
export type PrReviewReentryBindingReader = (directory: string, sessionID: string) => Promise<PrReviewReentryBindingContext | null>;
|
|
56
|
+
export declare function bindPrReviewReentryBindingReader(reader: PrReviewReentryBindingReader): void;
|
|
35
57
|
declare const AuthorizationFileSchema: z.ZodObject<{
|
|
36
58
|
schemaVersion: z.ZodLiteral<1>;
|
|
37
59
|
sessionId: z.ZodString;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* PR-review resilience circuit — typed, recoverable, versioned (
|
|
2
|
+
* PR-review resilience circuit — typed, recoverable, versioned (issues
|
|
3
|
+
* #2382, #2385).
|
|
3
4
|
*
|
|
4
5
|
* Pure state machine + typed-signal classification for the PR_REVIEW
|
|
5
6
|
* resilience circuit. No I/O: the owning gate (`pr-workflow-gate.ts`) reads
|
|
@@ -17,9 +18,17 @@
|
|
|
17
18
|
* waterline) or back to OPEN (new interval). Legacy unversioned records
|
|
18
19
|
* migrate once to a nonblocking v2 CLOSED record with an evidence waterline;
|
|
19
20
|
* malformed records fail open.
|
|
21
|
+
*
|
|
22
|
+
* Issue #2385 additionally makes this module the ONLY authority that may
|
|
23
|
+
* construct or transition circuit records: policy snapshot resolution, the
|
|
24
|
+
* re-enable reset, and the rolled-back-probe transition live here (previously
|
|
25
|
+
* inline record constructions in the gate). The parallel-rule guardrail
|
|
26
|
+
* (`src/pr-review/guardrails.ts`) enforces that no circuit record is built
|
|
27
|
+
* outside `src/pr-review/`.
|
|
20
28
|
*/
|
|
21
29
|
import { z } from 'zod';
|
|
22
30
|
import type { BackgroundDelegationRecord } from '../background/pending-delegations.js';
|
|
31
|
+
import { type PrReviewResilienceConfig } from '../config/schema.js';
|
|
23
32
|
/** Bounded contributor ledger. Mirrors `MAX_WORKFLOW_BATCHES (128) × 6` base dimensions. */
|
|
24
33
|
export declare const PR_REVIEW_CIRCUIT_CONTRIBUTOR_LIMIT = 768;
|
|
25
34
|
export type PrReviewCircuitIgnoredReason = 'observer_deadline' | 'client_unavailable' | 'parser' | 'validation' | 'policy' | 'filesystem' | 'git' | 'cancellation' | 'stale_observation' | 'unknown';
|
|
@@ -67,6 +76,20 @@ export interface PrReviewCircuitLegacyRecord {
|
|
|
67
76
|
}>;
|
|
68
77
|
openedAt: string;
|
|
69
78
|
}
|
|
79
|
+
/**
|
|
80
|
+
* The persisted circuit union: a v2 record or a legacy unversioned record
|
|
81
|
+
* awaiting migration.
|
|
82
|
+
*/
|
|
83
|
+
export type PrReviewCircuitRecord = PrReviewCircuitLegacyRecord | PrReviewCircuitRecordV2;
|
|
84
|
+
export interface PrReviewResiliencePolicyRecord {
|
|
85
|
+
enabled: boolean;
|
|
86
|
+
canaryProbeMs: number;
|
|
87
|
+
statusProbeTimeoutMs: number;
|
|
88
|
+
correlatedFailureThreshold: number;
|
|
89
|
+
maxRetryAttemptsAfterInitial: number;
|
|
90
|
+
/** Issue #2382. Optional: policies persisted before the field existed parse unchanged. */
|
|
91
|
+
circuitOpenDurationMs?: number;
|
|
92
|
+
}
|
|
70
93
|
export declare const PrReviewCircuitLegacyRecordSchema: z.ZodObject<{
|
|
71
94
|
signature: z.ZodString;
|
|
72
95
|
count: z.ZodNumber;
|
|
@@ -130,6 +153,12 @@ export declare const PrReviewCircuitRecordSchema: z.ZodUnion<readonly [z.ZodObje
|
|
|
130
153
|
admittedAt: z.ZodString;
|
|
131
154
|
}, z.core.$strict>>;
|
|
132
155
|
}, z.core.$strict>]>;
|
|
156
|
+
/**
|
|
157
|
+
* The terminal delegation statuses the circuit consults. The single shared
|
|
158
|
+
* definition (issue #2385): the gate's settlement paths and this module read
|
|
159
|
+
* the same vocabulary.
|
|
160
|
+
*/
|
|
161
|
+
export declare const CIRCUIT_TERMINAL_DELEGATION_STATUSES: ReadonlySet<string>;
|
|
133
162
|
/**
|
|
134
163
|
* Derive the typed circuit signal from a durable delegation record's LATEST
|
|
135
164
|
* terminal state. Returns `null` for anything that is not a terminal failure
|
|
@@ -190,7 +219,7 @@ export interface PrReviewCircuitAdvanceInput {
|
|
|
190
219
|
admission?: {
|
|
191
220
|
batchId: string;
|
|
192
221
|
laneId: string;
|
|
193
|
-
};
|
|
222
|
+
} | undefined;
|
|
194
223
|
/** Latest-record signals for every dispatch lane of the current workflow. */
|
|
195
224
|
laneSignals: readonly PrReviewCircuitSignal[];
|
|
196
225
|
/**
|
|
@@ -202,7 +231,7 @@ export interface PrReviewCircuitAdvanceInput {
|
|
|
202
231
|
terminalStatus: string;
|
|
203
232
|
signal: PrReviewCircuitSignal | null;
|
|
204
233
|
terminalAtMs: number;
|
|
205
|
-
};
|
|
234
|
+
} | undefined;
|
|
206
235
|
}
|
|
207
236
|
export type PrReviewCircuitAdvanceResult = {
|
|
208
237
|
action: 'admit';
|
|
@@ -230,3 +259,31 @@ export type PrReviewCircuitAdvanceResult = {
|
|
|
230
259
|
* gate passes an explicit waterlined record for migration / re-enable births).
|
|
231
260
|
*/
|
|
232
261
|
export declare function advancePrReviewCircuit(current: PrReviewCircuitRecordV2 | null, input: PrReviewCircuitAdvanceInput): PrReviewCircuitAdvanceResult;
|
|
262
|
+
/**
|
|
263
|
+
* Resolve the effective resilience policy record from optional config. Every
|
|
264
|
+
* default comes from `DEFAULT_PR_REVIEW_RESILIENCE_CONFIG` (single source);
|
|
265
|
+
* a hardcoded literal here would drift from the config schema (issue #2385
|
|
266
|
+
* recurrence class G-2).
|
|
267
|
+
*/
|
|
268
|
+
export declare function resolvePrReviewResiliencePolicy(policy?: PrReviewResilienceConfig): PrReviewResiliencePolicyRecord;
|
|
269
|
+
/**
|
|
270
|
+
* Issue #2382 re-enable semantics (issue #2385: moved behind the machine).
|
|
271
|
+
* Re-enabling resilience after a live disable starts from a fresh v2 CLOSED
|
|
272
|
+
* generation with an evidence waterline at `nowMs` — pre-disable evidence can
|
|
273
|
+
* never resurrect. Generation strictly increases.
|
|
274
|
+
*/
|
|
275
|
+
export declare function resetPrReviewResilienceForReEnable(args: {
|
|
276
|
+
previousCircuit?: PrReviewCircuitRecord | null;
|
|
277
|
+
policy: PrReviewResiliencePolicyRecord;
|
|
278
|
+
nowMs: number;
|
|
279
|
+
}): PrReviewCircuitRecordV2;
|
|
280
|
+
/**
|
|
281
|
+
* Issue #2382 review (PRR-002) rolled-back-probe transition (issue #2385:
|
|
282
|
+
* moved behind the machine). A rolled-back HALF_OPEN probe can never produce
|
|
283
|
+
* a terminal record — the rollback's own precondition is that the batch has
|
|
284
|
+
* zero delegation records — so leaving the probe in place would wedge the
|
|
285
|
+
* circuit on probe_in_flight forever. End the probe lifecycle exactly the way
|
|
286
|
+
* an ignored outcome does: state stays OPEN with a restarted recovery
|
|
287
|
+
* cooldown, and no contributor, generation, or waterline changes.
|
|
288
|
+
*/
|
|
289
|
+
export declare function rollbackPrReviewCircuitProbe(circuit: PrReviewCircuitRecordV2, nowMs: number, openDurationMs: number): PrReviewCircuitRecordV2;
|