@agent-wiki/mcp 0.20.0 → 0.21.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/dist/evidence-report.d.ts +82 -0
  2. package/dist/evidence-report.d.ts.map +1 -0
  3. package/dist/evidence-report.js +368 -0
  4. package/dist/evidence-report.js.map +1 -0
  5. package/dist/evidence-report.test.d.ts +2 -0
  6. package/dist/evidence-report.test.d.ts.map +1 -0
  7. package/dist/evidence-report.test.js +334 -0
  8. package/dist/evidence-report.test.js.map +1 -0
  9. package/dist/evidence-search-log.d.ts +33 -0
  10. package/dist/evidence-search-log.d.ts.map +1 -0
  11. package/dist/evidence-search-log.js +34 -0
  12. package/dist/evidence-search-log.js.map +1 -0
  13. package/dist/evidence-search-log.test.d.ts +2 -0
  14. package/dist/evidence-search-log.test.d.ts.map +1 -0
  15. package/dist/evidence-search-log.test.js +144 -0
  16. package/dist/evidence-search-log.test.js.map +1 -0
  17. package/dist/evidence-search.d.ts +2 -1
  18. package/dist/evidence-search.d.ts.map +1 -1
  19. package/dist/evidence-search.js +29 -1
  20. package/dist/evidence-search.js.map +1 -1
  21. package/dist/evidence-write-log.d.ts +73 -6
  22. package/dist/evidence-write-log.d.ts.map +1 -1
  23. package/dist/evidence-write-log.js +84 -83
  24. package/dist/evidence-write-log.js.map +1 -1
  25. package/dist/evidence-write-log.test.js +138 -7
  26. package/dist/evidence-write-log.test.js.map +1 -1
  27. package/dist/evidence.d.ts +17 -3
  28. package/dist/evidence.d.ts.map +1 -1
  29. package/dist/evidence.js +33 -4
  30. package/dist/evidence.js.map +1 -1
  31. package/dist/jsonl-log.d.ts +30 -0
  32. package/dist/jsonl-log.d.ts.map +1 -0
  33. package/dist/jsonl-log.js +97 -0
  34. package/dist/jsonl-log.js.map +1 -0
  35. package/dist/server.d.ts.map +1 -1
  36. package/dist/server.js +86 -27
  37. package/dist/server.js.map +1 -1
  38. package/dist/server.test.js +201 -0
  39. package/dist/server.test.js.map +1 -1
  40. package/dist/wiki.d.ts +4 -0
  41. package/dist/wiki.d.ts.map +1 -1
  42. package/dist/wiki.js +25 -11
  43. package/dist/wiki.js.map +1 -1
  44. package/dist/wiki.test.js +69 -0
  45. package/dist/wiki.test.js.map +1 -1
  46. package/docs/evidence-envelope.md +22 -3
  47. package/package.json +1 -1
@@ -1,10 +1,10 @@
1
1
  # Evidence Envelope
2
2
 
3
- **Status: Phase 0 design — interface and spec only, no consumers yet.**
3
+ **Status: Phases 1–4 delivered. Phase 2b (hard reject) ships disabled and is operator-toggleable via `AGENT_WIKI_EVIDENCE_REJECT_UNSUPPORTED` once the would-reject ratio settles. Section "Phase 0 — design" below is preserved as the original contract; downstream sections describe what shipped.**
4
4
 
5
5
  agent-wiki has accumulated many evidence-like features (raw provenance, frontmatter `sources`, COBOL lineage confidence tiers, graph edge evidence, lint, `raw_coverage`), but each tool exposes them differently. Agents using one tool's output have no reliable way to ask "is this match strong enough to act on?" The envelope is a unified contract every retrieval / query tool will adopt across the evidence-first program (#78).
6
6
 
7
- This document fixes the contract and the migration plan **before** any tool starts emitting envelopes. Phase 1+ implements; Phase 0 only specifies.
7
+ This document fixes the contract and the migration plan. Phase 0 specifies; Phases 1–4 implement.
8
8
 
9
9
  ## The shape
10
10
 
@@ -127,7 +127,26 @@ interface UnsupportedWriteEvent {
127
127
 
128
128
  **Storage**: append-only JSONL at `.agent-wiki/evidence-write-log.jsonl` (already-ignored `.agent-wiki/` namespace). Rotation policy: cap at 10 MB / 30 days, whichever first; `wiki_admin lint` truncates.
129
129
 
130
- **Aggregation**: Phase 4 dashboard reads this log. Until 4 ships, `wiki_admin rebuild` emits a one-line summary into `wiki/log.md` ("last week: 12 unsupported writes, 3 synthesis-flagged, 0 grounded").
130
+ The unsupported log only captures the **numerator** — distinct unsupported transitions and rejected attempts. To put that count in context, a sibling **per-write counter** at `.agent-wiki/evidence-write-counter.jsonl` records every classified write attempt:
131
+
132
+ ```ts
133
+ interface WriteEvent {
134
+ timestamp: string; // ISO 8601
135
+ kind: "grounded" | "synthesis" | "unsupported" | "rejected" | "legacy";
136
+ }
137
+ ```
138
+
139
+ Same rotation policy. The counter ticks on every classified `wiki_write` (system pages and bypassed writes excluded), regardless of whether the unsupported log dedupes the event. This keeps the "denominator" honest: `(unsupportedWrites + rejectedWrites) / totalWrites` reflects how often unsupported attempts occur versus total write volume — see `wouldRejectRatio` below.
140
+
141
+ **Aggregation**: Phase 4 dashboard reads both logs. Until 4 ships, `wiki_admin rebuild` emits a one-line summary into `wiki/log.md` ("last 7 days: 12 unsupported + 0 rejected / 47 wiki_write(s) (5 new unsupported pages) — 25.5% blocked-or-would-block under Phase 2b"). Three numerators are surfaced because they answer different questions:
142
+
143
+ - **`unsupportedWrites`** — every write that ended up unsupported in warn mode, including re-edits.
144
+ - **`rejectedWrites`** — every write blocked under Phase 2b reject mode.
145
+ - **`unsupportedTransitions`** — distinct *new* unsupported pages introduced (deduped on transition; lower bound, useful for authoring-intent vs. churn).
146
+
147
+ The headline ratio is `(unsupportedWrites + rejectedWrites) / totalWrites` — **mode-invariant**: in warn mode, `rejectedWrites` is 0 and the ratio is what 2b would block; in reject mode, `unsupportedWrites` is 0 (those writes go through the reject path instead) and the ratio is what 2b is currently blocking. Either way the same number drives threshold decisions.
148
+
149
+ The ratio is omitted when the counter file is empty (early deployments would otherwise read as 0%).
131
150
 
132
151
  Without this hook in Phase 2a, Phase 2b is guesswork. Including it now means the data is collected from day one.
133
152
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agent-wiki/mcp",
3
- "version": "0.20.0",
3
+ "version": "0.21.1",
4
4
  "description": "Agent-driven knowledge base — immutable raw sources + mutable wiki + self-checking lint. MCP server, no LLM needed.",
5
5
  "type": "module",
6
6
  "bin": {