@staix/vault-mem 0.9.0 → 0.10.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 (49) hide show
  1. package/CHANGELOG.md +32 -0
  2. package/README.md +19 -6
  3. package/bin/vmem.js +2 -2
  4. package/package.json +2 -2
  5. package/src/analysis-commands.ts +24 -14
  6. package/src/analysis-input.ts +12 -0
  7. package/src/analysis-types.ts +5 -1
  8. package/src/assert-command.ts +48 -0
  9. package/src/assertion-exposure.ts +367 -0
  10. package/src/assertion-index.ts +86 -0
  11. package/src/assertion-policy.ts +63 -0
  12. package/src/assertion-read.ts +170 -0
  13. package/src/assertions-command.ts +123 -0
  14. package/src/assertions.ts +1013 -0
  15. package/src/cli-output.ts +9 -3
  16. package/src/cli.ts +44 -23
  17. package/src/commands-table.ts +16 -2
  18. package/src/evidence.ts +222 -0
  19. package/src/graph-evidence.ts +169 -0
  20. package/src/index.ts +14 -0
  21. package/src/links.ts +18 -0
  22. package/src/log-commands.ts +7 -7
  23. package/src/mcp-spec.ts +11 -11
  24. package/src/mcp-vault.ts +105 -6
  25. package/src/mcp.ts +4 -0
  26. package/src/org-commands.ts +5 -5
  27. package/src/org-promote.ts +9 -0
  28. package/src/promote-command.ts +6 -6
  29. package/src/proposal-commands.ts +100 -0
  30. package/src/proposal-provider.ts +335 -0
  31. package/src/proposal-storage.ts +334 -0
  32. package/src/proposals.ts +170 -0
  33. package/src/read-commands.ts +44 -12
  34. package/src/read-output.ts +42 -14
  35. package/src/skills-mine.ts +12 -7
  36. package/src/source-age.ts +131 -0
  37. package/src/spec-output.ts +14 -13
  38. package/src/sync.ts +14 -7
  39. package/src/text-output.ts +86 -21
  40. package/src/vault-brief.ts +8 -4
  41. package/src/vault-graph.ts +12 -3
  42. package/src/vault-history.ts +662 -0
  43. package/src/vault-index.ts +2 -0
  44. package/src/vault-lint.ts +15 -4
  45. package/src/write-commands.ts +18 -17
  46. package/src/write-output.ts +6 -6
  47. package/src/write-types.ts +1 -0
  48. package/src/write-validation.ts +3 -1
  49. package/src/writer.ts +257 -11
@@ -551,6 +551,8 @@ export class VaultIndex<Source extends VaultSpec | SpecSourceSpec = VaultSpec> {
551
551
  if (row?.source === null) throw Object.assign(new Error(`note source exceeds the ${maximum}-byte remaining read budget; split the note or reduce configured tables before retrying`), { code: "V09" });
552
552
  return row?.source;
553
553
  }
