Repository navigation
feat(import): expose archive-backed import explain (#2178) - #2249
Conversation
Problem: #2178's landed baseline explained local import paths, but broad closure also required archived raw/source evidence retrieval plus explicit MCP and daemon/web treatment. That left the feature useful as a preflight, but not as an evidence-cockpit read surface.\n\nWhat changed: add archive-backed ImportExplain construction over source.db and index.db, extend the Python facade with raw_ref/source_path lookup, expose the shared payload through MCP and a shell-supported daemon route, classify the MCP tool contract, and regenerate OpenAPI route metadata. Archive-backed explanations omit raw bytes and redact absolute paths by default.\n\nVerification: devtools test focused ImportExplain/API/MCP/daemon nodes passed; devtools verify --quick passed; devtools verify passed with 266 affected tests.
|
Caution Review failedPull request was closed or merged during review 📝 WalkthroughWalkthroughAdds ChangesArchive-backed import explain feature
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b59701b8bb
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| ) | ||
| if path is None: | ||
| raise ValueError("path is required unless raw_ref or source_path is provided") | ||
| return explain_import_path(Path(path), source_name=source_name, limit=limit) |
There was a problem hiding this comment.
Honor redaction for local import paths
When callers use the newly exposed MCP/daemon local-path mode with the default redact_paths=True (or omit no_redact on /api/import/explain), this branch ignores that setting and calls explain_import_path directly, which resolves and serializes absolute local paths into source_path and skipped rows. That violates the new route contract that paths are redacted unless explicitly requested and can leak server-local archive/source paths; either apply the same redaction to path-backed explanations or disallow path on the redacted surfaces.
Useful? React with 👍 / 👎.
Summary
Completes #2178 by making ImportExplain archive-backed and cross-surface:
Polylogue.explain_import(...)can now explain already-observed raw evidence byraw_reforsource_path, MCP exposes the sharedImportExplainPayload, and the daemon exposes a shell-supported/api/import/explainroute. The archive-backed path readssource.dbraw/artifact evidence andindex.dbproduced rows without re-reading raw payload bytes.Problem
The first #2178 implementation was useful but incomplete: it explained local paths before import, while the issue also required a raw-ref/source-path read path for prior import evidence and explicit Python API/MCP/daemon treatment. That left ImportExplain narrowly true for CLI/API preflight but not broadly useful as an evidence-cockpit surface.
Solution
explain_import_archive(...)inpolylogue/sources/import_explain.pyto buildImportExplainPayloadfrom existingsource.dbandindex.dbrows.Polylogue.explain_import(...)so callers can passraw_reforsource_pathfor archive-backed explanations, while preserving the existing path preflight behavior.explain_importand classified it in the MCP envelope contract matrix as a typed report payload.GET /api/import/explainwith route-contract/OpenAPI metadata asshell_supportedlocal import/source evidence inspection.~/...for home paths,.../filenamefor other absolute paths) and omits raw bytes from every exposed payload.Closure matrix for #2178:
ImportExplainPayload: satisfied by the existing payloads and reused by CLI/API/MCP/daemon.Polylogue.explain_import, MCPexplain_import, and/api/import/explain.Verification
devtools test tests/unit/api/test_facade_contracts.py::test_explain_import_reads_archived_raw_evidence tests/unit/api/test_facade_contracts.py::test_explain_import_redacts_non_home_absolute_archive_paths tests/unit/mcp/test_server_surfaces.py::TestArchiveGenericToolSurfaces::test_explain_import_reads_shared_facade_payload tests/unit/mcp/test_envelope_contracts.py::TestRegistryWideClassification::test_every_registered_tool_is_classified tests/unit/mcp/test_envelope_contracts.py::test_envelope_class_carries_required_fields tests/unit/daemon/test_web_reader.py::TestReaderSessionState::test_import_explain_route_reads_archived_raw_evidence -q— 16 passed.devtools verify --quick— exit 0.devtools verify— exit 0; 266 affected tests passed in 147.78s, peak pytest RSS 781.5 MiB.Closes #2178
Summary by CodeRabbit
Release Notes