Skip to content

fix: close scope gaps — bare CLI, ingest contract, FK test - #902

Merged
Sinity merged 1 commit into
masterfrom
feature/fix/scope-gaps-batch-1
May 7, 2026
Merged

Sinity merged 1 commit into
masterfrom
feature/fix/scope-gaps-batch-1

Conversation

@Sinity

@Sinity Sinity commented May 7, 2026 •

Copy link
Copy Markdown
Owner

#825: wire bare polylogue to show_fast_status(). #861: CLI ingest uses ImportOperation.from_dict(). #881: add parent_message_id FK regression test.

Summary by CodeRabbit

  • New Features

    • Daemon status display now available in standard mode for faster status checks.
  • Bug Fixes

    • Import operations now report structured status information including operation ID and path details.
    • Improved error reporting for failed import operations.
  • Tests

    • Added tests validating message parent-child relationships and cascade deletion behavior.

- #825: wire bare polylogue to show_fast_status() via _show_stats
- #861: adapt CLI ingest to use ImportOperation.from_dict()
- #881: add parent_message_id self-referential FK regression test

Co-Authored-By: Claude Opus 4.7 <[email protected]>
Copilot AI review requested due to automatic review settings May 7, 2026 10:11
@Sinity
Sinity merged commit 3befca6 into master May 7, 2026
@Sinity
Sinity deleted the feature/fix/scope-gaps-batch-1 branch May 7, 2026 10:11
@coderabbitai

coderabbitai Bot commented May 7, 2026 •

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: c6f5afa5-2b55-4dea-9c46-6921b3a35878

📥 Commits

Reviewing files that changed from the base of the PR and between 370cb28 and 8115aba.

📒 Files selected for processing (3)
  • polylogue/cli/click_app.py
  • polylogue/cli/commands/ingest.py
  • tests/unit/storage/test_backend.py

📝 Walkthrough

Walkthrough

The PR adds typed daemon response parsing via ImportOperation model in the ingest command, updates CLI stats display to attempt fast status reporting with archive summary fallback, and introduces a test validating database foreign key and cascade delete behavior for message parent-child relationships.

Changes

Daemon Response Handling and Status Display Integration

Layer / File(s) Summary
Data Model Import
polylogue/cli/commands/ingest.py
Imports ImportOperation type to enable structured parsing of daemon responses.
Ingest Response Parsing
polylogue/cli/commands/ingest.py
Daemon response payload is loaded as raw JSON and converted to ImportOperation object; status-based success/error reporting uses typed fields.
Stats Display Fast Status Fallback
polylogue/cli/click_app.py
When non-verbose, _show_stats attempts to display fast daemon status; any exception silently falls back to archive summary.
Database Constraint Validation
tests/unit/storage/test_backend.py
New test verifies self-referential parent-message chains persist correctly and conversation deletion cascades to remove all associated messages.

🎯 2 (Simple) | ⏱️ ~12 minutes

🐰 The daemon whispers its status clear,
Response models parsed without fear,
Fast stats dance, with fallback grace,
Messages linked in their proper place. ✨

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/fix/scope-gaps-batch-1

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.

Copilot AI 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.

Pull request overview

This PR tightens a few “contract gaps” across CLI and storage: it makes bare polylogue show a fast status-oriented view when possible, aligns CLI ingest output with the shared ImportOperation envelope, and adds a regression test around the messages.parent_message_id FK behavior during conversation deletion.

Changes:

  • Bare polylogue now prefers show_fast_status() (daemon-first, SQLite fallback) when not in verbose mode.
  • polylogue ingest now parses the daemon response via ImportOperation.from_dict() and prints from the typed envelope.
  • Adds a unit test exercising deletion of a conversation containing a parent/child/grandchild message chain.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

File Description
polylogue/cli/click_app.py Routes the no-args CLI path through show_fast_status() when not verbose, else falls back to the existing archive summary.
polylogue/cli/commands/ingest.py Switches CLI ingest to interpret daemon responses via ImportOperation instead of ad-hoc dict access.
tests/unit/storage/test_backend.py Adds a regression test for deleting a conversation containing self-referential message chains.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 55 to 57
with urlopen(req, timeout=5) as resp:
result = json.loads(resp.read())
raw = json.loads(resp.read())
except OSError as exc:
Comment on lines +63 to +66
operation = ImportOperation.from_dict(raw)
if operation.status not in ("failed", "error"):
env.ui.console.print(
f"[bold green]Scheduled:[/bold green] {result['path']}\n"
f" Operation: {result['operation_id']}\n"
f" {result['message']}"
f"[bold green]Scheduled:[/bold green] {operation.path}\n"
Comment on lines +45 to +51
try:
from polylogue.cli.commands.status import show_fast_status

show_fast_status(env)
return
except Exception:
pass
Comment on lines +1472 to +1476
async def test_parent_message_id_self_referential_fk(
tmp_path: Path,
) -> None:
"""messages.parent_message_id FK uses NO ACTION — conversation-scoped deletion works."""
from polylogue.storage.sqlite.async_sqlite import SQLiteBackend
Sinity added a commit that referenced this pull request May 7, 2026
Three small slices for the user-facing CLI, the import-
contract migration, and storage FK invariants.

- #825 (bare CLI status): `polylogue/cli/click_app.py` wires
  bare `polylogue` (no subcommand) to `show_fast_status()` so
  the no-arg invocation matches the `polylogue status`
  command, satisfying #825's fast-feel acceptance criterion.
- #861 (import contract): `polylogue/cli/commands/ingest.py`
  parses incoming JSON through `ImportOperation.from_dict()`
  instead of bespoke kwargs, sharing the typed contract from
  PR #883 with daemon HTTP and the live watcher.
- #881 (FK regression): `tests/unit/storage/test_backend.py`
  adds a `parent_message_id` FK regression test pinning the
  `NO ACTION` policy from PR #881.

Refs #825, #861, #881
Sinity added a commit that referenced this pull request May 7, 2026
Three small slices for the user-facing CLI, the import-
contract migration, and storage FK invariants.

- #825 (bare CLI status): `polylogue/cli/click_app.py` wires
  bare `polylogue` (no subcommand) to `show_fast_status()` so
  the no-arg invocation matches the `polylogue status`
  command, satisfying #825's fast-feel acceptance criterion.
- #861 (import contract): `polylogue/cli/commands/ingest.py`
  parses incoming JSON through `ImportOperation.from_dict()`
  instead of bespoke kwargs, sharing the typed contract from
  PR #883 with daemon HTTP and the live watcher.
- #881 (FK regression): `tests/unit/storage/test_backend.py`
  adds a `parent_message_id` FK regression test pinning the
  `NO ACTION` policy from PR #881.

Refs #825, #861, #881
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.

2 participants