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
@@ -18,12 +18,11 @@ botName: last-light
18
18
 
19
19
  models:
20
20
  default: anthropic/claude-sonnet-4-6
21
- # The five `pr-review.yaml` survey branches and `falsify`. SET, not an
22
- # example — see the note below: this is the measured RECALL winner for
23
- # hypothesis generation, not a cost downgrade, and leaving it unset silently
24
- # ran six Sonnet phases under every number the pipeline was tuned on. A
21
+ # The unit survey (`survey-units`), and the fall-through of `review-site`
22
+ # and `review-falsify`. SET, not an example — see the note below: this is the
23
+ # measured RECALL winner for hypothesis generation, not a cost downgrade. A
25
24
  # deployment whose `models.default` points at a non-Anthropic provider MUST
26
- # override this in its overlay `config.yaml`, or these six phases reach for a
25
+ # override this in its overlay `config.yaml`, or these phases reach for a
27
26
  # provider it has no key for.
28
27
  review-survey: anthropic/claude-haiku-4-5-20251001
29
28
  # The `triage` phase of `pr-review.yaml` — "how much review is this push
@@ -38,9 +37,11 @@ models:
38
37
  # screener: anthropic/claude-haiku-4-5-20251001 # the prompt-injection screener
39
38
  # diagnose: anthropic/claude-haiku-4-5-20251001 # the CI-failure classifier
40
39
  # pr-fix-retry: anthropic/claude-opus-4-8 # used above fix.escalateModelAfterAttempt
41
- # review-adjudicate: anthropic/claude-sonnet-4-6 # the adjudication pass
42
40
  # review-summary: openai/gpt-5.4-mini # post-review's summary, written after the caps
43
41
  # review-falsify: anthropic/claude-haiku-4-5-20251001 # the probe oracle
42
+ # review-site: anthropic/claude-haiku-4-5-20251001 # a site investigator
43
+ # review-site-pair: opencode/deepseek-v4-flash # a second investigator per site (opt-in)
44
+ # review-select: anthropic/claude-sonnet-4-6 # the sites engine's selection pass
44
45
  # A per-task entry wins over `default`. `classifier`/`screener` are the cheap
45
46
  # one-shot helpers (src/engine/llm.ts); when unset they fall back to the first
46
47
  # configured provider's fast model, NOT `default`.
@@ -54,47 +55,43 @@ models:
54
55
  # each fix run costs one extra call at the default model until you pin it.
55
56
  #
56
57
  # `review-survey` is SET above, and it is the one entry in this block that is
57
- # not an example. It is the key the five survey branches of `pr-review.yaml`
58
- # declare (`model: "{{models.review-survey}}"`, one per obligation family),
59
- # and the `falsify` phase's fall-through.
58
+ # not an example. It is the model of `survey-units` (one call per unit), and
59
+ # the fall-through of `review-site` and `review-falsify`.
60
60
  #
61
- # Pinning it to Haiku 4.5 is NOT a cost downgrade, and that is the unusual
62
- # part: on review RECALL, Haiku 4.5 BEATS Sonnet 4.6 on two independent evals
63
- # — 41.2% vs 22.1% on the Martian corpus. It is the better model for
64
- # HYPOTHESIS GENERATION, which is what a survey branch does; its price is
65
- # merely what makes a five-way fan-out affordable inside the pipeline's 2–3x
66
- # budget. It is a different question from the SAYING phases (`review`,
67
- # `adjudicate`), which are not pinned here.
61
+ # Pinning it to Haiku 4.5 is NOT a cost downgrade: on review RECALL, Haiku
62
+ # 4.5 BEAT Sonnet 4.6 on two independent evals — 41.2% vs 22.1% on the
63
+ # Martian corpus — for HYPOTHESIS GENERATION, which is what a survey does.
64
+ # It is a different question from the SAYING phases (`review`, `select`),
65
+ # which are not pinned here.
68
66
  #
69
67
  # It was deliberately left unset for a long time, for the `diagnose` reason
70
68
  # above — these are Anthropic model ids, and a deployment that overrode only
71
- # `default` to another provider would find six phases reaching for a provider
72
- # it has no key for. That reason has not gone away; it is now handled the
73
- # other way round, because the cost of the unset default turned out to be
74
- # worse. Unset, all six fell through to `default` (Sonnet) SILENTLY, so an
75
- # operator who enabled the pipeline ran a configuration no measurement in
76
- # `docs/plans/deterministic-pr-levers.md` describes — every recall, cost and
77
- # latency number on record assumes Haiku surveys. A wrong-provider failure is
78
- # loud on the first run; a quietly-different model is not.
69
+ # `default` to another provider would find the survey reaching for a provider
70
+ # it has no key for. That reason has not gone away; it is handled the other
71
+ # way round, because unset, the survey fell through to `default` SILENTLY and
72
+ # an operator who enabled the pipeline ran a configuration no measurement
73
+ # describes. A wrong-provider failure is loud on the first run; a
74
+ # quietly-different model is not.
79
75
  #
80
76
  # SO: a non-Anthropic deployment must override this key in its overlay
81
77
  # `config.yaml` (a cheap, fast model of its own provider), exactly as it
82
78
  # already overrides `models.default`.
83
79
  #
84
80
  # `review-falsify` is the ORACLE's own key — the one phase that runs code.
