Repository navigation
docs: fix doc-vs-code drift across the Reference-docs table - #2610
Conversation
Ref polylogue-57bg, polylogue-9e5.13. Co-Authored-By: Claude <[email protected]>
## Summary Sweep every doc in CLAUDE.md's Reference-docs table for checkable factual claims (file paths, schema versions, table names, CLI command names) that have drifted from current source, fix each one, and add a rerunnable devtools lint so the sweep is a repeatable gate rather than a one-off. ## Problem Free-text docs have nothing forcing them to track a renamed table, a moved file, a bumped schema version, or a renamed CLI command. Found via mechanical + manual sweep: - `artifact_observations` (pre-split-file-cutover table name) still asserted as the current blob-linking table in architecture.md and internals.md; the real table has been `raw_artifacts` since #1787. - Several file paths pointing at files that moved or were split into packages: `pipeline/prepare_enrichment.py` (gone; real idempotency skip-decision lives in `pipeline/services/ingest_batch/_core.py`), `pipeline/services/ingest_batch.py` (now a package, `_core.py` is the largest file), `archive_tiers/bootstrap.py` (missing `storage/sqlite/` prefix), and the provider-parser table in architecture.md (missing `sources/` prefix; Claude web/Code split into `claude/ai_parser.py` and `claude/code_parser.py`). - internals.md's Index schema version history stopped at v24; the current constant is v28 (delegations view, primary_model_name/family, actions-view transcript-rank rewrite, blocks.content_hash) with no entries for v25-v28. - The `boundary_table_counts` table list in internals.md had a typo (`session_profile` vs `session_profiles`), a wrong name (`live_convergence_debt` vs `convergence_debt`), a table not actually in the probe's tuple (`actions`), and a stale CLI flag (`--exact-table-counts` vs the real `--exact-derived-counts`). - Both internals.md and architecture-spine.md described blob GC as "link counting" when the real (and separately, accurately documented elsewhere in internals.md) mechanism is a snapshot reference check plus a pending-lease check. - cost-model.md referenced two CLI commands that don't exist: `polylogue cost outlook` (real: `polylogue analyze --cost-outlook`) and `polylogue diagnostics usage` (real: `polylogue analyze usage`). - devtools/command_catalog.py's `insight-honesty` use_when text (source of the generated devtools.md table) said `polylogue insights audit`; real command is `polylogue ops insights audit`. - mcp-reference.md was severely stale: 3 of ~100 registered tools listed, both documented resource URIs don't exist (real ones are `polylogue://stats`, `polylogue://session/{conv_id}`, etc.), and the configuration block invoked a nonexistent `polylogue mcp` subcommand instead of the real standalone `polylogue-mcp --role read` entrypoint. Not touched: internals.md's FTS5 `content='messages'` claim vs the actual contentless build — that fix is owned by polylogue-3tl.14. ## Solution - `devtools/verify_docs_drift.py` (new, registered as `devtools lab policy docs-drift`, wired into `devtools verify --lab`): mechanically checks (1) every backtick-quoted, extension-bearing path referenced in a Reference-docs entry exists on disk (tried as-is, then under `polylogue/`/`tests/`, with a historical-reference exemption for paths explicitly described as retired/superseded), (2) every "<Tier> schema version N" claim does not exceed the tier's current `*_SCHEMA_VERSION` constant, and (3) a short explicit watchlist of renamed/removed table names (starting with `artifact_observations` -> `raw_artifacts`) isn't asserted as current. - Fixed every drift found above directly in the docs (and in command_catalog.py's use_when text, since docs/devtools.md is generated from it). - Filed polylogue-iyew (discovered-from 9e5.13) for a real code bug found incidentally: `daemon_workload_probe.py`'s `_BOUNDARY_TABLES` still lists `artifact_observations` too, so that probe slot has silently reported -1/missing since the split-file cutover. Left unfixed here — it's a probe-code bug, not a doc, and outside this bead's docs-only scope. ## Verification - `python3 -m devtools lab policy docs-drift`: "zero unhandled drift across the reference-docs sweep." - `python3 -m devtools test tests/unit/devtools`: 816 passed (includes the 12 new tests in test_verify_docs_drift.py). - `python3 -m mypy devtools/verify_docs_drift.py devtools/command_catalog.py devtools/verify.py --strict`: clean. - `python3 -m devtools render all --check`: clean (no "out of sync" surfaces; regenerated docs/devtools.md picks up the corrected insight-honesty use_when text and the new docs-drift catalog entry). - `python3 -m devtools verify --quick`: all 14 steps exit 0. - `python3 -m ruff format --check` / `ruff check`: clean on all touched Python files. Ref polylogue-9e5.13. Co-Authored-By: Claude <[email protected]>
Ref polylogue-9e5.13, polylogue-iyew. Co-Authored-By: Claude <[email protected]>
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
📝 WalkthroughWalkthroughAdds a new devtools docs-drift verifier ( ChangesDocs-drift verification and corrections
Estimated code review effort: 3 (Moderate) | ~25 minutes Sequence Diagram(s)sequenceDiagram
participant Verify as devtools verify --lab
participant Catalog as command_catalog
participant Checker as verify_docs_drift.main()
participant Docs as Reference docs / source
Verify->>Catalog: resolve "lab policy docs-drift" step
Catalog->>Checker: invoke entrypoint
Checker->>Docs: read REFERENCE_DOCS markdown, check paths/schema versions/watchlist
Docs-->>Checker: drift findings
Checker-->>Verify: DriftReport, exit code
Possibly related issues
Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
⚔️ Resolve merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@docs/mcp-reference.md`:
- Around line 3-31: Remove the hardcoded “~100 tools” estimate from the MCP
tools overview in docs/mcp-reference.md and rely on the test-enforced contract
instead. Update the introductory paragraph near the tool category list to avoid
a drifting numeric claim, while keeping the reference to
tests/infra/mcp.py:EXPECTED_TOOL_NAMES as the source of truth for the registered
tool set.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: f0bf0842-8d52-4163-b540-a6f701a7c08e
📒 Files selected for processing (12)
.beads/interactions.jsonl.beads/issues.jsonldevtools/command_catalog.pydevtools/verify.pydevtools/verify_docs_drift.pydocs/architecture-spine.mddocs/architecture.mddocs/cost-model.mddocs/devtools.mddocs/internals.mddocs/mcp-reference.mdtests/unit/devtools/test_verify_docs_drift.py
| Polylogue exposes an MCP (Model Context Protocol) server that coding agents can use to query | ||
| AI chat archives during sessions. | ||
| AI chat archives during sessions. This is the primary continuity surface — richer than the | ||
| CLI or Python API for agent-facing recall, corrections, and context assembly. | ||
|
|
||
| ## Tools | ||
|
|
||
| - `list_sessions` — List recent sessions, filterable by path and sort order. | ||
| - `get_session` — Retrieve a full session by ID with optional prose-only projection. | ||
| - `search` — Full-text search across sessions with filter chains. | ||
| ~100 tools registered across `polylogue/mcp/server_*.py`, gated by capability role (see | ||
| Configuration below). A representative sample by category: | ||
|
|
||
| - **Search / list / get**: `search`, `list_sessions`, `get_session`, `get_messages`, | ||
| `get_session_tree`, `get_session_summary`, `get_logical_session`, `facets`. | ||
| - **Insights**: `get_stats_by`, `session_costs`, `cost_rollups`, `usage_timeline`, | ||
| `tool_usage`, `workflow_shape_distribution`, `session_latency_profile`. | ||
| - **Continuity / recall**: `compile_context`, `build_context_image`, | ||
| `compose_context_preamble`, `get_resume_brief`, `find_resume_candidates`, | ||
| `find_abandoned_sessions`, `find_stuck_sessions`. | ||
| - **Correlation / topology**: `correlate_session`, `correlate_sessions`, | ||
| `get_session_topology`, `neighbor_candidates`, `find_similar_sessions`, | ||
| `compare_sessions`. | ||
| - **Postmortem / pathology**: `get_postmortem_bundle`, `get_pathologies`, | ||
| `insight_rigor_audit`. | ||
| - **Corrections / assertions** (write role): `add_tag`, `bulk_tag_sessions`, | ||
| `blackboard_post`. | ||
| - **Maintenance** (admin role): `maintenance_preview`, `maintenance_execute`, | ||
| `rebuild_index`, `update_index`, `rebuild_session_insights`. | ||
|
|
||
| The exhaustive, currently-registered tool name set is a test-enforced contract, not hand | ||
| duplicated here: `tests/infra/mcp.py:EXPECTED_TOOL_NAMES`. Adding a tool requires updating | ||
| that set plus its tool contract (see `CLAUDE.md` § MCP gotchas). |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
Drop the hardcoded tool count.
The ~100 tools claim will drift independently of tests/infra/mcp.py:EXPECTED_TOOL_NAMES, which is the actual contract this section points readers to. Consider removing the numeric estimate or deriving it from that contract instead.
Suggested rewrite
-~100 tools registered across `polylogue/mcp/server_*.py`, gated by capability role (see Configuration below). A representative sample by category:
+Tools registered across `polylogue/mcp/server_*.py`, gated by capability role (see Configuration below). A representative sample by category:📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| Polylogue exposes an MCP (Model Context Protocol) server that coding agents can use to query | |
| AI chat archives during sessions. | |
| AI chat archives during sessions. This is the primary continuity surface — richer than the | |
| CLI or Python API for agent-facing recall, corrections, and context assembly. | |
| ## Tools | |
| - `list_sessions` — List recent sessions, filterable by path and sort order. | |
| - `get_session` — Retrieve a full session by ID with optional prose-only projection. | |
| - `search` — Full-text search across sessions with filter chains. | |
| ~100 tools registered across `polylogue/mcp/server_*.py`, gated by capability role (see | |
| Configuration below). A representative sample by category: | |
| - **Search / list / get**: `search`, `list_sessions`, `get_session`, `get_messages`, | |
| `get_session_tree`, `get_session_summary`, `get_logical_session`, `facets`. | |
| - **Insights**: `get_stats_by`, `session_costs`, `cost_rollups`, `usage_timeline`, | |
| `tool_usage`, `workflow_shape_distribution`, `session_latency_profile`. | |
| - **Continuity / recall**: `compile_context`, `build_context_image`, | |
| `compose_context_preamble`, `get_resume_brief`, `find_resume_candidates`, | |
| `find_abandoned_sessions`, `find_stuck_sessions`. | |
| - **Correlation / topology**: `correlate_session`, `correlate_sessions`, | |
| `get_session_topology`, `neighbor_candidates`, `find_similar_sessions`, | |
| `compare_sessions`. | |
| - **Postmortem / pathology**: `get_postmortem_bundle`, `get_pathologies`, | |
| `insight_rigor_audit`. | |
| - **Corrections / assertions** (write role): `add_tag`, `bulk_tag_sessions`, | |
| `blackboard_post`. | |
| - **Maintenance** (admin role): `maintenance_preview`, `maintenance_execute`, | |
| `rebuild_index`, `update_index`, `rebuild_session_insights`. | |
| The exhaustive, currently-registered tool name set is a test-enforced contract, not hand | |
| duplicated here: `tests/infra/mcp.py:EXPECTED_TOOL_NAMES`. Adding a tool requires updating | |
| that set plus its tool contract (see `CLAUDE.md` § MCP gotchas). | |
| Polylogue exposes an MCP (Model Context Protocol) server that coding agents can use to query | |
| AI chat archives during sessions. This is the primary continuity surface — richer than the | |
| CLI or Python API for agent-facing recall, corrections, and context assembly. | |
| ## Tools | |
| Tools registered across `polylogue/mcp/server_*.py`, gated by capability role (see | |
| Configuration below). A representative sample by category: | |
| - **Search / list / get**: `search`, `list_sessions`, `get_session`, `get_messages`, | |
| `get_session_tree`, `get_session_summary`, `get_logical_session`, `facets`. | |
| - **Insights**: `get_stats_by`, `session_costs`, `cost_rollups`, `usage_timeline`, | |
| `tool_usage`, `workflow_shape_distribution`, `session_latency_profile`. | |
| - **Continuity / recall**: `compile_context`, `build_context_image`, | |
| `compose_context_preamble`, `get_resume_brief`, `find_resume_candidates`, | |
| `find_abandoned_sessions`, `find_stuck_sessions`. | |
| - **Correlation / topology**: `correlate_session`, `correlate_sessions`, | |
| `get_session_topology`, `neighbor_candidates`, `find_similar_sessions`, | |
| `compare_sessions`. | |
| - **Postmortem / pathology**: `get_postmortem_bundle`, `get_pathologies`, | |
| `insight_rigor_audit`. | |
| - **Corrections / assertions** (write role): `add_tag`, `bulk_tag_sessions`, | |
| `blackboard_post`. | |
| - **Maintenance** (admin role): `maintenance_preview`, `maintenance_execute`, | |
| `rebuild_index`, `update_index`, `rebuild_session_insights`. | |
| The exhaustive, currently-registered tool name set is a test-enforced contract, not hand | |
| duplicated here: `tests/infra/mcp.py:EXPECTED_TOOL_NAMES`. Adding a tool requires updating | |
| that set plus its tool contract (see `CLAUDE.md` § MCP gotchas). |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@docs/mcp-reference.md` around lines 3 - 31, Remove the hardcoded “~100 tools”
estimate from the MCP tools overview in docs/mcp-reference.md and rely on the
test-enforced contract instead. Update the introductory paragraph near the tool
category list to avoid a drifting numeric claim, while keeping the reference to
tests/infra/mcp.py:EXPECTED_TOOL_NAMES as the source of truth for the registered
tool set.
…e5.13 # Conflicts: # .beads/interactions.jsonl # .beads/issues.jsonl
Summary
Sweeps every doc in CLAUDE.md's Reference-docs table for checkable factual claims that drifted from current source, fixes each one, and adds a rerunnable devtools lint (
devtools lab policy docs-drift) so the sweep is a repeatable gate rather than a one-off.Problem
Free-text docs have nothing forcing them to track a renamed table, a moved file, a bumped schema version, or a renamed CLI command. Found via mechanical + manual sweep across
docs/architecture.md,docs/internals.md,docs/architecture-spine.md,docs/cost-model.md,docs/mcp-reference.md,docs/devtools.md.Solution
artifact_observations→raw_artifacts(pre-split-file-cutover table name still asserted as current, 3 sites) — spot-verified against the live DDL (storage/sqlite/archive_tiers/source.py:84).pipeline/prepare_enrichment.pycorrected to the real idempotency skip-decision site (pipeline/services/ingest_batch/_core.py:398-400), plus several other moved/missing-prefix file paths.internals.md's Index schema version history extended v24→v28 (content_hash anchors, actions-view rank rewrite, primary_model fields, delegations view).boundary_table_countsprose fixes (typo, renamed table, phantom entry, stale flag name).polylogue cost outlook→analyze --cost-outlook,polylogue diagnostics usage→analyze usage,polylogue insights audit→ops insights audit.docs/mcp-reference.mdrewritten — was listing 3 of ~100 tools, with two fictional resource URIs and a nonexistentpolylogue mcpsubcommand.Explicitly left untouched: the FTS5
content='messages'claim (owned bypolylogue-3tl.14, do not duplicate).Follow-up filed:
polylogue-iyewfor a real code bug found along the way —devtools/daemon_workload_probe.py's_BOUNDARY_TABLEStuple still has the staleartifact_observationsname, silently reporting -1 for that slot since the split-file cutover. Left unfixed since it's code, not docs, and out of this bead's scope.Verification
Independently re-verified (not just the authoring agent's own report):
python3 -m devtools lab policy docs-drift→ zero unhandled driftpython3 -m mypy --strict devtools/verify_docs_drift.py devtools/command_catalog.py devtools/verify.py→ cleanpython3 -m devtools test tests/unit/devtools/test_verify_docs_drift.py→ 12 passedpython3 -m devtools render all --check→ clean (no "out of sync" surfaces)Ref polylogue-9e5.13, polylogue-iyew.
🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Bug Fixes
Tests