memory-cli 0.1.0__py3-none-any.whl

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 (128) hide show
  1. memory_cli/__init__.py +1 -0
  2. memory_cli/__main__.py +49 -0
  3. memory_cli/capture/__init__.py +7 -0
  4. memory_cli/capture/codex_rollout.py +164 -0
  5. memory_cli/capture/event_lines.py +66 -0
  6. memory_cli/capture/extract.py +458 -0
  7. memory_cli/capture/state.py +183 -0
  8. memory_cli/commands/__init__.py +21 -0
  9. memory_cli/commands/admin.py +363 -0
  10. memory_cli/commands/common.py +609 -0
  11. memory_cli/commands/curate.py +1189 -0
  12. memory_cli/commands/diagnostics.py +126 -0
  13. memory_cli/commands/edit.py +1282 -0
  14. memory_cli/commands/hooks.py +730 -0
  15. memory_cli/commands/import_recovery.py +45 -0
  16. memory_cli/commands/install.py +152 -0
  17. memory_cli/commands/integrate.py +480 -0
  18. memory_cli/commands/memory.py +2152 -0
  19. memory_cli/commands/read.py +1290 -0
  20. memory_cli/commands/sources.py +766 -0
  21. memory_cli/commands/split.py +97 -0
  22. memory_cli/commands/split_plan.py +196 -0
  23. memory_cli/commands/split_transaction.py +230 -0
  24. memory_cli/commands/synthesis.py +1122 -0
  25. memory_cli/core/__init__.py +16 -0
  26. memory_cli/core/auto_state.py +30 -0
  27. memory_cli/core/codex_pass.py +109 -0
  28. memory_cli/core/config.py +87 -0
  29. memory_cli/core/file_journal.py +163 -0
  30. memory_cli/core/headless.py +130 -0
  31. memory_cli/core/jobs.py +130 -0
  32. memory_cli/core/resources.py +57 -0
  33. memory_cli/core/runner.py +398 -0
  34. memory_cli/core/safe_io.py +155 -0
  35. memory_cli/core/store_git.py +407 -0
  36. memory_cli/core/yaml_load.py +14 -0
  37. memory_cli/corroborate/__init__.py +11 -0
  38. memory_cli/corroborate/cli.py +267 -0
  39. memory_cli/corroborate/decide.py +893 -0
  40. memory_cli/corroborate/digest.py +425 -0
  41. memory_cli/corroborate/fill.py +744 -0
  42. memory_cli/corroborate/job.py +15 -0
  43. memory_cli/corroborate/reword.py +446 -0
  44. memory_cli/corroborate/run.py +1142 -0
  45. memory_cli/corroborate/state.py +300 -0
  46. memory_cli/digest/__init__.py +4 -0
  47. memory_cli/digest/lessons.py +483 -0
  48. memory_cli/entry/__init__.py +12 -0
  49. memory_cli/entry/auto.py +660 -0
  50. memory_cli/entry/capture.py +1403 -0
  51. memory_cli/entry/corroborate.py +214 -0
  52. memory_cli/entry/integrate.py +684 -0
  53. memory_cli/entry/integrate_self_check.py +203 -0
  54. memory_cli/entry/research.py +9 -0
  55. memory_cli/entry/settle.py +614 -0
  56. memory_cli/entry/split_auto.py +460 -0
  57. memory_cli/entry/synthesize.py +22 -0
  58. memory_cli/integrate/__init__.py +9 -0
  59. memory_cli/integrate/answers.py +42 -0
  60. memory_cli/integrate/briefs/check-brief.md +16 -0
  61. memory_cli/integrate/briefs/place-brief.md +26 -0
  62. memory_cli/integrate/log.py +43 -0
  63. memory_cli/integrate/plan.py +125 -0
  64. memory_cli/integrate/rows.py +99 -0
  65. memory_cli/integrate/state.py +158 -0
  66. memory_cli/integrate/undo.py +143 -0
  67. memory_cli/mem.py +1180 -0
  68. memory_cli/memories/__init__.py +16 -0
  69. memory_cli/memories/fingerprints.py +51 -0
  70. memory_cli/memories/journal.py +93 -0
  71. memory_cli/memories/locations.py +282 -0
  72. memory_cli/memories/matching.py +451 -0
  73. memory_cli/memories/model.py +205 -0
  74. memory_cli/memories/parse.py +237 -0
  75. memory_cli/memories/records.py +266 -0
  76. memory_cli/memories/rules.py +291 -0
  77. memory_cli/memories/sightings.py +314 -0
  78. memory_cli/memories/terms.py +148 -0
  79. memory_cli/memories/write.py +358 -0
  80. memory_cli/notes/__init__.py +13 -0
  81. memory_cli/notes/check.py +806 -0
  82. memory_cli/notes/due.py +260 -0
  83. memory_cli/notes/fields.py +217 -0
  84. memory_cli/notes/index.py +230 -0
  85. memory_cli/notes/links.py +170 -0
  86. memory_cli/notes/note.py +222 -0
  87. memory_cli/notes/search.py +391 -0
  88. memory_cli/notes/split_candidates.py +72 -0
  89. memory_cli/research/__init__.py +5 -0
  90. memory_cli/research/checks.py +1065 -0
  91. memory_cli/research/pipeline.py +952 -0
  92. memory_cli/session/__init__.py +5 -0
  93. memory_cli/session/handoff.py +139 -0
  94. memory_cli/session/notices.py +111 -0
  95. memory_cli/settle/__init__.py +5 -0
  96. memory_cli/settle/state.py +111 -0
  97. memory_cli/settle/verdicts.py +693 -0
  98. memory_cli/split/briefs/checker-brief.md +5 -0
  99. memory_cli/split/briefs/editor-brief.md +20 -0
  100. memory_cli/syntheses/__init__.py +8 -0
  101. memory_cli/syntheses/document.py +400 -0
  102. memory_cli/syntheses/edit.py +581 -0
  103. memory_cli/syntheses/project.py +384 -0
  104. memory_cli/syntheses/split_conservation.py +50 -0
  105. memory_cli/syntheses/units.py +427 -0
  106. memory_cli/synthesize/__init__.py +9 -0
  107. memory_cli/synthesize/backfill.py +431 -0
  108. memory_cli/synthesize/briefs/backfill-brief.md +26 -0
  109. memory_cli/synthesize/briefs/checker-brief.md +13 -0
  110. memory_cli/synthesize/briefs/fixer-brief.md +19 -0
  111. memory_cli/synthesize/briefs/memory-brief.md +30 -0
  112. memory_cli/synthesize/briefs/settle-brief.md +32 -0
  113. memory_cli/synthesize/briefs/verdict-brief.md +50 -0
  114. memory_cli/synthesize/briefs/web-brief.md +33 -0
  115. memory_cli/synthesize/cli.py +311 -0
  116. memory_cli/synthesize/pipeline.py +764 -0
  117. memory_cli/synthesize/references.py +164 -0
  118. memory_cli/synthesize/run.py +150 -0
  119. memory_cli/synthesize/topics.py +528 -0
  120. memory_cli/templates/knowledge.md +23 -0
  121. memory_cli/templates/literature.md +25 -0
  122. memory_cli/templates/research.md +23 -0
  123. memory_cli/templates/synthesis.md +6 -0
  124. memory_cli-0.1.0.dist-info/METADATA +102 -0
  125. memory_cli-0.1.0.dist-info/RECORD +128 -0
  126. memory_cli-0.1.0.dist-info/WHEEL +4 -0
  127. memory_cli-0.1.0.dist-info/entry_points.txt +9 -0
  128. memory_cli-0.1.0.dist-info/licenses/LICENSE +21 -0
