@saasontools/strauss-kb 0.1.9 → 0.1.11
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/ARCHITECTURE.md +17 -0
- package/README.md +155 -62
- package/dist/{chunk-MWWDD23L.js → chunk-CWWXMD35.js} +2 -2
- package/dist/{chunk-KVEEISYQ.js → chunk-I3WW4F6X.js} +2 -2
- package/dist/{chunk-OFDWRMY6.js → chunk-OVRQCQ6P.js} +1257 -304
- package/dist/chunk-OVRQCQ6P.js.map +1 -0
- package/dist/cli-main.cjs +1266 -321
- package/dist/cli-main.cjs.map +1 -1
- package/dist/cli-main.js +2 -2
- package/dist/index.cjs +1145 -186
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +294 -13
- package/dist/index.d.ts +294 -13
- package/dist/index.js +19 -3
- package/dist/index.js.map +1 -1
- package/dist/mcp-main.cjs +1262 -317
- package/dist/mcp-main.cjs.map +1 -1
- package/dist/mcp-main.js +2 -2
- package/package.json +1 -1
- package/dist/chunk-OFDWRMY6.js.map +0 -1
- /package/dist/{chunk-MWWDD23L.js.map → chunk-CWWXMD35.js.map} +0 -0
- /package/dist/{chunk-KVEEISYQ.js.map → chunk-I3WW4F6X.js.map} +0 -0
package/dist/index.d.cts
CHANGED
|
@@ -47,13 +47,29 @@ declare const kbVerifiedEventSchema: z.ZodObject<{
|
|
|
47
47
|
*
|
|
48
48
|
* Symbolic on purpose. These are written while the code is still moving: a
|
|
49
49
|
* `line: 379` recorded at minute five is wrong by minute forty, but
|
|
50
|
-
* `OrderService.cancel` survives every edit that does not rename it.
|
|
51
|
-
*
|
|
52
|
-
*
|
|
50
|
+
* `OrderService.cancel` survives every edit that does not rename it. Once the
|
|
51
|
+
* change settles, a resolution pass (`anchor-resolver.ts`) stamps `hash`,
|
|
52
|
+
* `resolved_at`, and `lines`; drift detection later re-resolves and compares.
|
|
53
|
+
*
|
|
54
|
+
* `hash` is prefixed with the algorithm so a future one can coexist with
|
|
55
|
+
* stored values. `lines` exists because the anchor keeps a hash, not the text:
|
|
56
|
+
* without the line count at hash time, a drift report could say "changed" but
|
|
57
|
+
* never how much.
|
|
58
|
+
*
|
|
59
|
+
* `repo` and `ref` say *which* code, for bases that describe more than one
|
|
60
|
+
* repository. They are author-owned identity: a resolver stamps `hash`,
|
|
61
|
+
* `lines`, and `resolved_at`, and never writes these two. Both are optional and
|
|
62
|
+
* independent of each other, so every anchor written before they existed stays
|
|
63
|
+
* valid.
|
|
53
64
|
*/
|
|
54
65
|
declare const kbAnchorSchema: z.ZodObject<{
|
|
55
66
|
file: z.ZodString;
|
|
56
67
|
symbol: z.ZodOptional<z.ZodString>;
|
|
68
|
+
repo: z.ZodOptional<z.ZodString>;
|
|
69
|
+
ref: z.ZodOptional<z.ZodString>;
|
|
70
|
+
hash: z.ZodOptional<z.ZodString>;
|
|
71
|
+
resolved_at: z.ZodOptional<z.ZodString>;
|
|
72
|
+
lines: z.ZodOptional<z.ZodNumber>;
|
|
57
73
|
}, z.core.$strict>;
|
|
58
74
|
declare const KB_RECORD_TYPES: readonly ["fact", "requirement", "constraint", "decision", "assumption", "open-question", "risk", "contract", "flow", "affected-system", "test-obligation", "source-note"];
|
|
59
75
|
type KbRecordType = (typeof KB_RECORD_TYPES)[number];
|
|
@@ -103,6 +119,11 @@ declare const kbRecordFrontmatterSchema: z.ZodObject<{
|
|
|
103
119
|
strauss_anchors: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
104
120
|
file: z.ZodString;
|
|
105
121
|
symbol: z.ZodOptional<z.ZodString>;
|
|
122
|
+
repo: z.ZodOptional<z.ZodString>;
|
|
123
|
+
ref: z.ZodOptional<z.ZodString>;
|
|
124
|
+
hash: z.ZodOptional<z.ZodString>;
|
|
125
|
+
resolved_at: z.ZodOptional<z.ZodString>;
|
|
126
|
+
lines: z.ZodOptional<z.ZodNumber>;
|
|
106
127
|
}, z.core.$strict>>>;
|
|
107
128
|
strauss_verify: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
108
129
|
strauss_status: z.ZodDefault<z.ZodEnum<{
|
|
@@ -145,6 +166,104 @@ type KbRecord = {
|
|
|
145
166
|
body: string;
|
|
146
167
|
};
|
|
147
168
|
|
|
169
|
+
/**
|
|
170
|
+
* Resolves symbolic anchors to text and detects drift against stored hashes.
|
|
171
|
+
*
|
|
172
|
+
* Resolvers are pure — source string in, range out; only the file readers touch
|
|
173
|
+
* disk. Any shape the lexer cannot handle confidently returns `null` and is
|
|
174
|
+
* reported `unresolved` rather than guessed at.
|
|
175
|
+
*/
|
|
176
|
+
type ResolvedSymbol = {
|
|
177
|
+
text: string;
|
|
178
|
+
/** 1-based, inclusive. */
|
|
179
|
+
startLine: number;
|
|
180
|
+
endLine: number;
|
|
181
|
+
};
|
|
182
|
+
interface AnchorResolver {
|
|
183
|
+
name: string;
|
|
184
|
+
resolve(source: string, symbol: string): ResolvedSymbol | null;
|
|
185
|
+
}
|
|
186
|
+
/** Why an anchor could not be compared. Never an error — always a finding. */
|
|
187
|
+
type AnchorUnresolvedReason = "file-missing" | "symbol-not-found" | "outside-repo" | "file-too-large" | "file-unreadable"
|
|
188
|
+
/**
|
|
189
|
+
* The anchor names a repository this root is not. Expected rather than
|
|
190
|
+
* wrong — a base describing several repositories resolves against one tree
|
|
191
|
+
* at a time — so it is never a drift finding and never reaches a reader as
|
|
192
|
+
* a warning. Multi-root resolution is SAA-709.
|
|
193
|
+
*/
|
|
194
|
+
| "foreign-repo";
|
|
195
|
+
/**
|
|
196
|
+
* v1 heuristic resolver. A dotted symbol like `OrderService.cancel` matches on
|
|
197
|
+
* its last segment, with the parent used to scope the search: a candidate
|
|
198
|
+
* counts only if the parent name appears in the fifty lines above it, when any
|
|
199
|
+
* candidate satisfies that at all.
|
|
200
|
+
*
|
|
201
|
+
* Deterministic, and ambiguity is not resolved by guessing — two lines of
|
|
202
|
+
* equally good shape mean the resolver cannot tell which one the record meant,
|
|
203
|
+
* and it says so by returning `null`.
|
|
204
|
+
*/
|
|
205
|
+
declare const regexResolver: AnchorResolver;
|
|
206
|
+
/** CRLF normalized to LF before hashing, so checkout style cannot read as drift. */
|
|
207
|
+
declare function hashAnchorText(text: string): string;
|
|
208
|
+
/**
|
|
209
|
+
* An anchor without a symbol is about the whole file; with one, the resolver
|
|
210
|
+
* decides. Source newlines are normalized first so line counts and hashes
|
|
211
|
+
* agree with `hashAnchorText`.
|
|
212
|
+
*
|
|
213
|
+
* A file's last line is the last line with content: a trailing newline is a
|
|
214
|
+
* terminator, not an empty line, and counting it would have made every
|
|
215
|
+
* whole-file anchor's `lines` one larger than the file.
|
|
216
|
+
*/
|
|
217
|
+
declare function resolveAnchor(source: string, anchor: KbAnchor, resolver?: AnchorResolver): ResolvedSymbol | null;
|
|
218
|
+
type KbAnchorDriftEntry = {
|
|
219
|
+
file: string;
|
|
220
|
+
symbol?: string;
|
|
221
|
+
state: "match" | "drifted" | "unresolved";
|
|
222
|
+
storedHash: string;
|
|
223
|
+
currentHash?: string;
|
|
224
|
+
/** `null` when the anchor recorded no `lines` — size unknown, not zero. */
|
|
225
|
+
diffSize: number | null;
|
|
226
|
+
reason?: AnchorUnresolvedReason;
|
|
227
|
+
};
|
|
228
|
+
/**
|
|
229
|
+
* An anchor's `file` must stay inside the repository root — a record points
|
|
230
|
+
* at code, not at arbitrary files on the machine reading it. Bundles are
|
|
231
|
+
* data, so a traversal or absolute path here is untrusted input, not a bug
|
|
232
|
+
* in the caller. Returns the resolved path, or `null` when it escapes.
|
|
233
|
+
*
|
|
234
|
+
* Lexical only, and therefore not the whole containment check: see
|
|
235
|
+
* `readAnchorFile`, which re-tests the real path after following symlinks.
|
|
236
|
+
*/
|
|
237
|
+
declare function anchorFilePath(repoRoot: string, file: string): string | null;
|
|
238
|
+
type AnchorRead = {
|
|
239
|
+
ok: true;
|
|
240
|
+
source: string;
|
|
241
|
+
} | {
|
|
242
|
+
ok: false;
|
|
243
|
+
reason: AnchorUnresolvedReason;
|
|
244
|
+
};
|
|
245
|
+
type AnchorFileReader = (file: string) => Promise<AnchorRead>;
|
|
246
|
+
/**
|
|
247
|
+
* Re-resolves every hash-carrying anchor and compares against the stored hash.
|
|
248
|
+
*
|
|
249
|
+
* Anchors without a `hash` are skipped; one naming another repository is
|
|
250
|
+
* reported `foreign-repo` and never read, and `origin` is asked for once per
|
|
251
|
+
* run, only when some anchor declares a `repo`. A missing file or unresolvable
|
|
252
|
+
* symbol is a finding (`unresolved`), never a throw. Each distinct file is read
|
|
253
|
+
* once per run; all checked entries are returned per record, callers filter.
|
|
254
|
+
*
|
|
255
|
+
* Three phases: collect the checkable anchors, read their distinct files with
|
|
256
|
+
* a bounded pool, then resolve and hash in record order — so the output does
|
|
257
|
+
* not depend on which read finished first.
|
|
258
|
+
*/
|
|
259
|
+
declare function detectAnchorDrift(records: KbRecord[], options?: {
|
|
260
|
+
repoRoot?: string;
|
|
261
|
+
resolver?: AnchorResolver;
|
|
262
|
+
concurrency?: number;
|
|
263
|
+
/** Test seam: replaces the disk reader. */
|
|
264
|
+
reader?: AnchorFileReader;
|
|
265
|
+
}): Promise<Map<string, KbAnchorDriftEntry[]>>;
|
|
266
|
+
|
|
148
267
|
/**
|
|
149
268
|
* Why a matched record must not be read as a plain answer.
|
|
150
269
|
*
|
|
@@ -189,6 +308,18 @@ type KbWarning =
|
|
|
189
308
|
staleAfter: string;
|
|
190
309
|
} | {
|
|
191
310
|
kind: "unverified";
|
|
311
|
+
}
|
|
312
|
+
/** The code this record anchors to has changed since its hash was recorded —
|
|
313
|
+
* the record may describe code that no longer exists in that form. */
|
|
314
|
+
| {
|
|
315
|
+
kind: "drifted";
|
|
316
|
+
anchors: {
|
|
317
|
+
file: string;
|
|
318
|
+
symbol?: string;
|
|
319
|
+
/** `null` when the anchor recorded no line count — size unknown. */
|
|
320
|
+
diffSize: number | null;
|
|
321
|
+
reason?: string;
|
|
322
|
+
}[];
|
|
192
323
|
};
|
|
193
324
|
type KbStanding = "current" | "superseded" | "rejected" | "unsettled" | "open";
|
|
194
325
|
type KbAdjudicated = {
|
|
@@ -205,7 +336,7 @@ type KbAdjudicated = {
|
|
|
205
336
|
* invisible: the caller cannot tell it missed anything, so a dropped record is
|
|
206
337
|
* worse than a flagged one — it turns a knowable gap into an unknowable one.
|
|
207
338
|
*/
|
|
208
|
-
declare function adjudicate(hits: KbRecord[], bundle: KbRecord[], now?: Date): KbAdjudicated[];
|
|
339
|
+
declare function adjudicate(hits: KbRecord[], bundle: KbRecord[], now?: Date, anchorDrift?: Map<string, KbAnchorDriftEntry[]>): KbAdjudicated[];
|
|
209
340
|
/**
|
|
210
341
|
* Walks a supersession chain to whatever currently stands in its place.
|
|
211
342
|
*
|
|
@@ -311,6 +442,79 @@ type KbPackResult = {
|
|
|
311
442
|
*/
|
|
312
443
|
declare function pack(bundle: KbRecord[], rootId: string, options?: KbPackOptions): KbPackResult;
|
|
313
444
|
|
|
445
|
+
/** One record as the catalog names it — no body, no description, one line. */
|
|
446
|
+
type KbCatalogEntry = {
|
|
447
|
+
conceptId: string;
|
|
448
|
+
type: string;
|
|
449
|
+
title: string | null;
|
|
450
|
+
standing: KbStanding;
|
|
451
|
+
/** Where the supersession chain ends. Empty when broken, cyclic, or n/a. */
|
|
452
|
+
supersededBy: string[];
|
|
453
|
+
/** `stale_after` is in the past. The one freshness signal a line can carry. */
|
|
454
|
+
stale: boolean;
|
|
455
|
+
};
|
|
456
|
+
type KbCatalogResult = {
|
|
457
|
+
entries: KbCatalogEntry[];
|
|
458
|
+
/** Every record the catalog names, filter applied. */
|
|
459
|
+
recordCount: number;
|
|
460
|
+
/**
|
|
461
|
+
* How many records hold each standing. Sums to `recordCount` — every record
|
|
462
|
+
* has exactly one standing, so the reader can see that nothing went missing.
|
|
463
|
+
*/
|
|
464
|
+
standings: Record<KbStanding, number>;
|
|
465
|
+
/** Shorthand for `standings.current` — records that simply hold. */
|
|
466
|
+
currentCount: number;
|
|
467
|
+
/** Shorthand for `standings.superseded`. */
|
|
468
|
+
supersededCount: number;
|
|
469
|
+
/**
|
|
470
|
+
* Records whose `stale_after` has passed. A flag over the standings rather
|
|
471
|
+
* than one of them — a current record can be stale — so this deliberately
|
|
472
|
+
* does not participate in the sum.
|
|
473
|
+
*/
|
|
474
|
+
staleCount: number;
|
|
475
|
+
};
|
|
476
|
+
/**
|
|
477
|
+
* The tier-one listing: every record named, nothing spelled out.
|
|
478
|
+
*
|
|
479
|
+
* `load` hands over bodies and `pack` hands over a neighbourhood; both have to
|
|
480
|
+
* decide what the reader can afford. The catalog is the rung below either — one
|
|
481
|
+
* line per record at roughly thirty tokens, so a base far past `load`'s gate
|
|
482
|
+
* still fits in a single call. What it buys is the ability to choose: a reader
|
|
483
|
+
* that can see every id, type, title and standing knows which record to `pack`
|
|
484
|
+
* and knows when no record covers the question at all, which is the conclusion
|
|
485
|
+
* a truncated read can never support.
|
|
486
|
+
*
|
|
487
|
+
* Standing travels on the line for the same reason it travels with every other
|
|
488
|
+
* result here: a title is a claim, and a superseded claim reads exactly like a
|
|
489
|
+
* live one. A superseded entry names its replacement, so the line the reader
|
|
490
|
+
* should follow instead is already in front of them.
|
|
491
|
+
*
|
|
492
|
+
* Unbounded, alone among the read paths. `load` and `pack` refuse past a
|
|
493
|
+
* ceiling because a partial body set reads as a complete one; a catalog has no
|
|
494
|
+
* such failure — it is the rung a caller lands on *because* something else
|
|
495
|
+
* refused, and a second refusal there would leave nowhere to go. The cost is
|
|
496
|
+
* linear and cheap: roughly thirty tokens a record, so a thousand-record base
|
|
497
|
+
* is about 30k and five thousand about 150k. Past that the `type` filter
|
|
498
|
+
* narrows it, and no ceiling is needed to make that available.
|
|
499
|
+
*
|
|
500
|
+
* Deterministic given a fixed `now`: no timestamp is emitted, and the ordering
|
|
501
|
+
* is total down to the concept id, so two catalogs of an unchanged base within
|
|
502
|
+
* one `stale_after` window are byte-identical and diff to nothing. The default
|
|
503
|
+
* clock is the wall clock, so a line can still flip to stale as a date passes —
|
|
504
|
+
* pass `now` when byte-equality has to hold across that boundary.
|
|
505
|
+
*/
|
|
506
|
+
declare function catalog(bundle: KbRecord[], options?: {
|
|
507
|
+
type?: string;
|
|
508
|
+
now?: Date;
|
|
509
|
+
}): KbCatalogResult;
|
|
510
|
+
/**
|
|
511
|
+
* One entry, as one line.
|
|
512
|
+
*
|
|
513
|
+
* ` · `-separated rather than a table: a table pays for column alignment on
|
|
514
|
+
* every row, and nothing downstream parses these.
|
|
515
|
+
*/
|
|
516
|
+
declare function renderCatalogLine(entry: KbCatalogEntry): string;
|
|
517
|
+
|
|
314
518
|
declare const LOG_FILE = "log.jsonl";
|
|
315
519
|
declare const kbLogEntrySchema: z.ZodObject<{
|
|
316
520
|
at: z.ZodISODateTime;
|
|
@@ -391,6 +595,8 @@ type KbLoadResult = {
|
|
|
391
595
|
recordCount: number;
|
|
392
596
|
approxTokens: number;
|
|
393
597
|
budgetTokens: number;
|
|
598
|
+
/** The refusal in words, naming the budget and what to call next. */
|
|
599
|
+
message: string;
|
|
394
600
|
};
|
|
395
601
|
type KbWriteInput = {
|
|
396
602
|
type: string;
|
|
@@ -451,6 +657,14 @@ declare class KbStore {
|
|
|
451
657
|
* timeouts.
|
|
452
658
|
*/
|
|
453
659
|
setStatus(bundlePath: string, conceptId: string, status: KbRecordStatus, actor?: string): Promise<KbRecord>;
|
|
660
|
+
/**
|
|
661
|
+
* Replaces a record's anchors wholesale, preserving everything else.
|
|
662
|
+
*
|
|
663
|
+
* Wholesale rather than merged: the caller just resolved the anchors it is
|
|
664
|
+
* writing, so it holds the complete current set, and a merge would keep
|
|
665
|
+
* stale entries the resolution pass deliberately dropped.
|
|
666
|
+
*/
|
|
667
|
+
updateAnchors(bundlePath: string, conceptId: string, anchors: KbAnchor[], actor?: string): Promise<KbRecord>;
|
|
454
668
|
/**
|
|
455
669
|
* Appends one `verified[]` event: who checked the record, when, and what the
|
|
456
670
|
* check found. Append-only — prior events are history, and are spread into
|
|
@@ -488,8 +702,31 @@ declare class KbStore {
|
|
|
488
702
|
query(bundlePath: string, text: string, options?: {
|
|
489
703
|
type?: string;
|
|
490
704
|
includeNonCurrent?: boolean;
|
|
705
|
+
repoRoot?: string;
|
|
491
706
|
}): Promise<KbAdjudicated[]>;
|
|
492
707
|
private rank;
|
|
708
|
+
/**
|
|
709
|
+
* Anchor drift over the records about to be handed back. Like the search
|
|
710
|
+
* index, this is an enrichment: a filesystem failure degrades to "no drift
|
|
711
|
+
* reported" rather than failing the read. Anchors without a stored hash are
|
|
712
|
+
* skipped inside `detectAnchorDrift`, so a base nobody has stamped pays no
|
|
713
|
+
* fs cost here. `repoRoot` defaults to the working directory — the CLI runs
|
|
714
|
+
* at the repo root, and the MCP server's cwd is the workspace.
|
|
715
|
+
*
|
|
716
|
+
* Public because `doctor` needs the same map with the same degradation: a
|
|
717
|
+
* sweep that failed to read the tree should report no drift, not fail.
|
|
718
|
+
*
|
|
719
|
+
* When no root was given and not one anchored file was found, the finding is
|
|
720
|
+
* discarded. A base read from somewhere other than the tree it describes
|
|
721
|
+
* misses every file at once, and that shape is far likelier to be a wrong
|
|
722
|
+
* default root than a repository where every anchored file was deleted on
|
|
723
|
+
* the same day. Reporting it would put a drift warning on every record in
|
|
724
|
+
* the base, which teaches a reader to ignore the warning — the one outcome
|
|
725
|
+
* worse than not having it. One file found anywhere makes the root
|
|
726
|
+
* plausible, and the misses become findings again; an explicit `repoRoot` is
|
|
727
|
+
* taken at its word either way.
|
|
728
|
+
*/
|
|
729
|
+
detectDrift(records: KbRecord[], repoRoot?: string): Promise<Map<string, KbAnchorDriftEntry[]> | undefined>;
|
|
493
730
|
/**
|
|
494
731
|
* The whole base, adjudicated, when it is small enough to hand over.
|
|
495
732
|
*
|
|
@@ -509,17 +746,30 @@ declare class KbStore {
|
|
|
509
746
|
* is indistinguishable from a complete one, so a caller would answer "that
|
|
510
747
|
* was never decided" from a slice it did not know was a slice.
|
|
511
748
|
*
|
|
512
|
-
*
|
|
513
|
-
*
|
|
514
|
-
*
|
|
749
|
+
* A token budget decides that, measured over what is actually handed back.
|
|
750
|
+
* The refusal names the estimate and the budget, because a caller told only
|
|
751
|
+
* "too big" cannot tell whether to narrow the type filter, raise the budget,
|
|
752
|
+
* or stop loading the base whole altogether. Past the budget the answer is
|
|
753
|
+
* the catalog and then a pack, which is what the refusal says.
|
|
754
|
+
*
|
|
755
|
+
* That refusal is the default guardrail. `all` bypasses the budget outright
|
|
756
|
+
* and always hands back the whole bundle: an explicit, never-accidental
|
|
757
|
+
* escape hatch for an operator who has the budget to spend, not a wider
|
|
758
|
+
* default.
|
|
515
759
|
*/
|
|
516
760
|
load(bundlePath: string, options?: {
|
|
517
761
|
budgetTokens?: number;
|
|
518
762
|
type?: string;
|
|
519
763
|
all?: boolean;
|
|
764
|
+
repoRoot?: string;
|
|
520
765
|
}): Promise<KbLoadResult>;
|
|
521
766
|
/** How a position was arrived at, as a timeline. See `trace.ts`. */
|
|
522
767
|
trace(bundlePath: string, seedId: string, options?: KbTraceOptions): Promise<KbTraceStep[]>;
|
|
768
|
+
/** Every record named in one line each. See `catalog.ts`. */
|
|
769
|
+
catalog(bundlePath: string, options?: {
|
|
770
|
+
type?: string;
|
|
771
|
+
now?: Date;
|
|
772
|
+
}): Promise<KbCatalogResult>;
|
|
523
773
|
/** A bounded neighbourhood around one record. See `pack.ts`. */
|
|
524
774
|
pack(bundlePath: string, rootId: string, options?: KbPackOptions): Promise<KbPackResult>;
|
|
525
775
|
/**
|
|
@@ -641,6 +891,7 @@ declare enum Fault {
|
|
|
641
891
|
declare enum ErrorTypes {
|
|
642
892
|
KbRecordAlreadyExists = "KbRecordAlreadyExists",
|
|
643
893
|
KbInvalidConceptId = "KbInvalidConceptId",
|
|
894
|
+
KbMissingFlagValue = "KbMissingFlagValue",
|
|
644
895
|
KbPackBudgetExceeded = "KbPackBudgetExceeded",
|
|
645
896
|
KbRecordNotFound = "KbRecordNotFound",
|
|
646
897
|
KbSelfVerification = "KbSelfVerification",
|
|
@@ -707,6 +958,18 @@ declare class KbPackBudgetExceededError extends BaseError {
|
|
|
707
958
|
readonly excluded: string[];
|
|
708
959
|
constructor(recordCount: number, approxTokens: number, budgetTokens: number, excluded: string[]);
|
|
709
960
|
}
|
|
961
|
+
/**
|
|
962
|
+
* A flag that takes a value, given none.
|
|
963
|
+
*
|
|
964
|
+
* `strauss-kb load --budget` used to read the next argv entry, find
|
|
965
|
+
* nothing, and quietly fall back to the default — so a caller who meant to
|
|
966
|
+
* raise a ceiling got the ceiling they were trying to move, and a typo looked
|
|
967
|
+
* exactly like success. Refusing is the only way that stays visible.
|
|
968
|
+
*/
|
|
969
|
+
declare class KbMissingFlagValueError extends BaseError {
|
|
970
|
+
readonly flag: string;
|
|
971
|
+
constructor(flag: string);
|
|
972
|
+
}
|
|
710
973
|
declare class KbInvalidConceptIdError extends BaseError {
|
|
711
974
|
constructor(message: string, details: Record<string, string>);
|
|
712
975
|
}
|
|
@@ -742,6 +1005,11 @@ declare const composeInputSchema: z.ZodObject<{
|
|
|
742
1005
|
anchors: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
743
1006
|
file: z.ZodString;
|
|
744
1007
|
symbol: z.ZodOptional<z.ZodString>;
|
|
1008
|
+
repo: z.ZodOptional<z.ZodString>;
|
|
1009
|
+
ref: z.ZodOptional<z.ZodString>;
|
|
1010
|
+
hash: z.ZodOptional<z.ZodString>;
|
|
1011
|
+
resolved_at: z.ZodOptional<z.ZodString>;
|
|
1012
|
+
lines: z.ZodOptional<z.ZodNumber>;
|
|
745
1013
|
}, z.core.$strict>>>;
|
|
746
1014
|
sources: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
747
1015
|
id: z.ZodString;
|
|
@@ -1181,9 +1449,10 @@ declare function validateBundle(records: KbRecord[]): KbValidationProblem[];
|
|
|
1181
1449
|
* decay silently, because a stale record reads exactly like a live one and a
|
|
1182
1450
|
* question nobody answered reads exactly like one nobody asked.
|
|
1183
1451
|
*
|
|
1184
|
-
* Grouped and counted rather than merged into one list: the
|
|
1185
|
-
*
|
|
1186
|
-
* and a flat list of "problems" would leave the reader sorting
|
|
1452
|
+
* Grouped and counted rather than merged into one list: the eight checks are
|
|
1453
|
+
* eight different repairs — re-verify, re-date, answer, link, supersede, or
|
|
1454
|
+
* re-anchor — and a flat list of "problems" would leave the reader sorting
|
|
1455
|
+
* them again.
|
|
1187
1456
|
*
|
|
1188
1457
|
* Every group is emitted even when empty. A check that found nothing and a
|
|
1189
1458
|
* check that never ran look identical in a report that only lists findings,
|
|
@@ -1192,7 +1461,7 @@ declare function validateBundle(records: KbRecord[]): KbValidationProblem[];
|
|
|
1192
1461
|
declare const DEFAULT_EXPIRING_DAYS = 30;
|
|
1193
1462
|
declare const DEFAULT_UNVERIFIED_DAYS = 90;
|
|
1194
1463
|
declare const DEFAULT_AGING_DAYS = 90;
|
|
1195
|
-
declare const KB_DOCTOR_CHECKS: readonly ["expired", "expiring", "unverified", "aging", "orphaned", "broken-supersession", "superseded-but-cited"];
|
|
1464
|
+
declare const KB_DOCTOR_CHECKS: readonly ["expired", "expiring", "unverified", "aging", "orphaned", "broken-supersession", "superseded-but-cited", "drifted"];
|
|
1196
1465
|
type KbDoctorCheck = (typeof KB_DOCTOR_CHECKS)[number];
|
|
1197
1466
|
type KbDoctorFinding = {
|
|
1198
1467
|
conceptId: string;
|
|
@@ -1217,7 +1486,7 @@ type KbDoctorReport = {
|
|
|
1217
1486
|
recordCount: number;
|
|
1218
1487
|
thresholds: KbDoctorThresholds;
|
|
1219
1488
|
counts: Record<KbDoctorCheck, number>;
|
|
1220
|
-
/** All
|
|
1489
|
+
/** All eight, in `KB_DOCTOR_CHECKS` order, empty ones included. */
|
|
1221
1490
|
groups: KbDoctorGroup[];
|
|
1222
1491
|
findingCount: number;
|
|
1223
1492
|
healthy: boolean;
|
|
@@ -1230,6 +1499,13 @@ type KbDoctorOptions = {
|
|
|
1230
1499
|
/** How long `open` or `proposed` may stand before `aging` reports it. */
|
|
1231
1500
|
agingDays?: number;
|
|
1232
1501
|
now?: Date;
|
|
1502
|
+
/**
|
|
1503
|
+
* Anchor drift, precomputed by the caller. `doctor` stays pure and sync for
|
|
1504
|
+
* the same reason `adjudicate` does — the filesystem work of re-resolving
|
|
1505
|
+
* anchors belongs to `detectAnchorDrift`, and a sweep with no map simply
|
|
1506
|
+
* reports the `drifted` check as clean rather than half-running it.
|
|
1507
|
+
*/
|
|
1508
|
+
anchorDrift?: Map<string, KbAnchorDriftEntry[]>;
|
|
1233
1509
|
};
|
|
1234
1510
|
declare function doctor(bundle: KbRecord[], options?: KbDoctorOptions): KbDoctorReport;
|
|
1235
1511
|
|
|
@@ -1277,6 +1553,11 @@ declare const decisionInputSchema: z.ZodObject<{
|
|
|
1277
1553
|
anchors: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
1278
1554
|
file: z.ZodString;
|
|
1279
1555
|
symbol: z.ZodOptional<z.ZodString>;
|
|
1556
|
+
repo: z.ZodOptional<z.ZodString>;
|
|
1557
|
+
ref: z.ZodOptional<z.ZodString>;
|
|
1558
|
+
hash: z.ZodOptional<z.ZodString>;
|
|
1559
|
+
resolved_at: z.ZodOptional<z.ZodString>;
|
|
1560
|
+
lines: z.ZodOptional<z.ZodNumber>;
|
|
1280
1561
|
}, z.core.$strict>>>;
|
|
1281
1562
|
verify: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
1282
1563
|
relatedConceptIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
@@ -1511,4 +1792,4 @@ declare function parseMarkdownWithFrontmatter<S extends z.ZodType>(text: string,
|
|
|
1511
1792
|
frontmatter: ReturnType<S["safeParse"]>;
|
|
1512
1793
|
};
|
|
1513
1794
|
|
|
1514
|
-
export { BaseError, CONTEXT_BEGIN, CONTEXT_END, CONTEXT_PROFILES, type ComposeInput, type ComposedRecord, DECISION_TYPE, DEFAULT_AGING_DAYS, DEFAULT_EXPIRING_DAYS, DEFAULT_LOAD_BUDGET, DEFAULT_PACK_HOPS, DEFAULT_PACK_MAX_NODES, DEFAULT_UNVERIFIED_DAYS, type DecisionInput, type DiffFile, type DiffHunk, type DiffMatch, type ErrorDetails, type ErrorProps, ErrorTypes, Fault, INDEX_FILE, KB_COMMANDS, KB_COMMANDS_BY_NAME, KB_CONCEPT_ID_PATTERN, KB_CONFIDENCES, KB_DIR, KB_DOCTOR_CHECKS, KB_EDGE_KINDS, KB_MATERIALITIES, KB_RECORD_STATUSES, KB_RECORD_TYPES, KB_SLUG_PATTERN, type KbActorStamp, type KbAdjudicated, type KbAnchor, KbBaseFrozenError, type KbCommand, type KbCommandContext, type KbContextBudgets, type KbContextOptions, type KbContextResult, type KbDoctorCheck, type KbDoctorFinding, type KbDoctorGroup, type KbDoctorOptions, type KbDoctorReport, type KbDoctorThresholds, type KbEdgeKind, KbInvalidConceptIdError, type KbLoadResult, type KbLogEntry, type KbLogReadResult, type KbLogger, type KbMergedPin, type KbMergedPins, type KbNeighbour, KbPackBudgetExceededError, type KbPackOptions, type KbPackResult, type KbPackedRecord, type KbPin, type KbPinLayer, type KbPinOptions, type KbPinResult, type KbPinStatus, KbPinsMalformedError, type KbPinsManifest, type KbRecord, KbRecordAlreadyExistsError, type KbRecordFrontmatter, KbRecordNotFoundError, type KbRecordStatus, type KbRecordType, type KbRecordTypeSpec, type KbSearchLogger, KbSelfVerificationError, type KbSource, type KbStanding, KbStore, type KbSupersededStub, type KbSyncResult, type KbTraceEdge, type KbTraceOptions, type KbTraceStep, type KbValidationProblem, type KbVerifiedEvent, type KbWarning, KbWriteConflictError, type KbWriteInput, LOG_FILE, type MatchOptions, NO_DECISION_SLUG, PINS_FILE, PINS_LOCAL_FILE, PIN_LAYERS, type QmdModule, RECORD_TYPES, SEARCH_INDEX_FILE, type SearchHit, type SearchOptions, type SymbolRange, TRACE_EDGES, adjudicate, assertBaseNotFrozen, buildContext, composeDecisionRecord, composeInputSchema, composeNoDecisionRecord, composeRecord, contextProfileBudgets, createKbMcpServer, decisionInputSchema, doctor, edgeNeighbours, indexIsStale, isKbRecordType, isNoDecisionRecord, kbActorStampSchema, kbAnchorSchema, kbConceptIdSchema, kbJsonSchemas, kbLogEntrySchema, kbRecordFrontmatterSchema, kbSourceSchema, kbVerifiedEventSchema, listPins, loadQmd, matchToDiff, mergedContextBudgets, neighbours, pack, parseLog, parseMarkdownWithFrontmatter, pinBase, readMergedPins, readPinsLayer, renderIndex, renderIndexLine, renderLogEntry, resolveHeads, resolveHits, resolvePinPath, runKbCli, runKbMcpServer, searchBase, selectDecisions, splitMarkdownFrontmatter, stringifyMarkdownWithFrontmatter, syncInstructions, toHookJson, trace, unpinBase, validateBundle };
|
|
1795
|
+
export { type AnchorResolver, BaseError, CONTEXT_BEGIN, CONTEXT_END, CONTEXT_PROFILES, type ComposeInput, type ComposedRecord, DECISION_TYPE, DEFAULT_AGING_DAYS, DEFAULT_EXPIRING_DAYS, DEFAULT_LOAD_BUDGET, DEFAULT_PACK_HOPS, DEFAULT_PACK_MAX_NODES, DEFAULT_UNVERIFIED_DAYS, type DecisionInput, type DiffFile, type DiffHunk, type DiffMatch, type ErrorDetails, type ErrorProps, ErrorTypes, Fault, INDEX_FILE, KB_COMMANDS, KB_COMMANDS_BY_NAME, KB_CONCEPT_ID_PATTERN, KB_CONFIDENCES, KB_DIR, KB_DOCTOR_CHECKS, KB_EDGE_KINDS, KB_MATERIALITIES, KB_RECORD_STATUSES, KB_RECORD_TYPES, KB_SLUG_PATTERN, type KbActorStamp, type KbAdjudicated, type KbAnchor, type KbAnchorDriftEntry, KbBaseFrozenError, type KbCatalogEntry, type KbCatalogResult, type KbCommand, type KbCommandContext, type KbContextBudgets, type KbContextOptions, type KbContextResult, type KbDoctorCheck, type KbDoctorFinding, type KbDoctorGroup, type KbDoctorOptions, type KbDoctorReport, type KbDoctorThresholds, type KbEdgeKind, KbInvalidConceptIdError, type KbLoadResult, type KbLogEntry, type KbLogReadResult, type KbLogger, type KbMergedPin, type KbMergedPins, KbMissingFlagValueError, type KbNeighbour, KbPackBudgetExceededError, type KbPackOptions, type KbPackResult, type KbPackedRecord, type KbPin, type KbPinLayer, type KbPinOptions, type KbPinResult, type KbPinStatus, KbPinsMalformedError, type KbPinsManifest, type KbRecord, KbRecordAlreadyExistsError, type KbRecordFrontmatter, KbRecordNotFoundError, type KbRecordStatus, type KbRecordType, type KbRecordTypeSpec, type KbSearchLogger, KbSelfVerificationError, type KbSource, type KbStanding, KbStore, type KbSupersededStub, type KbSyncResult, type KbTraceEdge, type KbTraceOptions, type KbTraceStep, type KbValidationProblem, type KbVerifiedEvent, type KbWarning, KbWriteConflictError, type KbWriteInput, LOG_FILE, type MatchOptions, NO_DECISION_SLUG, PINS_FILE, PINS_LOCAL_FILE, PIN_LAYERS, type QmdModule, RECORD_TYPES, type ResolvedSymbol, SEARCH_INDEX_FILE, type SearchHit, type SearchOptions, type SymbolRange, TRACE_EDGES, adjudicate, anchorFilePath, assertBaseNotFrozen, buildContext, catalog, composeDecisionRecord, composeInputSchema, composeNoDecisionRecord, composeRecord, contextProfileBudgets, createKbMcpServer, decisionInputSchema, detectAnchorDrift, doctor, edgeNeighbours, hashAnchorText, indexIsStale, isKbRecordType, isNoDecisionRecord, kbActorStampSchema, kbAnchorSchema, kbConceptIdSchema, kbJsonSchemas, kbLogEntrySchema, kbRecordFrontmatterSchema, kbSourceSchema, kbVerifiedEventSchema, listPins, loadQmd, matchToDiff, mergedContextBudgets, neighbours, pack, parseLog, parseMarkdownWithFrontmatter, pinBase, readMergedPins, readPinsLayer, regexResolver, renderCatalogLine, renderIndex, renderIndexLine, renderLogEntry, resolveAnchor, resolveHeads, resolveHits, resolvePinPath, runKbCli, runKbMcpServer, searchBase, selectDecisions, splitMarkdownFrontmatter, stringifyMarkdownWithFrontmatter, syncInstructions, toHookJson, trace, unpinBase, validateBundle };
|