Repository navigation
refactor(api): define shared query/status response envelopes (#859) - #916
Conversation
…read surfaces (#859) Define canonical typed response models shared across daemon HTTP, MCP, CLI, and web reader surfaces. Expand the daemon HTTP /api/conversations endpoint to accept the full ConversationQuerySpec filter vocabulary. Co-Authored-By: Claude Opus 4.7 <[email protected]>
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (19)
📝 WalkthroughWalkthroughThis PR systematically removes session-profile full-text search infrastructure (four FTS tables and their triggers) while maintaining query functionality via LIKE-based filtering. Changes span schema DDL, runtime artifact graphs, readiness/repair specifications, HTTP API payloads, and test updates. ChangesSession-Profile FTS Removal
HTTP API Response Enhancements
Supporting Changes
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
Suggested labels
Poem
✨ 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: 689f0ff546
ℹ️ 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".
There was a problem hiding this comment.
Pull request overview
This PR refactors/aligns API surface payloads by introducing shared query/status response envelopes, expanding daemon HTTP query parameter support toward the canonical ConversationQuerySpec vocabulary, and simplifying some storage/indexing internals (notably removing session-profile FTS tables and switching message FTS rebuild to the FTS5 rebuild command with an external-content table).
Changes:
- Add shared surface payload models for query errors, list/detail envelopes, facets envelopes, and query-miss diagnostics; extend conversation list rows with repo/cwd/flags metadata.
- Update daemon HTTP list/facets handlers to build canonical query specs from query-string params and return richer response shapes (items/total/limit/offset + optional diagnostics).
- Remove session-profile FTS schema + readiness/repair plumbing; adjust session profile “search” to use
LIKEover stored search text; update message FTS DDL to external-content mode and change rebuild SQL.
Reviewed changes
Copilot reviewed 19 out of 19 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/unit/storage/test_backend.py | Updates archive inserts for new version column; adds new regression test around FTS trigger restoration on ingest exceptions. |
| polylogue/surfaces/payloads.py | Adds shared response envelopes (errors, list/detail, facets, diagnostics) and extends conversation list row payload. |
| polylogue/storage/sqlite/schema_ddl_insight_profiles.py | Removes session-profile FTS virtual tables/triggers from insight profile DDL. |
| polylogue/storage/sqlite/schema_ddl_archive.py | Adjusts messages FTS virtual table to use external content (content='messages'). |
| polylogue/storage/sqlite/queries/session_insight_profile_reads.py | Replaces session-profile FTS MATCH queries with LIKE over *_search_text columns. |
| polylogue/storage/repair.py | Removes session-profile FTS artifacts from repair counting logic. |
| polylogue/storage/insights/session/status.py | Removes session-profile FTS status counts/descriptors/ready flags. |
| polylogue/storage/insights/session/runtime.py | Removes session-profile FTS counters/ready flags from status snapshot types. |
| polylogue/storage/fts/sql.py | Updates FTS table DDL to external-content and switches rebuild SQL to INSERT ... VALUES('rebuild'). |
| polylogue/storage/derived/insights.py | Removes derived status entries for session-profile FTS artifacts. |
| polylogue/storage/derived/derived_status.py | Removes session-profile FTS metrics from derived-status aggregation. |
| polylogue/sources/drive/auth.py | Adds type-check suppression for TOML/env-config string path resolution. |
| polylogue/readiness/init.py | Removes readiness artifacts related to removed session-profile FTS tables. |
| polylogue/operations/specs.py | Updates operation artifact dependencies to remove session-profile FTS artifacts. |
| polylogue/insights/storage.py | Removes dropped insight tables from rebuild list (session-profile FTS family). |
| polylogue/insights/readiness.py | Simplifies readiness specs/artifact mapping after session-profile FTS removal. |
| polylogue/daemon/http.py | Adopts shared error envelope; expands list/facets query parsing toward ConversationQuerySpec; enriches list/detail outputs. |
| polylogue/cli/shared/formatting.py | Switches plain-mode forcing to typed config property force_plain. |
| polylogue/artifacts/runtime.py | Removes session-profile FTS artifact nodes and updates path dependencies accordingly. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| # After exception + restore, triggers should be active | ||
| conn.execute( | ||
| "INSERT INTO messages(message_id, conversation_id, role, text, provider_name) VALUES(?,?,?,?,?)", |
| # After exception + restore, triggers should be active | ||
| conn.execute( | ||
| "INSERT INTO messages(message_id, conversation_id, role, text, provider_name) VALUES(?,?,?,?,?)", | ||
| ("m2", "c1", "assistant", "after exception", "test"), | ||
| ) | ||
| conn.commit() | ||
|
|
||
| # FTS should have both messages (the original m1 via repair, | ||
| # and m2 via active trigger after restore) | ||
| from polylogue.storage.fts.fts_lifecycle import ensure_fts_index_sync | ||
|
|
||
| ensure_fts_index_sync(conn) | ||
| conn.execute("INSERT INTO messages_fts(messages_fts) VALUES('rebuild')") | ||
|
|
||
| count = conn.execute("SELECT COUNT(*) FROM messages_fts").fetchone()[0] | ||
| assert count == 2, f"Expected 2 FTS entries after exception recovery, got {count}" |
| val = handler._get_param(params, key) | ||
| if val is not None: | ||
| spec_params[key] = val |
| def _extract_repo(provider_meta: dict[str, object] | None) -> str | None: | ||
| if provider_meta is None: | ||
| return None | ||
| repo = provider_meta.get("repo") or provider_meta.get("repository") or provider_meta.get("git_repo") | ||
| return str(repo) if repo else None | ||
|
|
||
|
|
||
| def _extract_cwd(provider_meta: dict[str, object] | None) -> str | None: | ||
| if provider_meta is None: | ||
| return None | ||
| cwd = provider_meta.get("cwd") or provider_meta.get("working_directory") or provider_meta.get("cwd_display") | ||
| return str(cwd) if cwd else None |
| stats = await poly.stats() | ||
| tags = await poly.list_tags() | ||
| scoped_to_query = bool(query_params) | ||
|
|
||
| return { | ||
| "scoped_to_query": scoped_to_query, | ||
| "providers": stats.providers, | ||
| "tags": tags, | ||
| "repos": {}, | ||
| "cwd_prefixes": {}, | ||
| "message_types": {}, | ||
| "action_types": {}, | ||
| "has_flags": {}, | ||
| "time_range": None, |
| return configured | ||
|
|
||
| env_path = load_polylogue_config().get("drive_credentials_path") or str(drive_credentials_path()) | ||
| env_path = load_polylogue_config().get("drive_credentials_path") or str(drive_credentials_path()) # type: ignore[arg-type] |
Closes #859. CLI, MCP, daemon HTTP, and the dynamic web reader should adapt the same archive/query/status contracts; the code was close but the envelope spine was not yet complete. CLI and MCP already shared `ConversationQuerySpec` through their respective `query_contracts.py`, but daemon HTTP `/api/conversations` only parsed a small subset of filter params. - `polylogue/operations/specs.py`, `polylogue/insights/{readiness,storage}.py`, `polylogue/readiness/__init__.py`: shared response envelope models adopted by all read surfaces. - `polylogue/daemon/http.py`: daemon `/api/conversations` and related endpoints now use the full filter vocabulary instead of a hand-shaped subset. - `polylogue/cli/shared/formatting.py`: shared formatter consumes the new envelope so CLI output stays in sync with the typed contract. - 19 files across the read surfaces touched, +435/-397 net. Refs #859
Closes #859. CLI, MCP, daemon HTTP, and the dynamic web reader should adapt the same archive/query/status contracts; the code was close but the envelope spine was not yet complete. CLI and MCP already shared `ConversationQuerySpec` through their respective `query_contracts.py`, but daemon HTTP `/api/conversations` only parsed a small subset of filter params. - `polylogue/operations/specs.py`, `polylogue/insights/{readiness,storage}.py`, `polylogue/readiness/__init__.py`: shared response envelope models adopted by all read surfaces. - `polylogue/daemon/http.py`: daemon `/api/conversations` and related endpoints now use the full filter vocabulary instead of a hand-shaped subset. - `polylogue/cli/shared/formatting.py`: shared formatter consumes the new envelope so CLI output stays in sync with the typed contract. - 19 files across the read surfaces touched, +435/-397 net. Refs #859
|
Historical Codex triage: evidence checked at 5ebcfe5. This records that source revision; it does not claim a fresh review of current master.
Only the rows listed above are dispositioned. Held findings remain open. |
Shared response models. Daemon HTTP uses full filter vocabulary. 19 files +435/-397.
Summary by CodeRabbit
Release Notes
New Features
limit,offset,total), word counts, repository information, and feature flags (tool use, thinking, paste).Bug Fixes
Chores