@fro.bot/systematic 3.33.2 → 3.35.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.
@@ -23,7 +23,8 @@ Return ONLY valid JSON matching this schema. No prose, no markdown, no explanati
23
23
 
24
24
  Rules:
25
25
  - You are a leaf validator inside an already-running review workflow. Do not invoke systematic skills or agents. Perform your analysis directly and return the JSON verdict only.
26
- - You are operationally read-only. You may use non-mutating inspection tools (file reads, glob, grep, git log, git diff, git show, git blame, gh pr view) to examine the code. Do not edit project files, change branches, commit, push, create PRs, or otherwise mutate the checkout or repository state.
26
+ - You are operationally read-only. You may use non-mutating inspection tools (file reads, glob, grep, git blame, gh pr view, and the pinned-scope reads described in `<pinned-scope>`) to examine the code. Do not edit project files, change branches, commit, push, create PRs, or otherwise mutate the checkout or repository state.
27
+ - You are static. Never run a build, typecheck, or lint at any scope, and never run a test or a probe, including `bun test`, `bun run typecheck`, `bunx tsc`, any alias or wrapper of them, or a named test file whose runner expands to a suite. CI owns those gates. You are given no approved command: decide from the code as written, and when it cannot settle the question, follow the conservative rule below.
27
28
  - Answer the three validation questions below. Set `outcome: "true"` only when all three answers are YES. Set `outcome: "false"` when any answer is NO.
28
29
  - A `false` verdict needs a `reason` of one sentence. State the specific code evidence that drove your verdict (file name, function name, or line reference when relevant). Do not repeat the finding title verbatim. A `true` verdict carries no reason.
29
30
  - Return `failed` with a reason when your analysis could not be completed, and `unavailable` with a reason when the code or tools you need could not be reached. Never guess a verdict to avoid either.
@@ -47,6 +48,16 @@ Set `outcome: "true"` only when: the issue is real (Q1 YES), introduced by this
47
48
  Set `outcome: "false"` when any question is NO, and state which question failed and why in `reason`.
48
49
  </validation-questions>
49
50
 
51
+ <pinned-scope>
52
+ You receive the same pinned scope as the reviewers: the checkout path, base SHA, head, and manifest in the review context. Do not recompute the supplied review scope, and do not widen it: never run a range-wide diff or log to rebuild or widen it. Run every git command against the pinned checkout.
53
+
54
+ - Diff of the cited path, when the head is a commit: `git -C <checkout_path> diff -U10 <base_sha> <head> -- <path>`.
55
+ - Diff of the cited path, when the head is "working tree": `git -C <checkout_path> diff -U10 <base_sha> -- <path>`.
56
+ - A renamed path (status `R`): pass the rename source and the path together in the same diff.
57
+ - Old source: `git -C <checkout_path> show <base_sha>:<path>`. For a deleted file (status `D`) the finding cites the base-side path and line, so verify it with this command. For a renamed path, read the old source from the rename source.
58
+ - Surrounding code that the diff does not touch: read it in the checkout.
59
+ </pinned-scope>
60
+
50
61
  <finding>
51
62
  Title: {finding_title}
52
63
  Severity: {finding_severity}
@@ -61,10 +72,14 @@ Suggested fix: {finding_suggested_fix}
61
72
  <review-context>
62
73
  Intent: {intent_summary}
63
74
 
64
- Changed files: {file_list}
75
+ Checkout: {checkout_path}
76
+
77
+ Base SHA: {base_sha}
78
+
79
+ Head: {head}
65
80
 
66
- Diff:
67
- {diff}
81
+ Manifest (path, status, rename source, added lines, deleted lines):
82
+ {manifest}
68
83
  </review-context>