85
- # Unset, it falls through to `review-survey` (its template is the same
86
- # `{{#if}}` pair `adjudicate` uses, so an unset key lands on the survey model
87
- # and not on `default`), which is exactly the behaviour before the key
88
- # existed. It exists so the oracle's model can be moved on its own: it was
89
- # hard-wired to `review-survey`, so asking "is a cheap model good enough at
90
- # WRITING AND RUNNING a probe?" meant moving all five survey branches too —
91
- # two variables, and therefore not a runnable experiment.
81
+ # Unset, it falls through to `review-survey` (an `{{#if}}` pair, so an unset
82
+ # key lands on the survey model and not on `default`). Not attached yet —
83
+ # see `review.analysis.probes`.
92
84
  #
93
- # `review-adjudicate` is the adjudicate phase's own key in `pr-review.yaml` —
94
- # the RANKING pass over what the surveys found, a different task from survey
95
- # discovery, so it can be moved independently of `models.review`. Unset, it
96
- # falls through to `models.review` (the phase's template guards it), so a
97
- # deployment that never sets it keeps today's behaviour exactly.
85
+ # `review-site` and `review-select` are the `sites` review engine's keys: the
86
+ # site investigators fall through to `review-survey`, and `select` — the
87
+ # one call that merges and orders their findings — to `models.review`.
88
+ # Measured (docs/plans/pr-review-units-sites.md): cheap investigators
89
+ # (`openai/gpt-6-luna`, `opencode/deepseek-v4-flash`, medium) beat Haiku on
90
+ # recall and posted precision at ¼–½ the cost. Left UNSET here for the
91
+ # `diagnose` reason — a default must be a provider every deployment has a key
92
+ # for — so pin it in your overlay. `review-site-pair` is OFF unless set: it
93
+ # puts a second investigator, on this model, on every selected site
94
+ # (`review.analysis.siteTop`), and `select` merges what the two agree on.
98
95
 
99
96
  # Provider endpoints. Ships EMPTY — every provider keeps the endpoint baked into
100
97
  # the registry (packages/shared/src/providers.ts), which is exactly today's
@@ -358,6 +355,20 @@ explore:
358
355
 
359
356
  review:
360
357
  postsCheck: false # post the `last-light/review` Check Run
358
+ # With postsCheck on, also post the PLACEHOLDER check a deferred review leaves
359
+ # (`queued` while after-checks waits for CI, `neutral` while on-request waits
360
+ # for a human). `false` = the check appears only once a review actually starts,
361
+ # so under after-checks nothing of ours shows on a PR until its CI settles —
362
+ # it still shows "in progress" and then the verdict (or "didn't complete").
363
+ # Trade-off: a required `last-light/review` has nothing to wait on until the
364
+ # review starts. Operator-only.
365
+ placeholderCheck: true
366
+ # The 30-min review sweep is the release valve for CI that never concludes,
367
+ # so it reviews a PR whose checks are still `pending` — but only once they
368
+ # have been pending this long (minutes, dated from the oldest pending check).
369
+ # Without it the sweep reviewed mid-CI, minutes after a push. `0` = no grace.
370
+ # Operator-only.
371
+ sweepPendingGraceMinutes: 60
361
372
  # When a pr-review run is triggered:
362
373
  # eager — on pr.opened / synchronize / reopened, in parallel with CI
363
374
  # after-checks — once the head SHA's checks SETTLE, either colour (default:
@@ -444,36 +455,21 @@ review:
444
455
  # is absent from the template context rather than present-and-empty. Each
445
456
  # stage lands dark and is switched on per deployment once it is measured.
446
457
  #
447
- # What `enabled: true` adds today (WP0, the `spec` axis):
448
- # - `{{prBody}}` + `{{linkedIssues}}` — the PR body and the issues it closes
449
- # (`closingIssuesReferences`), neither of which reached a prompt before.
450
- # - `{{specObligations}}` — one obligation per acceptance criterion found in
451
- # the issue/PR body, each naming BOTH ENDS of the mechanism: the criterion
452
- # itself, and the changed files that could satisfy it with `found: false`.
453
- # A one-ended seed measures WORSE than no seed (IRIS ablation: -3), which
454
- # is why the second end is the mechanical changed-file list and never
455
- # prose.
456
- # - the split verdict: `findings.json` may carry
457
- # `verdict: { spec, standards }` and a `fail` on either axis stops the
458
- # review being an APPROVE, so a clean standards pass can no longer hide a
459
- # spec miss (issue #271 fix 7).
458
+ # What `enabled: true` adds: `facts` → `seed` → the unit survey → the `sites`
459
+ # review engine → `reconcile`, which together write the findings.json that
460
+ # `post-review` posts (the path is spelled out at `siteConcurrency` below).
461
+ # The `review` phase then runs only on a light re-review. Spec obligations —
462
+ # one per acceptance criterion in the linked issue / PR body, each naming
463
+ # BOTH ENDS (the criterion and the changed files that could satisfy it) —
464
+ # are cut into units with the facts-derived ones.
460
465
  #
461
466
  # OPERATOR-ONLY — unlike every other `review:` key, a repo may not set this.
462
467
  # It is spend, with no "more conservative" direction to clamp towards.
463
- # What `enabled: true` additionally adds from WP3 (the facts-derived families):
464
- # - a `facts` phase writing .lastlight/pr-review/facts.json (no model spend)
465
- # - a `seed` phase turning it into obligations.json + one rendered block per
466
- # family, each naming BOTH ENDS of a mechanism
467
- # - five survey branches, one per live family, each appending to its OWN
468
- # hypotheses/<family>.jsonl — no pass ever reads or rewrites another's,
469
- # which makes consensus collapse impossible by construction rather than
470
- # by instruction
471
- #
472
- # Neither phase can run where `lastlight-facts` is not resolvable. That is
468
+ # No analysis phase can run where `lastlight-facts` is not resolvable. That is
473
469
  # true of the SANDBOX IMAGE today (WP2 is what installs it); the eval harness
