daftari 1.31.0 → 2.0.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.
Files changed (239) hide show
  1. package/CHANGELOG.md +179 -1
  2. package/README.md +89 -9
  3. package/dist/access/rbac.d.ts +1 -0
  4. package/dist/access/rbac.d.ts.map +1 -1
  5. package/dist/access/rbac.js +16 -0
  6. package/dist/access/rbac.js.map +1 -1
  7. package/dist/asof/index.d.ts.map +1 -1
  8. package/dist/asof/index.js +23 -2
  9. package/dist/asof/index.js.map +1 -1
  10. package/dist/asof/report.d.ts.map +1 -1
  11. package/dist/asof/report.js +24 -0
  12. package/dist/asof/report.js.map +1 -1
  13. package/dist/asof/snapshot.d.ts +7 -1
  14. package/dist/asof/snapshot.d.ts.map +1 -1
  15. package/dist/asof/snapshot.js +28 -1
  16. package/dist/asof/snapshot.js.map +1 -1
  17. package/dist/backfill/derive.d.ts.map +1 -1
  18. package/dist/backfill/derive.js +7 -0
  19. package/dist/backfill/derive.js.map +1 -1
  20. package/dist/canary/fixtures.d.ts +12 -0
  21. package/dist/canary/fixtures.d.ts.map +1 -0
  22. package/dist/canary/fixtures.js +132 -0
  23. package/dist/canary/fixtures.js.map +1 -0
  24. package/dist/canary/index.d.ts +16 -0
  25. package/dist/canary/index.d.ts.map +1 -0
  26. package/dist/canary/index.js +105 -0
  27. package/dist/canary/index.js.map +1 -0
  28. package/dist/canary/run.d.ts +39 -0
  29. package/dist/canary/run.d.ts.map +1 -0
  30. package/dist/canary/run.js +266 -0
  31. package/dist/canary/run.js.map +1 -0
  32. package/dist/canary/stats.d.ts +36 -0
  33. package/dist/canary/stats.d.ts.map +1 -0
  34. package/dist/canary/stats.js +143 -0
  35. package/dist/canary/stats.js.map +1 -0
  36. package/dist/canon/index.d.ts +15 -0
  37. package/dist/canon/index.d.ts.map +1 -0
  38. package/dist/canon/index.js +167 -0
  39. package/dist/canon/index.js.map +1 -0
  40. package/dist/canon/resolve.d.ts +12 -0
  41. package/dist/canon/resolve.d.ts.map +1 -0
  42. package/dist/canon/resolve.js +67 -0
  43. package/dist/canon/resolve.js.map +1 -0
  44. package/dist/canon/topic.d.ts +20 -0
  45. package/dist/canon/topic.d.ts.map +1 -0
  46. package/dist/canon/topic.js +81 -0
  47. package/dist/canon/topic.js.map +1 -0
  48. package/dist/canon/types.d.ts +37 -0
  49. package/dist/canon/types.d.ts.map +1 -0
  50. package/dist/canon/types.js +9 -0
  51. package/dist/canon/types.js.map +1 -0
  52. package/dist/cli.d.ts.map +1 -1
  53. package/dist/cli.js +12 -0
  54. package/dist/cli.js.map +1 -1
  55. package/dist/consolidate/index.d.ts.map +1 -1
  56. package/dist/consolidate/index.js +10 -12
  57. package/dist/consolidate/index.js.map +1 -1
  58. package/dist/curation/edges.d.ts.map +1 -1
  59. package/dist/curation/edges.js +36 -17
  60. package/dist/curation/edges.js.map +1 -1
  61. package/dist/curation/lint-voice.d.ts +3 -0
  62. package/dist/curation/lint-voice.d.ts.map +1 -0
  63. package/dist/curation/lint-voice.js +87 -0
  64. package/dist/curation/lint-voice.js.map +1 -0
  65. package/dist/curation/lint.d.ts +7 -1
  66. package/dist/curation/lint.d.ts.map +1 -1
  67. package/dist/curation/lint.js +62 -18
  68. package/dist/curation/lint.js.map +1 -1
  69. package/dist/curation/shadow.d.ts +1 -0
  70. package/dist/curation/shadow.d.ts.map +1 -1
  71. package/dist/curation/shadow.js +17 -11
  72. package/dist/curation/shadow.js.map +1 -1
  73. package/dist/curation/staged-actions.d.ts +1 -0
  74. package/dist/curation/staged-actions.d.ts.map +1 -1
  75. package/dist/curation/staged-actions.js +21 -24
  76. package/dist/curation/staged-actions.js.map +1 -1
  77. package/dist/curation/validity.d.ts +20 -0
  78. package/dist/curation/validity.d.ts.map +1 -0
  79. package/dist/curation/validity.js +191 -0
  80. package/dist/curation/validity.js.map +1 -0
  81. package/dist/eval/generate.d.ts.map +1 -1
  82. package/dist/eval/generate.js +16 -0
  83. package/dist/eval/generate.js.map +1 -1
  84. package/dist/eval/index.d.ts +1 -0
  85. package/dist/eval/index.d.ts.map +1 -1
  86. package/dist/eval/index.js +79 -28
  87. package/dist/eval/index.js.map +1 -1
  88. package/dist/eval/llm-openrouter.d.ts.map +1 -1
  89. package/dist/eval/llm-openrouter.js +158 -65
  90. package/dist/eval/llm-openrouter.js.map +1 -1
  91. package/dist/fence/detect.d.ts +10 -0
  92. package/dist/fence/detect.d.ts.map +1 -0
  93. package/dist/fence/detect.js +161 -0
  94. package/dist/fence/detect.js.map +1 -0
  95. package/dist/fence/index.d.ts +22 -0
  96. package/dist/fence/index.d.ts.map +1 -0
  97. package/dist/fence/index.js +117 -0
  98. package/dist/fence/index.js.map +1 -0
  99. package/dist/frontmatter/schema.d.ts.map +1 -1
  100. package/dist/frontmatter/schema.js +26 -0
  101. package/dist/frontmatter/schema.js.map +1 -1
  102. package/dist/frontmatter/types.d.ts +3 -1
  103. package/dist/frontmatter/types.d.ts.map +1 -1
  104. package/dist/frontmatter/types.js +2 -0
  105. package/dist/frontmatter/types.js.map +1 -1
  106. package/dist/holders/registry.d.ts +8 -0
  107. package/dist/holders/registry.d.ts.map +1 -0
  108. package/dist/holders/registry.js +18 -0
  109. package/dist/holders/registry.js.map +1 -0
  110. package/dist/holders/types.d.ts +10 -0
  111. package/dist/holders/types.d.ts.map +1 -0
  112. package/dist/holders/types.js +2 -0
  113. package/dist/holders/types.js.map +1 -0
  114. package/dist/index.d.ts.map +1 -1
  115. package/dist/index.js +10 -6
  116. package/dist/index.js.map +1 -1
  117. package/dist/interview/index.d.ts +7 -0
  118. package/dist/interview/index.d.ts.map +1 -0
  119. package/dist/interview/index.js +219 -0
  120. package/dist/interview/index.js.map +1 -0
  121. package/dist/interview/questions.d.ts +18 -0
  122. package/dist/interview/questions.d.ts.map +1 -0
  123. package/dist/interview/questions.js +201 -0
  124. package/dist/interview/questions.js.map +1 -0
  125. package/dist/interview/transcript.d.ts +23 -0
  126. package/dist/interview/transcript.d.ts.map +1 -0
  127. package/dist/interview/transcript.js +155 -0
  128. package/dist/interview/transcript.js.map +1 -0
  129. package/dist/okf/export.d.ts.map +1 -1
  130. package/dist/okf/export.js +4 -2
  131. package/dist/okf/export.js.map +1 -1
  132. package/dist/okf/import.d.ts.map +1 -1
  133. package/dist/okf/import.js +11 -3
  134. package/dist/okf/import.js.map +1 -1
  135. package/dist/okf/index.d.ts.map +1 -1
  136. package/dist/okf/index.js +13 -1
  137. package/dist/okf/index.js.map +1 -1
  138. package/dist/okf/map.d.ts +11 -0
  139. package/dist/okf/map.d.ts.map +1 -1
  140. package/dist/okf/map.js +191 -13
  141. package/dist/okf/map.js.map +1 -1
  142. package/dist/okf/types.d.ts +6 -2
  143. package/dist/okf/types.d.ts.map +1 -1
  144. package/dist/okf/types.js +39 -5
  145. package/dist/okf/types.js.map +1 -1
  146. package/dist/resources.d.ts +27 -0
  147. package/dist/resources.d.ts.map +1 -0
  148. package/dist/resources.js +169 -0
  149. package/dist/resources.js.map +1 -0
  150. package/dist/search/current-source.d.ts +1 -0
  151. package/dist/search/current-source.d.ts.map +1 -1
  152. package/dist/search/current-source.js +3 -1
  153. package/dist/search/current-source.js.map +1 -1
  154. package/dist/search/hybrid.d.ts +5 -0
  155. package/dist/search/hybrid.d.ts.map +1 -1
  156. package/dist/search/hybrid.js +25 -9
  157. package/dist/search/hybrid.js.map +1 -1
  158. package/dist/search/reindex.d.ts +3 -0
  159. package/dist/search/reindex.d.ts.map +1 -1
  160. package/dist/search/reindex.js +78 -23
  161. package/dist/search/reindex.js.map +1 -1
  162. package/dist/search/valid-at-source.d.ts +25 -0
  163. package/dist/search/valid-at-source.d.ts.map +1 -0
  164. package/dist/search/valid-at-source.js +131 -0
  165. package/dist/search/valid-at-source.js.map +1 -0
  166. package/dist/search/watcher.d.ts.map +1 -1
  167. package/dist/search/watcher.js +8 -17
  168. package/dist/search/watcher.js.map +1 -1
  169. package/dist/serve/index.d.ts.map +1 -1
  170. package/dist/serve/index.js +58 -89
  171. package/dist/serve/index.js.map +1 -1
  172. package/dist/server.d.ts +3 -1
  173. package/dist/server.d.ts.map +1 -1
  174. package/dist/server.js +159 -11
  175. package/dist/server.js.map +1 -1
  176. package/dist/sleep/cycle.d.ts.map +1 -1
  177. package/dist/sleep/cycle.js +20 -4
  178. package/dist/sleep/cycle.js.map +1 -1
  179. package/dist/storage/index-db.d.ts +7 -1
  180. package/dist/storage/index-db.d.ts.map +1 -1
  181. package/dist/storage/index-db.js +134 -8
  182. package/dist/storage/index-db.js.map +1 -1
  183. package/dist/tools/canon.d.ts +3 -0
  184. package/dist/tools/canon.d.ts.map +1 -0
  185. package/dist/tools/canon.js +177 -0
  186. package/dist/tools/canon.js.map +1 -0
  187. package/dist/tools/consumes.d.ts.map +1 -1
  188. package/dist/tools/consumes.js +47 -1
  189. package/dist/tools/consumes.js.map +1 -1
  190. package/dist/tools/curation.d.ts +2 -0
  191. package/dist/tools/curation.d.ts.map +1 -1
  192. package/dist/tools/curation.js +506 -3
  193. package/dist/tools/curation.js.map +1 -1
  194. package/dist/tools/edge-staleness.d.ts.map +1 -1
  195. package/dist/tools/edge-staleness.js +115 -0
  196. package/dist/tools/edge-staleness.js.map +1 -1
  197. package/dist/tools/edges.d.ts.map +1 -1
  198. package/dist/tools/edges.js +94 -0
  199. package/dist/tools/edges.js.map +1 -1
  200. package/dist/tools/read.d.ts +14 -0
  201. package/dist/tools/read.d.ts.map +1 -1
  202. package/dist/tools/read.js +452 -51
  203. package/dist/tools/read.js.map +1 -1
  204. package/dist/tools/receipt.d.ts +1 -1
  205. package/dist/tools/receipt.d.ts.map +1 -1
  206. package/dist/tools/receipt.js +147 -2
  207. package/dist/tools/receipt.js.map +1 -1
  208. package/dist/tools/search.d.ts.map +1 -1
  209. package/dist/tools/search.js +454 -3
  210. package/dist/tools/search.js.map +1 -1
  211. package/dist/tools/staged-actions.d.ts +7 -0
  212. package/dist/tools/staged-actions.d.ts.map +1 -1
  213. package/dist/tools/staged-actions.js +138 -36
  214. package/dist/tools/staged-actions.js.map +1 -1
  215. package/dist/tools/themes.d.ts.map +1 -1
  216. package/dist/tools/themes.js +120 -0
  217. package/dist/tools/themes.js.map +1 -1
  218. package/dist/tools/tier1.d.ts.map +1 -1
  219. package/dist/tools/tier1.js +56 -0
  220. package/dist/tools/tier1.js.map +1 -1
  221. package/dist/tools/tier2.d.ts.map +1 -1
  222. package/dist/tools/tier2.js +111 -1
  223. package/dist/tools/tier2.js.map +1 -1
  224. package/dist/tools/witness.d.ts.map +1 -1
  225. package/dist/tools/witness.js +93 -0
  226. package/dist/tools/witness.js.map +1 -1
  227. package/dist/tools/write.d.ts +1 -0
  228. package/dist/tools/write.d.ts.map +1 -1
  229. package/dist/tools/write.js +479 -216
  230. package/dist/tools/write.js.map +1 -1
  231. package/dist/utils/config.d.ts +2 -0
  232. package/dist/utils/config.d.ts.map +1 -1
  233. package/dist/utils/config.js +160 -86
  234. package/dist/utils/config.js.map +1 -1
  235. package/dist/utils/dates.d.ts +1 -0
  236. package/dist/utils/dates.d.ts.map +1 -1
  237. package/dist/utils/dates.js +5 -0
  238. package/dist/utils/dates.js.map +1 -1
  239. package/package.json +5 -2
