Repository navigation
Description
Purpose
This issue captures cross-cutting analysis results that inform multiple other issues but don't belong to any single one. It serves as a reference for implementation sequencing, risk assessment, and architectural decisions.
Dependency graph and critical path (2026-05-03)
PR Set 1 (FOUNDATION — parallel):
#618 storage correctness
#620 acquisition/live cursors
#622 browser capture hardening
#623 semantic drift preservation
#599 artifact split (can land any time)
PR Set 2 (STRUCTURAL — parallel):
#614 runtime compaction
#625 devtools consolidation
#635 vocabulary rename
#716 execution history
#719 ingest investigation
PR Set 3 (MIDDLE LAYER — #629 first):
#629 typed manifests (Pydantic for all YAML)
#621 query contract
#590 coverage contracts (blocks on #629)
#601 schema roundtrip (blocks on #629)
#624 insight registry
PR Set 4 (THE BIG ONE):
#717 daemon + UX (polylogued + local reader + CLI native UX)
PR Set 5 (POST-DAEMON — any order):
#721 reset redesign
#722 blob store GC
#723 API formalization
#713 performance diagnostics
#670 visual evidence
#649 MV3 harness
#594 proof enforcement
Critical path to v1.0: #618 → #621 → #629 → #717 → #723 (6 stages). #717 is by far the largest single item.
Independent clusters: Sets 1 and 2 have zero cross-dependencies. Within each set, all issues touch disjoint code areas. Maximum parallelism: 5 developers could work on Set 1 simultaneously with no merge conflicts.
Fragile areas (from git history analysis)
| Area | Fix count (Apr-May) | Risk |
|---|---|---|
ingest_batch.py |
12 fixes | Most-fixed production file. FTS trigger lifecycle, transaction boundaries, SQL correctness |
| Verification coverage | 5 sequential fixes (#701-#706) | Systematic hardening, not whack-a-mole |
| Query descriptor system | 7 fixes (#692-#698, #710) | Built incrementally; end-to-end parity incomplete (#621) |
| Proof Pack | 2 fixes (#689-#690) | Noise reduction then policy enforcement |
Cross-agent worktree conflicts: 3 fixes explicitly cleaned up after "other-agent workstreams" left partial changes. One caused a real SQL bug (#714). Process observation: uncommitted hunks in worktrees are a recurring footgun.
Test coverage gaps (2026-05-03)
68 of 614 production modules (11.1%) have zero test coverage:
| Area | Untested % | Largest gaps |
|---|---|---|
| MCP | 58.3% | server_tools.py (359 lines), payloads.py (407 lines), server_prompts.py (261 lines) |
| Storage | 32.4% | async_sqlite.py (567 lines), run_state.py (480 lines), mappers_insight_legacy.py (405 lines) |
| Rendering | 28.6% | core_messages.py (220 lines) |
| Pipeline | 22.0% | parsing_workflow.py (388 lines), planning_runtime.py (385 lines) |
The test-ownership manifest (docs/plans/test-ownership.yaml) claims untested: [] (empty) — this is incorrect and should be updated.
Performance findings (2026-05-03)
- Sync bridge thread-per-call:
run_coroutine_sync()spawns a new OS thread per call. 18+ call sites inapi/sync/. Millisecond overhead per call. Filed as perf(api): sync bridge spawns thread per call on hot paths #726. - Missing
acquired_atindex:raw_conversationshas no index onacquired_at— full sort scan on every query. Filed as perf(storage): add index on raw_conversations.acquired_at #727. - N+1 raw state updates:
_persist_batch_raw_state_updatesdoes individual UPDATE per raw ID (1000 round-trips for 1000 records). - Unbounded queries:
list_conversationsand insight list methods have no LIMIT whenlimit is None. - O(n^2) topological sort: Ingest hot path uses nested loop for parent-child ordering.
- Full-table scans in stats:
aggregate_message_statsdoes 4 full scans for one stats call. - Non-sargable COALESCE:
EFFECTIVE_RAW_PROVIDER_SQLcan't use provider indexes.
Error handling findings (2026-05-03)
3 real bugs found:
- Hash inconsistency when JSONL sample probe fails (fix(ingest): hash inconsistency when JSONL sample probe fails #724)
- Missing
exc_info=Trueon 5 critical error log sites (fix(logging): add exc_info=True to critical error log sites #725) - Debug-only logging for operational failure in
operations/archive.py:518
Dead code (2026-05-03)
showcase/context.py— 114 lines, 0 references. Delete.- 4 test-only modules that appear to be legacy/never-wired (chore: delete dead code identified by static analysis #729)
Schema evolution (2026-05-03)
Additive changes (new columns, indexes, tables) are safe within same SCHEMA_VERSION via the extension descriptor system. Breaking changes require full re-ingest — there is no migration chain. The daemon-owns-all-writes architecture makes a migration chain feasible (no concurrent writers), but it hasn't been built.
Related
Ref #578 (declaration-to-consumer drift tracker)
Activity
Sinity commentedon May 3, 2026
Red team findings — 2026-05-03 dialectical review
Daemon architecture over-engineering
The described daemon architecture introduces complexity that doesn't exist in the current code. The actual
daemon/cli.pyis 184 lines withasyncio.gather()and a try/finally block. Key simplifications to consider:asyncio.gather()already surfaces exceptions. The "supervisor" is a try/finally block.asyncio.to_thread()works fine. SQLite in WAL mode handles concurrent readers.unknown,ingested,errorcovers every real case. Content-hash dedup handles idempotency.rglob+awatchis sufficient. Content-hash dedup makes double-processing a no-op.Restart=on-failurehandles crashes.State machine edge cases (real bugs found)
Blob store and GC (design flaws)
verify()method exists but is never called. Corrupted blobs silently produce wrong parse results.Web UI architecture debate
Strong case made for Preact + HTM (4 KB total, no build step, component model) over htmx + server-side rendering. Key arguments:
Performance assumptions challenged
Sinity commentedon May 3, 2026
Architectural synthesis — 2026-05-03
This is the resolution of the dialectical tension between the design wave (full-featured daemon), the red team (minimal, use-what-exists), and the novel analyses (pre-mortem, v2.0 backward-pass, archive mining, subtraction).
Core decision: library-first, daemon as optional wrapper
The v2.0 analysis and the daemon-only-writes red team converge on the same answer: the
Polylogueclass is the canonical library surface. The daemon is an optional wrapper for long-running needs (live watching, browser capture). When the daemon is running, writes route through it. When it's not, the library writes directly with advisory locking. This gives:What the first daemon slice MUST include (from pre-mortem)
The pre-mortem proved these are not optional — they become catastrophic on service timescales:
_pendingdict eviction — pop entries after debounce completes. 78,000 entries, 300MB RAM leak after 6 months.What the first daemon slice can DEFER (from subtraction analysis)
The subtraction agent showed all 5 goals from #717 can be achieved in 75-125 lines by reusing existing infrastructure:
Web UI: static HTML for first slice, Preact+HTM for interactivity later
The debate between htmx (design wave), Preact+HTM (red team), and static HTML (subtraction) resolves to:
State machine: implicit, not explicit
The 8-state design and the 3-state counter-proposal both miss the point. The current implicit model (cursor row + fingerprint comparison) already works. The append/rewrite distinction is computed at comparison time, not stored. Keep the implicit model but make the comparison logic explicit and testable.
v2.0 irreversible decisions to make NOW
The v2.0 backward-pass identified these as the hardest things to change later:
conversations.metadataare the single most expensive migration. Addconversation_tagstable now, dual-write, drop JSON column later.insights.dbseparate fromarchive.db. Enables clean rebuilds without blocking queries.Sinity commentedon May 3, 2026
Blitz Plan — 2026-05-03 convergence
Current state: 28 open issues (down from 45)
16 issues closed:
AC audit refinements (from agent analysis)
cwd_prefixpath-component bounded matching is DONE.raw_records→raw_artifactspartial (MCP surface done, storage layer not).since_sessionneeds behavioral decision.notebook_pathis DONE. Narrowed to drift-fact collection + attachment ordering + dotted basename + ChatGPT unification.showcase/context.pydeletion.Phase 0: Mechanical cleanup (3 issues, ~2 hours, single PR)
Issues: #729 (dead code: delete 1 file), #599 (artifact split: 30 min), #614 (already done, closed)
Verification (run once after all three):
ruff check polylogue/ devtools/ tests/ pytest tests/unit/core/test_artifact_graph.py tests/unit/core/test_artifact_specs.py -x -q python -c "from polylogue.artifacts import ArtifactLayer, ArtifactNode, ArtifactPath, build_runtime_artifact_nodes, build_runtime_artifact_paths"Phase 1: Storage correctness (#618, ~2-3 days)
Remaining items (after AC audit): FTS SQL single-source, legacy session-product payload removal, write-path unification.
Test set:
Phase 2: Watcher + cursor (#620, ~2-3 days)
Items: incremental tail parsing, mtime fast-path (#736), pending dict eviction (#739), cursor table pruning (#740), file exclusion/backoff (#733).
Test set:
Phase 3: Query + parser (single PR, ~3-5 days, disjoint files)
Issues: #621 (remaining: raw_records→raw_artifacts storage rename, since_session decision, descriptor parity) + #623 (remaining: drift-fact collection, attachment ordering, dotted basename, ChatGPT unification)
Test set:
Phase 4: Browser capture + insights (single PR, ~3-4 days, disjoint files)
Issues: #622 (remaining: error sanitization, private permissions, origin trust, auto-capture gate, role inference) + #624 (readiness specs for 3 insights, MCP tool signatures, registry→consumer parity)
Test set:
Phase 5: The daemon (#717, ~4-6 days, the largest item)
First vertical slice: typed surface contracts, DaemonStatus rewrite, daemon/app.py with 7 GET endpoints, daemon/serve.py single entrypoint, vendored web reader (Preact+HTM), wire
polylogue opento daemon.Also absorbed: #737 (observability gaps), #741 (concurrent writer coordination).
Test set:
Phase 6: Post-daemon (3 PRs, can parallelize, ~5-8 days)
Issues: #721 (reset redesign: semantic scopes, sentinel-file notification, convergence), #722 (blob GC: algorithm, daemon scheduling), #723 (Python API: Phases 1-2 delegation + rich query)
Test sets (per-issue):
Phase 7: Verification + proof (2 PRs, ~4-6 days)
Issues: #590 (remaining 5 items) + #594 (remaining 6 items)
Test set:
Phase 8: Structural cleanup (2-3 PRs batching, ~4-6 days)
Issues: #625 (devtools), #629 (typed manifests), #634 (package tree), #635 (naming)
Naming (#635) touches 110+ test files — do LAST in this phase. Run full suite after.
Phase 9: Polish (7 issues, independent, ~6-10 days)
Issues: #670 (visual verification), #649 (MV3 harness), #601 (schema roundtrip), #719 (slow ingest), #716 (xtask history), #713 (perf diagnostics), #720 (Sinnix boundary)
Can be done in any order. All independent features.
Critical path
Phases 3, 4, 7, 8, 9 can parallelize around the critical path.
Tactical efficiency rules
devtools verifyonly before pushing the PR.ruff checkpasses and imports work, the tests pass.Sinity commentedon May 3, 2026
Wave 8 findings — 2026-05-03
Archive mining (live 68GB DB)
Temporal patterns (validates two-phase daemon design):
Resolved architectural decisions (#717 unblocking)
Polylogueis canonical, daemon is optional wrapper. CLI writes directly. No RPC layer..servicefile — no sd_notify, no watchdog. 10 lines.daemon_eventsSQLite table later.Resolved query decisions (#621 unblocking)
since_sessionunknown ID: warn + return empty (not error, not broaden)raw_records→raw_artifacts: rename public API surface only; storage internals via refactor(naming): normalize archive, proof, and surface vocabulary #635 if at allcwd_prefix: add parity test and close AC (both paths already correct)--format jsonrestriction: keep format diversity; ensure json always availableResolved boundary decisions (#720 unblocking)
Exact diffs (ready to apply)
polylogue/showcase/context.py(0 references)artifacts/__init__.pyinto descriptors.py + catalog.pySinity commentedon May 3, 2026
DuckDB analysis (2026-05-03)
DuckDB evaluated as SQLite alternative. Verdict: interesting but wrong fit. Polylogue is fundamentally OLTP + FTS5:
Migration cost: 6-10 weeks. Better path: DuckDB as optional read replica for analytics, SQLite stays primary. Pre-materialize more aggregates as lower-effort win.
Sinity commentedon May 3, 2026
Rust daemon analysis (2026-05-03)
Feasible. 3-5 weeks. SQLite WAL boundary is clean.
The daemon is 1,842 lines of Python. Rewriting in Rust:
Verdict: Optimization, not correctness fix. Do only if performance/memory becomes bottleneck.
The current architecture works. The rewrite would be 3-5 weeks for cleaner code and lower memory, but would not fix any correctness bugs or unlock new features. If done, model after sinex-ingestd: thin main.rs, service from config, tokio + shutdown signals.
systemd timers analysis (2026-05-03)
Feasible. More Unix-philosophical than a daemon.
Most daemon jobs are naturally timer-driven:
polylogue run indexpolylogue run sitePathModifiedpath units or periodic timerWhat's lost
polylogued status(systemd reports service state, not filesystem health)Key insight
The browser capture receiver is the ONLY component that genuinely needs a persistent server. Everything else is naturally a oneshot. The daemon is a Swiss Army knife that multiplexes unrelated concerns into one process.
Sinity commentedon May 3, 2026
Convergence framing + critical-path correction
Reading the open-issue graph end-to-end, the work clusters into one product-shaping problem expressed through many local symptoms: descriptors, manifests, APIs, commands, daemon status, storage write effects, and proof subjects have been declared faster than they have been made executable, consumer-backed contracts. Reframing as one archive kernel + one convergence engine (
polylogued) + thin surfaces + one evidence plane makes dependencies obvious.Critical path correction
Current:
#618 → #621 → #629 → #717 → #723.Proposed:
#618 + #620 + #622 → #621 → #723-lite → #717 → #721/#722 → #723-full.Rationale: #717's local API and web reader will otherwise have to invent read/query/status behavior before the canonical
PolylogueAPI exists. #723's own audit confirms many CLI verbs build query specs independently and all MCP tools bypass thePolylogueAPI. Without API-lite first, #717 reproduces the same surface drift the API formalization is meant to fix.ArchiveWriteGateway as the reconciling contract
"Daemon owns all writes" and "library-first, daemon optional" are both stated as architecture goals. They can only both be true behind an explicit
ArchiveWriteGateway:PRAGMA data_versionor an operation log before continuing its own work.This gateway should be the architectural boundary for #618, #717, #721, #722, and #723 — not a policy comment. The closed assurance work already identified concurrent daemon/CLI writes as a silent-divergence class.
Operational note on AC audits
Several issues now carry "AC narrowed by audit" comments not yet backed by code/test assertions (e.g., #736 assumes cursor metadata supports the mtime fast path; the implementation still does whole-file fingerprinting). Every AC refinement that claims existing support should cite a grep/test/code anchor before it is used to narrow scope. Otherwise "done in prose, not in code" keeps recurring.
Sinity commentedon May 3, 2026
Deep audit findings (2026-05-03) — cross-reference
~65 subagents across 3 phases confirmed most of the analysis here and found additional concrete issues. Key additions to the tracking:
Confirmed findings already in this issue
showcase/context.py— confirmed. Additionally foundwrite_gateway.pydead (never instantiated),blob_gc.pynever called, identity ledger DDL never applied,insights/storage.pynever instantiated.pytest.xfailwithout strict=True in test_breakers.py.New findings not in any issue yet
x-polylogue-semantic-roleannotations. Inference pipeline runs but output never integrated. 2 of 5 auto-inferred annotations wrong for claude-code, no pins to correct.pending_blob_refsqueried but never inserted into —_has_active_lease()always returns False.reset --databaseunlinks DB with no daemon check.normalize_role()duplicated with different behavior.chunked()triplicated: Identical implementation in 3 modules.Full synthesis:
.agent/scratch/deep-audit-2026-05-03/Sinity commentedon May 4, 2026
Resolved. All dependency graph issues (#599, #618, #620, #629, #621, #590, #601, #624, #717) are now implemented and closed. Fragile areas addressed: ingest_batch.py split, verification coverage enhanced, query descriptors implemented, Proof Pack enforced.