@afaik-lab/weigh 0.0.0 → 0.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.env.example +49 -0
- package/LICENSE +373 -0
- package/README.md +103 -1
- 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 +141 -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 +303 -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 +100 -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 +228 -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 +584 -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 +72 -1
|
@@ -0,0 +1,149 @@
|
|
|
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
|
+
* What reaches one review, in the blocks it is read in.
|
|
6
|
+
*
|
|
7
|
+
* The point of this is a finding that is never born. A convention has to be in
|
|
8
|
+
* the context before the model forms a view of the change, or the finding is
|
|
9
|
+
* produced every run and killed at refute — which costs a call, reads as noise,
|
|
10
|
+
* and teaches nobody anything. So what Weigh knows about the repository goes
|
|
11
|
+
* in with the diff.
|
|
12
|
+
*
|
|
13
|
+
* The blocks arrive already filled; this owns the budget over them. What does
|
|
14
|
+
* not fit is named in its block rather than dropped quietly, which is the rule
|
|
15
|
+
* the coverage ledger already follows: a review that was shown eleven of
|
|
16
|
+
* nineteen claims should say so, because the eight it did not see are exactly
|
|
17
|
+
* the ones that would explain a finding it got wrong.
|
|
18
|
+
*/
|
|
19
|
+
export class Recalled {
|
|
20
|
+
_blocks;
|
|
21
|
+
constructor(_blocks,
|
|
22
|
+
/** Characters of claims to inline. The block's own budget, like the diff's. */
|
|
23
|
+
budget) {
|
|
24
|
+
this._blocks = _blocks;
|
|
25
|
+
this._fit(budget);
|
|
26
|
+
}
|
|
27
|
+
/** The blocks in reading order, those with something in them. */
|
|
28
|
+
get blocks() {
|
|
29
|
+
return this._blocks.filter((block) => !block.isEmpty);
|
|
30
|
+
}
|
|
31
|
+
/** Claims found, whether or not they fit. */
|
|
32
|
+
get size() {
|
|
33
|
+
return this._blocks.reduce((n, block) => n + block.size, 0);
|
|
34
|
+
}
|
|
35
|
+
get isEmpty() {
|
|
36
|
+
return this.size === 0;
|
|
37
|
+
}
|
|
38
|
+
/** How many were found and left out of the prompt. */
|
|
39
|
+
get dropped() {
|
|
40
|
+
return this._blocks.reduce((n, block) => n + block.dropped, 0);
|
|
41
|
+
}
|
|
42
|
+
/** One line for the progress reporter, before the review starts. */
|
|
43
|
+
describe() {
|
|
44
|
+
const parts = this.blocks.map((block) => `${block.label} ${block.size}`);
|
|
45
|
+
const dropped = this.dropped ? ` · ${this.dropped} over budget` : '';
|
|
46
|
+
return `${this.size} claim${this.size === 1 ? '' : 's'} recalled — ${parts.join(', ')}${dropped}`;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Spends the budget in priority order, not in reading order.
|
|
50
|
+
*
|
|
51
|
+
* The thread on this change is filled first and is never capped: a
|
|
52
|
+
* correction that fell off the end of a budget would be a defect silenced by
|
|
53
|
+
* accident, which is worse than a review that runs with no memory at all.
|
|
54
|
+
* Everything else takes what is left, in the order the blocks declare.
|
|
55
|
+
*/
|
|
56
|
+
_fit(budget) {
|
|
57
|
+
let left = budget;
|
|
58
|
+
for (const block of [...this._blocks].sort((a, b) => a.priority - b.priority)) {
|
|
59
|
+
let kept = 0;
|
|
60
|
+
for (const entry of block.found) {
|
|
61
|
+
const cost = entry.describe().join('\n').length + 1;
|
|
62
|
+
if (cost > left)
|
|
63
|
+
break;
|
|
64
|
+
left -= cost;
|
|
65
|
+
kept++;
|
|
66
|
+
}
|
|
67
|
+
block.keep(kept);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* The part of the reviewer's instructions that only applies when something
|
|
72
|
+
* was recalled.
|
|
73
|
+
*
|
|
74
|
+
* Four sentences do the work. The first is why the claims are there at all:
|
|
75
|
+
* a change that follows a convention this repository holds is not a finding.
|
|
76
|
+
* The second is the one promotion rests on, and it was added after watching a
|
|
77
|
+
* review read a promoted claim and report the finding anyway, in a weaker
|
|
78
|
+
* form — it had been told that the precondition holds elsewhere, and reported
|
|
79
|
+
* the code for not checking it again. A claim that answers a finding has to
|
|
80
|
+
* answer the class of it, or promotion buys a reworded finding rather than no
|
|
81
|
+
* finding. The third is the escape hatch, because knowledge goes stale
|
|
82
|
+
* silently and a reviewer that trusts a stale claim over the code in front of
|
|
83
|
+
* it produces the most confusing kind of false positive. The fourth keeps the
|
|
84
|
+
* citation rule intact: a claim is context, never the evidence a finding rests
|
|
85
|
+
* on.
|
|
86
|
+
*/
|
|
87
|
+
instructions() {
|
|
88
|
+
return [
|
|
89
|
+
'',
|
|
90
|
+
'Before the change you will find what Weigh already knows about this repository, in',
|
|
91
|
+
'labelled blocks, each claim with where it can be checked.',
|
|
92
|
+
'',
|
|
93
|
+
'- Judge the change against them. Code that follows a convention recorded there is not a',
|
|
94
|
+
' finding, and reporting it as one is the failure these blocks exist to prevent.',
|
|
95
|
+
'- A claim that records a guarantee is an answer about that guarantee. Code which relies on',
|
|
96
|
+
' one is not a finding for relying on it, and neither is code that does not check it again.',
|
|
97
|
+
' If you think the guarantee is thinner than the claim says, say that in your summary.',
|
|
98
|
+
'- They are dated, and they can be wrong. If the code says otherwise, the code is right:',
|
|
99
|
+
' note in your summary that the claim looks out of date, and do not report the change as',
|
|
100
|
+
' a defect for disagreeing with it.',
|
|
101
|
+
'- Never cite a claim as the evidence for a finding. Evidence is code you read.',
|
|
102
|
+
].join('\n');
|
|
103
|
+
}
|
|
104
|
+
/** The blocks as the model receives them, above the change. */
|
|
105
|
+
render() {
|
|
106
|
+
const blocks = this.blocks.filter((block) => block.kept.length > 0 || block.dropped > 0);
|
|
107
|
+
if (blocks.length === 0)
|
|
108
|
+
return '';
|
|
109
|
+
const out = ['# What Weigh knows'];
|
|
110
|
+
for (const block of blocks) {
|
|
111
|
+
out.push('', `## ${block.label}`, block.note, '');
|
|
112
|
+
for (const entry of block.kept)
|
|
113
|
+
out.push(...entry.describe());
|
|
114
|
+
if (block.dropped > 0) {
|
|
115
|
+
out.push('', `${block.dropped} further claim${block.dropped === 1 ? '' : 's'} in this block did not fit the context.`);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
return out.join('\n');
|
|
119
|
+
}
|
|
120
|
+
toJSON() {
|
|
121
|
+
return {
|
|
122
|
+
claims: this.size,
|
|
123
|
+
dropped: this.dropped,
|
|
124
|
+
blocks: this.blocks.map((block) => block.toJSON()),
|
|
125
|
+
rendered: this.render(),
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* The same claims with their scores, for calibrating the retrieval.
|
|
130
|
+
*
|
|
131
|
+
* The caps and the threshold are numbers nobody can pick honestly from a
|
|
132
|
+
* design document, so this prints what came back and why: twenty real claims
|
|
133
|
+
* about a repository you know, run against a branch you know, and read it.
|
|
134
|
+
*/
|
|
135
|
+
explain() {
|
|
136
|
+
if (this.isEmpty)
|
|
137
|
+
return 'Nothing recalled for this change.';
|
|
138
|
+
const out = [];
|
|
139
|
+
for (const block of this.blocks) {
|
|
140
|
+
out.push(`${block.label} — ${block.size} claim(s), ${block.dropped} over budget`);
|
|
141
|
+
for (const entry of block.found) {
|
|
142
|
+
out.push(` ${entry.claim.kind}: ${entry.claim.statement}`, entry.explain());
|
|
143
|
+
}
|
|
144
|
+
out.push('');
|
|
145
|
+
}
|
|
146
|
+
return out.join('\n').trimEnd();
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
//# sourceMappingURL=recalled.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"recalled.js","sourceRoot":"","sources":["../../src/knowledge/recalled.ts"],"names":[],"mappings":"AAAA,sEAAsE;AACtE,sEAAsE;AACtE,4DAA4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AAC,IAAI,cAAc,KAAK,CAAC,OAAO,cAAc,CAAC,CAAC;YAClF,KAAK,MAAM,KAAK,IAAI,KAAK,CAAC,KAAK,EAAE,CAAC;gBAChC,GAAG,CAAC,IAAI,CAAC,KAAK,KAAK,CAAC,KAAK,CAAC,IAAI,KAAK,KAAK,CAAC,KAAK,CAAC,SAAS,EAAE,EAAE,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;YAC/E,CAAC;YACD,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACf,CAAC;QACD,OAAO,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,CAAC;IAClC,CAAC;CACF"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/**
|
|
3
|
+
* The contract between everything that writes repository knowledge.
|
|
4
|
+
*
|
|
5
|
+
* Three actors produce it — a priming agent that explores a repository before
|
|
6
|
+
* any review, retrieval during a review, and Weigh writing back what it
|
|
7
|
+
* learned — so the shape is the thing that has to be specified. Two writers
|
|
8
|
+
* diverge the first time either side changes a field, which is also why none of
|
|
9
|
+
* them talks to the store directly: they all go through `weigh context`.
|
|
10
|
+
*/
|
|
11
|
+
/** What kind of claim this is. */
|
|
12
|
+
export declare const KINDS: readonly ['architecture', 'convention', 'invariant', 'hotspot', 'glossary'];
|
|
13
|
+
export type Kind = (typeof KINDS)[number];
|
|
14
|
+
/**
|
|
15
|
+
* Who produced a claim.
|
|
16
|
+
*
|
|
17
|
+
* `correction` is a human ruling that taught something — the only source whose
|
|
18
|
+
* sentence a person wrote themselves. Added to the values this field may hold
|
|
19
|
+
* rather than over a version, because the metadata has no version and a claim
|
|
20
|
+
* written before a value existed still parses. It is worth telling apart from
|
|
21
|
+
* the other two: a claim Weigh inferred can be re-derived, and one a human
|
|
22
|
+
* typed cannot.
|
|
23
|
+
*/
|
|
24
|
+
export declare const SOURCES: readonly ['priming', 'review', 'correction'];
|
|
25
|
+
export type ClaimSource = (typeof SOURCES)[number];
|
|
26
|
+
/**
|
|
27
|
+
* What a writer supplies.
|
|
28
|
+
*
|
|
29
|
+
* Evidence is required, and that is the whole design holding itself honest:
|
|
30
|
+
* context goes stale silently, and an agent confidently describing an
|
|
31
|
+
* architecture that was refactored away is worse than one with no context at
|
|
32
|
+
* all. A claim that cites nothing cannot be checked, so it is not accepted.
|
|
33
|
+
*/
|
|
34
|
+
export declare const claimInputSchema: z.ZodObject<{
|
|
35
|
+
kind: z.ZodEnum<{
|
|
36
|
+
architecture: "architecture";
|
|
37
|
+
convention: "convention";
|
|
38
|
+
glossary: "glossary";
|
|
39
|
+
hotspot: "hotspot";
|
|
40
|
+
invariant: "invariant";
|
|
41
|
+
}>;
|
|
42
|
+
statement: z.ZodString;
|
|
43
|
+
evidence: z.ZodArray<z.ZodString>;
|
|
44
|
+
applies: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
45
|
+
confidence: z.ZodOptional<z.ZodNumber>;
|
|
46
|
+
provenance: z.ZodOptional<z.ZodObject<{
|
|
47
|
+
source: z.ZodOptional<z.ZodEnum<{
|
|
48
|
+
correction: "correction";
|
|
49
|
+
priming: "priming";
|
|
50
|
+
review: "review";
|
|
51
|
+
}>>;
|
|
52
|
+
commit: z.ZodOptional<z.ZodString>;
|
|
53
|
+
at: z.ZodOptional<z.ZodString>;
|
|
54
|
+
}, z.core.$strip>>;
|
|
55
|
+
}, z.core.$strip>;
|
|
56
|
+
export declare const claimMetadataSchema: z.ZodPreprocess<z.ZodObject<{
|
|
57
|
+
weigh: z.ZodLiteral<"claim">;
|
|
58
|
+
kind: z.ZodEnum<{
|
|
59
|
+
architecture: "architecture";
|
|
60
|
+
convention: "convention";
|
|
61
|
+
glossary: "glossary";
|
|
62
|
+
hotspot: "hotspot";
|
|
63
|
+
invariant: "invariant";
|
|
64
|
+
}>;
|
|
65
|
+
statement: z.ZodOptional<z.ZodString>;
|
|
66
|
+
evidence: z.ZodArray<z.ZodString>;
|
|
67
|
+
applies: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
68
|
+
confidence: z.ZodNumber;
|
|
69
|
+
source: z.ZodEnum<{
|
|
70
|
+
correction: "correction";
|
|
71
|
+
priming: "priming";
|
|
72
|
+
review: "review";
|
|
73
|
+
}>;
|
|
74
|
+
commit: z.ZodOptional<z.ZodString>;
|
|
75
|
+
at: z.ZodString;
|
|
76
|
+
verified: z.ZodOptional<z.ZodObject<{
|
|
77
|
+
commit: z.ZodString;
|
|
78
|
+
at: z.ZodString;
|
|
79
|
+
}, z.core.$strip>>;
|
|
80
|
+
}, z.core.$strip>, unknown>;
|
|
81
|
+
export type ClaimInput = z.infer<typeof claimInputSchema>;
|
|
82
|
+
export type ClaimMetadata = z.infer<typeof claimMetadataSchema>;
|
|
83
|
+
//# sourceMappingURL=schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/knowledge/schema.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;;;;;;GAQG;AAEH,kCAAkC;AAClC,eAAO,MAAM,KAAK,YAAI,cAAc,EAAE,YAAY,EAAE,WAAW,EAAE,SAAS,EAAE,UAAU,CAAU,CAAC;AACjG,MAAM,MAAM,IAAI,GAAG,CAAC,OAAO,KAAK,CAAC,CAAC,MAAM,CAAC,CAAC;AAE1C;;;;;;;;;GASG;AACH,eAAO,MAAM,OAAO,YAAI,SAAS,EAAE,QAAQ,EAAE,YAAY,CAAU,CAAC;AACpE,MAAM,MAAM,WAAW,GAAG,CAAC,OAAO,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC;AAEnD;;;;;;;GAOG;AACH,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;iBAmB3B,CAAC;AA0CH,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;2BAAsD,CAAC;AAEvF,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAC1D,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC"}
|
|
@@ -0,0 +1,96 @@
|
|
|
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
|
+
/**
|
|
6
|
+
* The contract between everything that writes repository knowledge.
|
|
7
|
+
*
|
|
8
|
+
* Three actors produce it — a priming agent that explores a repository before
|
|
9
|
+
* any review, retrieval during a review, and Weigh writing back what it
|
|
10
|
+
* learned — so the shape is the thing that has to be specified. Two writers
|
|
11
|
+
* diverge the first time either side changes a field, which is also why none of
|
|
12
|
+
* them talks to the store directly: they all go through `weigh context`.
|
|
13
|
+
*/
|
|
14
|
+
/** What kind of claim this is. */
|
|
15
|
+
export const KINDS = ['architecture', 'convention', 'invariant', 'hotspot', 'glossary'];
|
|
16
|
+
/**
|
|
17
|
+
* Who produced a claim.
|
|
18
|
+
*
|
|
19
|
+
* `correction` is a human ruling that taught something — the only source whose
|
|
20
|
+
* sentence a person wrote themselves. Added to the values this field may hold
|
|
21
|
+
* rather than over a version, because the metadata has no version and a claim
|
|
22
|
+
* written before a value existed still parses. It is worth telling apart from
|
|
23
|
+
* the other two: a claim Weigh inferred can be re-derived, and one a human
|
|
24
|
+
* typed cannot.
|
|
25
|
+
*/
|
|
26
|
+
export const SOURCES = ['priming', 'review', 'correction'];
|
|
27
|
+
/**
|
|
28
|
+
* What a writer supplies.
|
|
29
|
+
*
|
|
30
|
+
* Evidence is required, and that is the whole design holding itself honest:
|
|
31
|
+
* context goes stale silently, and an agent confidently describing an
|
|
32
|
+
* architecture that was refactored away is worse than one with no context at
|
|
33
|
+
* all. A claim that cites nothing cannot be checked, so it is not accepted.
|
|
34
|
+
*/
|
|
35
|
+
export const claimInputSchema = z.object({
|
|
36
|
+
kind: z.enum(KINDS),
|
|
37
|
+
statement: z.string().min(1).describe('One sentence, true of the repository rather than of a change'),
|
|
38
|
+
evidence: z
|
|
39
|
+
.array(z.string().min(1))
|
|
40
|
+
.min(1)
|
|
41
|
+
.describe('Where it can be checked: `path`, or `path:12-40` for a range'),
|
|
42
|
+
applies: z
|
|
43
|
+
.array(z.string().min(1))
|
|
44
|
+
.optional()
|
|
45
|
+
.describe('Globs this claim governs, or ["*"] for a rule that holds everywhere in the repository'),
|
|
46
|
+
confidence: z.number().min(0).max(1).optional(),
|
|
47
|
+
provenance: z
|
|
48
|
+
.object({
|
|
49
|
+
source: z.enum(SOURCES).optional(),
|
|
50
|
+
commit: z.string().optional(),
|
|
51
|
+
at: z.string().optional(),
|
|
52
|
+
})
|
|
53
|
+
.optional(),
|
|
54
|
+
});
|
|
55
|
+
/**
|
|
56
|
+
* Before the rename to Weigh, claims were marked `nimbus: 'claim'`. Stores
|
|
57
|
+
* written then still hold them, so they are read back as if marked `weigh`;
|
|
58
|
+
* the next update writes the new marker.
|
|
59
|
+
*/
|
|
60
|
+
function fromNimbusMarker(metadata) {
|
|
61
|
+
if (typeof metadata !== 'object' || metadata === null)
|
|
62
|
+
return metadata;
|
|
63
|
+
const { nimbus, ...rest } = metadata;
|
|
64
|
+
if (nimbus !== 'claim' || 'weigh' in rest)
|
|
65
|
+
return metadata;
|
|
66
|
+
return { ...rest, weigh: 'claim' };
|
|
67
|
+
}
|
|
68
|
+
/** What travels with a claim in the store, and is read back as the claim. */
|
|
69
|
+
const claimMetadataObject = z.object({
|
|
70
|
+
weigh: z.literal('claim'),
|
|
71
|
+
kind: z.enum(KINDS),
|
|
72
|
+
/**
|
|
73
|
+
* The sentence itself, kept here as well as in the memory text.
|
|
74
|
+
*
|
|
75
|
+
* The text is the embedding surface and carries the evidence paths with the
|
|
76
|
+
* statement, so it is no longer something a statement can be parsed back out
|
|
77
|
+
* of. Optional because records written before that change have none, and a
|
|
78
|
+
* claim that predates a field is not a claim to throw away.
|
|
79
|
+
*/
|
|
80
|
+
statement: z.string().optional(),
|
|
81
|
+
evidence: z.array(z.string()),
|
|
82
|
+
/** Globs this claim governs. `*` means everywhere — see `Claim.isHouseRule`. */
|
|
83
|
+
applies: z.array(z.string()).optional(),
|
|
84
|
+
confidence: z.number().min(0).max(1),
|
|
85
|
+
source: z.enum(SOURCES),
|
|
86
|
+
commit: z.string().optional(),
|
|
87
|
+
at: z.string(),
|
|
88
|
+
/**
|
|
89
|
+
* The last time someone read the code again and found the claim still
|
|
90
|
+
* holds, and the commit they read. Kept apart from `commit` and `at`, which
|
|
91
|
+
* say when it was written: a refresh moves this and leaves those alone.
|
|
92
|
+
*/
|
|
93
|
+
verified: z.object({ commit: z.string(), at: z.string() }).optional(),
|
|
94
|
+
});
|
|
95
|
+
export const claimMetadataSchema = z.preprocess(fromNimbusMarker, claimMetadataObject);
|
|
96
|
+
//# sourceMappingURL=schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../src/knowledge/schema.ts"],"names":[],"mappings":"AAAA,sEAAsE;AACtE,sEAAsE;AACtE,4DAA4D;AAE5D,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;;;;;;GAQG;AAEH,kCAAkC;AAClC,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,cAAc,EAAE,YAAY,EAAE,WAAW,EAAE,SAAS,EAAE,UAAU,CAAU,CAAC;AAGjG;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,SAAS,EAAE,QAAQ,EAAE,YAAY,CAAU,CAAC;AAGpE;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,CAAC,MAAM,CAAC;IACvC,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC;IACnB,SAAS,EAAE,CAA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,CAAC;IACnC,KAAK,EAAE,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC;IACzB,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC;IACnB;;;;;;;OAOG;IACH,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAChC,QAAQ,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;IAC7B,gFAAgF;IAChF,OAAO,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,QAAQ,EAAE;IACvC,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;IACpC,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC;IACvB,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC7B,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE;IACd;;;;OAIG;IACH,QAAQ,EAAE,CAAC,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,QAAQ,EAAE;CACtE,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,CAAC,UAAU,CAAC,gBAAgB,EAAE,mBAAmB,CAAC,CAAC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { Claim } from './claim.js';
|
|
2
|
+
/** Why a claim is worth reading again. */
|
|
3
|
+
export type StaleReason = 'changed' | 'unstamped' | 'unknown-commit';
|
|
4
|
+
/** One claim that may no longer hold, and why. */
|
|
5
|
+
export interface StaleClaim {
|
|
6
|
+
claim: Claim;
|
|
7
|
+
reason: StaleReason;
|
|
8
|
+
/** The cited files that changed since the claim was last known to hold. */
|
|
9
|
+
changed: string[];
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Which claims cite code that changed since they were last known to hold.
|
|
13
|
+
*
|
|
14
|
+
* A refresh cannot re-read every claim once a repository holds hundreds, and
|
|
15
|
+
* most of them cite files nobody touched. This narrows it to the ones whose
|
|
16
|
+
* evidence moved, by asking git, so the model reads only those.
|
|
17
|
+
*
|
|
18
|
+
* One `git diff` per distinct commit rather than one per claim. A priming run
|
|
19
|
+
* stamps every claim it writes with the same commit, so a store of a thousand
|
|
20
|
+
* claims written in five runs costs five diffs.
|
|
21
|
+
*
|
|
22
|
+
* The diff is from that commit to HEAD, commit to commit, because a stamp
|
|
23
|
+
* can only name a commit: a claim confirmed over uncommitted edits would
|
|
24
|
+
* name code nobody read. `uncommitted()` is how `context confirm` refuses
|
|
25
|
+
* those. Renames are off, so a cited file that was moved away shows up under
|
|
26
|
+
* the name the claim cites rather than only under its new one.
|
|
27
|
+
*
|
|
28
|
+
* What this cannot see: a claim that went wrong while its own files stayed the
|
|
29
|
+
* same, such as a convention that new code elsewhere stopped following.
|
|
30
|
+
* Reviews catch those, when a finding contradicts the claim and someone rules
|
|
31
|
+
* on it.
|
|
32
|
+
*/
|
|
33
|
+
export declare class Staleness {
|
|
34
|
+
private readonly _root;
|
|
35
|
+
/** Files changed since each commit; null for a commit git does not know. */
|
|
36
|
+
private readonly _changes;
|
|
37
|
+
constructor(_root: string);
|
|
38
|
+
/** The claims worth reading again, in the order given. */
|
|
39
|
+
check(claims: readonly Claim[]): StaleClaim[];
|
|
40
|
+
/** One line saying why, for the text listing. */
|
|
41
|
+
static describe(stale: StaleClaim): string;
|
|
42
|
+
/** Tracked files whose working copy differs from HEAD, staged or not. */
|
|
43
|
+
uncommitted(): ReadonlySet<string>;
|
|
44
|
+
private static readonly _NAMES;
|
|
45
|
+
private _changedSince;
|
|
46
|
+
private _git;
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=staleness.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"staleness.d.ts","sourceRoot":"","sources":["../../src/knowledge/staleness.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAExC,0CAA0C;AAC1C,MAAM,MAAM,WAAW,GAAG,SAAS,GAAG,WAAW,GAAG,gBAAgB,CAAC;AAErE,kDAAkD;AAClD,MAAM,WAAW,UAAU;IACzB,KAAK,EAAE,KAAK,CAAC;IACb,MAAM,EAAE,WAAW,CAAC;IACpB,2EAA2E;IAC3E,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,qBAAa,SAAS;IAIR,OAAO,CAAC,QAAQ,CAAC,KAAK;IAHlC,4EAA4E;IAC5E,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAiD;IAE1E,YAA6B,KAAK,EAAE,MAAM,EAAI;IAE9C,0DAA0D;IAC1D,KAAK,CAAC,MAAM,EAAE,SAAS,KAAK,EAAE,GAAG,UAAU,EAAE,CAiB5C;IAED,iDAAiD;IACjD,MAAM,CAAC,QAAQ,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CASzC;IAED,yEAAyE;IACzE,WAAW,IAAI,WAAW,CAAC,MAAM,CAAC,CAGjC;IAED,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAqE;IAEnG,OAAO,CAAC,aAAa;IASrB,OAAO,CAAC,IAAI;CAIb"}
|
|
@@ -0,0 +1,85 @@
|
|
|
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 { spawnSync } from 'child_process';
|
|
5
|
+
/**
|
|
6
|
+
* Which claims cite code that changed since they were last known to hold.
|
|
7
|
+
*
|
|
8
|
+
* A refresh cannot re-read every claim once a repository holds hundreds, and
|
|
9
|
+
* most of them cite files nobody touched. This narrows it to the ones whose
|
|
10
|
+
* evidence moved, by asking git, so the model reads only those.
|
|
11
|
+
*
|
|
12
|
+
* One `git diff` per distinct commit rather than one per claim. A priming run
|
|
13
|
+
* stamps every claim it writes with the same commit, so a store of a thousand
|
|
14
|
+
* claims written in five runs costs five diffs.
|
|
15
|
+
*
|
|
16
|
+
* The diff is from that commit to HEAD, commit to commit, because a stamp
|
|
17
|
+
* can only name a commit: a claim confirmed over uncommitted edits would
|
|
18
|
+
* name code nobody read. `uncommitted()` is how `context confirm` refuses
|
|
19
|
+
* those. Renames are off, so a cited file that was moved away shows up under
|
|
20
|
+
* the name the claim cites rather than only under its new one.
|
|
21
|
+
*
|
|
22
|
+
* What this cannot see: a claim that went wrong while its own files stayed the
|
|
23
|
+
* same, such as a convention that new code elsewhere stopped following.
|
|
24
|
+
* Reviews catch those, when a finding contradicts the claim and someone rules
|
|
25
|
+
* on it.
|
|
26
|
+
*/
|
|
27
|
+
export class Staleness {
|
|
28
|
+
_root;
|
|
29
|
+
/** Files changed since each commit; null for a commit git does not know. */
|
|
30
|
+
_changes = new Map();
|
|
31
|
+
constructor(_root) {
|
|
32
|
+
this._root = _root;
|
|
33
|
+
}
|
|
34
|
+
/** The claims worth reading again, in the order given. */
|
|
35
|
+
check(claims) {
|
|
36
|
+
const stale = [];
|
|
37
|
+
for (const claim of claims) {
|
|
38
|
+
const commit = claim.knownAt;
|
|
39
|
+
if (!commit) {
|
|
40
|
+
stale.push({ claim, reason: 'unstamped', changed: [] });
|
|
41
|
+
continue;
|
|
42
|
+
}
|
|
43
|
+
const changes = this._changedSince(commit);
|
|
44
|
+
if (!changes) {
|
|
45
|
+
stale.push({ claim, reason: 'unknown-commit', changed: [] });
|
|
46
|
+
continue;
|
|
47
|
+
}
|
|
48
|
+
const changed = claim.cites.filter((path) => changes.has(path));
|
|
49
|
+
if (changed.length)
|
|
50
|
+
stale.push({ claim, reason: 'changed', changed });
|
|
51
|
+
}
|
|
52
|
+
return stale;
|
|
53
|
+
}
|
|
54
|
+
/** One line saying why, for the text listing. */
|
|
55
|
+
static describe(stale) {
|
|
56
|
+
switch (stale.reason) {
|
|
57
|
+
case 'changed':
|
|
58
|
+
return `changed since ${stale.claim.knownAt.slice(0, 7)}: ${stale.changed.join(', ')}`;
|
|
59
|
+
case 'unstamped':
|
|
60
|
+
return 'no commit recorded, so nothing says when it last held';
|
|
61
|
+
case 'unknown-commit':
|
|
62
|
+
return `commit ${stale.claim.knownAt.slice(0, 7)} is not in this repository (rewritten or not fetched)`;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
/** Tracked files whose working copy differs from HEAD, staged or not. */
|
|
66
|
+
uncommitted() {
|
|
67
|
+
const diff = this._git(['diff', ...Staleness._NAMES, 'HEAD', '--']);
|
|
68
|
+
return new Set(diff.ok ? diff.out.split('\n').filter(Boolean) : []);
|
|
69
|
+
}
|
|
70
|
+
static _NAMES = ['--name-only', '--no-renames', '--no-ext-diff', '--no-textconv'];
|
|
71
|
+
_changedSince(commit) {
|
|
72
|
+
if (this._changes.has(commit))
|
|
73
|
+
return this._changes.get(commit);
|
|
74
|
+
const known = this._git(['rev-parse', '--verify', '--quiet', `${commit}^{commit}`]);
|
|
75
|
+
const diff = known.ok ? this._git(['diff', ...Staleness._NAMES, commit, 'HEAD', '--']) : undefined;
|
|
76
|
+
const changes = diff?.ok ? new Set(diff.out.split('\n').filter(Boolean)) : null;
|
|
77
|
+
this._changes.set(commit, changes);
|
|
78
|
+
return changes;
|
|
79
|
+
}
|
|
80
|
+
_git(args) {
|
|
81
|
+
const proc = spawnSync('git', args, { cwd: this._root, encoding: 'utf-8', maxBuffer: 64 * 1024 * 1024 });
|
|
82
|
+
return { ok: proc.status === 0, out: (proc.stdout ?? '').trim() };
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
//# sourceMappingURL=staleness.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"staleness.js","sourceRoot":"","sources":["../../src/knowledge/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,CAAC,CAAC,MAAM,EAAE,GAAG,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;QACnG,MAAM,OAAO,GAAG,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;QAChF,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QACnC,OAAO,OAAO,CAAC;IACjB,CAAC;IAEO,IAAI,CAAC,IAAc;QACzB,MAAM,IAAI,GAAG,SAAS,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,GAAG,EAAE,IAAI,CAAC,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,SAAS,EAAE,EAAE,GAAG,IAAI,GAAG,IAAI,EAAE,CAAC,CAAC;QACzG,OAAO,EAAE,EAAE,EAAE,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC;IACpE,CAAC;CACF"}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import type { AgentConfig } from '../config.js';
|
|
2
|
+
import type { MemoryStore } from '../memory/index.js';
|
|
3
|
+
import type { Scope } from '../memory/scope.js';
|
|
4
|
+
import { Claim } from './claim.js';
|
|
5
|
+
/** What `Knowledge.confirm` stamps, and what it refuses. */
|
|
6
|
+
export interface ConfirmAt {
|
|
7
|
+
/** The commit the claims were found to hold at. */
|
|
8
|
+
commit: string;
|
|
9
|
+
now?: Date;
|
|
10
|
+
/** A reason to refuse one claim, or nothing to accept it. */
|
|
11
|
+
check?: (claim: Claim) => string | undefined;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Repository knowledge, over whichever memory backend is configured.
|
|
15
|
+
*
|
|
16
|
+
* Deliberately narrow: typed claims in, typed claims out, one scope at a time.
|
|
17
|
+
* The store underneath takes free text and will remember anything — this is the
|
|
18
|
+
* only thing allowed to write knowledge into it, so that there is one schema and
|
|
19
|
+
* one place validation lives.
|
|
20
|
+
*
|
|
21
|
+
* Nothing here degrades quietly. `recall` swallows a failed read because a
|
|
22
|
+
* review is still worth running without memory; `weigh context` is *about* the
|
|
23
|
+
* store, so a backend that is down has to say so rather than print an empty
|
|
24
|
+
* list that reads as "nothing is remembered".
|
|
25
|
+
*/
|
|
26
|
+
export declare class Knowledge {
|
|
27
|
+
private readonly _store;
|
|
28
|
+
private readonly _config;
|
|
29
|
+
constructor(_store: MemoryStore, _config: AgentConfig);
|
|
30
|
+
get enabled(): boolean;
|
|
31
|
+
/** Why memory is off, when it is. */
|
|
32
|
+
get reason(): string | undefined;
|
|
33
|
+
/**
|
|
34
|
+
* Writes claims, one call each.
|
|
35
|
+
*
|
|
36
|
+
* `infer: false` is the point of this method. Left to itself the backend runs
|
|
37
|
+
* an LLM over what it is given and keeps whatever it decides is durable —
|
|
38
|
+
* which is the right behaviour for a conversation and the wrong one for a
|
|
39
|
+
* claim that has already been written, validated and cited. A paraphrase of
|
|
40
|
+
* an invariant is not the invariant.
|
|
41
|
+
*
|
|
42
|
+
* Each claim comes back with the id the store gave it, when the store says,
|
|
43
|
+
* so the writer can take one back without listing the scope to find it.
|
|
44
|
+
*/
|
|
45
|
+
add(claims: readonly Claim[], scope: Scope): Promise<Claim[]>;
|
|
46
|
+
/** Everything remembered in one scope, newest first where the backend says. */
|
|
47
|
+
list(scope: Scope, limit?: number): Promise<Claim[]>;
|
|
48
|
+
/**
|
|
49
|
+
* The claims in one scope that bear on a question.
|
|
50
|
+
*
|
|
51
|
+
* The caller supplies the cap and the floor rather than inheriting the
|
|
52
|
+
* prompt path's, because recall into a review is tuned against claims and
|
|
53
|
+
* hunks while `memory.topK` is tuned against a conversation.
|
|
54
|
+
*/
|
|
55
|
+
search(query: string, scope: Scope, options?: {
|
|
56
|
+
topK?: number;
|
|
57
|
+
threshold?: number;
|
|
58
|
+
}): Promise<Claim[]>;
|
|
59
|
+
/** Forgets one scope. Returns how many records went, claims or not. */
|
|
60
|
+
clear(scope: Scope): Promise<number>;
|
|
61
|
+
/**
|
|
62
|
+
* Takes back claims by id, and returns what was taken.
|
|
63
|
+
*
|
|
64
|
+
* Every id is checked before anything is deleted: it must be a claim, and
|
|
65
|
+
* one stored under this scope for this user and agent. The delete underneath
|
|
66
|
+
* is by id alone, so this check is what keeps `context remove` inside the
|
|
67
|
+
* repository it was run in. One bad id refuses the lot, so a typo never
|
|
68
|
+
* leaves half a retraction done.
|
|
69
|
+
*/
|
|
70
|
+
remove(ids: readonly string[], scope: Scope): Promise<Claim[]>;
|
|
71
|
+
/**
|
|
72
|
+
* Records that claims were read again at `commit` and still hold.
|
|
73
|
+
*
|
|
74
|
+
* The id, the text and when it was written stay as they were; only the
|
|
75
|
+
* verified stamp moves. Checked exactly as `remove` checks, all before any
|
|
76
|
+
* is touched.
|
|
77
|
+
*/
|
|
78
|
+
confirm(ids: readonly string[], scope: Scope, at: ConfirmAt): Promise<Claim[]>;
|
|
79
|
+
/** How many store calls a remove or confirm has in flight at once. */
|
|
80
|
+
private static readonly _PARALLEL;
|
|
81
|
+
/**
|
|
82
|
+
* One write per claim, a few at a time, waiting for all of them to settle.
|
|
83
|
+
*
|
|
84
|
+
* A failed write does not stop the others, so the error can name which
|
|
85
|
+
* claims were written and which were not. Stopping at the first failure
|
|
86
|
+
* would leave the rest unknown, and a retry of `remove` with every id is
|
|
87
|
+
* refused once some of them are gone.
|
|
88
|
+
*/
|
|
89
|
+
private _writeEach;
|
|
90
|
+
private static _message;
|
|
91
|
+
/**
|
|
92
|
+
* The claims these ids name, each checked to be a claim stored under this
|
|
93
|
+
* scope for this user and agent, or an error naming every id that is not.
|
|
94
|
+
* `check` adds a caller's own reason to refuse one.
|
|
95
|
+
*/
|
|
96
|
+
private _owned;
|
|
97
|
+
/** Records that are claims, in the order the store returned them. */
|
|
98
|
+
private static _claims;
|
|
99
|
+
}
|
|
100
|
+
//# sourceMappingURL=store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../src/knowledge/store.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAEnC,4DAA4D;AAC5D,MAAM,WAAW,SAAS;IACxB,mDAAmD;IACnD,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,CAAC,EAAE,IAAI,CAAC;IACX,6DAA6D;IAC7D,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,MAAM,GAAG,SAAS,CAAC;CAC9C;AAED;;;;;;;;;;;;GAYG;AACH,qBAAa,SAAS;IAElB,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,OAAO;IAF1B,YACmB,MAAM,EAAE,WAAW,EACnB,OAAO,EAAE,WAAW,EACnC;IAEJ,IAAI,OAAO,IAAI,OAAO,CAErB;IAED,qCAAqC;IACrC,IAAI,MAAM,IAAI,MAAM,GAAG,SAAS,CAE/B;IAED;;;;;;;;;;;OAWG;IACG,GAAG,CAAC,MAAM,EAAE,SAAS,KAAK,EAAE,EAAE,KAAK,EAAE,KAAK,GAAG,OAAO,CAAC,KAAK,EAAE,CAAC,CAelE;IAED,+EAA+E;IACzE,IAAI,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,EAAE,CAAC,CAKzD;IAED;;;;;;OAMG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