lastlight-core 0.34.1 → 0.35.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (96) hide show
  1. package/config/default.yaml +114 -138
  2. package/dist/config/config.d.ts +11 -0
  3. package/dist/config/config.js +100 -30
  4. package/dist/config/config.js.map +1 -1
  5. package/dist/engine/dispatcher.d.ts +5 -0
  6. package/dist/engine/dispatcher.js +13 -1
  7. package/dist/engine/dispatcher.js.map +1 -1
  8. package/dist/engine/github/github.d.ts +49 -0
  9. package/dist/engine/github/github.js +53 -1
  10. package/dist/engine/github/github.js.map +1 -1
  11. package/dist/engine/github/review-poster.d.ts +16 -3
  12. package/dist/engine/github/review-poster.js +3 -3
  13. package/dist/engine/github/review-poster.js.map +1 -1
  14. package/dist/engine/github/review-summary.d.ts +2 -2
  15. package/dist/engine/github/review-summary.js +1 -1
  16. package/dist/engine/github/review-summary.js.map +1 -1
  17. package/dist/engine/pr-decisions.d.ts +29 -0
  18. package/dist/engine/pr-decisions.js +145 -100
  19. package/dist/engine/pr-decisions.js.map +1 -1
  20. package/dist/engine/pr-discussion.d.ts +23 -0
  21. package/dist/engine/pr-discussion.js +55 -0
  22. package/dist/engine/pr-discussion.js.map +1 -0
  23. package/dist/engine/pr-intent.d.ts +32 -0
  24. package/dist/engine/pr-intent.js +55 -0
  25. package/dist/engine/pr-intent.js.map +1 -0
  26. package/dist/engine/pr-state.d.ts +23 -2
  27. package/dist/engine/pr-state.js +24 -3
  28. package/dist/engine/pr-state.js.map +1 -1
  29. package/dist/engine/review-check.d.ts +2 -0
  30. package/dist/engine/review-check.js +6 -0
  31. package/dist/engine/review-check.js.map +1 -1
  32. package/dist/engine/review-spec.d.ts +2 -87
  33. package/dist/engine/review-spec.js +2 -445
  34. package/dist/engine/review-spec.js.map +1 -1
  35. package/dist/engine/review-triage.d.ts +27 -9
  36. package/dist/engine/review-triage.js +20 -7
  37. package/dist/engine/review-triage.js.map +1 -1
  38. package/dist/engine/supersede.d.ts +42 -0
  39. package/dist/engine/supersede.js +72 -0
  40. package/dist/engine/supersede.js.map +1 -0
  41. package/dist/evals-api.d.ts +7 -0
  42. package/dist/evals-api.js +21 -0
  43. package/dist/evals-api.js.map +1 -1
  44. package/dist/sandbox/index.d.ts +9 -0
  45. package/dist/sandbox/index.js +24 -0
  46. package/dist/sandbox/index.js.map +1 -1
  47. package/dist/sandbox/sandbox.d.ts +25 -0
  48. package/dist/sandbox/sandbox.js +97 -14
  49. package/dist/sandbox/sandbox.js.map +1 -1
  50. package/dist/state/client.d.ts +8 -3
  51. package/dist/state/client.js.map +1 -1
  52. package/dist/state/db.js +7 -6
  53. package/dist/state/db.js.map +1 -1
  54. package/dist/state/sqlite-write-lock.d.ts +46 -0
  55. package/dist/state/sqlite-write-lock.js +145 -0
  56. package/dist/state/sqlite-write-lock.js.map +1 -0
  57. package/dist/state/workflow-run-store.d.ts +4 -1
  58. package/dist/state/workflow-run-store.js.map +1 -1
  59. package/dist/workflows/handlers/fanout.d.ts +17 -4
  60. package/dist/workflows/handlers/fanout.js +68 -31
  61. package/dist/workflows/handlers/fanout.js.map +1 -1
  62. package/dist/workflows/handlers/host-repo-dir.d.ts +38 -0
  63. package/dist/workflows/handlers/host-repo-dir.js +55 -0
  64. package/dist/workflows/handlers/host-repo-dir.js.map +1 -0
  65. package/dist/workflows/handlers/post-review.d.ts +9 -1
  66. package/dist/workflows/handlers/post-review.js +39 -16
  67. package/dist/workflows/handlers/post-review.js.map +1 -1
  68. package/dist/workflows/handlers/survey-units.d.ts +323 -0
  69. package/dist/workflows/handlers/survey-units.js +1211 -0
  70. package/dist/workflows/handlers/survey-units.js.map +1 -0
  71. package/dist/workflows/live-runs.d.ts +36 -0
  72. package/dist/workflows/live-runs.js +69 -0
  73. package/dist/workflows/live-runs.js.map +1 -0
  74. package/dist/workflows/runner.js +55 -15
  75. package/dist/workflows/runner.js.map +1 -1
  76. package/dist/workflows/simple.js +10 -3
  77. package/dist/workflows/simple.js.map +1 -1
  78. package/package.json +8 -8
  79. package/skills/code-review/SKILL.md +2 -3
  80. package/skills/pr-review/references/findings-schema.md +4 -4
  81. package/workflows/pr-review.yaml +491 -271
  82. package/workflows/prompts/review-falsify.md +17 -9
  83. package/workflows/prompts/review-select.md +113 -0
  84. package/workflows/prompts/review-site-summary.md +48 -0
  85. package/workflows/prompts/review-site.md +305 -0
  86. package/workflows/prompts/review.md +0 -60
  87. package/workflows/prompts/survey-unit.md +60 -0
  88. package/skills/adjudicate-pass/SKILL.md +0 -149
  89. package/skills/survey-pass/SKILL.md +0 -139
  90. package/workflows/prompts/review-adjudicate.md +0 -498
  91. package/workflows/prompts/survey-contract.md +0 -121
  92. package/workflows/prompts/survey-enforcement.md +0 -105
  93. package/workflows/prompts/survey-security.md +0 -162
  94. package/workflows/prompts/survey-spec.md +0 -131
  95. package/workflows/prompts/survey-state.md +0 -152
  96. package/workflows/prompts/survey-tests.md +0 -99
@@ -64,12 +64,19 @@ phases:
64
64
  # it is INERT unless `review.analysis.enabled` — each phase carries
65
65
  # `skip_if: analysisEnabled != true`, and an absent variable reads as false,
66
66
  # so a typo skips the analysis rather than running an unasked-for one.
67
- # `prepare` and `falsify` need `review.analysis.probes` on top.
67
+ #
68
+ # The one analysis path: facts → seed → the unit survey → the `sites` review
69
+ # engine → reconcile. `prepare`, `probe-plan` and `falsify` are kept but NOT
70
+ # ATTACHED (`falsifyAttached != true` — no code projects the key): nothing in
71
+ # the sites engine reads their output yet, and wiring them back in is its own
72
+ # measured change (docs/plans/pr-review-units-sites.md, stage 5).
68
73
  #
69
74
  # Each also carries the TIER guard, `scratch.reviewTriage.depth == 'light'`.
70
75
  # Quoted `==` there, the mirror image of the bare-boolean form above: an
71
76
  # absent value never matches, so the phase RUNS — again failing toward a full
72
- # review. `review` and `post-review` carry no tier guard and always run.
77
+ # review. `post-review` carries no tier guard and always runs; `review` runs
78
+ # unless the pipeline replaces it (see its own `skip_if`), and always runs on
79
+ # `light`.
73
80
  - name: prepare
74
81
  label: Prepare · probe environment
75
82
  type: bash
@@ -83,6 +90,7 @@ phases:
83
90
  skip_if:
