lastlight-core 0.26.0 → 0.28.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 (127) hide show
  1. package/config/default.yaml +302 -5
  2. package/dist/admin/docker.js.map +1 -1
  3. package/dist/admin/sessions.js.map +1 -1
  4. package/dist/admin/tail.js.map +1 -1
  5. package/dist/config/config.d.ts +18 -4
  6. package/dist/config/config.js +122 -9
  7. package/dist/config/config.js.map +1 -1
  8. package/dist/config/repo-config.js.map +1 -1
  9. package/dist/connectors/messaging/session-manager.js.map +1 -1
  10. package/dist/connectors/slack/connector.js.map +1 -1
  11. package/dist/cron/dependabot-discovery.js.map +1 -1
  12. package/dist/cron/review-discovery.js.map +1 -1
  13. package/dist/engine/agent-executor.d.ts +25 -1
  14. package/dist/engine/agent-executor.js +41 -1
  15. package/dist/engine/agent-executor.js.map +1 -1
  16. package/dist/engine/chat/chat-prompt.js.map +1 -1
  17. package/dist/engine/chat/chat-runner.js.map +1 -1
  18. package/dist/engine/dispatcher.js +17 -0
  19. package/dist/engine/dispatcher.js.map +1 -1
  20. package/dist/engine/event-shim.d.ts +18 -0
  21. package/dist/engine/event-shim.js +2 -0
  22. package/dist/engine/event-shim.js.map +1 -1
  23. package/dist/engine/executors/orchestrator.d.ts +92 -1
  24. package/dist/engine/executors/orchestrator.js +144 -46
  25. package/dist/engine/executors/orchestrator.js.map +1 -1
  26. package/dist/engine/executors/shared.js.map +1 -1
  27. package/dist/engine/fix-harvest.js.map +1 -1
  28. package/dist/engine/github/github.d.ts +59 -0
  29. package/dist/engine/github/github.js +72 -0
  30. package/dist/engine/github/github.js.map +1 -1
  31. package/dist/engine/github/installations.js.map +1 -1
  32. package/dist/engine/github/review-poster.d.ts +403 -9
  33. package/dist/engine/github/review-poster.js +619 -52
  34. package/dist/engine/github/review-poster.js.map +1 -1
  35. package/dist/engine/github/team-visibility.js.map +1 -1
  36. package/dist/engine/llm.js.map +1 -1
  37. package/dist/engine/pr-decisions.d.ts +85 -5
  38. package/dist/engine/pr-decisions.js +331 -5
  39. package/dist/engine/pr-decisions.js.map +1 -1
  40. package/dist/engine/pr-state.d.ts +82 -0
  41. package/dist/engine/pr-state.js +71 -1
  42. package/dist/engine/pr-state.js.map +1 -1
  43. package/dist/engine/review-spec.d.ts +264 -0
  44. package/dist/engine/review-spec.js +723 -0
  45. package/dist/engine/review-spec.js.map +1 -0
  46. package/dist/engine/router.js.map +1 -1
  47. package/dist/engine/screen/classifier.js.map +1 -1
  48. package/dist/engine/screen/screen.js.map +1 -1
  49. package/dist/evals-api.d.ts +3 -0
  50. package/dist/evals-api.js +20 -0
  51. package/dist/evals-api.js.map +1 -1
  52. package/dist/index.js +76 -11
  53. package/dist/index.js.map +1 -1
  54. package/dist/notify/digest-blocks.js.map +1 -1
  55. package/dist/notify/model.js.map +1 -1
  56. package/dist/notify/transports/github.js.map +1 -1
  57. package/dist/notify/transports/slack.js.map +1 -1
  58. package/dist/sandbox/artifact-backend.js.map +1 -1
  59. package/dist/sandbox/artifact-store.js.map +1 -1
  60. package/dist/sandbox/docker.d.ts +23 -4
  61. package/dist/sandbox/docker.js +1 -1
  62. package/dist/sandbox/docker.js.map +1 -1
  63. package/dist/sandbox/egress-allowlist.js.map +1 -1
  64. package/dist/sandbox/k8s/agent-context-registry.js.map +1 -1
  65. package/dist/sandbox/k8s/client.js.map +1 -1
  66. package/dist/sandbox/k8s/kubernetes-sandbox.js.map +1 -1
  67. package/dist/sandbox/k8s/resource-name.js.map +1 -1
  68. package/dist/sandbox/k8s/run-id.js.map +1 -1
  69. package/dist/sandbox/k8s/run-secrets.js.map +1 -1
  70. package/dist/sandbox/k8s/skill-bundle.js.map +1 -1
  71. package/dist/sandbox/k8s/workspace-provisioner.js +10 -2
  72. package/dist/sandbox/k8s/workspace-provisioner.js.map +1 -1
  73. package/dist/sandbox/sandbox.d.ts +20 -0
  74. package/dist/sandbox/sandbox.js +27 -6
  75. package/dist/sandbox/sandbox.js.map +1 -1
  76. package/dist/session-log.js.map +1 -1
  77. package/dist/state/approval-store.js.map +1 -1
  78. package/dist/state/build-assets.js.map +1 -1
  79. package/dist/state/cron-run-store.js.map +1 -1
  80. package/dist/state/data-migrate.d.ts +135 -0
  81. package/dist/state/data-migrate.js +309 -0
  82. package/dist/state/data-migrate.js.map +1 -0
  83. package/dist/state/db.d.ts +24 -3
  84. package/dist/state/db.js +41 -11
  85. package/dist/state/db.js.map +1 -1
  86. package/dist/state/execution-store.js.map +1 -1
  87. package/dist/state/feedback-store.js.map +1 -1
  88. package/dist/state/pg-client.d.ts +44 -0
  89. package/dist/state/pg-client.js +81 -0
  90. package/dist/state/pg-client.js.map +1 -0
  91. package/dist/state/schema/pg.d.ts +15 -15
  92. package/dist/state/schema/sqlite.d.ts +15 -15
  93. package/dist/state/state-cli.d.ts +8 -0
  94. package/dist/state/state-cli.js +247 -0
  95. package/dist/state/state-cli.js.map +1 -0
  96. package/dist/state/team-store.js.map +1 -1
  97. package/dist/state/user-store.js.map +1 -1
  98. package/dist/state/workflow-run-store.js.map +1 -1
  99. package/dist/telemetry/index.js.map +1 -1
  100. package/dist/workflows/handlers/fanout.d.ts +157 -0
  101. package/dist/workflows/handlers/fanout.js +663 -0
  102. package/dist/workflows/handlers/fanout.js.map +1 -0
  103. package/dist/workflows/handlers/post-review.d.ts +111 -10
  104. package/dist/workflows/handlers/post-review.js +531 -39
  105. package/dist/workflows/handlers/post-review.js.map +1 -1
  106. package/dist/workflows/runner.js +33 -0
  107. package/dist/workflows/runner.js.map +1 -1
  108. package/dist/workflows/simple.js.map +1 -1
  109. package/docker-compose.yml +50 -0
  110. package/package.json +22 -12
  111. package/sandbox.Dockerfile +54 -0
  112. package/skills/adjudicate-pass/SKILL.md +117 -0
  113. package/skills/code-review/SKILL.md +114 -15
  114. package/skills/pr-review/SKILL.md +113 -24
  115. package/skills/pr-review/references/findings-schema.md +38 -7
  116. package/skills/survey-pass/SKILL.md +148 -0
  117. package/workflows/pr-review.yaml +626 -0
  118. package/workflows/prompts/dependabot-pr-merge.md +22 -2
  119. package/workflows/prompts/review-adjudicate.md +340 -0
  120. package/workflows/prompts/review-falsify.md +167 -0
  121. package/workflows/prompts/review.md +80 -0
  122. package/workflows/prompts/survey-contract.md +121 -0
  123. package/workflows/prompts/survey-enforcement.md +137 -0
  124. package/workflows/prompts/survey-security.md +165 -0
  125. package/workflows/prompts/survey-spec.md +116 -0
  126. package/workflows/prompts/survey-state.md +151 -0
  127. package/workflows/prompts/survey-tests.md +99 -0
