Repository navigation
feat(insights): session timeline renderer with fidelity tags (#1135) - #1165
Conversation
Adds a per-session timeline view that merges materialized work events
and session phases for one conversation and tags every entry with a
user-visible fidelity label.
- polylogue/insights/timeline_renderer.py: pure renderer over
SessionWorkEventInsight / SessionPhaseInsight payloads. Builds a
chronological SessionTimeline, derives fidelity_for() from raw
timing_provenance (timestamped_range -> hook, anything else ->
sort_key), and renders plain-text and Markdown surfaces with an
explicit legend.
- polylogue/cli/commands/insights.py: new `polylogue insights timeline
<conversation-id>` subcommand with --format plain|markdown|json
reading from env.operations.get_session_{work_event,phase}_insights.
- tests/unit/insights/test_timeline_renderer.py: contract tests pinning
the fidelity-tag invariant, hook-vs-sort_key precedence, ordering,
empty handling, and JSON serializability.
- tests/unit/cli/test_insights.py: CLI integration tests for plain and
JSON timeline output against the seeded workspace.
Closes #1135
Co-Authored-By: Claude Opus 4.7 (1M context) <[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 (9)
📝 WalkthroughWalkthroughThis PR introduces a session timeline renderer for the CLI ChangesTimeline Renderer & CLI Integration
🎯 3 (Moderate) | ⏱️ ~25 minutes
✨ 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: 0730ed74ac
ℹ️ 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".
|
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. |
Summary
Adds a per-session timeline view that merges already-materialized work events and session phases for one conversation, and tags every entry with a user-visible fidelity label distinguishing hook-precise timing (
hook) from sort-key-reconstructed timing (sort_key).Closes #1135.
Problem
Issue #1135 (carry-over from #804 / parent #994) calls for a usable surface over the per-session timeline data already materialized as
session_work_eventandsession_phaseinsights. Without a renderer, the durable rows are only reachable through generic list commands and JSON dumps. The issue also requires that each rendered timestamp carry a fidelity tag so consumers can tell whether timing came from a precise recorded range or was reconstructed from message sort-key order.Solution
polylogue/insights/timeline_renderer.py(new) — pure renderer.fidelity_for(timing_provenance)maps the existingWorkEventEvidencePayload.timing_provenance/SessionPhaseEvidencePayload.timing_provenanceto"hook"when it equalstimestamped_rangeand"sort_key"otherwise (including unknown values, since the precise branch is the explicitly-recognized one).build_session_timeline()merges the two insight streams into a chronologically orderedSessionTimeline;render_plain()andrender_markdown()emit human-readable surfaces with a legend;SessionTimeline.to_dict()provides the JSON contract that preserves both the user-visible tag and the rawtiming_provenancefor downstream consumers.polylogue/cli/commands/insights.py— addspolylogue insights timeline <conversation-id>with--format plain|markdown|json(inherits root--format). Reads fromenv.operations.get_session_work_event_insightsandget_session_phase_insights, then delegates to the renderer.tests/unit/insights/test_timeline_renderer.py(new, 21 cases) — pins the fidelity-tag invariant (parametrized over the full set of recognized provenance strings), hook-vs-sort_key precedence on the same session, chronological ordering across sources, untimed-entry placement, plain/markdown surface contracts, empty-timeline message, and JSON serializability.tests/unit/cli/test_insights.py— adds two CLI cases against the seededcli_workspace: JSON envelope contract (every entry hasfidelityin{"hook","sort_key"}and atiming_provenancefield) and plain output includes the legend.The renderer is deliberately a pure function over insight payloads: it does not query storage, does not recompute timing, and does not introduce a new persistence shape. Hook-event integration (#802) will land precise timestamps in the existing
timing_provenancefield; the renderer's fidelity-tag contract already covers that path without further code changes.Verification
Exact commands run inside
nix develop -c:pytest tests/unit/insights/test_timeline_renderer.py -q—21 passed in 12.88spytest tests/unit/insights/ tests/unit/cli/test_insights.py -q—76 passed in 16.70smypy polylogue/insights/timeline_renderer.py polylogue/cli/commands/insights.py tests/unit/insights/test_timeline_renderer.py—Success: no issues found in 3 source filesdevtools verify --quick—exit_code: 0(also re-run automatically by the pre-push hook, exit 0)devtools build-topology-projection— refresheddocs/plans/topology-target.yamlto register the new module;verify-topologythen passes.Acceptance criteria mapping (#1135)
hookorsort_key)TimelineEntry.fidelity;test_non_hook_provenances_are_sort_key(parametrized)test_hook_and_sort_key_remain_distinct_on_same_session--jsonmode both consume the stored timeline (no recomputation)insights_timeline_commandreadsget_session_work_event_insights/get_session_phase_insights;test_insights_timeline_json_emits_fidelity_tagstests/unit/insights/test_timeline_renderer.py+tests/unit/cli/test_insights.pybuild_session_timelineSessionTimeline.to_dict()The reader-panel and MCP-tool ACs are deliberately out of scope of this PR (other agents own those surfaces under #1135's sibling issues). The renderer is the shared API both surfaces will consume; this PR makes that API committed and tested.
🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
polylogue insights timelinecommand to display conversation work events and session phases in chronological order. Supports JSON, Markdown, and plain-text output formats.Documentation