Repository navigation
Description
Problem
I'm trying by this way to clean the code and avoid massive grep in files to search for decision made regarding a change in code. Having the decision logged as markdown with the index it refers to, the decision made can be easily accessed. That's more or less what obsidian is doing, except the way it stores is not selective.
Proposed solution
Moving decision made to markdown file, with an index instead left in codebase. Then the rag is searching for indexes instead of having sementic search. Making it both faster and more accurate.
Alternatives considered
Considering a tree graph with decision and list of file instead of indexes, but it's slower to search in.
Scope assessment
Medium
Contribution
- I'd like to implement this myself.
- I can review a PR for this.
- I'm requesting that someone else implement it.
Decision (2026-09-08)
Option B is retained: the wiki page id is the single identifier space and the interface for every decision and every piece of established project documentation. Decision prose lives in the wiki; a source file keeps at most an index (# source: <wiki id>) pointing at the page. Retrieval resolves the index exactly, not semantically. In-file decision prose is refused from now on: it bloats the codebase and pushes files over the 300-line cap. A read-only mirror in docs/adr/ (option C) is not part of the scope; it is reconsidered only if reviewers need decision text in PR diffs.
Evidence and measurements: see the inspection comment below (HEAD ca32ba5). Key facts: 50,158 comment/docstring lines out of 148,652 (34 %), 1,433 comment blocks of 10+ lines, 131 files over the cap; three rival id spaces today; next_adr_number allocates 4253702 because two adr/ pages are named after memory ids; a hyphenated id such as D-0042 misses both exact recall lanes (FTS strips the hyphen, trigram scores 0.039 under the 0.1 gate) while a hyphen-free id is exactly retrievable today and phraseto_tsquery already matches hyphenated ids elsewhere in the schema.
Prerequisites, in order
- Repair the id authority:
next_adr_number(mcp_server/infrastructure/wiki_pages_listing.py:86-100) parses a fixed-width numeric head only; quarantineadr/4253701-…andadr/305772-…out ofadr/. - Reserve ids 0001–0055 so the 25
docs/adr/files and the 172 in-codeADR-references keep their numbers; document 014–043 as reserved (cause of the gap unknown). - Id-to-path resolution:
adr/is per-domain and numbered globally, so an id is a glob, not a path. Flattenadr/, or maintain an id→path map in the wiki index. Decide before implementing exact lookup. - The id appears in the pointer memory's
content(todaywiki_adrputs it only insource=wiki://…, which is not indexed), andrecall_memoriesstops stripping hyphens (or the id grammar is hyphen-free). - The craftsmanship gate resolves
# source: <wiki id>to an existing page (scripts/check_craftsmanship.py; the constants module stays I/O-free).
Increments (one PR each, CI is the authority)
- Id authority repair + quarantine + reservation.
- Exact-id recall lane + id in pointer content, delivered with the known-item benchmark.
# source:gate resolves wiki ids.- Migration tooling: extract decision blocks (start with the 379 blocks of 25+ lines) into wiki pages, leave the id in place, measure the line-count drop against the 131 files over the cap.
docs/adr/migrates into the wiki;unified_searchgains a wiki lane and an exact-id mode.
Acceptance signal
Known-item retrieval under benchmarks/reproduce.sh (isolated container; template benchmarks/gate_precision/run_benchmark.py): seed N decision pages, query each id bare, recall@1 = 1.0 and MRR@10 reported before/after. Regression guard: reproduce.sh --no-regression against origin/main.
Also found, to fix alongside
docs/mcp-tools.md claims wiki_reindex writes memory pointers; mcp_server/handlers/wiki_reindex.py:130-160 only rebuilds INDEX.md.
Activity
cdeust commentedon Sep 8, 2026
Code inspection and grounding (2026-09-08, HEAD ca32ba5)
Read-only inspection of the tree plus live PostgreSQL measurements. Nothing implemented yet; this is the evidence to decide on.
Owner ruling recorded
The wiki page id is the single identifier space and the interface for every decision and every piece of established documentation. Source files keep at most an index pointing at the wiki page. In-file decision prose is refused: it bloats the codebase and pushes files over the 300-line cap.
What in-file decisions cost today (
mcp_server/,scripts/,benchmarks/lib/,hooks/)pg_schema.py# source:lines (required by the craftsmanship gate on every constant)Three rival id spaces already exist
docs/adr/: 25 files, two schemes (001-…013-, thenADR-0044…ADR-0055; 014–043 absent, cause unknown).ADR-hits inmcp_server/+scripts/(some to wiki-style ids such asADR-2244), plus 25 baredecision <memory-id>references.adrkind: pages named<n>-<slug>.mdunder per-domain subdirectories;next_adr_number(infrastructure/wiki_pages_listing.py:86-100) parses the first numeric segment of every page underadr/**, so two pages named after memory ids (adr/4253701-…,adr/305772-…) make the next allocated id 4253702. The id authority is broken today.So the "index token in code" half of #514 already exists, in two grammars, and nothing resolves either.
Retrieval today, measured
recall_memories(infrastructure/pg_schema.py:1290-1300) builds its tsquery by replacing every non-alphanumeric character with a space, dropping one-character words and OR-joining the rest. PostgreSQL's parser keeps-0042as a signed-number token in the vector:A hyphenated id misses both exact lanes (FTS and trigram) and reaches recall by embedding similarity alone: that is exactly the complaint in this issue, now measured. A hyphen-free id is exactly retrievable today, and the schema already has an exact lane (
phraseto_tsquery, used by spreading activation atpg_schema.py:1682). This is a query-construction change on the recall path, not new machinery.Other findings on the retrieval side:
wiki_adrstores its pointer memory with the id only insource=wiki://…, which is not indexed; onlycontentfeedscontent_tsv. The id must appear in the memory body.unified_searchfuses memories + code symbols only: no wiki lane, no exact-id mode.recall(memory_id=N)andwiki_read(path=…).core/provenance.py:26-27) already treats a markdown path as a checkable reference (VERIFIED when it exists).# source:rule is a substring test (scripts/craftsmanship_constants.py:43,74-86):# source: <wiki id>passes today with no existence check. Verifying the page exists belongs incheck_craftsmanship.py(the constants module is declared I/O-free).docs/mcp-tools.mdsayswiki_reindexwrites memory pointers;handlers/wiki_reindex.py:130-160only rebuildsINDEX.md, zeroremembercalls.Prerequisites, in order
next_adr_number: parse a fixed-width numeric head only; quarantine the two memory-id-named pages out ofadr/.docs/adr/files and the 172 in-code references keep their numbers; document the 014–043 gap as reserved.adr/is per-domain and numbered globally, so an id is a glob (adr/**/0046-*.md), not a path. Either flattenadr/or keep an id→path map in the wiki index. This is the load-bearing decision for "look up the index exactly".content, and stop stripping hyphens inrecall_memories(or standardise on a hyphen-free id, which already works).# source: <wiki id>to an existing page.Options under the ruling
docs/: two substrates to keep in sync; contradicts "the wiki is the interface". Not recommended.docs/adr/migrates in;unified_searchgains a wiki lane and an exact-id mode. Trade-off: decision prose leaves PR diffs.docs/adr/produced bywiki_reindex: prose stays reviewable in PRs at the cost of one more module.Recommendation: B, with C's mirror only if reviewers need decision text in diffs.
Acceptance signal
Known-item retrieval, not semantic relevance (LongMemEval/LoCoMo are the wrong instruments): seed N decision pages, query each id bare, measure recall@1 and MRR@10 under
benchmarks/reproduce.sh(isolated container), templatebenchmarks/gate_precision/run_benchmark.py. Before: hyphenated ids hit neither exact lane (measured above). Target: recall@1 = 1.0. Guard the rest withreproduce.sh --no-regressionagainstorigin/main.Suggested increments
# source:gate resolves wiki ids.docs/adr/migration into the wiki,unified_searchwiki lane.cdeust commentedon Sep 8, 2026
Decision 2026-09-08: option B retained (wiki id and prose both in the wiki, index in code, exact-id retrieval). The issue body now carries the decision, the five prerequisites, the five increments and the acceptance signal; the inspection comment above is the evidence.