Skip to content

feat(hooks): expose per-session hook-event read model - #3295

Merged
Sinity merged 1 commit into
masterfrom
feature/fix/hook-event-session-read-model
Jul 27, 2026
Merged

Sinity merged 1 commit into
masterfrom
feature/fix/hook-event-session-read-model

Conversation

@Sinity

@Sinity Sinity commented Jul 27, 2026

Copy link
Copy Markdown
Owner

Summary

  • New ArchiveStore.hook_event_summary_for_session() read model joining raw_hook_events to a session by (origin, native_id).
  • Exposed via a new hooks CLI read-view (polylogue read <session> --view hooks), following the existing messages/raw view registration pattern.

Problem

polylogue-31r1's original bug (hook events ingested as standalone sessions, inflating the archive ~4.7x) was fixed weeks ago (PR #3265). The bead stayed open for one named fast-follow: hook events are now persisted correctly as raw_hook_events linked to their originating session, but no read surface exposed "how many/which hook events happened during session X" — polylogue/cli/commands/hooks.py only covered hook-harness install/status.

Solution

hook_event_summary_for_session() returns per-event-type counts plus first/last observed timestamps. Hook rows have no raw_id link since they attach to the session identity, not to any one raw acquisition record, so the join is by (origin, native_id).

Verification

  • tests/unit/core/test_facade_api.py (archive-layer summary correctness including missing-session/no-hooks cases)
  • tests/unit/cli/test_messages.py (CLI JSON/YAML/missing-session)
  • tests/unit/api/test_facade_contracts.py (registers the new facade method in READ_BY_ID_NONE_METHODS)
  • 328 tests passed across the three files
  • mypy --strict clean on all 8 changed source files
  • ruff check + format: clean
  • devtools render all --check: clean (topology projection regenerated)
  • pre-push quick gate: all 16 checks green

Ref polylogue-31r1

Problem: polylogue-31r1's original bug (hook events ingested as
standalone sessions, inflating the archive ~4.7x) was fixed weeks ago
(PR #3265). The bead stayed open for one named fast-follow: hook
events are now persisted correctly as raw_hook_events linked to their
originating session, but no read surface exposed "how many/which hook
events happened during session X" - polylogue/cli/commands/hooks.py
only covered hook-harness install/status.

What changed: ArchiveStore.hook_event_summary_for_session() is a new
read model joining raw_hook_events to a session by (origin, native_id)
- hook rows have no raw_id link, since they attach to the session
identity, not to any one raw acquisition record. It returns per-event-
type counts plus first/last observed timestamps. Exposed via a new
`hooks` CLI read-view (`polylogue read <session> --view hooks`),
following the same registration pattern as the existing messages/raw
views.

Verification: tests/unit/core/test_facade_api.py (archive-layer
summary correctness including missing-session/no-hooks cases),
tests/unit/cli/test_messages.py (CLI JSON/YAML/missing-session),
tests/unit/api/test_facade_contracts.py (registers the new facade
method in READ_BY_ID_NONE_METHODS). 328 tests passed across the three
files. mypy --strict clean on all 8 changed source files. ruff check +
format clean. devtools render all --check clean (topology projection
regenerated).

Ref polylogue-31r1
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@coderabbitai

coderabbitai Bot commented Jul 27, 2026

Copy link
Copy Markdown

Warning

Review limit reached

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

Next review available in: 27 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

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 reviews.

How do review limits work?

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

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, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 32b7c50f-4473-425c-9410-8040a117146e

📥 Commits

Reviewing files that changed from the base of the PR and between 07b74da and 956d395.

📒 Files selected for processing (13)
  • docs/cli-reference.md
  • docs/plans/topology-target.yaml
  • polylogue/api/archive.py
  • polylogue/archive/viewport/profiles.py
  • polylogue/cli/messages.py
  • polylogue/cli/read_view_handlers.py
  • polylogue/cli/read_view_registry.py
  • polylogue/cli/read_views/messages.py
  • polylogue/storage/sqlite/archive_tiers/archive.py
  • polylogue/surfaces/projection_spec.py
  • tests/unit/api/test_facade_contracts.py
  • tests/unit/cli/test_messages.py
  • tests/unit/core/test_facade_api.py
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/fix/hook-event-session-read-model

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.

@Sinity
Sinity merged commit 4d075ea into master Jul 27, 2026
3 checks passed
@Sinity
Sinity deleted the feature/fix/hook-event-session-read-model branch July 27, 2026 02:59
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.

1 participant