84
91
  - "analysisEnabled != true"
85
92
  - "probesEnabled != true"
93
+ - "falsifyAttached != true"
86
94
  - "scratch.reviewTriage.depth == 'light'"
87
95
  timeout_seconds: { from: probePhaseTimeoutSeconds }
88
96
  command: |
@@ -154,17 +162,17 @@ phases:
154
162
  # The shell-level catch covers what `--never-fail` cannot: a process that
155
163
  # DIES (OOM, a segfault in the native parser). `--stage-diff` writes the
156
164
  # per-file patches here, where the merge base is already resolved, so no
157
- # survey branch has to derive the range again.
165
+ # investigator has to derive the range again.
158
166
  if ! "$FACTS" all --repo . --base "$BASE" --head HEAD --out "$OUT" --stage-diff --never-fail; then
159
167
  fallback "the analysis process died without writing an envelope (OOM, a segfault in the native parser, or a compiler binary that cannot exec) — NOTHING here may be read as 'no findings'"
160
168
  fi
161
169
  echo "facts: $(wc -c < "$OUT" 2>/dev/null || echo 0) bytes, base $BASE"
162
- # Logged separately so "nothing was staged" and "the branches never found
163
- # it" are two lines rather than one silence.
170
+ # Logged separately so "nothing was staged" and "the investigators never
171
+ # found it" are two lines rather than one silence.
164
172
  if [ -s .lastlight/pr-review/diff/index.md ]; then
165
173
  echo "facts: staged $(ls .lastlight/pr-review/diff/*.patch 2>/dev/null | wc -l) per-file patch(es) under .lastlight/pr-review/diff/"
166
174
  else
167
- echo "facts: NO staged diff — every survey branch will have to derive the range itself"
175
+ echo "facts: NO staged diff — every investigator will have to derive the range itself"
168
176
  fi
169
177
 
170
178
  - name: seed
@@ -189,122 +197,456 @@ phases:
189
197
  set -- seed --facts .lastlight/pr-review/facts.json \
190
198
  --out .lastlight/pr-review/obligations.json \
191
199
  --contract "${CONTRACT:-minimal}" \
192
- --max-obligations "${MAX_OBLIGATIONS:-48}" \
193
- --blocks .lastlight/pr-review/obligations
200
+ --max-obligations "${MAX_OBLIGATIONS:-48}"
194
201
  if [ -n "$MINT" ]; then set -- "$@" --mint "$MINT"; fi
195
202
  "$FACTS" "$@" || true
196
203
  echo "seed: contract ${CONTRACT:-minimal} backstop ${MAX_OBLIGATIONS:-48} mint ${MINT:-none}"