69
84
  ```
70
85
 
@@ -83,15 +98,18 @@ Diff:
83
98
  | `{finding_requires_verification}` | Stage 5 merged finding | Boolean from the merged finding |
84
99
  | `{finding_suggested_fix}` | Stage 5 merged finding | Suggested fix text, or "none" |
85
100
  | `{intent_summary}` | Stage 2 output | 2–3 line description of what the change is trying to accomplish |
86
- | `{file_list}` | Stage 1 output | List of changed files from the scope step |
87
- | `{diff}` | Stage 1 output | The actual diff content to review |
101
+ | `{checkout_path}` | Stage 1 pinned scope | The absolute path of the authoritative checkout. Every git command targets it |
102
+ | `{base_sha}` | Stage 1 pinned scope | The full base SHA. Old source, including a deleted file's, comes from this commit |
103
+ | `{head}` | Stage 1 pinned scope | The checked-out commit SHA, or `working tree` when the checkout was dirty. It selects how a path's diff is read |
104
+ | `{manifest}` | Stage 1 pinned scope | One entry per changed path: path, status (`A`, `M`, `D`, `R`, or `T`), rename source, and added and deleted line counts |
88
105
 
89
106
  ---
90
107
 
91
108
  ## Dispatch Notes
92
109
 
93
110
  - Dispatch one validator subagent per gated finding. Run them in bounded batches, sized to what the harness handles reliably: the validators of a batch run in parallel, and a batch finishes before the next starts.
94
- - Pass the full diff and file list so the validator can inspect surrounding context, not just the cited line.
111
+ - Pass the same pinned checkout path, base SHA, head, and manifest the reviewers received, so the validator verifies cited source against the same tree. Pass no inline diff: the validator reads the cited path's diff from git and can inspect surrounding context in the checkout, not just the cited line.
112
+ - Validators stay static in every mode. Do not pass an approved command or ask a validator to run one; a probe is a parent decision and never a validator task.
95
113
  - The validator returns `{outcome, reason?}`. Record it as that finding's lifecycle result, keyed by `finding_id`, and carry it into `finalize` as `validator_lifecycle_results`.
96
114
  - **Never drop a finding based on the validator verdict.** A finding with `outcome: "false"` moves to the "Filtered (not validated)" presentation group in Stage 6. It is never removed from the report.
97
115
  - If a validator subagent fails, times out, or returns nothing, record `failed` or `unavailable` with a reason. The finding stays actionable and unvalidated, and `finalize` records a lifecycle failure that marks the run degraded. Report that validator in the Coverage section. Do not treat the finding as validated.
@@ -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: 8efcba72f9317848bb9f5c6c58e71e1f6d69e6330ec724bbd48d5b24ffce2e1a
5
+ // source-digest: e69a234bb1fbc469b0cab7623dc63109658c24640d47b615d41a683db8dd1a96
6
6
  var __defProp = Object.defineProperty
7
7
  var __returnValue = (v) => v
8
8
  function __exportSetter(name, newValue) {
@@ -54,6 +54,24 @@ function projectZodIssues(issues, max = MAX_PROJECTED_ISSUE_LINES) {
54
54
  total: issues.length,
55
55
  }
56
56
  }
57
+ function allowedValuesOf(issue) {
58
+ if (issue.code !== 'invalid_value' || issue.values === undefined) {
59
+ return
60
+ }
61
+ const allowed = issue.values.filter((value) => typeof value === 'string')
62
+ return allowed.length > 0 ? allowed : undefined
63
+ }
64
+ function projectRejectionIssues(issues, max = MAX_PROJECTED_ISSUE_LINES) {
65
+ const projected = projectZodIssues(issues, max)
66
+ return {
67
+ issues: projected.issues.map((entry, index) => {
68
+ const source = issues[index]
69
+ const allowed = source === undefined ? undefined : allowedValuesOf(source)
70
+ return allowed === undefined ? entry : { ...entry, allowed }
71
+ }),
72
+ total: projected.total,
73
+ }
74
+ }
57
75
  function schemaRejection(reason, zodIssues) {
58
76
  const { issues, total } = projectZodIssues(zodIssues)
59
77
  return {
@@ -7361,131 +7379,6 @@ var FinalizeOutputSchema = discriminatedUnion('kind', [
7361
7379
  ReportProjectionSchema.extend({ kind: literal('report_only') }).strict(),
7362
7380
  ])
7363
7381
 
7364
- // src/lib/review-return-validator.ts
7365
- import fs2 from 'node:fs'
7366
- var VALIDATE_REVIEW_RETURN_USAGE = 'Usage: systematic validate-review-return'
7367
- var MAX_REVIEW_RETURN_BYTES = 1024 * 1024
7368
- var REVIEW_RETURN_VALID_MESSAGE = 'Review return is valid'
7369
- var REVIEW_RETURN_EMPTY_MESSAGE = 'Review return is empty'
7370
- var REVIEW_RETURN_INVALID_UTF8_MESSAGE = 'Review return is not valid UTF-8'
7371
- var REVIEW_RETURN_MALFORMED_JSON_MESSAGE = 'Review return is not valid JSON'
7372
- var REVIEW_RETURN_OVERSIZED_MESSAGE =
7373
- 'Review return exceeds the 1 MiB input limit'
7374
- var REVIEW_RETURN_READ_FAILED_MESSAGE =
7375
- 'Review return could not be read from stdin'
7376
- var REVIEW_RETURN_TTY_MESSAGE =
7377
- 'validate-review-return reads one JSON document from stdin; interactive input is not supported'
7378
- function validateReviewReturnValue(value) {
7379
- const result = SubAgentReturnSchema.safeParse(value)
7380
- if (result.success) return { ok: true }
7381
- const { issues, total } = projectZodIssues(result.error.issues)
7382
- return { issues, ok: false, total }
7383
- }
7384
- function formatReviewReturnValidationFailure(total) {
7385
- return `Review return validation failed: ${total} issue(s)`
7386
- }
7387
- var READ_CHUNK_BYTES = 64 * 1024
7388
- function defaultReadChunk(fd, buffer, offset, length, position) {
7389
- return fs2.readSync(fd, buffer, offset, length, position)
7390
- }
7391
- var TRANSIENT_READ_RETRY_MS = 1
7392
- function isTransientReadError(error) {
7393
- if (typeof error !== 'object' || error === null) return false
7394
- const code = error.code
7395
- return code === 'EAGAIN' || code === 'EWOULDBLOCK'
7396
- }
7397
- function sleepSync(milliseconds) {
7398
- Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, milliseconds)
7399
- }
7400
- function readChunkWithRetry(fd, buffer, toRead, readChunk) {
7401
- for (;;) {
7402
- try {
7403
- return {
7404
- bytesRead: readChunk(fd, buffer, 0, toRead, null),
7405
- status: 'ok',
7406
- }
7407
- } catch (error) {
7408
- if (!isTransientReadError(error)) return { status: 'read-error' }
7409
- sleepSync(TRANSIENT_READ_RETRY_MS)
7410
- }
7411
- }
7412
- }
7413
- function readBoundedStdin(fd, readChunk, maxBytes = MAX_REVIEW_RETURN_BYTES) {
7414
- const chunks = []
7415
- let total = 0
7416
- while (true) {
7417
- const remaining = maxBytes + 1 - total
7418
- if (remaining <= 0) return { status: 'oversized' }
7419
- const toRead = Math.min(READ_CHUNK_BYTES, remaining)
7420
- const buffer = Buffer.allocUnsafe(toRead)
7421
- const read = readChunkWithRetry(fd, buffer, toRead, readChunk)
7422
- if (read.status === 'read-error') return { status: 'read-error' }
7423
- if (read.bytesRead <= 0) break
7424
- total += read.bytesRead
7425
- chunks.push(buffer.subarray(0, read.bytesRead))
7426
- if (total > maxBytes) return { status: 'oversized' }
7427
- }
7428
- return { buffer: Buffer.concat(chunks, total), status: 'ok' }
7429
- }
7430
- function isValidInvocation(argv) {
7431
- const commandIndex = argv[0] === 'systematic' ? 1 : 0
7432
- return (
7433
- argv[commandIndex] === 'validate-review-return' &&
7434
- argv.length === commandIndex + 1
7435
- )
7436
- }
7437
- function runReviewReturnValidator(options) {
7438
- const outputSink = options.outputSink ?? ((message) => console.log(message))
7439
- const errorSink = options.errorSink ?? ((message) => console.error(message))
7440
- const fd = options.fd ?? 0
7441
- const isTTY = options.isTTY ?? (fd === 0 && process.stdin.isTTY === true)
7442
- if (!isValidInvocation(options.argv)) {
7443
- errorSink(VALIDATE_REVIEW_RETURN_USAGE)
7444
- return 2
7445
- }
7446
- if (isTTY) {
7447
- errorSink(REVIEW_RETURN_TTY_MESSAGE)
7448
- return 2
7449
- }
7450
- const read = readBoundedStdin(fd, options.readChunk ?? defaultReadChunk)
7451
- if (read.status === 'read-error') {
7452
- errorSink(REVIEW_RETURN_READ_FAILED_MESSAGE)
7453
- return 2
7454
- }
7455
- if (read.status === 'oversized') {
7456
- errorSink(REVIEW_RETURN_OVERSIZED_MESSAGE)
7457
- return 1
7458
- }
7459
- let text
7460
- try {
7461
- text = new TextDecoder('utf-8', { fatal: true }).decode(read.buffer)
7462
- } catch {
7463
- errorSink(REVIEW_RETURN_INVALID_UTF8_MESSAGE)
7464
- return 1
7465
- }
7466
- if (text.trim() === '') {
7467
- errorSink(REVIEW_RETURN_EMPTY_MESSAGE)
7468
- return 1
7469
- }
7470
- let value
7471
- try {
7472
- value = JSON.parse(text)
7473
- } catch {
7474
- errorSink(REVIEW_RETURN_MALFORMED_JSON_MESSAGE)
7475
- return 1
7476
- }
7477
- const validation = validateReviewReturnValue(value)
7478
- if (validation.ok) {
7479
- outputSink(REVIEW_RETURN_VALID_MESSAGE)
7480
- return 0
7481
- }
7482
- for (const issue of validation.issues) {
7483
- errorSink(`${issue.path} ${issue.code}`)
7484
- }
7485
- errorSink(formatReviewReturnValidationFailure(validation.total))
7486
- return 1
7487
- }
7488
-
7489
7382
  // src/lib/review-pipeline.ts
7490
7383
  function normalizeRepoRelativePath(filePath) {
7491
7384
  return path2.posix.normalize(filePath.replaceAll('\\', '/'))
@@ -7555,38 +7448,55 @@ function wholePayloadRejection(
7555
7448
  harness,
7556
7449
  })
7557
7450
  }
7558
- function screenReviewReturn(input) {
7451
+ function rejected(result, rejection) {
7452
+ return { ok: false, rejection, result }
7453
+ }
7454
+ function screenReviewReturnWithReport(input) {
7559
7455
  const persona = input.expected_reviewer
7560
7456
  const harness = input.invoking_harness
7561
7457
  const parsed = parseRawReturn(input.raw_return)
7562
7458
  if (!parsed.ok) {
7563
- return wholePayloadRejection(
7564
- persona,
7565
- JSON_ROOT_PATH,
7566
- 'malformed JSON',
7567
- undefined,
7568
- harness,
7459
+ return rejected(
7460
+ wholePayloadRejection(
7461
+ persona,
7462
+ JSON_ROOT_PATH,
7463
+ 'malformed JSON',
7464
+ undefined,
7465
+ harness,
7466
+ ),
7467
+ { code: 'malformed_json' },
7569
7468
  )
7570
7469
  }
7571
- const validation = validateReviewReturnValue(parsed.value)
7572
- if (!validation.ok) {
7573
- const fieldPath = validation.issues[0]?.path ?? JSON_ROOT_PATH
7574
- return wholePayloadRejection(
7575
- persona,
7576
- fieldPath,
7577
- 'schema validation',
7578
- extractRejectedSeverities(parsed.value),
7579
- harness,
7470
+ const validation = SubAgentReturnSchema.safeParse(parsed.value)
7471
+ if (!validation.success) {
7472
+ const { issues, total } = projectRejectionIssues(validation.error.issues)
7473
+ return rejected(
7474
+ wholePayloadRejection(
7475
+ persona,
7476
+ issues[0]?.path ?? JSON_ROOT_PATH,
7477
+ 'schema validation',
7478
+ extractRejectedSeverities(parsed.value),
7479
+ harness,
7480
+ ),
7481
+ {
7482
+ code: 'schema_validation',
7483
+ issue_count: total,
7484
+ issues,
7485
+ omitted: total - issues.length,
7486
+ },
7580
7487
  )
7581
7488
  }
7582
- const raw = SubAgentReturnSchema.parse(parsed.value)
7489
+ const raw = validation.data
7583
7490
  if (raw.reviewer !== persona) {
7584
- return wholePayloadRejection(
7585
- persona,
7586
- 'reviewer',
7587
- 'schema validation',
7588
- raw.findings.map((finding) => finding.severity),
7589
- harness,
7491
+ return rejected(
7492
+ wholePayloadRejection(
7493
+ persona,
7494
+ 'reviewer',
7495
+ 'schema validation',
7496
+ raw.findings.map((finding) => finding.severity),
7497
+ harness,
7498
+ ),
7499
+ { code: 'identity_mismatch' },
7590
7500
  )
7591
7501
  }
7592
7502
  const admittedFindings = raw.findings.map((finding, originalIndex) => ({
@@ -7595,13 +7505,29 @@ function screenReviewReturn(input) {
7595
7505
  input_id: `${persona}#${originalIndex}`,
