lastlight-core 0.33.2 → 0.34.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 (89) hide show
  1. package/config/default.yaml +137 -48
  2. package/dist/admin/routes.js +3 -0
  3. package/dist/admin/routes.js.map +1 -1
  4. package/dist/config/config.d.ts +1 -1
  5. package/dist/config/config.js +45 -29
  6. package/dist/config/config.js.map +1 -1
  7. package/dist/engine/event-shim.d.ts +22 -0
  8. package/dist/engine/event-shim.js +98 -0
  9. package/dist/engine/event-shim.js.map +1 -1
  10. package/dist/engine/executors/orchestrator.d.ts +13 -0
  11. package/dist/engine/executors/orchestrator.js +42 -3
  12. package/dist/engine/executors/orchestrator.js.map +1 -1
  13. package/dist/engine/github/review-poster.d.ts +249 -40
  14. package/dist/engine/github/review-poster.js +332 -54
  15. package/dist/engine/github/review-poster.js.map +1 -1
  16. package/dist/engine/github/review-summary.d.ts +61 -0
  17. package/dist/engine/github/review-summary.js +101 -0
  18. package/dist/engine/github/review-summary.js.map +1 -0
  19. package/dist/engine/pr-decisions.d.ts +16 -0
  20. package/dist/engine/pr-decisions.js +127 -11
  21. package/dist/engine/pr-decisions.js.map +1 -1
  22. package/dist/engine/review-spec.d.ts +1 -1
  23. package/dist/engine/review-spec.js +69 -38
  24. package/dist/engine/review-spec.js.map +1 -1
  25. package/dist/sandbox/docker.d.ts +8 -0
  26. package/dist/sandbox/docker.js +31 -0
  27. package/dist/sandbox/docker.js.map +1 -1
  28. package/dist/sandbox/k8s/kubernetes-sandbox.d.ts +5 -0
  29. package/dist/sandbox/k8s/kubernetes-sandbox.js +46 -2
  30. package/dist/sandbox/k8s/kubernetes-sandbox.js.map +1 -1
  31. package/dist/sandbox/k8s/run-agent-script.d.ts +3 -1
  32. package/dist/sandbox/k8s/run-agent-script.js +10 -2
  33. package/dist/sandbox/k8s/run-agent-script.js.map +1 -1
  34. package/dist/sandbox/resource-usage.d.ts +64 -0
  35. package/dist/sandbox/resource-usage.js +115 -0
  36. package/dist/sandbox/resource-usage.js.map +1 -0
  37. package/dist/sandbox/sandbox.d.ts +20 -0
  38. package/dist/sandbox/sandbox.js +22 -0
  39. package/dist/sandbox/sandbox.js.map +1 -1
  40. package/dist/sandbox/smol.js +6 -0
  41. package/dist/sandbox/smol.js.map +1 -1
  42. package/dist/session-log.js +4 -0
  43. package/dist/session-log.js.map +1 -1
  44. package/dist/state/execution-store.d.ts +33 -1
  45. package/dist/state/execution-store.js +54 -12
  46. package/dist/state/execution-store.js.map +1 -1
  47. package/dist/state/schema/pg.d.ts +51 -0
  48. package/dist/state/schema/pg.js +7 -1
  49. package/dist/state/schema/pg.js.map +1 -1
  50. package/dist/state/schema/sqlite.d.ts +51 -0
  51. package/dist/state/schema/sqlite.js +6 -0
  52. package/dist/state/schema/sqlite.js.map +1 -1
  53. package/dist/state/workflow-run-store.d.ts +5 -2
  54. package/dist/state/workflow-run-store.js +10 -4
  55. package/dist/state/workflow-run-store.js.map +1 -1
  56. package/dist/telemetry/openinference.d.ts +13 -0
  57. package/dist/telemetry/openinference.js +13 -0
  58. package/dist/telemetry/openinference.js.map +1 -1
  59. package/dist/telemetry/pi-events.js +16 -1
  60. package/dist/telemetry/pi-events.js.map +1 -1
  61. package/dist/workflows/handlers/fanout.d.ts +54 -7
  62. package/dist/workflows/handlers/fanout.js +197 -21
  63. package/dist/workflows/handlers/fanout.js.map +1 -1
  64. package/dist/workflows/handlers/post-review.d.ts +17 -0
  65. package/dist/workflows/handlers/post-review.js +137 -50
  66. package/dist/workflows/handlers/post-review.js.map +1 -1
  67. package/dist/workflows/runner.js +1 -1
  68. package/dist/workflows/runner.js.map +1 -1
  69. package/drizzle/pg/0002_luxuriant_screwball.sql +3 -0
  70. package/drizzle/pg/meta/0002_snapshot.json +1894 -0
  71. package/drizzle/pg/meta/_journal.json +7 -0
  72. package/drizzle/sqlite/0003_first_namorita.sql +3 -0
  73. package/drizzle/sqlite/meta/0003_snapshot.json +1725 -0
  74. package/drizzle/sqlite/meta/_journal.json +7 -0
  75. package/package.json +5 -5
  76. package/skills/adjudicate-pass/SKILL.md +24 -20
  77. package/skills/pr-review/SKILL.md +3 -2
  78. package/skills/pr-review/references/findings-schema.md +1 -1
  79. package/skills/survey-pass/SKILL.md +121 -130
  80. package/workflows/pr-review.yaml +210 -7
  81. package/workflows/prompts/review-adjudicate.md +413 -264
  82. package/workflows/prompts/review-falsify.md +185 -44
  83. package/workflows/prompts/review.md +10 -10
  84. package/workflows/prompts/survey-contract.md +48 -48
  85. package/workflows/prompts/survey-enforcement.md +102 -134
  86. package/workflows/prompts/survey-security.md +53 -56
  87. package/workflows/prompts/survey-spec.md +52 -37
  88. package/workflows/prompts/survey-state.md +54 -53
  89. package/workflows/prompts/survey-tests.md +48 -48