@@ -0,0 +1,260 @@
1
+ """Requirement rows and the due queries: `rule_requirements` and the re-test, re-read and review lists. Pure."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import datetime
6
+ import re
7
+ from typing import TYPE_CHECKING
8
+
9
+ from memory_cli.notes import note as notes_mod
10
+ from memory_cli.notes.fields import _DATE, Problem
11
+ from memory_cli.notes.note import (
12
+ FrontmatterError,
13
+ descendants,
14
+ discover_notes,
15
+ load_topics,
16
+ root_of,
17
+ )
18
+
19
+ if TYPE_CHECKING:
20
+ from pathlib import Path
21
+
22
+ from memory_cli.notes.note import Note
23
+
24
+
25
+ _REQUIREMENTS = "docs/requirements.md"
26
+ _INTENT_ID = re.compile(r"I-[0-9]+")
27
+ _CONCRETE_ID = re.compile(r"C-[0-9]+")
28
+ # Cells of a concrete requirement row: ID, Requirement, Serves, Rests on, Revisit when, Review by.
29
+ REQUIREMENT_CELLS = 6
30
+
31
+
32
+ def _backtick_run(line: str, i: int) -> str:
33
+ """The run of backticks that starts at `line[i]`."""
34
+ return "`" * (len(line) - i - len(line[i:].lstrip("`")))
35
+
36
+
37
+ def _split_cells(line: str) -> list[str]:
38
+ """Cells of a table row, split on '|' outside inline code spans (a literal '|' in a cell is unsupported)."""
39
+ line = line.strip().removeprefix("|").removesuffix("|")
40
+ cells, start, i = [], 0, 0
41
+ while i < len(line):
42
+ if line[i] == "`":
43
+ run = _backtick_run(line, i)
44
+ close = line.find(run, i + len(run))
45
+ i = close + len(run) if close != -1 else i + len(run)
46
+ elif line[i] == "|":
47
+ cells.append(line[start:i].strip())
48
+ start = i = i + 1
49
+ else:
50
+ i += 1
51
+ cells.append(line[start:].strip())
52
+ return cells
53
+
54
+
55
+ def _requirement_rows(root: Path) -> list[tuple[int, list[str]]] | None:
56
+ """(line, cells) of the table rows whose first cell is an I-n or C-n id; None when the file is absent."""
57
+ path = root / _REQUIREMENTS
58
+ if not path.is_file():
59
+ return None
60
+ try:
61
+ text = notes_mod._read_text(path)
62
+ except FrontmatterError:
63
+ return None
64
+ rows = []
65
+ for number, line in enumerate(text.split("\n"), 1):
66
+ if line.lstrip().startswith("|"):
67
+ cells = _split_cells(line)
68
+ if _INTENT_ID.fullmatch(cells[0]) or _CONCRETE_ID.fullmatch(cells[0]):
69
+ rows.append((number, cells))
70
+ return rows
71
+
72
+
73
+ def _iso_date(value: str) -> datetime.date | None:
74
+ if not _DATE.fullmatch(value):
75
+ return None
76
+ try:
77
+ return datetime.date.fromisoformat(value)
78
+ except ValueError:
79
+ return None
80
+
81
+
82
+ def rule_requirements(root: Path, notes: list[Note], topics: dict | None) -> list[Problem]:
83
+ """Rule 12: docs/requirements.md rows are well formed (checked only when the file exists)."""
84
+ rows = _requirement_rows(root)
85
+ if not rows:
86
+ return []
87
+ problems = []
88
+ seen: set[str] = set()
89
+ intents = {cells[0] for _, cells in rows if _INTENT_ID.fullmatch(cells[0])}
90
+ for number, cells in rows:
91
+ ident = cells[0]
92
+ if ident in seen:
93
+ problems.append(
94
+ Problem(
95
+ _REQUIREMENTS,
96
+ number,
97
+ f"duplicate id {ident}: give each requirement a unique id",
98
+ )
99
+ )
100
+ seen.add(ident)
101
+ if _CONCRETE_ID.fullmatch(ident):
102
+ problems += _concrete_row_problems(number, cells, intents)
103
+ return problems
104
+
105
+
106
+ def _concrete_row_problems(number: int, cells: list[str], intents: set[str]) -> list[Problem]:
107
+ ident = cells[0]
108
+ if len(cells) != REQUIREMENT_CELLS:
109
+ return [
110
+ Problem(
111
+ _REQUIREMENTS,
112
+ number,
113
+ f"{ident} has {len(cells)} cells: use exactly {REQUIREMENT_CELLS} "
114
+ "(ID, Requirement, Serves, Rests on, Revisit when, Review by)",
115
+ )
116
+ ]
117
+ problems = []
118
+ if _iso_date(cells[5]) is None:
119
+ problems.append(
120
+ Problem(
121
+ _REQUIREMENTS,
122
+ number,
123
+ f"{ident} has an invalid 'Review by' date "
124
+ f"'{cells[5]}': use a real date as YYYY-MM-DD",
125
+ )
126
+ )
127
+ served = [c.strip() for c in cells[2].split(",")]
128
+ unknown = [c for c in served if c not in intents]
129
+ if unknown:
130
+ problems.append(
131
+ Problem(
132
+ _REQUIREMENTS,
133
+ number,
134
+ f"{ident} serves unknown intent "
135
+ f"{', '.join(repr(u) for u in unknown)}: list existing I-ids, comma-separated",
136
+ )
137
+ )
138
+ return problems
139
+
140
+
141
+ # Model-specific advice ages; see docs/requirements.md C-13.
142
+ MODEL_SPECIFIC_ROOT = "llm"
143
+ # Days after `updated` before such a note is listed for re-testing; see docs/requirements.md C-13.
144
+ RETEST_DAYS = 365
145
+ # Days after `added` (the date the source was last read) before a vendor web page is listed for re-reading;
146
+ # see docs/requirements.md C-15.
147
+ REREAD_DAYS = 182
148
+
149
+
150
+ def _retest_lines(notes: list[Note], topics: dict, today: datetime.date) -> list[str]:
151
+ if MODEL_SPECIFIC_ROOT not in topics:
152
+ return []
153
+ scope = descendants(topics, MODEL_SPECIFIC_ROOT)
154
+ # Only notes homed in llm's domain: a math note tagged llm-evaluation states statistics, not model behaviour.
155
+ home = f"knowledge/{root_of(topics, MODEL_SPECIFIC_ROOT)}/"
156
+ lines = []
157
+ for note in notes:
158
+ if (
159
+ note.type != "knowledge"
160
+ or note.error is not None
161
+ or not isinstance(note.meta, dict)
162
+ or not note.rel.startswith(home)
163
+ ):
164
+ continue
165
+ listed = note.meta.get("topics")
166
+ updated = (
167
+ _iso_date(note.meta["updated"]) if isinstance(note.meta.get("updated"), str) else None
168
+ )
169
+ if (
170
+ updated is None
171
+ or not isinstance(listed, list)
172
+ or not scope.intersection(t for t in listed if isinstance(t, str))
173
+ ):
174
+ continue
175
+ if (today - updated).days > RETEST_DAYS:
176
+ lines.append(
177
+ f"{note.rel}:1: re-test: updated {updated}; "
178
+ "advice that depends on model behaviour ages (spec 5.4)"
179
+ )
180
+ return lines
181
+
182
+
183
+ def _reread_lines(notes: list[Note], topics: dict, today: datetime.date) -> list[str]:
184
+ if MODEL_SPECIFIC_ROOT not in topics:
185
+ return []
186
+ scope = descendants(topics, MODEL_SPECIFIC_ROOT)
187
+ home = f"literature/{root_of(topics, MODEL_SPECIFIC_ROOT)}/"
188
+ lines = []
189
+ for note in notes:
190
+ if (
191
+ note.type != "literature"
192
+ or note.error is not None
193
+ or not isinstance(note.meta, dict)
194
+ or not note.rel.startswith(home)
195
+ or note.meta.get("kind") != "web"
196
+ ):
197
+ continue
198
+ listed = note.meta.get("topics")
199
+ added = _iso_date(note.meta["added"]) if isinstance(note.meta.get("added"), str) else None
200
+ if (
201
+ added is None
202
+ or not isinstance(listed, list)
203
+ or not scope.intersection(t for t in listed if isinstance(t, str))
204
+ ):
205
+ continue
206
+ if (today - added).days > REREAD_DAYS:
207
+ lines.append(
208
+ f"{note.rel}:1: re-read: added {added}; vendor documentation changes (spec 5.3)"
209
+ )
210
+ return lines
211
+
212
+
213
+ def due_retests(root: Path, today: datetime.date) -> list[str]:
214
+ """Lines for knowledge notes on llm topics not updated within RETEST_DAYS, sorted by path."""
215
+ try:
216
+ topics = load_topics(root)
217
+ except FrontmatterError: # `check` reports an unusable topics.yaml
218
+ return []
219
+ return (
220
+ _retest_lines(discover_notes(root), topics, today) if MODEL_SPECIFIC_ROOT in topics else []
221
+ )
222
+
223
+
224
+ def due_rereads(root: Path, today: datetime.date) -> list[str]:
225
+ """Lines for llm web literature notes whose `added` is over REREAD_DAYS old, sorted by path."""
226
+ try:
227
+ topics = load_topics(root)
228
+ except FrontmatterError: # `check` reports an unusable topics.yaml
229
+ return []
230
+ return (
231
+ _reread_lines(discover_notes(root), topics, today) if MODEL_SPECIFIC_ROOT in topics else []
232
+ )
233
+
234
+
235
+ def due_counts(root: Path, today: datetime.date) -> tuple[int, int]:
236
+ """(notes to re-test, notes to re-read) from one scan; the same notes the two line lists above report."""
237
+ try:
238
+ topics = load_topics(root)
239
+ except FrontmatterError:
240
+ return 0, 0
241
+ if MODEL_SPECIFIC_ROOT not in topics:
242
+ return 0, 0
243
+ notes = discover_notes(root)
244
+ return len(_retest_lines(notes, topics, today)), len(_reread_lines(notes, topics, today))
245
+
246
+
247
+ def due_requirements(root: Path, today: datetime.date) -> list[str]:
248
+ """One line per concrete requirement whose 'Review by' date is today or earlier, in file order."""
249
+ lines = []
250
+ for number, cells in _requirement_rows(root) or []:
251
+ if (
252
+ _CONCRETE_ID.fullmatch(cells[0])
253
+ and len(cells) == REQUIREMENT_CELLS
254
+ and (due := _iso_date(cells[5]))
255
+ and due <= today
256
+ ):
257
+ lines.append(
258
+ f"{_REQUIREMENTS}:{number}: {cells[0]} due for review since {due}: {cells[1]}"
259
+ )
260
+ return lines
@@ -0,0 +1,217 @@
1
+ """Field rules of a note's frontmatter: the `Problem` record, the per-field validators and the type schemas. Pure."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import datetime
6
+ import re
7
+ from collections.abc import Callable
8
+ from typing import Any, NamedTuple
9
+
10
+
11
+ class Problem(NamedTuple):
12
+ path: str
13
+ line: int
14
+ message: str
15
+
16
+ def __str__(self) -> str:
17
+ return f"{self.path}:{self.line}: {self.message}"
18
+
19
+
20
+ _DATE = re.compile(r"[0-9]{4}-[0-9]{2}-[0-9]{2}")
21
+ _MONTH = re.compile(r"[0-9]{4}-(0[1-9]|1[0-2])")
22
+
23
+ # Rule 11. Noun/verb homographs (check, test, cache, index, scale, prompt, query, start, stop,
24
+ # move, pin, separate, split, run, read, write, log, record, set, limit, measure, document,
25
+ # store) are left out on purpose, so a real claim is not rejected. Known limitation: a claim
26
+ # that starts with one of these words (use-after-free-...) is rejected too.
27
+ _IMPERATIVES = frozenset({
28
+ "add",
29
+ "always",
30
+ "apply",
31
+ "ask",
32
+ "avoid",
33
+ "choose",
34
+ "compare",
35
+ "consider",
36
+ "curate",
37
+ "define",
38
+ "do",
39
+ "dont",
40
+ "ensure",
41
+ "fix",
42
+ "give",
43
+ "include",
44
+ "isolate",
45
+ "keep",
46
+ "make",
47
+ "never",
48
+ "prefer",
49
+ "put",
50
+ "remove",
51
+ "replace",
52
+ "require",
53
+ "show",
54
+ "tell",
55
+ "treat",
56
+ "try",
57
+ "use",
58
+ "validate",
59
+ "verify",
60
+ "wrap",
61
+ })
62
+ _INSTRUCTION_FIX = 'rename to a declarative claim such as "x-is-y" and update links'
63
+
64
+
65
+ def instruction_word(stem: str) -> str | None:
66
+ """The imperative that makes a knowledge file stem read as an instruction, else None.
67
+
68
+ Looked at: the first token and the token right after a "so" or "then" token.
69
+ """
70
+ tokens = stem.split("-")
71
+ positions = [0] + [i + 1 for i, t in enumerate(tokens[:-1]) if t in {"so", "then"}]
72
+ return next((tokens[i] for i in positions if tokens[i] in _IMPERATIVES), None)
73
+
74
+
75
+ Validator = Callable[[Any], "str | None"]
76
+
77
+
78
+ def _string(v: Any) -> str | None:
79
+ return None if isinstance(v, str) and v.strip() else "set a non-empty string"
80
+
81
+
82
+ def _enum(*allowed: str) -> Validator:
83
+ def check_enum(v: Any) -> str | None:
84
+ return None if v in allowed else f"use one of {', '.join(allowed)}"
85
+
86
+ return check_enum
87
+
88
+
89
+ def _year(v: Any) -> str | None:
90
+ return None if isinstance(v, int) and not isinstance(v, bool) else "set an integer year"
91
+
92
+
93
+ def _url(v: Any) -> str | None:
94
+ ok = isinstance(v, str) and v.startswith(("http://", "https://"))
95
+ return None if ok else "start the url with http:// or https://"
96
+
97
+
98
+ def _date(v: Any) -> str | None:
99
+ if isinstance(v, str) and _DATE.fullmatch(v):
100
+ try:
101
+ datetime.date.fromisoformat(v)
102
+ return None
103
+ except ValueError:
104
+ pass
105
+ return "use a real date as a YYYY-MM-DD string"
106
+
107
+
108
+ def _month(v: Any) -> str | None:
109
+ return None if isinstance(v, str) and _MONTH.fullmatch(v) else 'use a "YYYY-MM" string'
110
+
111
+
112
+ def _authors(v: Any) -> str | None:
113
+ ok = isinstance(v, list) and v and all(isinstance(a, str) and a.strip() for a in v)
114
+ return None if ok else "set a list of one or more non-empty strings"
115
+
116
+
117
+ def _topics(v: Any) -> str | None:
118
+ ok = isinstance(v, list) and all(isinstance(t, str) for t in v)
119
+ return None if ok else "set a list of topic ids from topics.yaml"
120
+
121
+
122
+ _PART_OF = re.compile(r"[a-z0-9]+(?:-[a-z0-9]+)*#[a-z0-9]+(?:-[a-z0-9]+)*")
123
+
124
+
125
+ def _part_of(v: Any) -> str | None:
126
+ return (
127
+ None
128
+ if isinstance(v, str) and _PART_OF.fullmatch(v)
129
+ else "use <synthesis handle>#<section handle>"
130
+ )
131
+
132
+
133
+ def _part_hash(v: Any) -> str | None:
134
+ return (
135
+ None
136
+ if isinstance(v, str) and re.fullmatch(r"(?:u:)?[0-9a-f]{10}", v)
137
+ else "set the 10-hex fingerprint of the section (`u:` first for a per-note one)"
138
+ )
139
+
140
+
141
+ def _handle_value(v: Any) -> str | None:
142
+ return None if isinstance(v, str) and v.strip() else "use the handle of a note"
143
+
144
+
145
+ def _handle_list(v: Any) -> str | None:
146
+ ok = isinstance(v, list) and all(isinstance(h, str) and h.strip() for h in v)
147
+ return None if ok else "set a list of note handles"
148
+
149
+
150
+ _DISPUTE_KEYS = ("date", "fact", "source", "quote")
151
+
152
+
153
+ def _disputed(v: Any) -> str | None:
154
+ hint = (
155
+ "set a non-empty list of {date, fact, source, quote} entries (mem note dispute writes them)"
156
+ )
157
+ if not isinstance(v, list) or not v:
158
+ return hint
159
+ for entry in v:
160
+ if not isinstance(entry, dict) or set(entry) != set(_DISPUTE_KEYS):
161
+ return hint
162
+ if (
163
+ _date(entry["date"]) is not None
164
+ or any(not isinstance(entry[k], str) or not entry[k].strip() for k in _DISPUTE_KEYS[1:])
165
+ or _url(entry["source"]) is not None
166
+ ):
167
+ return hint
168
+ return None
169
+
170
+
171
+ LEVELS = ("basic", "beginner", "intermediate", "advanced", "expert", "niche")
172
+ # Fields a note may omit. Empty since 2026-11-07: `level` became required once every note had one (ADR 0004).
173
+ OPTIONAL_FIELDS: frozenset[str] = frozenset({
174
+ "part_of",
175
+ "part_of_hash",
176
+ "superseded_by",
177
+ "distinct_from",
178
+ "disputed",
179
+ })
180
+
181
+ # Field order follows the spec tables; `new` writes fields in this order.
182
+ SCHEMAS: dict[str, dict[str, Validator]] = {
183
+ "literature": {
184
+ "title": _string,
185
+ "authors": _authors,
186
+ "year": _year,
187
+ "kind": _enum("paper", "book", "article", "web", "talk", "repo", "dataset"),
188
+ "level": _enum(*LEVELS),
189
+ "url": _url,
190
+ "topics": _topics,
191
+ "added": _date,
192
+ "superseded_by": _handle_value,
193
+ "distinct_from": _handle_list,
194
+ },
195
+ "knowledge": {
196
+ "claim": _string,
197
+ "topics": _topics,
198
+ "confidence": _enum("high", "medium", "low"),
199
+ "level": _enum(*LEVELS),
200
+ "origin": _enum("literature", "research", "experience"),
201
+ "updated": _date,
202
+ "part_of": _part_of,
203
+ "part_of_hash": _part_hash,
204
+ "superseded_by": _handle_value,
205
+ "distinct_from": _handle_list,
206
+ "disputed": _disputed,
207
+ },
208
+ "research": {
209
+ "title": _string,
210
+ "question": _string,
211
+ "status": _enum("idea", "active", "paused", "done", "abandoned"),
212
+ "started": _month,
213
+ "topics": _topics,
214
+ "superseded_by": _handle_value,
215
+ "distinct_from": _handle_list,
216
+ },
217
+ }