lastlight-core 0.36.0 → 0.38.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/config/default.yaml +22 -1
  2. package/dist/config/config.js +5 -1
  3. package/dist/config/config.js.map +1 -1
  4. package/dist/engine/github/review-poster.d.ts +27 -1
  5. package/dist/engine/github/review-poster.js +8 -1
  6. package/dist/engine/github/review-poster.js.map +1 -1
  7. package/dist/engine/github/review-summary.d.ts +7 -0
  8. package/dist/engine/github/review-summary.js +7 -3
  9. package/dist/engine/github/review-summary.js.map +1 -1
  10. package/dist/engine/pr-decisions.d.ts +26 -0
  11. package/dist/engine/pr-decisions.js +39 -1
  12. package/dist/engine/pr-decisions.js.map +1 -1
  13. package/dist/engine/pr-escalation.js +4 -4
  14. package/dist/engine/pr-escalation.js.map +1 -1
  15. package/dist/engine/pr-state.d.ts +42 -0
  16. package/dist/engine/pr-state.js +28 -0
  17. package/dist/engine/pr-state.js.map +1 -1
  18. package/dist/engine/review-ledger.d.ts +152 -0
  19. package/dist/engine/review-ledger.js +302 -0
  20. package/dist/engine/review-ledger.js.map +1 -0
  21. package/dist/evals-api.d.ts +5 -2
  22. package/dist/evals-api.js +8 -2
  23. package/dist/evals-api.js.map +1 -1
  24. package/dist/index.js +3 -2
  25. package/dist/index.js.map +1 -1
  26. package/dist/workflows/handlers/fanout.d.ts +10 -0
  27. package/dist/workflows/handlers/fanout.js +68 -4
  28. package/dist/workflows/handlers/fanout.js.map +1 -1
  29. package/dist/workflows/handlers/post-review.d.ts +49 -3
  30. package/dist/workflows/handlers/post-review.js +201 -24
  31. package/dist/workflows/handlers/post-review.js.map +1 -1
  32. package/dist/workflows/runner.js +7 -0
  33. package/dist/workflows/runner.js.map +1 -1
  34. package/package.json +4 -4
  35. package/workflows/pr-review.yaml +60 -109
  36. package/workflows/prompts/review-select.md +10 -0
  37. package/workflows/prompts/review-site.md +3 -5
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lastlight-core",
3
- "version": "0.36.0",
3
+ "version": "0.38.0",
4
4
  "description": "GitHub repository maintenance agent — Agent SDK harness",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -75,9 +75,9 @@
75
75
  "pino-pretty": "13.1.3",
76
76
  "yaml": "^2.8.3",
77
77
  "zod": "^4.3.6",
78
- "lastlight-shared": "0.10.2",
79
- "lastlight-workflow-engine": "0.10.0",
80
- "agentic-pi": "0.7.0"
78
+ "agentic-pi": "0.7.0",
79
+ "lastlight-shared": "0.11.0",
80
+ "lastlight-workflow-engine": "0.11.0"
81
81
  },
