@afaik-lab/weigh 0.0.0-stage → 0.6.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/.env.example +49 -0
- package/LICENSE +373 -0
- package/README.md +102 -2
- package/dist/agent.d.ts +83 -0
- package/dist/agent.d.ts.map +1 -0
- package/dist/agent.js +204 -0
- package/dist/agent.js.map +1 -0
- package/dist/ceilings.d.ts +32 -0
- package/dist/ceilings.d.ts.map +1 -0
- package/dist/ceilings.js +61 -0
- package/dist/ceilings.js.map +1 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +530 -0
- package/dist/cli.js.map +1 -0
- package/dist/config-cli.d.ts +15 -0
- package/dist/config-cli.d.ts.map +1 -0
- package/dist/config-cli.js +132 -0
- package/dist/config-cli.js.map +1 -0
- package/dist/config.d.ts +198 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +373 -0
- package/dist/config.js.map +1 -0
- package/dist/context-cli.d.ts +35 -0
- package/dist/context-cli.d.ts.map +1 -0
- package/dist/context-cli.js +251 -0
- package/dist/context-cli.js.map +1 -0
- package/dist/context.d.ts +118 -0
- package/dist/context.d.ts.map +1 -0
- package/dist/context.js +159 -0
- package/dist/context.js.map +1 -0
- package/dist/corrections/correction-set.d.ts +67 -0
- package/dist/corrections/correction-set.d.ts.map +1 -0
- package/dist/corrections/correction-set.js +104 -0
- package/dist/corrections/correction-set.js.map +1 -0
- package/dist/corrections/correction.d.ts +74 -0
- package/dist/corrections/correction.d.ts.map +1 -0
- package/dist/corrections/correction.js +154 -0
- package/dist/corrections/correction.js.map +1 -0
- package/dist/corrections/follow-up.d.ts +69 -0
- package/dist/corrections/follow-up.d.ts.map +1 -0
- package/dist/corrections/follow-up.js +217 -0
- package/dist/corrections/follow-up.js.map +1 -0
- package/dist/corrections/index.d.ts +31 -0
- package/dist/corrections/index.d.ts.map +1 -0
- package/dist/corrections/index.js +31 -0
- package/dist/corrections/index.js.map +1 -0
- package/dist/corrections/ledger.d.ts +78 -0
- package/dist/corrections/ledger.d.ts.map +1 -0
- package/dist/corrections/ledger.js +117 -0
- package/dist/corrections/ledger.js.map +1 -0
- package/dist/corrections/promotion.d.ts +119 -0
- package/dist/corrections/promotion.d.ts.map +1 -0
- package/dist/corrections/promotion.js +221 -0
- package/dist/corrections/promotion.js.map +1 -0
- package/dist/corrections/schema.d.ts +125 -0
- package/dist/corrections/schema.d.ts.map +1 -0
- package/dist/corrections/schema.js +100 -0
- package/dist/corrections/schema.js.map +1 -0
- package/dist/corrections-cli.d.ts +28 -0
- package/dist/corrections-cli.d.ts.map +1 -0
- package/dist/corrections-cli.js +157 -0
- package/dist/corrections-cli.js.map +1 -0
- package/dist/diff.d.ts +105 -0
- package/dist/diff.d.ts.map +1 -0
- package/dist/diff.js +202 -0
- package/dist/diff.js.map +1 -0
- package/dist/doctor.d.ts +38 -0
- package/dist/doctor.d.ts.map +1 -0
- package/dist/doctor.js +197 -0
- package/dist/doctor.js.map +1 -0
- package/dist/events.d.ts +21 -0
- package/dist/events.d.ts.map +1 -0
- package/dist/events.js +5 -0
- package/dist/events.js.map +1 -0
- package/dist/findings.d.ts +510 -0
- package/dist/findings.d.ts.map +1 -0
- package/dist/findings.js +645 -0
- package/dist/findings.js.map +1 -0
- package/dist/follow-up-cli.d.ts +88 -0
- package/dist/follow-up-cli.d.ts.map +1 -0
- package/dist/follow-up-cli.js +208 -0
- package/dist/follow-up-cli.js.map +1 -0
- package/dist/harness.d.ts +64 -0
- package/dist/harness.d.ts.map +1 -0
- package/dist/harness.js +71 -0
- package/dist/harness.js.map +1 -0
- package/dist/help/command-help.d.ts +9 -0
- package/dist/help/command-help.d.ts.map +1 -0
- package/dist/help/command-help.js +21 -0
- package/dist/help/command-help.js.map +1 -0
- package/dist/help/commands/answer.d.ts +3 -0
- package/dist/help/commands/answer.d.ts.map +1 -0
- package/dist/help/commands/answer.js +39 -0
- package/dist/help/commands/answer.js.map +1 -0
- package/dist/help/commands/config.d.ts +3 -0
- package/dist/help/commands/config.d.ts.map +1 -0
- package/dist/help/commands/config.js +25 -0
- package/dist/help/commands/config.js.map +1 -0
- package/dist/help/commands/context.d.ts +3 -0
- package/dist/help/commands/context.d.ts.map +1 -0
- package/dist/help/commands/context.js +44 -0
- package/dist/help/commands/context.js.map +1 -0
- package/dist/help/commands/corrections.d.ts +3 -0
- package/dist/help/commands/corrections.d.ts.map +1 -0
- package/dist/help/commands/corrections.js +30 -0
- package/dist/help/commands/corrections.js.map +1 -0
- package/dist/help/commands/doctor.d.ts +3 -0
- package/dist/help/commands/doctor.d.ts.map +1 -0
- package/dist/help/commands/doctor.js +12 -0
- package/dist/help/commands/doctor.js.map +1 -0
- package/dist/help/commands/index.d.ts +4 -0
- package/dist/help/commands/index.d.ts.map +1 -0
- package/dist/help/commands/index.js +27 -0
- package/dist/help/commands/index.js.map +1 -0
- package/dist/help/commands/memory.d.ts +3 -0
- package/dist/help/commands/memory.d.ts.map +1 -0
- package/dist/help/commands/memory.js +33 -0
- package/dist/help/commands/memory.js.map +1 -0
- package/dist/help/commands/models.d.ts +3 -0
- package/dist/help/commands/models.d.ts.map +1 -0
- package/dist/help/commands/models.js +17 -0
- package/dist/help/commands/models.js.map +1 -0
- package/dist/help/commands/options.d.ts +4 -0
- package/dist/help/commands/options.d.ts.map +1 -0
- package/dist/help/commands/options.js +13 -0
- package/dist/help/commands/options.js.map +1 -0
- package/dist/help/commands/review.d.ts +3 -0
- package/dist/help/commands/review.d.ts.map +1 -0
- package/dist/help/commands/review.js +50 -0
- package/dist/help/commands/review.js.map +1 -0
- package/dist/help/commands/sessions.d.ts +3 -0
- package/dist/help/commands/sessions.d.ts.map +1 -0
- package/dist/help/commands/sessions.js +23 -0
- package/dist/help/commands/sessions.js.map +1 -0
- package/dist/help/commands/show.d.ts +3 -0
- package/dist/help/commands/show.d.ts.map +1 -0
- package/dist/help/commands/show.js +18 -0
- package/dist/help/commands/show.js.map +1 -0
- package/dist/help/help.d.ts +16 -0
- package/dist/help/help.d.ts.map +1 -0
- package/dist/help/help.js +68 -0
- package/dist/help/help.js.map +1 -0
- package/dist/help/index.d.ts +4 -0
- package/dist/help/index.d.ts.map +1 -0
- package/dist/help/index.js +7 -0
- package/dist/help/index.js.map +1 -0
- package/dist/index.d.ts +80 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +51 -0
- package/dist/index.js.map +1 -0
- package/dist/knowledge/block.d.ts +65 -0
- package/dist/knowledge/block.d.ts.map +1 -0
- package/dist/knowledge/block.js +89 -0
- package/dist/knowledge/block.js.map +1 -0
- package/dist/knowledge/claim.d.ts +143 -0
- package/dist/knowledge/claim.d.ts.map +1 -0
- package/dist/knowledge/claim.js +297 -0
- package/dist/knowledge/claim.js.map +1 -0
- package/dist/knowledge/index.d.ts +32 -0
- package/dist/knowledge/index.d.ts.map +1 -0
- package/dist/knowledge/index.js +29 -0
- package/dist/knowledge/index.js.map +1 -0
- package/dist/knowledge/novelty.d.ts +65 -0
- package/dist/knowledge/novelty.d.ts.map +1 -0
- package/dist/knowledge/novelty.js +94 -0
- package/dist/knowledge/novelty.js.map +1 -0
- package/dist/knowledge/recall.d.ts +134 -0
- package/dist/knowledge/recall.d.ts.map +1 -0
- package/dist/knowledge/recall.js +229 -0
- package/dist/knowledge/recall.js.map +1 -0
- package/dist/knowledge/recalled-claim.d.ts +35 -0
- package/dist/knowledge/recalled-claim.d.ts.map +1 -0
- package/dist/knowledge/recalled-claim.js +67 -0
- package/dist/knowledge/recalled-claim.js.map +1 -0
- package/dist/knowledge/recalled.d.ts +70 -0
- package/dist/knowledge/recalled.d.ts.map +1 -0
- package/dist/knowledge/recalled.js +149 -0
- package/dist/knowledge/recalled.js.map +1 -0
- package/dist/knowledge/schema.d.ts +83 -0
- package/dist/knowledge/schema.d.ts.map +1 -0
- package/dist/knowledge/schema.js +96 -0
- package/dist/knowledge/schema.js.map +1 -0
- package/dist/knowledge/staleness.d.ts +48 -0
- package/dist/knowledge/staleness.d.ts.map +1 -0
- package/dist/knowledge/staleness.js +85 -0
- package/dist/knowledge/staleness.js.map +1 -0
- package/dist/knowledge/store.d.ts +100 -0
- package/dist/knowledge/store.d.ts.map +1 -0
- package/dist/knowledge/store.js +184 -0
- package/dist/knowledge/store.js.map +1 -0
- package/dist/memory/compose-file.d.ts +14 -0
- package/dist/memory/compose-file.d.ts.map +1 -0
- package/dist/memory/compose-file.js +25 -0
- package/dist/memory/compose-file.js.map +1 -0
- package/dist/memory/index.d.ts +43 -0
- package/dist/memory/index.d.ts.map +1 -0
- package/dist/memory/index.js +119 -0
- package/dist/memory/index.js.map +1 -0
- package/dist/memory/oss.d.ts +62 -0
- package/dist/memory/oss.d.ts.map +1 -0
- package/dist/memory/oss.js +230 -0
- package/dist/memory/oss.js.map +1 -0
- package/dist/memory/platform.d.ts +37 -0
- package/dist/memory/platform.d.ts.map +1 -0
- package/dist/memory/platform.js +131 -0
- package/dist/memory/platform.js.map +1 -0
- package/dist/memory/scope.d.ts +49 -0
- package/dist/memory/scope.d.ts.map +1 -0
- package/dist/memory/scope.js +70 -0
- package/dist/memory/scope.js.map +1 -0
- package/dist/memory/types.d.ts +113 -0
- package/dist/memory/types.d.ts.map +1 -0
- package/dist/memory/types.js +18 -0
- package/dist/memory/types.js.map +1 -0
- package/dist/memory-cli.d.ts +17 -0
- package/dist/memory-cli.d.ts.map +1 -0
- package/dist/memory-cli.js +107 -0
- package/dist/memory-cli.js.map +1 -0
- package/dist/models-cli.d.ts +12 -0
- package/dist/models-cli.d.ts.map +1 -0
- package/dist/models-cli.js +54 -0
- package/dist/models-cli.js.map +1 -0
- package/dist/models.d.ts +111 -0
- package/dist/models.d.ts.map +1 -0
- package/dist/models.js +227 -0
- package/dist/models.js.map +1 -0
- package/dist/paths.d.ts +35 -0
- package/dist/paths.d.ts.map +1 -0
- package/dist/paths.js +65 -0
- package/dist/paths.js.map +1 -0
- package/dist/profile.d.ts +28 -0
- package/dist/profile.d.ts.map +1 -0
- package/dist/profile.js +154 -0
- package/dist/profile.js.map +1 -0
- package/dist/progress.d.ts +70 -0
- package/dist/progress.d.ts.map +1 -0
- package/dist/progress.js +132 -0
- package/dist/progress.js.map +1 -0
- package/dist/quiet.d.ts +2 -0
- package/dist/quiet.d.ts.map +1 -0
- package/dist/quiet.js +21 -0
- package/dist/quiet.js.map +1 -0
- package/dist/reconcile/continuation.d.ts +132 -0
- package/dist/reconcile/continuation.d.ts.map +1 -0
- package/dist/reconcile/continuation.js +306 -0
- package/dist/reconcile/continuation.js.map +1 -0
- package/dist/reconcile/index.d.ts +26 -0
- package/dist/reconcile/index.d.ts.map +1 -0
- package/dist/reconcile/index.js +28 -0
- package/dist/reconcile/index.js.map +1 -0
- package/dist/reconcile/outcome-set.d.ts +53 -0
- package/dist/reconcile/outcome-set.d.ts.map +1 -0
- package/dist/reconcile/outcome-set.js +124 -0
- package/dist/reconcile/outcome-set.js.map +1 -0
- package/dist/reconcile/outcome.d.ts +56 -0
- package/dist/reconcile/outcome.d.ts.map +1 -0
- package/dist/reconcile/outcome.js +60 -0
- package/dist/reconcile/outcome.js.map +1 -0
- package/dist/reconcile/reconciliation.d.ts +49 -0
- package/dist/reconcile/reconciliation.d.ts.map +1 -0
- package/dist/reconcile/reconciliation.js +88 -0
- package/dist/reconcile/reconciliation.js.map +1 -0
- package/dist/reconcile/schema.d.ts +157 -0
- package/dist/reconcile/schema.d.ts.map +1 -0
- package/dist/reconcile/schema.js +97 -0
- package/dist/reconcile/schema.js.map +1 -0
- package/dist/record/index.d.ts +23 -0
- package/dist/record/index.d.ts.map +1 -0
- package/dist/record/index.js +25 -0
- package/dist/record/index.js.map +1 -0
- package/dist/record/review-record.d.ts +28 -0
- package/dist/record/review-record.d.ts.map +1 -0
- package/dist/record/review-record.js +78 -0
- package/dist/record/review-record.js.map +1 -0
- package/dist/record/schema.d.ts +153 -0
- package/dist/record/schema.d.ts.map +1 -0
- package/dist/record/schema.js +87 -0
- package/dist/record/schema.js.map +1 -0
- package/dist/record/store.d.ts +83 -0
- package/dist/record/store.d.ts.map +1 -0
- package/dist/record/store.js +162 -0
- package/dist/record/store.js.map +1 -0
- package/dist/record/stored-review.d.ts +36 -0
- package/dist/record/stored-review.d.ts.map +1 -0
- package/dist/record/stored-review.js +90 -0
- package/dist/record/stored-review.js.map +1 -0
- package/dist/refute.d.ts +318 -0
- package/dist/refute.d.ts.map +1 -0
- package/dist/refute.js +513 -0
- package/dist/refute.js.map +1 -0
- package/dist/render.d.ts +212 -0
- package/dist/render.d.ts.map +1 -0
- package/dist/render.js +544 -0
- package/dist/render.js.map +1 -0
- package/dist/review-cli.d.ts +181 -0
- package/dist/review-cli.d.ts.map +1 -0
- package/dist/review-cli.js +598 -0
- package/dist/review-cli.js.map +1 -0
- package/dist/reviewer.d.ts +297 -0
- package/dist/reviewer.d.ts.map +1 -0
- package/dist/reviewer.js +580 -0
- package/dist/reviewer.js.map +1 -0
- package/dist/session-cli.d.ts +17 -0
- package/dist/session-cli.d.ts.map +1 -0
- package/dist/session-cli.js +62 -0
- package/dist/session-cli.js.map +1 -0
- package/dist/session.d.ts +36 -0
- package/dist/session.d.ts.map +1 -0
- package/dist/session.js +105 -0
- package/dist/session.js.map +1 -0
- package/dist/settings.d.ts +68 -0
- package/dist/settings.d.ts.map +1 -0
- package/dist/settings.js +175 -0
- package/dist/settings.js.map +1 -0
- package/dist/show-cli.d.ts +39 -0
- package/dist/show-cli.d.ts.map +1 -0
- package/dist/show-cli.js +56 -0
- package/dist/show-cli.js.map +1 -0
- package/dist/stdout.d.ts +28 -0
- package/dist/stdout.d.ts.map +1 -0
- package/dist/stdout.js +44 -0
- package/dist/stdout.js.map +1 -0
- package/dist/target.d.ts +58 -0
- package/dist/target.d.ts.map +1 -0
- package/dist/target.js +96 -0
- package/dist/target.js.map +1 -0
- package/dist/tools/index.d.ts +93 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +146 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/root.d.ts +62 -0
- package/dist/tools/root.d.ts.map +1 -0
- package/dist/tools/root.js +51 -0
- package/dist/tools/root.js.map +1 -0
- package/dist/usage.d.ts +75 -0
- package/dist/usage.d.ts.map +1 -0
- package/dist/usage.js +100 -0
- package/dist/usage.js.map +1 -0
- package/dist/version.d.ts +14 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +26 -0
- package/dist/version.js.map +1 -0
- package/dist/workspace.d.ts +48 -0
- package/dist/workspace.d.ts.map +1 -0
- package/dist/workspace.js +126 -0
- package/dist/workspace.js.map +1 -0
- package/docker-compose.yml +61 -0
- package/package.json +70 -4
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
// This Source Code Form is subject to the terms of the Mozilla Public
|
|
2
|
+
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
3
|
+
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
4
|
+
import { z } from 'zod';
|
|
5
|
+
import { evidenceSchema, reviewOutputSchema } from '../findings.js';
|
|
6
|
+
/**
|
|
7
|
+
* What a reconciliation says, as a stored review carries it.
|
|
8
|
+
*
|
|
9
|
+
* Its own file because it is a wire format two modules have to agree on: the
|
|
10
|
+
* reconciler produces it and the record stores it, and a shape declared inside
|
|
11
|
+
* whichever one happened to write it first changes without the other noticing.
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* What became of a finding between two reviews.
|
|
15
|
+
*
|
|
16
|
+
* Four, and the fourth is the one that matters. `fixed` is a claim about the
|
|
17
|
+
* code — the problem is gone — and there are runs in no position to make it: one
|
|
18
|
+
* that never opened the file, or one that stopped before it had finished
|
|
19
|
+
* looking. Those produce `unverified` rather than a fix nobody checked.
|
|
20
|
+
*
|
|
21
|
+
* `superseded` is not a softer `fixed`. It means the code the finding pointed
|
|
22
|
+
* at changed and this run reports the same kind of problem in the same file: the
|
|
23
|
+
* claim stands, under a new fingerprint, because the old one named code that is
|
|
24
|
+
* no longer there.
|
|
25
|
+
*/
|
|
26
|
+
export const RECONCILED = ['open', 'superseded', 'fixed', 'unverified'];
|
|
27
|
+
export const outcomeSchema = z.object({
|
|
28
|
+
/** The prior finding's fingerprint — its name across runs. */
|
|
29
|
+
id: z.string().min(1),
|
|
30
|
+
status: z.enum(RECONCILED),
|
|
31
|
+
/** One line a human can check the status against. */
|
|
32
|
+
reason: z.string(),
|
|
33
|
+
path: z.string(),
|
|
34
|
+
line: z.number().int().positive(),
|
|
35
|
+
title: z.string(),
|
|
36
|
+
/** What this run reported in its place, when the claim moved. */
|
|
37
|
+
restatedAs: z.string().optional(),
|
|
38
|
+
/**
|
|
39
|
+
* The code the ruling rests on, when it rests on any.
|
|
40
|
+
*
|
|
41
|
+
* A fix nobody can point at is a finding deleted on the model's word, so
|
|
42
|
+
* `fixed` is only accepted with something here — see `OutcomeSet.match`.
|
|
43
|
+
*/
|
|
44
|
+
evidence: z.array(evidenceSchema).optional(),
|
|
45
|
+
});
|
|
46
|
+
export const reconciledSchema = z.object({
|
|
47
|
+
/** The id of the review this one was compared against. */
|
|
48
|
+
against: z.string().min(1),
|
|
49
|
+
/** When that review was, ISO 8601. */
|
|
50
|
+
at: z.string().min(1),
|
|
51
|
+
/**
|
|
52
|
+
* The commit that review was at, when this run was shown only what changed
|
|
53
|
+
* after it. Absent when it was shown the whole branch.
|
|
54
|
+
*
|
|
55
|
+
* Optional rather than a new record version: older records simply lack it,
|
|
56
|
+
* and lacking it means what it always meant — the whole branch was read.
|
|
57
|
+
*/
|
|
58
|
+
since: z.string().min(1).optional(),
|
|
59
|
+
outcomes: z.array(outcomeSchema),
|
|
60
|
+
/** Fingerprints reported for the first time this run. */
|
|
61
|
+
new: z.array(z.string()),
|
|
62
|
+
});
|
|
63
|
+
/**
|
|
64
|
+
* A ruling on one finding the review was handed.
|
|
65
|
+
*
|
|
66
|
+
* `reportedOutcomeSchema` is to `Outcome` what `reportedFindingSchema` is to
|
|
67
|
+
* `Finding`: what the model is allowed to say, before anything has been checked
|
|
68
|
+
* about it. The fingerprint is how an answer is matched to the finding it is
|
|
69
|
+
* about, and it is the one string the model has to reproduce exactly.
|
|
70
|
+
*/
|
|
71
|
+
export const reportedOutcomeSchema = z.object({
|
|
72
|
+
fingerprint: z.string().min(1).describe('The id printed above the finding you are ruling on — copy it exactly'),
|
|
73
|
+
status: z
|
|
74
|
+
.enum(RECONCILED)
|
|
75
|
+
.describe('open: still there as described. superseded: still there, but the code moved — also report it as a new finding. fixed: this change removed it. unverified: you could not tell.'),
|
|
76
|
+
reason: z
|
|
77
|
+
.string()
|
|
78
|
+
.min(1)
|
|
79
|
+
.describe('One line a human can check: name the code that settles it, not your conclusion about it'),
|
|
80
|
+
evidence: z
|
|
81
|
+
.array(evidenceSchema)
|
|
82
|
+
.describe('The lines that justify this ruling — what fixed it, or what shows it standing. Required to call it fixed.'),
|
|
83
|
+
});
|
|
84
|
+
/**
|
|
85
|
+
* What a continuation review returns: the review, plus a ruling on each finding
|
|
86
|
+
* it was handed.
|
|
87
|
+
*
|
|
88
|
+
* One schema rather than a second call. The model is reading the whole change
|
|
89
|
+
* either way, and asking afterwards whether the last review's findings are
|
|
90
|
+
* still there would pay a second time for the same reading.
|
|
91
|
+
*/
|
|
92
|
+
export const continuationOutputSchema = reviewOutputSchema.extend({
|
|
93
|
+
outcomes: z
|
|
94
|
+
.array(reportedOutcomeSchema)
|
|
95
|
+
.describe('One entry per finding you were handed, keyed by its fingerprint.'),
|
|
96
|
+
});
|
|
97
|
+
//# sourceMappingURL=schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../src/reconcile/schema.ts"],"names":[],"mappings":"AAAA,sEAAsE;AACtE,sEAAsE;AACtE,4DAA4D;AAE5D,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAEpE;;;;;;GAMG;AAEH;;;;;;;;;;;;GAYG;AACH,M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AM,CAAC,MAAM,qBAAqB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC5C,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,sEAAsE,CAAC;IAC/G,MAAM,EAAE,CAAC;SACN,IAAI,CAAC,UAAU,CAAC;SAChB,QAAQ,CACP,+KAA+K,CAChL;IACH,MAAM,EAAE,CAAC;SACN,MAAM,EAAE;SACR,GAAG,CAAC,CAAC,CAAC;SACN,QAAQ,CAAC,yFAAyF,CAAC;IACtG,QAAQ,EAAE,CAAC;SACR,KAAK,CAAC,cAAc,CAAC;SACrB,QAAQ,CAAC,2GAA2G,CAAC;CACzH,CAAC,CAAC;AAEH;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,kBAAkB,CAAC,MAAM,CAAC;IAChE,QAAQ,EAAE,CAAC;SACR,KAAK,CAAC,qBAAqB,CAAC;SAC5B,QAAQ,CAAC,kEAAkE,CAAC;CAChF,CAAC,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A review, after the run that produced it has ended.
|
|
3
|
+
*
|
|
4
|
+
* Everything in P2 treated a review as something that happened and was then
|
|
5
|
+
* printed. Three things need one that outlives its process: reconciliation has
|
|
6
|
+
* to compare this run against the last one, a correction has to name a finding
|
|
7
|
+
* from a review someone has already read, and a standalone refute has to rule
|
|
8
|
+
* on findings nobody is re-deriving. So a review is written down, and this is
|
|
9
|
+
* the only part of Weigh that knows where and in what shape.
|
|
10
|
+
*
|
|
11
|
+
* The stored shape *is* the `--json` shape, with an id and a timestamp. Two
|
|
12
|
+
* serialisations of one review would drift, and the drift would be invisible
|
|
13
|
+
* until something read the wrong one.
|
|
14
|
+
*
|
|
15
|
+
* One class each: `ReviewRecord` writes, `StoredReview` reads, `ReviewStore`
|
|
16
|
+
* decides where — and `schema.ts` is what the three of them agree on.
|
|
17
|
+
*/
|
|
18
|
+
export { RECORD_VERSION, reviewRecordSchema } from './schema.js';
|
|
19
|
+
export type { ReviewRecordJson } from './schema.js';
|
|
20
|
+
export { ReviewRecord } from './review-record.js';
|
|
21
|
+
export { StoredReview } from './stored-review.js';
|
|
22
|
+
export { ReviewStore } from './store.js';
|
|
23
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/record/index.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;GAgBG;AACH,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACjE,YAAY,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// This Source Code Form is subject to the terms of the Mozilla Public
|
|
2
|
+
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
3
|
+
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
4
|
+
/**
|
|
5
|
+
* A review, after the run that produced it has ended.
|
|
6
|
+
*
|
|
7
|
+
* Everything in P2 treated a review as something that happened and was then
|
|
8
|
+
* printed. Three things need one that outlives its process: reconciliation has
|
|
9
|
+
* to compare this run against the last one, a correction has to name a finding
|
|
10
|
+
* from a review someone has already read, and a standalone refute has to rule
|
|
11
|
+
* on findings nobody is re-deriving. So a review is written down, and this is
|
|
12
|
+
* the only part of Weigh that knows where and in what shape.
|
|
13
|
+
*
|
|
14
|
+
* The stored shape *is* the `--json` shape, with an id and a timestamp. Two
|
|
15
|
+
* serialisations of one review would drift, and the drift would be invisible
|
|
16
|
+
* until something read the wrong one.
|
|
17
|
+
*
|
|
18
|
+
* One class each: `ReviewRecord` writes, `StoredReview` reads, `ReviewStore`
|
|
19
|
+
* decides where — and `schema.ts` is what the three of them agree on.
|
|
20
|
+
*/
|
|
21
|
+
export { RECORD_VERSION, reviewRecordSchema } from './schema.js';
|
|
22
|
+
export { ReviewRecord } from './review-record.js';
|
|
23
|
+
export { StoredReview } from './stored-review.js';
|
|
24
|
+
export { ReviewStore } from './store.js';
|
|
25
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/record/index.ts"],"names":[],"mappings":"AAAA,sEAAsE;AACtE,sEAAsE;AACtE,4DAA4D;AAE5D;;;;;;;;;;;;;;;;GAgBG;AACH,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEjE,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { ReviewContext } from '../context.js';
|
|
2
|
+
import type { ReviewResult } from '../reviewer.js';
|
|
3
|
+
import { type ReviewRecordJson } from './schema.js';
|
|
4
|
+
/** One review, on its way to disk or to `--json`. */
|
|
5
|
+
export declare class ReviewRecord {
|
|
6
|
+
readonly id: string;
|
|
7
|
+
private readonly _context;
|
|
8
|
+
private readonly _result;
|
|
9
|
+
private readonly _at;
|
|
10
|
+
constructor(id: string, _context: ReviewContext, _result: ReviewResult, _at?: Date);
|
|
11
|
+
/**
|
|
12
|
+
* A review's name, minted before the run starts.
|
|
13
|
+
*
|
|
14
|
+
* Timestamped like a session transcript, so a directory of them sorts
|
|
15
|
+
* chronologically — but minted here rather than read off a session file. The
|
|
16
|
+
* identity has to exist whether or not anything is written: `--no-session`
|
|
17
|
+
* suppresses the record, and a run that kept nothing still has a name while
|
|
18
|
+
* it is running.
|
|
19
|
+
*
|
|
20
|
+
* The suffix is there because the timestamp alone is not an identity. Two
|
|
21
|
+
* terminals reviewing one branch can start in the same millisecond, and the
|
|
22
|
+
* second record would land on the first — which is the one the next
|
|
23
|
+
* reconciliation reads.
|
|
24
|
+
*/
|
|
25
|
+
static newId(now?: Date): string;
|
|
26
|
+
toJSON(): ReviewRecordJson;
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=review-record.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"review-record.d.ts","sourceRoot":"","sources":["../../src/record/review-record.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,EAAkB,KAAK,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAEpE,qDAAqD;AACrD,qBAAa,YAAY;IAErB,QAAQ,CAAC,EAAE,EAAE,MAAM;IACnB,OAAO,CAAC,QAAQ,CAAC,QAAQ;IACzB,OAAO,CAAC,QAAQ,CAAC,OAAO;IACxB,OAAO,CAAC,QAAQ,CAAC,GAAG;IAJtB,YACW,EAAE,EAAE,MAAM,EACF,QAAQ,EAAE,aAAa,EACvB,OAAO,EAAE,YAAY,EACrB,GAAG,GAAE,IAAiB,EACrC;IAEJ;;;;;;;;;;;;;OAaG;IACH,MAAM,CAAC,KAAK,CAAC,GAAG,GAAE,IAAiB,GAAG,MAAM,CAE3C;IAED,MAAM,IAAI,gBAAgB,CAyCzB;CACF"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
// This Source Code Form is subject to the terms of the Mozilla Public
|
|
2
|
+
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
3
|
+
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
4
|
+
import { randomBytes } from 'crypto';
|
|
5
|
+
import { RECORD_VERSION } from './schema.js';
|
|
6
|
+
/** One review, on its way to disk or to `--json`. */
|
|
7
|
+
export class ReviewRecord {
|
|
8
|
+
id;
|
|
9
|
+
_context;
|
|
10
|
+
_result;
|
|
11
|
+
_at;
|
|
12
|
+
constructor(id, _context, _result, _at = new Date()) {
|
|
13
|
+
this.id = id;
|
|
14
|
+
this._context = _context;
|
|
15
|
+
this._result = _result;
|
|
16
|
+
this._at = _at;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* A review's name, minted before the run starts.
|
|
20
|
+
*
|
|
21
|
+
* Timestamped like a session transcript, so a directory of them sorts
|
|
22
|
+
* chronologically — but minted here rather than read off a session file. The
|
|
23
|
+
* identity has to exist whether or not anything is written: `--no-session`
|
|
24
|
+
* suppresses the record, and a run that kept nothing still has a name while
|
|
25
|
+
* it is running.
|
|
26
|
+
*
|
|
27
|
+
* The suffix is there because the timestamp alone is not an identity. Two
|
|
28
|
+
* terminals reviewing one branch can start in the same millisecond, and the
|
|
29
|
+
* second record would land on the first — which is the one the next
|
|
30
|
+
* reconciliation reads.
|
|
31
|
+
*/
|
|
32
|
+
static newId(now = new Date()) {
|
|
33
|
+
return `${now.toISOString().replace(/[:.]/g, '-')}-${randomBytes(2).toString('hex')}`;
|
|
34
|
+
}
|
|
35
|
+
toJSON() {
|
|
36
|
+
const result = this._result;
|
|
37
|
+
return {
|
|
38
|
+
version: RECORD_VERSION,
|
|
39
|
+
id: this.id,
|
|
40
|
+
at: this._at.toISOString(),
|
|
41
|
+
repo: this._context.repo,
|
|
42
|
+
verdict: result.verdict.toJSON(),
|
|
43
|
+
// Top level, beside the verdict rather than inside `run`: whether the
|
|
44
|
+
// review finished is the first thing a consumer has to know about it.
|
|
45
|
+
...(result.stopped && { stopped: result.stopped }),
|
|
46
|
+
summary: result.summary,
|
|
47
|
+
// Ranked, which is also how the terminal numbers them — so `#3` in a
|
|
48
|
+
// report someone is reading is `findings[2]` here. Resolving a
|
|
49
|
+
// correction against a different order would attach it to the wrong
|
|
50
|
+
// finding, which is the one mistake a correction must not make.
|
|
51
|
+
findings: result.findings.toJSON(),
|
|
52
|
+
// Whenever something was taken out, by either hand. `refuted` is separate
|
|
53
|
+
// and stays absent unless a pass ran: an always-present empty block would
|
|
54
|
+
// say a second pass looked and found nothing, which is a different claim
|
|
55
|
+
// from nobody having looked.
|
|
56
|
+
...(result.findings.suppressed.length > 0 && {
|
|
57
|
+
suppressed: result.findings.suppressed.map((s) => s.toJSON()),
|
|
58
|
+
}),
|
|
59
|
+
...(result.refuted && { refuted: { ...result.refuted } }),
|
|
60
|
+
...(result.reconciled && { reconciled: result.reconciled.toJSON() }),
|
|
61
|
+
coverage: {
|
|
62
|
+
changed: result.coverage.changedCount,
|
|
63
|
+
opened: result.coverage.opened,
|
|
64
|
+
unopened: result.coverage.unopened,
|
|
65
|
+
ratio: result.coverage.ratio,
|
|
66
|
+
},
|
|
67
|
+
run: {
|
|
68
|
+
model: result.model,
|
|
69
|
+
effort: result.effort,
|
|
70
|
+
channel: result.channel,
|
|
71
|
+
nudges: result.nudges,
|
|
72
|
+
durationMs: result.durationMs,
|
|
73
|
+
usage: result.usage,
|
|
74
|
+
},
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
//# sourceMappingURL=review-record.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"review-record.js","sourceRoot":"","sources":["../../src/record/review-record.ts"],"names":[],"mappings":"AAAA,sEAAsE;AACtE,sEAAsE;AACtE,4DAA4D;AAE5D,OAAO,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AAGrC,OAAO,EAAE,cAAc,EAAyB,MAAM,aAAa,CAAC;AAEpE,qDAAqD;AACrD,MAAM,OAAO,YAAY;IAEZ,EAAE;IACM,QAAQ;IACR,OAAO;IACP,GAAG;IAJtB,YACW,EAAU,EACF,QAAuB,EACvB,OAAqB,EACrB,GAAG,GAAS,IAAI,IAAI,EAAE;kBAH9B,EAAE;wBACM,QAAQ;uBACR,OAAO;mBACP,GAAG;IACnB,CAA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,CAAC,UAAU,IAAI,EAAE,UAAU,EAAE,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,EAAE,CAAC;YACpE,QAAQ,EAAE;gBACR,OAAO,EAAE,MAAM,CAAC,QAAQ,CAAC,YAAY;gBACrC,MAAM,EAAE,MAAM,CAAC,QAAQ,CAAC,MAAM;gBAC9B,QAAQ,EAAE,MAAM,CAAC,QAAQ,CAAC,QAAQ;gBAClC,KAAK,EAAE,MAAM,CAAC,QAAQ,CAAC,KAAK;aAC7B;YACD,GAAG,EAAE;gBACH,KAAK,EAAE,MAAM,CAAC,KAAK;gBACnB,MAAM,EAAE,MAAM,CAAC,MAAM;gBACrB,OAAO,EAAE,MAAM,CAAC,OAAO;gBACvB,MAAM,EAAE,MAAM,CAAC,MAAM;gBACrB,UAAU,EAAE,MAAM,CAAC,UAAU;gBAC7B,KAAK,EAAE,MAAM,CAAC,KAAK;aACpB;SACF,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/**
|
|
3
|
+
* The shape a stored review has on disk.
|
|
4
|
+
*
|
|
5
|
+
* Declared rather than implied by whatever wrote it, because this is a wire
|
|
6
|
+
* format: a later build reads it, a human can edit it, and a shape that exists
|
|
7
|
+
* only inside the method that produced it changes without anyone noticing.
|
|
8
|
+
*/
|
|
9
|
+
/** The record's version, so a loader refuses one it cannot read rather than guessing. */
|
|
10
|
+
export declare const RECORD_VERSION = 1;
|
|
11
|
+
/**
|
|
12
|
+
* What a stored review has to contain to be one.
|
|
13
|
+
*
|
|
14
|
+
* Validated on the way in. The blocks nothing here rebuilds — the verdict, the
|
|
15
|
+
* run accounting, what a refute pass did — are checked for being objects and
|
|
16
|
+
* otherwise passed through: see `StoredReview.toJSON`.
|
|
17
|
+
*/
|
|
18
|
+
export declare const reviewRecordSchema: z.ZodObject<{
|
|
19
|
+
version: z.ZodLiteral<1>;
|
|
20
|
+
id: z.ZodString;
|
|
21
|
+
at: z.ZodString;
|
|
22
|
+
repo: z.ZodObject<{
|
|
23
|
+
root: z.ZodString;
|
|
24
|
+
target: z.ZodString;
|
|
25
|
+
branch: z.ZodNullable<z.ZodString>;
|
|
26
|
+
base: z.ZodString;
|
|
27
|
+
baseSha: z.ZodString;
|
|
28
|
+
headSha: z.ZodNullable<z.ZodString>;
|
|
29
|
+
mergeBase: z.ZodString;
|
|
30
|
+
uncommitted: z.ZodBoolean;
|
|
31
|
+
}, z.core.$strip>;
|
|
32
|
+
summary: z.ZodString;
|
|
33
|
+
verdict: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
34
|
+
stopped: z.ZodOptional<z.ZodObject<{
|
|
35
|
+
reason: z.ZodEnum<{
|
|
36
|
+
cost: "cost";
|
|
37
|
+
error: "error";
|
|
38
|
+
steps: "steps";
|
|
39
|
+
}>;
|
|
40
|
+
detail: z.ZodString;
|
|
41
|
+
}, z.core.$strip>>;
|
|
42
|
+
findings: z.ZodArray<z.ZodObject<{
|
|
43
|
+
severity: z.ZodEnum<{
|
|
44
|
+
critical: "critical";
|
|
45
|
+
high: "high";
|
|
46
|
+
low: "low";
|
|
47
|
+
medium: "medium";
|
|
48
|
+
nit: "nit";
|
|
49
|
+
}>;
|
|
50
|
+
category: z.ZodEnum<{
|
|
51
|
+
"api-contract": "api-contract";
|
|
52
|
+
concurrency: "concurrency";
|
|
53
|
+
correctness: "correctness";
|
|
54
|
+
"error-handling": "error-handling";
|
|
55
|
+
maintainability: "maintainability";
|
|
56
|
+
performance: "performance";
|
|
57
|
+
security: "security";
|
|
58
|
+
style: "style";
|
|
59
|
+
testing: "testing";
|
|
60
|
+
}>;
|
|
61
|
+
title: z.ZodString;
|
|
62
|
+
body: z.ZodString;
|
|
63
|
+
path: z.ZodString;
|
|
64
|
+
line: z.ZodNumber;
|
|
65
|
+
evidence: z.ZodArray<z.ZodObject<{
|
|
66
|
+
path: z.ZodString;
|
|
67
|
+
line: z.ZodNumber;
|
|
68
|
+
snippet: z.ZodString;
|
|
69
|
+
}, z.core.$strip>>;
|
|
70
|
+
confidence: z.ZodNumber;
|
|
71
|
+
suggestion: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
72
|
+
id: z.ZodString;
|
|
73
|
+
anchor: z.ZodString;
|
|
74
|
+
}, z.core.$strip>>;
|
|
75
|
+
suppressed: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
76
|
+
finding: z.ZodObject<{
|
|
77
|
+
severity: z.ZodEnum<{
|
|
78
|
+
critical: "critical";
|
|
79
|
+
high: "high";
|
|
80
|
+
low: "low";
|
|
81
|
+
medium: "medium";
|
|
82
|
+
nit: "nit";
|
|
83
|
+
}>;
|
|
84
|
+
category: z.ZodEnum<{
|
|
85
|
+
"api-contract": "api-contract";
|
|
86
|
+
concurrency: "concurrency";
|
|
87
|
+
correctness: "correctness";
|
|
88
|
+
"error-handling": "error-handling";
|
|
89
|
+
maintainability: "maintainability";
|
|
90
|
+
performance: "performance";
|
|
91
|
+
security: "security";
|
|
92
|
+
style: "style";
|
|
93
|
+
testing: "testing";
|
|
94
|
+
}>;
|
|
95
|
+
title: z.ZodString;
|
|
96
|
+
body: z.ZodString;
|
|
97
|
+
path: z.ZodString;
|
|
98
|
+
line: z.ZodNumber;
|
|
99
|
+
evidence: z.ZodArray<z.ZodObject<{
|
|
100
|
+
path: z.ZodString;
|
|
101
|
+
line: z.ZodNumber;
|
|
102
|
+
snippet: z.ZodString;
|
|
103
|
+
}, z.core.$strip>>;
|
|
104
|
+
confidence: z.ZodNumber;
|
|
105
|
+
suggestion: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
106
|
+
id: z.ZodString;
|
|
107
|
+
anchor: z.ZodString;
|
|
108
|
+
}, z.core.$strip>;
|
|
109
|
+
ground: z.ZodEnum<{
|
|
110
|
+
answered: "answered";
|
|
111
|
+
code: "code";
|
|
112
|
+
confidence: "confidence";
|
|
113
|
+
convention: "convention";
|
|
114
|
+
corrected: "corrected";
|
|
115
|
+
}>;
|
|
116
|
+
reason: z.ZodNullable<z.ZodString>;
|
|
117
|
+
}, z.core.$strip>>>;
|
|
118
|
+
coverage: z.ZodObject<{
|
|
119
|
+
changed: z.ZodNumber;
|
|
120
|
+
opened: z.ZodArray<z.ZodString>;
|
|
121
|
+
unopened: z.ZodArray<z.ZodString>;
|
|
122
|
+
ratio: z.ZodNumber;
|
|
123
|
+
}, z.core.$strip>;
|
|
124
|
+
run: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
125
|
+
refuted: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
126
|
+
reconciled: z.ZodOptional<z.ZodObject<{
|
|
127
|
+
against: z.ZodString;
|
|
128
|
+
at: z.ZodString;
|
|
129
|
+
since: z.ZodOptional<z.ZodString>;
|
|
130
|
+
outcomes: z.ZodArray<z.ZodObject<{
|
|
131
|
+
id: z.ZodString;
|
|
132
|
+
status: z.ZodEnum<{
|
|
133
|
+
fixed: "fixed";
|
|
134
|
+
open: "open";
|
|
135
|
+
superseded: "superseded";
|
|
136
|
+
unverified: "unverified";
|
|
137
|
+
}>;
|
|
138
|
+
reason: z.ZodString;
|
|
139
|
+
path: z.ZodString;
|
|
140
|
+
line: z.ZodNumber;
|
|
141
|
+
title: z.ZodString;
|
|
142
|
+
restatedAs: z.ZodOptional<z.ZodString>;
|
|
143
|
+
evidence: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
144
|
+
path: z.ZodString;
|
|
145
|
+
line: z.ZodNumber;
|
|
146
|
+
snippet: z.ZodString;
|
|
147
|
+
}, z.core.$strip>>>;
|
|
148
|
+
}, z.core.$strip>>;
|
|
149
|
+
new: z.ZodArray<z.ZodString>;
|
|
150
|
+
}, z.core.$strip>>;
|
|
151
|
+
}, z.core.$strip>;
|
|
152
|
+
export type ReviewRecordJson = z.infer<typeof reviewRecordSchema>;
|
|
153
|
+
//# sourceMappingURL=schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/record/schema.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB;;;;;;GAMG;AAEH,yFAAyF;AACzF,eAAO,MAAM,cAAc,IAAI,CAAC;AA8BhC;;;;;;GAMG;AACH,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAsC7B,CAAC;AAEH,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
// This Source Code Form is subject to the terms of the Mozilla Public
|
|
2
|
+
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
3
|
+
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
4
|
+
import { z } from 'zod';
|
|
5
|
+
import { GROUNDS, reportedFindingSchema } from '../findings.js';
|
|
6
|
+
import { reconciledSchema } from '../reconcile/schema.js';
|
|
7
|
+
/**
|
|
8
|
+
* The shape a stored review has on disk.
|
|
9
|
+
*
|
|
10
|
+
* Declared rather than implied by whatever wrote it, because this is a wire
|
|
11
|
+
* format: a later build reads it, a human can edit it, and a shape that exists
|
|
12
|
+
* only inside the method that produced it changes without anyone noticing.
|
|
13
|
+
*/
|
|
14
|
+
/** The record's version, so a loader refuses one it cannot read rather than guessing. */
|
|
15
|
+
export const RECORD_VERSION = 1;
|
|
16
|
+
/**
|
|
17
|
+
* A finding as it is stored: what the model reported, plus the anchor.
|
|
18
|
+
*
|
|
19
|
+
* The anchor is the part that matters on the way back in. `id` travels with it
|
|
20
|
+
* for anyone reading the file by eye, but it is recomputed on load rather than
|
|
21
|
+
* trusted — see `StoredReview.findings`.
|
|
22
|
+
*/
|
|
23
|
+
const storedFindingSchema = reportedFindingSchema.extend({
|
|
24
|
+
id: z.string().min(1),
|
|
25
|
+
anchor: z.string(),
|
|
26
|
+
});
|
|
27
|
+
const storedSuppressionSchema = z.object({
|
|
28
|
+
finding: storedFindingSchema,
|
|
29
|
+
// `answered` was added inside version 1 rather than over a bump. Widening
|
|
30
|
+
// the values a field may hold keeps every record already on disk readable.
|
|
31
|
+
// A bump would orphan all of them, so every branch would lose the baseline
|
|
32
|
+
// its next review stands on — to guard a build that no longer exists. The
|
|
33
|
+
// version is owed when a record gains or loses a field, not a value.
|
|
34
|
+
ground: z.enum([...GROUNDS, 'confidence', 'answered']),
|
|
35
|
+
reason: z.string().nullable(),
|
|
36
|
+
});
|
|
37
|
+
const stoppedSchema = z.object({
|
|
38
|
+
reason: z.enum(['cost', 'steps', 'error']),
|
|
39
|
+
detail: z.string(),
|
|
40
|
+
});
|
|
41
|
+
/**
|
|
42
|
+
* What a stored review has to contain to be one.
|
|
43
|
+
*
|
|
44
|
+
* Validated on the way in. The blocks nothing here rebuilds — the verdict, the
|
|
45
|
+
* run accounting, what a refute pass did — are checked for being objects and
|
|
46
|
+
* otherwise passed through: see `StoredReview.toJSON`.
|
|
47
|
+
*/
|
|
48
|
+
export const reviewRecordSchema = z.object({
|
|
49
|
+
version: z.literal(RECORD_VERSION),
|
|
50
|
+
id: z.string().min(1),
|
|
51
|
+
/**
|
|
52
|
+
* When the record was written, which is the end of the run.
|
|
53
|
+
*
|
|
54
|
+
* The id carries when it started, so the two are minutes apart on a long
|
|
55
|
+
* review rather than redundant — and `run.durationMs` brackets the same
|
|
56
|
+
* span from the other end.
|
|
57
|
+
*/
|
|
58
|
+
at: z.string().min(1),
|
|
59
|
+
repo: z.object({
|
|
60
|
+
/** Where the review was read from — a workspace, often disposable. */
|
|
61
|
+
root: z.string(),
|
|
62
|
+
/** The repository the review is *about*. What a later run is keyed to. */
|
|
63
|
+
target: z.string(),
|
|
64
|
+
branch: z.string().nullable(),
|
|
65
|
+
base: z.string(),
|
|
66
|
+
baseSha: z.string(),
|
|
67
|
+
headSha: z.string().nullable(),
|
|
68
|
+
mergeBase: z.string(),
|
|
69
|
+
uncommitted: z.boolean(),
|
|
70
|
+
}),
|
|
71
|
+
summary: z.string(),
|
|
72
|
+
verdict: z.record(z.string(), z.unknown()),
|
|
73
|
+
stopped: stoppedSchema.optional(),
|
|
74
|
+
findings: z.array(storedFindingSchema),
|
|
75
|
+
suppressed: z.array(storedSuppressionSchema).optional(),
|
|
76
|
+
coverage: z.object({
|
|
77
|
+
changed: z.number(),
|
|
78
|
+
opened: z.array(z.string()),
|
|
79
|
+
unopened: z.array(z.string()),
|
|
80
|
+
ratio: z.number(),
|
|
81
|
+
}),
|
|
82
|
+
run: z.record(z.string(), z.unknown()),
|
|
83
|
+
refuted: z.record(z.string(), z.unknown()).optional(),
|
|
84
|
+
/** This review set against the one before it. Absent when there was none. */
|
|
85
|
+
reconciled: reconciledSchema.optional(),
|
|
86
|
+
});
|
|
87
|
+
//# sourceMappingURL=schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../src/record/schema.ts"],"names":[],"mappings":"AAAA,sEAAsE;AACtE,sEAAsE;AACtE,4DAA4D;AAE5D,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,OAAO,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AAChE,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE1D;;;;;;GAMG;AAEH,yFAAyF;AACzF,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,CAAC;AAEhC;;;;;;GAMG;AACH,MAAM,mBAAmB,GAAG,qBAAqB,CAAC,MAAM,CAAC;IACvD,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IACrB,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE;C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,CAAC,MAAM,EAAE;QACrB,WAAW,EAAE,CAAC,CAAC,OAAO,EAAE;KACzB,CAAC;IACF,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE;IACnB,OAAO,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC;IAC1C,OAAO,EAAE,aAAa,CAAC,QAAQ,EAAE;IACjC,QAAQ,EAAE,CAAC,CAAC,KAAK,CAAC,mBAAmB,CAAC;IACtC,UAAU,EAAE,CAAC,CAAC,KAAK,CAAC,uBAAuB,CAAC,CAAC,QAAQ,EAAE;IACvD,QAAQ,EAAE,CAAC,CAAC,MAAM,CAAC;QACjB,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE;QACnB,MAAM,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;QAC3B,QAAQ,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;QAC7B,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE;KAClB,CAAC;IACF,GAAG,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC;IACtC,OAAO,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,QAAQ,EAAE;IACrD,6EAA6E;IAC7E,UAAU,EAAE,gBAAgB,CAAC,QAAQ,EAAE;CACxC,CAAC,CAAC"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import type { ReviewRecord } from './review-record.js';
|
|
2
|
+
import { StoredReview } from './stored-review.js';
|
|
3
|
+
/**
|
|
4
|
+
* Where reviews are kept, and how one is found again.
|
|
5
|
+
*
|
|
6
|
+
* Under `~/.weigh` and deliberately not under the cache. `paths.repos()` and
|
|
7
|
+
* the workspaces beside it are documented as safe to delete at any time —
|
|
8
|
+
* which is true of a clone and false of the record a correction is keyed to.
|
|
9
|
+
*/
|
|
10
|
+
export declare class ReviewStore {
|
|
11
|
+
private readonly _dir;
|
|
12
|
+
constructor(_dir?: string);
|
|
13
|
+
/** The root of every repository's reviews. */
|
|
14
|
+
get dir(): string;
|
|
15
|
+
/**
|
|
16
|
+
* One directory per repository, named so a human browsing can tell which.
|
|
17
|
+
*
|
|
18
|
+
* The same identity memory scopes a convention under — one rule, in
|
|
19
|
+
* `target.ts`, so a review and a memory about a repository cannot disagree
|
|
20
|
+
* about which repository they mean.
|
|
21
|
+
*/
|
|
22
|
+
static slug(target: string): string;
|
|
23
|
+
dirFor(target: string): string;
|
|
24
|
+
/**
|
|
25
|
+
* Writes a review and returns the path it landed at.
|
|
26
|
+
*
|
|
27
|
+
* Refuses to overwrite. Two ids colliding takes two runs in the same
|
|
28
|
+
* millisecond drawing the same suffix, so this should never fire — and if it
|
|
29
|
+
* does, failing loudly beats writing a record whose name belongs to another
|
|
30
|
+
* review. The caller treats that as a lost record, not a lost review.
|
|
31
|
+
*/
|
|
32
|
+
save(record: ReviewRecord): string;
|
|
33
|
+
/** Ids for one repository, oldest first — the timestamped names sort. */
|
|
34
|
+
ids(target: string): string[];
|
|
35
|
+
/**
|
|
36
|
+
* The most recent review of a repository, or of one branch of it.
|
|
37
|
+
*
|
|
38
|
+
* By id rather than by mtime: the id is when the run started, and that is
|
|
39
|
+
* the order reconciliation means by "the last review". A file touched since
|
|
40
|
+
* is still the review it was.
|
|
41
|
+
*
|
|
42
|
+
* A branch narrows it, because reconciling one branch's findings against
|
|
43
|
+
* another's would report fixes that are only a different change. Narrowed, it
|
|
44
|
+
* reads records newest-first until one matches rather than loading them all.
|
|
45
|
+
*
|
|
46
|
+
* A record this build cannot read — truncated, hand-edited, a later version —
|
|
47
|
+
* is skipped rather than ending the scan. It costs the scan one candidate;
|
|
48
|
+
* throwing would hide a usable record one slot older behind it.
|
|
49
|
+
*/
|
|
50
|
+
latest(target: string, branch?: string): StoredReview | undefined;
|
|
51
|
+
/**
|
|
52
|
+
* Every review of a repository, or of one branch of it, newest first.
|
|
53
|
+
*
|
|
54
|
+
* Lazy, so a caller that stops at the first one it can use reads only up to
|
|
55
|
+
* it. Unreadable records are skipped, as `latest` skips them.
|
|
56
|
+
*/
|
|
57
|
+
history(target: string, branch?: string): Generator<StoredReview>;
|
|
58
|
+
/**
|
|
59
|
+
* Resolves a reference to a review: a path, or an id.
|
|
60
|
+
*
|
|
61
|
+
* An id is looked up in the repository's own directory when a target is
|
|
62
|
+
* known, and otherwise across every repository's — a review's id is what the
|
|
63
|
+
* report printed, and someone holding one should not have to know which
|
|
64
|
+
* checkout produced it.
|
|
65
|
+
*/
|
|
66
|
+
load(ref: string, target?: string): StoredReview;
|
|
67
|
+
/**
|
|
68
|
+
* The review a command means: the one it was given, or the last of this branch.
|
|
69
|
+
*
|
|
70
|
+
* The last of this branch because that is the one whose report is on the
|
|
71
|
+
* screen. A detached HEAD has no branch to narrow by, and the most recent
|
|
72
|
+
* review of *some* branch would be the wrong one silently, so it is refused
|
|
73
|
+
* and naming the review is the way through. `answer` and `show` both ask
|
|
74
|
+
* this, and one rule is what lets a number read off one land on the same
|
|
75
|
+
* finding in the other. They name a review differently (`show` takes it as a
|
|
76
|
+
* positional, `answer` as `--review <id>`), so `how` is the caller's own
|
|
77
|
+
* phrase for it, and a refusal tells the user what to type.
|
|
78
|
+
*/
|
|
79
|
+
pick(target: string, branch: string | null, ref?: string, how?: string): StoredReview;
|
|
80
|
+
private _repoDirs;
|
|
81
|
+
private _idsIn;
|
|
82
|
+
}
|
|
83
|
+
//# sourceMappingURL=store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../src/record/store.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB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