daftari 3.17.0 → 3.19.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/CHANGELOG.md +46 -0
- package/README.md +3 -3
- package/dist/access/rbac.d.ts.map +1 -1
- package/dist/access/rbac.js +3 -1
- package/dist/access/rbac.js.map +1 -1
- package/dist/asof/git-read.d.ts.map +1 -1
- package/dist/asof/git-read.js +11 -9
- package/dist/asof/git-read.js.map +1 -1
- package/dist/asof/index.d.ts.map +1 -1
- package/dist/asof/index.js +3 -1
- package/dist/asof/index.js.map +1 -1
- package/dist/asof/report.d.ts.map +1 -1
- package/dist/asof/report.js +5 -3
- package/dist/asof/report.js.map +1 -1
- package/dist/asof/snapshot.d.ts +4 -3
- package/dist/asof/snapshot.d.ts.map +1 -1
- package/dist/asof/snapshot.js +44 -24
- package/dist/asof/snapshot.js.map +1 -1
- package/dist/board/ledger.d.ts.map +1 -1
- package/dist/board/ledger.js +1 -0
- package/dist/board/ledger.js.map +1 -1
- package/dist/board/sources/index.d.ts.map +1 -1
- package/dist/board/sources/index.js +2 -1
- package/dist/board/sources/index.js.map +1 -1
- package/dist/board/sources/lint.d.ts.map +1 -1
- package/dist/board/sources/lint.js +3 -1
- package/dist/board/sources/lint.js.map +1 -1
- package/dist/board/sources/staleness.d.ts +1 -0
- package/dist/board/sources/staleness.d.ts.map +1 -1
- package/dist/board/sources/staleness.js +101 -9
- package/dist/board/sources/staleness.js.map +1 -1
- package/dist/board/sources/staleness.test.js +27 -0
- package/dist/board/sources/staleness.test.js.map +1 -1
- package/dist/board/types.d.ts +7 -0
- package/dist/board/types.d.ts.map +1 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +9 -2
- package/dist/cli.js.map +1 -1
- package/dist/consolidate/constants.d.ts.map +1 -1
- package/dist/consolidate/constants.js +6 -1
- package/dist/consolidate/constants.js.map +1 -1
- package/dist/consolidate/index.d.ts.map +1 -1
- package/dist/consolidate/index.js +1 -1
- package/dist/consolidate/index.js.map +1 -1
- package/dist/court/index.d.ts.map +1 -1
- package/dist/court/index.js +8 -1
- package/dist/court/index.js.map +1 -1
- package/dist/curation/chains.d.ts +21 -0
- package/dist/curation/chains.d.ts.map +1 -0
- package/dist/curation/chains.js +151 -0
- package/dist/curation/chains.js.map +1 -0
- package/dist/curation/governance-journals.d.ts +2 -0
- package/dist/curation/governance-journals.d.ts.map +1 -0
- package/dist/curation/governance-journals.js +36 -0
- package/dist/curation/governance-journals.js.map +1 -0
- package/dist/curation/grounding.d.ts +42 -0
- package/dist/curation/grounding.d.ts.map +1 -0
- package/dist/curation/grounding.js +247 -0
- package/dist/curation/grounding.js.map +1 -0
- package/dist/curation/lint-page.d.ts +22 -0
- package/dist/curation/lint-page.d.ts.map +1 -0
- package/dist/curation/lint-page.js +97 -0
- package/dist/curation/lint-page.js.map +1 -0
- package/dist/curation/lint-voice.d.ts.map +1 -1
- package/dist/curation/lint-voice.js +16 -11
- package/dist/curation/lint-voice.js.map +1 -1
- package/dist/curation/lint.d.ts +7 -1
- package/dist/curation/lint.d.ts.map +1 -1
- package/dist/curation/lint.js +85 -25
- package/dist/curation/lint.js.map +1 -1
- package/dist/curation/provenance.d.ts.map +1 -1
- package/dist/curation/provenance.js.map +1 -1
- package/dist/curation/question-candidates.d.ts +27 -0
- package/dist/curation/question-candidates.d.ts.map +1 -0
- package/dist/curation/question-candidates.js +151 -0
- package/dist/curation/question-candidates.js.map +1 -0
- package/dist/curation/questions.d.ts +9 -0
- package/dist/curation/questions.d.ts.map +1 -0
- package/dist/curation/questions.js +44 -0
- package/dist/curation/questions.js.map +1 -0
- package/dist/curation/review-log.d.ts +36 -0
- package/dist/curation/review-log.d.ts.map +1 -0
- package/dist/curation/review-log.js +195 -0
- package/dist/curation/review-log.js.map +1 -0
- package/dist/curation/review-stats.d.ts +39 -0
- package/dist/curation/review-stats.d.ts.map +1 -0
- package/dist/curation/review-stats.js +222 -0
- package/dist/curation/review-stats.js.map +1 -0
- package/dist/curation/review-throughput.d.ts +1 -0
- package/dist/curation/review-throughput.d.ts.map +1 -1
- package/dist/curation/review-throughput.js +1 -1
- package/dist/curation/review-throughput.js.map +1 -1
- package/dist/curation/shadow.d.ts.map +1 -1
- package/dist/curation/shadow.js +2 -0
- package/dist/curation/shadow.js.map +1 -1
- package/dist/curation/source-refs.d.ts +7 -0
- package/dist/curation/source-refs.d.ts.map +1 -1
- package/dist/curation/source-refs.js +46 -1
- package/dist/curation/source-refs.js.map +1 -1
- package/dist/curation/staged-actions.d.ts +12 -3
- package/dist/curation/staged-actions.d.ts.map +1 -1
- package/dist/curation/staged-actions.js +206 -46
- package/dist/curation/staged-actions.js.map +1 -1
- package/dist/curation/staleness.d.ts +6 -0
- package/dist/curation/staleness.d.ts.map +1 -1
- package/dist/curation/staleness.js +41 -0
- package/dist/curation/staleness.js.map +1 -1
- package/dist/curation/structural.d.ts.map +1 -1
- package/dist/curation/structural.js +6 -4
- package/dist/curation/structural.js.map +1 -1
- package/dist/curation/supersede-chains.d.ts +10 -0
- package/dist/curation/supersede-chains.d.ts.map +1 -0
- package/dist/curation/supersede-chains.js +95 -0
- package/dist/curation/supersede-chains.js.map +1 -0
- package/dist/curation/tension-blast.d.ts +5 -1
- package/dist/curation/tension-blast.d.ts.map +1 -1
- package/dist/curation/tension-blast.js +56 -9
- package/dist/curation/tension-blast.js.map +1 -1
- package/dist/curation/tension.d.ts +4 -1
- package/dist/curation/tension.d.ts.map +1 -1
- package/dist/curation/tension.js +48 -18
- package/dist/curation/tension.js.map +1 -1
- package/dist/curation/tier0.d.ts +3 -1
- package/dist/curation/tier0.d.ts.map +1 -1
- package/dist/curation/tier0.js +7 -3
- package/dist/curation/tier0.js.map +1 -1
- package/dist/curation/vault-docs.js +4 -4
- package/dist/curation/vault-docs.js.map +1 -1
- package/dist/distill/citation-check.d.ts +29 -0
- package/dist/distill/citation-check.d.ts.map +1 -0
- package/dist/distill/citation-check.js +109 -0
- package/dist/distill/citation-check.js.map +1 -0
- package/dist/distill/cli.d.ts +1 -1
- package/dist/distill/cli.d.ts.map +1 -1
- package/dist/distill/cli.js +127 -16
- package/dist/distill/cli.js.map +1 -1
- package/dist/distill/cost.d.ts +7 -3
- package/dist/distill/cost.d.ts.map +1 -1
- package/dist/distill/cost.js.map +1 -1
- package/dist/distill/extract.d.ts +38 -1
- package/dist/distill/extract.d.ts.map +1 -1
- package/dist/distill/extract.js +48 -6
- package/dist/distill/extract.js.map +1 -1
- package/dist/distill/index.d.ts +1 -1
- package/dist/distill/index.d.ts.map +1 -1
- package/dist/distill/index.js +1 -1
- package/dist/distill/index.js.map +1 -1
- package/dist/distill/propose.d.ts.map +1 -1
- package/dist/distill/propose.js +23 -0
- package/dist/distill/propose.js.map +1 -1
- package/dist/distill/receipt-store.d.ts.map +1 -1
- package/dist/distill/receipt-store.js +4 -3
- package/dist/distill/receipt-store.js.map +1 -1
- package/dist/distill/state.d.ts +39 -0
- package/dist/distill/state.d.ts.map +1 -1
- package/dist/distill/state.js +84 -7
- package/dist/distill/state.js.map +1 -1
- package/dist/eval/index.js.map +1 -1
- package/dist/eval/llm-openrouter.d.ts.map +1 -1
- package/dist/eval/llm-openrouter.js +6 -4
- package/dist/eval/llm-openrouter.js.map +1 -1
- package/dist/eval/llm.d.ts +2 -0
- package/dist/eval/llm.d.ts.map +1 -1
- package/dist/eval/llm.js +29 -4
- package/dist/eval/llm.js.map +1 -1
- package/dist/eval/tool-surface.d.ts.map +1 -1
- package/dist/eval/tool-surface.js +4 -1
- package/dist/eval/tool-surface.js.map +1 -1
- package/dist/federation/classification.d.ts.map +1 -1
- package/dist/federation/classification.js +4 -0
- package/dist/federation/classification.js.map +1 -1
- package/dist/federation/mounts.d.ts.map +1 -1
- package/dist/federation/mounts.js +3 -2
- package/dist/federation/mounts.js.map +1 -1
- package/dist/fence/detect.js +1 -1
- package/dist/fence/detect.js.map +1 -1
- package/dist/frontmatter/schema.d.ts.map +1 -1
- package/dist/frontmatter/schema.js +20 -0
- package/dist/frontmatter/schema.js.map +1 -1
- package/dist/frontmatter/types.d.ts +4 -1
- package/dist/frontmatter/types.d.ts.map +1 -1
- package/dist/frontmatter/types.js +3 -0
- package/dist/frontmatter/types.js.map +1 -1
- package/dist/import/langgraph-store.d.ts +2 -1
- package/dist/import/langgraph-store.d.ts.map +1 -1
- package/dist/import/langgraph-store.js +23 -4
- package/dist/import/langgraph-store.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +27 -10
- package/dist/index.js.map +1 -1
- package/dist/integrations/distill.d.ts.map +1 -1
- package/dist/integrations/distill.js +5 -3
- package/dist/integrations/distill.js.map +1 -1
- package/dist/interview/index.d.ts.map +1 -1
- package/dist/interview/index.js +7 -1
- package/dist/interview/index.js.map +1 -1
- package/dist/interview/questions.d.ts +1 -1
- package/dist/interview/questions.d.ts.map +1 -1
- package/dist/interview/questions.js +6 -39
- package/dist/interview/questions.js.map +1 -1
- package/dist/interview/transcript.d.ts +2 -0
- package/dist/interview/transcript.d.ts.map +1 -1
- package/dist/interview/transcript.js +19 -5
- package/dist/interview/transcript.js.map +1 -1
- package/dist/lifecycle/lock.d.ts +19 -4
- package/dist/lifecycle/lock.d.ts.map +1 -1
- package/dist/lifecycle/lock.js +760 -171
- package/dist/lifecycle/lock.js.map +1 -1
- package/dist/okf/import.d.ts.map +1 -1
- package/dist/okf/import.js +15 -3
- package/dist/okf/import.js.map +1 -1
- package/dist/search/amended-by.d.ts +45 -0
- package/dist/search/amended-by.d.ts.map +1 -0
- package/dist/search/amended-by.js +62 -0
- package/dist/search/amended-by.js.map +1 -0
- package/dist/search/hybrid.d.ts +5 -0
- package/dist/search/hybrid.d.ts.map +1 -1
- package/dist/search/hybrid.js.map +1 -1
- package/dist/search/reindex.d.ts +2 -0
- package/dist/search/reindex.d.ts.map +1 -1
- package/dist/search/reindex.js +44 -12
- package/dist/search/reindex.js.map +1 -1
- package/dist/search/watcher.d.ts +2 -1
- package/dist/search/watcher.d.ts.map +1 -1
- package/dist/search/watcher.js +11 -19
- package/dist/search/watcher.js.map +1 -1
- package/dist/serve/index.d.ts.map +1 -1
- package/dist/serve/index.js +21 -10
- package/dist/serve/index.js.map +1 -1
- package/dist/serve/session.d.ts +3 -1
- package/dist/serve/session.d.ts.map +1 -1
- package/dist/serve/session.js +32 -4
- package/dist/serve/session.js.map +1 -1
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +10 -1
- package/dist/server.js.map +1 -1
- package/dist/sleep/cycle.d.ts +2 -0
- package/dist/sleep/cycle.d.ts.map +1 -1
- package/dist/sleep/cycle.js +65 -35
- package/dist/sleep/cycle.js.map +1 -1
- package/dist/sleep/index.d.ts.map +1 -1
- package/dist/sleep/index.js +1 -1
- package/dist/sleep/index.js.map +1 -1
- package/dist/sleep/report.d.ts.map +1 -1
- package/dist/sleep/report.js +3 -2
- package/dist/sleep/report.js.map +1 -1
- package/dist/storage/index-db.d.ts +28 -1
- package/dist/storage/index-db.d.ts.map +1 -1
- package/dist/storage/index-db.js +82 -23
- package/dist/storage/index-db.js.map +1 -1
- package/dist/storage/local.d.ts +6 -2
- package/dist/storage/local.d.ts.map +1 -1
- package/dist/storage/local.js +45 -7
- package/dist/storage/local.js.map +1 -1
- package/dist/storage/sync.d.ts +1 -0
- package/dist/storage/sync.d.ts.map +1 -1
- package/dist/storage/sync.js +31 -6
- package/dist/storage/sync.js.map +1 -1
- package/dist/tools/board.d.ts +1 -0
- package/dist/tools/board.d.ts.map +1 -1
- package/dist/tools/board.js +27 -2
- package/dist/tools/board.js.map +1 -1
- package/dist/tools/board.test.js +4 -2
- package/dist/tools/board.test.js.map +1 -1
- package/dist/tools/chains.d.ts +11 -0
- package/dist/tools/chains.d.ts.map +1 -0
- package/dist/tools/chains.js +133 -0
- package/dist/tools/chains.js.map +1 -0
- package/dist/tools/curation.d.ts +6 -1
- package/dist/tools/curation.d.ts.map +1 -1
- package/dist/tools/curation.js +114 -69
- package/dist/tools/curation.js.map +1 -1
- package/dist/tools/erase.d.ts.map +1 -1
- package/dist/tools/erase.js +14 -19
- package/dist/tools/erase.js.map +1 -1
- package/dist/tools/positions.d.ts.map +1 -1
- package/dist/tools/positions.js +4 -2
- package/dist/tools/positions.js.map +1 -1
- package/dist/tools/question-candidates.d.ts +11 -0
- package/dist/tools/question-candidates.d.ts.map +1 -0
- package/dist/tools/question-candidates.js +205 -0
- package/dist/tools/question-candidates.js.map +1 -0
- package/dist/tools/read.d.ts +5 -0
- package/dist/tools/read.d.ts.map +1 -1
- package/dist/tools/read.js +39 -12
- package/dist/tools/read.js.map +1 -1
- package/dist/tools/receipt.d.ts +4 -0
- package/dist/tools/receipt.d.ts.map +1 -1
- package/dist/tools/receipt.js +262 -22
- package/dist/tools/receipt.js.map +1 -1
- package/dist/tools/search.d.ts.map +1 -1
- package/dist/tools/search.js +53 -4
- package/dist/tools/search.js.map +1 -1
- package/dist/tools/staged-actions.d.ts +2 -1
- package/dist/tools/staged-actions.d.ts.map +1 -1
- package/dist/tools/staged-actions.js +152 -46
- package/dist/tools/staged-actions.js.map +1 -1
- package/dist/tools/write.d.ts +15 -2
- package/dist/tools/write.d.ts.map +1 -1
- package/dist/tools/write.js +747 -89
- package/dist/tools/write.js.map +1 -1
- package/dist/utils/config.d.ts +10 -2
- package/dist/utils/config.d.ts.map +1 -1
- package/dist/utils/config.js +61 -1
- package/dist/utils/config.js.map +1 -1
- package/dist/utils/git.d.ts +1 -0
- package/dist/utils/git.d.ts.map +1 -1
- package/dist/utils/git.js +18 -0
- package/dist/utils/git.js.map +1 -1
- package/dist/utils/vault-gitignore.d.ts +1 -1
- package/dist/utils/vault-gitignore.d.ts.map +1 -1
- package/dist/utils/vault-gitignore.js +25 -9
- package/dist/utils/vault-gitignore.js.map +1 -1
- package/dist/view/board-page.test.js +1 -1
- package/dist/view/board-page.test.js.map +1 -1
- package/package.json +3 -1
- package/templates/config.yaml +18 -3
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
// Grounding at risk (nlzr) — one-hop upstream-at-risk propagation.
|
|
2
|
+
//
|
|
3
|
+
// A document's grounding is at risk when a vault document it cites in
|
|
4
|
+
// `sources` (one hop up, explicit `vault:` or a legacy string that resolves)
|
|
5
|
+
// is itself in trouble:
|
|
6
|
+
//
|
|
7
|
+
// contested — party to an unresolved tension the caller can see. A
|
|
8
|
+
// contested derives_from edge counts through this: an edge
|
|
9
|
+
// contest always logs a tension (tools/edges.ts).
|
|
10
|
+
// ttl-expired — past its ttl_days since `updated` (computeStaleness, the
|
|
11
|
+
// same clock vault_read's decay banner uses).
|
|
12
|
+
// validity-ended — past its valid_until (computeValidity, half-open).
|
|
13
|
+
// superseded — status superseded, or a superseded_by pointer.
|
|
14
|
+
// retracted — status deprecated or archived.
|
|
15
|
+
//
|
|
16
|
+
// The state is DERIVED, never stored: every surface (vault_receipt,
|
|
17
|
+
// vault_read, vault_search, the sleep wake list, the board) asks this module,
|
|
18
|
+
// so the classification has exactly one definition. Surfaces differ only in
|
|
19
|
+
// how they gather a source's state — the receipt and sleep read frontmatter,
|
|
20
|
+
// read/search read the index — and in the caller's vantage.
|
|
21
|
+
//
|
|
22
|
+
// RBAC: callers pass only sources the caller can read, and only tensions the
|
|
23
|
+
// caller can see. An unreadable source contributes nothing here — no path, no
|
|
24
|
+
// title, no state; the receipt's coarse `cites-unreadable-source` flag stays
|
|
25
|
+
// the only (existing) signal that one exists. One hop only, by design: a
|
|
26
|
+
// source's own sources are its own grounding's business.
|
|
27
|
+
//
|
|
28
|
+
// Advisory and Daftari-authored: no document-supplied string except the
|
|
29
|
+
// vault-relative source path (already visible to the caller) and tension ids
|
|
30
|
+
// is interpolated into `detail`, the banner, or the summary.
|
|
31
|
+
import { canRead } from "../access/rbac.js";
|
|
32
|
+
import { contestedFor } from "../search/contested.js";
|
|
33
|
+
import { outgoingSourceRows } from "../storage/index-db.js";
|
|
34
|
+
import { canonicalRel } from "../utils/paths.js";
|
|
35
|
+
import { resolveVaultSourceRef } from "./source-refs.js";
|
|
36
|
+
import { computeStaleness } from "./staleness.js";
|
|
37
|
+
import { computeValidity } from "./validity.js";
|
|
38
|
+
import { buildPathIndexes } from "./vault-docs.js";
|
|
39
|
+
export const GROUNDING_RISK_KINDS = [
|
|
40
|
+
"contested",
|
|
41
|
+
"ttl-expired",
|
|
42
|
+
"validity-ended",
|
|
43
|
+
"superseded",
|
|
44
|
+
"retracted",
|
|
45
|
+
];
|
|
46
|
+
const MS_PER_DAY = 86_400_000;
|
|
47
|
+
function addDays(dateISO, days) {
|
|
48
|
+
const t = Date.parse(`${dateISO}T00:00:00Z`);
|
|
49
|
+
if (Number.isNaN(t))
|
|
50
|
+
return null;
|
|
51
|
+
return new Date(t + days * MS_PER_DAY).toISOString().slice(0, 10);
|
|
52
|
+
}
|
|
53
|
+
function isRetired(s) {
|
|
54
|
+
return (s.status === "superseded" ||
|
|
55
|
+
s.supersededBy !== null ||
|
|
56
|
+
s.status === "deprecated" ||
|
|
57
|
+
s.status === "archived");
|
|
58
|
+
}
|
|
59
|
+
// The reasons one source puts its dependents at risk, in GROUNDING_RISK_KINDS
|
|
60
|
+
// order. Empty means healthy. A retired source reports its retirement only:
|
|
61
|
+
// a lapsed TTL or interval on a document nobody maintains any more is noise.
|
|
62
|
+
export function sourceRiskReasons(s, now) {
|
|
63
|
+
const out = [];
|
|
64
|
+
if (s.tensionCount > 0) {
|
|
65
|
+
const n = s.tensionCount;
|
|
66
|
+
const ids = s.tensionIds.length > 0 ? `: ${s.tensionIds.join(", ")}` : "";
|
|
67
|
+
out.push({
|
|
68
|
+
source: s.path,
|
|
69
|
+
kind: "contested",
|
|
70
|
+
detail: `contested — party to ${n} unresolved tension${n === 1 ? "" : "s"}${ids}`,
|
|
71
|
+
tensionIds: [...s.tensionIds],
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
if (!isRetired(s)) {
|
|
75
|
+
const st = computeStaleness({ updated: s.updated, ttl_days: s.ttlDays }, now);
|
|
76
|
+
if (st.expired && st.ttlDays !== null) {
|
|
77
|
+
const expiredOn = addDays(s.updated, Math.max(st.ttlDays, 0)) ?? s.updated;
|
|
78
|
+
out.push({
|
|
79
|
+
source: s.path,
|
|
80
|
+
kind: "ttl-expired",
|
|
81
|
+
detail: `past its ${st.ttlDays}d TTL — expired ${expiredOn} (last updated ${s.updated})`,
|
|
82
|
+
expiredOn,
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
const v = computeValidity({ valid_from: s.validFrom, valid_until: s.validUntil }, now.toISOString().slice(0, 10));
|
|
86
|
+
if (v?.state === "expired" && s.validUntil !== null) {
|
|
87
|
+
out.push({
|
|
88
|
+
source: s.path,
|
|
89
|
+
kind: "validity-ended",
|
|
90
|
+
detail: `validity ended ${v.until}`,
|
|
91
|
+
expiredOn: String(v.until),
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
if (s.status === "superseded" || s.supersededBy !== null) {
|
|
96
|
+
out.push({
|
|
97
|
+
source: s.path,
|
|
98
|
+
kind: "superseded",
|
|
99
|
+
detail: "superseded — a newer version of this source exists",
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
if (s.status === "deprecated" || s.status === "archived") {
|
|
103
|
+
out.push({ source: s.path, kind: "retracted", detail: `retracted — status ${s.status}` });
|
|
104
|
+
}
|
|
105
|
+
return out;
|
|
106
|
+
}
|
|
107
|
+
// The banner every read-shaped surface shows. Null-free: callers only render
|
|
108
|
+
// it for an at-risk result.
|
|
109
|
+
function renderBanner(reasons) {
|
|
110
|
+
const head = "⚠ GROUNDING AT RISK — a source this document cites is contested, expired, or " +
|
|
111
|
+
"retracted. Re-verify the claim against its sources before relying on it.";
|
|
112
|
+
return `${head}\n${reasons.map((r) => ` - ${r.source} — ${r.detail}`).join("\n")}`;
|
|
113
|
+
}
|
|
114
|
+
// Aggregates per-source reasons. Null when every source is healthy (the
|
|
115
|
+
// silent baseline every other derived state follows). Reasons are sorted by
|
|
116
|
+
// source path, then kind order, so every surface lists them identically.
|
|
117
|
+
export function assessGrounding(sources, now = new Date()) {
|
|
118
|
+
const reasons = [];
|
|
119
|
+
const seen = new Set();
|
|
120
|
+
for (const s of [...sources].sort((a, b) => a.path.localeCompare(b.path))) {
|
|
121
|
+
if (seen.has(s.path))
|
|
122
|
+
continue;
|
|
123
|
+
seen.add(s.path);
|
|
124
|
+
reasons.push(...sourceRiskReasons(s, now));
|
|
125
|
+
}
|
|
126
|
+
if (reasons.length === 0)
|
|
127
|
+
return null;
|
|
128
|
+
return { reasons, banner: renderBanner(reasons) };
|
|
129
|
+
}
|
|
130
|
+
// One line for compact channels (search summaries, the wake reason):
|
|
131
|
+
// "grounding at risk: <source> — <detail>[; +n more]".
|
|
132
|
+
export function groundingSummary(g) {
|
|
133
|
+
const first = g.reasons[0];
|
|
134
|
+
if (!first)
|
|
135
|
+
return "";
|
|
136
|
+
const more = g.reasons.length - 1;
|
|
137
|
+
return `grounding at risk: ${first.source} — ${first.detail}${more > 0 ? `; +${more} more` : ""}`;
|
|
138
|
+
}
|
|
139
|
+
// The MCP output schema for a GroundingAtRisk value — shared by vault_read,
|
|
140
|
+
// vault_search hits and vault_receipt sources. Lives here, beside the type,
|
|
141
|
+
// so the tools import it without a read.ts <-> search.ts value cycle.
|
|
142
|
+
export const GROUNDING_AT_RISK_SCHEMA = {
|
|
143
|
+
type: "object",
|
|
144
|
+
description: "Grounding at risk: a vault source this document cites one hop up is contested, " +
|
|
145
|
+
"past its TTL or validity, superseded, or retracted. Sources the caller cannot " +
|
|
146
|
+
"read are omitted entirely.",
|
|
147
|
+
properties: {
|
|
148
|
+
reasons: {
|
|
149
|
+
type: "array",
|
|
150
|
+
items: {
|
|
151
|
+
type: "object",
|
|
152
|
+
properties: {
|
|
153
|
+
source: { type: "string", description: "Vault-relative path of the cited source" },
|
|
154
|
+
kind: { type: "string", enum: [...GROUNDING_RISK_KINDS] },
|
|
155
|
+
detail: { type: "string" },
|
|
156
|
+
tensionIds: { type: "array", items: { type: "string" } },
|
|
157
|
+
expiredOn: { type: "string", description: "YYYY-MM-DD" },
|
|
158
|
+
},
|
|
159
|
+
required: ["source", "kind", "detail"],
|
|
160
|
+
},
|
|
161
|
+
},
|
|
162
|
+
banner: { type: "string" },
|
|
163
|
+
},
|
|
164
|
+
required: ["reasons", "banner"],
|
|
165
|
+
};
|
|
166
|
+
export function stateFromFrontmatter(path, fm, tensionIds, tensionCount) {
|
|
167
|
+
return {
|
|
168
|
+
path,
|
|
169
|
+
status: fm.status,
|
|
170
|
+
supersededBy: fm.superseded_by ?? null,
|
|
171
|
+
updated: fm.updated,
|
|
172
|
+
ttlDays: fm.ttl_days ?? null,
|
|
173
|
+
validFrom: fm.valid_from ?? null,
|
|
174
|
+
validUntil: fm.valid_until ?? null,
|
|
175
|
+
tensionIds,
|
|
176
|
+
tensionCount,
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
// Index-backed assessment for the read/search hot path: the cited targets come
|
|
180
|
+
// from the materialized `doc_links` source edges (the same resolution sleep,
|
|
181
|
+
// lint and the receipt use — outgoingEdges), each target's state from its
|
|
182
|
+
// indexed row, and its tensions from the mtime-cached contested join. Cost is
|
|
183
|
+
// one indexed query for the edges plus one row lookup per cited source.
|
|
184
|
+
//
|
|
185
|
+
// RBAC: a target the caller cannot read is skipped before anything about it is
|
|
186
|
+
// looked up; contestedFor already omits tensions whose counterpart is hidden.
|
|
187
|
+
// A target missing from the index (deleted) is skipped too — vanished
|
|
188
|
+
// grounding is the receipt's cites-broken-source and sleep's source-vanished.
|
|
189
|
+
export function groundingFromIndex(vaultRoot, db, path, access, now = new Date()) {
|
|
190
|
+
const states = [];
|
|
191
|
+
for (const row of outgoingSourceRows(db, path)) {
|
|
192
|
+
// The row's own collection is what collectionForPath would resolve (the
|
|
193
|
+
// join guarantees the row exists), so this is sourceReadable's gate.
|
|
194
|
+
if (access && !canRead(access.role, row.collection))
|
|
195
|
+
continue;
|
|
196
|
+
const ct = contestedFor(vaultRoot, db, row.path, access);
|
|
197
|
+
const { collection: _collection, ...state } = row;
|
|
198
|
+
states.push({
|
|
199
|
+
...state,
|
|
200
|
+
tensionIds: (ct?.contested ?? []).flatMap((t) => (t.id ? [t.id] : [])),
|
|
201
|
+
tensionCount: ct?.contestedCount ?? 0,
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
return assessGrounding(states, now);
|
|
205
|
+
}
|
|
206
|
+
// Frontmatter-backed assessment for whole-vault passes (the sleep wake list,
|
|
207
|
+
// the board): one map over the loaded docs and the tension log, then a cheap
|
|
208
|
+
// per-doc lookup. Sources resolve exactly as outgoingEdges resolves them
|
|
209
|
+
// (explicit `vault:` plus legacy strings that name a doc), one hop.
|
|
210
|
+
//
|
|
211
|
+
// `tensions` must already be filtered to what the caller may see, and
|
|
212
|
+
// `readable` (absent = operator vantage, everything readable) narrows both
|
|
213
|
+
// the resolution universe — a hidden doc must not make a basename resolve or
|
|
214
|
+
// go ambiguous, the receipt's rule — and the sources assessed.
|
|
215
|
+
export function groundingAssessor(docs, tensions, opts) {
|
|
216
|
+
const visible = opts.readable ? docs.filter((d) => opts.readable?.(d.path)) : docs;
|
|
217
|
+
const byDocPath = new Map(visible.map((d) => [d.path, d]));
|
|
218
|
+
const { byPath, byBasename } = buildPathIndexes(visible);
|
|
219
|
+
const tensionsByDoc = new Map();
|
|
220
|
+
for (const t of tensions) {
|
|
221
|
+
if (t.resolved)
|
|
222
|
+
continue;
|
|
223
|
+
for (const side of new Set([canonicalRel(t.sourceA), canonicalRel(t.sourceB)])) {
|
|
224
|
+
const entry = tensionsByDoc.get(side) ?? { ids: [], count: 0 };
|
|
225
|
+
entry.count += 1;
|
|
226
|
+
if (t.id)
|
|
227
|
+
entry.ids.push(t.id);
|
|
228
|
+
tensionsByDoc.set(side, entry);
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
return (doc) => {
|
|
232
|
+
const states = [];
|
|
233
|
+
for (const raw of doc.frontmatter.sources ?? []) {
|
|
234
|
+
const ref = resolveVaultSourceRef(raw, doc.path, byPath, byBasename);
|
|
235
|
+
const target = ref.kind === "vault" ? ref.target : null;
|
|
236
|
+
if (target === null || target === doc.path)
|
|
237
|
+
continue;
|
|
238
|
+
const src = byDocPath.get(target);
|
|
239
|
+
if (!src)
|
|
240
|
+
continue;
|
|
241
|
+
const t = tensionsByDoc.get(target);
|
|
242
|
+
states.push(stateFromFrontmatter(target, src.frontmatter, t?.ids ?? [], t?.count ?? 0));
|
|
243
|
+
}
|
|
244
|
+
return assessGrounding(states, opts.now);
|
|
245
|
+
};
|
|
246
|
+
}
|
|
247
|
+
//# sourceMappingURL=grounding.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"grounding.js","sourceRoot":"","sources":["../../src/curation/grounding.ts"],"names":[],"mappings":"AAAA,mEAAmE;AACnE,EAAE;AACF,sEAAsE;AACtE,6EAA6E;AAC7E,wBAAwB;AACxB,EAAE;AACF,0EAA0E;AAC1E,8EAA8E;AAC9E,qEAAqE;AACrE,8EAA8E;AAC9E,iEAAiE;AACjE,wEAAwE;AACxE,oEAAoE;AACpE,oDAAoD;AACpD,EAAE;AACF,oEAAoE;AACpE,8EAA8E;AAC9E,4EAA4E;AAC5E,6EAA6E;AAC7E,4DAA4D;AAC5D,EAAE;AACF,6EAA6E;AAC7E,8EAA8E;AAC9E,6EAA6E;AAC7E,yEAAyE;AACzE,yDAAyD;AACzD,EAAE;AACF,wEAAwE;AACxE,6EAA6E;AAC7E,6DAA6D;AAE7D,OAAO,EAAsB,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAEhE,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAgB,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC1E,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAElD,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G,EAAE,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,CAAC,CAAC;YACrE,MAAM,MAAM,GAAG,GAAG,CAAC,IAAI,KAAK,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC;YACxD,IAAI,MAAM,KAAK,IAAI,IAAI,MAAM,KAAK,GAAG,CAAC,IAAI;gBAAE,SAAS;YACrD,MAAM,GAAG,GAAG,SAAS,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;YAClC,IAAI,CAAC,GAAG;gBAAE,SAAS;YACnB,MAAM,CAAC,GAAG,aAAa,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;YACpC,MAAM,CAAC,IAAI,CAAC,oBAAoB,CAAC,MAAM,EAAE,GAAG,CAAC,WAAW,EAAE,CAAC,EAAE,GAAG,IAAI,EAAE,EAAE,CAAC,EAAE,KAAK,IAAI,CAAC,CAAC,CAAC,CAAC;QAC1F,CAAC;QACD,OAAO,eAAe,CAAC,MAAM,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC;IAC3C,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { type Result } from "../frontmatter/types.js";
|
|
2
|
+
import { type LintCheckName, type LintFinding, type StagedActionLintItem } from "./lint.js";
|
|
3
|
+
import type { ShadowLintSummary } from "./shadow.js";
|
|
4
|
+
export declare const LINT_PREVIEW_PER_CHECK = 3;
|
|
5
|
+
export declare const LINT_PREVIEW_CHARS = 3500;
|
|
6
|
+
export declare const LINT_PREVIEW_LIST_ITEMS = 2;
|
|
7
|
+
export declare const LINT_PAGE_DEFAULT_LIMIT = 50;
|
|
8
|
+
export interface LintPaging {
|
|
9
|
+
limit: number;
|
|
10
|
+
offset: number;
|
|
11
|
+
}
|
|
12
|
+
export interface LintChecksView {
|
|
13
|
+
checks: Partial<Record<LintCheckName, LintFinding[]>>;
|
|
14
|
+
counts: Partial<Record<LintCheckName, number>>;
|
|
15
|
+
nextOffset: Partial<Record<LintCheckName, number>>;
|
|
16
|
+
}
|
|
17
|
+
export declare function parseLintPaging(args: Record<string, unknown>): Result<LintPaging | null, Error>;
|
|
18
|
+
export declare function pageChecks(reported: Partial<Record<LintCheckName, LintFinding[]>>, { limit, offset }: LintPaging): LintChecksView;
|
|
19
|
+
export declare function previewChecks(reported: Record<LintCheckName, LintFinding[]>): LintChecksView;
|
|
20
|
+
export declare function previewStagedActions(items: StagedActionLintItem[]): StagedActionLintItem[];
|
|
21
|
+
export declare function previewShadowActions(summary: ShadowLintSummary): ShadowLintSummary;
|
|
22
|
+
//# sourceMappingURL=lint-page.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lint-page.d.ts","sourceRoot":"","sources":["../../src/curation/lint-page.ts"],"names":[],"mappings":"AAOA,OAAO,EAAW,KAAK,MAAM,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EAIL,KAAK,aAAa,EAClB,KAAK,WAAW,EAChB,KAAK,oBAAoB,EAE1B,MAAM,WAAW,CAAC;AACnB,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAMrD,eAAO,MAAM,sBAAsB,IAAI,CAAC;AACxC,eAAO,MAAM,kBAAkB,OAAQ,CAAC;AAExC,eAAO,MAAM,uBAAuB,IAAI,CAAC;AACzC,eAAO,MAAM,uBAAuB,KAAK,CAAC;AAE1C,MAAM,WAAW,UAAU;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,aAAa,EAAE,WAAW,EAAE,CAAC,CAAC,CAAC;IAEtD,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,aAAa,EAAE,MAAM,CAAC,CAAC,CAAC;IAE/C,UAAU,EAAE,OAAO,CAAC,MAAM,CAAC,aAAa,EAAE,MAAM,CAAC,CAAC,CAAC;CACpD;AAWD,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,UAAU,GAAG,IAAI,EAAE,KAAK,CAAC,CAO/F;AAGD,wBAAgB,UAAU,CACxB,QAAQ,EAAE,OAAO,CAAC,MAAM,CAAC,aAAa,EAAE,WAAW,EAAE,CAAC,CAAC,EACvD,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,UAAU,GAC5B,cAAc,CAUhB;AAKD,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,CAAC,aAAa,EAAE,WAAW,EAAE,CAAC,GAAG,cAAc,CA4B5F;AAED,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,oBAAoB,EAAE,GAAG,oBAAoB,EAAE,CAI1F;AAED,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,iBAAiB,GAAG,iBAAiB,CAMlF"}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
// How much of a lint report reaches the caller (#644). runLint stays complete —
|
|
2
|
+
// the board and every other internal consumer need all of it — so paging lives
|
|
3
|
+
// here, applied to a finished report. It runs after pathVisible has already
|
|
4
|
+
// shaped that report, which is why it cannot change what a caller may see: a
|
|
5
|
+
// count is the length of the list the caller could already receive, and no
|
|
6
|
+
// offset reaches past it.
|
|
7
|
+
import { err, ok } from "../frontmatter/types.js";
|
|
8
|
+
import { clip, LINT_CHECKS, LINT_SUMMARY_DETAIL_CHARS, TIER0_LINT_CHECKS, } from "./lint.js";
|
|
9
|
+
// A default vault_lint must fit an MCP client's result limit on a real vault
|
|
10
|
+
// (88K observed at 295 documents). Previews are spent against a character
|
|
11
|
+
// budget, not only a per-check cap: details and paths have no length limit, so
|
|
12
|
+
// a count alone could not hold the bound.
|
|
13
|
+
export const LINT_PREVIEW_PER_CHECK = 3;
|
|
14
|
+
export const LINT_PREVIEW_CHARS = 3_500;
|
|
15
|
+
// The staged and shadow lists preview the same way, at the same detail width.
|
|
16
|
+
export const LINT_PREVIEW_LIST_ITEMS = 2;
|
|
17
|
+
export const LINT_PAGE_DEFAULT_LIMIT = 50;
|
|
18
|
+
function parseCount(raw, name) {
|
|
19
|
+
if (raw === undefined || raw === null)
|
|
20
|
+
return ok(null);
|
|
21
|
+
if (typeof raw !== "number" || !Number.isInteger(raw) || raw < 0) {
|
|
22
|
+
return err(new Error(`vault_lint '${name}' must be a non-negative integer`));
|
|
23
|
+
}
|
|
24
|
+
return ok(raw);
|
|
25
|
+
}
|
|
26
|
+
// Null when the caller asked for neither, leaving the mode to the caller.
|
|
27
|
+
export function parseLintPaging(args) {
|
|
28
|
+
const limit = parseCount(args.limit, "limit");
|
|
29
|
+
if (!limit.ok)
|
|
30
|
+
return limit;
|
|
31
|
+
const offset = parseCount(args.offset, "offset");
|
|
32
|
+
if (!offset.ok)
|
|
33
|
+
return offset;
|
|
34
|
+
if (limit.value === null && offset.value === null)
|
|
35
|
+
return ok(null);
|
|
36
|
+
return ok({ limit: limit.value ?? LINT_PAGE_DEFAULT_LIMIT, offset: offset.value ?? 0 });
|
|
37
|
+
}
|
|
38
|
+
// One page of every reported check, findings verbatim.
|
|
39
|
+
export function pageChecks(reported, { limit, offset }) {
|
|
40
|
+
const view = { checks: {}, counts: {}, nextOffset: {} };
|
|
41
|
+
for (const check of LINT_CHECKS) {
|
|
42
|
+
const findings = reported[check];
|
|
43
|
+
if (!findings)
|
|
44
|
+
continue;
|
|
45
|
+
view.checks[check] = findings.slice(offset, offset + limit);
|
|
46
|
+
view.counts[check] = findings.length;
|
|
47
|
+
if (offset + limit < findings.length)
|
|
48
|
+
view.nextOffset[check] = offset + limit;
|
|
49
|
+
}
|
|
50
|
+
return view;
|
|
51
|
+
}
|
|
52
|
+
// The first few findings of every check, details clipped. Filled round-robin,
|
|
53
|
+
// tier-0 first, so a tight budget thins every check rather than starving the
|
|
54
|
+
// last ones, and certain failures are the last to go.
|
|
55
|
+
export function previewChecks(reported) {
|
|
56
|
+
const view = pageChecks(reported, { limit: 0, offset: 0 });
|
|
57
|
+
const order = [
|
|
58
|
+
...TIER0_LINT_CHECKS,
|
|
59
|
+
...LINT_CHECKS.filter((check) => !TIER0_LINT_CHECKS.includes(check)),
|
|
60
|
+
];
|
|
61
|
+
let budget = LINT_PREVIEW_CHARS;
|
|
62
|
+
for (let round = 0; round < LINT_PREVIEW_PER_CHECK && budget > 0; round++) {
|
|
63
|
+
for (const check of order) {
|
|
64
|
+
const finding = reported[check][round];
|
|
65
|
+
if (!finding)
|
|
66
|
+
continue;
|
|
67
|
+
const clipped = {
|
|
68
|
+
path: finding.path,
|
|
69
|
+
detail: clip(finding.detail, LINT_SUMMARY_DETAIL_CHARS),
|
|
70
|
+
};
|
|
71
|
+
budget -= JSON.stringify(clipped).length + 1;
|
|
72
|
+
if (budget < 0)
|
|
73
|
+
break;
|
|
74
|
+
view.checks[check]?.push(clipped);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
view.nextOffset = {};
|
|
78
|
+
for (const check of LINT_CHECKS) {
|
|
79
|
+
const shown = view.checks[check]?.length ?? 0;
|
|
80
|
+
if (shown < reported[check].length)
|
|
81
|
+
view.nextOffset[check] = shown;
|
|
82
|
+
}
|
|
83
|
+
return view;
|
|
84
|
+
}
|
|
85
|
+
export function previewStagedActions(items) {
|
|
86
|
+
return items
|
|
87
|
+
.slice(0, LINT_PREVIEW_LIST_ITEMS)
|
|
88
|
+
.map((item) => ({ ...item, rationale: clip(item.rationale, LINT_SUMMARY_DETAIL_CHARS) }));
|
|
89
|
+
}
|
|
90
|
+
export function previewShadowActions(summary) {
|
|
91
|
+
return {
|
|
92
|
+
...summary,
|
|
93
|
+
recentGated: summary.recentGated.slice(0, LINT_PREVIEW_LIST_ITEMS),
|
|
94
|
+
gatedSurfaced: summary.gatedSurfaced.slice(0, LINT_PREVIEW_LIST_ITEMS),
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
//# sourceMappingURL=lint-page.js.map
|
|
@@ -0,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AAC;IACrE,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED,MAAM,UAAU,oBAAoB,CAAC,KAA6B;IAChE,OAAO,KAAK;SACT,KAAK,CAAC,CAAC,EAAE,uBAAuB,CAAC;SACjC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,IAAI,EAAE,SAAS,EAAE,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,yBAAyB,CAAC,EAAE,CAAC,CAAC,CAAC;AAC9F,CAAC;AAED,MAAM,UAAU,oBAAoB,CAAC,OAA0B;IAC7D,OAAO;QACL,GAAG,OAAO;QACV,WAAW,EAAE,OAAO,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,EAAE,uBAAuB,CAAC;QAClE,aAAa,EAAE,OAAO,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,EAAE,uBAAuB,CAAC;KACvE,CAAC;AACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lint-voice.d.ts","sourceRoot":"","sources":["../../src/curation/lint-voice.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"lint-voice.d.ts","sourceRoot":"","sources":["../../src/curation/lint-voice.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AA2C5D,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,eAAe,GAAG,MAAM,CA6DlE"}
|
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
// orders findings with the SAME shared constants the plain summary uses
|
|
7
7
|
// (TIER0_LINT_CHECKS, LINT_SUMMARY_TOP_FINDINGS), so the two voices surface the
|
|
8
8
|
// same documents — the voice changes wording, never what is flagged. It is a
|
|
9
|
-
// pure function of its input: no I/O, no LLM, no randomness, no clock. The
|
|
10
|
-
// structured
|
|
9
|
+
// pure function of its input: no I/O, no LLM, no randomness, no clock. The
|
|
10
|
+
// structured channel is untouched by the choice of voice.
|
|
11
11
|
import { clip, LINT_CHECKS, LINT_SUMMARY_DETAIL_CHARS, LINT_SUMMARY_TOP_FINDINGS, TIER0_LINT_CHECKS, } from "./lint.js";
|
|
12
12
|
// One clause per check, in the ledger-keeper's register. Exhaustive by type: a
|
|
13
13
|
// new entry in LINT_CHECKS will not compile until it is given a clause here, so
|
|
@@ -29,6 +29,8 @@ const LEDGER_CLAUSE = {
|
|
|
29
29
|
malformedPins: "carries a code-anchor pin the ledger cannot read",
|
|
30
30
|
verbatimQuoteOverrun: "quotes its source verbatim past the compiler's budget",
|
|
31
31
|
unverifiableSourceRefs: "cites evidence the ledger cannot presently verify",
|
|
32
|
+
supersedeChains: "follows a line of succession that never reaches a current entry",
|
|
33
|
+
danglingAmends: "claims to amend what cannot be found",
|
|
32
34
|
};
|
|
33
35
|
// "1 matter" / "3 matters" — a small deterministic pluralizer for the copy.
|
|
34
36
|
function count(n, one, many) {
|
|
@@ -43,15 +45,15 @@ export function renderLedgerKeeper(report) {
|
|
|
43
45
|
let advisory = 0;
|
|
44
46
|
const flat = [];
|
|
45
47
|
for (const check of LINT_CHECKS) {
|
|
46
|
-
const
|
|
47
|
-
if (
|
|
48
|
+
const total = report.counts[check] ?? 0;
|
|
49
|
+
if (total === 0)
|
|
48
50
|
continue;
|
|
49
|
-
perCheck.push(`${check} ${
|
|
51
|
+
perCheck.push(`${check} ${total}`);
|
|
50
52
|
if (TIER0_LINT_CHECKS.includes(check))
|
|
51
|
-
certain +=
|
|
53
|
+
certain += total;
|
|
52
54
|
else
|
|
53
|
-
advisory +=
|
|
54
|
-
for (const finding of
|
|
55
|
+
advisory += total;
|
|
56
|
+
for (const finding of report.checks[check] ?? [])
|
|
55
57
|
flat.push({ check, finding });
|
|
56
58
|
}
|
|
57
59
|
// Certain (tier-0) findings first; stable sort preserves LINT_CHECKS order
|
|
@@ -69,7 +71,7 @@ export function renderLedgerKeeper(report) {
|
|
|
69
71
|
`${h.aging.fresh} fresh, ${h.aging.aging} aging, ${h.aging.stale} past patience; ` +
|
|
70
72
|
`${count(h.clusters.count, "knot", "knots")} (${h.clusters.large} large, ${h.clusters.aged} aged); ` +
|
|
71
73
|
`${count(h.blastRadiusOfStaleTensions, "entry", "entries")} shadowed by a stale dispute.`,
|
|
72
|
-
`Awaiting your ruling: ${report.
|
|
74
|
+
`Awaiting your ruling: ${report.stagedActionsTotal} staged, ` +
|
|
73
75
|
`${report.reviewThroughput.lifetime.expired} lapsed unread; ` +
|
|
74
76
|
`${report.shadowActions.total} write(s) watched in shadow, ` +
|
|
75
77
|
`${report.shadowActions.gated} the budget would have stayed; ` +
|
|
@@ -78,15 +80,18 @@ export function renderLedgerKeeper(report) {
|
|
|
78
80
|
];
|
|
79
81
|
const top = flat.slice(0, LINT_SUMMARY_TOP_FINDINGS);
|
|
80
82
|
if (top.length > 0) {
|
|
81
|
-
lines.push(`The ${count(top.length, "entry", "entries")} most wanting your eye, of ${
|
|
83
|
+
lines.push(`The ${count(top.length, "entry", "entries")} most wanting your eye, of ${report.totalFindings}:`);
|
|
82
84
|
for (const { check, finding } of top) {
|
|
83
85
|
lines.push(` Entry ${finding.path} ${LEDGER_CLAUSE[check]}. ` +
|
|
84
86
|
`(${clip(finding.detail, LINT_SUMMARY_DETAIL_CHARS)})`);
|
|
85
87
|
}
|
|
86
88
|
}
|
|
87
|
-
else {
|
|
89
|
+
else if (report.totalFindings === 0) {
|
|
88
90
|
lines.push("Nothing demands correction today. I have recorded as much. — the daftari");
|
|
89
91
|
}
|
|
92
|
+
if (Object.keys(report.nextOffset).length > 0) {
|
|
93
|
+
lines.push("The ledger runs on: turn its pages with filter, limit and offset, as nextOffset marks.");
|
|
94
|
+
}
|
|
90
95
|
return lines.join("\n");
|
|
91
96
|
}
|
|
92
97
|
//# sourceMappingURL=lint-voice.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lint-voice.js","sourceRoot":"","sources":["../../src/curation/lint-voice.ts"],"names":[],"mappings":"AAAA,8DAA8D;AAC9D,EAAE;AACF,+EAA+E;AAC/E,yEAAyE;AACzE,8EAA8E;AAC9E,wEAAwE;AACxE,gFAAgF;AAChF,6EAA6E;AAC7E,
|
|
1
|
+
{"version":3,"file":"lint-voice.js","sourceRoot":"","sources":["../../src/curation/lint-voice.ts"],"names":[],"mappings":"AAAA,8DAA8D;AAC9D,EAAE;AACF,+EAA+E;AAC/E,yEAAyE;AACzE,8EAA8E;AAC9E,wEAAwE;AACxE,gFAAgF;AAChF,6EAA6E;AAC7E,2EAA2E;AAC3E,0DAA0D;AAK1D,OAAO,EACL,IAAI,EACJ,WAAW,EACX,yBAAyB,EACzB,yBAAyB,EAGzB,iBAAiB,GAClB,MAAM,WAAW,CAAC;AAEnB,+EAA+E;AAC/E,gFAAgF;AAChF,mDAAmD;AACnD,MAAM,aAAa,GAAkC;IACnD,UAAU,EAAE,6CAA6C;IACzD,WAAW,EAAE,oCAAoC;IACjD,SAAS,EAAE,uCAAuC;IAClD,qBAAqB,EAAE,8BAA8B;IACrD,kBAAkB,EAAE,+CAA+C;IACnE,mBAAmB,EAAE,6CAA6C;IAClE,aAAa,EAAE,iCAAiC;IAChD,gBAAgB,EAAE,qCAAqC;IACvD,kBAAkB,EAAE,+BAA+B;IACnD,aAAa,EAAE,sCAAsC;IACrD,WAAW,EAAE,oCAAoC;IACjD,iBAAiB,EAAE,+CAA+C;IAClE,iBAAiB,EAAE,qDAAqD;IACxE,aAAa,EAAE,kDAAkD;IACjE,oBAAoB,EAAE,uDAAuD;IAC7E,sBAAsB,EAAE,mDAAmD;IAC3E,eAAe,EAAE,iEAAiE;IAClF,cAAc,EAAE,sCAAsC;CACvD,CAAC;AAEF,4EAA4E;AAC5E,SAAS,KAAK,CAAC,CAAS,EAAE,GAAW,EAAE,IAAY;IACjD,OAAO,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,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,MAAM,CAAC,aAAa,GAAG,CAClG,CAAC;QACF,KAAK,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,GAAG,EAAE,CAAC;YACrC,KAAK,CAAC,IAAI,CACR,WAAW,OAAO,CAAC,IAAI,IAAI,aAAa,CAAC,KAAK,CAAC,IAAI;gBACjD,IAAI,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,yBAAyB,CAAC,GAAG,CACzD,CAAC;QACJ,CAAC;IACH,CAAC;SAAM,IAAI,MAAM,CAAC,aAAa,KAAK,CAAC,EAAE,CAAC;QACtC,KAAK,CAAC,IAAI,CAAC,0EAA0E,CAAC,CAAC;IACzF,CAAC;IACD,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC9C,KAAK,CAAC,IAAI,CACR,wFAAwF,CACzF,CAAC;IACJ,CAAC;IAED,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC"}
|
package/dist/curation/lint.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ import { type ShadowLintSummary } from "./shadow.js";
|
|
|
6
6
|
import { type StagedActionLintItem } from "./staged-actions.js";
|
|
7
7
|
export type { StagedActionLintItem } from "./staged-actions.js";
|
|
8
8
|
import { type ResolutionKind, type TensionKind } from "./tension.js";
|
|
9
|
-
export declare const LINT_CHECKS: readonly ["staleFiles", "orphanFiles", "oldDrafts", "stagnantLowConfidence", "retiredStillLinked", "unansweredQuestions", "tierDemotions", "brokenSourceRefs", "lifecycleConflicts", "schemaInvalid", "domainLeaks", "validityConflicts", "positionIntegrity", "malformedPins", "verbatimQuoteOverrun", "unverifiableSourceRefs"];
|
|
9
|
+
export declare const LINT_CHECKS: readonly ["staleFiles", "orphanFiles", "oldDrafts", "stagnantLowConfidence", "retiredStillLinked", "unansweredQuestions", "tierDemotions", "brokenSourceRefs", "lifecycleConflicts", "schemaInvalid", "domainLeaks", "validityConflicts", "positionIntegrity", "malformedPins", "verbatimQuoteOverrun", "unverifiableSourceRefs", "supersedeChains", "danglingAmends"];
|
|
10
10
|
export type LintCheckName = (typeof LINT_CHECKS)[number];
|
|
11
11
|
export interface LintFinding {
|
|
12
12
|
path: string;
|
|
@@ -42,6 +42,10 @@ export interface TensionHealth {
|
|
|
42
42
|
clusters: TensionClustersHealth;
|
|
43
43
|
blastRadiusOfStaleTensions: number;
|
|
44
44
|
}
|
|
45
|
+
export interface OrphanSummary {
|
|
46
|
+
noInboundLink: number;
|
|
47
|
+
nothingRefers: number;
|
|
48
|
+
}
|
|
45
49
|
export interface LintReport {
|
|
46
50
|
generatedAt: string;
|
|
47
51
|
checks: Record<LintCheckName, LintFinding[]>;
|
|
@@ -51,6 +55,7 @@ export interface LintReport {
|
|
|
51
55
|
shadowActions: ShadowLintSummary;
|
|
52
56
|
coverageEquity: CoverageEquitySummary;
|
|
53
57
|
compiledEdgeCoverage: CompiledEdgeCoverageSummary;
|
|
58
|
+
orphanSummary: OrphanSummary;
|
|
54
59
|
reviewThroughput: ReviewThroughputSummary;
|
|
55
60
|
}
|
|
56
61
|
export interface LintOptions {
|
|
@@ -58,6 +63,7 @@ export interface LintOptions {
|
|
|
58
63
|
draftMaxDays?: number;
|
|
59
64
|
lowConfidenceMaxDays?: number;
|
|
60
65
|
pathVisible?: (path: string) => boolean;
|
|
66
|
+
restrictedVantage?: boolean;
|
|
61
67
|
maxVerbatimChars?: number;
|
|
62
68
|
verifyRepoSources?: boolean;
|
|
63
69
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lint.d.ts","sourceRoot":"","sources":["../../src/curation/lint.ts"],"names":[],"mappings":"AASA,OAAO,EAAM,KAAK,MAAM,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"lint.d.ts","sourceRoot":"","sources":["../../src/curation/lint.ts"],"names":[],"mappings":"AASA,OAAO,EAAM,KAAK,MAAM,EAAE,MAAM,y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