197
- echo "seed: $(ls .lastlight/pr-review/obligations 2>/dev/null | wc -l) family block(s)"
204
+ if [ -s .lastlight/pr-review/obligations.json ]; then
205
+ echo "seed: obligations.json $(wc -c < .lastlight/pr-review/obligations.json) bytes"
206
+ else
207
+ echo "seed: obligations.json MISSING — every unit will be cut with no obligation"
208
+ fi
209
+ exit 0
210
+
211
+ # ── The unit survey (docs/plans/pr-review-units-sites.md) ─────────────────────────────
212
+ #
213
+ # Three phases that end in `hypotheses/<family>.jsonl` — the rows `site-plan`
214
+ # clusters into sites:
215
+ #
216
+ # units deterministic: cut the PR into units (a symbol, a module
217
+ # region, the PR itself) and render each one's COMPLETE
218
+ # request — code, neighbours, obligations, questions, schema.
219
+ # survey-units in-process: ONE bounded, non-agentic model call per unit,
220
+ # concurrently. No sandbox, no tools, no re-deriving with
221
+ # bash what `facts`/`seed` already computed.
222
+ # units-ingest deterministic: validate every response, write the
223
+ # hypothesis rows. A unit that never answered is RECORDED —
224
+ # each obligation it owned gets a row saying so — never
225
+ # dropped.
226
+ #
227
+ # `all_done` down the chain, like every deterministic phase here: `units`
228
+ # always writes a document (the shell fallback included), and `units-ingest`
229
+ # must run even when the calls failed — that is when it has the most to
230
+ # record.
231
+ - name: units
232
+ label: Units · deterministic
233
+ type: bash
234
+ skip_if:
235
+ - "analysisEnabled != true"
236
+ - "scratch.reviewTriage.depth == 'light'"
237
+ depends_on: [seed]
238
+ trigger_rule: all_done
239
+ # `facts`' own budget: the same class of analysis over the same tree, and a
240
+ # context key rather than a literal like every budget here (#385).
241
+ timeout_seconds: { from: factsTimeoutSeconds }
242
+ command: |
243
+ set -u
244
+ FACTS="${LASTLIGHT_FACTS_BIN:-$(command -v lastlight-facts || echo /opt/lastlight/bin/lastlight-facts)}"
245
+ OUT=.lastlight/pr-review/units.json
246
+ SPEC=.lastlight/pr-review/spec-obligations.json
247
+ mkdir -p .lastlight/pr-review
248
+ # A reused per-PR workspace still holds the LAST head's document. Remove
249
+ # it first, so a process that dies before writing leaves no stale units
250
+ # for `survey-units` to spend money on.
251
+ rm -f "$OUT" "$SPEC"
252
+
253
+ # The spec obligations are built HARNESS-side (the PR body and the issues
254
+ # it closes; `review-spec.ts`), so they reach the sandbox only through
255
+ # this command: the raw set, as the one line of JSON `specContext`
256
+ # projects, for `units` to cut into units. QUOTED heredoc — nothing in it
257
+ # is expanded — and the value is one line, so it can never be the
258
+ # delimiter line. No set (nothing to say, nothing degraded) writes no
259
+ # file; the `rm` above already removed a stale one.
260
+ {{#if specObligationsJson}}
261
+ cat > "$SPEC" <<'LASTLIGHT_SPEC_EOF'
262
+ {{specObligationsJson}}
263
+ LASTLIGHT_SPEC_EOF
264
+ {{/if}}
265
+ if [ -s "$SPEC" ]; then
266
+ echo "units: spec obligations written, $(wc -c < "$SPEC") bytes"
267
+ else
268
+ echo "units: no spec obligations for this PR"
269
+ fi
270
+
271
+ # The fallback must read downstream as "nothing was cut into units", never
272
+ # as "there was nothing to survey": `coverage: none`, the reason in
273
+ # `degraded[]`, and an EMPTY `units` array `survey-units` accepts.
274
+ fallback() {
275
+ printf '{"version":1,"generatedAt":"%s","baseSha":null,"headSha":"%s","promptVersion":null,"coverage":"none","degraded":[{"extractor":"units","reason":"%s"}],"responseSchema":null,"units":[]}\n' \
276
+ "$(date -u +%Y-%m-%dT%H:%M:%S.000Z)" "$(git rev-parse HEAD 2>/dev/null || echo unknown)" "$1" > "$OUT"
277
+ }
198
278
 
199
- # A block is always emitted for all five seedable families, even a NOT
200
- # MEASURED one, so a MISSING line here is a seeder failure — and a survey
201
- # that then reports the family clean is reporting on no measurement at
202
- # all. `spec` is absent by design: it is built harness-side.
203
- for FAMILY in contract enforcement security state tests; do
204
- BLOCK=".lastlight/pr-review/obligations/$FAMILY.md"
205
- if [ -s "$BLOCK" ]; then
206
- echo "seed: $FAMILY block $(wc -c < "$BLOCK") bytes"
279
+ # `--never-fail` covers what the CLI can see; the shell covers a process
280
+ # that DIES (OOM, a segfault in the native parser). The fallback is
281
+ # written only when nothing was — a document the CLI wrote on its way to
282
+ # a non-zero exit carries more than this one can.
283
+ "$FACTS" units --dir .lastlight/pr-review --repo . --never-fail
284
+ CODE=$?
285
+ if [ ! -s "$OUT" ]; then
286
+ fallback "the units process exited $CODE without writing units.json (OOM, a segfault in the native parser, or a CLI that could not be executed) — NOTHING here may be read as 'no findings'"
287
+ fi
288
+ N=$(node -e 'console.log(JSON.parse(require("fs").readFileSync(process.argv[1], "utf8")).units.length)' "$OUT" 2>/dev/null || echo "?")
289
+ echo "units: exit $CODE, $N unit(s), $(wc -c < "$OUT" 2>/dev/null || echo 0) bytes"
290
+ exit 0
291
+
292
+ # One call per unit, in the HARNESS process (`handlers/survey-units.ts`).
293
+ # The system prompt of every call is `prompt:` plus the document's
294
+ # byte-identical `sharedPrefix` (so Anthropic's system-prompt cache
295
+ # breakpoint covers both), and the user message is the rest of the unit's
296
+ # request; with no usable prefix, the request goes verbatim. Concurrency is
297
+ # `review.analysis.surveyUnitConcurrency`. Replies are cached outside the
298
+ # workspace, keyed on the resolved endpoint, thinking level, system text and
299
+ # request, so a re-review re-asks only the units whose request changed — and
300
+ # a reply `units-ingest` judged invalid/partial is evicted before the next
301
+ # run. One transcript and one `executions` row for the phase.
302
+ #
303
+ # It SUCCEEDS on every path inside the phase — no units, no units.json, every
304
+ # call failing, the deadline — with a loud summary, because a red phase here
305
+ # posts nothing and re-arms the review sweep, while `units-ingest` already
306
+ # records every unanswered obligation. The one unsupported setup (kubernetes:
307
+ # no host checkout) is refused at config load instead — with it, the whole
308
+ # analysis pipeline.
309
+ - name: survey-units
310
+ label: Survey · one call per unit
311
+ type: survey-units
312
+ prompt: prompts/survey-unit.md
313
+ model: "{{models.review-survey}}"
314
+ # Thinking level, resolved like every agent phase's (`variants.<key>`, then
315
+ # the resolver's per-phase / catch-all default). Part of the cache key.
316
+ variant: "{{variants.review-survey}}"
317
+ # The WHOLE-PHASE deadline (every unit call shares one AbortController);
318
+ # a unit not finished by then is recorded `ok: false`, "phase deadline".
319
+ timeout_seconds: { from: surveyUnitsTimeoutSeconds }
320
+ skip_if:
321
+ - "analysisEnabled != true"
322
+ - "scratch.reviewTriage.depth == 'light'"
323
+ depends_on: [units]
324
+ trigger_rule: all_done
325
+
326
+ - name: units-ingest
327
+ label: Units · ingest
328
+ type: bash
329
+ skip_if:
330
+ - "analysisEnabled != true"
331
+ - "scratch.reviewTriage.depth == 'light'"
332
+ depends_on: [survey-units]
333
+ trigger_rule: all_done
334
+ timeout_seconds: { from: seedTimeoutSeconds }
335
+ command: |
336
+ set -u
337
+ FACTS="${LASTLIGHT_FACTS_BIN:-$(command -v lastlight-facts || echo /opt/lastlight/bin/lastlight-facts)}"
338
+ mkdir -p .lastlight/pr-review/hypotheses
339
+ if ! "$FACTS" units-ingest --dir .lastlight/pr-review --never-fail; then
340
+ echo "units-ingest: the ingest process died — hypotheses/ holds whatever it wrote before; site-plan reads what is there"
341
+ fi
342
+
343
+ # The POST-CHECK: every seeded obligation carries a discharge, and every
344
+ # row gets the canonical id rewrite (issue #405). `spec` is graded
345
+ # `--ungraded` — its obligations are not in obligations.json.
346
+ # REPORTED, never failed on: there is no agent to hand a gate failure
347
+ # back to, and ingest has already written an unanswered row for every
348
+ # obligation a unit could not answer — a red phase here would only paint
349
+ # the run red over a gap that is already on the record.
350
+ for FAMILY in contract enforcement security state spec; do
351
+ if [ "$FAMILY" = spec ]; then set -- --ungraded; else set --; fi
352
+ if RESULT="$("$FACTS" discharge --dir .lastlight/pr-review --family "$FAMILY" "$@" 2>&1)"; then
353
+ echo "discharge $FAMILY: ok"
207
354
  else
208
- echo "seed: $FAMILY block MISSING — the survey branch for this family will run UNSEEDED"
355
+ echo "discharge $FAMILY: NOT satisfied"
356
+ printf '%s\n' "$RESULT" | head -n 20
209
357
  fi
210
358
  done
211
359
  exit 0
212
360
 
213
- # The six survey families, run CONCURRENTLY as one node: six agent sessions
214
- # in one provisioned workspace, one `executions` row each, so per-family
215
- # cost, resume and the dashboard column all survive. The families are
216
- # pairwise disjoint — each appends to its own `hypotheses/<family>.jsonl` —
217
- # so there is no ordering between them.
361
+ # ── The `sites` review engine (docs/plans/pr-review-units-sites.md) ──────────
362
+ #
363
+ # The hypothesis rows are not the items the review weighs; they are a VOLUME
364
+ # signal: where many independent units pointed is where an investigator
365
+ # looks.
366
+ #
367
+ # site-plan deterministic: rank sites (distinct-unit votes, span ≤ 60,
368
+ # test-file sites last), one brief per slot.
369
+ # site-review fan-out: one investigator per selected site writes 1–3
370
+ # grounded findings, or a probe-backed `none`.
371
+ # merge deterministic: pool the findings, propose duplicate groups.
372
+ # select one agent call: merge true duplicates, set importance,
373
+ # write the comments.
374
+ # site-finalize deterministic: `sites --finalize` → findings.json (every
375
+ # row `internal`); then `reconcile`'s usual floor.
218
376
  #
219
- # Prompt order is fixed and expensive to change: the shared prefix (skills,
220
- # AGENTS.md, diff summary) goes first and the family's obligations last, so
221
- # the six share one provider-side cached prefix.
222
- - name: survey
223
- label: Survey · five families
377
+ # `all_done` down the chain: each step must run on whatever the last one
378
+ # left, and the floor in `reconcile` covers a failed `select`.
379
+ - name: site-plan
380
+ label: Sites · plan
381
+ type: bash
382
+ skip_if:
383
+ - "analysisEnabled != true"
384
+ - "scratch.reviewTriage.depth == 'light'"
385
+ depends_on: [units-ingest]
386
+ trigger_rule: all_done
387
+ timeout_seconds: { from: seedTimeoutSeconds }
388
+ # Writes `sites/plan.json` and one brief per slot, `sites/site-001.md` …
389
+ # `site-016.md` (it clears `sites/` first — a reused workspace holds the
390
+ # last head's). Slots 1–`siteTop` investigate the ranked sites; with
391
+ # `models.review-site-pair` set, slots 9–(8+`siteTop`) investigate the
392
+ # same sites again on that model. Every other slot is empty: its brief
393
+ # says so and its `empty` line is written here, so `site-review`'s
394
+ # `skip_satisfied_branches` starts no session for it.
395
+ command: |
396
+ set -u
397
+ FACTS="${LASTLIGHT_FACTS_BIN:-$(command -v lastlight-facts || echo /opt/lastlight/bin/lastlight-facts)}"
398
+ # Test-then-flag: an absent {{key}} renders EMPTY and would swallow the
399
+ # following flag.
400
+ TOP="{{siteTop}}"
401
+ set -- --slots 16
402
+ [ -n "$TOP" ] && set -- "$@" --top "$TOP"
403
+ {{#if models.review-site-pair}}set -- "$@" --pair{{/if}}
404
+ "$FACTS" sites --plan "$@" --dir .lastlight/pr-review --never-fail
405
+ exit 0
406
+
407
+ # One investigator per site, concurrently, in one workspace. The prompt is
408
+ # slot-generic (a branch has no variables of its own): the attached brief
409
+ # names the site id, the one file the branch writes
410
+ # (`sites/<site id>.findings.jsonl` — disjoint across branches, which is the
411
+ # fan-out's isolation model) and how many probed suspicions a `none` needs.
412
+ # The gate is the one the evals replay graded (`sites --check`), and
413
+ # `on_branch_gate_failure` hands its gaps back once — the round-2 feedback the
414
+ # replay built by hand.
415
+ - name: site-review
416
+ label: Sites · investigate
224
417
  type: fanout
225
- skills: [survey-pass]
226
- model: "{{models.review-survey}}"
227
- # No survey pass executes code (issue #403): measured, the `spec` branch ran
228
- # the suite whatever the model. Every branch inherits this; a branch may
229
- # replace it whole with its own `command_policy`.
230
- # `host` (issue #404): measured, two branches scanned the whole disk
231
- # (`find / -name SKILL.md`) to recover a lost skill path.
418
+ prompt: prompts/review-site.md
419
+ # Its own key, falling through to the survey model. The `{{#if}}` pair is
420
+ # load-bearing: a bare unset key renders EMPTY, and an empty model falls
421
+ # back to the DEFAULT model rather than to `models.review-survey`.
422
+ model: "{{#if models.review-site}}{{models.review-site}}{{/if}}{{#if !models.review-site}}{{models.review-survey}}{{/if}}"
423
+ skip_if:
424
+ - "analysisEnabled != true"
425
+ - "scratch.reviewTriage.depth == 'light'"
426
+ depends_on: [site-plan]
427
+ trigger_rule: all_done
428
+ # `review.analysis.siteConcurrency`, clamped per backend (gondolin pins to
429
+ # 1 — the sites then run in series).
430
+ max_concurrent: { from: siteConcurrency, default: 6 }
431
+ # An investigator RUNS code — copied lines under `node`, a differential
432
+ # `git show` — and that is its evidence. Installing the repo and the suite
433
+ # are never a probe; scratch installs follow falsify's switch, and `block`
434
+ # when probes are off (the key is projected only with probes on — the
435
+ # sites engine does not need them).
232
436
  command_policy:
233
437
  install: block
438
+ install-scratch: { from: probeScratchInstallPolicy, default: block }
234
439
  test: block
235
440
  host: block
236
441
  reason: >-
237
- No survey pass executes code. Cite CI from the Context section; where only
238
- running the code could settle a field of the evidence record, record it
239
- `unknown` — whether falsify probes the row is computed from that record.
240
- Nothing outside the checkout counts: never search the machine for a missing
241
- dependency or file — stop, and let the hypothesis go to falsify as unprobed.
242
- skip_if:
243
- - "analysisEnabled != true"
244
- - "scratch.reviewTriage.depth == 'light'"
245
- depends_on: [seed]
246
- trigger_rule: all_done
247
- # A CEILING the run clamps further per backend: gondolin boots a micro-VM
248
- # per session and pins to 1; `none` takes all six.
249
- max_concurrent: { from: surveyConcurrency, default: 6 }
250
- # The fan-out's OWN key. `on_soft_failure` is the `generic_loop` name and
251
- # at phase level the schema strips it silently, reverting to
252
- # `{retries: 0, then: fail}` — one degenerate turn then fails the review.
442
+ Installing the repository's dependencies is not this pass's job, and the whole
443
+ suite is never a probe. Run the one targeted check the site needs (a copied
444
+ function under `node`, a differential `git show`), or report what you read.
445
+ Nothing outside the checkout counts.
253
446
  on_branch_soft_failure: { retries: 1, then: complete }
254
- # A branch whose gate RAN and said no — seeded checks no row names, claim
255
- # rows with no evidence record, a zero-obligation family with no claim —
256
- # is re-run ONCE with the gate's output as the instruction, then gated
257
- # again. Without it the gate only recorded `condition_not_met` and the
258
- # half-done file went downstream as if complete (measured: MiniMax M3
259
- # answered 2 and 3 of 12 seeded checks on two of eight repeats). One extra
260
- # branch turn, only on failure.
261
447
  on_branch_gate_failure: { retries: 1 }
262
- # `context_file` is read by the HARNESS, host-side, from the cwd the
263
- # deterministic phases wrote in, and appended to the branch's prompt — the
264
- # model resolves no path of its own. An unreadable file appends a loud NOT
265
- # AVAILABLE notice, so a lost seed cannot pass for a clean family.
266
- #
267
- # `until_bash` checks every obligation carries a discharge code, not merely
268
- # that the file is non-empty. It DEGRADES to `test -s` when the obligations
269
- # are unreadable or the contract is `minimal`, because a gate an agent
270
- # cannot satisfy burns every iteration it has.
448
+ # `site-plan` wrote every empty slot's `empty` line, so its gate is already
449
+ # closed: no session for it. Sixteen static branches, of which a PR
450
+ # typically uses five (top 5, unpaired) to sixteen (top 8, paired).
451
+ skip_satisfied_branches: true
271
452
  branches:
272
- - name: contract
273
- prompt: prompts/survey-contract.md
274
- context_file: .lastlight/pr-review/obligations/contract.md
453
+ - name: site-001
454
+ context_file: .lastlight/pr-review/sites/site-001.md
275
455
  until_bash: |
276
456
  FACTS="${LASTLIGHT_FACTS_BIN:-$(command -v lastlight-facts || echo /opt/lastlight/bin/lastlight-facts)}"
277
- "$FACTS" discharge --dir .lastlight/pr-review --family contract
278
- - name: enforcement
279
- prompt: prompts/survey-enforcement.md
280
- context_file: .lastlight/pr-review/obligations/enforcement.md
457
+ "$FACTS" sites --check site-001 --dir .lastlight/pr-review --repo .
458
+ - name: site-002
459
+ context_file: .lastlight/pr-review/sites/site-002.md
281
460
  until_bash: |
282
461
  FACTS="${LASTLIGHT_FACTS_BIN:-$(command -v lastlight-facts || echo /opt/lastlight/bin/lastlight-facts)}"
283
- "$FACTS" discharge --dir .lastlight/pr-review --family enforcement
284
- - name: security
285
- prompt: prompts/survey-security.md
286
- context_file: .lastlight/pr-review/obligations/security.md
462
+ "$FACTS" sites --check site-002 --dir .lastlight/pr-review --repo .
463
+ - name: site-003
464
+ context_file: .lastlight/pr-review/sites/site-003.md
287
465
  until_bash: |
288
466
  FACTS="${LASTLIGHT_FACTS_BIN:-$(command -v lastlight-facts || echo /opt/lastlight/bin/lastlight-facts)}"
289
- "$FACTS" discharge --dir .lastlight/pr-review --family security
290
- - name: state
291
- prompt: prompts/survey-state.md
292
- context_file: .lastlight/pr-review/obligations/state.md
467
+ "$FACTS" sites --check site-003 --dir .lastlight/pr-review --repo .
468
+ - name: site-004
469
+ context_file: .lastlight/pr-review/sites/site-004.md
293
470
  until_bash: |
294
471
  FACTS="${LASTLIGHT_FACTS_BIN:-$(command -v lastlight-facts || echo /opt/lastlight/bin/lastlight-facts)}"
295
- "$FACTS" discharge --dir .lastlight/pr-review --family state
296
- # No `tests` branch: the family has no seeder, so it is reported
297
- # `notMeasured` rather than run to write NOT MEASURED. `spec` is built
298
- # harness-side from the PR body and linked issues, so it reads
299
- # `{{specObligations}}` from the context instead of a block on disk —
300
- # there is nothing in obligations.json for `discharge` to grade, so it
301
- # runs `--ungraded`: the same canonical-id rewrite every branch gets
302
- # (issue #405), and the non-empty-file floor it always had.
303
- - name: spec
304
- prompt: prompts/survey-spec.md
472
+ "$FACTS" sites --check site-004 --dir .lastlight/pr-review --repo .
473
+ - name: site-005
474
+ context_file: .lastlight/pr-review/sites/site-005.md
305
475
  until_bash: |
306
476
  FACTS="${LASTLIGHT_FACTS_BIN:-$(command -v lastlight-facts || echo /opt/lastlight/bin/lastlight-facts)}"
307
- "$FACTS" discharge --dir .lastlight/pr-review --family spec --ungraded
477
+ "$FACTS" sites --check site-005 --dir .lastlight/pr-review --repo .
478
+ - name: site-006
479
+ context_file: .lastlight/pr-review/sites/site-006.md
480
+ until_bash: |
481
+ FACTS="${LASTLIGHT_FACTS_BIN:-$(command -v lastlight-facts || echo /opt/lastlight/bin/lastlight-facts)}"
482
+ "$FACTS" sites --check site-006 --dir .lastlight/pr-review --repo .
483
+ - name: site-007
484
+ context_file: .lastlight/pr-review/sites/site-007.md
485
+ until_bash: |
486
+ FACTS="${LASTLIGHT_FACTS_BIN:-$(command -v lastlight-facts || echo /opt/lastlight/bin/lastlight-facts)}"
487
+ "$FACTS" sites --check site-007 --dir .lastlight/pr-review --repo .
488
+ - name: site-008
489
+ context_file: .lastlight/pr-review/sites/site-008.md
490
+ until_bash: |
491
+ FACTS="${LASTLIGHT_FACTS_BIN:-$(command -v lastlight-facts || echo /opt/lastlight/bin/lastlight-facts)}"
492
+ "$FACTS" sites --check site-008 --dir .lastlight/pr-review --repo .
493
+ # Slots 9–16: the second investigator of ranks 1–8, on
494
+ # `models.review-site-pair`. Empty (and never started) unless it is set.
495
+ - name: site-009
496
+ model: "{{models.review-site-pair}}"
497
+ context_file: .lastlight/pr-review/sites/site-009.md
498
+ until_bash: |
499
+ FACTS="${LASTLIGHT_FACTS_BIN:-$(command -v lastlight-facts || echo /opt/lastlight/bin/lastlight-facts)}"
500
+ "$FACTS" sites --check site-009 --dir .lastlight/pr-review --repo .
501
+ - name: site-010
502
+ model: "{{models.review-site-pair}}"
503
+ context_file: .lastlight/pr-review/sites/site-010.md
504
+ until_bash: |
505
+ FACTS="${LASTLIGHT_FACTS_BIN:-$(command -v lastlight-facts || echo /opt/lastlight/bin/lastlight-facts)}"
506
+ "$FACTS" sites --check site-010 --dir .lastlight/pr-review --repo .
507
+ - name: site-011
508
+ model: "{{models.review-site-pair}}"
509
+ context_file: .lastlight/pr-review/sites/site-011.md
510
+ until_bash: |
511
+ FACTS="${LASTLIGHT_FACTS_BIN:-$(command -v lastlight-facts || echo /opt/lastlight/bin/lastlight-facts)}"
512
+ "$FACTS" sites --check site-011 --dir .lastlight/pr-review --repo .
513
+ - name: site-012
514
+ model: "{{models.review-site-pair}}"
515
+ context_file: .lastlight/pr-review/sites/site-012.md
516
+ until_bash: |
517
+ FACTS="${LASTLIGHT_FACTS_BIN:-$(command -v lastlight-facts || echo /opt/lastlight/bin/lastlight-facts)}"
518
+ "$FACTS" sites --check site-012 --dir .lastlight/pr-review --repo .
519
+ - name: site-013
520
+ model: "{{models.review-site-pair}}"
521
+ context_file: .lastlight/pr-review/sites/site-013.md
522
+ until_bash: |
523
+ FACTS="${LASTLIGHT_FACTS_BIN:-$(command -v lastlight-facts || echo /opt/lastlight/bin/lastlight-facts)}"
524
+ "$FACTS" sites --check site-013 --dir .lastlight/pr-review --repo .
525
+ - name: site-014
526
+ model: "{{models.review-site-pair}}"
527
+ context_file: .lastlight/pr-review/sites/site-014.md
528
+ until_bash: |
529
+ FACTS="${LASTLIGHT_FACTS_BIN:-$(command -v lastlight-facts || echo /opt/lastlight/bin/lastlight-facts)}"
530
+ "$FACTS" sites --check site-014 --dir .lastlight/pr-review --repo .
531
+ - name: site-015
532
+ model: "{{models.review-site-pair}}"
533
+ context_file: .lastlight/pr-review/sites/site-015.md
534
+ until_bash: |
535
+ FACTS="${LASTLIGHT_FACTS_BIN:-$(command -v lastlight-facts || echo /opt/lastlight/bin/lastlight-facts)}"
536
+ "$FACTS" sites --check site-015 --dir .lastlight/pr-review --repo .
537
+ - name: site-016
538
+ model: "{{models.review-site-pair}}"
539
+ context_file: .lastlight/pr-review/sites/site-016.md
540
+ until_bash: |
541
+ FACTS="${LASTLIGHT_FACTS_BIN:-$(command -v lastlight-facts || echo /opt/lastlight/bin/lastlight-facts)}"
542
+ "$FACTS" sites --check site-016 --dir .lastlight/pr-review --repo .
543
+ # Pool every site's findings for `select`: numbered `F1…Fn`, each with an
544
+ # excerpt, and the duplicate groups line proximity PROPOSES (it cannot decide
545
+ # "same defect"; no rule here reads prose). STDOUT is the delivery mechanism
546
+ # — `output_var` puts it in the select prompt — and `sites/merged.json` is
547
+ # what `--finalize` reads.
548
+ - name: merge
549
+ label: Sites · merge
550
+ type: bash
551
+ skip_if:
552
+ - "analysisEnabled != true"
553
+ - "scratch.reviewTriage.depth == 'light'"
554
+ depends_on: [site-review]
555
+ trigger_rule: all_done
556
+ output_var: siteMerge
557
+ timeout_seconds: { from: reconcileTimeoutSeconds }
558
+ command: |
559
+ set -u
560
+ FACTS="${LASTLIGHT_FACTS_BIN:-$(command -v lastlight-facts || echo /opt/lastlight/bin/lastlight-facts)}"
561
+ if ! "$FACTS" sites --merge --dir .lastlight/pr-review --repo . --never-fail; then
562
+ echo "MERGE NOT AVAILABLE — \`lastlight-facts sites --merge\` failed. Write {\"items\": []}."
563
+ fi
564
+ exit 0
565
+
566
+ # One agent call over at most ~15 findings: merge true duplicates, set
567
+ # importance, write the comments to `sites/selected.json`. The gate is
568
+ # conservation — every pooled finding in exactly one item — so selecting can
569
+ # merge and demote (`nit` is recorded, never posted) but never silently drop.
570
+ # A selection that never closes is not fatal: `sites --finalize` falls back
571
+ # to one item per finding at the investigator's own importance.
572
+ - name: select
573
+ label: Sites · select
574
+ prompt: prompts/review-select.md
575
+ model: "{{#if models.review-select}}{{models.review-select}}{{/if}}{{#if !models.review-select}}{{models.review}}{{/if}}"
576
+ variant: "{{variants.review}}"
577
+ skip_if:
578
+ - "analysisEnabled != true"
579
+ - "scratch.reviewTriage.depth == 'light'"
580
+ depends_on: [merge]
581
+ trigger_rule: all_done
582
+ command_policy:
583
+ install: block
584
+ test: block
585
+ host: block
586
+ reason: >-
587
+ This phase selects; it does not verify. The investigators already ran their
588
+ probes — read their findings above, and the code only to decide whether two
589
+ findings are the same defect.
590
+ generic_loop:
591
+ on_soft_failure: { retries: 1, then: complete }
592
+ max_iterations: 2
593
+ fresh_context: true
594
+ until_bash: |
595
+ FACTS="${LASTLIGHT_FACTS_BIN:-$(command -v lastlight-facts || echo /opt/lastlight/bin/lastlight-facts)}"
596
+ "$FACTS" sites --check-select --dir .lastlight/pr-review
597
+
598
+ # `select`'s file → findings.json, the shape `post-review` reads: each item at
599
+ # its primary finding's location (with the line's text as `existingCode`, so
600
+ # the poster anchors it), severity from importance (must-fix outranks
601
+ # worth-mentioning for the inline slots; a `nit` is filed `internal`), and
602
+ # every hypothesis row by id in `internal[]` — the rows are the volume
603
+ # record, and `reconcile`'s conservation check then holds. A missing or
604
+ # invalid selection falls back to one item per site finding at the
605
+ # investigator's own importance, so a failed `select` still posts.
606
+ - name: site-finalize
607
+ label: Sites · findings.json
608
+ type: bash
609
+ skip_if:
610
+ - "analysisEnabled != true"
611
+ - "scratch.reviewTriage.depth == 'light'"
612
+ depends_on: [select]
613
+ trigger_rule: all_done
614
+ timeout_seconds: { from: reconcileTimeoutSeconds }
615
+ command: |
616
+ set -u
617
+ FACTS="${LASTLIGHT_FACTS_BIN:-$(command -v lastlight-facts || echo /opt/lastlight/bin/lastlight-facts)}"
618
+ if ! "$FACTS" sites --finalize --dir .lastlight/pr-review --repo .; then
619
+ echo "site-finalize: sites --finalize failed; reconcile's floor files every hypothesis internal"
620
+ fi
621
+ exit 0
622
+
623
+ # WHICH hypotheses `falsify` owes a verdict on — decided in code, not by the
624
+ # oracle. `lastlight-facts probe-plan` derives the owed set (a derived-Critical
625
+ # row, or a survey's own `needsProbe`), ranks it and caps it at
626
+ # `review.analysis.maxProbes`, writing `probes/plan.json` (the `probes` gate
627
+ # owes exactly that list) and `probes/plan.md` (the records falsify reads).
628
+ # The prompt used to say "probe every row whose severity is Critical", and a
629
+ # derived severity is never written on a row: measured 2026-09-27, the gate
630
+ # owed 21 rows on one case and falsify probed one. `--never-fail`: with no
631
+ # plan on disk the gate and the prompt fall back to the pre-plan owed set, so
632
+ # a failure here costs the cap, never a probe.
633
+ - name: probe-plan
634
+ label: Falsify · plan the probes
635
+ type: bash
636
+ skip_if:
637
+ - "analysisEnabled != true"
638
+ - "probesEnabled != true"
639
+ - "falsifyAttached != true"
640
+ - "scratch.reviewTriage.depth == 'light'"
641
+ depends_on: [units-ingest]
642
+ trigger_rule: all_done
643
+ timeout_seconds: { from: seedTimeoutSeconds }
644
+ command: |
645
+ set -u
646
+ FACTS="${LASTLIGHT_FACTS_BIN:-$(command -v lastlight-facts || echo /opt/lastlight/bin/lastlight-facts)}"
647
+ MAX_PROBES="{{maxProbes}}"
648
+ if [ -z "$MAX_PROBES" ] || [ "$MAX_PROBES" = "null" ]; then set --; else set -- --max-probes "$MAX_PROBES"; fi
649
+ "$FACTS" probe-plan --dir .lastlight/pr-review "$@" --never-fail
308
650
 
309
651
  # The only phase that RUNS anything. It reads the hypothesis RECORDS and the
310
652
  # code, never an earlier pass's transcript — a checker that can see the
@@ -312,19 +654,18 @@ phases:
312
654
  - name: falsify
313
655
  label: Falsify · run the probe
314
656
  prompt: prompts/review-falsify.md
315
- # Its OWN key, falling through to `models.review-survey`. Hard-wiring the
316
- # survey key meant the oracle's model could not be moved without moving all
317
- # five survey branches with it — two variables, so "is a cheap model good
318
- # enough at WRITING AND RUNNING a probe?" was not a runnable experiment.
319
- # The `{{#if}}` pair is load-bearing, exactly as on `adjudicate` below: a
320
- # bare unset `{{models.review-falsify}}` renders EMPTY, and an empty model
321
- # falls back to the DEFAULT model rather than to `models.review-survey`.
657
+ # Its OWN key, falling through to `models.review-survey`, so the oracle's
658
+ # model moves without the survey's. The `{{#if}}` pair is load-bearing, as
659
+ # on `site-review`.
322
660
  model: "{{#if models.review-falsify}}{{models.review-falsify}}{{/if}}{{#if !models.review-falsify}}{{models.review-survey}}{{/if}}"
323
661
  skip_if:
324
662
  - "analysisEnabled != true"
325
663
  - "probesEnabled != true"
664
+ - "falsifyAttached != true"
326
665
  - "scratch.reviewTriage.depth == 'light'"
327
- depends_on: [survey]
666
+ # `all_done`: a FAILED plan step never stopped falsify, which then reads
667
+ # the pre-plan owed set (see `probe-plan` above).
668
+ depends_on: [probe-plan]
328
669
  trigger_rule: all_done
329
670
  # A WHOLE-PHASE ceiling, across every round. `probeRounds` bounds how many
330
671
  # times the loop may go round and not what it may spend, and this is the
@@ -366,18 +707,29 @@ phases:
366
707
  "$FACTS" probes --dir .lastlight/pr-review
367
708
 
368
709
  # Writes findings to `.lastlight/pr-review/findings.json` — content only —
369
- # and never submits; `post-review` below does that. With the pipeline on the
370
- # brief collapses to one fast independent pass, since the surveys have
371
- # already done the deep work.
710
+ # and never submits; `post-review` below does that. Two arms of one prompt:
711
+ # the whole review with the pipeline OFF (`baseline`), and the single pass a
712
+ # `light` re-review gets.
713
+ #
714
+ # With the pipeline ON it does not run: `site-finalize` writes findings.json.
715
+ # The guard is ONE scratch flag because `skip_if` lists are OR-ed and the
716
+ # condition is an AND — pipeline on, depth not `light`. `runner.ts` seeds
717
+ # `skipReview` for the first, and the light harvest REPLACES the namespace,
718
+ # which drops the flag: a light review runs this phase. A context-key guard
719
+ # would survive the harvest, and a light review would then post nothing.
720
+ # Bare `== true`, so an absent flag (a run seeded before the key existed, a
721
+ # failed seed) runs the review — the direction every failure here points.
372
722
  - name: review
373
723
  label: Review
374
724
  # EXPLICIT: declaring `depends_on` anywhere disables the synthesized linear
375
725
  # chain for the WHOLE workflow, so without these two lines `review` and
376
- # `post-review` become roots and run in parallel with the surveys. And
726
+ # `post-review` become roots and run in parallel with the pipeline. And
377
727
  # `all_done`, because with `all_success` they would be skipped on every
378
728
  # deployment that has not enabled the pipeline.
379
- depends_on: [falsify]
729
+ depends_on: [site-finalize, falsify]
380
730
  trigger_rule: all_done
731
+ skip_if:
732
+ - "scratch.reviewTriage.skipReview == true"
381
733
  prompt: prompts/review.md
382
734
  skills: [pr-review, code-review]
383
735
  model: "{{models.review}}"
@@ -385,8 +737,8 @@ phases:
385
737
  # Review re-created CI by hand (`npm ci` then `npm run lint:check && npm
386
738
  # test`) although `{{ciSection}}` already carries the result (issue #403),
387
739
  # so the suite is blocked everywhere. An INSTALL is blocked only when the
388
- # evidence pipeline is on: then `prepare`/`falsify` own execution and this
389
- # pass is an abbreviated read. With it off this is the whole review, and the
740
+ # evidence pipeline is on — a light re-review there is a focused read. With
741
+ # it off this is the whole review, and the
390
742
  # `pr-review` skill's install-to-probe affordance is a measured fix (it is
391
743
  # why the reviewer could open `node_modules/@slack` at all), so it stays.
392
744
  command_policy:
@@ -395,184 +747,34 @@ phases:
395
747
  host: block
396
748
  reason: >-
397
749
  This phase does not run the build, the linter or the test suite: CI already
398
- answered those, in the Context section. Cite it, or report the claim for the
399
- adjudicator to weigh. Nothing outside the checkout counts: never search the
750
+ answered those, in the Context section. Cite it, or report the claim as
751
+ unverified. Nothing outside the checkout counts: never search the
400
752
  machine for a missing dependency — stop, and leave the claim unprobed.
401
753
 
402
- # #399 idea 2. One TypeSafe `systemOne` call PER HYPOTHESIS (not per
403
- # finding — hypotheses vastly outnumber findings, and per-hypothesis is the
404
- # volume a System-1 primitive is for), asking only the category axis
405
- # measured at AUC 0.897 (never correctness, measured dead at AUC 0.534).
406
- # Writes `.lastlight/pr-review/jev.json`, which `dossier` below renders as
407
- # an ADVISORY line per hypothesis — `adjudicate` still writes every
408
- # disposition itself. Measured 2026-09-22: 260 hypotheses / 8 cases, 83.6%
409
- # agreement with Sonnet's own adjudicate call on identical evidence,
410
- # $0.0053 — weakest on the rarest, highest-stakes categories, which is why
411
- # this annotates rather than decides.
412
- #
413
- # `dossier` depends on this PHASE (not just on the file it writes) so the
414
- # DAG itself enforces the ordering the render call needs — `jev.json` must
415
- # exist before `dossier --json`'s underlying render reads it.
754
+ # The conservation floor under `site-finalize`: `--repair` writes every
755
+ # hypothesis findings.json does not account for at `internal` tier, so a
756
+ # failed or partial finalize never loses a row. Idempotent, model-free, and
757
+ # exits 0 on every path.
416
758
  #
417
- # `|| true`: no `TYPESAFE_KEY`, a network error, a malformed answer — all of
418
- # it degrades to "no annotation" inside the CLI command itself (see
419
- # `jev-classify.ts`), and this phase must never fail the run on a third
420
- # party's API health that `legacy`/`dossier` deployments never needed at all.
421
- - name: jev-classify
422
- label: System-1 per-hypothesis pre-read
423
- type: bash
424
- skip_if:
425
- - "analysisEnabled != true"
426
- - "jevClassifyEnabled != true"
427
- - "scratch.reviewTriage.depth == 'light'"
428
- depends_on: [review]
429
- trigger_rule: all_done
430
- timeout_seconds: { from: jevTimeoutSeconds }
431
- command: |
432
- set -u
433
- FACTS="${LASTLIGHT_FACTS_BIN:-$(command -v lastlight-facts || echo /opt/lastlight/bin/lastlight-facts)}"
434
- "$FACTS" jev-classify --dir .lastlight/pr-review --repo . \
435
- {{#if jevModel}}--model "{{jevModel}}"{{/if}} || true
436
-
437
- # #399. Every record `adjudicate` needs, joined and quote-checked ONCE, by
438
- # code, instead of thirty shell calls inside the phase.
439
- #
440
- # Measured on the 8-case probes arm: `adjudicate` made 137 bash calls across
441
- # 8 adjudications — 35 turns and 30 bash on `1587-r2`, one `write`, about a
442
- # third of case cost — `cat`-ing hypothesis files `readHypothesisSet` had
443
- # parsed, transcripts `checkProbes` had located, the ledger twice, and dozens
444
- # of `sed -n '<N>p'` re-reads to check quotes it was handed.
445
- #
446
- # It goes to STDOUT as well as to disk, and that is the delivery mechanism:
447
- # `output_var` puts it in `{{phaseOutputs.dossier.output}}`, which
448
- # `review-adjudicate.md` interpolates. The alternative — a path in the prompt
449
- # — is the failure `context_file` exists to remove: of 120 non-spec survey
450
- # branches, 27 first-turn reads of a prompt-named path resolved against the
451
- # wrong root and hit ENOENT, and 23 never recovered. The on-disk copy is for
452
- # the eval harness's artifact capture and for the one case the dossier
453
- # deliberately does not inline in full, a truncated probe transcript.
454
- #
455
- # `|| true` and a fallback line for the same reason every deterministic phase
456
- # here has one: a non-zero exit fails the phase, and this is an input, not a
457
- # gate. An adjudication with no dossier is the shipped phase; an adjudication
458
- # that never ran is a review that never posts.
459
- - name: dossier
460
- label: Adjudication dossier
461
- type: bash
462
- skip_if:
463
- - "analysisEnabled != true"
464
- - "dossierEnabled != true"
465
- - "scratch.reviewTriage.depth == 'light'"
466
- # `jev-classify` too, not just `review` — `all_done` already tolerates a
467
- # skipped dependency (it is what `review` itself already relies on here;
468
- # the stricter `none_failed_min_one_success` below is for `adjudicate`,
469
- # which must not run if `review` genuinely FAILED). Declaring the
470
- # dependency is what makes the DAG run `jev-classify` to completion (or
471
- # skip) before this phase reads the file it writes.
472
- depends_on: [review, jev-classify]
473
- trigger_rule: all_done
474
- output_var: dossier
475
- timeout_seconds: { from: reconcileTimeoutSeconds }
476
- command: |
477
- set -u
478
- FACTS="${LASTLIGHT_FACTS_BIN:-$(command -v lastlight-facts || echo /opt/lastlight/bin/lastlight-facts)}"
479
- "$FACTS" dossier --dir .lastlight/pr-review --repo . \
480
- --out .lastlight/pr-review/dossier.md || true
481
- if [ -s .lastlight/pr-review/dossier.md ]; then
482
- cat .lastlight/pr-review/dossier.md
483
- else
484
- echo "DOSSIER NOT AVAILABLE — \`lastlight-facts dossier\` produced nothing."
485
- echo "Read .lastlight/pr-review/ yourself: hypotheses/*.jsonl, probes/verdicts.jsonl,"
486
- echo "probes/*.txt, findings.json, and \`lastlight-facts findings --ledger\`."
487
- fi
488
-
489
- # The exit of the funnel, and the only phase that can move recall: it ranks,
490
- # re-tiers and demotes the hypotheses into the review. It DELETES only when a
491
- # probe transcript refutes a claim.
492
- #
493
- # A SIBLING of `post-review`, not a link in its chain. `trigger_rule` is
494
- # per-node, so folding it into `post-review`'s deps would force that node to
495
- # `all_done` and lose the invariant that a FAILED REVIEW MUST NOT POST.
496
- # Declared first, so the sequential scheduler still runs it first.
497
- - name: adjudicate
498
- label: Adjudicate
499
- skills: [adjudicate-pass]
500
- prompt: prompts/review-adjudicate.md
501
- # The `{{#if}}` pair is load-bearing: a bare unset `{{models.review-adjudicate}}`
502
- # renders EMPTY, and an empty model falls back to the DEFAULT model rather
503
- # than to `models.review`.
504
- model: "{{#if models.review-adjudicate}}{{models.review-adjudicate}}{{/if}}{{#if !models.review-adjudicate}}{{models.review}}{{/if}}"
505
- variant: "{{variants.review}}"
506
- command_policy:
507
- install: block
508
- test: block
509
- host: block
510
- reason: >-
511
- This phase does not execute code. Weigh the probe transcripts falsify already
512
- wrote and the CI result in the Context section; an unsettled claim is demoted,
513
- not re-run. Nothing outside the checkout counts: never search the machine for
514
- a missing dependency — the hypothesis stays unprobed.
515
- skip_if:
516
- - "analysisEnabled != true"
517
- - "scratch.reviewTriage.depth == 'light'"
518
- # `none_failed_min_one_success`, NOT `all_success`, and the difference is
519
- # load-bearing in both directions:
520
- #
521
- # - a FAILED review must still not post, and it does not: a failed dep
522
- # fails this rule exactly as it fails `all_success`;
523
- # - a SKIPPED `dossier` must not take this phase down with it, and under
524
- # `all_success` it WOULD. `evaluateTriggerRule` requires every dep to be
525
- # literally `succeeded`, and `skip_if` sets `skipped`
526
- # (`scheduler.ts` — "Uses the same non-failing skip mechanics"), so on
527
- # every deployment left on `review.analysis.adjudicate: legacy` the
528
- # dossier skips and `all_success` would silently skip the adjudicator
529
- # with it. The whole pipeline would go quiet with no phase failing.
530
- #
531
- # Declaring the dependency at all is what ORDERS the dossier before this
532
- # phase. The sequential scheduler happens to run the earliest-declared ready
533
- # node, so declaration order alone would work today — but a data dependency
534
- # that survives only until someone reorders the file is not a dependency.
535
- depends_on: [review, dossier]
536
- trigger_rule: none_failed_min_one_success
537
- generic_loop:
538
- on_soft_failure: { retries: 1, then: complete }
539
- max_iterations: 2
540
- fresh_context: true
541
- # The CONSERVATION gate: every hypothesis id must appear with exactly one
542
- # disposition, and a `dropped` one must name a transcript that EXISTS.
543
- # Silent omission is impossible by construction rather than by
544
- # instruction. Literal shell — no `{{` markers allowed.
545
- until_bash: |
546
- FACTS="${LASTLIGHT_FACTS_BIN:-$(command -v lastlight-facts || echo /opt/lastlight/bin/lastlight-facts)}"
547
- "$FACTS" findings --dir .lastlight/pr-review
548
-
549
- # The floor under that gate: reaching `max_iterations` unsatisfied is not a
550
- # phase failure in this engine, so hypotheses would otherwise go unaccounted
551
- # for. `--repair` writes every uncovered hypothesis into findings.json at
552
- # `internal` tier and promotes back any `dropped` entry whose transcript does
553
- # not exist. Idempotent, model-free, and exits 0 on every path.
554
- #
555
- # It is also where a finding's SEVERITY is derived (issue #405): every
556
- # hypothesis-derived finding gets the severity its evidence records and probe
557
- # verdicts imply (`finding-severity.ts`), stamped over whatever `adjudicate`
558
- # wrote — which is the mechanism behind "the adjudicator does not choose it".
559
- # `post-review` ranks both posting budgets on that value.
759
+ # It is also where a hypothesis-derived finding's SEVERITY is derived (issue
760
+ # #405): the severity its evidence records and probe verdicts imply
761
+ # (`finding-severity.ts`). `post-review` ranks both posting budgets on it.
560
762
  - name: reconcile
561
763
  label: Reconcile · the conservation floor
562
764
  type: bash
563
765
  skip_if:
564
766
  - "analysisEnabled != true"
565
767
  - "scratch.reviewTriage.depth == 'light'"
566
- depends_on: [adjudicate]
567
- # `all_done`: the floor must apply even when the adjudicator failed — that
568
- # is precisely when there is something to repair.
768
+ depends_on: [site-finalize]
769
+ # `all_done`: the floor must apply even when finalize failed — that is
770
+ # precisely when there is something to repair.
569
771
  trigger_rule: all_done
570
772
  timeout_seconds: { from: reconcileTimeoutSeconds }
571
773
  command: |
572
774
  set -u
573
775
  FACTS="${LASTLIGHT_FACTS_BIN:-$(command -v lastlight-facts || echo /opt/lastlight/bin/lastlight-facts)}"
574
776
  if ! "$FACTS" findings --dir .lastlight/pr-review --repair; then
575
- echo "reconcile: could not repair findings.json; it stands as the review phase wrote it"
777
+ echo "reconcile: could not repair findings.json; it stands as site-finalize wrote it"
576
778
  fi
577
779
  exit 0
578
780
 
@@ -581,7 +783,25 @@ phases:
581
783
  # and diff — so the agent never hand-copies metadata. Anchors each finding to
582
784
  # a changed line, demotes off-diff findings to the body, and posts one
583
785
  # review. Idempotent on resume.
786
+ #
787
+ # `none_failed` on `review` alone:
788
+ #
789
+ # - a FAILED `review` never posts — a failed dep fails the rule;
790
+ # - a `review` SKIPPED by its own guard (pipeline on) posts what
791
+ # `site-finalize` + `reconcile` wrote — the default rule, `all_success`,
792
+ # would skip this phase with it and post nothing;
793
+ # - a failed `select`, `site-finalize` or `reconcile` still posts —
794
+ # the money property: a red run that posts nothing leaves both per-head
795
+ # dedups blank, and the thirty-minute sweep re-buys the whole pipeline
796
+ # on the same SHA forever. That is why this does NOT also depend on
797
+ # `reconcile`: `none_failed_min_one_success` over both would withhold the
798
+ # post whenever `reconcile` itself failed.
799
+ #
800
+ # So the floor runs before the post by DECLARATION ORDER — every pipeline
801
+ # phase is declared earlier and the sequential scheduler takes the earliest
802
+ # ready node — exactly as it did while `review` always ran.
584
803
  - name: post-review
585
804
  label: Post inline review
586
805
  type: post-review
587
806
  depends_on: [review]
807
+ trigger_rule: none_failed