Design decisions (ADRs)¶
Every design decision in Noesis carries a recorded rationale — the house rule is "no rationale, no merge." Decisions live in the devlog's decisions table and in the decision log of architecture-docs/code-indexer-expanded-architecture.md (Appendix A), which holds the full chosen/reason/alternatives table. This page is the index; ADRs 1–18 belong to the approved baseline documents.
| # | Title | Decision (one line) |
|---|---|---|
| 19 | Reranker sequencing | Build after the M3 evaluation gate; default-on only on a measured NDCG@10 win |
| 20 | Reranker concurrency | Second dedicated single-thread worker, separate from the embedder's |
| 21 | Structural search substrate | Live filesystem via ast-grep-py; the index is bypassed entirely |
| 22 | ast-grep capability exposure | Search only — the rewrite capability is never exposed |
| 23 | Git integration | subprocess git CLI; candidates only shrink the hash set; hash remains truth |
| 24 | Embedder pluggability | Tiny async Protocol encapsulating dim/model_id/prefix; local implementations only |
| 25 | Hosted embedding: rejected | No remote embedding of any kind; no HTTP client in core/; CI-grep enforced |
| 26 | MCP v2 handling | Scheduled migration checkpoint; FastMCP drives the mcp version range until then |
| 27 | Lessons & memories storage | Hybrid: SQLite as system of record + committed rendered LESSONS.md; 15-lesson cap |
| 28 | .gitignore matching |
pathspec runtime dep — canonical gitwildmatch, not a hand-rolled matcher |
| 29 | M1 API surface | None — M1 is core-library only; HTTP lands with M2 |
| 30 | Grammar assets | Keep tree-sitter-language-pack 1.12.x + install-time prefetch of all grammars |
| 31 | Generated-lockfile skip-list | Discovery skips committed lockfiles (uv.lock alone was 53% of this repo's chunks) |
| 32 | BM25 TF encoding | qdrant-client[fastembed] client-side TF + server-side Modifier.IDF; RRF k is server-fixed |
| 33 | Reranker model-loading boundary | New core/reranker.py; sentence_transformers allowed in exactly two modules |
| 34 | Rerank request-flag default | rerank defaults to reranker.enabled; disabled reranker returns reranked:false, not an error |
| 35 | M4 gate: reranker default-off | Quality passed (+0.106 NDCG@10), latency failed (12.2 s p50 on T4) — ships opt-in |
| 36 | chunk_id in search hits |
Every hit exposes its deterministic point id so get_chunk is discoverable |
| 37 | Git fast-path specifics | Anchor validity = merge-base --is-ancestor; -z parsing; directory entries match as prefixes |
| 38 | Roadmap reorder | Dashboard + watcher promoted to M8; MCP v2 checkpoint renumbered to M9 |
| 39 | M8 runtime deps | jinja2 3.1.6 + watchdog 6.0.0, decision row recorded before install |
| 40 | M8 scope expansion | Per-project watch/auto-reindex (default off), persisted device setting, metadata-only query_log |
| 41 | Per-file error capture | Runs continue past per-file failures; run_file_errors + files_failed surface them |
| 42 | Dashboard registration | Register-only vs register+index split; per-project index config; browse/preview endpoints |
| 43 | Dashboard project deletion | Cancel run → unwatch → delete points by filter → SQLite child-first; source files untouched |
| 44 | Anchored db_path + config lookup | Default DB at $XDG_DATA_HOME/noesis/noesis.sqlite; no cwd-relative resolution |
| 45 | Watcher polling fallback | inotify-blind mounts (9p/cifs/nfs/…) get a polling observer, detected via /proc/mounts |
| 46 | Polling walk pruning | PollingObserverVFS prunes excluded dirs at the walk source (~350 s → ~0.6 s per interval) |
| 47 | Cancellation vs in-flight upsert | execute_run shields the in-flight upsert and awaits it on cancel — no orphaned points |
| 48 | Startup orphan-point sweep | Delete points of dead projects at startup; refused when the project table is empty |
| 49 | SQLite↔Qdrant drift self-heal | Count gate per run → per-file scroll → re-embed drifted files + prune orphans |
| 50 | Documentation stack | MkDocs Material on GitHub Pages via Actions: static mkdocstrings (griffe — no runtime deps at docs build), official Pages actions (no gh-pages branch), stdlib-urllib releases generator with a committed empty-state placeholder, dev-only docs dependency group |
| 51 | Discovery errors block deletion | A transient walk/stat failure is reported, never silently skipped; file-level errors carry the stored hash forward, a directory-level error suppresses deletion and orphan pruning and blocks the anchor. Extended: a missing root is not genuine absence, and an empty scan against non-empty state is refused outright. The two stated exceptions to "never silently skipped" — the follow_symlinks cycle-guard stat and an unreadable .gitignore — were removed by ADR-58; nothing in discovery is logged-but-unrecorded any more. This row also claimed a lost .gitignore risks under-ignoring but "cannot cause over-deletion"; that is retracted, see ADR-58 |
| 52 | Telemetry writer thread | record_query enqueues on a bounded queue and returns; one writer thread owns the connections and is closed at teardown — the usage page becomes eventually consistent. Ownership superseded by ADR-59: the writer is per-AppContext, not per process |
| 53 | Drift needs two agreeing reads | The expected total is read on both sides of the Qdrant count; drift is reported only when those readings agree with each other and disagree with the count |
| 54 | Suppression scoped to the unwalked subtree | A directory discovery error blocks deletion and orphan pruning only under its own prefix — project-wide only when no prefix describes what went unseen |
| 55 | Empty-scan escapes | Discovery reports what the walk enumerated before filtering, so a fully filtered tree converges; a genuinely empty root needs an explicit force, on REST only — never on the MCP tool an agent calls. The guard covers emptiness that raises nothing, so it defers to a directory error discovery already recorded |
| 56 | Unwalkable-directory ledger and quarantine | Directory-level discovery failures are tracked per project with a consecutive-failure count; after N runs a directory is quarantined and the paths it hides stop being re-queued, so the pending backlog drains. Quarantine bounds the RETRY only — ADR-51/54 keep sole ownership of deletion — and the run that finds the directory walkable again re-hashes its subtree |
| 57 | Automatic promotion to a full walk | A scoped run is promoted to a full one after N scoped runs, once the effective candidate set passes a fraction of the index, or when an unattributable discovery failure leaves the whole index unverified — restoring the drain that only a full run can perform. Amended in the PR #30 review: the working-tree-dirty set counts toward the fraction only while the last full walk was clean, since a run reporting any failure leaves that set pinned and promoting cannot shrink it |
| 58 | Screening faults are recorded, non-fatal, and block only what they put in doubt | Faults where the walk saw everything but a screening input failed get their own collector lists. unscreened (an unreadable or unstattable .gitignore) suppresses deletion and orphan pruning under that directory's prefix and blocks the anchor only when it actually held a deletion back; unidentified (symlink/cycle-guard stat) suppresses nothing, because it can only make the walk over-inclusive. Neither fails the run. Corrects ADR-51: a lost .gitignore can cause over-deletion — git is last-match-wins, so losing a deeper spec cancels its negation of a shallower exclusion and the file drops out of the walk entirely. Also stops the three calls from raising EACCES/ESTALE out of the whole run, which had been 500-ing structural search. The run's clean_run verdict is persisted on a new index_runs.clean column instead of being re-derived as files_failed == 0 — that derivation had already drifted once (ADR-57 round 2) and this adds a term it cannot see |
| 59 | Telemetry writer is per-AppContext |
The writer's state moves from module globals into a QueryTelemetry instance each context owns, which makes close() terminal and idempotent for free — a late record_query drops its row instead of resurrecting a worker whose DB handle nothing would reap. Deletes all three of the module's carve-outs: the one-live-context invariant, the non-terminal close(), and the per-generation queue |
| 60 | Anchor advances past a failure it can name | The git anchor no longer stops for any failure — it stops only for one whose paths cannot be enumerated (an unattributable discovery failure) or for a run that finished failed. Everything else the run could not verify — files that failed to index or to hash, paths under an unwalkable subtree, deletions a screening fault held back — is carried in the H1 dirty set, which the next run re-admits as candidates. The guarantee is unchanged (no file whose state is unknown is ever skipped); it is met by recording the doubt rather than by freezing the project, which one unreadable directory — or one unreadable file — used to do forever. Subsumes the old rule: on a clean run the carried set is empty and nothing changes. Deletion policy and the clean verdict are untouched, and ADR-57's fraction trigger deliberately keeps ignoring the dirty set on a faulted project, because the carried set is a floor promotion cannot get under |
| 61 | Committed lesson files are the durable record | render-lessons refuses (exit 1) when the committed files name a lesson the local DB has never seen — it rebuilds a tracked file from a gitignored one, so a stale DB makes it a delete rather than a refresh, and it has destroyed the lesson set once. lessons import preserves each lesson's id and reads both files, so the round trip is an identity rather than a renumbering that breaks the cross-references the bodies make to each other. Retired and promoted lessons render to dev/LESSONS-archive.md, committed for durability and injected by nothing, because LESSONS.md is injected verbatim and a retired lesson there would keep steering sessions. Amends ADR-27 |
| 62 | Qdrant client and server pins are one decision | The server moves to v1.18.3 and the client gains a <1.19 ceiling, so both land on 1.18 with zero skew. A default-suite test asserts that zero skew directly — same major and minor — rather than the client's own is_compatible, which tolerates one minor of drift and so would pass on the very state issue #37 grew out of; is_compatible is still checked, to catch a future client that tightens its rule. Every other copy of the version — the CI job's image tag, the install guide, the Colab guide's download URL — is pinned to the compose tag by the same test. A server-marked tier and a server-compat CI job re-check the pair against a live container, because every existing store test uses the embedded client and never performs the version handshake. Correctness only: the golden harness still measures on the embedded client, so this does not establish that retrieval ranking survived the jump (#38). Answered 2026-08-08 under [ADR-66]: it did not, measurably — dense Recall@10 is identical on both, but hybrid is 0.775 embedded versus 0.713 against a real v1.18.3 server, so the embedded harness over-reports hybrid by 0.062 |
| 63 | Qdrant's own telemetry is disabled in compose | The image ships telemetry_disabled: false and reports collection and configuration statistics to telemetry.qdrant.io on start. Binding the ports to 127.0.0.1 only governs inbound traffic, so ADR-25's "nothing leaves the machine" was true of our Python and not of the datastore we ship. QDRANT__TELEMETRY_DISABLED=true — in compose and on the CI service container, which runs the same image and would otherwise ship the same default — asserted by a test |
| 64 | Golden retrieval labels address content, not line numbers | A label is a path plus an anchor (a substring occurring exactly once in that file), optionally widened by an anchor_end; load_golden resolves them against the tree being measured and raises when one stops matching. Positional lines: ranges are rejected outright. They had rotted: 22 of 46 labels no longer overlapped their own content, and because a result must overlap the range to count, each rotted label silently forced its query to zero. Ranges were refreshed once, the day they were written, and never again across the month of drift that followed — nl-10 and symbol-12 do both score 0 under the pre-ADR-64 label set, but not because their ranges were ever past EOF: an earlier version of this row claimed exactly that and the PR #42 round-5 review measured it against the wrong commit's file content and retracted it. Width follows the question: a symbol query's label is its definition site, while nl/structural labels keep a span, because matching is a span-overlap test — a one-line label counts only when the chunk holding that exact line is retrieved, while a region-wide label counts whichever chunk of the region comes back. (At labeling time the sharper form of this was dedupe_by_path keeping only each file's best-ranked chunk; ADR-67 removed that, and the width rule survives on the narrower ground stated here.) tests/eval/test_golden_labels.py runs in the DEFAULT suite so rot fails on the commit that causes it, and additionally requires a symbol query's identifier to appear inside its own labeled span — the second route that found the rot, made permanent. Extended in the PR #42 round-2 review: the fresh-read check covers anchor_end as well as anchor (35 of 47 labels had their end unchecked, and the end is the half that drifts), and an anchor unique only by its indentation is now rejected — nl-09's " WHERE id = ?" matched one line while the bare fragment matched 13, so one more SQL statement at that indent would have failed collection. tests/eval/migrate_labels.py records the re-derivation of all 46 — 43 mechanically, 3 from explicit overrides (round 4 corrected this count in evaluation.md; this row and the architecture doc still said "mechanical re-derivation of all 46" until the PR #42 round-5 review, finding 15) |
| 65 | The golden run gates by assertion, in three layers, and never writes a baseline implicitly | Layer 1 asserts same-run relations — M3's exit criterion (hybrid beats dense on Recall@10, especially the symbol subset) and ADR-35's rerank NDCG win — which corpus growth cannot skew because every channel sees the same corpus. Layer 2 compares against one living baselines/reference.json and only when its provenance says it is comparable: same models, same store, same questions, corpus within a chunk-count band; otherwise the run fails, never skips, with the tables marked NOT A GATE and the exact re-baseline command. A drop must exceed both a relative band and one query's worth in absolute terms, because a relative band alone silently changes meaning with the score level. Layer 3 makes re-baselining explicit (NOESIS_EVAL_REBASELINE=1, refused on a dirty tree at two points — the corpus fixture before any indexing, and the test body, which catches a tree edited mid-run; measured 336.60s to refuse before, 25.79s after); the write-if-missing that made whichever run got there first the standard, and two unconditional writes that dirtied the tree every run, are both deleted. Provenance also carries duration (measure_s, the channel loop; total_s, from collection so it includes the corpus build and both model loads) — evidence only, ignored by the comparability check, because runtime claims about this tier were being quoted with no committed artifact behind them. Every run writes a rendered report_latest.md — verdicts first, and stamped when the run re-baselined — because the tables were printed and pytest captures stdout, so no invocation without -s ever showed them (-q is innocent: bare pytest hides them too) |
| 66 | The store an eval ran against is part of its provenance | NOESIS_EVAL_QDRANT_URL switches the golden corpus fixture from the embedded client to a real Qdrant server on a throwaway collection, and the store kind and server version are recorded in reference.json and treated as a hard comparability term, so an embedded-measured reference can never gate a server-measured run. Closes the quality half ADR-62 left open and assigned to #38: sparse IDF is computed server-side and RRF fusion uses a constant the server fixes, so ranking can move between the two implementations with every existing test staying green, because all of them use QdrantClient(":memory:") |
| 67 | Golden scoring groups a file's chunks instead of keeping only the best-ranked one | dedupe_by_path collapsed each file to its top-ranked chunk before matching, so a file that genuinely contained the answer scored 0 whenever any other chunk of it ranked higher. Measured on the 2026-08-08 run: the query chunk_point_id retrieved the chunk holding its definition at rank 2 and scored zero because a usage chunk ranked 1; three of forty queries were pinned at zero across all five channels by this alone, so they could never register a regression or an improvement. group_by_path keeps the property the collapse existed for — one file occupies one rank slot, so a single file's chunks cannot flood recall — while leaving every retrieved chunk of that file available for matching, and lets one file answer two distinct relevant items through different chunks (structural-03 labels two async methods in embedder.py, structural-08 two endpoints in routes.py; both reach 1.0 on at least one channel of the stored reference, which is only possible if each pair was credited through different chunks). The residual is stated rather than hidden: the cap is per chunk, so two same-file labels landing inside one chunk still credit only one and cap that query at 1/len(relevant). Lifting it would let a single wide chunk sweep every label in its file — the flooding the collapse existed to prevent — so it is the deliberate boundary, pinned by test_two_relevant_greedy_credit. Recall rises, and the metric now measures what the harness documents: whether the relevant code was retrieved, not whether it happened to be the file's top-ranked chunk |
| 68 | Chunk credit is assigned by maximum matching, not first fit | ADR-67 stopped the scorer discarding a matching chunk because a sibling outranked it; the assignment inside a file's group still did the same thing one level lower. Each chunk credits at most one label — the cap that stops a wide chunk sweeping its whole file — but first fit gave each chunk the first label it happened to overlap. Where chunk A overlaps labels L0 and L1 while chunk B overlaps only L0, first fit spent A on L0, left B with nothing to credit, and scored the query 0.5 with both labels sitting inside retrieved chunks; reproduced against the pre-fix scorer as assert 0.5 == 1.0. Assignment is now an incremental Kuhn's matching over chunks × labels, so the size after rank slot r is the maximum matching over slots 0..r — exactly what Recall@k needs, and monotone in k. Every prior property is preserved: chunk capacity 1, one rank slot per file, NDCG gain 1 per slot that grows the matching. The sets are ≤10 slots × ≤3 labels, so cost is irrelevant. Exposure is an upper bound of two — the golden queries with two labels in one file (structural-03, structural-08), the same two ADR-67 was written for — and at today's chunk boundaries the realised exposure is zero: chunking both labeled files and testing every chunk against both of its query's labels, no chunk overlaps more than one (5 chunks examined, max overlap 1), so first fit and maximum matching are provably identical on the whole set right now, which is why every Recall aggregate is bit-identical across the change. It is hardening, not an improvement. The defect is in the metric rather than in those labels, and a metric that under-reports whenever a wide chunk arrives first is not a standard other numbers can be judged against. Alternative rejected: leave first fit and document the bias, which is what ADR-67 declined to do about its own case |
| 69 | The reference stores per-query rows, not only aggregates | Lesson 19 was recorded in PR #42 after a five-row per-channel table for structural-08 went out reconstructed from memory with two rows wrong. The falsifying evidence existed only in tests/eval/report_latest.json, which is gitignored; the committed reference.json stored aggregates, so it could confirm every aggregate claim and refute no per-query one. The lesson's own remedy — "add the per-item view to what the run persists" — had not been applied, leaving the class open while the instance was closed. save_reference now writes each channel's per-query rows beside its aggregates, and test_reference_integrity.py re-derives every stored aggregate from those rows in the default suite, so the two halves of the artifact cannot drift and a hand-edited row fails a test rather than persuading a reader. Latency is deliberately excluded per query: it is device- and load-specific, so it would rewrite all 200 rows on every re-baseline even when quality is bit-identical and bury the rows that actually moved — the p50/p95 summary keeps the cost visible. The integrity test asserts internal consistency only, never that the ids match today's golden.yaml: the reference is a past measurement, reference_mismatches already refuses to gate across a golden_sha256 change, and coupling them would turn the default suite red on every label edit until someone spent ~15 GPU-minutes — a standing incentive not to fix labels, which is issue #38's own failure mode |
| 70 | The scorer is part of a reference's provenance | provenance.scoring.version records which scoring rules produced a stored number, and reference_mismatches refuses to gate across a change to it. Until this, the comparability check covered models, store, labels and corpus size but had no term for the scorer, so numbers produced under one set of scoring rules could be compared against numbers produced under another — and that is not hypothetical: ADR-67 and ADR-68 each changed what a retrieved chunk credits, and both times the only thing that forced a re-baseline was a human remembering to. A reference recorded before the field existed reads as None and refuses by absence rather than passing by it, in both directions. SCORER_VERSION is bumped by hand whenever a change to score_query, group_by_path or matches can move a stored number, which is a judgement the person making that change is best placed to make; a hash of the source would fire on a comment. Policy, decided in the PR #42 round-5 review (finding 7): the bump turns the default suite red until a ~15 GPU-minute re-baseline lands — the same standing incentive ADR-69 explicitly refused to build for labels. Kept anyway: a label edit is frequent and cheap and must not be discouraged, while a scorer change is rare and inherently invalidates the measurement, so the asymmetry is deliberate rather than an oversight. The rule: a scorer change and its re-baseline land in the same commit — finding 1 of that same review needed exactly this bump, and paid the cost immediately (SCORER_VERSION 3, ADR-72). The current reference is stamped 2 rather than re-measured, and the stamp is checkable rather than asserted: its corpus.commit is 30cd229, a descendant of 27572ce where ADR-68's scorer landed (git merge-base --is-ancestor confirms), so it was measured under scorer 2 and the field records a fact instead of creating one. No metric was touched. Alternatives rejected: infer the scorer from the presence of per-query rows (true for exactly this one transition, useless for the next); document the gap in ADR-65 and rely on the author to re-baseline (that is what already failed, twice) |
| 71 | Per-query rows are compared between runs, and reported rather than gated | harness.reference_query_deltas names every query whose recall@10 crossed zero against the reference, per channel, and the verdict block also names any change to the zero-recall set. ADR-69 committed the rows so a reader could check a per-query claim by hand, but nothing compared them, and the aggregates cannot: permuting hybrid rows among same-category queries leaves every stored aggregate bit-identical and both gate layers passing clean, so a channel can change which questions it answers while the gate sees a flat line (PR #42 review round 4; the mechanism reproduces against the live reference, but no committed artifact records the "12 of 40" count this row originally quoted — corrected, PR #42 review round 5, finding 19). Crossing zero is the signal worth naming — a query that went from answered to unanswered is either a retrieval regression or a rotted label, and both deserve a human look — while a query moving 1.0 to 0.5 is ordinary rank churn the aggregate already covers. Reported and never gated, the same standing as rerank_query_deltas: per-query retrieval is noisy, a false red costs a ~15-minute re-run, and layer 2 already fires on the aggregate. Alternatives rejected: gate on any lost query (reds a run whose overall quality is unchanged); leave the rows uncompared (the churn stays invisible, which is the finding) |
| 72 | NDCG's ideal counts unique files, not relevant items | ideal = min(len({item.path for item in relevant}), NDCG_K) in harness.score_query, replacing ideal = min(len(relevant), NDCG_K). DCG grants one gain slot per FILE (ADR-67/68's deliberate binary-per-file-slot design), but IDCG assumed one ideal slot per relevant ITEM, so a query with two labels in one file could never reach its own ideal even when answered perfectly at the best rank: it scored a flat 0.6131 (1/(1+1/log2(3))), identical to a half answer. Fixed to count unique files, the most rank slots DCG can ever fill (PR #42 review round 5, finding 1). SCORER_VERSION bumped 2 → 3 (ADR-70's policy: the bump and its re-baseline land in the same commit); reference.json re-recorded 2026-08-28 at commit 5ae17ea, 572 chunks. Measured effect: only structural and overall NDCG@10 moved (structural-03/structural-08 are the only same-file two-label queries in the golden set) — zero Recall figures changed on any channel or category. Per-channel structural NDCG@10 deltas: dense +0.0246, dense(python-only) +0.0286, sparse +0.0222, hybrid +0.0209, hybrid+rerank +0.0322. Pinned by the corrected assertion in test_credit_is_assigned_optimally_not_first_fit (now 1.0, was the buggy 0.6131) and a new test_ndcg_ideal_counts_unique_files_not_relevant_items, which also verifies and documents that a same-file half-answer and full-answer score identically under this fix — NDCG saturates at the file-slot level by the existing binary-gain design, and Recall is what discriminates them — while a cross-file half-vs-full answer does differ, and already did before this fix. Alternatives rejected: leaving IDCG counting items (that is the defect); capping DCG's gain per file at the number of items it answers instead of binary (contradicts ADR-67/68's deliberate one-slot-per-file design, which exists specifically to stop one wide chunk sweeping every label in its file from being over-rewarded) |
| 73 | Screening-fault path redaction is one shared helper across all four discovery channels | Issue #32: the PR #31 round-2 review fixed the absolute-path leak (OSError.__str__ interpolates filename, the normal shape here) only in _record_degraded's unscreened/unidentified lists, because errors.dirs/errors.files were out of scope for that PR — those two kept building their pair with bare str(exc), live on main independent of that branch. _error_detail(exc) is now extracted out of _record_degraded and reused at _walk_error's errors.dirs.append and the file-screening loop's errors.files.append, so all four channels rebuild the message from errno/strerror instead. _walk_error's unattributable branch keeps storing an absolute path as the dirs key when relative_to fails — that's load-bearing for indexer.is_attributable_prefix — only the message narrows. Two new tests pin the invariant for the two newly-covered channels, run against the pre-fix code first and observed to fail on the absolute tmp path being present in the message (rule 9); full suite (696 tests) green after the fix, no other behavior changed since every suppression/quarantine decision reads the key, never the message. Alternatives rejected: duplicate the rebuild logic inline at the two new sites (the copy-paste risk that caused the gap in the first place); route dirs/files through _record_degraded itself (wrong shape — it also DEBUG-logs and dedupes per directory key, neither of which applies to a dir-scan or per-file screening fault) |
| 74 | Screening-fault dedupe uses a companion set, not a bucket rescan | Issue #33 (filed from the PR #31 round-2 review): _record_degraded's per-directory dedupe rescanned the whole bucket list on every call (any(existing == key for existing, _ in bucket)), so recording N distinct degraded directories in one walk cost O(N²) — measured in the review at 0.02s/1000 dirs, 0.30s/5000, 1.31s/10000, independently reproduced here at 0.0139s/1000, 0.33s/5000, 1.33s/10000 before the fix. _record_degraded now takes a required keyword-only seen: set[str], checked and inserted into instead of the rescan; discover_files builds one unscreened_seen and one unidentified_seen set per walk and threads them through every call site sharing those buckets (the two .gitignore fault sites, the per-child is_symlink fault, and both _cycle_guard_identity call sites, which forward their own seen into _record_degraded). The dedupe contract itself — one row per directory key, first fault wins — is unchanged. New test test_record_degraded_dedupe_is_not_quadratic was run against a deliberately reintroduced linear-scan branch first and observed to fail for the stated reason (70.6x time for 8x the keys, matching the ~64x a quadratic scan predicts), then passed once the real fix was restored (18,200 keys in 0.09s, rule 9). Full suite 699 passed, 0 failures. Alternatives rejected: a private field(default_factory=set) on the public DiscoveryErrors dataclass (it is public API tests construct directly, and _record_degraded takes the bucket list rather than the parent dataclass, so wiring the set through needed a larger, less local change); a recorder object wrapping list+set in place of the public fields (existing tests do errors.unscreened == []/index/iterate it — a wrapper would need to reimplement list semantics); an optional seen falling back to the O(N) scan (a needless second code path — the one direct test call was updated to pass seen=set() instead) |
| 75 | The structural-search scan deadline starts after discovery, not before | Issue #43 (filed from the PR #42 round-4 review): _scan_sync set deadline = time.monotonic() + timeout_s before calling discover_files, so discovery time was charged against the scan's own budget. On a slow filesystem or a large tree (the review's own reproduction: three agent worktrees under .claude/worktrees/ took discover_files from 6.63s to 14.36s, past the 10s default timeout_s), the very first budget check inside the scan loop had already tripped, and the scan returned scanned_files: 0, timed_out: True, matches: [] having read nothing — indistinguishable from "this pattern does not occur" to a caller reading only matches. The deadline now starts after discover_files returns; discovery is bounded separately by its own filters (.gitignore, secret skip-list, size caps) and was never the runaway case timeout_s exists to guard against. Discovery's own wall time is now logged (logger.info("structural scan: discovery took=%.3fs candidates=%d", ...), mirroring indexer.py's existing "discovery took=%.1fs discovered=%d" line) rather than added to StructuralResult: no other core surface returns wall-clock timing in its response body — search latency is telemetry-only — and a timing field would make the REST/MCP response for the same query stop being byte-identical across two separate live calls, which is the M6 milestone's own design invariant (test_mcp.py::test_structural_search_identical_to_rest). The residual pathological case (timed_out and scanned_files == 0 after the fix — e.g. timeout_s set at or below zero, or the very first candidate file's own parse+match time exceeding the whole budget) now logs a WARNING naming candidate count, discovery time and the configured budget, so it is loud rather than silently indistinguishable from a normal empty result. Regression test test_discovery_time_is_not_charged_to_scan_budget monkeypatches discover_files to sleep past a timeout_s shorter than the sleep, reproduced red against the pre-fix code (rule 9) before the fix made it green; test_timeout_returns_partial_with_flag was changed from timeout_s=0.0 to timeout_s=-1.0 since a bare 0.0 deadline is deterministically in the past only because of the bug this PR fixes — after the fix it depends on float slack between two adjacent time.monotonic() calls, which hard rule 9 already prohibits relying on. tests/eval/golden.yaml's sp-07 pattern (time.monotonic() occurrence count in structural.py) updated 2 → 4 for the two new calls; this does not affect golden-set comparability since golden_digest hashes only the queries section, never structural_patterns. Alternatives rejected: budgeting discovery separately with its own sub-timeout (adds a second knob to [structural] for a phase already bounded by discovery's own filters, and the issue's own text agrees discovery "is not the thing the budget was written to protect against"); putting discovery_s in the response body anyway and relaxing the MCP/REST identity test to ignore volatile fields (weakens a milestone invariant to accommodate one field, and diverges from the codebase's existing convention of keeping timing in logs/telemetry — recorded as its own lesson, #22, after being caught by the full-suite run) |
| 76 | ~~Dedicated index_client for the write path~~ |
Superseded by 83. Closed the write half of issue #48 only; its reader-only measurement does not reproduce |
| 77 | Background model warm-up after startup | A fire-and-forget task forces the model load at process start instead of on the first search |
| 78 | huggingface_hub as a direct dependency |
Fail-loud asset detection needs a no-network cache check; already transitive, so no new supply-chain surface |
| 79 | PR #50 round-1 fixes | Readiness reported only after the model actually loads; weights checked, not just config.json; close() cannot leak the second client |
| 80 | PR #50 round-3 fixes | Per-resource isolation in teardown; the health check's filesystem stats moved off the event loop |
| 81 | Warm-up state on the MCP surface too | embedder_assets/embedder_ready on get_index_status, since /healthz is unreachable over stdio |
| 82 | One shared readiness implementation | prefetch.embedder_readiness replaces the same logic pasted into two call sites (renamed model_readiness by ADR-87, once the reranker became its second caller) |
| 83 | Bounded query-connection pool + object-keyed locks | Closes the reader-vs-reader half of issue #48: a connection per in-flight query, and one lock per client object rather than per role |
| 84 | Bounded search executor with fail-fast admission | Search leaves the process-wide default thread pool for its own executor, sized 1:1 with connections; overload answers 429 / ToolError instead of stalling |
| 85 | Index-run cap enforced in SQLite | A machine-wide limit on concurrent runs, inside the existing BEGIN IMMEDIATE — an in-process semaphore cannot bound the HTTP + stdio deployment |
| 86 | Shared server + thin stdio shims | --shared proxies to one server instead of loading the model per agent; singleton election via an OS-released advisory lock |
| 87 | Reranker cold-start visibility + warm-up | reranker_assets/reranker_ready on /healthz and get_index_status, "disabled" when reranking is off; a background warm-up chained behind the embedder's; resolved_device set only after the model actually loads |
| 88 | Issue #52 round-1 fixes | A device switch during a model load can no longer be overwritten by the superseded load; prefetch fetches the models the config actually names, so the health check's "run prefetch" remedy works |
| 89 | Issue #52 round-2 fixes | "unknown" (not "disabled") for a context that never mentions a reranker; the load-completion log names the device it actually used; the two /healthz probes run together (a structural tidy, not a speedup — see ADR-90, which retracts the ~9ms figure this row first quoted) |
| 90 | Issue #52 round-3 fixes | Cached weights without a tokenizer no longer count as "ready" (measured: it loads and silently ranks <unk>); an unreadable config skips the model downloads instead of guessing; the loader uses the worker's generation snapshot; three claims in rows 87-89 corrected in place |
| 91 | Issue #52 round-4/5/6 fixes | The tokenizer check follows each tokenizer class's own vocab_files_names — metadata does not count, byte-level BPE counts only as a vocab.json + merges.txt pair, and tokenizer.model (Llama) is no longer a permanent false "missing"; ADR-90's retraction applied to the copies it missed; prefetch's ~2.3 GB download for a disabled reranker deferred to #58 |
| 92 | Issue #52 round-9/12 fixes | A malformed model pin (~nosuchuser/..., an over-long path, a blank string) answers "missing" instead of 500-ing every health and status surface or giving a false "ready" for an empty pin that happens to match the cwd |
| 93 | Issue #59: deterministic dedupe-complexity guard | test_record_degraded_dedupe_is_not_quadratic counts real __eq__ comparisons instead of a wall-clock ratio; a companion test proves the counter would have caught the pre-fix O(N^2) scan |
| 94 | Issue #61: shared embedder/reranker race-fix mixin | core/model_worker._DeviceGenerationTracker replaces the pasted _generation/_load_target/set_device copies in embedder.py and reranker.py; self._lock stays subclass-owned so tests that swap it keep working |
| 95 | Issue #51: dashboard model-prefetch progress — polling, not SSE | Reuses ctx.progress/app.js poll()'s existing index-run-progress mechanism instead of adding SSE; GET/POST /api/prefetch sequence the same four prefetch.py functions the CLI already calls, at the same 4-step granularity SSE could not have improved on. Comparison + diagrams: architecture-docs/dashboard-prefetch-polling-vs-sse.html |
See also the risk register and milestones.