Skip to content

feat(api): expose import explain payloads (#2178) - #2200

Merged
Sinity merged 1 commit into
masterfrom
feature/feat/import-explain-api-2178
Jun 19, 2026
Merged

Sinity merged 1 commit into
masterfrom
feature/feat/import-explain-api-2178

Conversation

@Sinity

@Sinity Sinity commented Jun 19, 2026

Copy link
Copy Markdown
Owner

Summary

Adds Polylogue.explain_import(...) as the Python API counterpart to the existing polylogue import PATH --explain CLI path. The method returns the shared ImportExplainPayload without writing archive rows, so library callers can inspect provider detection, parser mode, produced counts, skips, and caveats directly.

Problem

#2178 already has a CLI vertical for ImportExplain, but the explanation surface was not reusable from the async facade. That left Python/API consumers either shelling out to the CLI or reimplementing the local-path explanation helper, while the issue's next slices need shared API/MCP/daemon/web reuse.

Solution

  • Add PolylogueArchiveMixin.explain_import(path, source_name="unknown", limit=100) and delegate to the existing polylogue.sources.import_explain.explain_import_path helper.
  • Categorize the method in the facade contract tests as a bespoke payload helper.
  • Add focused tests for a successful Codex JSONL explanation and for malformed input staying bounded/no-raw-bytes.
  • Document the method in docs/library-api.md.

This does not close #2178. Raw/source-ref lookup plus daemon/MCP/web reuse remain owned by the issue.

Verification

  • devtools test tests/unit/api/test_facade_contracts.py -k "explain_import or undiscovered_async_methods or public_async_methods_have_return_annotations" -q -> 4 passed, 213 deselected.
  • devtools verify --quick -> exit_code 0.

Ref #2178

Problem: #2178 already has the CLI ImportExplain vertical, but library callers could not ask for the same non-mutating detector/parser explanation without shelling out to the CLI.

What changed: add Polylogue.explain_import(path, source_name, limit), document it in the library API, and cover the facade with both successful Codex JSONL input and bounded malformed-input reporting.

Verification: devtools test tests/unit/api/test_facade_contracts.py -k 'explain_import or undiscovered_async_methods or public_async_methods_have_return_annotations' -q; devtools verify --quick.
@coderabbitai

coderabbitai Bot commented Jun 19, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@Sinity, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 37 minutes and 4 seconds. Learn how PR review limits work.

Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file).

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits.

🚦 How do rate limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan refill rate.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, the refill rate gradually slows as usage increases. The highest same-day bursts are limited more strictly.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: ea103b13-807f-4c1d-a1e3-607ef91ab715

📥 Commits

Reviewing files that changed from the base of the PR and between 8ae5b4a and 16291dc.

📒 Files selected for processing (3)
  • docs/library-api.md
  • polylogue/api/archive.py
  • tests/unit/api/test_facade_contracts.py
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/feat/import-explain-api-2178

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

github-actions Bot pushed a commit that referenced this pull request Jun 19, 2026
@Sinity
Sinity merged commit 0de4331 into master Jun 19, 2026
14 checks passed
@Sinity
Sinity deleted the feature/feat/import-explain-api-2178 branch June 19, 2026 23:31

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 16291dccad

ℹ️ 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".

Comment thread polylogue/api/archive.py Resolved
@Sinity

Sinity commented Oct 1, 2026

Copy link
Copy Markdown
Owner Author

Historical Codex triage: evidence checked at 5ebcfe5. This records that source revision; it does not claim a fresh review of current master.

  • 59.F009 / P2: stale at the checked revision: polylogue/cli/commands/status.py:283 now obtains status through _status_operation_result instead of the retired public-async facade route catalog. The named catalog and coverage assertion are absent from the current status implementation and test, so adding explain_import no longer creates that missing-entry failure.

Only the rows listed above are dispositioned. Held findings remain open.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(import): explain provider detection, parsing, and produced archive rows

1 participant