Skip to content

feat(web): execute context-pack workbench reads (#1846) - #2160

Merged
Sinity merged 1 commit into
masterfrom
feature/feat/workbench-overlay-mutations-1846
Jun 19, 2026
Merged

Sinity merged 1 commit into
masterfrom
feature/feat/workbench-overlay-mutations-1846

Conversation

@Sinity

@Sinity Sinity commented Jun 19, 2026 •

Copy link
Copy Markdown
Owner

Summary

Executes the context-pack read view through the daemon workbench route, shares the archive context-pack payload builder across MCP/API/daemon, and adds fixture-backed evidence for both context-pack reads and route-backed overlay mutations.

Problem

#1846 had the browser shell reading profile metadata from /api/read-view-profiles, but context-pack remained disabled in /api/sessions/:id/read even though the project already had a typed ContextPackPayload. MCP also owned a private archive context-pack builder, so the workbench/API route could not reuse the same payload without duplicating serialization. Separately, the #1846 map still described overlay mutation DTOs as future work even though user-state routes already return shared mutation envelopes.

Solution

Moved the archive-backed context-pack payload builder into polylogue.context.pack, reused it from MCP, exposed it via Polylogue.context_pack_payload(...), and wired /api/sessions/:id/read?view=context-pack to exact-session seeded payloads. The web shell now enables and renders context-pack from the same read-view selector. Added visual/daemon coverage for context-pack execution and overlay mark/annotation mutation envelopes, then updated the #1846 workbench map and issue body to reflect current scope.

Verification

  • .venv/bin/python -m devtools test tests/unit/daemon/test_web_reader.py tests/visual/test_reader_dom_smoke.py -k 'read_view_execution_route_returns_messages_recovery_raw_and_context_pack or test_reader_evidence_panel_endpoint_and_shell_smoke or test_reader_overlay_mutation_flow_evidence' -> 3 passed
  • .venv/bin/python -m devtools verify --quick -> exit_code: 0

Ref #1846

@coderabbitai

coderabbitai Bot commented Jun 19, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

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

More reviews will be available in 16 minutes and 13 seconds. Learn how PR review limits work.

Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file).

⌛ How to resolve this issue?

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

🚦 How do rate limits work?

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

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, the refill rate gradually slows as usage increases. The highest same-day bursts are limited more strictly.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 099f89e2-3955-4a70-a9ab-8aafe22fb448

📥 Commits

Reviewing files that changed from the base of the PR and between 645268a and 5bb72e0.

📒 Files selected for processing (8)
  • docs/plans/web-workbench-1846-v0-plan.md
  • polylogue/api/archive.py
  • polylogue/context/pack.py
  • polylogue/daemon/http.py
  • polylogue/daemon/web_shell.py
  • polylogue/mcp/server_context_tools.py
  • tests/unit/daemon/test_web_reader.py
  • tests/visual/test_reader_dom_smoke.py
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/feat/workbench-overlay-mutations-1846

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.