554
+ /** The indexed note path for a stem, alias or notes/ path, resolved as `show` resolves it but reading no content. */
555
+ resolve(target: string): string { return this.find(target); }
554
556
  show(target: string, maxBytes = 16384, section?: string, offset?: number): NoteReadResult {
555
557
  if (!Number.isInteger(maxBytes) || maxBytes < 1 || maxBytes > MAX_READ_BYTES) throw new Error(`max-bytes: expected integer 1..${MAX_READ_BYTES}`);
556
558
  if (section !== undefined && (typeof section !== "string" || !section.trim() || /[\r\n]/.test(section) || Buffer.byteLength(section) > 1024)) throw new Error("section: expected one exact H2 heading <=1024 bytes");
package/src/vault-lint.ts CHANGED
@@ -9,7 +9,7 @@ const LEGACY = new Set("CREATE UPDATE MIGRATE REFACTOR MERGE MOVE RELOCATE RENAM
9
9
  const CODE_TITLES: Record<LintCode, string> = {
10
10
  L01: "L01 — dead wiki-link", L02: "L02 — 필수 frontmatter / 허용값", L03: "L03 — orphan",
11
11
  L09: "L09 — 로그 포맷", L10: "L10 — project 값", L11: "L11 — graph report staleness", L12: "L12 — island community", L13: "L13 — filename", L14: "L14 — source paths",
12
- L15: "L15 — proven confidence의 source",
12
+ L15: "L15 — proven confidence의 source", L16: "L16 — evidence drift", L17: "L17 — source changed after updated",
13
13
  };
14
14
  const truth = yamlTruthy;
15
15
  const emptySource = (value: unknown) => !truth(value) || typeof value === "string" && !value.trim();
@@ -110,10 +110,18 @@ function graphChecks(snapshot: AnalysisSnapshot): { l11: string[]; l12: string[]
110
110
  singles.sort();
111
111
  return { l11, l12, info: `nodes ${graph.nodes?.length ?? 0} / edges ${edges.length} / communities ${communities.size}; singleton ${singles.length}개${singles.length ? ": " + singles.slice(0,10).map(s => `\`${s}\``).join(", ") : ""}` };
112
112
  }
113
+ /** Counted, never flagged: notes without `updated`, and paths the bound or an unavailable git left unchecked. */
114
+ function sourceAgeInfo(age: AnalysisSnapshot["sourceAge"]): string {
115
+ if (!age) return "정보: 워크스페이스 루트 없음 (registry 미지정) — L17 생략";
116
+ const parts = [`unknown age ${age.unknownAge}건 (updated 없음, 미검사)`];
117
+ if (age.skipped) parts.push(`미검사 source ${age.skipped}건`);
118
+ if (age.gitUnavailable) parts.push(`git: ${age.gitUnavailable}`);
119
+ return `정보: ${parts.join("; ")}`;
120
+ }
113
121
  export function lintVault(snapshot: AnalysisSnapshot, only?: string): LintReport { return lintDetails(snapshot, only).report; }
114
122
  /** The report plus what only its markdown carries: the note count, check titles and per-check info lines, for the CLI text view. */
115
123
  export function lintDetails(snapshot: AnalysisSnapshot, only?: string): { report: LintReport; notes: number; titles: Record<LintCode, string>; info: Partial<Record<LintCode, string>> } {
116
- const findings: Record<LintCode,string[]> = {L01:[],L02:[],L03:[],L09:[],L10:[],L11:[],L12:[],L13:[],L14:[],L15:[]};
124
+ const findings: Record<LintCode,string[]> = {L01:[],L02:[],L03:[],L09:[],L10:[],L11:[],L12:[],L13:[],L14:[],L15:[],L16:[],L17:[]};
117
125
  const notes = [...snapshot.notes].sort((a,b) => a.path < b.path ? -1 : a.path > b.path ? 1 : 0).map(n => ({...n,...legacyDocument(n.source),stem: n.path.replace(/^notes\//, "").slice(0,-3)}));
118
126
  const stems = new Set(notes.map(n => n.stem)), inlinks = new Map(notes.map(n => [n.stem,0]));
119
127
  // A text the hint pass never reached was not looked up, so its line must not read as a title that merely did not match.
@@ -122,6 +130,8 @@ export function lintDetails(snapshot: AnalysisSnapshot, only?: string): { report
122
130
  for (const note of notes) {
123
131
  const rel = `notes/${note.stem}.md`, prefix = `\`${rel}\`: `, fm = note.fm;
124
132
  for (const message of ownValue(snapshot.sourceWarnings, note.path) ?? []) findings.L14.push(prefix+message);
133
+ for (const message of ownValue(snapshot.evidenceWarnings, note.path) ?? []) findings.L16.push(prefix+message);
134
+ for (const message of ownValue(snapshot.sourceAge?.findings, note.path) ?? []) findings.L17.push(prefix+message);
125
135
  const allLinks: [string,string][] = links(note.body).map(t => ["body",t]);
126
136
  if (fm) for (const field of FIELDS) for (const t of links(fm[field])) allLinks.push([field,t]);
127
137
  for (const [field,t] of allLinks) {
@@ -167,9 +177,9 @@ export function lintDetails(snapshot: AnalysisSnapshot, only?: string): { report
167
177
  }
168
178
  if (data > 20000) findings.L09.push(`log ${data} 라인 > 20000 — 수동 아카이브 권장`);
169
179
  const graph = graphChecks(snapshot); findings.L11 = graph.l11; findings.L12 = graph.l12;
170
- if (only) for (const code of ["L01","L02","L03","L10","L13","L14","L15"] as const) findings[code] = findings[code].filter(s => s.startsWith(`\`${only}\``));
180
+ if (only) for (const code of ["L01","L02","L03","L10","L13","L14","L15","L16","L17"] as const) findings[code] = findings[code].filter(s => s.startsWith(`\`${only}\``));
171
181
  const errors = findings.L01.length + findings.L02.length + findings.L13.length;
172
- const warnings = findings.L03.length + findings.L09.length + findings.L10.length + findings.L11.length + findings.L12.length + findings.L14.length + findings.L15.length;
182
+ const warnings = findings.L03.length + findings.L09.length + findings.L10.length + findings.L11.length + findings.L12.length + findings.L14.length + findings.L15.length + findings.L16.length + findings.L17.length;
173
183
  const summary = `SUMMARY errors=${errors} warnings=${warnings}`;
174
184
  const extra: Partial<Record<LintCode,string>> = {
175
185
  L01: bound ? `정보: 힌트 상한 ${bound.cap}개 텍스트 초과 — ${bound.skipped}개 dead link 텍스트는 힌트 미계산 (미탐 아님)` : "",
@@ -177,6 +187,7 @@ export function lintDetails(snapshot: AnalysisSnapshot, only?: string): { report
177
187
  L03: "hub MOC `notes/index.md`는 설계상 예외",
178
188
  L09: snapshot.log === null ? "정보: log 없음" : `정보: ${legacy ? `legacy TYPE ${legacy}건 (정규화표 등재), 최종 사용 ${last}, 신규 발생 없음` : "legacy TYPE 0건"}`,
179
189
  L10: snapshot.registryIds === null ? "registry 미지정 — plain id 검사 생략" : "", L12: graph.info,
190
+ L17: sourceAgeInfo(snapshot.sourceAge),
180
191
  };
181
192
  const lines = [`<!-- lint.py ${snapshot.today} notes=${notes.length} errors=${errors} warnings=${warnings} -->`,""];
182
193
  for (const code of Object.keys(findings) as LintCode[]) {
@@ -10,17 +10,18 @@ import type { LogEvent } from "./log-types.ts";
10
10
  import { LOG_EVENT_SCHEMA } from "./log-format.ts";
11
11
  import { argumentError } from "./mcp.ts";
12
12
  import { parseTidyMap, tidyVault, TIDY_RULES } from "./tidy.ts";
13
- import { PLAIN, type TextOptions } from "./text-output.ts";
13
+ import { PLAIN, UsageError, type TextOptions } from "./text-output.ts";
14
14
  import { renderTidy, renderWriteReceipt } from "./write-output.ts";
15
15
  const COMMANDS = new Set(["new", "patch", "append", "frontmatter", "link", "supersede", "merge", "move", "delete", "tidy", "report", "check"]);
16
16
  export function isWriteCommand(command: string): boolean { return COMMANDS.has(command); }
17
17
  function object(text: string, label: string): Record<string, unknown> {
18
18
  let value: unknown;
19
- try { value = JSON.parse(text); } catch { throw new Error(`${label}: invalid JSON`); }
20
- if (!value || typeof value !== "object" || Array.isArray(value)) throw new Error(`${label}: expected object`);
19
+ try { value = JSON.parse(text); } catch { throw new UsageError(`${label}: invalid JSON`); }
20
+ if (!value || typeof value !== "object" || Array.isArray(value)) throw new UsageError(`${label}: expected object`);
21
21
  return value as Record<string, unknown>;
22
22
  }
23
- function input(file: string, home: string): string {
23
+ /** Read a `FILE|-` argument as UTF-8 within the write bound, refusing denied paths; also `vmem assert --batch`. */
24
+ export function input(file: string, home: string): string {
24
25
  if (file !== "-" && isDenied(canonicalPath(file), loadRegistry(home).denyPaths)) throw new Error("V06: input path denied");
25
26
  const fd = file === "-" ? 0 : openSync(file, constants.O_RDONLY | constants.O_NOFOLLOW | constants.O_NONBLOCK);
26
27
  try {
@@ -38,9 +39,9 @@ function input(file: string, home: string): string {
38
39
  function logOption(text: string | undefined): { log?: LogEvent } {
39
40
  if (text === undefined) return {};
40
41
  let value: unknown;
41
- try { value = JSON.parse(text); } catch { throw new Error("--log: invalid JSON; expected {\"type\", \"project\", \"source\", \"note\"[, \"dest\"]}"); }
42
+ try { value = JSON.parse(text); } catch { throw new UsageError("--log: invalid JSON; expected {\"type\", \"project\", \"source\", \"note\"[, \"dest\"]}"); }
42
43
  const error = argumentError(value, LOG_EVENT_SCHEMA, "--log");
43
- if (error) throw new Error(`${error}; expected {"type", "project", "source", "note"[, "dest"]} as for log append`);
44
+ if (error) throw new UsageError(`${error}; expected {"type", "project", "source", "note"[, "dest"]} as for log append`);
44
45
  return { log: value as LogEvent };
45
46
  }
46
47
  export function runWriteCommand(command: string, args: string[], home: string, env: NodeJS.ProcessEnv = process.env, text: TextOptions = PLAIN): { text: string; code: number } {
@@ -59,28 +60,28 @@ export function runWriteCommand(command: string, args: string[], home: string, e
59
60
  for (let i = 0; i < args.length; i++) {
60
61
  const arg = args[i]!;
61
62
  if (!arg.startsWith("--")) { positional.push(arg); continue; }
62
- if (Object.hasOwn(flags, arg) || (!values.includes(arg) && !booleans.includes(arg))) throw new Error(`${command}: unknown or repeated option: ${arg}`);
63
+ if (Object.hasOwn(flags, arg) || (!values.includes(arg) && !booleans.includes(arg))) throw new UsageError(`${command}: unknown or repeated option: ${arg}`);
63
64
  if (booleans.includes(arg)) flags[arg] = true;
64
65
  else {
65
66
  const value = args[++i];
66
- if (value === undefined || value.startsWith("--")) throw new Error(`${arg}: value required`);
67
+ if (value === undefined || value.startsWith("--")) throw new UsageError(`${arg}: value required`);
67
68
  flags[arg] = value;
68
69
  }
69
70
  }
70
- const required = (name: string): string => { if (typeof flags[name] !== "string") throw new Error(`${name}: required`); return flags[name] as string; };
71
+ const required = (name: string): string => { if (typeof flags[name] !== "string") throw new UsageError(`${name}: required`); return flags[name] as string; };
71
72
  const optional = (name: string): string | undefined => typeof flags[name] === "string" ? flags[name] as string : undefined;
72
73
  const usage = COMMAND_USAGE.find(item => item.name === command)!.usage;
73
74
  const targets = usage.slice(command.length).split(/\s+(?:--|\[)/, 1)[0]!.match(/<[^>]+>/g) ?? [];
74
75
  if (positional.length !== targets.length) {
75
76
  const expected = targets.length === 2 ? `${targets[0]} and one ${targets[1]}` : targets.join(" and ");
76
- throw new Error(`${command}: takes ${expected}; got ${Math.max(0, positional.length - 1)} targets`);
77
+ throw new UsageError(`${command}: takes ${expected}; got ${Math.max(0, positional.length - 1)} targets`);
77
78
  }
78
79
  const vault = positional[0]!, target = positional[1]!;
79
80
  if (command === "tidy") {
80
81
  const all = flags["--all"] === true, rules = TIDY_RULES.filter(rule => all || flags[`--${rule}`] === true);
81
- if (all && TIDY_RULES.some(rule => flags[`--${rule}`] === true)) throw new Error("tidy: use rule flags or --all, not both");
82
- if (!rules.length) throw new Error("tidy: select at least one rule (--connections --escapes --enums --keys --sources --topics --secrets --log) or --all");
83
- if (flags["--dry-run"] && flags["--confirm"]) throw new Error("tidy: --dry-run and --confirm are exclusive");
82
+ if (all && TIDY_RULES.some(rule => flags[`--${rule}`] === true)) throw new UsageError("tidy: use rule flags or --all, not both");
83
+ if (!rules.length) throw new UsageError("tidy: select at least one rule (--connections --escapes --enums --keys --sources --topics --secrets --log) or --all");
84
+ if (flags["--dry-run"] && flags["--confirm"]) throw new UsageError("tidy: --dry-run and --confirm are exclusive");
84
85
  const mapText = optional("--map") !== undefined ? input(required("--map"), home) : undefined;
85
86
  const result = tidyVault(home, { vault, rules, ...(mapText !== undefined ? { map: parseTidyMap(mapText), mapText } : {}), confirm: flags["--confirm"] === true && !flags["--dry-run"], fingerprint: optional("--fingerprint"), channel: "cli" }, { env });
86
87
  return { text: flags["--json"] ? JSON.stringify(result) : renderTidy(result, text, { argv: [command, ...args], positional }), code: result.ok ? 0 : 1 };
@@ -90,18 +91,18 @@ export function runWriteCommand(command: string, args: string[], home: string, e
90
91
  case "new": {
91
92
  const frontmatter = optional("--extra") ? object(required("--extra"), "extra") : {};
92
93
  for (const key of ["type", "domain", "description", "title", "source", "confidence", "status"]) if (optional(`--${key}`) !== undefined) frontmatter[key] = optional(`--${key}`);
93
- if(optional("--source")?.trim().startsWith("["))try{frontmatter.source=JSON.parse(required("--source"));}catch{throw new Error("--source: expected a string or JSON array of strings");}
94
+ if(optional("--source")?.trim().startsWith("["))try{frontmatter.source=JSON.parse(required("--source"));}catch{throw new UsageError("--source: expected a string or JSON array of strings");}
94
95
  if (optional("--topics") !== undefined) frontmatter.topics = required("--topics").split(",").filter(Boolean).map(value => value.startsWith("[[") ? value : `[[${value}]]`);
95
96
  operation = { op: "create", path: target, frontmatter, ...(optional("--body") ? { body: input(required("--body"), home) } : {}) }; break;
96
97
  }
97
98
  case "patch": {
98
99
  // --edits takes the same JSON array as the MCP `edits` argument.
99
100
  if (optional("--edits") === undefined) { operation = { op: "patch", path: target, oldString: required("--old"), newString: required("--new"), expectedSha: optional("--expected-sha") }; break; }
100
- if (optional("--old") !== undefined || optional("--new") !== undefined) throw new Error("patch: use --old/--new or --edits, not both");
101
+ if (optional("--old") !== undefined || optional("--new") !== undefined) throw new UsageError("patch: use --old/--new or --edits, not both");
101
102
  const text = input(required("--edits"), home);
102
103
  let edits: unknown;
103
- try { edits = JSON.parse(text); } catch { throw new Error("--edits: invalid JSON; expected an array of {oldString, newString}"); }
104
- if (!Array.isArray(edits)) throw new Error("--edits: expected a JSON array of {oldString, newString}");
104
+ try { edits = JSON.parse(text); } catch { throw new UsageError("--edits: invalid JSON; expected an array of {oldString, newString}"); }
105
+ if (!Array.isArray(edits)) throw new UsageError("--edits: expected a JSON array of {oldString, newString}");
105
106
  operation = { op: "patch", path: target, edits: edits as PatchEdit[], expectedSha: optional("--expected-sha") }; break;
106
107
  }
107
108
  case "append": operation = { op: "append", path: target, section: required("--section"), markdown: required("--markdown"), expectedSha: optional("--expected-sha") }; break;
@@ -7,16 +7,16 @@ import type { ChangeReceipt, WriteIssue, WriteReceipt } from "./write-types.ts";
7
7
  import type { LogReceipt } from "./log-types.ts";
8
8
  import type { TidyResult } from "./tidy.ts";
9
9
  import type { OrgPromoteResult } from "./org-promote.ts";
10
- import type { SyncResult } from "./sync.ts";
10
+ import { STAGED_DESCRIPTION, type SyncResult } from "./sync.ts";
11
11
  import type { PromoteResult } from "./promote.ts";
12
12
  import { notePath } from "./write-operations.ts";
13
- import { blocks, clean, fields, heading, issueTable, nextCommand, paragraph, plural, shellWord, table, type TextOptions, type Tone } from "./text-output.ts";
13
+ import { blocks, clean, fields, heading, issueTable, marker, nextCommand, paragraph, plural, shellWord, summary, table, type TextOptions, type Tone } from "./text-output.ts";
14
14
 
15
15
  /** The words the command was run with (`[command, ...args]`, no `--color`) and its positional arguments. */
16
16
  export interface WriteContext { argv: string[]; positional: string[] }
17
17
  type Candidates = { projects: { project: string; candidates: { id: string; project: string; kind: string; title: string | null; at: string }[] }[] };
18
18
 
19
- const line = (text: string, o: TextOptions, t?: Tone) => paragraph(text, o, t);
19
+ const line = (text: string, o: TextOptions, t?: Tone) => paragraph(t === "ok" || t === "warn" || t === "fail" ? `${marker(t, { ...o, color: false })} ${text}` : text, o, t);
20
20
  const list = (label: string, items: readonly string[] | undefined) => items?.length ? [`${label}:`, ...items.map(item => ` - ${clean(item)}`)].join("\n") : undefined;
21
21
  const canonList = (rows: readonly CanonRowMatch[] | undefined) => list("canonical rows", rows?.map(row => `${row.path}:${row.line} ${row.key}: ${row.row}`));
22
22
  const short = (sha: string | null) => sha ? sha.slice(0, 12) : "-";
@@ -63,7 +63,7 @@ export function renderWriteReceipt(r: WriteReceipt, o: TextOptions, ctx: WriteCo
63
63
  if (command === "check") {
64
64
  const path = r.changes[0]?.path ?? r.issues.find(issue => issue.path)?.path ?? "the note", e = errors(r.issues), w = r.issues.length - e;
65
65
  const verdict = r.ok ? `ok: ${path} passes validation${w ? ` (${plural(w, "warning")})` : ""}` : `fail: ${path} has ${plural(e, "error")}${w ? ` and ${plural(w, "warning")}` : ""}`;
66
- return blocks(issues, line(verdict, o, r.ok ? "ok" : "fail"));
66
+ return blocks(issues, line(verdict, o, r.ok ? "ok" : "fail"), summary({ failed: e || (r.ok ? 0 : 1), warnings: w, ok: r.ok ? 1 : 0 }, o));
67
67
  }
68
68
  const twoStep = command === "merge" || command === "move" || command === "delete";
69
69
  const hasState = r.changes.some(change => change.applied !== undefined);
@@ -84,7 +84,7 @@ export function renderWriteReceipt(r: WriteReceipt, o: TextOptions, ctx: WriteCo
84
84
  list("merged source", r.merge.source), list("merged topics", r.merge.topics),
85
85
  r.merge.inboundLinks.length ? heading("INBOUND LINKS", o) + "\n" + table(["PATH", "FIELD", "TARGET", "REPLACEMENT", "LINE"], r.merge.inboundLinks.map(link => [link.path, link.field, link.target + (link.block ? `#^${link.block}` : link.heading ? `#${link.heading}` : ""), link.replacement + (link.block ? `#^${link.block}` : link.heading ? `#${link.heading}` : ""), link.line ?? "-"]), o) : line("inbound links: none", o, "muted"),
86
86
  ) : undefined;
87
- return blocks([line(head, o, t), one].filter(Boolean).join("\n"), changes, merge, issues, list("possible duplicates", r.possibleDuplicates), list("retained backups", r.retainedBackups), log, confirm);
87
+ return blocks([line(head, o, t), one].filter(Boolean).join("\n"), changes, merge, list(r.preview ? "subjects to relink" : "subjects relinked", r.assertions?.relinked), r.assertions?.omitted ? line(`${r.assertions.omitted} relinked subject ids omitted; inspect the assertion journal`, o, "muted") : undefined, r.assertions?.issue ? issueTable([r.assertions.issue], o) : undefined, issues, list("possible duplicates", r.possibleDuplicates), list("retained backups", r.retainedBackups), log, confirm);
88
88
  }
89
89
 
90
90
  /** `tidy`: counts per rule and the notes touched, then the confirm command. */
@@ -132,7 +132,7 @@ export function renderSync(r: SyncResult, o: TextOptions, ctx: WriteContext): st
132
132
  const info = r.branch === null ? "" : fields([["vault", r.vault], ["branch", r.branch], ["remote", r.remote.configured], ["origin", r.remote.origin], ["ahead", r.ahead], ["behind", r.behind]], o);
133
133
  const paths = r.paths.length ? table(["PATH"], r.paths.map(path => [path]), o) : undefined;
134
134
  const confirm = r.ok && r.preview && work && r.fingerprint ? nextCommand("confirm", confirmCommand(ctx.argv, r.fingerprint), o) : undefined;
135
- return blocks([line(head, o, t), info].filter(Boolean).join("\n"), paths, list("not synced (outside notes/, reports/ and log)", r.ignored), issueTable(r.issues, o), confirm);
135
+ return blocks([line(head, o, t), info].filter(Boolean).join("\n"), paths, list(`not synced (outside ${STAGED_DESCRIPTION})`, r.ignored), issueTable(r.issues, o), confirm);
136
136
  }
137
137
 
138
138
  /** `promote-from-amem <vault>`: the candidate table per project. */
@@ -54,6 +54,7 @@ export interface WriteReceipt {
54
54
  preview?: boolean;
55
55
  possibleDuplicates?: string[];
56
56
  merge?: MergePreview;
57
+ assertions?: { relinked: string[]; relinkedCount?: number; omitted?: number; issue?: WriteIssue };
57
58
  indexUpdated: boolean;
58
59
  /** Original relative names of backups retained for recovery after drift/failed rollback. */
59
60
  retainedBackups?: string[];
@@ -9,6 +9,7 @@ import { MAX_WRITE_BYTES, type PlannedChange, type ValidationContext, type Write
9
9
  import type { PiiSurface } from "./config.ts";
10
10
  import { screenPii } from "./pii.ts";
11
11
  import { moveSourcePath } from "./write-operations.ts";
12
+ import { evidenceProblem } from "./evidence.ts";
12
13
 
13
14
  const TYPES = new Set(["insight", "decision", "observation", "person", "project", "method", "moc", "reference"]);
14
15
  const CONFIDENCE = new Set(["proven", "likely", "experimental"]);
@@ -19,7 +20,7 @@ const KEYS = new Set([
19
20
  "methodology", "evidence_strength", "project", "alternatives", "superseded_by", "supersedes", "stakeholders",
20
21
  "course", "semester", "student_level", "institution", "policy_area", "role", "affiliation", "last_contact",
21
22
  "tool", "category", "resolution_status", "aliases", "tags", "cssclasses", "title", "created", "updated", "received", "entities",
22
- "promoted_from", "promoted_at", "promoted_to", "source_ref",
23
+ "promoted_from", "promoted_at", "promoted_to", "source_ref", "evidence",
23
24
  // Adopted in the V2 cutover (#22): decision dates/owners and person contact fields.
24
25
  "decided_at", "decided_by", "email", "phone",
25
26
  "citekey", "doi", "arxiv_id", "authors", "year", "venue",
@@ -162,6 +163,7 @@ function schema(note: ParsedNote, vault: VaultSpec): SchemaIssue[] {
162
163
  if (data[key] !== undefined && (typeof data[key] !== "string" || !allowed.has(data[key]))) add(key,`invalid ${key} enum`);
163
164
  }
164
165
  if(data.source!==undefined)try{sourceReferences(data.source);}catch{add("source","source must contain workspace-relative paths, mem ids or URLs");}
166
+ if(data.evidence!==undefined){const problem=evidenceProblem(data.evidence,data.source);if(problem)add("evidence",problem,["evidence","source"]);}
165
167
  if (data.type === "reference") {
166
168
  if (data.citekey !== undefined && (typeof data.citekey !== "string" || !/^[A-Za-z0-9_:-]{1,64}(?![\s\S])/.test(data.citekey))) add("citekey", "citekey must match [A-Za-z0-9_:-]{1,64}");
167
169
  if (data.doi !== undefined && (typeof data.doi !== "string" || !/^10\.[0-9]{4,9}\/[^\s\p{C}]+(?![\s\S])/u.test(data.doi))) add("doi", "doi must be 10.<4..9 digit registrant>/<nonempty suffix>, without whitespace or control characters");