Skip to content

feat: add product-backed resume briefs (#379) - #379

Merged
Sinity merged 1 commit into
masterfrom
feature/feat/resume-brief
Apr 23, 2026
Merged

Sinity merged 1 commit into
masterfrom
feature/feat/resume-brief

Conversation

@Sinity

@Sinity Sinity commented Apr 23, 2026 •

Copy link
Copy Markdown
Owner

Summary

Adds polylogue resume <session-id> as a typed, product-backed handoff surface for reconstructing agent work state from an archived session. The brief combines archive facts, session-product inferences, work events, phase summaries, work-thread context, related sessions, uncertainties, and next-step hints.

Problem

Issue #309 needs a restart/resume path that is more useful than a transcript dump. Fresh agents need stable facts and explicit inference provenance from the archive/product layers, plus clear degradation when session products have not been materialized.

Solution

  • Added polylogue/archive_resume.py with ResumeBrief models and build_resume_brief() assembly over conversations, session profiles, enrichments, work events, phases, and work threads.
  • Exposed resume briefs through ArchiveOperations, Polylogue.resume_brief(), and the new polylogue resume CLI command.
  • Added plain rendering plus JSON output via --json, command-local --format json, and root --format json.
  • Included exact work-thread matching through normalized FTS plus unbounded exact fallback over stored session_ids, avoiding unsafe raw FTS queries and arbitrary result windows.
  • Refreshed CLI reference, proof catalog, quality workflow projections, showcase baselines, and terminal snapshots.

Verification

  • devtools verify -> all checks passed
  • pytest -q tests/unit/core/test_resume.py tests/unit/cli/test_resume.py
  • pytest -q tests/unit/core/test_resume.py tests/unit/cli/test_resume.py tests/unit/cli/test_click_app.py tests/unit/cli/test_terminal_snapshots.py
  • devtools verify-showcase
  • devtools render-all --check
  • ruff check polylogue/archive_resume.py polylogue/cli/commands/resume.py polylogue/cli/resume_rendering.py polylogue/cli/click_command_registration.py polylogue/facade_archive.py polylogue/operations/archive.py tests/unit/core/test_resume.py tests/unit/cli/test_resume.py tests/unit/cli/test_click_app.py
  • mypy polylogue/archive_resume.py polylogue/operations/archive.py
  • push hook: devtools verify --quick -> all checks passed

Closes #309

Summary by CodeRabbit

  • New Features

    • Added a resume command to reconstruct work-state context for starting fresh agent sessions, displaying conversation facts, inferred state, related sessions, and recommended next steps. Supports JSON output format.
  • Documentation

    • Updated CLI reference and help documentation for the new resume command.

Problem: fresh agents need a durable way to reconstruct work state from an archived session after interruption or handoff. A plain transcript dump loses typed facts, product-derived inferences, related sessions, and uncertainty about missing session products.

What changed: add a typed ResumeBrief product assembly over conversations, session products, work events, phases, and work threads; expose it through ArchiveOperations, the facade, and a new polylogue resume command with plain and JSON output. Refresh generated help/proof surfaces and add focused core, CLI, help, showcase, and snapshot coverage.

Verification: devtools verify -> all checks passed. Focused checks also run: pytest -q tests/unit/core/test_resume.py tests/unit/cli/test_resume.py; pytest -q tests/unit/core/test_resume.py tests/unit/cli/test_resume.py tests/unit/cli/test_click_app.py tests/unit/cli/test_terminal_snapshots.py; devtools verify-showcase; devtools render-all --check; ruff check on touched files; mypy on touched resume/operations files.

Closes #309
@Sinity Sinity changed the title feat: add product-backed resume briefs feat: add product-backed resume briefs (#379) Apr 23, 2026
@coderabbitai

coderabbitai Bot commented Apr 23, 2026 •

Copy link
Copy Markdown

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: 0b558e08-bb5b-4180-a212-d28c1fec7f72

📥 Commits

Reviewing files that changed from the base of the PR and between a432de6 and 246f01d.

📒 Files selected for processing (15)
  • docs/cli-reference.md
  • docs/test-quality-workflows.md
  • docs/verification-catalog.md
  • polylogue/archive_resume.py
  • polylogue/cli/click_command_registration.py
  • polylogue/cli/commands/resume.py
  • polylogue/cli/resume_rendering.py
  • polylogue/facade_archive.py
  • polylogue/operations/archive.py
  • tests/baselines/showcase/help-main.txt
  • tests/baselines/showcase/help-resume.txt
  • tests/unit/cli/__snapshots__/test_terminal_snapshots.ambr
  • tests/unit/cli/test_click_app.py
  • tests/unit/cli/test_resume.py
  • tests/unit/core/test_resume.py

📝 Walkthrough

Walkthrough

The PR introduces a new resume command that reconstructs work-state context for archived sessions. It adds domain logic to compose conversation facts and inferred session products into a ResumeBrief, CLI command registration, terminal rendering, operation layer integration, and comprehensive test coverage with documentation updates.

Changes

Cohort / File(s) Summary
Core Resume Logic
polylogue/archive_resume.py
New module defining Pydantic models (ResumeBrief, ResumeFacts, ResumeInferences, ResumeLastMessage, ResumePhase, ResumeRelatedSession, ResumeUncertainty, ResumeWorkEvent, ResumeWorkThread) and the build_resume_brief coroutine that orchestrates fact extraction, inference composition, related-session traversal, and error handling with uncertainty tracking.
CLI Command Implementation
polylogue/cli/commands/resume.py, polylogue/cli/resume_rendering.py
New command handler that invokes build_resume_brief with session ID and optional --related-limit, outputs JSON or rendered brief text; rendering module formats resume data as human-readable terminal sections including facts, inferred state, related sessions, uncertainties, and next steps.
Command Registration & API Integration
polylogue/cli/click_command_registration.py, polylogue/operations/archive.py, polylogue/facade_archive.py
Registers resume_command in Click root commands; adds build_resume_brief method via ArchiveResumeMixin to ArchiveOperations; exposes resume_brief method in PolylogueArchiveMixin facade and _ArchiveOperationsSurface protocol.
Documentation Updates
docs/cli-reference.md, docs/test-quality-workflows.md, docs/verification-catalog.md
CLI reference adds resume verb; test-quality-workflows snapshot reflects +1 scenario projection and +1 exercise; verification-catalog updates command subject count and proof obligations for the new resume command.
Help & Baseline Files
tests/baselines/showcase/help-main.txt, tests/baselines/showcase/help-resume.txt
Main help text includes new resume command; new baseline fixture documents polylogue resume command synopsis, description, and supported options (--related-limit, --json, --format).
Test Snapshots & CLI Tests
tests/unit/cli/__snapshots__/test_terminal_snapshots.ambr, tests/unit/cli/test_click_app.py
Terminal-width snapshots updated with resume command in help output; registered-commands test now expects "resume" in CLI subcommands.
Functional & Core Tests
tests/unit/cli/test_resume.py, tests/unit/core/test_resume.py
CLI test validates JSON output structure, plain-text rendering, and error handling for missing sessions; core test seeds linked sessions and verifies resume_brief composition with products available and degradation when products are unavailable.

Sequence Diagram

sequenceDiagram
    actor User
    participant CLI as resume_command
    participant Ops as ArchiveOperations
    participant Domain as build_resume_brief
    participant DB as Archive/Products
    participant Render as render_resume_brief

    User->>CLI: polylogue resume SESSION_ID [--related-limit]
    CLI->>Ops: operations.build_resume_brief(session_id)
    Ops->>Domain: build_resume_brief(operations, session_id)
    
    Domain->>DB: Load target conversation & facts
    alt Conversation found
        Domain->>DB: Load session products (profile, enrichment, work-events, phases)
        Domain->>DB: Load related sessions from thread/continuation
        Domain->>DB: Load work-thread via FTS5/fallback
        Domain->>Domain: Compose ResumeFacts, ResumeInferences
        Domain->>Domain: Compose next_steps from blockers/intent/outcomes
        Domain-->>Ops: ResumeBrief
    else Conversation not found
        Domain-->>Ops: None
    end
    
    CLI->>CLI: Check --json / --format flags
    alt JSON requested
        CLI->>User: emit_success(brief.model_dump(mode="json"))
    else Plain output
        CLI->>Render: render_resume_brief(brief)
        Render->>User: click.echo formatted sections
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Suggested labels

type:test, area:storage, area:qa

Poem

🐰 A resume blooms where sessions sleep,
Facts and inferences we gently keep,
With phases, threads, and work-event tales,
Fresh context rises when memory fails—
Hop back in time with just a brief! 🌿

✨ 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/feat/resume-brief

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.

@Sinity
Sinity merged commit a6c00af into master Apr 23, 2026
9 of 13 checks passed
@Sinity
Sinity deleted the feature/feat/resume-brief branch April 23, 2026 04:38

@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: 246f01d15a

ℹ️ 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/archive_resume.py Resolved
Comment thread polylogue/archive_resume.py Resolved
@Sinity

Sinity commented Apr 28, 2026

Copy link
Copy Markdown
Owner Author

🤖 Post-hoc audit note: this PR received bot review feedback verified against current HEAD as part of #544. 2 finding(s) confirmed still present → tracked in #550.

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.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Sinity added a commit that referenced this pull request May 7, 2026
## Summary

Adds `polylogue resume <session-id>` as a typed, product-backed handoff
surface for reconstructing agent work state from an archived session.
The brief combines archive facts, session-product inferences, work
events, phase summaries, work-thread context, related sessions,
uncertainties, and next-step hints.

## Problem

Issue #309 needs a restart/resume path that is more useful than a
transcript dump. Fresh agents need stable facts and explicit inference
provenance from the archive/product layers, plus clear degradation when
session products have not been materialized.

## Solution

- Added `polylogue/archive_resume.py` with `ResumeBrief` models and
`build_resume_brief()` assembly over conversations, session profiles,
enrichments, work events, phases, and work threads.
- Exposed resume briefs through `ArchiveOperations`,
`Polylogue.resume_brief()`, and the new `polylogue resume` CLI command.
- Added plain rendering plus JSON output via `--json`, command-local
`--format json`, and root `--format json`.
- Included exact work-thread matching through normalized FTS plus
unbounded exact fallback over stored `session_ids`, avoiding unsafe raw
FTS queries and arbitrary result windows.
- Refreshed CLI reference, proof catalog, quality workflow projections,
showcase baselines, and terminal snapshots.

## Verification

- `devtools verify` -> all checks passed
- `pytest -q tests/unit/core/test_resume.py
tests/unit/cli/test_resume.py`
- `pytest -q tests/unit/core/test_resume.py
tests/unit/cli/test_resume.py tests/unit/cli/test_click_app.py
tests/unit/cli/test_terminal_snapshots.py`
- `devtools verify-showcase`
- `devtools render-all --check`
- `ruff check polylogue/archive_resume.py
polylogue/cli/commands/resume.py polylogue/cli/resume_rendering.py
polylogue/cli/click_command_registration.py polylogue/facade_archive.py
polylogue/operations/archive.py tests/unit/core/test_resume.py
tests/unit/cli/test_resume.py tests/unit/cli/test_click_app.py`
- `mypy polylogue/archive_resume.py polylogue/operations/archive.py`
- push hook: `devtools verify --quick` -> all checks passed

Closes #309
@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.

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] polylogue resume <session-id> — reconstruct work-state context for fresh agent

2 participants