82
82
  "devDependencies": {
83
83
  "@electric-sql/pglite": "^0.5.8",
@@ -37,6 +37,15 @@ phases:
37
37
  # matches the guard and the phase skips — leaving a full review. The
38
38
  # quoted-string form has the opposite behaviour and must not be used here.
39
39
  #
40
+ # NOT with the evidence pipeline on (issue #429): a light run is one
41
+ # agent pass over the diff with no ledger and no convergence gate — exactly
42
+ # the unbounded re-review that re-opens code the last review already had.
43
+ # The pipeline scopes a re-review in code instead (`units --prior`): a
44
+ # small push is a few changed units, so few sites, and a push that changed
45
+ # nothing the last review had plans no site at all. `analysisEnabled == true`
46
+ # is the bare-boolean form, so an absent key does NOT match and triage runs
47
+ # as before on a deployment without the pipeline.
48
+ #
40
49
  # The phase ends with one `REVIEW_DEPTH: full|light` line, which
41
50
  # `engine/review-triage.ts` harvests onto `scratch.reviewTriage` from the same
42
51
  # `onPhaseEnd` hook the fix markers ride. On `light`, the seven phases below
@@ -50,6 +59,7 @@ phases:
50
59
  skip_if:
51
60
  - "triageEnabled != true"
52
61
  - "reviewIsRereview != true"
62
+ - "analysisEnabled == true"
53
63
  timeout_seconds: { from: triageTimeoutSeconds }
54
64
  # NO `on_output.requires_marker`, deliberately — see AC2 in
55
65
  # `tests/workflows/pr-review-probes.test.ts`: nothing in this workflow may
@@ -244,11 +254,33 @@ phases:
244
254
  FACTS="${LASTLIGHT_FACTS_BIN:-$(command -v lastlight-facts || echo /opt/lastlight/bin/lastlight-facts)}"
245
255
  OUT=.lastlight/pr-review/units.json
246
256
  SPEC=.lastlight/pr-review/spec-obligations.json
257
+ PRIOR=.lastlight/pr-review/prior-review.json
258
+ RISK=.lastlight/pr-review/risk-rules.json
247
259
  mkdir -p .lastlight/pr-review
248
260
  # A reused per-PR workspace still holds the LAST head's document. Remove
249
261
  # 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"
262
+ # for `survey-units` to spend money on — and no stale prior review or
263
+ # risk rules for this run to scope by.
264
+ rm -f "$OUT" "$SPEC" "$PRIOR" "$RISK"
265
+
266
+ # Issue #429 — the units the LAST review had (the PR's review ledger),
267
+ # so each unit gets a `delta` (new / changed / affected / unchanged) and
268
+ # the sites skip what is unchanged. Absent on a first review: nothing is
269
+ # scoped. Same QUOTED heredoc as the spec obligations below.
270
+ {{#if priorReviewJson}}
271
+ cat > "$PRIOR" <<'LASTLIGHT_PRIOR_EOF'
272
+ {{priorReviewJson}}
273
+ LASTLIGHT_PRIOR_EOF
274
+ {{/if}}
275
+ # …and the configured risk rules (the repo's, then the operator's).
276
+ {{#if riskRulesJson}}
277
+ cat > "$RISK" <<'LASTLIGHT_RISK_EOF'
278
+ {{riskRulesJson}}
279
+ LASTLIGHT_RISK_EOF
280
+ {{/if}}
281
+ set --
282
+ [ -s "$RISK" ] && set -- --risk-rules "$RISK"
283
+ if [ -s "$PRIOR" ]; then echo "units: re-review — scoping against the last review's units"; fi
252
284
 
253
285
  # The spec obligations are built HARNESS-side (the PR body and the issues
254
286
  # it closes; `review-spec.ts`), so they reach the sandbox only through
@@ -280,7 +312,7 @@ phases:
280
312
  # that DIES (OOM, a segfault in the native parser). The fallback is
281
313
  # written only when nothing was — a document the CLI wrote on its way to
282
314
  # a non-zero exit carries more than this one can.
283
- "$FACTS" units --dir .lastlight/pr-review --repo . --never-fail
315
+ "$FACTS" units --dir .lastlight/pr-review --repo . "$@" --never-fail
284
316
  CODE=$?
285
317
  if [ ! -s "$OUT" ]; then
286
318
  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'"
@@ -385,28 +417,28 @@ phases:
385
417
  depends_on: [units-ingest]
386
418
  trigger_rule: all_done
387
419
  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.
420
+ # Writes `sites/plan.json`, one brief per slot (`sites/site-001.md` …) and
421
+ # `sites/branches.json`, the manifest `site-review` fans out over (it
422
+ # clears `sites/` first — a reused workspace holds the last head's). One
423
+ # slot per ranked site, up to `siteTop`; with `models.review-site-pair`
424
+ # set, a second slot per site, `site-00N-b`, on that model. A PR with two
425
+ # sites plans two investigators, not sixteen.
395
426
  command: |
396
427
  set -u
397
428
  FACTS="${LASTLIGHT_FACTS_BIN:-$(command -v lastlight-facts || echo /opt/lastlight/bin/lastlight-facts)}"
398
429
  # Test-then-flag: an absent {{key}} renders EMPTY and would swallow the
399
430
  # following flag.
400
431
  TOP="{{siteTop}}"
401
- set -- --slots 16
432
+ set --
402
433
  [ -n "$TOP" ] && set -- "$@" --top "$TOP"
403
434
  {{#if models.review-site-pair}}set -- "$@" --pair{{/if}}
404
435
  "$FACTS" sites --plan "$@" --dir .lastlight/pr-review --never-fail
405
436
  exit 0
406
437
 
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
438
+ # One investigator per site, concurrently, in one workspace. The branch list
439
+ # is DYNAMIC: `branches_from` reads the manifest `site-plan` just wrote and
440
+ # renders `branch:` once per item (`{{item.id}}`, `{{item.pair}}`). The prompt
441
+ # is slot-generic: the attached brief names the site id, the one file the branch writes
410
442
  # (`sites/<site id>.findings.jsonl` — disjoint across branches, which is the
411
443
  # fan-out's isolation model) and how many probed suspicions a `none` needs.
412
444
  # The gate is the one the evals replay graded (`sites --check`), and
@@ -445,101 +477,20 @@ phases:
445
477
  Nothing outside the checkout counts.
446
478
  on_branch_soft_failure: { retries: 1, then: complete }
447
479
  on_branch_gate_failure: { retries: 1 }
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
452
- branches:
453
- - name: site-001
454
- context_file: .lastlight/pr-review/sites/site-001.md
455
- until_bash: |
456
- FACTS="${LASTLIGHT_FACTS_BIN:-$(command -v lastlight-facts || echo /opt/lastlight/bin/lastlight-facts)}"
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
460
- until_bash: |
461
- FACTS="${LASTLIGHT_FACTS_BIN:-$(command -v lastlight-facts || echo /opt/lastlight/bin/lastlight-facts)}"
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
465
- until_bash: |
466
- FACTS="${LASTLIGHT_FACTS_BIN:-$(command -v lastlight-facts || echo /opt/lastlight/bin/lastlight-facts)}"
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
470
- until_bash: |
471
- FACTS="${LASTLIGHT_FACTS_BIN:-$(command -v lastlight-facts || echo /opt/lastlight/bin/lastlight-facts)}"
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
475
- until_bash: |
476
- FACTS="${LASTLIGHT_FACTS_BIN:-$(command -v lastlight-facts || echo /opt/lastlight/bin/lastlight-facts)}"
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 .
480
+ # `max` is the spend cap: top 8, paired. More items than that are dropped,
481
+ # loudly — `site-plan` never writes more.
482
+ branches_from:
483
+ file: .lastlight/pr-review/sites/branches.json
484
+ max: 16
485
+ branch:
486
+ name: "{{item.id}}"
487
+ # A pair slot runs on `models.review-site-pair`; a primary renders empty
488
+ # here and so takes the phase's `model:` above.
489
+ model: "{{#if item.pair}}{{models.review-site-pair}}{{/if}}"
490
+ context_file: ".lastlight/pr-review/sites/{{item.id}}.md"
491
+ until_bash: |
492
+ FACTS="${LASTLIGHT_FACTS_BIN:-$(command -v lastlight-facts || echo /opt/lastlight/bin/lastlight-facts)}"
493
+ "$FACTS" sites --check {{item.id}} --dir .lastlight/pr-review --repo .
543
494
  # Pool every site's findings for `select`: numbered `F1…Fn`, each with an
544
495
  # excerpt, and the duplicate groups line proximity PROPOSES (it cannot decide
545
496
  # "same defect"; no rule here reads prose). STDOUT is the delivery mechanism
@@ -44,6 +44,16 @@ you write an item:
44
44
  The discussion is context for deciding what is new. It is never a reason to
45
45
  drop or demote a finding the investigators grounded in code.
46
46
  {{/if}}
47
+ {{#if priorLedger}}
48
+ ## What our earlier reviews of this pull request found
49
+
50
+ {{priorLedger}}
51
+
52
+ The first list was **posted** and is still open: a finding that is the same
53
+ defect as one of those gets `"alreadyRaised"` (`"an earlier review, src/a.ts:42"`)
54
+ — the author already has it. The second list was found but **never posted**:
55
+ re-raising one of those is a choice, not a duplicate, so judge it on its merits.
56
+ {{/if}}
47
57
 
48
58
  ## What to do
49
59
 
@@ -4,8 +4,9 @@ no `findings.json`, and you touch no other pass's files.
4
4
 
5
5
  <!-- One prompt for every slot of pr-review's `site-review` fan-out
6
6
  (`review.analysis.reviewEngine: sites`) and for the evals `micro-site-review`
7
- replay: a fan-out branch has no per-branch variables, so the attached brief
8
- names the site id, the output file and the `none` bar
7
+ replay. The prompt stays slot-generic — it is shared with the replay, which has
8
+ no manifest — so the attached brief names the site id, the output file and the
9
+ `none` bar
9
10
  (docs/plans/pr-review-units-sites.md, "Act 6"). -->
10
11
 
11
12
  Reviewing **{{owner}}/{{repo}}#{{prNumber}}**, head `{{headSha}}` against `{{baseBranch}}`.
@@ -35,9 +36,6 @@ you write** (`.lastlight/pr-review/sites/<site id>.findings.jsonl`), your
35
36
  scratch directory, and how many probed suspicions a `none` needs. Wherever this
36
37
  prompt says `<site id>`, use the id the brief gives.
37
38
 
38
- If the brief says the slot has **no site**, write the single `empty` line it
39
- shows and stop — read no code.
40
-
41
39
  The brief may list **leads**: short subjects the survey's hypotheses named at
42
40
  this site. Treat them exactly as what they are:
43
41