opencode-swarm 7.164.0 → 7.164.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.
- package/.opencode/skills/codebase-review-swarm/SKILL.md +4 -0
- package/.opencode/skills/commit-pr/SKILL.md +4 -1
- package/.opencode/skills/critic-gate/SKILL.md +4 -0
- package/.opencode/skills/deep-dive/SKILL.md +4 -0
- package/.opencode/skills/engineering-conventions/SKILL.md +2 -0
- package/.opencode/skills/execute/SKILL.md +4 -0
- package/.opencode/skills/phase-wrap/SKILL.md +4 -0
- package/.opencode/skills/plan/SKILL.md +4 -0
- package/.opencode/skills/running-tests/SKILL.md +4 -0
- package/.opencode/skills/swarm-pr-review/SKILL.md +4 -0
- package/.opencode/skills/swarm-pr-review/references/prompt-templates.md +2 -0
- package/.opencode/skills/writing-tests/SKILL.md +4 -0
- package/dist/agents/critic.d.ts +6 -6
- package/dist/cli/{coder-settlement-84je6bza.js → coder-settlement-kv1x94w6.js} +12 -13
- package/dist/cli/{config-doctor-vfze38e1.js → config-doctor-8d7ydxck.js} +3 -3
- package/dist/cli/{core-q5hv8e2w.js → core-7jjgxczp.js} +2 -2
- package/dist/cli/{curation-policy-a2zty4br.js → curation-policy-7pnmnfct.js} +6 -7
- package/dist/cli/{curator-4pckmmyf.js → curator-5nyth2rj.js} +35 -38
- package/dist/cli/{curator-drift-wy7ejcvw.js → curator-drift-ykrdf08r.js} +4 -5
- package/dist/cli/curator-llm-factory-d415s169.js +66 -0
- package/dist/cli/{evidence-summary-service-b15yes21.js → evidence-summary-service-aebn7nb9.js} +16 -17
- package/dist/cli/{gate-evidence-70h0w4tb.js → gate-evidence-es59pysy.js} +8 -9
- package/dist/cli/guardrail-explain-mn2x7w2y.js +67 -0
- package/dist/cli/{guardrail-log-7rxbd20p.js → guardrail-log-fd3c5rks.js} +8 -9
- package/dist/cli/{guardrail-reset-3b4gs357.js → guardrail-reset-r49rvptv.js} +35 -38
- package/dist/cli/{hive-promoter-s80g1gwb.js → hive-promoter-qp2kjhhp.js} +35 -38
- package/dist/cli/{index-93sepnc9.js → index-0145kpjr.js} +2 -2
- package/dist/cli/{index-v3a9rmyh.js → index-1r6p1wpa.js} +4 -4
- package/dist/cli/{index-c4pynht5.js → index-2xj34nkh.js} +1 -1
- package/dist/cli/{index-g64154pd.js → index-34exj2e3.js} +2 -2
- package/dist/cli/{index-td6n935w.js → index-3704v4e6.js} +2 -2
- package/dist/cli/{index-ynqp3jb6.js → index-5d7bzpfn.js} +1 -1
- package/dist/cli/{index-hyq20s2v.js → index-6vtm4rd0.js} +12 -12
- package/dist/cli/{index-4afh2cz7.js → index-92q98ry8.js} +7 -7
- package/dist/cli/{index-wdtckfnf.js → index-ac39znep.js} +2 -2
- package/dist/cli/{index-4jersar8.js → index-axtnc0xf.js} +5 -5
- package/dist/cli/{index-e3hwzcjv.js → index-b85jnfp4.js} +2 -2
- package/dist/cli/{index-bm73pych.js → index-br7q79t2.js} +7 -7
- package/dist/cli/{index-1b1h770t.js → index-bzd67m2j.js} +3 -3
- package/dist/cli/{index-ma8w6pfp.js → index-c8k4cs94.js} +5 -5
- package/dist/cli/{index-t90gjc0k.js → index-cm4r8gh2.js} +1 -1
- package/dist/cli/{index-3b762978.js → index-f9nfknjg.js} +182 -37
- package/dist/cli/{index-t9rhtvy9.js → index-fyt5byhd.js} +3 -3
- package/dist/cli/{index-zbpcpsk0.js → index-gz5rn6w6.js} +9 -9
- package/dist/cli/{index-7r9vpkwa.js → index-h9wnkr2e.js} +5 -5
- package/dist/cli/{index-1hpjwz3s.js → index-hcn69kp0.js} +1 -1
- package/dist/cli/{index-12f1tsn2.js → index-hnwg5gt6.js} +655 -16
- package/dist/cli/{index-qkk2skff.js → index-jw9wbwdh.js} +37 -40
- package/dist/cli/{index-pvgcex0d.js → index-kwd09y5a.js} +4 -4
- package/dist/cli/{index-9xd073d4.js → index-m1nrd3yd.js} +9 -2
- package/dist/cli/{index-c69jbpex.js → index-pcnhh2vt.js} +2 -2
- package/dist/cli/{index-gxd8fwyt.js → index-q3xn3m3g.js} +4 -4
- package/dist/cli/{index-fckfgptr.js → index-qbr05tbw.js} +2 -2
- package/dist/cli/{index-9sy65e94.js → index-qmeewt3g.js} +32 -34
- package/dist/cli/{index-tb1k8jya.js → index-sb4eanpv.js} +1 -1
- package/dist/cli/{index-dtn0pne5.js → index-v56mhyhs.js} +1 -1
- package/dist/cli/{index-2s4s9n82.js → index-w5jpjaqe.js} +2 -2
- package/dist/cli/{index-1z4jzwja.js → index-w8qt2612.js} +3 -3
- package/dist/cli/{index-nhxaa9j5.js → index-xm6c1tnf.js} +1 -1
- package/dist/cli/{index-0515j0cz.js → index-y2f5s2cf.js} +1 -1
- package/dist/cli/{index-36nt17m8.js → index-yep24wn4.js} +1 -1
- package/dist/cli/{index-xk0kc1py.js → index-yjftcanv.js} +7767 -2575
- package/dist/cli/{index-t5t82jy8.js → index-yqhwrjw9.js} +5 -5
- package/dist/cli/{index-nzrhw31r.js → index-zgeqwbhw.js} +2 -2
- package/dist/cli/{index-70bfj3v1.js → index-zs1jrsta.js} +2 -2
- package/dist/cli/index.js +35 -38
- package/dist/cli/{knowledge-escalator-sttdnwf8.js → knowledge-escalator-439jajb3.js} +14 -15
- package/dist/cli/{knowledge-events-4h88stj7.js → knowledge-events-wz3h98kk.js} +12 -13
- package/dist/cli/{knowledge-link-yykmxdyw.js → knowledge-link-2gh1cnk3.js} +5 -6
- package/dist/cli/{knowledge-store-j832fxpx.js → knowledge-store-y1cwe80n.js} +6 -7
- package/dist/cli/{knowledge-validator-edbg761g.js → knowledge-validator-bk2qfqe2.js} +8 -9
- package/dist/cli/{model-preflight-c3mc8njg.js → model-preflight-pmnbfzjv.js} +1 -1
- package/dist/cli/{pending-delegations-sphntrs0.js → pending-delegations-kh4mkvzb.js} +6 -8
- package/dist/cli/{pr-subscriptions-1a4gcnzv.js → pr-subscriptions-sdv0n59c.js} +6 -7
- package/dist/cli/pr-workflow-gate-a9vj11e5.js +221 -0
- package/dist/cli/{runner-d294h1by.js → runner-m95v9d47.js} +6 -7
- package/dist/cli/{scan-cursor-5frvp7nb.js → scan-cursor-pjek24k7.js} +7 -8
- package/dist/cli/{schema-9xkt5hvd.js → schema-674qw3aj.js} +2 -2
- package/dist/cli/{scope-persistence-gk55h3sp.js → scope-persistence-sq331eqh.js} +10 -11
- package/dist/cli/{skill-generator-sxxf7jbb.js → skill-generator-pcw7c50r.js} +16 -17
- package/dist/cli/{telemetry-q51s6tyt.js → telemetry-c4j18da8.js} +1 -1
- package/dist/cli/{worktree-collision-ownership-7kj2ryt1.js → worktree-collision-ownership-vnj31rgc.js} +7 -9
- package/dist/cli/{worktree-isolation-67fs6rz9.js → worktree-isolation-tje6p4zt.js} +35 -38
- package/dist/hooks/delegate-ack-collector.d.ts +5 -0
- package/dist/hooks/delegation-gate.d.ts +14 -2
- package/dist/hooks/plan-task-id-context.d.ts +24 -0
- package/dist/hooks/pr-workflow-gate.d.ts +14 -8
- package/dist/hooks/pr-workflow-response-gate.d.ts +9 -12
- package/dist/hooks/skill-injection.d.ts +7 -3
- package/dist/hooks/skill-propagation-gate.d.ts +1 -1
- package/dist/hooks/task-id-resolver.d.ts +46 -0
- package/dist/index.js +118 -92
- package/dist/pr-review/authorization.d.ts +18 -12
- package/dist/tools/authorize-pr-review-reentry.d.ts +12 -8
- package/dist/tools/tool-metadata.d.ts +1 -1
- package/opencode-swarm.schema.json +4 -1
- package/package.json +1 -1
- package/dist/cli/authorization-vstrh7ra.js +0 -23
- package/dist/cli/curator-llm-factory-msbj3hpn.js +0 -69
- package/dist/cli/guardrail-explain-kksdy032.js +0 -70
- package/dist/cli/index-ed5ykebp.js +0 -151
- package/dist/cli/index-mmngnxev.js +0 -883
- package/dist/cli/index-w7ekntej.js +0 -643
|
@@ -2,22 +2,19 @@
|
|
|
2
2
|
import {
|
|
3
3
|
canonicalRootKeyFresh
|
|
4
4
|
} from "./index-ddszzne4.js";
|
|
5
|
-
import {
|
|
6
|
-
PrReviewResultReceiptSchema
|
|
7
|
-
} from "./index-w7ekntej.js";
|
|
8
5
|
import {
|
|
9
6
|
validateSwarmPath
|
|
10
|
-
} from "./index-
|
|
7
|
+
} from "./index-v56mhyhs.js";
|
|
11
8
|
import {
|
|
12
9
|
bunWrite
|
|
13
10
|
} from "./index-r3mvsbtq.js";
|
|
14
11
|
import {
|
|
15
12
|
observeDelegationLedgerPressure
|
|
16
|
-
} from "./index-
|
|
13
|
+
} from "./index-ac39znep.js";
|
|
17
14
|
import {
|
|
18
15
|
EvidenceLockTimeoutError,
|
|
19
16
|
withEvidenceLock
|
|
20
|
-
} from "./index-
|
|
17
|
+
} from "./index-yep24wn4.js";
|
|
21
18
|
import {
|
|
22
19
|
exports_external,
|
|
23
20
|
init_zod
|
|
@@ -33,7 +30,7 @@ import {
|
|
|
33
30
|
|
|
34
31
|
// src/background/pending-delegations.ts
|
|
35
32
|
init_zod();
|
|
36
|
-
import { createHash as
|
|
33
|
+
import { createHash as createHash3 } from "crypto";
|
|
37
34
|
import * as fs2 from "fs";
|
|
38
35
|
import * as path2 from "path";
|
|
39
36
|
import { isDeepStrictEqual } from "util";
|
|
@@ -396,6 +393,648 @@ function parsePrReviewCollectionReceiptFooter(binding, result) {
|
|
|
396
393
|
const payload = parsed.data;
|
|
397
394
|
return payload.parentSessionId === binding.parentSessionId && payload.batchId === (binding.batchId ?? binding.callID) && payload.laneId === (binding.laneId ?? binding.correlationId) && payload.mode === binding.mode && payload.workflowLane === binding.workflowLane && payload.outputDigest === result.digest ? payload : null;
|
|
398
395
|
}
|
|
396
|
+
|
|
397
|
+
// src/background/pr-review-contract.ts
|
|
398
|
+
init_zod();
|
|
399
|
+
import { createHash as createHash2 } from "crypto";
|
|
400
|
+
|
|
401
|
+
// src/pr-review/critic-routing.ts
|
|
402
|
+
function prReviewFindingRequiresCritic(input) {
|
|
403
|
+
if (input.classification !== "CONFIRMED")
|
|
404
|
+
return false;
|
|
405
|
+
const impact = input.risk_impact ?? "UNKNOWN";
|
|
406
|
+
const tags = input.risk_tags ?? [];
|
|
407
|
+
if (impact === "UNKNOWN")
|
|
408
|
+
return true;
|
|
409
|
+
if (input.severity === undefined)
|
|
410
|
+
return true;
|
|
411
|
+
if (input.severity === "CRITICAL" || input.severity === "HIGH")
|
|
412
|
+
return true;
|
|
413
|
+
if (input.severity === "MEDIUM") {
|
|
414
|
+
return impact === "HIGH_IMPACT" || tags.length > 0;
|
|
415
|
+
}
|
|
416
|
+
return false;
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
// src/background/pr-review-contract.ts
|
|
420
|
+
var PR_REVIEW_REVIEWER_CLASSIFICATIONS = [
|
|
421
|
+
"CONFIRMED",
|
|
422
|
+
"DISPROVED",
|
|
423
|
+
"UNVERIFIED",
|
|
424
|
+
"PRE_EXISTING"
|
|
425
|
+
];
|
|
426
|
+
var PR_REVIEW_REVIEWER_EVIDENCE_TYPES = [
|
|
427
|
+
"STRUCTURALLY_PROVEN",
|
|
428
|
+
"EXECUTION_PROVEN",
|
|
429
|
+
"STATIC_TRACE_PROVEN",
|
|
430
|
+
"PLAUSIBLE_BUT_UNVERIFIED"
|
|
431
|
+
];
|
|
432
|
+
var PR_REVIEW_SEVERITIES = [
|
|
433
|
+
"CRITICAL",
|
|
434
|
+
"HIGH",
|
|
435
|
+
"MEDIUM",
|
|
436
|
+
"LOW",
|
|
437
|
+
"INFO",
|
|
438
|
+
"NONE"
|
|
439
|
+
];
|
|
440
|
+
var PR_REVIEW_CRITIC_STATUSES = [
|
|
441
|
+
"UPHELD",
|
|
442
|
+
"DOWNGRADED",
|
|
443
|
+
"DISPROVED",
|
|
444
|
+
"NEEDS_MORE_EVIDENCE"
|
|
445
|
+
];
|
|
446
|
+
var PR_REVIEW_FINDING_STATUSES = [
|
|
447
|
+
"PENDING",
|
|
448
|
+
"CONFIRMED",
|
|
449
|
+
"DISPROVED",
|
|
450
|
+
"PRE_EXISTING"
|
|
451
|
+
];
|
|
452
|
+
var PR_REVIEW_FINDING_ACTIONS = [
|
|
453
|
+
"route_to_reviewer",
|
|
454
|
+
"route_to_critic",
|
|
455
|
+
"report",
|
|
456
|
+
"suppress_with_reason",
|
|
457
|
+
"handoff_to_feedback"
|
|
458
|
+
];
|
|
459
|
+
var PR_REVIEW_ARTIFACT_BOUNDARIES = [
|
|
460
|
+
"post_explorer",
|
|
461
|
+
"post_reviewer",
|
|
462
|
+
"post_critic"
|
|
463
|
+
];
|
|
464
|
+
var PR_REVIEW_BASE_DIMENSION_IDS = [
|
|
465
|
+
"intent-architecture",
|
|
466
|
+
"correctness-state",
|
|
467
|
+
"tests-falsifiability",
|
|
468
|
+
"security-trust",
|
|
469
|
+
"reliability-performance",
|
|
470
|
+
"compatibility-delivery"
|
|
471
|
+
];
|
|
472
|
+
var PR_REVIEW_RISK_IMPACTS = [
|
|
473
|
+
"ORDINARY",
|
|
474
|
+
"HIGH_IMPACT",
|
|
475
|
+
"UNKNOWN"
|
|
476
|
+
];
|
|
477
|
+
var PR_REVIEW_RISK_TAGS = [
|
|
478
|
+
"SECURITY",
|
|
479
|
+
"AUTH_PERMISSIONS",
|
|
480
|
+
"STATE_INTEGRITY",
|
|
481
|
+
"WRITE_PATH",
|
|
482
|
+
"EVIDENCE_INTEGRITY",
|
|
483
|
+
"GIT",
|
|
484
|
+
"CONFIGURATION"
|
|
485
|
+
];
|
|
486
|
+
var PR_REVIEW_RESULT_LANE_MODES = [
|
|
487
|
+
"swarm-pr-review:base",
|
|
488
|
+
"swarm-pr-review:micro"
|
|
489
|
+
];
|
|
490
|
+
var PR_REVIEW_RESULT_OUTCOMES = [
|
|
491
|
+
"CLEAN",
|
|
492
|
+
"FINDINGS",
|
|
493
|
+
"INCOMPLETE"
|
|
494
|
+
];
|
|
495
|
+
var PR_REVIEW_RESULT_FINDING_SEVERITIES = [
|
|
496
|
+
"CRITICAL",
|
|
497
|
+
"HIGH",
|
|
498
|
+
"MEDIUM",
|
|
499
|
+
"LOW",
|
|
500
|
+
"INFO"
|
|
501
|
+
];
|
|
502
|
+
var PR_REVIEW_RESULT_UNRESOLVED_REASONS = [
|
|
503
|
+
"NOT_EXECUTED",
|
|
504
|
+
"PARTIAL_OUTPUT",
|
|
505
|
+
"CONTRACT_FAILURE",
|
|
506
|
+
"RESOURCE_LIMIT",
|
|
507
|
+
"DEADLINE_EXCEEDED",
|
|
508
|
+
"STALE_BINDING",
|
|
509
|
+
"PARENT_CANCELLED"
|
|
510
|
+
];
|
|
511
|
+
var MAX_PR_REVIEW_RESULT_OWNED_LANES = 11;
|
|
512
|
+
var MAX_PR_REVIEW_RESULT_FINDINGS = 256;
|
|
513
|
+
var MAX_PR_REVIEW_RESULT_RECEIPT_BYTES = 64 * 1024;
|
|
514
|
+
function prReviewLegacyTranscriptCompatibilityEnabled(value) {
|
|
515
|
+
return value === true;
|
|
516
|
+
}
|
|
517
|
+
var PrReviewResultLaneIdSchema = exports_external.string().trim().min(1).max(120);
|
|
518
|
+
var PrReviewResultChildSessionSchema = exports_external.string().trim().min(1).max(256);
|
|
519
|
+
var PrReviewResultShaSchema = exports_external.string().trim().regex(/^[0-9a-f]{6,64}$/i);
|
|
520
|
+
var PrReviewResultDigestSchema = exports_external.string().trim().regex(/^[0-9a-f]{64}$/i);
|
|
521
|
+
function addDuplicateIssue(ctx, path2, label, value) {
|
|
522
|
+
ctx.addIssue({
|
|
523
|
+
code: exports_external.ZodIssueCode.custom,
|
|
524
|
+
path: path2,
|
|
525
|
+
message: `${label} must not contain duplicate value "${value}"`
|
|
526
|
+
});
|
|
527
|
+
}
|
|
528
|
+
function assertUniqueStrings(values, ctx, path2, label) {
|
|
529
|
+
const seen = new Set;
|
|
530
|
+
for (const value of values) {
|
|
531
|
+
if (seen.has(value)) {
|
|
532
|
+
addDuplicateIssue(ctx, path2, label, value);
|
|
533
|
+
return;
|
|
534
|
+
}
|
|
535
|
+
seen.add(value);
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
var PrReviewResultLocationSchema = exports_external.discriminatedUnion("kind", [
|
|
539
|
+
exports_external.object({
|
|
540
|
+
kind: exports_external.literal("local"),
|
|
541
|
+
file: exports_external.string().trim().min(1).max(4096),
|
|
542
|
+
line: exports_external.number().int().positive().max(1e6).optional(),
|
|
543
|
+
endLine: exports_external.number().int().positive().max(1e6).optional(),
|
|
544
|
+
column: exports_external.number().int().positive().max(1e4).optional(),
|
|
545
|
+
endColumn: exports_external.number().int().positive().max(1e4).optional()
|
|
546
|
+
}).strict().superRefine((value, ctx) => {
|
|
547
|
+
if (value.endLine !== undefined && value.line !== undefined && value.endLine < value.line) {
|
|
548
|
+
ctx.addIssue({
|
|
549
|
+
code: exports_external.ZodIssueCode.custom,
|
|
550
|
+
path: ["endLine"],
|
|
551
|
+
message: "endLine must be greater than or equal to line"
|
|
552
|
+
});
|
|
553
|
+
}
|
|
554
|
+
if (value.endColumn !== undefined && value.column !== undefined && value.endColumn < value.column) {
|
|
555
|
+
ctx.addIssue({
|
|
556
|
+
code: exports_external.ZodIssueCode.custom,
|
|
557
|
+
path: ["endColumn"],
|
|
558
|
+
message: "endColumn must be greater than or equal to column"
|
|
559
|
+
});
|
|
560
|
+
}
|
|
561
|
+
}),
|
|
562
|
+
exports_external.object({
|
|
563
|
+
kind: exports_external.literal("non_local"),
|
|
564
|
+
label: exports_external.string().trim().min(1).max(200),
|
|
565
|
+
detail: exports_external.string().trim().min(1).max(2000)
|
|
566
|
+
}).strict()
|
|
567
|
+
]);
|
|
568
|
+
var PrReviewResultFindingSchema = exports_external.object({
|
|
569
|
+
id: exports_external.string().trim().min(1).max(128),
|
|
570
|
+
workflowLane: PrReviewResultLaneIdSchema,
|
|
571
|
+
severity: exports_external.enum(PR_REVIEW_RESULT_FINDING_SEVERITIES),
|
|
572
|
+
riskImpact: exports_external.enum(PR_REVIEW_RISK_IMPACTS),
|
|
573
|
+
riskTags: exports_external.array(exports_external.enum(PR_REVIEW_RISK_TAGS)).max(PR_REVIEW_RISK_TAGS.length),
|
|
574
|
+
title: exports_external.string().trim().min(1).max(200),
|
|
575
|
+
body: exports_external.string().trim().min(1).max(4000),
|
|
576
|
+
evidence: exports_external.string().trim().min(1).max(4000),
|
|
577
|
+
location: PrReviewResultLocationSchema
|
|
578
|
+
}).strict().superRefine((value, ctx) => {
|
|
579
|
+
assertUniqueStrings(value.riskTags, ctx, ["riskTags"], "riskTags");
|
|
580
|
+
});
|
|
581
|
+
var PrReviewCleanAttestationSchema = exports_external.object({
|
|
582
|
+
workflowLane: PrReviewResultLaneIdSchema,
|
|
583
|
+
coverageScope: exports_external.string().trim().min(12).max(2000),
|
|
584
|
+
evidence: exports_external.string().trim().min(20).max(4000)
|
|
585
|
+
}).strict();
|
|
586
|
+
var PrReviewUnresolvedLaneSchema = exports_external.object({
|
|
587
|
+
workflowLane: PrReviewResultLaneIdSchema,
|
|
588
|
+
reason: exports_external.enum(PR_REVIEW_RESULT_UNRESOLVED_REASONS),
|
|
589
|
+
detail: exports_external.string().trim().min(1).max(4000)
|
|
590
|
+
}).strict();
|
|
591
|
+
var PrReviewLaneResultEnvelopeSchema = exports_external.object({
|
|
592
|
+
schemaVersion: exports_external.literal(1),
|
|
593
|
+
outcome: exports_external.enum(PR_REVIEW_RESULT_OUTCOMES),
|
|
594
|
+
creditedLanes: exports_external.array(PrReviewResultLaneIdSchema).max(MAX_PR_REVIEW_RESULT_OWNED_LANES),
|
|
595
|
+
findings: exports_external.array(PrReviewResultFindingSchema).max(MAX_PR_REVIEW_RESULT_FINDINGS),
|
|
596
|
+
cleanAttestations: exports_external.array(PrReviewCleanAttestationSchema).max(MAX_PR_REVIEW_RESULT_OWNED_LANES),
|
|
597
|
+
unresolved: exports_external.array(PrReviewUnresolvedLaneSchema).max(MAX_PR_REVIEW_RESULT_OWNED_LANES)
|
|
598
|
+
}).strict().superRefine((value, ctx) => {
|
|
599
|
+
assertUniqueStrings(value.creditedLanes, ctx, ["creditedLanes"], "creditedLanes");
|
|
600
|
+
const findingIds = value.findings.map((finding) => finding.id);
|
|
601
|
+
assertUniqueStrings(findingIds, ctx, ["findings"], "findings");
|
|
602
|
+
const findingLanes = value.findings.map((finding) => finding.workflowLane);
|
|
603
|
+
assertUniqueStrings(value.cleanAttestations.map((entry) => entry.workflowLane), ctx, ["cleanAttestations"], "cleanAttestations");
|
|
604
|
+
assertUniqueStrings(value.unresolved.map((entry) => entry.workflowLane), ctx, ["unresolved"], "unresolved");
|
|
605
|
+
for (const lane of findingLanes) {
|
|
606
|
+
if (value.cleanAttestations.some((entry) => entry.workflowLane === lane)) {
|
|
607
|
+
ctx.addIssue({
|
|
608
|
+
code: exports_external.ZodIssueCode.custom,
|
|
609
|
+
path: ["findings"],
|
|
610
|
+
message: `workflow lane "${lane}" cannot be both CLEAN and FINDINGS`
|
|
611
|
+
});
|
|
612
|
+
return;
|
|
613
|
+
}
|
|
614
|
+
}
|
|
615
|
+
const coveredLanes = new Set([
|
|
616
|
+
...findingLanes,
|
|
617
|
+
...value.cleanAttestations.map((entry) => entry.workflowLane)
|
|
618
|
+
]);
|
|
619
|
+
for (const lane of value.creditedLanes) {
|
|
620
|
+
if (!coveredLanes.has(lane)) {
|
|
621
|
+
ctx.addIssue({
|
|
622
|
+
code: exports_external.ZodIssueCode.custom,
|
|
623
|
+
path: ["creditedLanes"],
|
|
624
|
+
message: `credited workflow lane "${lane}" must be backed by a finding or CLEAN attestation`
|
|
625
|
+
});
|
|
626
|
+
return;
|
|
627
|
+
}
|
|
628
|
+
}
|
|
629
|
+
for (const lane of coveredLanes) {
|
|
630
|
+
if (!value.creditedLanes.includes(lane)) {
|
|
631
|
+
ctx.addIssue({
|
|
632
|
+
code: exports_external.ZodIssueCode.custom,
|
|
633
|
+
path: ["creditedLanes"],
|
|
634
|
+
message: `covered workflow lane "${lane}" must appear in creditedLanes`
|
|
635
|
+
});
|
|
636
|
+
return;
|
|
637
|
+
}
|
|
638
|
+
}
|
|
639
|
+
for (const lane of value.unresolved.map((entry) => entry.workflowLane)) {
|
|
640
|
+
if (coveredLanes.has(lane)) {
|
|
641
|
+
ctx.addIssue({
|
|
642
|
+
code: exports_external.ZodIssueCode.custom,
|
|
643
|
+
path: ["unresolved"],
|
|
644
|
+
message: `workflow lane "${lane}" cannot be both credited and unresolved`
|
|
645
|
+
});
|
|
646
|
+
return;
|
|
647
|
+
}
|
|
648
|
+
}
|
|
649
|
+
const totalCovered = value.creditedLanes.length + value.unresolved.length;
|
|
650
|
+
if (totalCovered === 0) {
|
|
651
|
+
ctx.addIssue({
|
|
652
|
+
code: exports_external.ZodIssueCode.custom,
|
|
653
|
+
path: ["creditedLanes"],
|
|
654
|
+
message: "result envelope must cover at least one workflow lane"
|
|
655
|
+
});
|
|
656
|
+
return;
|
|
657
|
+
}
|
|
658
|
+
if (value.outcome === "CLEAN") {
|
|
659
|
+
if (value.findings.length > 0 || value.unresolved.length > 0) {
|
|
660
|
+
ctx.addIssue({
|
|
661
|
+
code: exports_external.ZodIssueCode.custom,
|
|
662
|
+
path: ["outcome"],
|
|
663
|
+
message: "CLEAN outcome cannot include findings or unresolved lanes"
|
|
664
|
+
});
|
|
665
|
+
}
|
|
666
|
+
if (value.cleanAttestations.length !== value.creditedLanes.length) {
|
|
667
|
+
ctx.addIssue({
|
|
668
|
+
code: exports_external.ZodIssueCode.custom,
|
|
669
|
+
path: ["cleanAttestations"],
|
|
670
|
+
message: "CLEAN outcome must attest every credited workflow lane exactly once"
|
|
671
|
+
});
|
|
672
|
+
}
|
|
673
|
+
}
|
|
674
|
+
if (value.outcome === "FINDINGS") {
|
|
675
|
+
if (value.findings.length === 0) {
|
|
676
|
+
ctx.addIssue({
|
|
677
|
+
code: exports_external.ZodIssueCode.custom,
|
|
678
|
+
path: ["findings"],
|
|
679
|
+
message: "FINDINGS outcome requires at least one finding"
|
|
680
|
+
});
|
|
681
|
+
}
|
|
682
|
+
if (value.unresolved.length > 0) {
|
|
683
|
+
ctx.addIssue({
|
|
684
|
+
code: exports_external.ZodIssueCode.custom,
|
|
685
|
+
path: ["unresolved"],
|
|
686
|
+
message: "FINDINGS outcome cannot include unresolved lanes"
|
|
687
|
+
});
|
|
688
|
+
}
|
|
689
|
+
}
|
|
690
|
+
if (value.outcome === "INCOMPLETE" && value.unresolved.length === 0) {
|
|
691
|
+
ctx.addIssue({
|
|
692
|
+
code: exports_external.ZodIssueCode.custom,
|
|
693
|
+
path: ["unresolved"],
|
|
694
|
+
message: "INCOMPLETE outcome requires at least one unresolved lane"
|
|
695
|
+
});
|
|
696
|
+
}
|
|
697
|
+
});
|
|
698
|
+
function serializedPrReviewResultReceiptBytes(value) {
|
|
699
|
+
return new TextEncoder().encode(JSON.stringify(value)).byteLength;
|
|
700
|
+
}
|
|
701
|
+
function prReviewLaneResultEnvelopeDigest(value) {
|
|
702
|
+
return createHash2("sha256").update(JSON.stringify(value)).digest("hex");
|
|
703
|
+
}
|
|
704
|
+
var PrReviewResultReceiptSchema = exports_external.object({
|
|
705
|
+
schemaVersion: exports_external.literal(1),
|
|
706
|
+
mode: exports_external.enum(PR_REVIEW_RESULT_LANE_MODES),
|
|
707
|
+
workflowInstanceId: exports_external.string().trim().min(1).max(256),
|
|
708
|
+
workflowRevision: exports_external.number().int().nonnegative(),
|
|
709
|
+
batchId: exports_external.string().trim().min(1).max(120),
|
|
710
|
+
laneId: exports_external.string().trim().min(1).max(120),
|
|
711
|
+
workflowLane: PrReviewResultLaneIdSchema,
|
|
712
|
+
ownedWorkflowLanes: exports_external.array(PrReviewResultLaneIdSchema).min(1).max(MAX_PR_REVIEW_RESULT_OWNED_LANES),
|
|
713
|
+
baseSha: PrReviewResultShaSchema,
|
|
714
|
+
headSha: PrReviewResultShaSchema,
|
|
715
|
+
dispatchRevisionDigest: PrReviewResultDigestSchema,
|
|
716
|
+
childSessionId: PrReviewResultChildSessionSchema,
|
|
717
|
+
generation: exports_external.number().int().positive().max(1e6),
|
|
718
|
+
semanticEnvelopeDigest: PrReviewResultDigestSchema,
|
|
719
|
+
envelope: PrReviewLaneResultEnvelopeSchema
|
|
720
|
+
}).strict().superRefine((value, ctx) => {
|
|
721
|
+
assertUniqueStrings(value.ownedWorkflowLanes, ctx, ["ownedWorkflowLanes"], "ownedWorkflowLanes");
|
|
722
|
+
if (!value.ownedWorkflowLanes.includes(value.workflowLane)) {
|
|
723
|
+
ctx.addIssue({
|
|
724
|
+
code: exports_external.ZodIssueCode.custom,
|
|
725
|
+
path: ["workflowLane"],
|
|
726
|
+
message: "workflowLane must be included in ownedWorkflowLanes"
|
|
727
|
+
});
|
|
728
|
+
}
|
|
729
|
+
const covered = new Set([
|
|
730
|
+
...value.envelope.creditedLanes,
|
|
731
|
+
...value.envelope.unresolved.map((entry) => entry.workflowLane)
|
|
732
|
+
]);
|
|
733
|
+
if (covered.size !== value.ownedWorkflowLanes.length) {
|
|
734
|
+
ctx.addIssue({
|
|
735
|
+
code: exports_external.ZodIssueCode.custom,
|
|
736
|
+
path: ["envelope"],
|
|
737
|
+
message: "envelope credited and unresolved workflow lanes must exactly partition ownedWorkflowLanes"
|
|
738
|
+
});
|
|
739
|
+
return;
|
|
740
|
+
}
|
|
741
|
+
for (const lane of value.ownedWorkflowLanes) {
|
|
742
|
+
if (!covered.has(lane)) {
|
|
743
|
+
ctx.addIssue({
|
|
744
|
+
code: exports_external.ZodIssueCode.custom,
|
|
745
|
+
path: ["ownedWorkflowLanes"],
|
|
746
|
+
message: `owned workflow lane "${lane}" is missing from the envelope coverage`
|
|
747
|
+
});
|
|
748
|
+
return;
|
|
749
|
+
}
|
|
750
|
+
}
|
|
751
|
+
const expectedDigest = prReviewLaneResultEnvelopeDigest(value.envelope);
|
|
752
|
+
if (value.semanticEnvelopeDigest !== expectedDigest) {
|
|
753
|
+
ctx.addIssue({
|
|
754
|
+
code: exports_external.ZodIssueCode.custom,
|
|
755
|
+
path: ["semanticEnvelopeDigest"],
|
|
756
|
+
message: "semanticEnvelopeDigest must match the canonical envelope digest"
|
|
757
|
+
});
|
|
758
|
+
}
|
|
759
|
+
const bytes = serializedPrReviewResultReceiptBytes(value);
|
|
760
|
+
if (bytes > MAX_PR_REVIEW_RESULT_RECEIPT_BYTES) {
|
|
761
|
+
ctx.addIssue({
|
|
762
|
+
code: exports_external.ZodIssueCode.custom,
|
|
763
|
+
path: [],
|
|
764
|
+
message: `receipt exceeds the ${MAX_PR_REVIEW_RESULT_RECEIPT_BYTES}-byte bound`
|
|
765
|
+
});
|
|
766
|
+
}
|
|
767
|
+
});
|
|
768
|
+
var PR_REVIEW_FINDINGS_MAX_BYTES = 10 * 1024 * 1024;
|
|
769
|
+
var PR_REVIEW_FINDINGS_WRITE_MAX_BYTES = 3 * 1024 * 1024;
|
|
770
|
+
var PR_REVIEW_HANDOFF_MAX_BYTES = 128 * 1024;
|
|
771
|
+
var PR_REVIEW_HANDOFF_WRITE_MAX_BYTES = 120 * 1024;
|
|
772
|
+
var PR_REVIEW_DISCARDED_EXAMPLE_ITEM_ID = "discarded-id";
|
|
773
|
+
function serializedPrReviewArtifactInputBytes(value) {
|
|
774
|
+
return new TextEncoder().encode(JSON.stringify(value)).byteLength;
|
|
775
|
+
}
|
|
776
|
+
var PrReviewRunIdSchema = exports_external.string().regex(/^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/, "run_id must be a safe relative identifier");
|
|
777
|
+
var PrReviewFindingSchema = exports_external.object({
|
|
778
|
+
finding_id: exports_external.string().trim().min(1).max(128),
|
|
779
|
+
status: exports_external.enum(PR_REVIEW_FINDING_STATUSES),
|
|
780
|
+
file_line: exports_external.string().trim().min(1).max(1000),
|
|
781
|
+
evidence: exports_external.string().trim().min(1).max(20000),
|
|
782
|
+
next_action: exports_external.enum(PR_REVIEW_FINDING_ACTIONS),
|
|
783
|
+
severity: exports_external.enum(PR_REVIEW_SEVERITIES).optional(),
|
|
784
|
+
category: exports_external.string().trim().min(1).max(128).optional(),
|
|
785
|
+
risk_impact: exports_external.enum(PR_REVIEW_RISK_IMPACTS).optional(),
|
|
786
|
+
risk_tags: exports_external.array(exports_external.enum(PR_REVIEW_RISK_TAGS)).max(PR_REVIEW_RISK_TAGS.length).optional()
|
|
787
|
+
}).strict().superRefine((value, ctx) => {
|
|
788
|
+
if (value.status !== "CONFIRMED")
|
|
789
|
+
return;
|
|
790
|
+
if (value.risk_impact === undefined) {
|
|
791
|
+
ctx.addIssue({
|
|
792
|
+
code: "custom",
|
|
793
|
+
path: ["risk_impact"],
|
|
794
|
+
message: "is required on every newly written CONFIRMED finding (issue #2383 typed critic routing)"
|
|
795
|
+
});
|
|
796
|
+
}
|
|
797
|
+
if (value.risk_tags === undefined) {
|
|
798
|
+
ctx.addIssue({
|
|
799
|
+
code: "custom",
|
|
800
|
+
path: ["risk_tags"],
|
|
801
|
+
message: "is required on every newly written CONFIRMED finding (issue #2383 typed critic routing)"
|
|
802
|
+
});
|
|
803
|
+
}
|
|
804
|
+
});
|
|
805
|
+
var PrReviewHandoffSchema = exports_external.object({
|
|
806
|
+
pr_url: exports_external.string().url().max(2000),
|
|
807
|
+
finding_ids: exports_external.array(exports_external.string().trim().min(1).max(128)).min(1).max(1000),
|
|
808
|
+
summary: exports_external.string().trim().min(1).max(20000),
|
|
809
|
+
provenance: exports_external.array(exports_external.string().trim().min(1).max(4000)).min(1).max(1000)
|
|
810
|
+
}).strict();
|
|
811
|
+
var PrReviewPartialBaseCoverageSchema = exports_external.object({
|
|
812
|
+
unresolved_dimensions: exports_external.array(exports_external.enum(PR_REVIEW_BASE_DIMENSION_IDS)).min(1).max(PR_REVIEW_BASE_DIMENSION_IDS.length)
|
|
813
|
+
}).strict().superRefine((value, ctx) => {
|
|
814
|
+
const seen = new Set;
|
|
815
|
+
for (const dimension of value.unresolved_dimensions) {
|
|
816
|
+
if (seen.has(dimension)) {
|
|
817
|
+
ctx.addIssue({
|
|
818
|
+
code: "custom",
|
|
819
|
+
path: ["unresolved_dimensions"],
|
|
820
|
+
message: `must not contain duplicate dimension "${dimension}"`
|
|
821
|
+
});
|
|
822
|
+
return;
|
|
823
|
+
}
|
|
824
|
+
seen.add(dimension);
|
|
825
|
+
}
|
|
826
|
+
});
|
|
827
|
+
var WritePrReviewArtifactArgsSchema = exports_external.discriminatedUnion("kind", [
|
|
828
|
+
exports_external.object({
|
|
829
|
+
kind: exports_external.literal("findings"),
|
|
830
|
+
run_id: PrReviewRunIdSchema.optional(),
|
|
831
|
+
pr_head_sha: exports_external.string().trim().regex(/^[0-9a-f]{6,64}$/i),
|
|
832
|
+
boundary: exports_external.enum(PR_REVIEW_ARTIFACT_BOUNDARIES),
|
|
833
|
+
records: exports_external.array(PrReviewFindingSchema).min(1).max(1000),
|
|
834
|
+
partial_base_coverage: PrReviewPartialBaseCoverageSchema.optional()
|
|
835
|
+
}).strict(),
|
|
836
|
+
exports_external.object({
|
|
837
|
+
kind: exports_external.literal("handoff"),
|
|
838
|
+
run_id: PrReviewRunIdSchema.optional(),
|
|
839
|
+
pr_head_sha: exports_external.string().trim().regex(/^[0-9a-f]{6,64}$/i),
|
|
840
|
+
handoff: PrReviewHandoffSchema
|
|
841
|
+
}).strict()
|
|
842
|
+
]).superRefine((value, ctx) => {
|
|
843
|
+
if (value.kind === "findings" && value.partial_base_coverage !== undefined && value.boundary !== "post_explorer") {
|
|
844
|
+
ctx.addIssue({
|
|
845
|
+
code: "custom",
|
|
846
|
+
path: ["partial_base_coverage"],
|
|
847
|
+
message: "is valid only for the post_explorer boundary"
|
|
848
|
+
});
|
|
849
|
+
}
|
|
850
|
+
const bytes = serializedPrReviewArtifactInputBytes(value);
|
|
851
|
+
const maxBytes = value.kind === "findings" ? PR_REVIEW_FINDINGS_WRITE_MAX_BYTES : PR_REVIEW_HANDOFF_WRITE_MAX_BYTES;
|
|
852
|
+
if (bytes > maxBytes) {
|
|
853
|
+
ctx.addIssue({
|
|
854
|
+
code: "custom",
|
|
855
|
+
path: [value.kind === "findings" ? "records" : "handoff"],
|
|
856
|
+
message: `serialized UTF-8 payload must be at most ${maxBytes} bytes (got ${bytes})`
|
|
857
|
+
});
|
|
858
|
+
}
|
|
859
|
+
});
|
|
860
|
+
var introducedByPrSchema = exports_external.string().regex(/^(?:introduced_by_pr\s*:\s*)?(?:YES|NO|UNKNOWN)$/i);
|
|
861
|
+
var PrReviewRiskTagsFieldPattern = new RegExp(`^(?:(?:${PR_REVIEW_RISK_TAGS.join("|")})(?:,(?:${PR_REVIEW_RISK_TAGS.join("|")}))*)?$`);
|
|
862
|
+
var PrReviewRiskTagsFieldSchema = exports_external.string().regex(PrReviewRiskTagsFieldPattern, `must be a comma-separated subset of the canonical risk tags (${PR_REVIEW_RISK_TAGS.join(", ")}), or empty`);
|
|
863
|
+
var PR_REVIEW_REVIEWER_LEGACY_FIELD_COUNT = 10;
|
|
864
|
+
function parsePrReviewRiskTagsField(field) {
|
|
865
|
+
const trimmed = field.trim();
|
|
866
|
+
if (!trimmed)
|
|
867
|
+
return [];
|
|
868
|
+
return trimmed.split(",").map((tag) => tag.trim());
|
|
869
|
+
}
|
|
870
|
+
var PrReviewReviewerVerdictFieldsSchema = exports_external.tuple([
|
|
871
|
+
exports_external.literal("[REVIEWED]"),
|
|
872
|
+
exports_external.string().min(1),
|
|
873
|
+
exports_external.enum(PR_REVIEW_REVIEWER_CLASSIFICATIONS),
|
|
874
|
+
exports_external.enum(PR_REVIEW_REVIEWER_EVIDENCE_TYPES),
|
|
875
|
+
exports_external.enum(PR_REVIEW_SEVERITIES),
|
|
876
|
+
introducedByPrSchema,
|
|
877
|
+
exports_external.string().min(1),
|
|
878
|
+
exports_external.string().min(8),
|
|
879
|
+
exports_external.string().min(5),
|
|
880
|
+
exports_external.string().min(3),
|
|
881
|
+
exports_external.enum(PR_REVIEW_RISK_IMPACTS),
|
|
882
|
+
PrReviewRiskTagsFieldSchema
|
|
883
|
+
]).superRefine((fields, ctx) => {
|
|
884
|
+
if (fields[2] === "DISPROVED" && fields[4] !== "NONE") {
|
|
885
|
+
ctx.addIssue({
|
|
886
|
+
code: "custom",
|
|
887
|
+
path: [4],
|
|
888
|
+
message: "DISPROVED reviewer severity must be NONE"
|
|
889
|
+
});
|
|
890
|
+
}
|
|
891
|
+
});
|
|
892
|
+
var PrReviewCriticVerdictFieldsSchema = exports_external.tuple([
|
|
893
|
+
exports_external.literal("[CRITIC]"),
|
|
894
|
+
exports_external.string().min(1),
|
|
895
|
+
exports_external.enum(PR_REVIEW_CRITIC_STATUSES),
|
|
896
|
+
exports_external.enum(PR_REVIEW_SEVERITIES),
|
|
897
|
+
exports_external.string().min(6),
|
|
898
|
+
exports_external.string().min(6)
|
|
899
|
+
]).superRefine((fields, ctx) => {
|
|
900
|
+
const status = fields[2];
|
|
901
|
+
const severity = fields[3];
|
|
902
|
+
if (status === "NEEDS_MORE_EVIDENCE") {
|
|
903
|
+
ctx.addIssue({
|
|
904
|
+
code: "custom",
|
|
905
|
+
path: [2],
|
|
906
|
+
message: "NEEDS_MORE_EVIDENCE is not a terminal transport verdict"
|
|
907
|
+
});
|
|
908
|
+
}
|
|
909
|
+
if (status === "DISPROVED" && severity !== "NONE") {
|
|
910
|
+
ctx.addIssue({
|
|
911
|
+
code: "custom",
|
|
912
|
+
path: [3],
|
|
913
|
+
message: "DISPROVED critic severity must be NONE"
|
|
914
|
+
});
|
|
915
|
+
}
|
|
916
|
+
if (status === "UPHELD" && !["CRITICAL", "HIGH", "MEDIUM"].includes(severity)) {
|
|
917
|
+
ctx.addIssue({
|
|
918
|
+
code: "custom",
|
|
919
|
+
path: [3],
|
|
920
|
+
message: "UPHELD critic severity must be CRITICAL, HIGH, or MEDIUM"
|
|
921
|
+
});
|
|
922
|
+
}
|
|
923
|
+
if (status === "DOWNGRADED" && severity === "CRITICAL") {
|
|
924
|
+
ctx.addIssue({
|
|
925
|
+
code: "custom",
|
|
926
|
+
path: [3],
|
|
927
|
+
message: "DOWNGRADED critic severity cannot be CRITICAL"
|
|
928
|
+
});
|
|
929
|
+
}
|
|
930
|
+
});
|
|
931
|
+
var PR_REVIEW_VERDICT_ROW_DESCRIPTORS = {
|
|
932
|
+
reviewer: {
|
|
933
|
+
marker: "[REVIEWED]",
|
|
934
|
+
fieldCount: 12,
|
|
935
|
+
fieldRoles: [
|
|
936
|
+
"marker",
|
|
937
|
+
"item_id",
|
|
938
|
+
"classification",
|
|
939
|
+
"evidence_type",
|
|
940
|
+
"severity",
|
|
941
|
+
"introduced_by_pr",
|
|
942
|
+
"file:line",
|
|
943
|
+
"rationale",
|
|
944
|
+
"probe",
|
|
945
|
+
"reviewer_notes",
|
|
946
|
+
"risk_impact",
|
|
947
|
+
"risk_tags"
|
|
948
|
+
],
|
|
949
|
+
schema: PrReviewReviewerVerdictFieldsSchema
|
|
950
|
+
},
|
|
951
|
+
critic: {
|
|
952
|
+
marker: "[CRITIC]",
|
|
953
|
+
fieldCount: 6,
|
|
954
|
+
fieldRoles: [
|
|
955
|
+
"marker",
|
|
956
|
+
"item_id",
|
|
957
|
+
"status",
|
|
958
|
+
"severity",
|
|
959
|
+
"rationale",
|
|
960
|
+
"required_change"
|
|
961
|
+
],
|
|
962
|
+
schema: PrReviewCriticVerdictFieldsSchema
|
|
963
|
+
}
|
|
964
|
+
};
|
|
965
|
+
function parsePrReviewVerdictRow(line, kind) {
|
|
966
|
+
const descriptor = PR_REVIEW_VERDICT_ROW_DESCRIPTORS[kind];
|
|
967
|
+
const fields = [];
|
|
968
|
+
let current = "";
|
|
969
|
+
let usedCanonicalEscape = false;
|
|
970
|
+
for (let index = 0;index < line.length; index++) {
|
|
971
|
+
const char = line[index];
|
|
972
|
+
if (char === "\\") {
|
|
973
|
+
const next = line[index + 1];
|
|
974
|
+
if (next === "\\") {
|
|
975
|
+
current += "\\";
|
|
976
|
+
usedCanonicalEscape = true;
|
|
977
|
+
index++;
|
|
978
|
+
continue;
|
|
979
|
+
}
|
|
980
|
+
if (next === "|") {
|
|
981
|
+
current += "|";
|
|
982
|
+
usedCanonicalEscape = true;
|
|
983
|
+
index++;
|
|
984
|
+
continue;
|
|
985
|
+
}
|
|
986
|
+
if (next === "n") {
|
|
987
|
+
current += `
|
|
988
|
+
`;
|
|
989
|
+
usedCanonicalEscape = true;
|
|
990
|
+
index++;
|
|
991
|
+
continue;
|
|
992
|
+
}
|
|
993
|
+
if (next === "r") {
|
|
994
|
+
current += "\r";
|
|
995
|
+
usedCanonicalEscape = true;
|
|
996
|
+
index++;
|
|
997
|
+
continue;
|
|
998
|
+
}
|
|
999
|
+
current += "\\";
|
|
1000
|
+
continue;
|
|
1001
|
+
}
|
|
1002
|
+
if (char === "|") {
|
|
1003
|
+
fields.push(current.trim());
|
|
1004
|
+
current = "";
|
|
1005
|
+
continue;
|
|
1006
|
+
}
|
|
1007
|
+
current += char;
|
|
1008
|
+
}
|
|
1009
|
+
fields.push(current.trim());
|
|
1010
|
+
if (fields[0] !== descriptor.marker)
|
|
1011
|
+
return null;
|
|
1012
|
+
if (kind === "reviewer" && fields.length === PR_REVIEW_REVIEWER_LEGACY_FIELD_COUNT) {
|
|
1013
|
+
fields.push("UNKNOWN", "");
|
|
1014
|
+
}
|
|
1015
|
+
if (fields.length > descriptor.fieldCount) {
|
|
1016
|
+
const retained = fields.slice(0, descriptor.fieldCount - 1);
|
|
1017
|
+
retained.push(fields.slice(descriptor.fieldCount - 1).join("|"));
|
|
1018
|
+
return {
|
|
1019
|
+
marker: descriptor.marker,
|
|
1020
|
+
fields: retained,
|
|
1021
|
+
recoveredOverflow: true,
|
|
1022
|
+
overflowClass: fields.length === descriptor.fieldCount + 1 && fields[fields.length - 1] === "" ? "legacy-fidelity-safe" : "legacy-lossy"
|
|
1023
|
+
};
|
|
1024
|
+
}
|
|
1025
|
+
return {
|
|
1026
|
+
marker: descriptor.marker,
|
|
1027
|
+
fields,
|
|
1028
|
+
recoveredOverflow: false,
|
|
1029
|
+
overflowClass: fields.length === descriptor.fieldCount ? usedCanonicalEscape ? "canonical" : "legacy-fidelity-safe" : "legacy-lossy"
|
|
1030
|
+
};
|
|
1031
|
+
}
|
|
1032
|
+
function pad(value, width) {
|
|
1033
|
+
return `${value}`.padStart(width, "0");
|
|
1034
|
+
}
|
|
1035
|
+
function generatePrReviewRunId(now = new Date) {
|
|
1036
|
+
return `pr-review-${now.getUTCFullYear()}` + `${pad(now.getUTCMonth() + 1, 2)}` + `${pad(now.getUTCDate(), 2)}` + `${pad(now.getUTCHours(), 2)}` + `${pad(now.getUTCMinutes(), 2)}` + `${pad(now.getUTCSeconds(), 2)}` + `${pad(now.getUTCMilliseconds(), 3)}`;
|
|
1037
|
+
}
|
|
399
1038
|
// src/background/pending-delegations.ts
|
|
400
1039
|
var BACKGROUND_DELEGATIONS_FILE = "background-delegations.jsonl";
|
|
401
1040
|
var BACKGROUND_DELEGATION_FALLBACK_DIR = "background-delegation-fallback";
|
|
@@ -874,7 +1513,7 @@ function readDelegationCheckpoint(directory) {
|
|
|
874
1513
|
return { kind: "ok", checkpoint: parsed.data, bytes };
|
|
875
1514
|
}
|
|
876
1515
|
function sha256Hex(data) {
|
|
877
|
-
return
|
|
1516
|
+
return createHash3("sha256").update(data).digest("hex");
|
|
878
1517
|
}
|
|
879
1518
|
function checkpointPayloadChecksum(checkpoint) {
|
|
880
1519
|
return sha256Hex(JSON.stringify([
|
|
@@ -1753,7 +2392,7 @@ function buildPromptSnapshot(text, maxChars) {
|
|
|
1753
2392
|
text: bounded,
|
|
1754
2393
|
chars: text.length,
|
|
1755
2394
|
truncated,
|
|
1756
|
-
digest:
|
|
2395
|
+
digest: createHash3("sha256").update(text).digest("hex")
|
|
1757
2396
|
};
|
|
1758
2397
|
}
|
|
1759
2398
|
async function appendDelegationTransition(directory, correlationId, transition) {
|
|
@@ -1856,7 +2495,7 @@ async function publishPrReviewResultReceipt(directory, input) {
|
|
|
1856
2495
|
...current.result ?? {
|
|
1857
2496
|
chars: 0,
|
|
1858
2497
|
truncated: false,
|
|
1859
|
-
digest:
|
|
2498
|
+
digest: createHash3("sha256").update("").digest("hex")
|
|
1860
2499
|
},
|
|
1861
2500
|
prReviewResultReceipt: parsed.data
|
|
1862
2501
|
}
|
|
@@ -1880,7 +2519,7 @@ function buildBackgroundCompletionEventId(input) {
|
|
|
1880
2519
|
input.status,
|
|
1881
2520
|
input.resultDigest
|
|
1882
2521
|
]);
|
|
1883
|
-
return `bgc1:${
|
|
2522
|
+
return `bgc1:${createHash3("sha256").update(canonical).digest("hex")}`;
|
|
1884
2523
|
}
|
|
1885
2524
|
function sameJson(left, right) {
|
|
1886
2525
|
return JSON.stringify(left) === JSON.stringify(right);
|
|
@@ -2338,7 +2977,7 @@ async function claimDelegationIngestion(directory, correlationId, options) {
|
|
|
2338
2977
|
}
|
|
2339
2978
|
const disposition = current.status === "ingestion_error" || current.ingestion?.state === "claimed" ? "retry" : "claimed";
|
|
2340
2979
|
const attempt = (current.ingestion?.attempt ?? 0) + 1;
|
|
2341
|
-
const claimToken =
|
|
2980
|
+
const claimToken = createHash3("sha256").update(JSON.stringify([correlationId, options.claimantId, attempt, now])).digest("hex");
|
|
2342
2981
|
const next = {
|
|
2343
2982
|
...current,
|
|
2344
2983
|
schemaVersion: current.schemaVersion === 4 ? 4 : 3,
|
|
@@ -2690,7 +3329,7 @@ async function sweepStaleDelegations(directory, timeoutMs, options = {}) {
|
|
|
2690
3329
|
}
|
|
2691
3330
|
}
|
|
2692
3331
|
function fallbackRelativePath(correlationId) {
|
|
2693
|
-
const digest =
|
|
3332
|
+
const digest = createHash3("sha256").update(correlationId).digest("hex");
|
|
2694
3333
|
return path2.join(BACKGROUND_DELEGATION_FALLBACK_DIR, `${digest}.json`);
|
|
2695
3334
|
}
|
|
2696
3335
|
function fallbackPath(directory, correlationId) {
|
|
@@ -2948,7 +3587,7 @@ function reservationStorePath(directory) {
|
|
|
2948
3587
|
}
|
|
2949
3588
|
function buildBackgroundCoderReservationId(input) {
|
|
2950
3589
|
const ownerIdentity = input.planTaskId === null ? ["call", input.parentSessionId, input.callID] : ["task", input.parentSessionId, input.planTaskId];
|
|
2951
|
-
return `bgcr1:${
|
|
3590
|
+
return `bgcr1:${createHash3("sha256").update(JSON.stringify(ownerIdentity)).digest("hex")}`;
|
|
2952
3591
|
}
|
|
2953
3592
|
function scanBackgroundCoderReservationsForAdmission(directory) {
|
|
2954
3593
|
let absolutePath;
|
|
@@ -3308,7 +3947,7 @@ async function reconcileLegacyCoderSettlements(directory, maxRecords, onReconcil
|
|
|
3308
3947
|
const candidates = readDelegations(directory).filter((record) => record.normalizedAgent === "coder" && Boolean(record.legacyCoderSettlementTransfer) && Boolean(record.terminalResult)).slice(0, maxRecords);
|
|
3309
3948
|
if (candidates.length === 0)
|
|
3310
3949
|
return 0;
|
|
3311
|
-
const { transferCoderSettlementToBackground } = await import("./coder-settlement-
|
|
3950
|
+
const { transferCoderSettlementToBackground } = await import("./coder-settlement-kv1x94w6.js");
|
|
3312
3951
|
let transferred = 0;
|
|
3313
3952
|
for (const record of candidates) {
|
|
3314
3953
|
try {
|
|
@@ -3665,4 +4304,4 @@ async function maintainBackgroundDelegations(directory, options = {}) {
|
|
|
3665
4304
|
return emitObservation("ok");
|
|
3666
4305
|
}
|
|
3667
4306
|
|
|
3668
|
-
export { MAX_RECOVERY_LEDGER_BYTES, readDelegationHealthArtifact, collectDelegationLedgerHealth, MAX_PR_REVIEW_COLLECTION_RECEIPT_ITEM_IDS, BACKGROUND_DELEGATIONS_FILE, BACKGROUND_DELEGATION_FALLBACK_DIR, BACKGROUND_CODER_RESERVATIONS_FILE, BACKGROUND_DELEGATIONS_CHECKPOINT_FILE, BACKGROUND_DELEGATIONS_MANIFEST_FILE, MAX_LIVE_BACKGROUND_FALLBACKS, MAX_LIVE_BACKGROUND_CODER_RESERVATIONS, MAX_BACKGROUND_OBSERVED_FILES, MAX_BACKGROUND_ADVISORY_CHARS, LEGACY_CODER_SETTLEMENT_PENDING_ADVISORY_MARKER, DELEGATION_COMPACTION_LOW_WATER_BYTES, DELEGATION_COMPACTION_HIGH_WATER_BYTES, MAX_CHECKPOINT_BYTES, MAX_CHECKPOINT_RECORDS, TOMBSTONE_MIN_AGE_MS, BACKGROUND_INGESTION_LEASE_MS, BACKGROUND_CODER_RESERVATION_LEASE_MS, BACKGROUND_CODER_RESERVATION_LEASE_MAX_MS, BACKGROUND_CODER_RESERVATION_LEASE_MIN_MS, DEFAULT_STALE_DELEGATION_TIMEOUT_MS, DEFAULT_SWEEPABLE_DELEGATION_STATUSES, _checkpointInternals, isUnsettledWorktreeOwner, compactBackgroundDelegations, readDelegations, scanDelegationsForRecovery, findByCorrelationId, recordPendingDelegationDetailed, recordPendingDelegation, buildPromptSnapshot, appendDelegationTransition, publishPrReviewResultReceipt, buildBackgroundCompletionEventId, claimTerminalResult, claimCoderSettlement, normalizeBackgroundObservedFiles, updateCoderSettlement, registerLegacyCoderSettlementReconciler, _internals, markLegacyCoderSettlementTransferPending, clearLegacyCoderSettlementTransferPending, claimDelegationIngestion, recordDelegationIngestionResult, putPendingBackgroundAdvisory, replacePendingBackgroundAdvisory, preparePendingBackgroundAdvisories, acknowledgeObservedBackgroundAdvisories, releasePreparedBackgroundAdvisories, findByBatchId, findOpenAsyncLaneBatches, isTerminalDelegationStatus, sweepStaleDelegations, readDelegationFallback, listDelegationFallbacks, scanDelegationFallbacksForRecovery, writeDelegationFallback, removeDelegationFallback, findDelegationForCompletion, promoteDelegationFallback, buildBackgroundCoderReservationId, scanBackgroundCoderReservationsForAdmission, reserveBackgroundCoderSlot, bindBackgroundCoderReservation, releaseBackgroundCoderReservation, maintainBackgroundDelegations };
|
|
4307
|
+
export { prReviewFindingRequiresCritic, PR_REVIEW_BASE_DIMENSION_IDS, PR_REVIEW_RISK_IMPACTS, PR_REVIEW_RISK_TAGS, prReviewLegacyTranscriptCompatibilityEnabled, PrReviewLaneResultEnvelopeSchema, prReviewLaneResultEnvelopeDigest, PrReviewResultReceiptSchema, PR_REVIEW_FINDINGS_MAX_BYTES, PR_REVIEW_HANDOFF_MAX_BYTES, PR_REVIEW_DISCARDED_EXAMPLE_ITEM_ID, PrReviewRunIdSchema, parsePrReviewRiskTagsField, PrReviewReviewerVerdictFieldsSchema, PrReviewCriticVerdictFieldsSchema, parsePrReviewVerdictRow, generatePrReviewRunId, MAX_RECOVERY_LEDGER_BYTES, readDelegationHealthArtifact, collectDelegationLedgerHealth, MAX_PR_REVIEW_COLLECTION_RECEIPT_ITEM_IDS, BACKGROUND_DELEGATIONS_FILE, BACKGROUND_DELEGATION_FALLBACK_DIR, BACKGROUND_CODER_RESERVATIONS_FILE, BACKGROUND_DELEGATIONS_CHECKPOINT_FILE, BACKGROUND_DELEGATIONS_MANIFEST_FILE, MAX_LIVE_BACKGROUND_FALLBACKS, MAX_LIVE_BACKGROUND_CODER_RESERVATIONS, MAX_BACKGROUND_OBSERVED_FILES, MAX_BACKGROUND_ADVISORY_CHARS, LEGACY_CODER_SETTLEMENT_PENDING_ADVISORY_MARKER, DELEGATION_COMPACTION_LOW_WATER_BYTES, DELEGATION_COMPACTION_HIGH_WATER_BYTES, MAX_CHECKPOINT_BYTES, MAX_CHECKPOINT_RECORDS, TOMBSTONE_MIN_AGE_MS, BACKGROUND_INGESTION_LEASE_MS, BACKGROUND_CODER_RESERVATION_LEASE_MS, BACKGROUND_CODER_RESERVATION_LEASE_MAX_MS, BACKGROUND_CODER_RESERVATION_LEASE_MIN_MS, DEFAULT_STALE_DELEGATION_TIMEOUT_MS, DEFAULT_SWEEPABLE_DELEGATION_STATUSES, _checkpointInternals, isUnsettledWorktreeOwner, compactBackgroundDelegations, readDelegations, scanDelegationsForRecovery, findByCorrelationId, recordPendingDelegationDetailed, recordPendingDelegation, buildPromptSnapshot, appendDelegationTransition, publishPrReviewResultReceipt, buildBackgroundCompletionEventId, claimTerminalResult, claimCoderSettlement, normalizeBackgroundObservedFiles, updateCoderSettlement, registerLegacyCoderSettlementReconciler, _internals, markLegacyCoderSettlementTransferPending, clearLegacyCoderSettlementTransferPending, claimDelegationIngestion, recordDelegationIngestionResult, putPendingBackgroundAdvisory, replacePendingBackgroundAdvisory, preparePendingBackgroundAdvisories, acknowledgeObservedBackgroundAdvisories, releasePreparedBackgroundAdvisories, findByBatchId, findOpenAsyncLaneBatches, isTerminalDelegationStatus, sweepStaleDelegations, readDelegationFallback, listDelegationFallbacks, scanDelegationFallbacksForRecovery, writeDelegationFallback, removeDelegationFallback, findDelegationForCompletion, promoteDelegationFallback, buildBackgroundCoderReservationId, scanBackgroundCoderReservationsForAdmission, reserveBackgroundCoderSlot, bindBackgroundCoderReservation, releaseBackgroundCoderReservation, maintainBackgroundDelegations };
|