474
470
  # runs `--sandbox none` on the host, where it is. Set LASTLIGHT_FACTS_BIN to
475
471
  # point at a specific build. A missing binary degrades to a `coverage: "none"`
476
- # envelope and the survey phases say so — it never fails the run.
472
+ # envelope and the downstream phases say so — it never fails the run.
477
473
  analysis:
478
474
  enabled: false
479
475
  # A SAFETY BOUND, not a budget — it should never bind on a real PR. The
@@ -493,9 +489,9 @@ review:
493
489
  maxSpecObligations: 40
494
490
  # The five facts-derived families are bounded PER FAMILY, not pooled:
495
491
  # contract 12, enforcement 12, state 8, security 8, tests 8 (FAMILY_CAPS in
496
- # packages/code-facts/src/seed.ts). Each family's obligations feed exactly
497
- # ONE survey branch, so the cost is per branch and a pooled cap never bound
498
- # the fattest one; and cross-family ranking prices incommensurable mechanism
492
+ # packages/code-facts/src/seed.ts). Measured on the (since removed) agent
493
+ # survey, where each family fed one branch: a pooled cap never bound the
494
+ # fattest one, and cross-family ranking prices incommensurable mechanism
499
495
  # classes against each other — measured, `contract` minted 89 across the
500
496
  # eight gate cases while `security` minted 3, and the pool went to contract.
501
497
  #
@@ -504,7 +500,10 @@ review:
504
500
  # that raising one ceiling is a bounded act rather than an unbounded one.
505
501
  maxObligations: 48
506
502
 
507
- # Which obligation BLOCK the six families are handed. `full` | `minimal`.
503
+ # Which obligation contract `lastlight-facts seed` records. `full` |
504
+ # `minimal`. Today it only changes how strictly the `discharge` post-check
505
+ # in `units-ingest` grades; the history below was measured on the (since
506
+ # removed) agent survey.
508
507
  #
509
508
  # This is a CONTROL, not a dial. On 2026-08-23 the block gained a mandatory
510
509
  # discharge contract (a `discharge` field the row can actually hold a code
@@ -535,51 +534,6 @@ review:
535
534
  # telemetry (and the clean-discharge demotion it enables at the posting
536
535
  # boundary), at the cost of the verification-report volume above.
537
536
  obligationContract: minimal
538
- # What `adjudicate` is handed, and what shape it writes back (#399).
539
- #
540
- # legacy — the shipped phase. The prompt names the files and the model
541
- # shells out to assemble them, then writes a `tier` and a
542
- # `confidence` per finding.
543
- # dossier — a deterministic `dossier` phase renders every record the
544
- # phase needs and the harness attaches it, and the model writes
545
- # typed attributes (`claim` / `category` / `fix`) from which a
546
- # pure function derives the tier. `confidence` is not asked for.
547
- #
548
- # ONE key for both halves deliberately: they move the same phase's measured
549
- # surface — its input and its output — so shipping them together costs one
550
- # comparability break with the archive instead of two, and one arm validates
551
- # both.
552
- #
553
- # What it targets, measured on the 8-case probes arm: adjudicate spends 137
554
- # bash calls across 8 adjudications (35 turns, 30 of them bash on the stress
555
- # case) re-deriving records the harness already holds — about a third of
556
- # case cost — and makes its actual judgement at the end of that transcript.
557
- #
558
- # jev — implies `dossier` (same rendering, same typed output) and
559
- # additionally runs `jev-classify`: one TypeSafe `systemOne`
560
- # call PER HYPOTHESIS (not per finding — hypotheses vastly
561
- # outnumber findings, and per-hypothesis is the volume a
562
- # System-1 primitive is for), asking only the category axis
563
- # measured at AUC 0.897 (never correctness, measured dead at
564
- # AUC 0.534). Its category is rendered into the dossier as an
565
- # ADVISORY line — Sonnet still writes every disposition
566
- # itself. Measured 2026-09-22: 260 hypotheses / 8 cases,
567
- # 83.6% agreement with Sonnet's own call on identical
568
- # evidence, $0.0053. Weakest on the rarest, highest-stakes
569
- # categories (`defect` 33%, `correctness-risk` 40% recall
570
- # against Sonnet) — that is why it annotates rather than
571
- # decides. Needs `TYPESAFE_KEY` (or `TYPESAFE_API_KEY`); its
572
- # absence degrades the phase to "no annotation", never a
573
- # failed run.
574
- #
575
- # `legacy` until an arm has run for each. An unrecognised value lands there
576
- # too.
577
- adjudicate: legacy
578
- # The TypeSafe model `jev-classify` calls, under `adjudicate: "jev"`.
579
- # `null` = the CLI's own default (`TYPESAFE_MODEL` env, else `jev-latest`).
580
- # Kept out of the `models:` map above — TypeSafe is a distinct provider
581
- # from the `provider/model` chat models that map resolves.
582
- jevModel: null
583
537
 
584
538
  # Which D2 minting rules `lastlight-facts seed` runs beyond the original
585
539
  # four. A comma-list; the valid tokens are `all-in-diff` (contract