@@ -100,6 +100,13 @@ phases:
100
100
  }
101
101
 
102
102
  ARGS="--repo . --out $OUT"
103
+ # The INSTALL decision, and the only one whose default direction is
104
+ # inverted: anything that is not the literal "true" adds `--no-install`,
105
+ # so `probes: static` — and an absent value — prepares the tree without
106
+ # ever running a package manager. `env.json` then says
107
+ # `install: "skipped"` with `installed` still read off the filesystem,
108
+ # which is the one field `falsify` branches on.
109
+ [ "{{probeInstall}}" != "true" ] && ARGS="$ARGS --no-install"
103
110
  # Each switch arrives as the literal "true"/"false"; absent means off.
104
111
  [ "{{probeLifecycleScripts}}" = "true" ] && ARGS="$ARGS --lifecycle-scripts"
105
112
  [ "{{probeTypecheck}}" = "true" ] && ARGS="$ARGS --typecheck"
@@ -217,6 +224,21 @@ phases:
217
224
  type: fanout
218
225
  skills: [survey-pass]
219
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.
232
+ command_policy:
233
+ install: block
234
+ test: block
235
+ host: block
236
+ 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.
220
242
  skip_if:
221
243
  - "analysisEnabled != true"
222
244
  - "scratch.reviewTriage.depth == 'light'"
@@ -229,6 +251,14 @@ phases:
229
251
  # at phase level the schema strips it silently, reverting to
230
252
  # `{retries: 0, then: fail}` — one degenerate turn then fails the review.
231
253
  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
+ on_branch_gate_failure: { retries: 1 }
232
262
  # `context_file` is read by the HARNESS, host-side, from the cwd the
233
263
  # deterministic phases wrote in, and appended to the branch's prompt — the
234
264
  # model resolves no path of its own. An unreadable file appends a loud NOT
@@ -266,11 +296,15 @@ phases:
266
296
  # No `tests` branch: the family has no seeder, so it is reported
267
297
  # `notMeasured` rather than run to write NOT MEASURED. `spec` is built
268
298
  # harness-side from the PR body and linked issues, so it reads
269
- # `{{specObligations}}` from the context instead of a block on disk and
270
- # keeps the `test -s` gate.
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.
271
303
  - name: spec
272
304
  prompt: prompts/survey-spec.md
273
- until_bash: test -s .lastlight/pr-review/hypotheses/spec.jsonl
305
+ until_bash: |
306
+ FACTS="${LASTLIGHT_FACTS_BIN:-$(command -v lastlight-facts || echo /opt/lastlight/bin/lastlight-facts)}"
307
+ "$FACTS" discharge --dir .lastlight/pr-review --family spec --ungraded
274
308
 
275
309
  # The only phase that RUNS anything. It reads the hypothesis RECORDS and the
276
310
  # code, never an earlier pass's transcript — a checker that can see the
@@ -278,13 +312,48 @@ phases:
278
312
  - name: falsify
279
313
  label: Falsify · run the probe