7596
7506
  }))
7597
7507
  const dispatchOutcome = raw.findings.length === 0 ? 'empty' : 'findings'
7598
- return ScreenOutputSchema.parse({
7599
- admitted_findings: admittedFindings,
7600
- dispatch_outcome: dispatchOutcome,
7601
- residual_risks: raw.residual_risks,
7602
- testing_gaps: raw.testing_gaps,
7603
- harness,
7604
- })
7508
+ return {
7509
+ ok: true,
7510
+ result: ScreenOutputSchema.parse({
7511
+ admitted_findings: admittedFindings,
7512
+ dispatch_outcome: dispatchOutcome,
7513
+ residual_risks: raw.residual_risks,
7514
+ testing_gaps: raw.testing_gaps,
7515
+ harness,
7516
+ }),
7517
+ }
7518
+ }
7519
+ function rejectUnreadableScreenInput(input) {
7520
+ return {
7521
+ ok: false,
7522
+ rejection: { code: input.code },
7523
+ result: wholePayloadRejection(
7524
+ input.expected_reviewer,
7525
+ JSON_ROOT_PATH,
7526
+ 'schema validation',
7527
+ undefined,
7528
+ input.invoking_harness,
7529
+ ),
7530
+ }
7605
7531
  }
7606
7532
  var STANDARD_CONFIDENCE_FLOOR = 0.6