@@ -594,35 +548,57 @@ review:
594
548
  # typo'd arm is loud rather than silently running baseline.
595
549
  mint: all-in-diff,registrations
596
550
 
597
- # RECORDED, NOT CONSUMED. The fan-out's branch list in `pr-review.yaml` is
598
- # the authority (five branches; `tests` has no seeder and no branch), and
599
- # nothing reads this key to pick or drop branches — it exists so the value
600
- # an operator believed they set is on the record. A previous design DID
601
- # consume a count (defaulted to 3 against six families, never recording
602
- # which three ran), which is exactly why the branch list is now the one
603
- # authority.
604
- surveyPasses: 6
605
551
 
606
- # How many of those families run AT ONCE (WP11c).
552
+ # How many `site-review` investigators run AT ONCE.
607
553
  #
608
554
  # A CEILING the run clamps again per backend, never the effective value. On
609
555
  # the shipped default backend (gondolin) each agent session is a QEMU
610
556
  # micro-VM inside the harness process, so it pins to 1 and this key changes
611
- # nothing at all until that is measured; `none` and `docker` take it as
612
- # written.
613
- #
614
- # Six because the six families write six disjoint, append-only
615
- # `hypotheses/<family>.jsonl` and never read each other's — there was never
616
- # an ordering constraint between them, only a scheduler that ran one DAG
617
- # node at a time. Chained, they were 851s of a 29-minute review (49% of the
618
- # wall clock); concurrent, they cost the slowest single family.
619
- #
620
- # Lower it to bound provider rate-limit pressure or memory, NOT to bound
621
- # spend: six passes cost the same in tokens either way.
622
- surveyConcurrency: 6
557
+ # nothing at all until that is measured; `none` takes it up to 16 (a
558
+ # paired top-8 fan-out) and `docker` up to 6. Lower it to bound provider rate-limit pressure or memory, NOT to
559
+ # bound spend: the investigators cost the same in tokens either way.
560
+ # `surveyConcurrency` is still read as its old name.
561
+ siteConcurrency: 6
562
+
563
+ # How many vote-ranked sites get an investigator (1–8). Top 5 put 16 of 25
564
+ # gold-mapped rows inside a selected site on the Martian audit, top 8 put
565
+ # 21, for ~2 more investigators per PR. Setting `models.review-site-pair`
566
+ # puts a SECOND investigator on every selected site (a different model:
567
+ # two models' blind spots are disjoint), so the sessions double.
568
+ siteTop: 5
569
+
570
+ # The analysis path (docs/plans/pr-review-units-sites.md): `facts` and
571
+ # `seed`, then the unit survey — `lastlight-facts units` (deterministic
572
+ # units: a symbol, a module, the PR), ONE bounded, non-agentic model call
573
+ # per unit on `models.review-survey`, and `lastlight-facts units-ingest`,
574
+ # which writes `hypotheses/<family>.jsonl` — then the `sites` engine: the
575
+ # rows are only a VOLUME signal, `lastlight-facts sites --plan` ranks the
576
+ # places they point at (distinct-unit votes, span ≤ 60, test files
577
+ # skipped), one investigator per top-5 site writes grounded findings (the
578
+ # `site-review` fan-out, model `models.review-site`, else review-survey),
579
+ # `merge` pools them and `select` (one agent call, model
580
+ # `models.review-select`, else review) merges duplicates and orders them by
581
+ # importance. Every row is filed `internal`. `survey-units` reads and writes
582
+ # the workspace from the harness, so config load REFUSES `enabled: true` on
583
+ # the kubernetes backend (no host checkout).
584
+ # Unit calls in flight at once in `survey-units`. No backend
585
+ # clamp — they are HTTP requests from the harness, not sandboxes — so lower
586
+ # it only to ease provider rate limits. Spend is the same either way.
587
+ surveyUnitConcurrency: 16
588
+ # The WHOLE-PHASE deadline on `survey-units`, in seconds — one
589
+ # AbortController over every unit call. A unit not finished by then is
590
+ # recorded `ok: false` ("phase deadline") and `units-ingest` records each
591
+ # obligation it owned as unanswered; the phase itself still succeeds, so a
592
+ # slow provider degrades the survey rather than failing the review.
593
+ surveyUnitsTimeoutSeconds: 600
623
594
 
624
595
  # ── WP4: `prepare` (the affordance) + `falsify` (the oracle) ──────────────
625
596
  #
597
+ # NOT ATTACHED to the sites engine yet: the three probe phases skip whatever
598
+ # this says, because nothing reads their output
599
+ # (docs/plans/pr-review-units-sites.md, stage 5). The keys stay so the
600
+ # re-attachment is a wiring change, not a config one.
601
+ #
626
602
  # A SECOND switch under an already-gated block, and TRI-STATE — the middle
627
603
  # value is the point of it.
628
604
  #
@@ -633,9 +609,8 @@ review:
633
609
  # with `--no-install`, so it writes a real `env.json`
634
610
  # (`install: "skipped"`, `installed` still read off the
635
611
  # filesystem) and `falsify` gets the fact its prompt is written
636
- # against: it already branches on `installed: false`, records
637
- # what it cannot run as `unprobed` with a reason, and those
638
- # hypotheses SURVIVE to adjudication. The oracle was written
612
+ # against: it already branches on `installed: false` and
613
+ # records what it cannot run as `unprobed` with a reason. The oracle was written
639
614
  # for the zero-install world; one shared gate was all that kept
640
615
  # it out of one. Seconds of CPU, no package manager, no test
