daftari 1.32.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.
- package/CHANGELOG.md +109 -1
- package/README.md +31 -0
- package/dist/access/rbac.d.ts +1 -0
- package/dist/access/rbac.d.ts.map +1 -1
- package/dist/access/rbac.js +16 -0
- package/dist/access/rbac.js.map +1 -1
- package/dist/asof/index.d.ts.map +1 -1
- package/dist/asof/index.js +23 -2
- package/dist/asof/index.js.map +1 -1
- package/dist/asof/report.d.ts.map +1 -1
- package/dist/asof/report.js +24 -0
- package/dist/asof/report.js.map +1 -1
- package/dist/asof/snapshot.d.ts +7 -1
- package/dist/asof/snapshot.d.ts.map +1 -1
- package/dist/asof/snapshot.js +28 -1
- package/dist/asof/snapshot.js.map +1 -1
- package/dist/backfill/derive.d.ts.map +1 -1
- package/dist/backfill/derive.js +7 -0
- package/dist/backfill/derive.js.map +1 -1
- package/dist/canary/fixtures.d.ts +12 -0
- package/dist/canary/fixtures.d.ts.map +1 -0
- package/dist/canary/fixtures.js +132 -0
- package/dist/canary/fixtures.js.map +1 -0
- package/dist/canary/index.d.ts +16 -0
- package/dist/canary/index.d.ts.map +1 -0
- package/dist/canary/index.js +105 -0
- package/dist/canary/index.js.map +1 -0
- package/dist/canary/run.d.ts +39 -0
- package/dist/canary/run.d.ts.map +1 -0
- package/dist/canary/run.js +266 -0
- package/dist/canary/run.js.map +1 -0
- package/dist/canary/stats.d.ts +36 -0
- package/dist/canary/stats.d.ts.map +1 -0
- package/dist/canary/stats.js +143 -0
- package/dist/canary/stats.js.map +1 -0
- package/dist/canon/index.d.ts +15 -0
- package/dist/canon/index.d.ts.map +1 -0
- package/dist/canon/index.js +167 -0
- package/dist/canon/index.js.map +1 -0
- package/dist/canon/resolve.d.ts +12 -0
- package/dist/canon/resolve.d.ts.map +1 -0
- package/dist/canon/resolve.js +67 -0
- package/dist/canon/resolve.js.map +1 -0
- package/dist/canon/topic.d.ts +20 -0
- package/dist/canon/topic.d.ts.map +1 -0
- package/dist/canon/topic.js +81 -0
- package/dist/canon/topic.js.map +1 -0
- package/dist/canon/types.d.ts +37 -0
- package/dist/canon/types.d.ts.map +1 -0
- package/dist/canon/types.js +9 -0
- package/dist/canon/types.js.map +1 -0
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +6 -0
- package/dist/cli.js.map +1 -1
- package/dist/curation/lint-voice.d.ts +3 -0
- package/dist/curation/lint-voice.d.ts.map +1 -0
- package/dist/curation/lint-voice.js +87 -0
- package/dist/curation/lint-voice.js.map +1 -0
- package/dist/curation/lint.d.ts +5 -1
- package/dist/curation/lint.d.ts.map +1 -1
- package/dist/curation/lint.js +36 -0
- package/dist/curation/lint.js.map +1 -1
- package/dist/curation/validity.d.ts +20 -0
- package/dist/curation/validity.d.ts.map +1 -0
- package/dist/curation/validity.js +191 -0
- package/dist/curation/validity.js.map +1 -0
- package/dist/fence/detect.d.ts +10 -0
- package/dist/fence/detect.d.ts.map +1 -0
- package/dist/fence/detect.js +161 -0
- package/dist/fence/detect.js.map +1 -0
- package/dist/fence/index.d.ts +22 -0
- package/dist/fence/index.d.ts.map +1 -0
- package/dist/fence/index.js +117 -0
- package/dist/fence/index.js.map +1 -0
- package/dist/frontmatter/schema.d.ts.map +1 -1
- package/dist/frontmatter/schema.js +26 -0
- package/dist/frontmatter/schema.js.map +1 -1
- package/dist/frontmatter/types.d.ts +3 -1
- package/dist/frontmatter/types.d.ts.map +1 -1
- package/dist/frontmatter/types.js +2 -0
- package/dist/frontmatter/types.js.map +1 -1
- package/dist/holders/registry.d.ts +8 -0
- package/dist/holders/registry.d.ts.map +1 -0
- package/dist/holders/registry.js +18 -0
- package/dist/holders/registry.js.map +1 -0
- package/dist/holders/types.d.ts +10 -0
- package/dist/holders/types.d.ts.map +1 -0
- package/dist/holders/types.js +2 -0
- package/dist/holders/types.js.map +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -6
- package/dist/index.js.map +1 -1
- package/dist/interview/questions.d.ts.map +1 -1
- package/dist/interview/questions.js +41 -9
- package/dist/interview/questions.js.map +1 -1
- package/dist/resources.d.ts +27 -0
- package/dist/resources.d.ts.map +1 -0
- package/dist/resources.js +169 -0
- package/dist/resources.js.map +1 -0
- package/dist/search/current-source.d.ts +1 -0
- package/dist/search/current-source.d.ts.map +1 -1
- package/dist/search/current-source.js +3 -1
- package/dist/search/current-source.js.map +1 -1
- package/dist/search/hybrid.d.ts +5 -0
- package/dist/search/hybrid.d.ts.map +1 -1
- package/dist/search/hybrid.js +23 -4
- package/dist/search/hybrid.js.map +1 -1
- package/dist/search/reindex.d.ts.map +1 -1
- package/dist/search/reindex.js +48 -13
- package/dist/search/reindex.js.map +1 -1
- package/dist/search/valid-at-source.d.ts +25 -0
- package/dist/search/valid-at-source.d.ts.map +1 -0
- package/dist/search/valid-at-source.js +131 -0
- package/dist/search/valid-at-source.js.map +1 -0
- package/dist/serve/index.d.ts.map +1 -1
- package/dist/serve/index.js +58 -89
- package/dist/serve/index.js.map +1 -1
- package/dist/server.d.ts +3 -1
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +159 -11
- package/dist/server.js.map +1 -1
- package/dist/sleep/cycle.d.ts.map +1 -1
- package/dist/sleep/cycle.js +20 -4
- package/dist/sleep/cycle.js.map +1 -1
- package/dist/storage/index-db.d.ts +7 -1
- package/dist/storage/index-db.d.ts.map +1 -1
- package/dist/storage/index-db.js +133 -8
- package/dist/storage/index-db.js.map +1 -1
- package/dist/tools/canon.d.ts +3 -0
- package/dist/tools/canon.d.ts.map +1 -0
- package/dist/tools/canon.js +177 -0
- package/dist/tools/canon.js.map +1 -0
- package/dist/tools/consumes.d.ts.map +1 -1
- package/dist/tools/consumes.js +47 -1
- package/dist/tools/consumes.js.map +1 -1
- package/dist/tools/curation.d.ts +2 -0
- package/dist/tools/curation.d.ts.map +1 -1
- package/dist/tools/curation.js +506 -3
- package/dist/tools/curation.js.map +1 -1
- package/dist/tools/edge-staleness.d.ts.map +1 -1
- package/dist/tools/edge-staleness.js +115 -0
- package/dist/tools/edge-staleness.js.map +1 -1
- package/dist/tools/edges.d.ts.map +1 -1
- package/dist/tools/edges.js +94 -0
- package/dist/tools/edges.js.map +1 -1
- package/dist/tools/read.d.ts +14 -0
- package/dist/tools/read.d.ts.map +1 -1
- package/dist/tools/read.js +383 -4
- package/dist/tools/read.js.map +1 -1
- package/dist/tools/receipt.d.ts +1 -1
- package/dist/tools/receipt.d.ts.map +1 -1
- package/dist/tools/receipt.js +147 -2
- package/dist/tools/receipt.js.map +1 -1
- package/dist/tools/search.d.ts.map +1 -1
- package/dist/tools/search.js +454 -3
- package/dist/tools/search.js.map +1 -1
- package/dist/tools/staged-actions.d.ts +7 -0
- package/dist/tools/staged-actions.d.ts.map +1 -1
- package/dist/tools/staged-actions.js +106 -2
- package/dist/tools/staged-actions.js.map +1 -1
- package/dist/tools/themes.d.ts.map +1 -1
- package/dist/tools/themes.js +120 -0
- package/dist/tools/themes.js.map +1 -1
- package/dist/tools/tier1.d.ts.map +1 -1
- package/dist/tools/tier1.js +56 -0
- package/dist/tools/tier1.js.map +1 -1
- package/dist/tools/tier2.d.ts.map +1 -1
- package/dist/tools/tier2.js +111 -1
- package/dist/tools/tier2.js.map +1 -1
- package/dist/tools/witness.d.ts.map +1 -1
- package/dist/tools/witness.js +93 -0
- package/dist/tools/witness.js.map +1 -1
- package/dist/tools/write.d.ts +1 -0
- package/dist/tools/write.d.ts.map +1 -1
- package/dist/tools/write.js +329 -2
- package/dist/tools/write.js.map +1 -1
- package/dist/utils/config.d.ts +2 -0
- package/dist/utils/config.d.ts.map +1 -1
- package/dist/utils/config.js +74 -0
- package/dist/utils/config.js.map +1 -1
- package/package.json +5 -2
package/dist/tools/curation.js
CHANGED
|
@@ -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
|
];
|