github-actions Bot pushed a commit that referenced this pull request Jun 19, 2026
Problem: #1846 had workbench read-profile metadata for context-pack, but the daemon read route still disabled it and MCP owned a private archive context-pack serializer. That left the browser/API/MCP surfaces fragmented around a real read-view payload.\n\nWhat changed: extracted the archive-backed context-pack payload builder into polylogue.context.pack, reused it from MCP, exposed it through the Python archive facade, and wired /api/sessions/:id/read?view=context-pack to exact-session seeded payloads. The web shell now enables and renders the context-pack read view. The branch also keeps the route-backed overlay mutation evidence and updates the #1846 workbench map to match the implemented surface.\n\nVerification: .venv/bin/python -m devtools test tests/unit/daemon/test_web_reader.py tests/visual/test_reader_dom_smoke.py -k 'read_view_execution_route_returns_messages_recovery_raw_and_context_pack or test_reader_evidence_panel_endpoint_and_shell_smoke or test_reader_overlay_mutation_flow_evidence'; .venv/bin/python -m devtools verify --quick.\n\nRef #1846
@Sinity
Sinity force-pushed the feature/feat/workbench-overlay-mutations-1846 branch from 3941aca to 5bb72e0 Compare June 19, 2026 10:18
@Sinity Sinity changed the title test(web): cover route-backed overlay mutations (#1846) feat(web): execute context-pack workbench reads (#1846) Jun 19, 2026
@Sinity
Sinity merged commit 9af1edc into master Jun 19, 2026
14 checks passed
@Sinity
Sinity deleted the feature/feat/workbench-overlay-mutations-1846 branch June 19, 2026 10:21
Sinity added a commit that referenced this pull request Jun 19, 2026
## Summary

This tightens the #2006 query grammar boundary for runtime-transform
unit sources. `runs where ...`, `observed-events where ...`, and
`context-snapshots where ...` remain valid terminal row queries, but
session-selector paths now reject them with a typed error instead of
manufacturing an unlowerable or ambiguous `exists ...` predicate. The
branch also registers the `context_pack_payload` API method added by
#2160 in the archive facade route catalog, which the broad seed
surfaced.

## Problem

The full query DSL issue distinguishes terminal row sources from
structural session selectors. Runtime-transform units are generated from
recovery/run projections today; they do not have durable SQL lowerers
that can support `exists run(...)`, `exists observed-event(...)`, or
`exists context-snapshot(...)` session predicates. Before this change,
`runs where ...` could leak into the session compiler as an `EXISTS`
predicate that storage cannot lower, while
observed-event/context-snapshot forms could fall through to weaker parse
behavior.

#2160 also added a public async `Polylogue.context_pack_payload(...)`
method without updating the archive-route catalog used by `polylogue ops
status`, so facade coverage and the JSON status snapshot drifted.

## Solution

- Add a typed terminal-only error in
`polylogue.archive.query.expression` for runtime-transform unit sources
used as session selectors.
- Keep `parse_unit_source_expression(...)` behavior intact for terminal
CLI/API/MCP/daemon query-unit routes.
- Document `runs` alongside the existing terminal units and clarify that
runtime-transform units are terminal-only until real durable lowerers
exist.
- Add focused parser and daemon HTTP coverage for the rejected
session-selector path.
- Register `context_pack_payload` as an index-routed archive facade
method and refresh the affected status snapshot.

## Verification

- `nix develop --command devtools test
tests/unit/cli/test_query_expression.py
tests/unit/daemon/test_web_reader.py -k
'terminal_only_unit_sources_do_not_compile_to_session_selectors or
session_list_rejects_terminal_only_unit_query or
parse_run_source_expression_preserves_terminal_unit or
query_units_endpoint_returns_run_rows'`
- `nix develop --command devtools test
tests/unit/cli/test_status.py::test_archive_facade_route_catalog_covers_public_async_facade
tests/unit/api/test_facade_contracts.py::test_no_undiscovered_async_methods`
- `nix develop --command devtools test
tests/unit/cli/test_plain_cli_snapshots.py::test_json_status_snapshot
--snapshot-update`
- `nix develop --command devtools test
tests/unit/cli/test_plain_cli_snapshots.py::test_json_status_snapshot`
- `nix develop --command devtools verify --quick`
- `git diff --check`

`nix develop --command devtools verify --seed-testmon --skip-slow`
(detached to avoid foreground session SIGTERM): 11,504 selected, 11,503
passed, 1 xfailed; peak pytest RSS 3,168 MiB.
- `nix develop --command devtools verify`: 7 affected tests passed; peak
pytest RSS 125 MiB.

Closes part of #2006.


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

* **New Features**
* Extended query DSL to support `runs` as a selectable terminal unit
alongside other units.
  * Added new `context_pack_payload` method to the facade API.

* **Bug Fixes**
* Improved error handling to provide clearer messages when terminal-only
units are used incorrectly in session queries.

* **Documentation**
* Updated query documentation with `runs` examples and expanded
structural unit coverage.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
Sinity added a commit that referenced this pull request Jun 19, 2026
## Summary

Adds executable `context` read support to the daemon workbench by
routing `/api/sessions/:id/read?view=context` through the same typed
`ContextPreamble` contract used by CLI/MCP/API surfaces. The web shell
now enables and renders the context preamble profile instead of treating
it as a pending browser-only placeholder.

## Problem

#1846 tracks the workbench as a browser cockpit over existing archive
contracts. After #2160, `context-pack` was route-backed, but `context`
remained disabled in the reader even though the context preamble already
existed as a real CLI/MCP-facing payload. That left the workbench
fragmented: browser code could show profile metadata but not execute one
of the concrete read profiles without inventing a separate shape.

## Solution

- Added `build_context_preamble_payload(...)` in
`polylogue/context/preamble.py` as the shared async builder for context
preamble DTOs.
- Exposed `Polylogue.context_preamble_payload(...)` and registered it in
the facade route catalog.
- Routed daemon `read?view=context&format=json` through the shared
builder and rendered it in `web_shell.py`.
- Reused the builder from MCP `compose_context_preamble` while
preserving seedless SessionStart behavior.
- Extended `ContextPreamble` with typed assertion guidance so injectable
assertion claims remain structured across API, daemon, MCP, and shell
surfaces.

Closes part of #1846. The issue remains open for the broader
operator-flow polish, remaining read profiles (`neighbors`,
`correlation`), overlay UX, and visual end-to-end flow completion.

## Verification

- `devtools test tests/unit/cli/test_context_view.py
tests/unit/mcp/test_compose_context_preamble.py
tests/unit/daemon/test_web_reader.py::TestReaderViewProfiles
tests/visual/test_reader_dom_smoke.py::test_reader_evidence_panel_endpoint_and_shell_smoke
tests/unit/cli/test_status.py::test_archive_facade_route_catalog_covers_public_async_facade
tests/unit/api/test_facade_contracts.py::test_no_undiscovered_async_methods`
- `devtools test
tests/unit/cli/test_plain_cli_snapshots.py::test_json_status_snapshot
--snapshot-update`
- `devtools test
tests/unit/cli/test_plain_cli_snapshots.py::test_json_status_snapshot`
- `devtools verify --quick`
- `devtools verify --seed-testmon --skip-slow` (11505 passed, 1 xfailed;
peak pytest RSS 3449.3 MiB)
- `devtools verify` (7 affected tests passed)
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