@@ -1 +1 @@
1
- {"version":3,"file":"curation.d.ts","sourceRoot":"","sources":["../../src/tools/curation.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,KAAK,aAAa,EAAkC,MAAM,mBAAmB,CAAC;AAEvF,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AACrE,OAAO,EAEL,KAAK,aAAa,EAClB,KAAK,WAAW,EAEhB,KAAK,oBAAoB,EACzB,KAAK,aAAa,EACnB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,KAAK,eAAe,EAAqB,MAAM,2BAA2B,CAAC;AACpF,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,kCAAkC,CAAC;AAChF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAE/D,OAAO,EAOL,KAAK,Y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G,IAAI,CAAC;IAC7B,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,aAAa,EAAE,WAAW,EAAE,CAAC,CAAC,CAAC;IACtD,aAAa,EAAE,MAAM,CAAC;IACtB,aAAa,EAAE,aAAa,CAAC;IAC7B,aAAa,EAAE,oBAAoB,EAAE,CAAC;IACtC,aAAa,EAAE,iBAAiB,CAAC;IACjC,cAAc,EAAE,qBAAqB,CAAC;IACtC,gBAAgB,EAAE,uBAAuB,CAAC;CAC3C;AAED,wBAAsB,SAAS,CAC7B,SAAS,EAAE,MAAM,EACjB,IAAI,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM,EAClC,MAAM,CAAC,EAAE,aAAa,GACrB,OAAO,CAAC,MAAM,CAAC,eAAe,EAAE,KAAK,CAAC,CAAC,CAmEzC;AAMD,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,eAAe,EAAE,CAAC;CAC5B;AAID,wBAAsB,eAAe,CACnC,SAAS,EAAE,MAAM,EACjB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,MAAM,CAAC,EAAE,aAAa,GACrB,OAAO,CAAC,MAAM,CAAC,qBAAqB,EAAE,KAAK,CAAC,CAAC,CA4C/C;AAmcD,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAgDpD;AAMD,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAM5E;AAMD,eAAO,MAAM,aAAa,EAAE,cAAc,EA4NzC,CAAC"}
@@ -10,16 +10,18 @@
10
10
  // write-path tools.
11
11
  import { canRatify, canRead, hasAnyRead } from "../access/rbac.js";
12
12
  import { CONSOLIDATE_AGENT } from "../consolidate/constants.js";
13
- import { LINT_CHECKS, runLint, } from "../curation/lint.js";
13
+ import { clip, LINT_CHECKS, LINT_SUMMARY_DETAIL_CHARS, LINT_SUMMARY_TOP_FINDINGS, runLint, TIER0_LINT_CHECKS, } from "../curation/lint.js";
14
+ import { renderLedgerKeeper } from "../curation/lint-voice.js";
14
15
  import { readProvenanceLog } from "../curation/provenance.js";
15
- import { sweepExpiredActions } from "../curation/staged-actions.js";
16
- import { addTension, LOGGABLE_TENSION_KINDS, listTensions, RESOLUTION_KINDS, resolveTension, } from "../curation/tension.js";
16
+ import { STAGED_ACTION_TYPES, sweepExpiredActions } from "../curation/staged-actions.js";
17
+ import { addTension, LOGGABLE_TENSION_KINDS, listTensions, RESOLUTION_KINDS, resolveTension, TENSION_KINDS, } from "../curation/tension.js";
17
18
  import { canSeeTension, sourceReadable, visibleTensions } from "../curation/tension-access.js";
18
19
  import { bucketHiddenDownstream, computeTensionBlast, } from "../curation/tension-blast.js";
19
20
  import { loadTensionClusters } from "../curation/tension-clusters.js";
20
21
  import { parseDocument } from "../frontmatter/parser.js";
21
22
  import { err, ok } from "../frontmatter/types.js";
22
23
  import { readFile, resolveVaultPath } from "../storage/local.js";
24
+ import { loadConfig } from "../utils/config.js";
23
25
  import { openIndexForAccessOrNull } from "./search.js";
24
26
  // Curation tools are open to any role with at least one read grant. A guest
25
27
  // (or any role with no read access) is denied.
@@ -382,6 +384,498 @@ export async function vaultProvenance(vaultRoot, args, access) {
382
384
  return ok({ path: filePath, count: history.length, history });
383
385
  }
384
386
  // ---------------------------------------------------------------------------
387
+ // Output schemas (spec 2026-07-26, Decision 3)
388
+ // ---------------------------------------------------------------------------
389
+ //
390
+ // JSON Schema 2020-12 for each handler's ok-value, derived from the return
391
+ // types above. Closed vocabularies reuse the source-of-truth constants so a
392
+ // rename there breaks this build instead of silently drifting the schema.
393
+ // Where a structure is open by construction — a free-form counts map, a
394
+ // verbatim frontmatter diff — the schema stays permissive rather than
395
+ // promising a shape the handler never guarantees.
396
+ // { key: integer } over a fixed vocabulary (byKind, byResolutionKind, ...).
397
+ function countsByKey(keys) {
398
+ const properties = {};
399
+ for (const key of keys)
400
+ properties[key] = { type: "integer" };
401
+ return { type: "object", properties, required: [...keys], additionalProperties: false };
402
+ }
403
+ const tensionResolutionSchema = {
404
+ type: "object",
405
+ properties: {
406
+ resolved_at: { type: "string", description: "ISO 8601 instant the tension was closed" },
407
+ resolved_by: { type: "string" },
408
+ kind: { type: "string", enum: [...RESOLUTION_KINDS] },
409
+ rationale: { type: "string" },
410
+ references: { type: "array", items: { type: "string" } },
411
+ },
412
+ required: ["resolved_at", "resolved_by", "kind"],
413
+ additionalProperties: false,
414
+ };
415
+ // One tension-log entry. `kinds` narrows the taxonomy to what the calling
416
+ // tool can actually return: vault_tension_log mints only loggable kinds,
417
+ // while vault_tension_resolve can close an entry of any kind (including the
418
+ // system-generated inter-proposal one and legacy unspecified entries).
419
+ function tensionEntrySchema(kinds) {
420
+ return {
421
+ type: "object",
422
+ properties: {
423
+ id: { type: "string", description: "e.g. 'tension-007'; absent on legacy entries" },
424
+ date: { type: "string", description: "YYYY-MM-DD" },
425
+ title: { type: "string" },
426
+ kind: { type: "string", enum: [...kinds] },
427
+ sourceA: { type: "string" },
428
+ claimA: { type: "string" },
429
+ sourceB: { type: "string" },
430
+ claimB: { type: "string" },
431
+ status: { type: "string", description: "'unresolved' | 'resolved'" },
432
+ loggedBy: { type: "string" },
433
+ decidedByPrincipal: { type: "string" },
434
+ resolved: { type: "boolean" },
435
+ resolution: tensionResolutionSchema,
436
+ },
437
+ required: [
438
+ "date",
439
+ "title",
440
+ "kind",
441
+ "sourceA",
442
+ "claimA",
443
+ "sourceB",
444
+ "claimB",
445
+ "status",
446
+ "loggedBy",
447
+ "resolved",
448
+ ],
449
+ additionalProperties: false,
450
+ };
451
+ }
452
+ const tensionClustersOutputSchema = {
453
+ type: "object",
454
+ properties: {
455
+ cluster_count: { type: "integer" },
456
+ clusters: {
457
+ type: "array",
458
+ items: {
459
+ type: "object",
460
+ properties: {
461
+ id: { type: "string", description: "cluster:<8 hex chars>" },
462
+ size: { type: "integer" },
463
+ documents: { type: "array", items: { type: "string" } },
464
+ tension_count: { type: "integer" },
465
+ kinds: countsByKey(TENSION_KINDS),
466
+ oldest_tension_age_days: { type: "number" },
467
+ newest_tension_age_days: { type: "number" },
468
+ },
469
+ required: [
470
+ "id",
471
+ "size",
472
+ "documents",
473
+ "tension_count",
474
+ "kinds",
475
+ "oldest_tension_age_days",
476
+ "newest_tension_age_days",
477
+ ],
478
+ additionalProperties: false,
479
+ },
480
+ },
481
+ },
482
+ required: ["cluster_count", "clusters"],
483
+ additionalProperties: false,
484
+ };
485
+ const tensionBlastOutputSchema = {
486
+ type: "object",
487
+ properties: {
488
+ contested_document: { type: ["string", "null"] },
489
+ cluster_id: { type: ["string", "null"] },
490
+ cluster_documents: { type: "array", items: { type: "string" } },
491
+ downstream: {
492
+ type: "array",
493
+ items: {
494
+ type: "object",
495
+ properties: {
496
+ path: { type: "string" },
497
+ dependency_type: { type: "string", enum: ["source", "link"] },
498
+ distance: { type: "integer" },
499
+ },
500
+ required: ["path", "dependency_type", "distance"],
501
+ additionalProperties: false,
502
+ },
503
+ },
504
+ primary_blast: { type: "integer", description: "docs reached via the 'sources' edge" },
505
+ advisory_blast: { type: "integer", description: "docs reached only via markdown links" },
506
+ max_depth: { type: "integer" },
507
+ hidden_downstream: {
508
+ type: "string",
509
+ enum: ["none", "some", "many"],
510
+ description: "Coarsened remainder of unreadable downstream docs — never an exact count",
511
+ },
512
+ },
513
+ required: [
514
+ "contested_document",
515
+ "cluster_id",
516
+ "cluster_documents",
517
+ "downstream",
518
+ "primary_blast",
519
+ "advisory_blast",
520
+ "max_depth",
521
+ "hidden_downstream",
522
+ ],
523
+ additionalProperties: false,
524
+ };
525
+ const lintFindingSchema = {
526
+ type: "object",
527
+ properties: { path: { type: "string" }, detail: { type: "string" } },
528
+ required: ["path", "detail"],
529
+ additionalProperties: false,
530
+ };
531
+ // `checks` is a Partial record — a filtered run carries exactly one key — so
532
+ // no check name is required, only known.
533
+ const lintChecksProperties = {};
534
+ for (const check of LINT_CHECKS) {
535
+ lintChecksProperties[check] = { type: "array", items: lintFindingSchema };
536
+ }
537
+ const strengthGroupStatsSchema = {
538
+ type: "object",
539
+ properties: {
540
+ count: { type: "integer" },
541
+ mean: { type: "number" },
542
+ median: { type: "number" },
543
+ p10: { type: "number" },
544
+ p90: { type: "number" },
545
+ variance: { type: "number" },
546
+ },
547
+ required: ["count", "mean", "median", "p10", "p90", "variance"],
548
+ additionalProperties: false,
549
+ };
550
+ const shadowLintItemSchema = {
551
+ type: "object",
552
+ properties: {
553
+ at: { type: "string" },
554
+ tool: { type: "string" },
555
+ action: { type: "string" },
556
+ targetPath: { type: "string" },
557
+ agent: { type: "string" },
558
+ impact: { type: "number" },
559
+ budget: { type: "number" },
560
+ },
561
+ required: ["at", "tool", "action", "targetPath", "agent", "impact", "budget"],
562
+ additionalProperties: false,
563
+ };
564
+ const reviewThroughputWindowSchema = {
565
+ type: "object",
566
+ properties: {
567
+ arrivals: { type: "integer" },
568
+ decisions: { type: "integer" },
569
+ expiries: { type: "integer" },
570
+ },
571
+ required: ["arrivals", "decisions", "expiries"],
572
+ additionalProperties: false,
573
+ };
574
+ const lintOutputSchema = {
575
+ type: "object",
576
+ properties: {
577
+ generatedAt: { type: "string" },
578
+ filter: {
579
+ type: ["string", "null"],
580
+ enum: [...LINT_CHECKS, null],
581
+ description: "The single check the report was restricted to, or null for all checks",
582
+ },
583
+ checks: {
584
+ type: "object",
585
+ properties: lintChecksProperties,
586
+ additionalProperties: false,
587
+ },
588
+ totalFindings: { type: "integer" },
589
+ // Vault-global by design (#217 decision C): counts only, no paths.
590
+ tensionHealth: {
591
+ type: "object",
592
+ properties: {
593
+ total: { type: "integer" },
594
+ byKind: countsByKey(TENSION_KINDS),
595
+ resolvedLifetime: { type: "integer" },
596
+ byResolutionKind: countsByKey(RESOLUTION_KINDS),
597
+ stableAcknowledged: { type: "integer" },
598
+ unspecifiedLegacy: { type: "integer" },
599
+ aging: {
600
+ type: "object",
601
+ properties: {
602
+ fresh: { type: "integer" },
603
+ aging: { type: "integer" },
604
+ stale: { type: "integer" },
605
+ staleByKind: countsByKey(TENSION_KINDS),
606
+ // Kind-keyed lint copy, present only for kinds with a nonzero
607
+ // stale count; `unspecified` never appears.
608
+ staleMessages: { type: "object", additionalProperties: { type: "string" } },
609
+ },
610
+ required: ["fresh", "aging", "stale", "staleByKind", "staleMessages"],
611
+ additionalProperties: false,
612
+ },
613
+ clusters: {
614
+ type: "object",
615
+ properties: {
616
+ count: { type: "integer" },
617
+ maxSize: { type: "integer" },
618
+ large: { type: "integer" },
619
+ aged: { type: "integer" },
620
+ },
621
+ required: ["count", "maxSize", "large", "aged"],
622
+ additionalProperties: false,
623
+ },
624
+ blastRadiusOfStaleTensions: { type: "integer" },
625
+ },
626
+ required: [
627
+ "total",
628
+ "byKind",
629
+ "resolvedLifetime",
630
+ "byResolutionKind",
631
+ "stableAcknowledged",
632
+ "unspecifiedLegacy",
633
+ "aging",
634
+ "clusters",
635
+ "blastRadiusOfStaleTensions",
636
+ ],
637
+ additionalProperties: false,
638
+ },
639
+ stagedActions: {
640
+ type: "array",
641
+ description: "Pending staged actions awaiting ratification, soonest-to-expire first",
642
+ items: {
643
+ type: "object",
644
+ properties: {
645
+ id: { type: "string" },
646
+ actionType: { type: "string", enum: [...STAGED_ACTION_TYPES] },
647
+ targetPath: { type: "string" },
648
+ ageDays: { type: "integer" },
649
+ expiresInDays: { type: "integer" },
650
+ rationale: { type: "string", description: "First sentence of the staged rationale" },
651
+ },
652
+ required: ["id", "actionType", "targetPath", "ageDays", "expiresInDays", "rationale"],
653
+ additionalProperties: false,
654
+ },
655
+ },
656
+ shadowActions: {
657
+ type: "object",
658
+ properties: {
659
+ total: { type: "integer" },
660
+ gated: { type: "integer" },
661
+ recentGated: { type: "array", items: shadowLintItemSchema },
662
+ gatedSurfaced: { type: "array", items: shadowLintItemSchema },
663
+ gatedCount: { type: "integer" },
664
+ },
665
+ required: ["total", "gated", "recentGated", "gatedSurfaced", "gatedCount"],
666
+ additionalProperties: false,
667
+ },
668
+ coverageEquity: {
669
+ type: "object",
670
+ properties: {
671
+ generatedAt: { type: "string" },
672
+ strengthDrift: {
673
+ type: "object",
674
+ properties: {
675
+ core: strengthGroupStatsSchema,
676
+ periphery: strengthGroupStatsSchema,
677
+ // Null when either group is empty — the gap is undefined, and a
678
+ // sentinel 0 would read as "no drift".
679
+ coreMinusPeripheryMedian: { type: ["number", "null"] },
680
+ belowTriggerCount: { type: "integer" },
681
+ },
682
+ required: ["core", "periphery", "coreMinusPeripheryMedian", "belowTriggerCount"],
683
+ additionalProperties: false,
684
+ },
685
+ backstopOverdue: {
686
+ type: "object",
687
+ properties: {
688
+ count: { type: "integer" },
689
+ stalest: {
690
+ type: "array",
691
+ items: {
692
+ type: "object",
693
+ properties: {
694
+ fromPath: { type: "string" },
695
+ toPath: { type: "string" },
696
+ daysOverdue: { type: "number" },
697
+ },
698
+ required: ["fromPath", "toPath", "daysOverdue"],
699
+ additionalProperties: false,
700
+ },
701
+ },
702
+ },
703
+ required: ["count", "stalest"],
704
+ additionalProperties: false,
705
+ },
706
+ actionMix: {
707
+ type: "object",
708
+ properties: {
709
+ // Open by construction: keyed by whatever action names the edge
710
+ // ops and staged-action log carry.
711
+ counts: { type: "object", additionalProperties: { type: "integer" } },
712
+ cheapLinkFraction: { type: "number" },
713
+ total: { type: "integer" },
714
+ },
715
+ required: ["counts", "cheapLinkFraction", "total"],
716
+ additionalProperties: false,
717
+ },
718
+ directionResolution: {
719
+ type: "object",
720
+ properties: {
721
+ directed: { type: "integer" },
722
+ symmetric: { type: "integer" },
723
+ unresolvedFraction: { type: "number" },
724
+ },
725
+ required: ["directed", "symmetric", "unresolvedFraction"],
726
+ additionalProperties: false,
727
+ },
728
+ },
729
+ required: [
730
+ "generatedAt",
731
+ "strengthDrift",
732
+ "backstopOverdue",
733
+ "actionMix",
734
+ "directionResolution",
735
+ ],
736
+ additionalProperties: false,
737
+ },
738
+ reviewThroughput: {
739
+ type: "object",
740
+ properties: {
741
+ lifetime: {
742
+ type: "object",
743
+ properties: {
744
+ proposals: { type: "integer" },
745
+ ratified: { type: "integer" },
746
+ rejected: { type: "integer" },
747
+ expired: { type: "integer" },
748
+ pending: { type: "integer" },
749
+ },
750
+ required: ["proposals", "ratified", "rejected", "expired", "pending"],
751
+ additionalProperties: false,
752
+ },
753
+ last7d: reviewThroughputWindowSchema,
754
+ last30d: reviewThroughputWindowSchema,
755
+ timeToDecisionDays: {
756
+ type: "object",
757
+ properties: {
758
+ p50: { type: ["number", "null"] },
759
+ p90: { type: ["number", "null"] },
760
+ },
761
+ required: ["p50", "p90"],
762
+ additionalProperties: false,
763
+ },
764
+ oldestPendingDays: { type: ["number", "null"] },
765
+ },
766
+ required: ["lifetime", "last7d", "last30d", "timeToDecisionDays", "oldestPendingDays"],
767
+ additionalProperties: false,
768
+ },
769
+ },
770
+ required: [
771
+ "generatedAt",
772
+ "filter",
773
+ "checks",
774
+ "totalFindings",
775
+ "tensionHealth",
776
+ "stagedActions",
777
+ "shadowActions",
778
+ "coverageEquity",
779
+ "reviewThroughput",
780
+ ],
781
+ additionalProperties: false,
782
+ };
783
+ const provenanceOutputSchema = {
784
+ type: "object",
785
+ properties: {
786
+ path: { type: "string" },
787
+ count: { type: "integer" },
788
+ history: {
789
+ type: "array",
790
+ description: "Provenance entries for this document, oldest first",
791
+ items: {
792
+ type: "object",
793
+ properties: {
794
+ timestamp: { type: "string" },
795
+ tool: { type: "string" },
796
+ file: { type: "string" },
797
+ agent: { type: "string", description: "Caller-claimed acting identity" },
798
+ action: { type: "string" },
799
+ principal: { type: "string", description: "Authenticated server identity (§11.6)" },
800
+ run_id: { type: "string" },
801
+ body_changed: { type: "boolean" },
802
+ // Per-field { before, after } over arbitrary frontmatter keys —
803
+ // open by construction, so the value shape stays unconstrained.
804
+ frontmatter_diff: { type: "object", additionalProperties: { type: "object" } },
805
+ reason: { type: "string" },
806
+ },
807
+ required: ["timestamp", "tool", "file", "agent", "action"],
808
+ additionalProperties: false,
809
+ },
810
+ },
811
+ },
812
+ required: ["path", "count", "history"],
813
+ additionalProperties: false,
814
+ };
815
+ // ---------------------------------------------------------------------------
816
+ // vault_lint summarizer
817
+ // ---------------------------------------------------------------------------
818
+ //
819
+ // Decision 3 names vault-wide lint output as a worst token offender: the full
820
+ // report is a wall. The `content` channel gets counts plus a handful of
821
+ // findings, one line each; the full report still rides the structured channel.
822
+ export function summarizeLint(value) {
823
+ const report = value;
824
+ const perCheck = [];
825
+ let certain = 0;
826
+ let advisory = 0;
827
+ const flat = [];
828
+ for (const check of LINT_CHECKS) {
829
+ const findings = report.checks[check] ?? [];
830
+ if (findings.length === 0)
831
+ continue;
832
+ perCheck.push(`${check} ${findings.length}`);
833
+ if (TIER0_LINT_CHECKS.includes(check))
834
+ certain += findings.length;
835
+ else
836
+ advisory += findings.length;
837
+ for (const finding of findings)
838
+ flat.push({ check, finding });
839
+ }
840
+ // Certain (tier-0) findings first; sort is stable, so within each severity
841
+ // the LINT_CHECKS order is preserved.
842
+ flat.sort((a, b) => Number(TIER0_LINT_CHECKS.includes(b.check)) - Number(TIER0_LINT_CHECKS.includes(a.check)));
843
+ const health = report.tensionHealth;
844
+ const lines = [
845
+ `vault_lint [${report.filter ?? "all checks"}] ${report.totalFindings} finding(s): ` +
846
+ `${certain} certain (tier-0), ${advisory} advisory — ${report.generatedAt}`,
847
+ perCheck.length > 0 ? `by check: ${perCheck.join(", ")}` : "by check: clean",
848
+ `tensions: ${health.total} logged, ${health.resolvedLifetime} resolved, ` +
849
+ `${health.stableAcknowledged} accepted; aging ${health.aging.fresh}/${health.aging.aging}/` +
850
+ `${health.aging.stale} fresh/aging/stale; ${health.clusters.count} cluster(s) ` +
851
+ `(${health.clusters.large} large, ${health.clusters.aged} aged); ` +
852
+ `stale blast ${health.blastRadiusOfStaleTensions}`,
853
+ `staged: ${report.stagedActions.length} pending, ` +
854
+ `${report.reviewThroughput.lifetime.expired} expired lifetime; ` +
855
+ `shadow: ${report.shadowActions.total} logged, ${report.shadowActions.gated} would-gate; ` +
856
+ `coverage: ${report.coverageEquity.backstopOverdue.count} backstop-overdue edge(s)`,
857
+ ];
858
+ const top = flat.slice(0, LINT_SUMMARY_TOP_FINDINGS);
859
+ if (top.length > 0) {
860
+ lines.push(`top ${top.length} of ${flat.length} finding(s):`);
861
+ for (const { check, finding } of top) {
862
+ lines.push(` [${check}] ${finding.path} — ${clip(finding.detail, LINT_SUMMARY_DETAIL_CHARS)}`);
863
+ }
864
+ }
865
+ return lines.join("\n");
866
+ }
867
+ // The vault_lint `content`-channel summary, choosing the voice from the vault's
868
+ // `lint_voice` config. Default (or on any config error) is the plain summary;
869
+ // `ledger_keeper` re-renders the SAME findings in the ledger-keeper register.
870
+ // The structured channel (the VaultLintResult itself) is untouched either way.
871
+ export function lintContentSummary(value, vaultRoot) {
872
+ const config = loadConfig(vaultRoot);
873
+ const voice = config.ok ? config.value.lintVoice : "plain";
874
+ return voice === "ledger_keeper"
875
+ ? renderLedgerKeeper(value)
876
+ : summarizeLint(value);
877
+ }
878
+ // ---------------------------------------------------------------------------
385
879
  // MCP tool definitions
386
880
  // ---------------------------------------------------------------------------
387
881
  export const curationTools = [
@@ -433,6 +927,8 @@ export const curationTools = [
433
927
  required: ["title", "sourceA", "claimA", "sourceB", "claimB", "agent", "kind"],
434
928
  additionalProperties: false,
435
929
  },
930
+ // The entry as logged: id assigned, status 'unresolved', no resolution.
931
+ outputSchema: tensionEntrySchema(LOGGABLE_TENSION_KINDS),
436
932
  handler: (vaultRoot, args, access) => vaultTensionLog(vaultRoot, args, access),
437
933
  },
438
934
  {
@@ -473,6 +969,8 @@ export const curationTools = [
473
969
  required: ["id", "kind"],
474
970
  additionalProperties: false,
475
971
  },
972
+ // The updated entry: status 'resolved' with the resolution block attached.
973
+ outputSchema: tensionEntrySchema(TENSION_KINDS),
476
974
  handler: (vaultRoot, args, access) => vaultTensionResolve(vaultRoot, args, access),
477
975
  },
478
976
  {
@@ -492,6 +990,7 @@ export const curationTools = [
492
990
  properties: {},
493
991
  additionalProperties: false,
494
992
  },
993
+ outputSchema: tensionClustersOutputSchema,
495
994
  handler: (vaultRoot, args, access) => vaultTensionClusters(vaultRoot, args, access),
496
995
  },
497
996
  {
@@ -529,6 +1028,7 @@ export const curationTools = [
529
1028
  },
530
1029
  additionalProperties: false,
531
1030
  },
1031
+ outputSchema: tensionBlastOutputSchema,
532
1032
  handler: (vaultRoot, args, access) => vaultTensionBlast(vaultRoot, args, access),
533
1033
  },
534
1034
  {
@@ -563,6 +1063,8 @@ export const curationTools = [
563
1063
  },
564
1064
  additionalProperties: false,
565
1065
  },
1066
+ outputSchema: lintOutputSchema,
1067
+ summarize: lintContentSummary,
566
1068
  handler: (vaultRoot, args, access) => vaultLint(vaultRoot, args, access),
567
1069
  },
568
1070
  {
@@ -583,6 +1085,7 @@ export const curationTools = [
583
1085
  required: ["filePath"],
584
1086
  additionalProperties: false,
585
1087
  },
1088
+ outputSchema: provenanceOutputSchema,
586
1089
  handler: (vaultRoot, args, access) => vaultProvenance(vaultRoot, args, access),
587
1090
  },
588
1091
  ];