7607
7533
  var P0_CONFIDENCE_FLOOR = 0.5
@@ -10255,6 +10181,131 @@ function finalizeReview(input) {
10255
10181
  })
10256
10182
  }
10257
10183
 
10184
+ // src/lib/review-return-validator.ts
10185
+ import fs2 from 'node:fs'
10186
+ var VALIDATE_REVIEW_RETURN_USAGE = 'Usage: systematic validate-review-return'
10187
+ var MAX_REVIEW_RETURN_BYTES = 1024 * 1024
10188
+ var REVIEW_RETURN_VALID_MESSAGE = 'Review return is valid'
10189
+ var REVIEW_RETURN_EMPTY_MESSAGE = 'Review return is empty'
10190
+ var REVIEW_RETURN_INVALID_UTF8_MESSAGE = 'Review return is not valid UTF-8'
10191
+ var REVIEW_RETURN_MALFORMED_JSON_MESSAGE = 'Review return is not valid JSON'
10192
+ var REVIEW_RETURN_OVERSIZED_MESSAGE =
10193
+ 'Review return exceeds the 1 MiB input limit'
10194
+ var REVIEW_RETURN_READ_FAILED_MESSAGE =
10195
+ 'Review return could not be read from stdin'
10196
+ var REVIEW_RETURN_TTY_MESSAGE =
10197
+ 'validate-review-return reads one JSON document from stdin; interactive input is not supported'
10198
+ function validateReviewReturnValue(value) {
10199
+ const result = SubAgentReturnSchema.safeParse(value)
10200
+ if (result.success) return { ok: true }
10201
+ const { issues, total } = projectZodIssues(result.error.issues)
10202
+ return { issues, ok: false, total }
10203
+ }
10204
+ function formatReviewReturnValidationFailure(total) {
10205
+ return `Review return validation failed: ${total} issue(s)`
10206
+ }
10207
+ var READ_CHUNK_BYTES = 64 * 1024
10208
+ function defaultReadChunk(fd, buffer, offset, length, position) {
10209
+ return fs2.readSync(fd, buffer, offset, length, position)
10210
+ }
10211
+ var TRANSIENT_READ_RETRY_MS = 1
10212
+ function isTransientReadError(error) {
10213
+ if (typeof error !== 'object' || error === null) return false
10214
+ const code = error.code
10215
+ return code === 'EAGAIN' || code === 'EWOULDBLOCK'
10216
+ }
10217
+ function sleepSync(milliseconds) {
10218
+ Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, milliseconds)
10219
+ }
10220
+ function readChunkWithRetry(fd, buffer, toRead, readChunk) {
10221
+ for (;;) {
10222
+ try {
10223
+ return {
10224
+ bytesRead: readChunk(fd, buffer, 0, toRead, null),
10225
+ status: 'ok',
10226
+ }
10227
+ } catch (error) {
10228
+ if (!isTransientReadError(error)) return { status: 'read-error' }
10229
+ sleepSync(TRANSIENT_READ_RETRY_MS)
10230
+ }
10231
+ }
10232
+ }
10233
+ function readBoundedStdin(fd, readChunk, maxBytes = MAX_REVIEW_RETURN_BYTES) {
10234
+ const chunks = []
10235
+ let total = 0
10236
+ while (true) {
10237
+ const remaining = maxBytes + 1 - total
10238
+ if (remaining <= 0) return { status: 'oversized' }
10239
+ const toRead = Math.min(READ_CHUNK_BYTES, remaining)
10240
+ const buffer = Buffer.allocUnsafe(toRead)
10241
+ const read = readChunkWithRetry(fd, buffer, toRead, readChunk)
10242
+ if (read.status === 'read-error') return { status: 'read-error' }
10243
+ if (read.bytesRead <= 0) break
10244
+ total += read.bytesRead
10245
+ chunks.push(buffer.subarray(0, read.bytesRead))
10246
+ if (total > maxBytes) return { status: 'oversized' }
10247
+ }
10248
+ return { buffer: Buffer.concat(chunks, total), status: 'ok' }
10249
+ }
10250
+ function isValidInvocation(argv) {
10251
+ const commandIndex = argv[0] === 'systematic' ? 1 : 0
10252
+ return (
10253
+ argv[commandIndex] === 'validate-review-return' &&
10254
+ argv.length === commandIndex + 1
10255
+ )
10256
+ }
10257
+ function runReviewReturnValidator(options) {
10258
+ const outputSink = options.outputSink ?? ((message) => console.log(message))
10259
+ const errorSink = options.errorSink ?? ((message) => console.error(message))
10260
+ const fd = options.fd ?? 0
10261
+ const isTTY = options.isTTY ?? (fd === 0 && process.stdin.isTTY === true)
10262
+ if (!isValidInvocation(options.argv)) {
10263
+ errorSink(VALIDATE_REVIEW_RETURN_USAGE)
10264
+ return 2
10265
+ }
10266
+ if (isTTY) {
10267
+ errorSink(REVIEW_RETURN_TTY_MESSAGE)
10268
+ return 2
10269
+ }
10270
+ const read = readBoundedStdin(fd, options.readChunk ?? defaultReadChunk)
10271
+ if (read.status === 'read-error') {
10272
+ errorSink(REVIEW_RETURN_READ_FAILED_MESSAGE)
10273
+ return 2
10274
+ }
10275
+ if (read.status === 'oversized') {
10276
+ errorSink(REVIEW_RETURN_OVERSIZED_MESSAGE)
10277
+ return 1
10278
+ }
10279
+ let text
10280
+ try {
10281
+ text = new TextDecoder('utf-8', { fatal: true }).decode(read.buffer)
10282
+ } catch {
10283
+ errorSink(REVIEW_RETURN_INVALID_UTF8_MESSAGE)
10284
+ return 1
10285
+ }
10286
+ if (text.trim() === '') {
10287
+ errorSink(REVIEW_RETURN_EMPTY_MESSAGE)
10288
+ return 1
10289
+ }
10290
+ let value
10291
+ try {
10292
+ value = JSON.parse(text)
10293
+ } catch {
10294
+ errorSink(REVIEW_RETURN_MALFORMED_JSON_MESSAGE)
10295
+ return 1
10296
+ }
10297
+ const validation = validateReviewReturnValue(value)
10298
+ if (validation.ok) {
10299
+ outputSink(REVIEW_RETURN_VALID_MESSAGE)
10300
+ return 0
10301
+ }
10302
+ for (const issue of validation.issues) {
10303
+ errorSink(`${issue.path} ${issue.code}`)
10304
+ }
10305
+ errorSink(formatReviewReturnValidationFailure(validation.total))
10306
+ return 1
10307
+ }
10308
+
10258
10309
  // src/ce-review-validator.ts
