lastlight-core 0.25.9 → 0.27.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.
- package/config/default.yaml +317 -1
- package/dist/admin/chat-session-reader.d.ts +3 -3
- package/dist/admin/chat-session-reader.js +8 -8
- package/dist/admin/chat-session-reader.js.map +1 -1
- package/dist/admin/docker.js.map +1 -1
- package/dist/admin/routes.js +97 -99
- package/dist/admin/routes.js.map +1 -1
- package/dist/admin/sessions.d.ts +7 -7
- package/dist/admin/sessions.js +6 -4
- package/dist/admin/sessions.js.map +1 -1
- package/dist/admin/tail.js.map +1 -1
- package/dist/config/config.d.ts +29 -0
- package/dist/config/config.js +141 -0
- package/dist/config/config.js.map +1 -1
- package/dist/config/repo-config.js +6 -7
- package/dist/config/repo-config.js.map +1 -1
- package/dist/connectors/messaging/base.js +2 -2
- package/dist/connectors/messaging/base.js.map +1 -1
- package/dist/connectors/messaging/session-manager.d.ts +29 -31
- package/dist/connectors/messaging/session-manager.js +156 -189
- package/dist/connectors/messaging/session-manager.js.map +1 -1
- package/dist/connectors/messaging/thread-transcript.d.ts +2 -2
- package/dist/connectors/messaging/thread-transcript.js +14 -8
- package/dist/connectors/messaging/thread-transcript.js.map +1 -1
- package/dist/connectors/slack/connector.js +5 -5
- package/dist/connectors/slack/connector.js.map +1 -1
- package/dist/cron/dependabot-discovery.js.map +1 -1
- package/dist/cron/feedback-poll.js +6 -6
- package/dist/cron/feedback-poll.js.map +1 -1
- package/dist/cron/handlers.js +3 -3
- package/dist/cron/handlers.js.map +1 -1
- package/dist/cron/jobs.d.ts +1 -1
- package/dist/cron/jobs.js +2 -2
- package/dist/cron/jobs.js.map +1 -1
- package/dist/cron/repo-digest.js +4 -4
- package/dist/cron/repo-digest.js.map +1 -1
- package/dist/cron/review-discovery.js.map +1 -1
- package/dist/cron/runner.js +2 -2
- package/dist/cron/runner.js.map +1 -1
- package/dist/cron/scheduler.js +1 -1
- package/dist/cron/scheduler.js.map +1 -1
- package/dist/engine/agent-executor.d.ts +25 -1
- package/dist/engine/agent-executor.js +41 -1
- package/dist/engine/agent-executor.js.map +1 -1
- package/dist/engine/chat/chat-prompt.d.ts +11 -4
- package/dist/engine/chat/chat-prompt.js.map +1 -1
- package/dist/engine/chat/chat-runner.d.ts +3 -2
- package/dist/engine/chat/chat-runner.js +9 -7
- package/dist/engine/chat/chat-runner.js.map +1 -1
- package/dist/engine/dispatcher.js +29 -25
- package/dist/engine/dispatcher.js.map +1 -1
- package/dist/engine/event-shim.d.ts +18 -0
- package/dist/engine/event-shim.js +2 -0
- package/dist/engine/event-shim.js.map +1 -1
- package/dist/engine/executors/orchestrator.d.ts +120 -1
- package/dist/engine/executors/orchestrator.js +214 -47
- package/dist/engine/executors/orchestrator.js.map +1 -1
- package/dist/engine/executors/shared.js.map +1 -1
- package/dist/engine/feedback/ingest.d.ts +4 -4
- package/dist/engine/feedback/ingest.js +13 -13
- package/dist/engine/feedback/ingest.js.map +1 -1
- package/dist/engine/feedback/slack.d.ts +2 -2
- package/dist/engine/feedback/slack.js +6 -6
- package/dist/engine/feedback/slack.js.map +1 -1
- package/dist/engine/fix-harvest.d.ts +1 -1
- package/dist/engine/fix-harvest.js +3 -3
- package/dist/engine/fix-harvest.js.map +1 -1
- package/dist/engine/github/github.d.ts +59 -0
- package/dist/engine/github/github.js +72 -0
- package/dist/engine/github/github.js.map +1 -1
- package/dist/engine/github/installations.js.map +1 -1
- package/dist/engine/github/review-poster.d.ts +388 -9
- package/dist/engine/github/review-poster.js +550 -50
- package/dist/engine/github/review-poster.js.map +1 -1
- package/dist/engine/github/team-visibility.js +7 -7
- package/dist/engine/github/team-visibility.js.map +1 -1
- package/dist/engine/llm.js.map +1 -1
- package/dist/engine/pr-decisions.d.ts +13 -5
- package/dist/engine/pr-decisions.js +204 -5
- package/dist/engine/pr-decisions.js.map +1 -1
- package/dist/engine/pr-escalation.js +7 -7
- package/dist/engine/pr-escalation.js.map +1 -1
- package/dist/engine/pr-state.d.ts +59 -1
- package/dist/engine/pr-state.js +76 -10
- package/dist/engine/pr-state.js.map +1 -1
- package/dist/engine/review-check.d.ts +1 -1
- package/dist/engine/review-check.js +5 -5
- package/dist/engine/review-check.js.map +1 -1
- package/dist/engine/review-spec.d.ts +264 -0
- package/dist/engine/review-spec.js +723 -0
- package/dist/engine/review-spec.js.map +1 -0
- package/dist/engine/router.js +3 -3
- package/dist/engine/router.js.map +1 -1
- package/dist/engine/screen/classifier.js.map +1 -1
- package/dist/engine/screen/screen.js.map +1 -1
- package/dist/evals-api.d.ts +3 -0
- package/dist/evals-api.js +20 -0
- package/dist/evals-api.js.map +1 -1
- package/dist/index.js +145 -67
- package/dist/index.js.map +1 -1
- package/dist/notify/digest-blocks.js.map +1 -1
- package/dist/notify/model.js.map +1 -1
- package/dist/notify/transports/github.js.map +1 -1
- package/dist/notify/transports/slack.js.map +1 -1
- package/dist/sandbox/artifact-backend.js.map +1 -1
- package/dist/sandbox/artifact-store.js.map +1 -1
- package/dist/sandbox/docker.d.ts +56 -5
- package/dist/sandbox/docker.js +96 -2
- package/dist/sandbox/docker.js.map +1 -1
- package/dist/sandbox/egress-allowlist.js.map +1 -1
- package/dist/sandbox/k8s/agent-context-registry.js.map +1 -1
- package/dist/sandbox/k8s/client.js.map +1 -1
- package/dist/sandbox/k8s/kubernetes-sandbox.d.ts +3 -0
- package/dist/sandbox/k8s/kubernetes-sandbox.js +9 -0
- package/dist/sandbox/k8s/kubernetes-sandbox.js.map +1 -1
- package/dist/sandbox/k8s/pod.d.ts +11 -0
- package/dist/sandbox/k8s/pod.js +11 -6
- package/dist/sandbox/k8s/pod.js.map +1 -1
- package/dist/sandbox/k8s/resource-name.js.map +1 -1
- package/dist/sandbox/k8s/run-id.js.map +1 -1
- package/dist/sandbox/k8s/run-secrets.js.map +1 -1
- package/dist/sandbox/k8s/service-containers.d.ts +43 -0
- package/dist/sandbox/k8s/service-containers.js +87 -0
- package/dist/sandbox/k8s/service-containers.js.map +1 -0
- package/dist/sandbox/k8s/skill-bundle.js.map +1 -1
- package/dist/sandbox/k8s/workspace-provisioner.js +10 -2
- package/dist/sandbox/k8s/workspace-provisioner.js.map +1 -1
- package/dist/sandbox/reap.d.ts +9 -0
- package/dist/sandbox/reap.js +36 -0
- package/dist/sandbox/reap.js.map +1 -1
- package/dist/sandbox/sandbox.d.ts +34 -0
- package/dist/sandbox/sandbox.js +36 -6
- package/dist/sandbox/sandbox.js.map +1 -1
- package/dist/sandbox/service-containers-docker.d.ts +45 -0
- package/dist/sandbox/service-containers-docker.js +78 -0
- package/dist/sandbox/service-containers-docker.js.map +1 -0
- package/dist/session-log.js.map +1 -1
- package/dist/state/approval-store.d.ts +23 -14
- package/dist/state/approval-store.js +137 -86
- package/dist/state/approval-store.js.map +1 -1
- package/dist/state/build-assets.js.map +1 -1
- package/dist/state/client.d.ts +105 -0
- package/dist/state/client.js +68 -0
- package/dist/state/client.js.map +1 -0
- package/dist/state/cron-run-store.d.ts +32 -12
- package/dist/state/cron-run-store.js +105 -39
- package/dist/state/cron-run-store.js.map +1 -1
- package/dist/state/data-migrate.d.ts +135 -0
- package/dist/state/data-migrate.js +309 -0
- package/dist/state/data-migrate.js.map +1 -0
- package/dist/state/db.d.ts +82 -23
- package/dist/state/db.js +201 -105
- package/dist/state/db.js.map +1 -1
- package/dist/state/dialect.d.ts +77 -0
- package/dist/state/dialect.js +129 -0
- package/dist/state/dialect.js.map +1 -0
- package/dist/state/execution-store.d.ts +124 -103
- package/dist/state/execution-store.js +569 -374
- package/dist/state/execution-store.js.map +1 -1
- package/dist/state/feedback-store.d.ts +20 -20
- package/dist/state/feedback-store.js +241 -187
- package/dist/state/feedback-store.js.map +1 -1
- package/dist/state/legacy-sqlite.d.ts +15 -0
- package/dist/state/legacy-sqlite.js +131 -0
- package/dist/state/legacy-sqlite.js.map +1 -0
- package/dist/state/pg-client.d.ts +44 -0
- package/dist/state/pg-client.js +81 -0
- package/dist/state/pg-client.js.map +1 -0
- package/dist/state/repo-ref.d.ts +9 -4
- package/dist/state/repo-ref.js +12 -6
- package/dist/state/repo-ref.js.map +1 -1
- package/dist/state/schema/pg.d.ts +2788 -0
- package/dist/state/schema/pg.js +301 -0
- package/dist/state/schema/pg.js.map +1 -0
- package/dist/state/schema/sqlite.d.ts +3063 -0
- package/dist/state/schema/sqlite.js +391 -0
- package/dist/state/schema/sqlite.js.map +1 -0
- package/dist/state/state-cli.d.ts +8 -0
- package/dist/state/state-cli.js +247 -0
- package/dist/state/state-cli.js.map +1 -0
- package/dist/state/team-store.d.ts +26 -13
- package/dist/state/team-store.js +140 -93
- package/dist/state/team-store.js.map +1 -1
- package/dist/state/user-store.d.ts +31 -13
- package/dist/state/user-store.js +180 -80
- package/dist/state/user-store.js.map +1 -1
- package/dist/state/workflow-run-store.d.ts +95 -56
- package/dist/state/workflow-run-store.js +419 -314
- package/dist/state/workflow-run-store.js.map +1 -1
- package/dist/telemetry/index.js.map +1 -1
- package/dist/workflows/admission.d.ts +4 -3
- package/dist/workflows/admission.js +34 -10
- package/dist/workflows/admission.js.map +1 -1
- package/dist/workflows/handlers/fanout.d.ts +157 -0
- package/dist/workflows/handlers/fanout.js +663 -0
- package/dist/workflows/handlers/fanout.js.map +1 -0
- package/dist/workflows/handlers/post-review.d.ts +98 -8
- package/dist/workflows/handlers/post-review.js +394 -23
- package/dist/workflows/handlers/post-review.js.map +1 -1
- package/dist/workflows/resume.js +22 -15
- package/dist/workflows/resume.js.map +1 -1
- package/dist/workflows/runner.js +60 -12
- package/dist/workflows/runner.js.map +1 -1
- package/dist/workflows/simple.d.ts +23 -0
- package/dist/workflows/simple.js +40 -16
- package/dist/workflows/simple.js.map +1 -1
- package/docker-compose.yml +50 -0
- package/drizzle/pg/0000_init.sql +235 -0
- package/drizzle/pg/meta/0000_snapshot.json +1751 -0
- package/drizzle/pg/meta/_journal.json +13 -0
- package/drizzle/sqlite/0000_baseline.sql +257 -0
- package/drizzle/sqlite/0001_backfill_repo_refs.sql +74 -0
- package/drizzle/sqlite/meta/0000_snapshot.json +1593 -0
- package/drizzle/sqlite/meta/0001_snapshot.json +1593 -0
- package/drizzle/sqlite/meta/_journal.json +20 -0
- package/package.json +31 -15
- package/sandbox.Dockerfile +54 -0
- package/skills/code-review/SKILL.md +98 -13
- package/skills/pr-review/SKILL.md +97 -21
- package/skills/pr-review/references/findings-schema.md +37 -6
- package/workflows/pr-review.yaml +567 -0
- package/workflows/prompts/dependabot-pr-merge.md +22 -2
- package/workflows/prompts/review-adjudicate.md +323 -0
- package/workflows/prompts/review-falsify.md +149 -0
- package/workflows/prompts/review.md +80 -0
- package/workflows/prompts/survey-contract.md +109 -0
- package/workflows/prompts/survey-enforcement.md +126 -0
- package/workflows/prompts/survey-security.md +118 -0
- package/workflows/prompts/survey-spec.md +110 -0
- package/workflows/prompts/survey-state.md +143 -0
- package/workflows/prompts/survey-tests.md +99 -0
- package/dist/state/migrate.d.ts +0 -15
- package/dist/state/migrate.js +0 -518
- package/dist/state/migrate.js.map +0 -1
|
@@ -20,13 +20,85 @@ export type ReviewSide = "LEFT" | "RIGHT";
|
|
|
20
20
|
/** One finding as written by the `pr-review` skill into findings.json. */
|
|
21
21
|
export interface ReviewFinding {
|
|
22
22
|
path: string;
|
|
23
|
-
|
|
23
|
+
/**
|
|
24
|
+
* ADVISORY since WP6a. The model is asked for it, but {@link resolveAnchor}
|
|
25
|
+
* derives the real value from {@link ReviewFinding.existingCode} and
|
|
26
|
+
* overwrites this when it succeeds. Optional because a finding whose excerpt
|
|
27
|
+
* resolves needs no line at all, and one whose excerpt does not resolve is
|
|
28
|
+
* demoted to the body — where a wrong number is worse than none.
|
|
29
|
+
*/
|
|
30
|
+
line?: number;
|
|
24
31
|
side?: ReviewSide;
|
|
25
32
|
start_line?: number;
|
|
26
33
|
severity?: string;
|
|
27
34
|
title?: string;
|
|
28
35
|
body?: string;
|
|
29
36
|
suggestion?: string;
|
|
37
|
+
/**
|
|
38
|
+
* The verbatim excerpt the finding is about — the anchor of record.
|
|
39
|
+
*
|
|
40
|
+
* **Models quote code well and count lines badly.** `alibaba/open-code-review`
|
|
41
|
+
* names the failure "position drift" and lists it second of the three its
|
|
42
|
+
* architecture is built against; our own cost is worse than theirs, because
|
|
43
|
+
* `post-review` DEMOTES an off-diff line rather than correcting it, so a
|
|
44
|
+
* finding whose analysis is perfect and whose arithmetic is off by two pays
|
|
45
|
+
* the full price of a wrong answer. See {@link resolveAnchor}.
|
|
46
|
+
*/
|
|
47
|
+
existingCode?: string;
|
|
48
|
+
/** The obligation family this came from — the key for the per-family threshold (WP6b). */
|
|
49
|
+
family?: string;
|
|
50
|
+
/** 0..1. Absent is NOT zero — see {@link tierFindings}. */
|
|
51
|
+
confidence?: number;
|
|
52
|
+
/**
|
|
53
|
+
* The survey hypothesis ids this finding was built from, as written by the
|
|
54
|
+
* `adjudicate` phase (`findings[].hypotheses[]`, the same field the
|
|
55
|
+
* conservation gate reads).
|
|
56
|
+
*
|
|
57
|
+
* **Optional, and an empty array is not the same as a clean one.** A finding
|
|
58
|
+
* with none is either the shipped reviewer's own — which was never
|
|
59
|
+
* hypothesis-derived — or one the adjudicator generated downstream of the
|
|
60
|
+
* surveys. Neither can be judged by its provenance, so both keep the
|
|
61
|
+
* confidence path. See {@link tierFindings}.
|
|
62
|
+
*/
|
|
63
|
+
hypotheses?: string[];
|
|
64
|
+
/**
|
|
65
|
+
* An EXPLICIT destination, set by the `adjudicate` phase (and by
|
|
66
|
+
* `lastlight-facts findings --repair`, which records an unaccounted-for
|
|
67
|
+
* hypothesis at `internal`).
|
|
68
|
+
*
|
|
69
|
+
* Honoured in one direction only: `internal` and `body` are obeyed, `inline`
|
|
70
|
+
* is a request that still has to clear anchorability and the budget. A
|
|
71
|
+
* document may not grant itself a scarce inline slot — but it must always be
|
|
72
|
+
* able to say "record this, do not post it", or the conservation floor's
|
|
73
|
+
* repaired findings would be POSTED, which is the opposite of what recording
|
|
74
|
+
* them means.
|
|
75
|
+
*/
|
|
76
|
+
tier?: "inline" | "body" | "internal";
|
|
77
|
+
}
|
|
78
|
+
/** A finding that has an anchor. Narrowed by {@link splitFindings}. */
|
|
79
|
+
export type AnchoredFinding = ReviewFinding & {
|
|
80
|
+
line: number;
|
|
81
|
+
};
|
|
82
|
+
/** One axis of the split verdict. `unknown` = not assessed, which is not a pass. */
|
|
83
|
+
export type AxisVerdict = "pass" | "fail" | "unknown";
|
|
84
|
+
/**
|
|
85
|
+
* The per-axis verdict — issue #271's fix 7.
|
|
86
|
+
*
|
|
87
|
+
* > *"A blended verdict lets the passing axis hide the failing one."*
|
|
88
|
+
*
|
|
89
|
+
* A change that is clean by every standards check but does not do what the
|
|
90
|
+
* issue asked is exactly the case a single `event` cannot express, and the
|
|
91
|
+
* production numbers say it is not hypothetical: 71% APPROVE, 58 of 59
|
|
92
|
+
* approvals carrying zero inline findings.
|
|
93
|
+
*
|
|
94
|
+
* `unknown` is a first-class value and deliberately does NOT block: it is the
|
|
95
|
+
* honest answer when a PR states no acceptance criteria, which is most of them.
|
|
96
|
+
* Treating "not assessed" as "failed" would stop the reviewer approving
|
|
97
|
+
* anything, which is a worse reviewer, not a stricter one.
|
|
98
|
+
*/
|
|
99
|
+
export interface SplitVerdict {
|
|
100
|
+
spec?: AxisVerdict;
|
|
101
|
+
standards?: AxisVerdict;
|
|
30
102
|
}
|
|
31
103
|
/**
|
|
32
104
|
* The findings document the agent writes. `pr_number` / `base_ref` /
|
|
@@ -38,6 +110,14 @@ export interface ReviewFindingsDoc {
|
|
|
38
110
|
summary?: string;
|
|
39
111
|
event?: ReviewEvent;
|
|
40
112
|
findings?: ReviewFinding[];
|
|
113
|
+
/**
|
|
114
|
+
* Optional per-axis verdict. Absent ⇒ today's behaviour exactly, which is
|
|
115
|
+
* what makes the field safe to add before anything writes it.
|
|
116
|
+
*
|
|
117
|
+
* The `post-review` handler strips this unless `review.analysis.enabled`, so
|
|
118
|
+
* inertness is structural rather than a promise about what a prompt says.
|
|
119
|
+
*/
|
|
120
|
+
verdict?: SplitVerdict;
|
|
41
121
|
}
|
|
42
122
|
/** An inline review comment in the shape GitHub's create-review API expects. */
|
|
43
123
|
export interface InlineComment {
|
|
@@ -55,14 +135,122 @@ export interface BuiltReview {
|
|
|
55
135
|
comments: InlineComment[];
|
|
56
136
|
inlineCount: number;
|
|
57
137
|
demotedCount: number;
|
|
138
|
+
/** Below the floor: recorded, never posted. Always 0 without an {@link AttentionBoundary}. */
|
|
139
|
+
internalCount: number;
|
|
140
|
+
/**
|
|
141
|
+
* The tiering this review was built from, present only when an
|
|
142
|
+
* {@link AttentionBoundary} was supplied.
|
|
143
|
+
*
|
|
144
|
+
* Returned rather than recomputed by the caller so that the review that gets
|
|
145
|
+
* POSTED and the disposition record that gets AUDITED are the same object.
|
|
146
|
+
* Two calls to a pure function on identical arguments cannot disagree today —
|
|
147
|
+
* but the audit trail claiming something the post did not do is precisely the
|
|
148
|
+
* failure the `internal` tier's auditability exists to rule out, and one edit
|
|
149
|
+
* to either branch is all it would take.
|
|
150
|
+
*/
|
|
151
|
+
tiered?: TieredFindings;
|
|
58
152
|
}
|
|
153
|
+
/** One line of one hunk, with the line number it carries on each side. */
|
|
154
|
+
export interface DiffLine {
|
|
155
|
+
/** `+` added · `-` removed · ` ` context. */
|
|
156
|
+
prefix: "+" | "-" | " ";
|
|
157
|
+
/** The line's text, with the diff prefix character stripped. */
|
|
158
|
+
text: string;
|
|
159
|
+
/** Old-file line number, or `null` for an added line. */
|
|
160
|
+
left: number | null;
|
|
161
|
+
/** New-file line number, or `null` for a removed line. */
|
|
162
|
+
right: number | null;
|
|
163
|
+
}
|
|
164
|
+
/** One `@@` hunk. Lines within a hunk are contiguous; across hunks they are not. */
|
|
165
|
+
export interface DiffHunk {
|
|
166
|
+
lines: DiffLine[];
|
|
167
|
+
}
|
|
168
|
+
/** One file's worth of a unified diff, keyed by its NEW path. */
|
|
169
|
+
export interface DiffFile {
|
|
170
|
+
path: string;
|
|
171
|
+
hunks: DiffHunk[];
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Parse a unified diff into per-file hunks, **keeping the line text**.
|
|
175
|
+
*
|
|
176
|
+
* `parseDiff` used to be the only parser and threw the text away, which made
|
|
177
|
+
* the WP6a anchor cascade structurally impossible: you cannot match an excerpt
|
|
178
|
+
* against a corpus of line numbers. This is the same single pass, retaining
|
|
179
|
+
* what it already read.
|
|
180
|
+
*
|
|
181
|
+
* A `+++ /dev/null` (a deletion) yields no file — there is no new-side path to
|
|
182
|
+
* anchor against — matching the old parser exactly.
|
|
183
|
+
*/
|
|
184
|
+
export declare function parseDiffFiles(diff: string): DiffFile[];
|
|
59
185
|
/**
|
|
60
|
-
*
|
|
186
|
+
* The commentable set: `path -> Set<"SIDE:line">`. Added/`+` and context lines
|
|
61
187
|
* are `RIGHT:<newLine>`; removed/`-` and context lines are `LEFT:<oldLine>` —
|
|
62
188
|
* mirroring GitHub's three-dot PR diff anchoring. A finding may be commented
|
|
63
189
|
* inline only when its `side:line` appears in this set.
|
|
64
190
|
*/
|
|
191
|
+
export declare function commentableOf(files: DiffFile[]): Map<string, Set<string>>;
|
|
192
|
+
/** Map a unified diff straight to its commentable set. */
|
|
65
193
|
export declare function parseDiff(diff: string): Map<string, Set<string>>;
|
|
194
|
+
/** How an anchor was arrived at. `model` = the cascade declined and the model's own line stands. */
|
|
195
|
+
export type AnchorVia = "model" | "hunk" | "file" | "relocated";
|
|
196
|
+
/** A resolved anchor. `path` may differ from the finding's — that is step 3. */
|
|
197
|
+
export interface AnchorResolution {
|
|
198
|
+
path: string;
|
|
199
|
+
line: number;
|
|
200
|
+
side: ReviewSide;
|
|
201
|
+
start_line?: number;
|
|
202
|
+
via: AnchorVia;
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* Derive a finding's anchor from its verbatim `existingCode`, instead of
|
|
206
|
+
* trusting the line number the model counted.
|
|
207
|
+
*
|
|
208
|
+
* | # | Step | Model? |
|
|
209
|
+
* |---|---|---|
|
|
210
|
+
* | 1 | Match the excerpt against the file's own hunks — new side, then old side | no |
|
|
211
|
+
* | 2 | Scan the full head-side file content | no |
|
|
212
|
+
* | 3 | Relocate across files: a **unique** hit anywhere in the diff re-files the finding | no |
|
|
213
|
+
* | 4 | Ask a model to regenerate the excerpt and retry step 1 | yes |
|
|
214
|
+
* | 5 | Still unlocated — demote to the body, exactly as today | — |
|
|
215
|
+
*
|
|
216
|
+
* **Step 4 is deliberately NOT built**, and the reason is the same one that
|
|
217
|
+
* makes step 3 mandatory. `post-review` is a deterministic phase-type handler
|
|
218
|
+
* with no model binding, so step 4 is new machinery; and Open Code Review's
|
|
219
|
+
* source records what that machinery does when it fires — handed the *wrong
|
|
220
|
+
* file's* diff and a prompt demanding a code block back, the model answers with
|
|
221
|
+
* whatever token in that diff looks closest, overwriting the one piece of
|
|
222
|
+
* evidence that pointed at the real code. The comment then ends up **looking
|
|
223
|
+
* located while pointing at unrelated code**, which is strictly worse than the
|
|
224
|
+
* demotion it was trying to avoid. A declaration/implementation split is the
|
|
225
|
+
* normal shape of a finding from a contract delta, so that is not an exotic
|
|
226
|
+
* case for us. Step 3 covers it without a model; step 5 is the honest floor.
|
|
227
|
+
*
|
|
228
|
+
* Returns `null` when nothing resolved — the caller then leaves the model's own
|
|
229
|
+
* `line` alone and lets {@link splitFindings} demote it if it is off-diff.
|
|
230
|
+
*/
|
|
231
|
+
export declare function resolveAnchor(f: ReviewFinding, files: DiffFile[], readHeadFile?: (path: string) => string | null): AnchorResolution | null;
|
|
232
|
+
/** What {@link anchorFindings} did, for the log line and the eval. */
|
|
233
|
+
export interface AnchorStats {
|
|
234
|
+
hunk: number;
|
|
235
|
+
file: number;
|
|
236
|
+
relocated: number;
|
|
237
|
+
/** Had an `existingCode` and still could not be placed. */
|
|
238
|
+
unresolved: number;
|
|
239
|
+
/** Carried no `existingCode` at all — the model's line stands unchecked. */
|
|
240
|
+
noExcerpt: number;
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* Run the cascade over every finding, returning NEW finding objects with the
|
|
244
|
+
* derived anchor written on. Pure: the only I/O is the injected `readHeadFile`.
|
|
245
|
+
*
|
|
246
|
+
* The anchor must be written back onto the finding before {@link splitFindings}
|
|
247
|
+
* sees it — that function partitions on `f.line`, so a resolution that is not
|
|
248
|
+
* persisted is a resolution that demotes anyway.
|
|
249
|
+
*/
|
|
250
|
+
export declare function anchorFindings(findings: ReviewFinding[], files: DiffFile[], readHeadFile?: (path: string) => string | null): {
|
|
251
|
+
findings: ReviewFinding[];
|
|
252
|
+
stats: AnchorStats;
|
|
253
|
+
};
|
|
66
254
|
/** True when a finding anchors onto a line that appears in the diff. */
|
|
67
255
|
export declare function isAnchored(f: ReviewFinding, commentable: Map<string, Set<string>> | null): boolean;
|
|
68
256
|
/**
|
|
@@ -72,27 +260,218 @@ export declare function isAnchored(f: ReviewFinding, commentable: Map<string, Se
|
|
|
72
260
|
* review still posts and nothing is lost.
|
|
73
261
|
*/
|
|
74
262
|
export declare function splitFindings(findings: ReviewFinding[], commentable: Map<string, Set<string>> | null): {
|
|
75
|
-
inline:
|
|
263
|
+
inline: AnchoredFinding[];
|
|
76
264
|
demoted: ReviewFinding[];
|
|
77
265
|
};
|
|
78
|
-
/**
|
|
266
|
+
/**
|
|
267
|
+
* Why a finding is in the review body rather than inline. Three causes, and
|
|
268
|
+
* they must stay distinguishable: "Additional findings" meaning off-diff AND
|
|
269
|
+
* below-threshold AND overflowed-the-cap, under one heading, is a worse review
|
|
270
|
+
* to read than the one it replaced (§D11).
|
|
271
|
+
*/
|
|
272
|
+
export type DemotionReason = "off-diff" | "below-threshold" | "overflow" | "adjudicated";
|
|
273
|
+
/** One demoted finding, carrying the reason it did not earn an inline comment. */
|
|
274
|
+
export interface DemotedFinding {
|
|
275
|
+
finding: ReviewFinding;
|
|
276
|
+
reason: DemotionReason;
|
|
277
|
+
}
|
|
278
|
+
/**
|
|
279
|
+
* Why a finding was recorded rather than posted. The same treatment
|
|
280
|
+
* {@link DemotionReason} gives the body tier, and for the same reason: three
|
|
281
|
+
* causes under one label is a record that cannot answer *"what did we know and
|
|
282
|
+
* not say, and why?"* — which is the only thing separating an attention
|
|
283
|
+
* boundary from v2's suppressor.
|
|
284
|
+
*
|
|
285
|
+
* - `adjudicated` — the document said `tier: "internal"` itself. That includes
|
|
286
|
+
* every hypothesis the conservation floor repaired, which carries no
|
|
287
|
+
* confidence at all.
|
|
288
|
+
* - `clean-discharge` — every supporting hypothesis is a clean QUOTE, so the
|
|
289
|
+
* finding is an ANTI-finding. See {@link tierFindings}.
|
|
290
|
+
* - `below-floor` — under {@link AttentionBoundary.internalFloor}.
|
|
291
|
+
* - `body-budget` — demoted to the body and then past
|
|
292
|
+
* {@link AttentionBoundary.maxBodyComments}. The only reason applied to a
|
|
293
|
+
* finding the boundary had already ROUTED somewhere visible, which is why it
|
|
294
|
+
* must stay its own token: folded into any of the other three it would read
|
|
295
|
+
* as a judgement about the finding's content, when it is a judgement about
|
|
296
|
+
* the reader's attention.
|
|
297
|
+
*/
|
|
298
|
+
export type InternalReason = "adjudicated" | "clean-discharge" | "below-floor" | "body-budget";
|
|
299
|
+
/** One recorded-not-posted finding, carrying the reason it was withheld. */
|
|
300
|
+
export interface InternalFinding {
|
|
301
|
+
finding: ReviewFinding;
|
|
302
|
+
reason: InternalReason;
|
|
303
|
+
}
|
|
304
|
+
/**
|
|
305
|
+
* The attention budget. Absent ⇒ today's behaviour exactly: no cap, no
|
|
306
|
+
* thresholds, no `internal` tier — every finding is inline or body, decided by
|
|
307
|
+
* anchorability alone.
|
|
308
|
+
*/
|
|
309
|
+
export interface AttentionBoundary {
|
|
310
|
+
/** Rank by confidence × severity; everything past this goes to the body, never away. */
|
|
311
|
+
maxInlineComments: number;
|
|
312
|
+
/** Per-obligation-family confidence bar for an INLINE comment. Below it: the body. */
|
|
313
|
+
thresholds: Record<string, number>;
|
|
314
|
+
/** Below this, recorded but not posted. See {@link TieredFindings.internal}. */
|
|
315
|
+
internalFloor: number;
|
|
316
|
+
/**
|
|
317
|
+
* Cap on the FINAL body list — applied last, after every other rule has
|
|
318
|
+
* routed findings there (including the inline overflow), because it governs
|
|
319
|
+
* what the "Additional findings" section may cost a reader, not how any
|
|
320
|
+
* single finding was judged.
|
|
321
|
+
*
|
|
322
|
+
* Unlike `maxInlineComments` this budget DOES filter: the excess is tiered
|
|
323
|
+
* `internal` with reason `body-budget` — recorded in the disposition, never
|
|
324
|
+
* posted. `null` or absent = unlimited, the legacy funnel; `0` = nothing
|
|
325
|
+
* tiers to body at all. Ranked by {@link rankOf} — the same severity ×
|
|
326
|
+
* confidence rank the inline budget spends, so an absent confidence ranks
|
|
327
|
+
* as 1.0 (severity order), never as low confidence. Shipped default is `5`
|
|
328
|
+
* (see `ReviewAnalysisConfig.maxBodyComments` in lastlight-shared for the
|
|
329
|
+
* measurements, and for why the measured-best `0` is not the shipped one);
|
|
330
|
+
* optional here so every existing constructor keeps today's behaviour.
|
|
331
|
+
*/
|
|
332
|
+
maxBodyComments?: number | null;
|
|
333
|
+
}
|
|
334
|
+
/** The three destinations. Nothing is dropped; `internal` is recorded, not posted. */
|
|
335
|
+
export interface TieredFindings {
|
|
336
|
+
inline: AnchoredFinding[];
|
|
337
|
+
body: DemotedFinding[];
|
|
338
|
+
/**
|
|
339
|
+
* Below the floor: kept in `findings.json` with its reason, never posted.
|
|
340
|
+
*
|
|
341
|
+
* **This is an attention boundary, not v2's suppressor**, and the difference
|
|
342
|
+
* is that it is auditable — WP7's `review_findings` table is where it becomes
|
|
343
|
+
* queryable; until then the run's own findings document is the record.
|
|
344
|
+
*/
|
|
345
|
+
internal: InternalFinding[];
|
|
346
|
+
}
|
|
347
|
+
/**
|
|
348
|
+
* Split findings across the three destinations.
|
|
349
|
+
*
|
|
350
|
+
* Order matters and each step is a different question: does this SAY anything
|
|
351
|
+
* (the clean-discharge rule) · is it worth a human's attention at all (the
|
|
352
|
+
* floor) · can it even be anchored (GitHub's constraint) · is it confident
|
|
353
|
+
* enough for an inline comment (the family threshold) · is there room (the
|
|
354
|
+
* budget) · and, last, may the body still grow (the body budget,
|
|
355
|
+
* {@link AttentionBoundary.maxBodyComments} — the one step that moves a
|
|
356
|
+
* finding OUT of the posted review, to `internal` with reason `body-budget`).
|
|
357
|
+
*
|
|
358
|
+
* **A missing `confidence` never demotes and never suppresses.** Both bars are
|
|
359
|
+
* `confidence !== undefined && confidence < bar`, so a finding that declines to
|
|
360
|
+
* self-score is treated as passing — the alternative silently deletes every
|
|
361
|
+
* finding from any prompt that has not been taught the field.
|
|
362
|
+
*
|
|
363
|
+
* ## The clean-discharge rule, and why it is not a confidence rule
|
|
364
|
+
*
|
|
365
|
+
* A survey discharges each obligation with QUOTE / ABSENT / PARTIAL / PROBE,
|
|
366
|
+
* and the row shape's own contract is *"on a clean QUOTE write
|
|
367
|
+
* `failureScenario: null`"*. So a row that is a `QUOTE` with an explicit null
|
|
368
|
+
* scenario is the pass saying **"I looked, I quote the line, and it is fine"**.
|
|
369
|
+
* A finding built ENTIRELY out of such rows is an anti-finding: it cannot match
|
|
370
|
+
* a gold defect by construction, and posting it spends a maintainer's attention
|
|
371
|
+
* on a report that nothing is wrong.
|
|
372
|
+
*
|
|
373
|
+
* **Measured on `prreview__skillspro-1587-r2`, three identical repeats**: of the
|
|
374
|
+
* 45 / 48 / 46 hypotheses, **23 / 25 / 23** are clean discharges under the rule
|
|
375
|
+
* this file implements — `QUOTE` with `failureScenario` PRESENT and explicitly
|
|
376
|
+
* `null` — and 17 / 14 / 7 findings trace entirely to them.
|
|
377
|
+
*
|
|
378
|
+
* The looser reading that counts a merely ABSENT key scores 23 / 25 / 30, and
|
|
379
|
+
* the seven-row gap is the whole reason the strict form is the one here. Under
|
|
380
|
+
* the pre-2026-08-23 obligation contract the field did not exist at all, and the
|
|
381
|
+
* `spec` pass's row shape has nowhere to record one, so 37 rows across the
|
|
382
|
+
* preserved minimal-contract runs are `QUOTE` with no key — silence that carries
|
|
383
|
+
* no information. Reading it as "clean" would demote 28 findings across 4 of 16
|
|
384
|
+
* of those instances on the strength of a field nobody asked for. Strictly, the
|
|
385
|
+
* count there is **0 of 16** and this rule is a verified no-op, which is what
|
|
386
|
+
* keeps the control arm single-variable. On the first repeat **all 17 were posted**
|
|
387
|
+
* — "Type contract: consolidateData correctly accepts…", "GOOGLE_CLIENT_ID
|
|
388
|
+
* constant imported and passed correctly". The confidence bars cannot catch
|
|
389
|
+
* them: confidence on those rows is uniformly ≥ 0.7 (median 0.95–1.00, minimum
|
|
390
|
+
* 0.75 across the whole document), so `internalFloor` and every family
|
|
391
|
+
* threshold pass them. That is the point — **an anti-finding is not an
|
|
392
|
+
* unconfident finding, it is a confident report of nothing**, and only its
|
|
393
|
+
* provenance says so.
|
|
394
|
+
*
|
|
395
|
+
* It is checked BEFORE the floor because it is the more specific answer to
|
|
396
|
+
* "why was this withheld?", not because the two disagree about the tier — they
|
|
397
|
+
* cannot; both are `internal`.
|
|
398
|
+
*
|
|
399
|
+
* `clean` is supplied by the caller (`post-review` reads the sibling
|
|
400
|
+
* `hypotheses/*.jsonl`), never read here: this module does no I/O. Absent or
|
|
401
|
+
* empty ⇒ the rule cannot fire, which is the inertness guarantee for every
|
|
402
|
+
* deployment and every arm that runs no evidence pipeline.
|
|
403
|
+
*/
|
|
404
|
+
export declare function tierFindings(findings: ReviewFinding[], commentable: Map<string, Set<string>> | null, boundary: AttentionBoundary, clean?: ReadonlySet<string>): TieredFindings;
|
|
405
|
+
/**
|
|
406
|
+
* The flat "Additional findings" section — no reasons, one heading. Still the
|
|
407
|
+
* whole story when there is no attention boundary configured, and the shape the
|
|
408
|
+
* body-only retry uses (there every finding is demoted for the same reason).
|
|
409
|
+
*/
|
|
79
410
|
export declare function renderDemoted(list: ReviewFinding[]): string;
|
|
411
|
+
/**
|
|
412
|
+
* The "Additional findings" section, grouped by why each finding is here.
|
|
413
|
+
*
|
|
414
|
+
* Everything in it is still POSTED and still visible — demotion is not
|
|
415
|
+
* suppression. What it is not is an inline comment at the defect site, and the
|
|
416
|
+
* evidence says that difference is large ("Does AI Code Review Lead to Code
|
|
417
|
+
* Changes?", 22k+ real comments: concise, hunk-level, actionable findings are
|
|
418
|
+
* substantially likelier to cause a change).
|
|
419
|
+
*/
|
|
420
|
+
export declare function renderDemotedGrouped(entries: DemotedFinding[]): string;
|
|
80
421
|
/** Build the inline-comment objects GitHub's create-review API expects. */
|
|
81
|
-
export declare function toInlineComments(list:
|
|
422
|
+
export declare function toInlineComments(list: AnchoredFinding[]): InlineComment[];
|
|
423
|
+
/**
|
|
424
|
+
* The worse of the two axes, or `undefined` when neither was recorded.
|
|
425
|
+
*
|
|
426
|
+
* Ordering is `fail` > `unknown` > `pass`, and only `fail` is load-bearing —
|
|
427
|
+
* see {@link SplitVerdict} for why `unknown` must not block.
|
|
428
|
+
*/
|
|
429
|
+
export declare function worstAxis(verdict: SplitVerdict | undefined): AxisVerdict | undefined;
|
|
82
430
|
/**
|
|
83
431
|
* Resolve the review event. An explicit `doc.event` wins; otherwise an empty
|
|
84
432
|
* findings set is an `APPROVE` and anything else is a `COMMENT` (never an
|
|
85
433
|
* automatic `REQUEST_CHANGES` — that stays an explicit, deliberate call).
|
|
434
|
+
*
|
|
435
|
+
* ## The split verdict's one effect
|
|
436
|
+
*
|
|
437
|
+
* A `fail` on EITHER axis stops the review being an `APPROVE`; it becomes a
|
|
438
|
+
* `COMMENT`. Nothing else changes: the event is never escalated to
|
|
439
|
+
* `REQUEST_CHANGES`, and among the non-APPROVE events an explicit `doc.event`
|
|
440
|
+
* still wins, so a fork choosing `REQUEST_CHANGES` over `COMMENT` keeps its
|
|
441
|
+
* choice.
|
|
442
|
+
*
|
|
443
|
+
* **Why the downgrade also applies to an EXPLICIT `APPROVE`**, which is the one
|
|
444
|
+
* judgement call in this function. The retired WP6 doc (git history; condensed
|
|
445
|
+
* in `docs/plans/deterministic-pr-levers.md` §"Adjudication and the attention
|
|
446
|
+
* boundary (WP6)") says `resolveEvent` "takes
|
|
447
|
+
* the worse of the two axes" while `event` "remains explicit-wins". Read
|
|
448
|
+
* strictly, those contradict: today's skill makes `event` a REQUIRED field, so
|
|
449
|
+
* an always-present explicit event would make the split verdict inert by
|
|
450
|
+
* construction — the passing axis would go on hiding the failing one, which is
|
|
451
|
+
* the entire defect #271 filed. So "explicit-wins" is read as governing the
|
|
452
|
+
* CHOICE OF EVENT, and the axis verdict as a FLOOR under it, exactly like the
|
|
453
|
+
* skill's existing "never APPROVE over an open human CHANGES_REQUESTED" rule.
|
|
454
|
+
* An agent that writes `event: APPROVE` beside `verdict.spec: "fail"` has
|
|
455
|
+
* contradicted itself, and the safe reading of a self-contradiction is the one
|
|
456
|
+
* that does not silently approve a change that does not do what was asked.
|
|
86
457
|
*/
|
|
87
458
|
export declare function resolveEvent(doc: ReviewFindingsDoc): ReviewEvent;
|
|
88
459
|
/**
|
|
89
460
|
* Compose the full review payload. Pass `commentable = null` to force every
|
|
90
461
|
* finding into the body (the diff-unavailable fallback).
|
|
91
462
|
*/
|
|
92
|
-
export declare function buildReview(doc: ReviewFindingsDoc, commentable: Map<string, Set<string>> | null): BuiltReview;
|
|
463
|
+
export declare function buildReview(doc: ReviewFindingsDoc, commentable: Map<string, Set<string>> | null, boundary?: AttentionBoundary, clean?: ReadonlySet<string>): BuiltReview;
|
|
93
464
|
/**
|
|
94
465
|
* The body-only fallback: when the inline POST is rejected (e.g. a stale diff
|
|
95
|
-
* yields a 422 on a comment line), re-render with
|
|
96
|
-
* the review still lands. Same event as the inline attempt.
|
|
466
|
+
* yields a 422 on a comment line), re-render with every POSTABLE finding in the
|
|
467
|
+
* body so the review still lands. Same event as the inline attempt.
|
|
468
|
+
*
|
|
469
|
+
* **Pass `tiered` whenever the boundary produced one.** Without it this
|
|
470
|
+
* re-reads `doc.findings` wholesale, which republishes the `internal` tier —
|
|
471
|
+
* the conservation floor's repaired hypotheses and the anti-findings alike — so
|
|
472
|
+
* "recorded, never posted" would hold on the happy path and quietly stop
|
|
473
|
+
* holding on the retry. That is a dark drop's mirror image: a publication
|
|
474
|
+
* nobody decided on, reached by a failure in an unrelated request. Omitted ⇒
|
|
475
|
+
* today's behaviour exactly, which is what every no-boundary caller gets.
|
|
97
476
|
*/
|
|
98
|
-
export declare function buildBodyOnlyReview(doc: ReviewFindingsDoc): BuiltReview;
|
|
477
|
+
export declare function buildBodyOnlyReview(doc: ReviewFindingsDoc, tiered?: TieredFindings): BuiltReview;
|