@@ -0,0 +1,157 @@
1
+ import type { AssetLoader, DagNode, ExecutionResult, ExecutorConfig, GitSandboxAccess, LedgerDeps, PhaseDefinition, PhaseOutcome, PhaseReporter, PhaseResolver, PhaseTypeHandler, TemplateContext, WorkflowStateStore } from "lastlight-workflow-engine";
2
+ import type { SandboxBackend } from "../../config/config.js";
3
+ import type { SandboxFactory } from "../../sandbox/sandbox.js";
4
+ /**
5
+ * The heading the appended {@link FanoutBranch.context_file} is filed under. A
6
+ * constant rather than a literal at the call site because two tests and one
7
+ * prompt-authoring convention all name it.
8
+ */
9
+ export declare const BRANCH_CONTEXT_HEADING = "## Attached: the file this pass was seeded with";
10
+ /** Run-scoped data the `fanout` handler needs. */
11
+ export interface FanoutRunScope {
12
+ workflowName: string;
13
+ ctx: TemplateContext;
14
+ config: ExecutorConfig;
15
+ /** Single workspace shared by every phase + branch of the run. */
16
+ taskId: string;
17
+ triggerId: string;
18
+ githubAccess: GitSandboxAccess;
19
+ backend: SandboxBackend;
20
+ assets: AssetLoader;
21
+ resolver: PhaseResolver;
22
+ store?: WorkflowStateStore;
23
+ workflowId?: string;
24
+ ledger: Omit<LedgerDeps, "store">;
25
+ /**
26
+ * The two quota hooks `runner.ts` wraps its `AgentPort` in. A fan-out branch
27
+ * bypasses that port (it drives an already-provisioned sandbox directly), so
28
+ * without these a k8s ResourceQuota rejection inside a branch would fail the
29
+ * run red instead of requeueing it as backpressure.
30
+ */
31
+ observeResult: (r: ExecutionResult) => ExecutionResult;
32
+ observeError: (err: unknown) => never;
33
+ /** Test seam — substitute a FakeSandbox. Defaults to the real factory. */
34
+ sandboxFactory?: SandboxFactory;
35
+ }
36
+ /**
37
+ * The `type: fanout` phase — N agent sessions run CONCURRENTLY inside ONE
38
+ * provisioned workspace, as a single DAG node.
39
+ *
40
+ * **Why this exists rather than parallel phases.** Real DAG concurrency is
41
+ * parked (`docs/plans/deterministic-pr-levers.md` §WP5) behind
42
+ * four hard blockers and seven design changes, and that document says why in one
43
+ * sentence: *"Every hard blocker below — B1, D1, D2, D7 — exists because each
44
+ * phase provisions its own sandbox against a shared workspace. A fan-out inside
45
+ * one agent has none of them."* One node means one workspace (B1), one
46
+ * `current_phase` (B4), one terminal transition (D5), one provisioning pass so
47
+ * no `ensureBaseAvailable` git-lock contention (D1/D2), one artifact
48
+ * stage/harvest (D3), and one `outputs` writer (D4). B2 — a sibling's success
49
+ * overwriting a `paused` run and orphaning its approval row, the item that doc
50
+ * calls the worst in the list — is refused at the schema instead: a fanout phase
51
+ * may not declare an approval gate.
52
+ *
53
+ * **What it gives up, and buys back.** A DAG node per branch is genuinely lost:
54
+ * six survey families are one node now, retried as one. What is NOT lost is the
55
+ * per-branch `executions` row — each branch goes through the same
56
+ * {@link runLedgeredPhase} every other phase does, keyed
57
+ * `<phase>_branch_<name>`, so resume, dedup, cost attribution and the
58
+ * dashboard's longest-prefix grouping all keep working. WP5
59
+ * (`docs/plans/deterministic-pr-levers.md` §"Parked: parallel phases (WP5)")
60
+ * listed exactly those as the price of an in-agent fan-out; the ledger key is
61
+ * how it goes unpaid.
62
+ */
63
+ export declare class FanoutHandler implements PhaseTypeHandler {
64
+ private readonly run;
65
+ private readonly reporter;
66
+ constructor(run: FanoutRunScope, reporter: PhaseReporter);
67
+ execute(phase: PhaseDefinition, _node: DagNode, outputs: Readonly<Record<string, unknown>>): Promise<PhaseOutcome>;
68
+ /**
69
+ * Run one branch, with the one-shot soft retry `on_branch_soft_failure`
70
+ * describes. A HARD failure (terminated / fatal / tool error / non-zero exit)
71
+ * is never retried — that is `isSoftOutcome`'s split, shared with the reviewer
72
+ * and generic loops so all three stay in lockstep.
73
+ */
74
+ private runBranch;
75
+ /** The attempt loop — one branch's agent turn plus its one-shot soft retry. */
76
+ private runBranchAttempts;
77
+ /**
78
+ * Append the branch's `context_file` to its rendered prompt, if it declares
79
+ * one.
80
+ *
81
+ * **LAST in the prompt, and that is §D4's ordering rather than convenience.**
82
+ * Provider-side prompt caching is keyed on the request PREFIX, so the shared
83
+ * head (skills, AGENTS.md, the diff summary) has to stay byte-identical across
84
+ * the six branches and everything family-specific has to come after it. The
85
+ * attached file is the most family-specific thing there is.
86
+ *
87
+ * Whether the read succeeded is LOGGED either way. A lost seed used to be
88
+ * invisible from outside the transcript — it is now one grep on the harness
89
+ * log, which is what turned a 22%-of-branches defect into something anybody
90
+ * could have found in a minute.
91
+ */
92
+ private withBranchContext;
93
+ /** One ledgered agent turn for a branch, under its own AGENT span. */
94
+ private runBranchOnce;
95
+ /**
96
+ * A branch's `until_bash`, recorded as its own `<phase>_branch_<name>_check`
97
+ * row.
98
+ *
99
+ * Observational, and that is not a weakening — it is what the six chained
100
+ * survey phases already did. Each declared `generic_loop: { max_iterations: 1,
101
+ * until_bash: … }`, and with one iteration the gate can never cause a re-run:
102
+ * it runs once, records `condition_met` / `condition_not_met`, and the loop
103
+ * ends either way. Reproducing that exactly is what makes this a speed change
104
+ * rather than a behaviour change.
105
+ *
106
+ * Like the generic loop's check row it bypasses the dedup ledger: a condition
107
+ * must be re-evaluated every time it is asked, and `success` records whether
108
+ * the check RAN, not what it said.
109
+ */
110
+ private runBranchGate;
111
+ /**
112
+ * Fold the branches into one node outcome.
113
+ *
114
+ * `then: "complete"` (the default) is what makes a fan-out a fan-out: it
115
+ * gathers independent evidence, so one branch coming back empty must not
116
+ * discard the other five. The six survey phases already had this — a chained
117
+ * phase with `on_soft_failure: { retries: 1, then: complete }` — and it was
118
+ * worth having: without it a single degenerate turn hard-failed the run, which
119
+ * records no `assessedHeadShaByWorkflow` and hands `cron-review.yaml` something
120
+ * to re-dispatch every thirty minutes forever.
121
+ *
122
+ * A HARD branch failure still fails the phase. That is not the soft policy's
123
+ * business, and a fan-out where every branch crashed is not a success.
124
+ */
125
+ private report;
126
+ /**
127
+ * `min(declared, backend ceiling)`, logged when the host has the last word so
128
+ * an operator who set `max_concurrent: 6` and saw sequential timings can find
129
+ * out why from the log rather than from this file.
130
+ */
131
+ private resolveConcurrency;
132
+ /** The phase-level config — what opens the shared session. */
133
+ private phaseConfig;
134
+ /**
135
+ * The per-branch config. Two things vary and both matter:
136
+ * `telemetry.phaseName` (which is `skillBundleKey`, so each branch stages into
137
+ * its OWN `.lastlight-skills/<label>/` and concurrent branches cannot clobber
138
+ * each other's catalogue) and `skillPaths` when the branch overrides skills.
139
+ */
140
+ private branchConfig;
141
+ /**
142
+ * The branch as a phase-shaped object, for the two engine helpers that take
143
+ * one (`buildPhasePrompt`, `phaseConfigFor`).
144
+ *
145
+ * Built by hand rather than by spreading the branch over the phase: a spread
146
+ * would carry `until_bash` and `branches` into something that looks like a
147
+ * PhaseDefinition, and the prompt-cache ordering (§D4 — shared prefix first,
148
+ * the family's obligations last) depends on this going through exactly the
149
+ * same `buildPhasePrompt` path the six chained phases used.
150
+ */
151
+ private branchPhase;
152
+ /** Mirrors `PhaseExecutor.resolveModelVariant` — YAML template first, then the resolver. */
153
+ private resolveModelVariant;
154
+ private gateTimeoutSeconds;
155
+ }
156
+ /** Build the app-registered `fanout` phase-type handler for a run. */
157
+ export declare function makeFanoutHandler(run: FanoutRunScope, reporter: PhaseReporter): PhaseTypeHandler;