10259
10310
  var CE_REVIEW_VALIDATOR_USAGE =
10260
10311
  'Usage: node validate-review.mjs <return|artifact|screen|prepare|merge|finalize> [...]'
@@ -10348,6 +10399,12 @@ function formatAggregateRejection(rejectedMessage, rejection) {
10348
10399
  }
10349
10400
  }
10350
10401
  }
10402
+ function formatScreenRejectionOutput(admission) {
10403
+ return JSON.stringify({
10404
+ screen: admission.result,
10405
+ rejection: admission.rejection,
10406
+ })
10407
+ }
10351
10408
  function runScreenSubcommand(options, outputSink, errorSink) {
10352
10409
  const flags = parseScreenFlags(options.argv.slice(1))
10353
10410
  if (!flags.ok) {
@@ -10360,38 +10417,57 @@ function runScreenSubcommand(options, outputSink, errorSink) {
10360
10417
  errorSink(CE_REVIEW_SCREEN_STDIN_TTY_MESSAGE)
10361
10418
  return 2
10362
10419
  }
10420
+ const rejectUnreadable = (code, message) => {
10421
+ outputSink(
10422
+ formatScreenRejectionOutput(
10423
+ rejectUnreadableScreenInput({
10424
+ code,
10425
+ expected_reviewer: flags.reviewer,
10426
+ invoking_harness: flags.harness,
10427
+ }),
10428
+ ),
10429
+ )
10430
+ errorSink(message)
10431
+ return 1
10432
+ }
10363
10433
  const read = readBoundedStdin(fd, options.readChunk ?? defaultReadChunk)
10364
10434
  if (read.status === 'read-error') {
10365
10435
  errorSink(CE_REVIEW_SCREEN_STDIN_READ_FAILED_MESSAGE)
10366
10436
  return 2
10367
10437
  }
10368
10438
  if (read.status === 'oversized') {
10369
- errorSink(CE_REVIEW_SCREEN_STDIN_OVERSIZED_MESSAGE)
10370
- return 1
10439
+ return rejectUnreadable(
10440
+ 'input_oversized',
10441
+ CE_REVIEW_SCREEN_STDIN_OVERSIZED_MESSAGE,
10442
+ )
10371
10443
  }
10372
10444
  let text
10373
10445
  try {
10374
10446
  text = new TextDecoder('utf-8', { fatal: true }).decode(read.buffer)
10375
10447
  } catch {
10376
- errorSink(CE_REVIEW_SCREEN_STDIN_INVALID_UTF8_MESSAGE)
10377
- return 1
10448
+ return rejectUnreadable(
10449
+ 'input_invalid_utf8',
10450
+ CE_REVIEW_SCREEN_STDIN_INVALID_UTF8_MESSAGE,
10451
+ )
10378
10452
  }
10379
10453
  if (text.trim() === '') {
10380
10454
  errorSink(CE_REVIEW_SCREEN_STDIN_EMPTY_MESSAGE)
10381
10455
  return 2
10382
10456
  }
10383
- const result = screenReviewReturn({
10457
+ const admission = screenReviewReturnWithReport({
10384
10458
  expected_reviewer: flags.reviewer,
10385
10459
  invoking_harness: flags.harness,
10386
10460
  raw_return: text,
10387
10461
  })
10388
- if (result.dispatch_outcome === 'malformed') {
10462
+ if (!admission.ok) {
10463
+ outputSink(formatScreenRejectionOutput(admission))
10389
10464
  errorSink(
10390
- result.rejected_summary?.reason ?? CE_REVIEW_SCREEN_REJECTED_MESSAGE,
10465
+ admission.result.rejected_summary?.reason ??
10466
+ CE_REVIEW_SCREEN_REJECTED_MESSAGE,
10391
10467
  )
10392
10468
  return 1
10393
10469
  }
10394
- outputSink(JSON.stringify(result))
10470
+ outputSink(JSON.stringify(admission.result))
10395
10471
  return 0
10396
10472
  }
10397
10473
  function runPrepareSubcommand(options, outputSink, errorSink) {
@@ -332,6 +332,8 @@ If agent outputs conflict:
332
332
  - Prefer official framework documentation over secondary best-practice summaries when the conflict is about library behavior
333
333
  - If a real tradeoff remains, record it explicitly in the plan rather than pretending the conflict does not exist
334
334
 
335
+ The metacogs skills `synthesis` and `counterfactual`, if you load them for such a conflict, come from a separate plugin and are not Systematic skills. Load them by their bare names through the host's skill-loading mechanism, in the parent agent only. If they are not available, continue unchanged.
336
+
335
337
  ### Phase 5: Synthesize and Rewrite the Plan
336
338
 
337
339
  Strengthen only the selected sections. Keep the plan coherent and preserve its overall structure.