641
616
  # suite, no `postinstall` from a pull request head.
@@ -695,6 +670,12 @@ review:
695
670
  # five-line existence gate, not a validator — v2's full quote validator was
696
671
  # overkill and cost 2.4x for a worse result.
697
672
  probeRounds: 2
673
+ # At most this many hypotheses go in front of `falsify`, `null` for no cap.
674
+ # `lastlight-facts probe-plan` derives the owed set (a derived-Critical row,
675
+ # or a survey's own `needsProbe`), ranks it and cuts it here. Provisional:
676
+ # under the unit survey 16–25 rows were owed on the 1587 cases. The
677
+ # micro-falsify eval is what should move this number.
678
+ maxProbes: 8
698
679
  # The WHOLE-PHASE ceiling on `falsify`, across every round. It had none at
699
680
  # all until the oracle could run without an install, and `probeRounds` was
700
681
  # never a budget: a round count bounds how many times the loop may go round,
@@ -703,11 +684,6 @@ review:
703
684
  # construction (a differential `git` run, a copied pure function under plain
704
685
  # `node`) and whose real cost is model latency.
705
686
  falsifyTimeoutSeconds: 600
706
- # The WHOLE-PHASE ceiling on `jev-classify`, under `adjudicate: "jev"`.
707
- # Each call is a TypeSafe `systemOne` round trip (~100ms typically) but the
708
- # phase makes one per hypothesis and a case can carry dozens; 120s covers
709
- # a slow provider day without threatening the falsify-sized budget above.
710
- jevTimeoutSeconds: 120
711
687
  # The attention boundary (WP6b). Preserving internal recall and spending a
712
688
  # human's attention are two different budgets; conflating them is how a
713
689
  # recall-first reviewer becomes unreadable.
@@ -597,6 +597,17 @@ export declare function loadConfig(): LastLightConfig;
597
597
  * `tests/config.test.ts` pins the two together.
598
598
  */
599
599
  export declare function defaultRouteConfig(): RouteConfig;
600
+ /**
601
+ * `review.analysis` needs a workspace the HARNESS can read and write: the
602
+ * in-process `survey-units` phase reads `units.json` from the host checkout and
603
+ * writes one response per unit back into it for the sandboxed `units-ingest`.
604
+ * A backend with no host checkout ({@link HOST_READABLE_WORKSPACE}, i.e.
605
+ * `kubernetes`) would survey nothing on every review, so the combination is
606
+ * refused at startup, naming both keys — a boot error an operator sees once
607
+ * beats a degraded review on every run. (The repo layer cannot reach this:
608
+ * `review.analysis` is operator-only.)
609
+ */
610
+ export declare function assertReviewAnalysisSupported(enabled: boolean, backend: SandboxBackend): void;
600
611
  export declare function parseOtelCollectorHostsFromEnv(env?: NodeJS.ProcessEnv): string[];
601
612
  export declare function resolveModel(models: ModelConfig, taskType: string): string;
602
613
  export declare function resolveVariant(variants: VariantConfig, taskType: string): string | undefined;
@@ -9,6 +9,7 @@ import { DEFAULT_REPO_CONFIG_ALLOW_KEYS, } from "lastlight-shared/repo-config-sc
9
9
  import { isPgDriver, isPostgresUrl, redactDbUrl, PG_DRIVERS, } from "lastlight-shared/database-url";
10
10
  import { providerOverridesFromEnv, } from "lastlight-shared/providers";
11
11
  import { installProviderOverrides } from "./provider-registry.js";
12
+ import { HOST_READABLE_WORKSPACE } from "../workflows/handlers/host-repo-dir.js";
12
13
  import { logger } from "../logging/logger.js";
13
14
  const log = logger("config");