280
314
  prompt: prompts/review-falsify.md
281
- model: "{{models.review-survey}}"
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`.
322
+ model: "{{#if models.review-falsify}}{{models.review-falsify}}{{/if}}{{#if !models.review-falsify}}{{models.review-survey}}{{/if}}"
282
323
  skip_if:
283
324
  - "analysisEnabled != true"
284
325
  - "probesEnabled != true"
285
326
  - "scratch.reviewTriage.depth == 'light'"
286
327
  depends_on: [survey]
287
328
  trigger_rule: all_done
329
+ # A WHOLE-PHASE ceiling, across every round. `probeRounds` bounds how many
330
+ # times the loop may go round and not what it may spend, and this is the
331
+ # one phase in the pipeline that executes code — so it is the one that
332
+ # needs a wall-clock bound rather than a count. Like every other budget
333
+ # here it names a context key, never a literal (#385).
334
+ timeout_seconds: { from: falsifyTimeoutSeconds }
335
+ # The one phase that runs code, and even here installing the repo is
336
+ # `prepare`'s job, never the model's. Whether a TEST can run depends on
337
+ # whether `prepare` installed the tree, so those two modes are read from
338
+ # the run context: `probes: full` → `log` (a targeted test is the point;
339
+ # a reach for the whole suite shows up in the logs), `probes: static` →
340
+ # `block` (nothing is installed, so it cannot work). A scratch-dir install
341
+ # (`npm install fastify@5` in /tmp/probe) follows the same switch.
342
+ #
343
+ # `host` (issue #404) is `log` here for one eval arm, then `block` once the
344
+ # log shows nothing legitimate is caught: measured, 24 of 27 out-of-workspace
345
+ # commands came from falsify hunting a dependency on the host (`find /`,
346
+ # `~/.nvm`, a global `lastlight` put on PATH).
347
+ command_policy:
348
+ install: block
349
+ install-scratch: { from: probeScratchInstallPolicy }
350
+ test: { from: probeTestPolicy }
351
+ host: log
352
+ reason: >-
353
+ Installing the repository's dependencies is the prepare phase's job, and the
354
+ whole suite is never a probe. Run the one targeted check this hypothesis needs
355
+ (a single test file, `node -e`, an AST or facts query), or record the
356
+ hypothesis as unprobed.
288
357
  generic_loop:
289
358
  on_soft_failure: { retries: 1, then: complete }
290
359
  max_iterations: { from: probeRounds, default: 2 }
@@ -313,6 +382,109 @@ phases:
313
382
  skills: [pr-review, code-review]
314
383
  model: "{{models.review}}"
315
384
  variant: "{{variants.review}}"
385
+ # Review re-created CI by hand (`npm ci` then `npm run lint:check && npm
386
+ # test`) although `{{ciSection}}` already carries the result (issue #403),
387
+ # 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
390
+ # `pr-review` skill's install-to-probe affordance is a measured fix (it is
391
+ # why the reviewer could open `node_modules/@slack` at all), so it stays.
392
+ command_policy:
393
+ install: { from: reviewInstallPolicy, default: allow }
394
+ test: block
395
+ host: block
396
+ reason: >-
397
+ 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
400
+ machine for a missing dependency — stop, and leave the claim unprobed.
401
+
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.
416
+ #
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
316
488
 
317
489
  # The exit of the funnel, and the only phase that can move recall: it ranks,
318
490
  # re-tiers and demotes the hypotheses into the review. It DELETES only when a
@@ -331,12 +503,37 @@ phases:
331
503
  # than to `models.review`.
332
504
  model: "{{#if models.review-adjudicate}}{{models.review-adjudicate}}{{/if}}{{#if !models.review-adjudicate}}{{models.review}}{{/if}}"
333
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.
334
515
  skip_if:
335
516
  - "analysisEnabled != true"
336
517
  - "scratch.reviewTriage.depth == 'light'"
337
- # `all_success` (the default) where `review` uses `all_done`: a failed
338
- # review must NOT post.
339
- depends_on: [review]
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
340
537
  generic_loop:
341
538
  on_soft_failure: { retries: 1, then: complete }
342
539
  max_iterations: 2
@@ -354,6 +551,12 @@ phases:
354
551
  # for. `--repair` writes every uncovered hypothesis into findings.json at
355
552
  # `internal` tier and promotes back any `dropped` entry whose transcript does
356
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.
357
560
  - name: reconcile
358
561
  label: Reconcile · the conservation floor
359
562
  type: bash