@fro.bot/systematic 3.25.1 → 3.26.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/HARNESSES.md +49 -1
- package/README.md +1 -1
- package/dist/ce-review-validator.d.ts +22 -3
- package/dist/cli.js +69 -34
- package/dist/{index-bmsgc2em.js → index-1dyb2x0z.js} +1 -0
- package/dist/index.js +1 -1
- package/dist/lib/bundled-names.d.ts +1 -1
- package/dist/lib/review-artifact-path.d.ts +66 -0
- package/dist/lib/review-artifact-schema.d.ts +12 -0
- package/dist/lib/review-pipeline.d.ts +25 -17
- package/dist/lib/review-return-validator.d.ts +3 -6
- package/dist/pi.js +1 -0
- package/package.json +2 -1
- package/skills/ce-review/SKILL.md +2 -2
- package/skills/ce-review/references/pipeline-invocation.md +36 -1
- package/skills/ce-review/references/review-pipeline-schema.json +3 -3
- package/skills/ce-review/references/review-summary-schema.json +12 -12
- package/skills/ce-review/references/validator-template.md +12 -11
- package/skills/ce-review/scripts/validate-review.mjs +355 -136
- package/skills/git-commit-push-pr/SKILL.md +79 -6
- package/skills/pr-attachments/SKILL.md +764 -0
- package/skills/pr-attachments/scripts/pr-attachments.mjs +3140 -0
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// biome-ignore-all assist/source/organizeImports: generated bundle
|
|
3
3
|
// Generated by scripts/generate-ce-review-validator.ts; do not edit by hand.
|
|
4
4
|
// Run `bun run ce-review-validator:build` to regenerate.
|
|
5
|
-
// source-digest:
|
|
5
|
+
// source-digest: c1ed0125927578fdca4ed3bb6765d7a4373d27ebf8b03acd34650b404ca6ac51
|
|
6
6
|
var __defProp = Object.defineProperty
|
|
7
7
|
var __returnValue = (v) => v
|
|
8
8
|
function __exportSetter(name, newValue) {
|
|
@@ -44,6 +44,49 @@ function formatReviewArtifactIssuePath(issuePath) {
|
|
|
44
44
|
.map((segment) => (typeof segment === 'number' ? String(segment) : segment))
|
|
45
45
|
.join('.')
|
|
46
46
|
}
|
|
47
|
+
var MAX_PROJECTED_ISSUE_LINES = 8
|
|
48
|
+
function projectZodIssues(issues, max = MAX_PROJECTED_ISSUE_LINES) {
|
|
49
|
+
return {
|
|
50
|
+
issues: issues.slice(0, max).map((issue) => ({
|
|
51
|
+
path: formatReviewArtifactIssuePath(issue.path),
|
|
52
|
+
code: issue.code,
|
|
53
|
+
})),
|
|
54
|
+
total: issues.length,
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
function schemaRejection(reason, zodIssues) {
|
|
58
|
+
const { issues, total } = projectZodIssues(zodIssues)
|
|
59
|
+
return {
|
|
60
|
+
kind: 'schema',
|
|
61
|
+
path: issues[0]?.path ?? '$',
|
|
62
|
+
reason,
|
|
63
|
+
issues,
|
|
64
|
+
total,
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
var REVIEW_ARTIFACT_SCHEMA_RELATIVE_PATH =
|
|
68
|
+
'skills/ce-review/references/review-summary-schema.json'
|
|
69
|
+
function formatProjectedIssueLines(projected) {
|
|
70
|
+
const lines = projected.issues.map((issue) => `${issue.path} ${issue.code}`)
|
|
71
|
+
const omitted = projected.total - projected.issues.length
|
|
72
|
+
if (omitted > 0) lines.push(`… and ${omitted} more`)
|
|
73
|
+
return lines
|
|
74
|
+
}
|
|
75
|
+
function formatReviewArtifactValidationFailure(issues) {
|
|
76
|
+
const projected = projectZodIssues(issues)
|
|
77
|
+
const issueLines = formatProjectedIssueLines(projected)
|
|
78
|
+
const shown = projected.issues.length
|
|
79
|
+
for (const [index, issue] of issues.slice(0, shown).entries()) {
|
|
80
|
+
if (issue.code === 'custom' && issue.message !== undefined) {
|
|
81
|
+
issueLines[index] = `${issueLines[index]}: ${issue.message}`
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return [
|
|
85
|
+
`Review artifact failed schema validation: ${projected.total} issue(s)`,
|
|
86
|
+
`Schema: ${REVIEW_ARTIFACT_SCHEMA_RELATIVE_PATH}`,
|
|
87
|
+
...issueLines,
|
|
88
|
+
]
|
|
89
|
+
}
|
|
47
90
|
function readReviewArtifact(filePath) {
|
|
48
91
|
let content
|
|
49
92
|
try {
|
|
@@ -6352,6 +6395,18 @@ var MAX_INPUT_ID_LENGTH = 128
|
|
|
6352
6395
|
var MAX_REASON_LENGTH = 2048
|
|
6353
6396
|
var MAX_FINDINGS = 32
|
|
6354
6397
|
var MAX_PERSONAS = 64
|
|
6398
|
+
var MAX_RUN_FINDINGS = MAX_FINDINGS * MAX_PERSONAS
|
|
6399
|
+
var MAX_DECISION_FACTS = MAX_FINDINGS
|
|
6400
|
+
var MAX_RUN_DISAGREEMENT_FACTS = MAX_RUN_FINDINGS * (MAX_DECISION_FACTS + 1)
|
|
6401
|
+
var COVERAGE_BOUNDS = {
|
|
6402
|
+
reviewers: MAX_PERSONAS,
|
|
6403
|
+
validators: MAX_RUN_FINDINGS,
|
|
6404
|
+
residual_risks: MAX_PERSONAS * MAX_PERSONAS,
|
|
6405
|
+
testing_gaps: MAX_PERSONAS * MAX_PERSONAS,
|
|
6406
|
+
failed_reviewers: MAX_PERSONAS,
|
|
6407
|
+
validator_failures: MAX_RUN_FINDINGS,
|
|
6408
|
+
intent_uncertainty: MAX_RUN_DISAGREEMENT_FACTS,
|
|
6409
|
+
}
|
|
6355
6410
|
var REVIEW_ARTIFACT_CUSTOM_MESSAGES = [
|
|
6356
6411
|
'severity count must match rejected finding count',
|
|
6357
6412
|
'filtered findings require a validation reason',
|
|
@@ -6491,7 +6546,7 @@ var SynthesizedFindingFieldsSchema = object({
|
|
|
6491
6546
|
route_narrowing_reason: ReasonSchema.optional(),
|
|
6492
6547
|
input_finding_ids: array(boundedText(MAX_INPUT_ID_LENGTH))
|
|
6493
6548
|
.min(1)
|
|
6494
|
-
.max(
|
|
6549
|
+
.max(MAX_RUN_FINDINGS),
|
|
6495
6550
|
provenance: ProvenanceSchema,
|
|
6496
6551
|
}).strict()
|
|
6497
6552
|
var SynthesizedFindingSchema = SynthesizedFindingFieldsSchema.superRefine(
|
|
@@ -6530,41 +6585,38 @@ var DispatchSchema = object({
|
|
|
6530
6585
|
}
|
|
6531
6586
|
})
|
|
6532
6587
|
var DispositionCountsSchema = object({
|
|
6533
|
-
surviving: number2()
|
|
6534
|
-
|
|
6535
|
-
|
|
6536
|
-
|
|
6537
|
-
|
|
6538
|
-
|
|
6539
|
-
|
|
6540
|
-
|
|
6541
|
-
suppressed: number2()
|
|
6542
|
-
.int()
|
|
6543
|
-
.nonnegative()
|
|
6544
|
-
.max(MAX_FINDINGS * MAX_PERSONAS),
|
|
6545
|
-
filtered: number2()
|
|
6588
|
+
surviving: number2().int().nonnegative().max(MAX_RUN_FINDINGS),
|
|
6589
|
+
merged: number2().int().nonnegative().max(MAX_RUN_FINDINGS),
|
|
6590
|
+
suppressed: number2().int().nonnegative().max(MAX_RUN_FINDINGS),
|
|
6591
|
+
filtered: number2().int().nonnegative().max(MAX_RUN_FINDINGS),
|
|
6592
|
+
rejected: number2().int().nonnegative().max(MAX_RUN_FINDINGS),
|
|
6593
|
+
}).strict()
|
|
6594
|
+
var CoverageSchema = object({
|
|
6595
|
+
reviewers: number2()
|
|
6546
6596
|
.int()
|
|
6547
6597
|
.nonnegative()
|
|
6548
|
-
.max(
|
|
6549
|
-
|
|
6598
|
+
.max(COVERAGE_BOUNDS.reviewers)
|
|
6599
|
+
.optional(),
|
|
6600
|
+
validators: number2()
|
|
6550
6601
|
.int()
|
|
6551
6602
|
.nonnegative()
|
|
6552
|
-
.max(
|
|
6553
|
-
|
|
6554
|
-
|
|
6555
|
-
|
|
6556
|
-
|
|
6557
|
-
|
|
6558
|
-
|
|
6559
|
-
|
|
6560
|
-
|
|
6561
|
-
|
|
6603
|
+
.max(COVERAGE_BOUNDS.validators)
|
|
6604
|
+
.optional(),
|
|
6605
|
+
residual_risks: array(ReasonSchema).max(COVERAGE_BOUNDS.residual_risks),
|
|
6606
|
+
testing_gaps: array(ReasonSchema).max(COVERAGE_BOUNDS.testing_gaps),
|
|
6607
|
+
failed_reviewers: array(ReviewerSchema).max(COVERAGE_BOUNDS.failed_reviewers),
|
|
6608
|
+
validator_failures: array(ReasonSchema).max(
|
|
6609
|
+
COVERAGE_BOUNDS.validator_failures,
|
|
6610
|
+
),
|
|
6611
|
+
intent_uncertainty: array(ReasonSchema).max(
|
|
6612
|
+
COVERAGE_BOUNDS.intent_uncertainty,
|
|
6613
|
+
),
|
|
6562
6614
|
}).strict()
|
|
6563
6615
|
var DeclinedMergeSchema = object({
|
|
6564
6616
|
file: RepoRelativePathSchema,
|
|
6565
6617
|
input_finding_ids: array(boundedText(MAX_INPUT_ID_LENGTH))
|
|
6566
6618
|
.min(2)
|
|
6567
|
-
.max(
|
|
6619
|
+
.max(MAX_RUN_FINDINGS),
|
|
6568
6620
|
reason: ReasonSchema,
|
|
6569
6621
|
}).strict()
|
|
6570
6622
|
var ValidationSchema = object({
|
|
@@ -6621,14 +6673,14 @@ var ReviewArtifactSchema = object({
|
|
|
6621
6673
|
verdict: boundedText(256),
|
|
6622
6674
|
completed_at: CompletedAtSchema,
|
|
6623
6675
|
dispatches: array(DispatchSchema).max(MAX_PERSONAS),
|
|
6624
|
-
input_findings: array(InputFindingSchema).max(
|
|
6625
|
-
findings: array(SynthesizedFindingSchema).max(
|
|
6626
|
-
declined_merges: array(DeclinedMergeSchema).max(
|
|
6676
|
+
input_findings: array(InputFindingSchema).max(MAX_RUN_FINDINGS),
|
|
6677
|
+
findings: array(SynthesizedFindingSchema).max(MAX_RUN_FINDINGS),
|
|
6678
|
+
declined_merges: array(DeclinedMergeSchema).max(MAX_RUN_FINDINGS).optional(),
|
|
6627
6679
|
risk_coverage: array(RiskCoverageSchema).max(MAX_PERSONAS).optional(),
|
|
6628
6680
|
disposition_counts: DispositionCountsSchema,
|
|
6629
|
-
applied_fixes: array(ReasonSchema).max(
|
|
6630
|
-
residual_actionable_work: array(ReasonSchema).max(
|
|
6631
|
-
advisory_outputs: array(ReasonSchema).max(
|
|
6681
|
+
applied_fixes: array(ReasonSchema).max(MAX_RUN_FINDINGS),
|
|
6682
|
+
residual_actionable_work: array(ReasonSchema).max(MAX_RUN_FINDINGS),
|
|
6683
|
+
advisory_outputs: array(ReasonSchema).max(MAX_RUN_FINDINGS),
|
|
6632
6684
|
coverage: CoverageSchema,
|
|
6633
6685
|
validation: ValidationSchema.optional(),
|
|
6634
6686
|
})
|
|
@@ -6921,8 +6973,6 @@ var ParentRecordSchema = object({
|
|
|
6921
6973
|
}).strict()
|
|
6922
6974
|
|
|
6923
6975
|
// src/claude-code-validator.ts
|
|
6924
|
-
var REVIEW_ARTIFACT_SCHEMA_RELATIVE_PATH =
|
|
6925
|
-
'skills/ce-review/references/review-summary-schema.json'
|
|
6926
6976
|
function runClaudeCodeValidator(options) {
|
|
6927
6977
|
const outputSink = options.outputSink ?? ((message) => console.log(message))
|
|
6928
6978
|
const errorSink = options.errorSink ?? ((message) => console.error(message))
|
|
@@ -6951,16 +7001,11 @@ function runClaudeCodeValidator(options) {
|
|
|
6951
7001
|
}
|
|
6952
7002
|
const result = ReviewArtifactSchema.safeParse(artifact.value)
|
|
6953
7003
|
if (!result.success) {
|
|
6954
|
-
for (const
|
|
6955
|
-
|
|
6956
|
-
|
|
6957
|
-
|
|
6958
|
-
errorSink(`${issuePath} ${issue.code}${authoredMessage}`)
|
|
7004
|
+
for (const line of formatReviewArtifactValidationFailure(
|
|
7005
|
+
result.error.issues,
|
|
7006
|
+
)) {
|
|
7007
|
+
errorSink(line)
|
|
6959
7008
|
}
|
|
6960
|
-
errorSink(`Schema: ${REVIEW_ARTIFACT_SCHEMA_RELATIVE_PATH}`)
|
|
6961
|
-
errorSink(
|
|
6962
|
-
`Review artifact validation failed: ${result.error.issues.length} issue(s)`,
|
|
6963
|
-
)
|
|
6964
7009
|
return 1
|
|
6965
7010
|
}
|
|
6966
7011
|
outputSink(
|
|
@@ -7041,7 +7086,7 @@ var CandidateGroupMemberSchema = object({
|
|
|
7041
7086
|
}).strict()
|
|
7042
7087
|
var CandidateGroupSchema = object({
|
|
7043
7088
|
file: RepoRelativePathSchema,
|
|
7044
|
-
members: array(CandidateGroupMemberSchema).min(2).max(
|
|
7089
|
+
members: array(CandidateGroupMemberSchema).min(2).max(MAX_RUN_FINDINGS),
|
|
7045
7090
|
}).strict()
|
|
7046
7091
|
var SurvivingAdmittedFindingSchema = ParentFindingSchema.extend({
|
|
7047
7092
|
input_id: PipelineInputIdSchema,
|
|
@@ -7049,15 +7094,13 @@ var SurvivingAdmittedFindingSchema = ParentFindingSchema.extend({
|
|
|
7049
7094
|
}).strict()
|
|
7050
7095
|
var PrepareOutputSchema = object({
|
|
7051
7096
|
confidence_dispositions: array(ConfidenceDispositionSchema).max(
|
|
7052
|
-
|
|
7097
|
+
MAX_RUN_FINDINGS,
|
|
7053
7098
|
),
|
|
7054
|
-
coverage_union: array(RepoRelativePathSchema).max(
|
|
7055
|
-
|
|
7056
|
-
),
|
|
7057
|
-
singletons: array(PipelineInputIdSchema).max(MAX_FINDINGS * MAX_PERSONAS),
|
|
7058
|
-
candidate_groups: array(CandidateGroupSchema).max(MAX_FINDINGS),
|
|
7099
|
+
coverage_union: array(RepoRelativePathSchema).max(MAX_RUN_FINDINGS),
|
|
7100
|
+
singletons: array(PipelineInputIdSchema).max(MAX_RUN_FINDINGS),
|
|
7101
|
+
candidate_groups: array(CandidateGroupSchema).max(MAX_RUN_FINDINGS),
|
|
7059
7102
|
surviving_findings: array(SurvivingAdmittedFindingSchema).max(
|
|
7060
|
-
|
|
7103
|
+
MAX_RUN_FINDINGS,
|
|
7061
7104
|
),
|
|
7062
7105
|
}).strict()
|
|
7063
7106
|
var PER_FINDING_BYTE_ASSUMPTION = 8192
|
|
@@ -7102,7 +7145,10 @@ var isRouteTransitionAllowed = (from, to) => {
|
|
|
7102
7145
|
return autofixAllowed && ownerAllowed && verificationAllowed
|
|
7103
7146
|
}
|
|
7104
7147
|
var AgreementCreditSchema = SubAgentReturnSchema.shape.reviewer
|
|
7105
|
-
var
|
|
7148
|
+
var DecisionFactsSchema = array(PipelineReasonSchema).max(MAX_DECISION_FACTS)
|
|
7149
|
+
var AggregateFactsSchema = array(PipelineReasonSchema).max(
|
|
7150
|
+
MAX_RUN_DISAGREEMENT_FACTS,
|
|
7151
|
+
)
|
|
7106
7152
|
var ProposedRouteSchema = object({
|
|
7107
7153
|
autofix_class: AutofixClassRouteSchema,
|
|
7108
7154
|
owner: OwnerRouteSchema,
|
|
@@ -7111,13 +7157,13 @@ var ProposedRouteSchema = object({
|
|
|
7111
7157
|
var MergedDecisionSchema = object({
|
|
7112
7158
|
decision_id: PipelineInputIdSchema,
|
|
7113
7159
|
disposition: literal('merged'),
|
|
7114
|
-
input_finding_ids: array(PipelineInputIdSchema).min(2).max(
|
|
7160
|
+
input_finding_ids: array(PipelineInputIdSchema).min(2).max(MAX_RUN_FINDINGS),
|
|
7115
7161
|
title: ParentFindingSchema.shape.title,
|
|
7116
7162
|
why_it_matters: ParentFindingSchema.shape.why_it_matters,
|
|
7117
7163
|
evidence: ParentFindingSchema.shape.evidence,
|
|
7118
7164
|
suggested_fix: ParentFindingSchema.shape.suggested_fix,
|
|
7119
7165
|
line: ParentFindingSchema.shape.line,
|
|
7120
|
-
disagreement_facts:
|
|
7166
|
+
disagreement_facts: DecisionFactsSchema.optional(),
|
|
7121
7167
|
eligible_agreement_credit: array(AgreementCreditSchema)
|
|
7122
7168
|
.max(MAX_PERSONAS)
|
|
7123
7169
|
.optional(),
|
|
@@ -7129,7 +7175,7 @@ var DeclinedDecisionSchema = object({
|
|
|
7129
7175
|
disposition: literal('declined'),
|
|
7130
7176
|
input_finding_id: PipelineInputIdSchema,
|
|
7131
7177
|
declined_reason: PipelineReasonSchema,
|
|
7132
|
-
disagreement_facts:
|
|
7178
|
+
disagreement_facts: DecisionFactsSchema.optional(),
|
|
7133
7179
|
proposed_route: ProposedRouteSchema.optional(),
|
|
7134
7180
|
route_narrowing_reason: PipelineReasonSchema.optional(),
|
|
7135
7181
|
}).strict()
|
|
@@ -7138,7 +7184,7 @@ var MergeDecisionSchema = discriminatedUnion('disposition', [
|
|
|
7138
7184
|
DeclinedDecisionSchema,
|
|
7139
7185
|
])
|
|
7140
7186
|
var AdjudicationEnvelopeSchema = object({
|
|
7141
|
-
decisions: array(MergeDecisionSchema).max(
|
|
7187
|
+
decisions: array(MergeDecisionSchema).max(MAX_RUN_FINDINGS),
|
|
7142
7188
|
})
|
|
7143
7189
|
.strict()
|
|
7144
7190
|
.superRefine((envelope, ctx) => {
|
|
@@ -7209,7 +7255,7 @@ var MergedFindingSchema = object({
|
|
|
7209
7255
|
requires_verification: ParentFindingSchema.shape.requires_verification,
|
|
7210
7256
|
evidence: ParentFindingSchema.shape.evidence,
|
|
7211
7257
|
suggested_fix: ParentFindingSchema.shape.suggested_fix,
|
|
7212
|
-
input_finding_ids: array(PipelineInputIdSchema).min(1).max(
|
|
7258
|
+
input_finding_ids: array(PipelineInputIdSchema).min(1).max(MAX_RUN_FINDINGS),
|
|
7213
7259
|
agreement_credit: array(AgreementCreditSchema).max(MAX_PERSONAS).optional(),
|
|
7214
7260
|
severity: ParentFindingSchema.shape.severity,
|
|
7215
7261
|
confidence: ParentFindingSchema.shape.confidence,
|
|
@@ -7219,9 +7265,9 @@ var MergedFindingSchema = object({
|
|
|
7219
7265
|
route_narrowing_reason: PipelineReasonSchema.optional(),
|
|
7220
7266
|
}).strict()
|
|
7221
7267
|
var MergeOutputSchema = object({
|
|
7222
|
-
merged_findings: array(MergedFindingSchema).max(
|
|
7223
|
-
validator_requests: array(ValidatorRequestSchema).max(
|
|
7224
|
-
disagreement_facts:
|
|
7268
|
+
merged_findings: array(MergedFindingSchema).max(MAX_RUN_FINDINGS),
|
|
7269
|
+
validator_requests: array(ValidatorRequestSchema).max(MAX_RUN_FINDINGS),
|
|
7270
|
+
disagreement_facts: AggregateFactsSchema,
|
|
7225
7271
|
}).strict()
|
|
7226
7272
|
var ValidatorLifecycleResultSchema = discriminatedUnion('outcome', [
|
|
7227
7273
|
object({ outcome: literal('true') }).strict(),
|
|
@@ -7237,7 +7283,7 @@ var ValidatorLifecycleRecordSchema = object({
|
|
|
7237
7283
|
result: ValidatorLifecycleResultSchema,
|
|
7238
7284
|
}).strict()
|
|
7239
7285
|
var ValidatorLifecycleResultsSchema = array(ValidatorLifecycleRecordSchema).max(
|
|
7240
|
-
|
|
7286
|
+
MAX_RUN_FINDINGS,
|
|
7241
7287
|
)
|
|
7242
7288
|
var PlanAssessmentResultSchema = object({
|
|
7243
7289
|
kind: _enum(['explicit_unmet_requirement', 'inferred_gap']),
|
|
@@ -7245,7 +7291,7 @@ var PlanAssessmentResultSchema = object({
|
|
|
7245
7291
|
}).strict()
|
|
7246
7292
|
var PlanAssessmentEnvelopeSchema = object({
|
|
7247
7293
|
verdict: ReviewArtifactSchema.shape.verdict,
|
|
7248
|
-
results: array(PlanAssessmentResultSchema).max(
|
|
7294
|
+
results: array(PlanAssessmentResultSchema).max(MAX_RUN_FINDINGS),
|
|
7249
7295
|
}).strict()
|
|
7250
7296
|
var ParentRunModeSchema = _enum([
|
|
7251
7297
|
...ReviewArtifactSchema.shape.mode.options,
|
|
@@ -7289,9 +7335,9 @@ var ReportQueueEntrySchema = object({
|
|
|
7289
7335
|
unconfirmed: boolean2(),
|
|
7290
7336
|
}).strict()
|
|
7291
7337
|
var ReportQueuesSchema = object({
|
|
7292
|
-
fixer: array(ReportQueueEntrySchema).max(
|
|
7293
|
-
residual: array(ReportQueueEntrySchema).max(
|
|
7294
|
-
report_only: array(ReportQueueEntrySchema).max(
|
|
7338
|
+
fixer: array(ReportQueueEntrySchema).max(MAX_RUN_FINDINGS),
|
|
7339
|
+
residual: array(ReportQueueEntrySchema).max(MAX_RUN_FINDINGS),
|
|
7340
|
+
report_only: array(ReportQueueEntrySchema).max(MAX_RUN_FINDINGS),
|
|
7295
7341
|
}).strict()
|
|
7296
7342
|
var ReportProjectionSchema = object({
|
|
7297
7343
|
verdict: ReviewArtifactSchema.shape.verdict,
|
|
@@ -7301,11 +7347,11 @@ var ReportProjectionSchema = object({
|
|
|
7301
7347
|
advisory_outputs: ReviewArtifactSchema.shape.advisory_outputs,
|
|
7302
7348
|
coverage: ReviewArtifactSchema.shape.coverage,
|
|
7303
7349
|
input_dispositions: array(FinalizedInputDispositionSchema).max(
|
|
7304
|
-
|
|
7350
|
+
MAX_RUN_FINDINGS,
|
|
7305
7351
|
),
|
|
7306
7352
|
disposition_counts: ReviewArtifactSchema.shape.disposition_counts,
|
|
7307
7353
|
queues: ReportQueuesSchema,
|
|
7308
|
-
pre_existing_findings: array(ReportQueueEntrySchema).max(
|
|
7354
|
+
pre_existing_findings: array(ReportQueueEntrySchema).max(MAX_RUN_FINDINGS),
|
|
7309
7355
|
risk_coverage: ReviewArtifactSchema.shape.risk_coverage,
|
|
7310
7356
|
}).strict()
|
|
7311
7357
|
var FinalizeOutputSchema = discriminatedUnion('kind', [
|
|
@@ -7321,7 +7367,6 @@ var FinalizeOutputSchema = discriminatedUnion('kind', [
|
|
|
7321
7367
|
import fs2 from 'node:fs'
|
|
7322
7368
|
var VALIDATE_REVIEW_RETURN_USAGE = 'Usage: systematic validate-review-return'
|
|
7323
7369
|
var MAX_REVIEW_RETURN_BYTES = 1024 * 1024
|
|
7324
|
-
var MAX_PROJECTED_ISSUE_LINES = 8
|
|
7325
7370
|
var REVIEW_RETURN_VALID_MESSAGE = 'Review return is valid'
|
|
7326
7371
|
var REVIEW_RETURN_EMPTY_MESSAGE = 'Review return is empty'
|
|
7327
7372
|
var REVIEW_RETURN_INVALID_UTF8_MESSAGE = 'Review return is not valid UTF-8'
|
|
@@ -7335,13 +7380,7 @@ var REVIEW_RETURN_TTY_MESSAGE =
|
|
|
7335
7380
|
function validateReviewReturnValue(value) {
|
|
7336
7381
|
const result = SubAgentReturnSchema.safeParse(value)
|
|
7337
7382
|
if (result.success) return { ok: true }
|
|
7338
|
-
const total = result.error.issues
|
|
7339
|
-
const issues = result.error.issues
|
|
7340
|
-
.slice(0, MAX_PROJECTED_ISSUE_LINES)
|
|
7341
|
-
.map((issue) => ({
|
|
7342
|
-
path: formatReviewArtifactIssuePath(issue.path),
|
|
7343
|
-
code: issue.code,
|
|
7344
|
-
}))
|
|
7383
|
+
const { issues, total } = projectZodIssues(result.error.issues)
|
|
7345
7384
|
return { issues, ok: false, total }
|
|
7346
7385
|
}
|
|
7347
7386
|
function formatReviewReturnValidationFailure(total) {
|
|
@@ -7570,7 +7609,7 @@ var STANDARD_CONFIDENCE_FLOOR = 0.6
|
|
|
7570
7609
|
var P0_CONFIDENCE_FLOOR = 0.5
|
|
7571
7610
|
var CONFIDENCE_GATE_SUPPRESSED_REASON = 'confidence below gate threshold'
|
|
7572
7611
|
function rejectPrepare(path, reason) {
|
|
7573
|
-
return { ok: false, rejection: { path, reason } }
|
|
7612
|
+
return { ok: false, rejection: { kind: 'domain', path, reason } }
|
|
7574
7613
|
}
|
|
7575
7614
|
function compareStrings(a, b) {
|
|
7576
7615
|
if (a < b) return -1
|
|
@@ -7740,7 +7779,10 @@ function groupCandidates(survivors) {
|
|
|
7740
7779
|
function prepareReviewCandidates(input) {
|
|
7741
7780
|
const byteLength = payloadByteLength(input.raw_input)
|
|
7742
7781
|
if (byteLength !== undefined && byteLength > AGGREGATE_STDIN_BYTE_CAP) {
|
|
7743
|
-
return rejectPrepare(
|
|
7782
|
+
return rejectPrepare(
|
|
7783
|
+
JSON_ROOT_PATH,
|
|
7784
|
+
`aggregate payload exceeds the byte cap (${AGGREGATE_STDIN_BYTE_CAP} bytes)`,
|
|
7785
|
+
)
|
|
7744
7786
|
}
|
|
7745
7787
|
const parsed = parseRawReturn(input.raw_input)
|
|
7746
7788
|
if (!parsed.ok) {
|
|
@@ -7748,11 +7790,10 @@ function prepareReviewCandidates(input) {
|
|
|
7748
7790
|
}
|
|
7749
7791
|
const validation = PrepareInputSchema.safeParse(parsed.value)
|
|
7750
7792
|
if (!validation.success) {
|
|
7751
|
-
|
|
7752
|
-
|
|
7753
|
-
|
|
7754
|
-
|
|
7755
|
-
return rejectPrepare(issuePath, 'schema validation')
|
|
7793
|
+
return {
|
|
7794
|
+
ok: false,
|
|
7795
|
+
rejection: schemaRejection('schema validation', validation.error.issues),
|
|
7796
|
+
}
|
|
7756
7797
|
}
|
|
7757
7798
|
const {
|
|
7758
7799
|
screen_results: screenResults,
|
|
@@ -7769,17 +7810,26 @@ function prepareReviewCandidates(input) {
|
|
|
7769
7810
|
applyConfidenceGate(screenResults)
|
|
7770
7811
|
const coverageUnion = computeCoverageUnion(selectedDispatches)
|
|
7771
7812
|
const { candidateGroups, singletonIds } = groupCandidates(survivors)
|
|
7772
|
-
const output = PrepareOutputSchema.
|
|
7813
|
+
const output = PrepareOutputSchema.safeParse({
|
|
7773
7814
|
candidate_groups: candidateGroups,
|
|
7774
7815
|
confidence_dispositions: confidenceDispositions,
|
|
7775
7816
|
coverage_union: coverageUnion,
|
|
7776
7817
|
singletons: singletonIds,
|
|
7777
7818
|
surviving_findings: survivingFindings,
|
|
7778
7819
|
})
|
|
7779
|
-
|
|
7820
|
+
if (!output.success) {
|
|
7821
|
+
return {
|
|
7822
|
+
ok: false,
|
|
7823
|
+
rejection: schemaRejection(
|
|
7824
|
+
'prepare output failed schema validation',
|
|
7825
|
+
output.error.issues,
|
|
7826
|
+
),
|
|
7827
|
+
}
|
|
7828
|
+
}
|
|
7829
|
+
return { ok: true, value: output.data }
|
|
7780
7830
|
}
|
|
7781
7831
|
function rejectAdjudication(path, reason) {
|
|
7782
|
-
return { ok: false, rejection: { path, reason } }
|
|
7832
|
+
return { ok: false, rejection: { kind: 'domain', path, reason } }
|
|
7783
7833
|
}
|
|
7784
7834
|
function citedInputIds(decision) {
|
|
7785
7835
|
return decision.disposition === 'merged'
|
|
@@ -7824,13 +7874,13 @@ function validateCitations(decisions, index, suppressed) {
|
|
|
7824
7874
|
for (const [citedIndex, inputId] of citedInputIds(decision).entries()) {
|
|
7825
7875
|
const path = citationPath(decision, decisionIndex, citedIndex)
|
|
7826
7876
|
if (suppressed.has(inputId)) {
|
|
7827
|
-
return { path, reason: 'suppressed input id' }
|
|
7877
|
+
return { kind: 'domain', path, reason: 'suppressed input id' }
|
|
7828
7878
|
}
|
|
7829
7879
|
if (!index.groupIndexByInputId.has(inputId)) {
|
|
7830
|
-
return { path, reason: 'unknown input id' }
|
|
7880
|
+
return { kind: 'domain', path, reason: 'unknown input id' }
|
|
7831
7881
|
}
|
|
7832
7882
|
if (seen.has(inputId)) {
|
|
7833
|
-
return { path, reason: 'duplicate input id citation' }
|
|
7883
|
+
return { kind: 'domain', path, reason: 'duplicate input id citation' }
|
|
7834
7884
|
}
|
|
7835
7885
|
seen.add(inputId)
|
|
7836
7886
|
}
|
|
@@ -7842,6 +7892,7 @@ function validateNoOmissions(candidateGroups, citedIds) {
|
|
|
7842
7892
|
for (const [memberIndex, member] of group.members.entries()) {
|
|
7843
7893
|
if (!citedIds.has(member.input_id)) {
|
|
7844
7894
|
return {
|
|
7895
|
+
kind: 'domain',
|
|
7845
7896
|
path: formatReviewArtifactIssuePath([
|
|
7846
7897
|
'candidate_groups',
|
|
7847
7898
|
groupIndex,
|
|
@@ -7878,6 +7929,7 @@ function validateMergedDecisionConsistency(
|
|
|
7878
7929
|
const groupIndex = index.groupIndexByInputId.get(inputId)
|
|
7879
7930
|
if (groupIndex !== expectedGroupIndex) {
|
|
7880
7931
|
return {
|
|
7932
|
+
kind: 'domain',
|
|
7881
7933
|
path: formatReviewArtifactIssuePath([
|
|
7882
7934
|
'decisions',
|
|
7883
7935
|
decisionIndex,
|
|
@@ -7891,6 +7943,7 @@ function validateMergedDecisionConsistency(
|
|
|
7891
7943
|
const group = candidateGroups[expectedGroupIndex]
|
|
7892
7944
|
if (group && !group.members.some((member) => member.line === decision.line)) {
|
|
7893
7945
|
return {
|
|
7946
|
+
kind: 'domain',
|
|
7894
7947
|
path: formatReviewArtifactIssuePath(['decisions', decisionIndex, 'line']),
|
|
7895
7948
|
reason: 'representative line mismatch',
|
|
7896
7949
|
}
|
|
@@ -7945,7 +7998,107 @@ function buildValidatedPartition(
|
|
|
7945
7998
|
singletons: [...singletons].sort(compareStrings),
|
|
7946
7999
|
}
|
|
7947
8000
|
}
|
|
8001
|
+
function validatePreparedEcho(prepared) {
|
|
8002
|
+
const survivors = new Set(
|
|
8003
|
+
prepared.surviving_findings.map((finding) => finding.input_id),
|
|
8004
|
+
)
|
|
8005
|
+
const members = new Set()
|
|
8006
|
+
const singletons = new Set()
|
|
8007
|
+
return (
|
|
8008
|
+
checkEchoGroupMembers(prepared, survivors, members) ??
|
|
8009
|
+
checkEchoSingletons(prepared, survivors, members, singletons) ??
|
|
8010
|
+
checkEchoSurvivorsAccountedFor(prepared, members, singletons)
|
|
8011
|
+
)
|
|
8012
|
+
}
|
|
8013
|
+
function checkEchoGroupMembers(prepared, survivors, members) {
|
|
8014
|
+
for (const [
|
|
8015
|
+
groupIndex,
|
|
8016
|
+
candidateGroup,
|
|
8017
|
+
] of prepared.candidate_groups.entries()) {
|
|
8018
|
+
for (const [memberIndex, member] of candidateGroup.members.entries()) {
|
|
8019
|
+
const path = formatReviewArtifactIssuePath([
|
|
8020
|
+
'candidate_groups',
|
|
8021
|
+
groupIndex,
|
|
8022
|
+
'members',
|
|
8023
|
+
memberIndex,
|
|
8024
|
+
'input_id',
|
|
8025
|
+
])
|
|
8026
|
+
if (!survivors.has(member.input_id)) {
|
|
8027
|
+
return {
|
|
8028
|
+
kind: 'domain',
|
|
8029
|
+
path,
|
|
8030
|
+
reason: 'prepared survivor missing for input id',
|
|
8031
|
+
}
|
|
8032
|
+
}
|
|
8033
|
+
if (members.has(member.input_id)) {
|
|
8034
|
+
return {
|
|
8035
|
+
kind: 'domain',
|
|
8036
|
+
path,
|
|
8037
|
+
reason: 'duplicate candidate group member',
|
|
8038
|
+
}
|
|
8039
|
+
}
|
|
8040
|
+
members.add(member.input_id)
|
|
8041
|
+
}
|
|
8042
|
+
}
|
|
8043
|
+
return
|
|
8044
|
+
}
|
|
8045
|
+
function checkEchoSingletons(prepared, survivors, members, singletons) {
|
|
8046
|
+
for (const [index, inputId] of prepared.singletons.entries()) {
|
|
8047
|
+
const path = formatReviewArtifactIssuePath(['singletons', index])
|
|
8048
|
+
if (!survivors.has(inputId)) {
|
|
8049
|
+
return {
|
|
8050
|
+
kind: 'domain',
|
|
8051
|
+
path,
|
|
8052
|
+
reason: 'prepared survivor missing for input id',
|
|
8053
|
+
}
|
|
8054
|
+
}
|
|
8055
|
+
if (members.has(inputId)) {
|
|
8056
|
+
return {
|
|
8057
|
+
kind: 'domain',
|
|
8058
|
+
path,
|
|
8059
|
+
reason: 'singleton input id is also a candidate group member',
|
|
8060
|
+
}
|
|
8061
|
+
}
|
|
8062
|
+
if (singletons.has(inputId)) {
|
|
8063
|
+
return {
|
|
8064
|
+
kind: 'domain',
|
|
8065
|
+
path,
|
|
8066
|
+
reason: 'duplicate passthrough singleton input id',
|
|
8067
|
+
}
|
|
8068
|
+
}
|
|
8069
|
+
singletons.add(inputId)
|
|
8070
|
+
}
|
|
8071
|
+
return
|
|
8072
|
+
}
|
|
8073
|
+
function checkEchoSurvivorsAccountedFor(prepared, members, singletons) {
|
|
8074
|
+
const seen = new Set()
|
|
8075
|
+
for (const [index, finding] of prepared.surviving_findings.entries()) {
|
|
8076
|
+
const path = formatReviewArtifactIssuePath([
|
|
8077
|
+
'surviving_findings',
|
|
8078
|
+
index,
|
|
8079
|
+
'input_id',
|
|
8080
|
+
])
|
|
8081
|
+
if (!members.has(finding.input_id) && !singletons.has(finding.input_id)) {
|
|
8082
|
+
return {
|
|
8083
|
+
kind: 'domain',
|
|
8084
|
+
path,
|
|
8085
|
+
reason: 'prepared survivor missing from the partition',
|
|
8086
|
+
}
|
|
8087
|
+
}
|
|
8088
|
+
if (seen.has(finding.input_id)) {
|
|
8089
|
+
return {
|
|
8090
|
+
kind: 'domain',
|
|
8091
|
+
path,
|
|
8092
|
+
reason: 'duplicate prepared survivor input id',
|
|
8093
|
+
}
|
|
8094
|
+
}
|
|
8095
|
+
seen.add(finding.input_id)
|
|
8096
|
+
}
|
|
8097
|
+
return
|
|
8098
|
+
}
|
|
7948
8099
|
function validateAdjudication(prepared, decisions) {
|
|
8100
|
+
const echoViolation = validatePreparedEcho(prepared)
|
|
8101
|
+
if (echoViolation) return { ok: false, rejection: echoViolation }
|
|
7949
8102
|
if (prepared.candidate_groups.length === 0) {
|
|
7950
8103
|
if (decisions.length > 0) {
|
|
7951
8104
|
return rejectAdjudication(
|
|
@@ -7996,7 +8149,7 @@ function validateAdjudication(prepared, decisions) {
|
|
|
7996
8149
|
}
|
|
7997
8150
|
}
|
|
7998
8151
|
function rejectMergedFinding(path, reason) {
|
|
7999
|
-
return { ok: false, rejection: { path, reason } }
|
|
8152
|
+
return { ok: false, rejection: { kind: 'domain', path, reason } }
|
|
8000
8153
|
}
|
|
8001
8154
|
var SEVERITY_RANK = {
|
|
8002
8155
|
P0: 0,
|
|
@@ -8353,6 +8506,7 @@ function checkNoDuplicateAssembledFindingIds(origins) {
|
|
|
8353
8506
|
const priorOrigin = seen.get(entry.finding_id)
|
|
8354
8507
|
if (priorOrigin !== undefined) {
|
|
8355
8508
|
return {
|
|
8509
|
+
kind: 'domain',
|
|
8356
8510
|
path: formatReviewArtifactIssuePath([
|
|
8357
8511
|
'merge_assembly',
|
|
8358
8512
|
index,
|
|
@@ -8441,17 +8595,27 @@ function applyReviewAdjudication(input) {
|
|
|
8441
8595
|
file: assembly.file,
|
|
8442
8596
|
line: assembly.line,
|
|
8443
8597
|
}))
|
|
8444
|
-
return {
|
|
8445
|
-
|
|
8446
|
-
|
|
8447
|
-
|
|
8448
|
-
|
|
8449
|
-
|
|
8450
|
-
|
|
8598
|
+
return parseMergeOutput({
|
|
8599
|
+
merged_findings: mergedFindings,
|
|
8600
|
+
validator_requests: validatorRequests,
|
|
8601
|
+
disagreement_facts: disagreementFacts,
|
|
8602
|
+
})
|
|
8603
|
+
}
|
|
8604
|
+
function parseMergeOutput(candidate) {
|
|
8605
|
+
const output = MergeOutputSchema.safeParse(candidate)
|
|
8606
|
+
if (!output.success) {
|
|
8607
|
+
return {
|
|
8608
|
+
ok: false,
|
|
8609
|
+
rejection: schemaRejection(
|
|
8610
|
+
'merge output failed schema validation',
|
|
8611
|
+
output.error.issues,
|
|
8612
|
+
),
|
|
8613
|
+
}
|
|
8451
8614
|
}
|
|
8615
|
+
return { ok: true, value: output.data }
|
|
8452
8616
|
}
|
|
8453
8617
|
function rejectReconcile(path, reason) {
|
|
8454
|
-
return { ok: false, rejection: { path, reason } }
|
|
8618
|
+
return { ok: false, rejection: { kind: 'domain', path, reason } }
|
|
8455
8619
|
}
|
|
8456
8620
|
function indexLifecycleResults(results, requestedIds) {
|
|
8457
8621
|
const resultsByFindingId = new Map()
|
|
@@ -8475,6 +8639,7 @@ function validateNoMissingResults(validatorRequests, resultsByFindingId) {
|
|
|
8475
8639
|
for (const [index, request] of validatorRequests.entries()) {
|
|
8476
8640
|
if (!resultsByFindingId.has(request.finding_id)) {
|
|
8477
8641
|
return {
|
|
8642
|
+
kind: 'domain',
|
|
8478
8643
|
path: formatReviewArtifactIssuePath([
|
|
8479
8644
|
'validator_requests',
|
|
8480
8645
|
index,
|
|
@@ -8556,7 +8721,7 @@ function reconcileValidatorResults(input) {
|
|
|
8556
8721
|
}
|
|
8557
8722
|
}
|
|
8558
8723
|
function rejectFinalizeContext(path, reason) {
|
|
8559
|
-
return { ok: false, rejection: { path, reason } }
|
|
8724
|
+
return { ok: false, rejection: { kind: 'domain', path, reason } }
|
|
8560
8725
|
}
|
|
8561
8726
|
function normalizeSelectionSurface(surface) {
|
|
8562
8727
|
if (surface === undefined) return
|
|
@@ -8687,6 +8852,7 @@ function checkValidatorRequestsResolve(validatorRequests, mergedFindings) {
|
|
|
8687
8852
|
validatorRequestMismatches(request, findingById, expectedFindingIds)
|
|
8688
8853
|
) {
|
|
8689
8854
|
return {
|
|
8855
|
+
kind: 'domain',
|
|
8690
8856
|
path,
|
|
8691
8857
|
reason: 'validator request references unknown merged finding',
|
|
8692
8858
|
}
|
|
@@ -8695,6 +8861,7 @@ function checkValidatorRequestsResolve(validatorRequests, mergedFindings) {
|
|
|
8695
8861
|
}
|
|
8696
8862
|
if (seenFindingIds.size !== expectedFindingIds.size) {
|
|
8697
8863
|
return {
|
|
8864
|
+
kind: 'domain',
|
|
8698
8865
|
path: formatReviewArtifactIssuePath(['merge', 'validator_requests']),
|
|
8699
8866
|
reason: 'validator request references unknown merged finding',
|
|
8700
8867
|
}
|
|
@@ -8888,6 +9055,7 @@ function checkMergedFindingsMatchDerivation(
|
|
|
8888
9055
|
})
|
|
8889
9056
|
) {
|
|
8890
9057
|
return {
|
|
9058
|
+
kind: 'domain',
|
|
8891
9059
|
path: formatReviewArtifactIssuePath([
|
|
8892
9060
|
'merge',
|
|
8893
9061
|
'merged_findings',
|
|
@@ -8898,6 +9066,7 @@ function checkMergedFindingsMatchDerivation(
|
|
|
8898
9066
|
}
|
|
8899
9067
|
if (mergedFindingRouteReasonMismatch(finding, meet)) {
|
|
8900
9068
|
return {
|
|
9069
|
+
kind: 'domain',
|
|
8901
9070
|
path: formatReviewArtifactIssuePath([
|
|
8902
9071
|
'merge',
|
|
8903
9072
|
'merged_findings',
|
|
@@ -8915,6 +9084,7 @@ function checkNoDuplicateConfidenceDispositions(confidenceDispositions) {
|
|
|
8915
9084
|
for (const [index, entry] of confidenceDispositions.entries()) {
|
|
8916
9085
|
if (seen.has(entry.input_id)) {
|
|
8917
9086
|
return {
|
|
9087
|
+
kind: 'domain',
|
|
8918
9088
|
path: formatReviewArtifactIssuePath([
|
|
8919
9089
|
'prepared',
|
|
8920
9090
|
'confidence_dispositions',
|
|
@@ -8955,6 +9125,7 @@ function checkConfidenceDispositionsResolveScreenedFindings(
|
|
|
8955
9125
|
] of prepared.confidence_dispositions.entries()) {
|
|
8956
9126
|
if (screenedCounts.get(disposition.input_id) !== 1) {
|
|
8957
9127
|
return {
|
|
9128
|
+
kind: 'domain',
|
|
8958
9129
|
path: formatReviewArtifactIssuePath([
|
|
8959
9130
|
'prepared',
|
|
8960
9131
|
'confidence_dispositions',
|
|
@@ -8969,6 +9140,7 @@ function checkConfidenceDispositionsResolveScreenedFindings(
|
|
|
8969
9140
|
const screened = screenedByInputId.get(survivor.input_id)
|
|
8970
9141
|
if (screened === undefined) {
|
|
8971
9142
|
return {
|
|
9143
|
+
kind: 'domain',
|
|
8972
9144
|
path: formatReviewArtifactIssuePath([
|
|
8973
9145
|
'prepared',
|
|
8974
9146
|
'surviving_findings',
|
|
@@ -8987,6 +9159,7 @@ function checkConfidenceDispositionsResolveScreenedFindings(
|
|
|
8987
9159
|
screened.severity !== survivor.severity
|
|
8988
9160
|
) {
|
|
8989
9161
|
return {
|
|
9162
|
+
kind: 'domain',
|
|
8990
9163
|
path: formatReviewArtifactIssuePath([
|
|
8991
9164
|
'prepared',
|
|
8992
9165
|
'surviving_findings',
|
|
@@ -8996,6 +9169,34 @@ function checkConfidenceDispositionsResolveScreenedFindings(
|
|
|
8996
9169
|
}
|
|
8997
9170
|
}
|
|
8998
9171
|
}
|
|
9172
|
+
return checkScreenedFindingsHaveOneDisposition(prepared, screenResults)
|
|
9173
|
+
}
|
|
9174
|
+
function checkScreenedFindingsHaveOneDisposition(prepared, screenResults) {
|
|
9175
|
+
const dispositionCounts = new Map()
|
|
9176
|
+
for (const disposition of prepared.confidence_dispositions) {
|
|
9177
|
+
dispositionCounts.set(
|
|
9178
|
+
disposition.input_id,
|
|
9179
|
+
(dispositionCounts.get(disposition.input_id) ?? 0) + 1,
|
|
9180
|
+
)
|
|
9181
|
+
}
|
|
9182
|
+
for (const [resultIndex, result] of screenResults.entries()) {
|
|
9183
|
+
for (const [index, finding] of result.result.admitted_findings.entries()) {
|
|
9184
|
+
if (dispositionCounts.get(finding.input_id) !== 1) {
|
|
9185
|
+
return {
|
|
9186
|
+
kind: 'domain',
|
|
9187
|
+
path: formatReviewArtifactIssuePath([
|
|
9188
|
+
'screen_results',
|
|
9189
|
+
resultIndex,
|
|
9190
|
+
'result',
|
|
9191
|
+
'admitted_findings',
|
|
9192
|
+
index,
|
|
9193
|
+
'input_id',
|
|
9194
|
+
]),
|
|
9195
|
+
reason: 'screened finding lacks exactly one confidence disposition',
|
|
9196
|
+
}
|
|
9197
|
+
}
|
|
9198
|
+
}
|
|
9199
|
+
}
|
|
8999
9200
|
return
|
|
9000
9201
|
}
|
|
9001
9202
|
function findUnavailableCitedReviewer(
|
|
@@ -9016,6 +9217,7 @@ function findUnavailableCitedReviewer(
|
|
|
9016
9217
|
return {
|
|
9017
9218
|
citedReviewers,
|
|
9018
9219
|
rejection: {
|
|
9220
|
+
kind: 'domain',
|
|
9019
9221
|
path: formatReviewArtifactIssuePath([
|
|
9020
9222
|
'merge',
|
|
9021
9223
|
'merged_findings',
|
|
@@ -9034,6 +9236,7 @@ function findUnsupportedSubmitter(finding, findingIndex, citedReviewers) {
|
|
|
9034
9236
|
for (const [submitterIndex, submitter] of finding.submitters.entries()) {
|
|
9035
9237
|
if (!citedReviewers.has(submitter)) {
|
|
9036
9238
|
return {
|
|
9239
|
+
kind: 'domain',
|
|
9037
9240
|
path: formatReviewArtifactIssuePath([
|
|
9038
9241
|
'merge',
|
|
9039
9242
|
'merged_findings',
|
|
@@ -9053,6 +9256,7 @@ function findOverlappingAgreementCredit(finding, findingIndex) {
|
|
|
9053
9256
|
for (const [creditIndex, credit] of agreementCredit.entries()) {
|
|
9054
9257
|
if (submitterSet.has(credit)) {
|
|
9055
9258
|
return {
|
|
9259
|
+
kind: 'domain',
|
|
9056
9260
|
path: formatReviewArtifactIssuePath([
|
|
9057
9261
|
'merge',
|
|
9058
9262
|
'merged_findings',
|
|
@@ -9245,6 +9449,7 @@ function deriveInputDispositions(
|
|
|
9245
9449
|
return {
|
|
9246
9450
|
ok: false,
|
|
9247
9451
|
rejection: {
|
|
9452
|
+
kind: 'domain',
|
|
9248
9453
|
path: formatReviewArtifactIssuePath([
|
|
9249
9454
|
'prepared',
|
|
9250
9455
|
'confidence_dispositions',
|
|
@@ -9675,18 +9880,22 @@ function buildInputLedger(input) {
|
|
|
9675
9880
|
function dedupeSortedStrings(values) {
|
|
9676
9881
|
return [...new Set(values)].sort(compareStrings)
|
|
9677
9882
|
}
|
|
9883
|
+
function dedupeSortedNonBlankStrings(values) {
|
|
9884
|
+
return dedupeSortedStrings(values.filter((value) => value.trim() !== ''))
|
|
9885
|
+
}
|
|
9678
9886
|
function checkCoverageArrayBound(field, values) {
|
|
9679
|
-
if (values.length <=
|
|
9887
|
+
if (values.length <= COVERAGE_BOUNDS[field]) return
|
|
9680
9888
|
return {
|
|
9889
|
+
kind: 'domain',
|
|
9681
9890
|
path: formatReviewArtifactIssuePath(['coverage', field]),
|
|
9682
9891
|
reason: 'coverage array exceeds bound',
|
|
9683
9892
|
}
|
|
9684
9893
|
}
|
|
9685
9894
|
function buildReviewCoverage(input) {
|
|
9686
|
-
const residualRisks =
|
|
9895
|
+
const residualRisks = dedupeSortedNonBlankStrings(
|
|
9687
9896
|
input.screen_results.flatMap((result) => result.result.residual_risks),
|
|
9688
9897
|
)
|
|
9689
|
-
const testingGaps =
|
|
9898
|
+
const testingGaps = dedupeSortedNonBlankStrings(
|
|
9690
9899
|
input.screen_results.flatMap((result) => result.result.testing_gaps),
|
|
9691
9900
|
)
|
|
9692
9901
|
const failedReviewers = dedupeSortedStrings(
|
|
@@ -9848,6 +10057,7 @@ function checkRiskCoverageSemantics(artifactCandidate) {
|
|
|
9848
10057
|
return {
|
|
9849
10058
|
ok: false,
|
|
9850
10059
|
rejection: {
|
|
10060
|
+
kind: 'domain',
|
|
9851
10061
|
path: formatReviewArtifactIssuePath([
|
|
9852
10062
|
'risk_coverage',
|
|
9853
10063
|
coverageIndex,
|
|
@@ -9874,6 +10084,7 @@ function checkDispositionCountsReconcileLedger(dispositionCounts, ledger) {
|
|
|
9874
10084
|
return {
|
|
9875
10085
|
ok: false,
|
|
9876
10086
|
rejection: {
|
|
10087
|
+
kind: 'domain',
|
|
9877
10088
|
path: formatReviewArtifactIssuePath(['disposition_counts']),
|
|
9878
10089
|
reason:
|
|
9879
10090
|
'disposition counts do not reconcile with the admitted input ledger',
|
|
@@ -9918,15 +10129,12 @@ function buildReportProjection(
|
|
|
9918
10129
|
function parseFinalizeOutput(output) {
|
|
9919
10130
|
const parsed = FinalizeOutputSchema.safeParse(output)
|
|
9920
10131
|
if (!parsed.success) {
|
|
9921
|
-
const issue = parsed.error.issues[0]
|
|
9922
10132
|
return {
|
|
9923
10133
|
ok: false,
|
|
9924
|
-
rejection:
|
|
9925
|
-
|
|
9926
|
-
|
|
9927
|
-
|
|
9928
|
-
reason: 'finalize output failed schema validation',
|
|
9929
|
-
},
|
|
10134
|
+
rejection: schemaRejection(
|
|
10135
|
+
'finalize output failed schema validation',
|
|
10136
|
+
parsed.error.issues,
|
|
10137
|
+
),
|
|
9930
10138
|
}
|
|
9931
10139
|
}
|
|
9932
10140
|
return { ok: true, value: parsed.data }
|
|
@@ -10034,15 +10242,12 @@ function finalizeReview(input) {
|
|
|
10034
10242
|
}
|
|
10035
10243
|
const parsedArtifact = ReviewArtifactSchema.safeParse(artifact)
|
|
10036
10244
|
if (!parsedArtifact.success) {
|
|
10037
|
-
const issue = parsedArtifact.error.issues[0]
|
|
10038
10245
|
return {
|
|
10039
10246
|
ok: false,
|
|
10040
|
-
rejection:
|
|
10041
|
-
|
|
10042
|
-
|
|
10043
|
-
|
|
10044
|
-
reason: 'artifact failed schema validation',
|
|
10045
|
-
},
|
|
10247
|
+
rejection: schemaRejection(
|
|
10248
|
+
'artifact failed schema validation',
|
|
10249
|
+
parsedArtifact.error.issues,
|
|
10250
|
+
),
|
|
10046
10251
|
}
|
|
10047
10252
|
}
|
|
10048
10253
|
return parseFinalizeOutput({
|
|
@@ -10074,8 +10279,7 @@ var CE_REVIEW_PREPARE_STDIN_TTY_MESSAGE =
|
|
|
10074
10279
|
'prepare reads one aggregate JSON envelope from stdin; interactive input is not supported'
|
|
10075
10280
|
var CE_REVIEW_PREPARE_STDIN_READ_FAILED_MESSAGE =
|
|
10076
10281
|
'prepare could not read the aggregate envelope from stdin'
|
|
10077
|
-
var CE_REVIEW_PREPARE_STDIN_OVERSIZED_MESSAGE =
|
|
10078
|
-
'prepare input exceeds the aggregate byte cap'
|
|
10282
|
+
var CE_REVIEW_PREPARE_STDIN_OVERSIZED_MESSAGE = `prepare input exceeds the aggregate byte cap (${AGGREGATE_STDIN_BYTE_CAP} bytes)`
|
|
10079
10283
|
var CE_REVIEW_PREPARE_STDIN_INVALID_UTF8_MESSAGE =
|
|
10080
10284
|
'prepare input is not valid UTF-8'
|
|
10081
10285
|
var CE_REVIEW_PREPARE_STDIN_EMPTY_MESSAGE = 'prepare received empty stdin'
|
|
@@ -10086,8 +10290,7 @@ var CE_REVIEW_MERGE_STDIN_TTY_MESSAGE =
|
|
|
10086
10290
|
'merge reads one aggregate JSON envelope from stdin; interactive input is not supported'
|
|
10087
10291
|
var CE_REVIEW_MERGE_STDIN_READ_FAILED_MESSAGE =
|
|
10088
10292
|
'merge could not read the aggregate envelope from stdin'
|
|
10089
|
-
var CE_REVIEW_MERGE_STDIN_OVERSIZED_MESSAGE =
|
|
10090
|
-
'merge input exceeds the aggregate byte cap'
|
|
10293
|
+
var CE_REVIEW_MERGE_STDIN_OVERSIZED_MESSAGE = `merge input exceeds the aggregate byte cap (${AGGREGATE_STDIN_BYTE_CAP} bytes)`
|
|
10091
10294
|
var CE_REVIEW_MERGE_STDIN_INVALID_UTF8_MESSAGE =
|
|
10092
10295
|
'merge input is not valid UTF-8'
|
|
10093
10296
|
var CE_REVIEW_MERGE_STDIN_EMPTY_MESSAGE = 'merge received empty stdin'
|
|
@@ -10097,8 +10300,7 @@ var CE_REVIEW_FINALIZE_STDIN_TTY_MESSAGE =
|
|
|
10097
10300
|
'finalize reads one aggregate JSON envelope from stdin; interactive input is not supported'
|
|
10098
10301
|
var CE_REVIEW_FINALIZE_STDIN_READ_FAILED_MESSAGE =
|
|
10099
10302
|
'finalize could not read the aggregate envelope from stdin'
|
|
10100
|
-
var CE_REVIEW_FINALIZE_STDIN_OVERSIZED_MESSAGE =
|
|
10101
|
-
'finalize input exceeds the aggregate byte cap'
|
|
10303
|
+
var CE_REVIEW_FINALIZE_STDIN_OVERSIZED_MESSAGE = `finalize input exceeds the aggregate byte cap (${AGGREGATE_STDIN_BYTE_CAP} bytes)`
|
|
10102
10304
|
var CE_REVIEW_FINALIZE_STDIN_INVALID_UTF8_MESSAGE =
|
|
10103
10305
|
'finalize input is not valid UTF-8'
|
|
10104
10306
|
var CE_REVIEW_FINALIZE_STDIN_EMPTY_MESSAGE = 'finalize received empty stdin'
|
|
@@ -10132,8 +10334,21 @@ function parseScreenFlags(argv) {
|
|
|
10132
10334
|
}
|
|
10133
10335
|
return { harness, ok: true, reviewer }
|
|
10134
10336
|
}
|
|
10135
|
-
function
|
|
10136
|
-
|
|
10337
|
+
function formatAggregateRejection(rejectedMessage, rejection) {
|
|
10338
|
+
switch (rejection.kind) {
|
|
10339
|
+
case 'schema':
|
|
10340
|
+
return [
|
|
10341
|
+
`${rejectedMessage}: ${rejection.reason}`,
|
|
10342
|
+
...formatProjectedIssueLines(rejection),
|
|
10343
|
+
].join(`
|
|
10344
|
+
`)
|
|
10345
|
+
case 'domain':
|
|
10346
|
+
return `${rejectedMessage}: ${rejection.reason} at ${rejection.path}`
|
|
10347
|
+
default: {
|
|
10348
|
+
const unhandled = rejection
|
|
10349
|
+
throw new Error(`Unhandled rejection kind: ${String(unhandled)}`)
|
|
10350
|
+
}
|
|
10351
|
+
}
|
|
10137
10352
|
}
|
|
10138
10353
|
function runScreenSubcommand(options, outputSink, errorSink) {
|
|
10139
10354
|
const flags = parseScreenFlags(options.argv.slice(1))
|
|
@@ -10219,7 +10434,7 @@ function runPrepareSubcommand(options, outputSink, errorSink) {
|
|
|
10219
10434
|
const result = prepareReviewCandidates({ raw_input: text })
|
|
10220
10435
|
if (!result.ok) {
|
|
10221
10436
|
errorSink(
|
|
10222
|
-
|
|
10437
|
+
formatAggregateRejection(
|
|
10223
10438
|
CE_REVIEW_PREPARE_REJECTED_MESSAGE,
|
|
10224
10439
|
result.rejection,
|
|
10225
10440
|
),
|
|
@@ -10268,27 +10483,30 @@ function runAggregateStdinSubcommand(options, outputSink, errorSink, spec) {
|
|
|
10268
10483
|
try {
|
|
10269
10484
|
value = JSON.parse(text)
|
|
10270
10485
|
} catch {
|
|
10271
|
-
errorSink(
|
|
10486
|
+
errorSink(
|
|
10487
|
+
formatAggregateRejection(spec.rejectedMessage, {
|
|
10488
|
+
kind: 'domain',
|
|
10489
|
+
path: '$',
|
|
10490
|
+
reason: 'malformed JSON',
|
|
10491
|
+
}),
|
|
10492
|
+
)
|
|
10272
10493
|
return 1
|
|
10273
10494
|
}
|
|
10274
10495
|
const parsed = spec.schema.safeParse(value)
|
|
10275
10496
|
if (!parsed.success) {
|
|
10276
|
-
const issue = parsed.error.issues[0]
|
|
10277
10497
|
errorSink(
|
|
10278
|
-
|
|
10279
|
-
?
|
|
10280
|
-
|
|
10281
|
-
|
|
10282
|
-
|
|
10498
|
+
parsed.error.issues.length > 0
|
|
10499
|
+
? formatAggregateRejection(
|
|
10500
|
+
spec.rejectedMessage,
|
|
10501
|
+
schemaRejection('schema validation', parsed.error.issues),
|
|
10502
|
+
)
|
|
10283
10503
|
: spec.rejectedMessage,
|
|
10284
10504
|
)
|
|
10285
10505
|
return 1
|
|
10286
10506
|
}
|
|
10287
10507
|
const result = spec.execute(parsed.data)
|
|
10288
10508
|
if (!result.ok) {
|
|
10289
|
-
errorSink(
|
|
10290
|
-
formatAggregateRejectionMessage(spec.rejectedMessage, result.rejection),
|
|
10291
|
-
)
|
|
10509
|
+
errorSink(formatAggregateRejection(spec.rejectedMessage, result.rejection))
|
|
10292
10510
|
return 1
|
|
10293
10511
|
}
|
|
10294
10512
|
outputSink(JSON.stringify(result.value))
|
|
@@ -10439,5 +10657,6 @@ export {
|
|
|
10439
10657
|
CE_REVIEW_SCREEN_STDIN_TTY_MESSAGE,
|
|
10440
10658
|
CE_REVIEW_SCREEN_USAGE,
|
|
10441
10659
|
CE_REVIEW_VALIDATOR_USAGE,
|
|
10660
|
+
formatAggregateRejection,
|
|
10442
10661
|
runCeReviewValidator,
|
|
10443
10662
|
}
|