14
15
  /**
@@ -50,7 +51,7 @@ function loadDotEnv(path) {
50
51
  // compiles — has to name their shape and their shipped defaults. Imported for
51
52
  // in-file use and re-exported so `../config/config.js` stays the one import
52
53
  // surface for the runtime config shape.
53
- import { DIAGNOSIS_CLASSES, coerceAdjudicateMode, coerceProbeMode, defaultDependenciesConfig, defaultFixConfig, defaultReviewPolicy, isDependencyImpact, isDiagnosisClass, isReviewTrigger, } from "lastlight-shared/config-types";
54
+ import { DIAGNOSIS_CLASSES, coerceProbeMode, defaultDependenciesConfig, defaultFixConfig, defaultReviewPolicy, isDependencyImpact, isDiagnosisClass, isReviewTrigger, } from "lastlight-shared/config-types";
54
55
  export { defaultDependenciesConfig, defaultFixConfig, defaultNotificationsConfig, defaultReviewPolicy, } from "lastlight-shared/config-types";
55
56
  export { DEFAULT_REPO_CONFIG_ALLOW_KEYS } from "lastlight-shared/repo-config-schema";
56
57
  let currentConfig;
@@ -234,6 +235,10 @@ function normalizeAutonomyStages(raw) {
234
235
  }
235
236
  return out;
236
237
  }
238
+ /** `review.analysis.siteTop`: an integer 1–8, else the packaged default. */
239
+ function siteTopOrDefault(raw, fallback) {
240
+ return typeof raw === "number" && Number.isInteger(raw) && raw >= 1 && raw <= 8 ? raw : fallback;
241
+ }
237
242
  /**
238
243
  * The budget bounds. Every leaf is `nonNegativeNumber` + the packaged value:
239
244
  * `0` is a real setting ("refuse everything"), while a negative or non-numeric
@@ -303,7 +308,7 @@ export function withReviewDurations(policy, operator) {
303
308
  seedTimeoutSeconds: operator.analysis.seedTimeoutSeconds,
304
309
  reconcileTimeoutSeconds: operator.analysis.reconcileTimeoutSeconds,
305
310
  falsifyTimeoutSeconds: operator.analysis.falsifyTimeoutSeconds,
306
- jevTimeoutSeconds: operator.analysis.jevTimeoutSeconds,
311
+ surveyUnitsTimeoutSeconds: operator.analysis.surveyUnitsTimeoutSeconds,
307
312
  },
308
313
  };
309
314
  }
@@ -335,6 +340,28 @@ function applyDeprecatedGateAlias(layer, label) {
335
340
  gateTimeoutSeconds: legacy,
336
341
  });
337
342
  }
343
+ /**
344
+ * `review.analysis.surveyConcurrency`, the old name of `siteConcurrency`
345
+ * (it bounded the agent survey fan-out, removed with it), applied to ONE layer
346
+ * in place before the merge — as {@link applyDeprecatedGateAlias} does, and for
347
+ * the same reason: `default.yaml` carries the new name, so an alias resolved
348
+ * after the merge would always lose to the packaged value.
349
+ */
350
+ function applySiteConcurrencyAlias(layer, label) {
351
+ const review = layer && isPlainObject(layer.review) ? layer.review : undefined;
352
+ const analysis = review && isPlainObject(review.analysis) ? review.analysis : undefined;
353
+ if (!analysis || !("surveyConcurrency" in analysis))
354
+ return;
355
+ const legacy = analysis.surveyConcurrency;
356
+ delete analysis.surveyConcurrency;
357
+ if (analysis.siteConcurrency !== undefined)
358
+ return;
359
+ analysis.siteConcurrency = legacy;
360
+ log.warn("review.analysis.surveyConcurrency is deprecated — mapped to siteConcurrency; rename it", {
361
+ layer: label,
362
+ siteConcurrency: legacy,
363
+ });
364
+ }
338
365
  /**
339
366
  * The configured HOLD label, with the packaged default when config isn't loaded
340
367
  * yet (unit tests) — see {@link LastLightConfig.holdLabel} and {@link HOLD_LABEL}.
@@ -452,6 +479,7 @@ export function loadConfig() {
452
479
  overlayRaw = readYamlFile(join(overlayDir, "config.yaml"), false);
453
480
  }
454
481
  applyDeprecatedGateAlias(overlayRaw, "overlay");
482
+ applySiteConcurrencyAlias(overlayRaw, "overlay");
455
483
  // Build the env layer once: a partial config tree in the same shape as the
456
484
  // YAML layers. This is the single place that maps env vars onto config paths
457
485
  // (LASTLIGHT_MODELS → models.*, legacy OPENCODE_* aliases, …). Once built,
@@ -464,6 +492,7 @@ export function loadConfig() {
464
492
  env: envLayer,
465
493
  });
466
494
  const fileCfg = normalizeFileConfig(mergedRaw);
495
+ assertReviewAnalysisSupported(fileCfg.review.analysis.enabled, fileCfg.sandbox.backend);
467
496
  const stateDir = resolve(stringEnv("STATE_DIR", "./data"));
468
497
  const models = fileCfg.models;
469
498
  const model = models.default;
@@ -633,7 +662,7 @@ function normalizeFileConfig(raw) {
633
662
  const exploreRaw = isPlainObject(raw.explore) ? raw.explore : {};
634
663
  const reviewRaw = isPlainObject(raw.review) ? raw.review : {};
635
664
  const analysisRaw = isPlainObject(reviewRaw.analysis) ? reviewRaw.analysis : {};
636
- warnRemovedBoundaryKeys(analysisRaw);
665
+ warnRemovedAnalysisKeys(analysisRaw);
637
666
  const triageRaw = isPlainObject(reviewRaw.triage) ? reviewRaw.triage : {};
638
667
  const autonomyRaw = isPlainObject(raw.autonomy) ? raw.autonomy : {};
639
668
  const fixRaw = isPlainObject(raw.fix) ? raw.fix : {};
@@ -752,6 +781,13 @@ function normalizeFileConfig(raw) {
752
781
  // Historically `review.postsCheck` defaulted OFF for anything that wasn't
753
782
  // literally `true`; keep that exact reading.
754
783
  postsCheck: reviewRaw.postsCheck === true,
784
+ // Ships ON (today's behaviour), so only a literal `false` turns it off.
785
+ placeholderCheck: reviewRaw.placeholderCheck !== false,
786
+ sweepPendingGraceMinutes: typeof reviewRaw.sweepPendingGraceMinutes === "number" &&
787
+ Number.isFinite(reviewRaw.sweepPendingGraceMinutes) &&
788
+ reviewRaw.sweepPendingGraceMinutes >= 0
789
+ ? reviewRaw.sweepPendingGraceMinutes
790
+ : reviewDefaults.sweepPendingGraceMinutes,
755
791
  trigger: isReviewTrigger(reviewRaw.trigger) ? reviewRaw.trigger : reviewDefaults.trigger,
756
792
  requestLabel: typeof reviewRaw.requestLabel === "string" && reviewRaw.requestLabel.trim()
757
793
  ? reviewRaw.requestLabel.trim()
@@ -795,11 +831,20 @@ function normalizeFileConfig(raw) {
795
831
  // the same rule. A non-string falls back to the default (""), which is
796
832
  // the baseline arm — the direction every switch in this block fails.
797
833
  mint: typeof analysisRaw.mint === "string" ? analysisRaw.mint.trim() : reviewDefaults.analysis.mint,
798
- surveyPasses: nonNegativeNumber(analysisRaw.surveyPasses) ?? reviewDefaults.analysis.surveyPasses,
799
- // WP11c. A CEILING the run clamps again per backend, so an overlay that
800
- // asks for six on gondolin still gets one — the operator's ask is not the
834
+ // A CEILING the run clamps again per backend, so an overlay that asks for
835
+ // six on gondolin still gets one — the operator's ask is not the
801
836
  // effective value and the run logs when the host overrides it.
802
- surveyConcurrency: nonNegativeNumber(analysisRaw.surveyConcurrency) ?? reviewDefaults.analysis.surveyConcurrency,
837
+ // `surveyConcurrency`, its old name, is mapped onto it per layer
838
+ // (`applySiteConcurrencyAlias`).
839
+ siteConcurrency: nonNegativeNumber(analysisRaw.siteConcurrency) ?? reviewDefaults.analysis.siteConcurrency,
840
+ // `sites --plan --top` refuses anything outside 1–8 (the fan-out's
841
+ // static branches), so a bad value falls back here instead of failing
842
+ // every review's plan.
843
+ siteTop: siteTopOrDefault(analysisRaw.siteTop, reviewDefaults.analysis.siteTop),
844
+ // No backend clamp, unlike `siteConcurrency`: unit calls are in-process
845
+ // HTTP requests, not sandboxes, so this bounds rate-limit pressure only.
846
+ // Zero would stall the phase, so it floors at one.
847
+ surveyUnitConcurrency: Math.max(1, nonNegativeNumber(analysisRaw.surveyUnitConcurrency) ?? reviewDefaults.analysis.surveyUnitConcurrency),
803
848
  // WP4. `probes` is TRI-STATE (`off` | `static` | `full`) and the other
804
849
  // three still read `=== true`, for the same reason `enabled` does: each
805
850
  // buys the operator's compute, and two of them — `full` (which installs a
@@ -810,12 +855,6 @@ function normalizeFileConfig(raw) {
810
855
  // `"static"` (so no existing deployment gains an install by upgrading),
811
856
  // and every other value — including `"true"` and `"yes"` — is `"off"`.
812
857
  probes: coerceProbeMode(analysisRaw.probes),
813
- // #399. Selects what `adjudicate` is handed and what shape it writes
814
- // back, in ONE key because both halves move the same phase's measured
815
- // surface. Only the literal `"dossier"` moves a deployment; everything
816
- // else is the shipped phase, which is the direction the whole block
817
- // fails.
818
- adjudicate: coerceAdjudicateMode(analysisRaw.adjudicate),
819
858
  probeLifecycleScripts: analysisRaw.probeLifecycleScripts === true,
820
859
  probeTypecheck: analysisRaw.probeTypecheck === true,
821
860
  probeCoverage: analysisRaw.probeCoverage === true,
@@ -825,7 +864,13 @@ function normalizeFileConfig(raw) {
825
864
  seedTimeoutSeconds: requiredSeconds(analysisRaw.seedTimeoutSeconds, "review.analysis.seedTimeoutSeconds"),
826
865
  reconcileTimeoutSeconds: requiredSeconds(analysisRaw.reconcileTimeoutSeconds, "review.analysis.reconcileTimeoutSeconds"),
827
866
  falsifyTimeoutSeconds: requiredSeconds(analysisRaw.falsifyTimeoutSeconds, "review.analysis.falsifyTimeoutSeconds"),
867
+ surveyUnitsTimeoutSeconds: requiredSeconds(analysisRaw.surveyUnitsTimeoutSeconds, "review.analysis.surveyUnitsTimeoutSeconds"),
828
868
  probeRounds: nonNegativeNumber(analysisRaw.probeRounds) ?? reviewDefaults.analysis.probeRounds,
869
+ // Nullable like `maxBodyComments`: an explicit `null` is "no cap", distinct
870
+ // from an absent key, which takes the shipped default.
871
+ maxProbes: analysisRaw.maxProbes === null
872
+ ? null
873
+ : nonNegativeNumber(analysisRaw.maxProbes) ?? reviewDefaults.analysis.maxProbes,
829
874
  // WP6b, the attention boundary. `maxInlineComments` allows 0 — a
830
875
  // deployment that wants every finding in the review body is a coherent
831
876
  // choice — so `nonNegativeNumber` is right and `|| default` would not be.
@@ -839,11 +884,6 @@ function normalizeFileConfig(raw) {
839
884
  maxBodyComments: analysisRaw.maxBodyComments === null
840
885
  ? null
841
886
  : nonNegativeNumber(analysisRaw.maxBodyComments) ?? reviewDefaults.analysis.maxBodyComments,
842
- // #399 idea 2. `null` ⇒ `jev-classify`'s own default. A non-string is
843
- // the same direction every switch in this block fails: the default,
844
- // never a fabricated model id.
845
- jevModel: typeof analysisRaw.jevModel === "string" ? analysisRaw.jevModel.trim() : reviewDefaults.analysis.jevModel,
846
- jevTimeoutSeconds: requiredSeconds(analysisRaw.jevTimeoutSeconds, "review.analysis.jevTimeoutSeconds"),
847
887
  },
848
888
  };
849
889
  // The autonomy pipeline (issue: the software factory). Lenient like every
@@ -1091,25 +1131,37 @@ function nonNegativeNumber(raw) {
1091
1131
  return typeof raw === "number" && Number.isFinite(raw) && raw >= 0 ? raw : undefined;
1092
1132
  }
1093
1133
  /**
1094
- * Keys this config once honoured under `review.analysis` and now IGNORES.
1134
+ * Keys this config once honoured under `review.analysis` and now IGNORES, each
1135
+ * with why.
1095
1136
  *
1096
- * Both were confidence gates on the attention boundary, removed 2026-09-21
1097
- * after `finding.confidence` measured AUROC 0.228 [0.171, 0.299] over 516
1098
- * findings — a strong signal pointing the wrong way — and after the preserved
1099
- * archive showed neither had ever cost a gold finding. Two overlay repos and
1100
- * ~17 eval overlays may still pin them, so they are ACCEPTED AND IGNORED
1101
- * rather than rejected: this loader reads only the keys it knows, so an
1137
+ * Overlay repos and eval overlays may still pin them, so they are ACCEPTED AND
1138
+ * IGNORED rather than rejected: this loader reads only the keys it knows, so an
1102
1139
  * unknown leaf was already inert. The warning is so an operator who pinned one
1103
- * learns it stopped meaning anything, instead of believing a bar is in force.
1140
+ * learns it stopped meaning anything, instead of believing it is in force.
1104
1141
  */
1105
- const REMOVED_ANALYSIS_KEYS = ["internalFloor", "thresholds"];
1106
- function warnRemovedBoundaryKeys(analysisRaw) {
1107
- const present = REMOVED_ANALYSIS_KEYS.filter((k) => analysisRaw[k] !== undefined);
1142
+ const REMOVED_ANALYSIS_KEYS = {
1143
+ // Confidence gates on the attention boundary, removed 2026-09-21 after
1144
+ // `finding.confidence` measured AUROC 0.228 [0.171, 0.299] over 516 findings.
1145
+ internalFloor: "the attention boundary no longer gates on finding.confidence (AUROC 0.228)",
1146
+ thresholds: "the attention boundary no longer gates on finding.confidence (AUROC 0.228)",
1147
+ // Units + sites became the only analysis path
1148
+ // (docs/plans/pr-review-units-sites.md).
1149
+ surveyEngine: "the unit survey is the only survey engine",
1150
+ reviewEngine: "the sites engine is the only review engine",
1151
+ independentReview: "the sites engine writes findings.json; `review` runs only with the pipeline off or on a light re-review",
1152
+ adjudicate: "the adjudicator was removed; the sites engine selects the review",
1153
+ jevModel: "jev-classify was removed with the adjudicator",
1154
+ admit: "dossier admission was removed with the adjudicator",
1155
+ jevTimeoutSeconds: "jev-classify was removed with the adjudicator",
1156
+ surveyPasses: "the agent survey fan-out was removed",
1157
+ };
1158
+ function warnRemovedAnalysisKeys(analysisRaw) {
1159
+ const present = Object.keys(REMOVED_ANALYSIS_KEYS).filter((k) => analysisRaw[k] !== undefined);
1108
1160
  if (present.length === 0)
1109
1161
  return;
1110
1162
  log.warn("review.analysis keys were removed and are ignored", {
1111
1163
  keys: present,
1112
- detail: "the attention boundary no longer gates on finding.confidence (AUROC 0.228); remove these keys from your overlay",
1164
+ detail: `${present.map((k) => `${k}: ${REMOVED_ANALYSIS_KEYS[k]}`).join("; ")} — remove these keys from your overlay`,
1113
1165
  });
1114
1166
  }
1115
1167
  /**
@@ -1262,6 +1314,24 @@ function optionalStringArray(raw, path) {
1262
1314
  return [];
1263
1315
  return stringArray(raw, path);
1264
1316
  }
1317
+ /**
1318
+ * `review.analysis` needs a workspace the HARNESS can read and write: the
1319
+ * in-process `survey-units` phase reads `units.json` from the host checkout and
1320
+ * writes one response per unit back into it for the sandboxed `units-ingest`.
1321
+ * A backend with no host checkout ({@link HOST_READABLE_WORKSPACE}, i.e.
1322
+ * `kubernetes`) would survey nothing on every review, so the combination is
1323
+ * refused at startup, naming both keys — a boot error an operator sees once
1324
+ * beats a degraded review on every run. (The repo layer cannot reach this:
1325
+ * `review.analysis` is operator-only.)
1326
+ */
1327
+ export function assertReviewAnalysisSupported(enabled, backend) {
1328
+ if (!enabled || HOST_READABLE_WORKSPACE[backend])
1329
+ return;
1330
+ throw new Error(`review.analysis.enabled is not supported on the ${backend} sandbox backend — the survey-units ` +
1331
+ "phase reads and writes the workspace from the harness, and this backend has no host checkout. " +
1332
+ `Set review.analysis.enabled: false, or use a backend with a host-readable workspace ` +
1333
+ `(${Object.keys(HOST_READABLE_WORKSPACE).filter((b) => HOST_READABLE_WORKSPACE[b]).join(", ")}).`);
1334
+ }
1265
1335
  function sandboxBackend(raw, path) {
1266
1336
  if (raw === "gondolin" || raw === "docker" || raw === "smol" || raw === "none" || raw === "kubernetes")
1267
1337
  return raw;