Repository navigation
Classify every read view by the operation route that serves it - #5160
Conversation
Design D3 for the CLI unification: each read view now declares one execution kind and the declared operations it reaches durable evidence through, so the S8 migrations have a total table to work from instead of a per-family guess. The design hypothesised that the per-session evidence views whose names resemble query units would lower to `query.units` with a `session:` filter. The relations refute it: `Session.session_events` is not the materialised relation `query_observed_events` reads, and the structured `file_edits` diffs are not the affected paths `query_files` reads. `hook_events`, `session_agent_policies`, `web_content_constructs` and the effective-context replay have no unit descriptor at all. All eleven are therefore `session.read` projections, and `query-units-projection` is declared but unpopulated. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01DYUNBGoE652b3nfmq3CtqK
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
Warning Review limit reachedNext included review available in 51 minutes. View limit detailsLimit details: You’ve used the included review currently available. You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Review configuration: ⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Advanced Run ID: 📒 Files selected for processing (2)
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 |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
> Stacked on #5160 (the D3 classification). Review that one first; this PR's > base will be retargeted to `master` once it merges. ## Summary The first S8 family migration. The `hooks` read view stops opening an archive through the API facade and instead lowers onto `session.read` and renders what the operation returns. ## Problem `read --view hooks` reached durable evidence by opening the `Polylogue` facade in-process (`cli/messages.py::run_hooks` → `api.get_hook_event_summary_for_session`). That is a second read authority inside a surface, and it is the shape S8 exists to remove. Two further consequences at head: - The view decided its own execution route. Nothing about whether a daemon was resident reached the decision, because there was no dispatch at all. - A missing session printed `Session not found: <ref>` through `env.ui.error` and returned normally. An operator scripting `read --view hooks` could not distinguish "this session recorded no hook events" from "this reference does not resolve", because both produced a zero exit and no evidence. ## Solution `session.read` grows a `kind` discriminator (`polylogue/operations/read_contracts.py`): - `transcript` — the message window it already served; unchanged. - `hooks` — the first per-session evidence relation, read through the pinned reader's `hook_event_summary_for_session` rather than the facade. Evidence kinds are bounded read models answered whole, so the request model refuses a continuation on one and the result model refuses three states that would otherwise be expressible: an evidence body on a transcript window, a transcript kind with no body, and a `hooks` result that reports itself partial. `_WHOLE_EVIDENCE_KINDS` names which kinds that last rule binds, so a kind that later genuinely needs paging graduates to the windowed contract instead of silently truncating. `lower_session_read` gains `kind=` and refuses window coordinates alongside an evidence kind. `run_read_hooks` becomes lowering + dispatch + render; it never opens an archive and never branches on daemon presence — which executor answers is the kernel's decision, recorded in the result's own authority. A refusal is classed exactly as the transcript path classes its own (`UsageError` for an ordinary refusal, `ClickException` for `daemon_required`/`result_too_large`), so it exits non-zero naming itself rather than rendering as an empty summary. `cli/messages.py::run_hooks` is deleted. `read_views/messages.py` survives because `messages` and `raw` still live there; it goes when the last of its views migrates. **Behaviour change, stated plainly:** a missing session under `read --view hooks` now exits non-zero with a typed refusal instead of exiting zero after a notice. This is the operator's 2026-09-14 ruling applied — a read that could not be served must never read as an empty result — and it makes `hooks` consistent with the transcript path, which already refuses an unresolvable reference. ## Golden bytes `scripts/golden_find_bytes.py` at `890a2921e` (master) vs this head: **37 goldens (13 skipped), byte-identical** (`cmp` clean). The documented `find` surface is untouched. As noted in #5160, the non-empty companion cases the brief attributes to S4/S6/S7's author are not on master and not in #5156/#5157/#5158's file lists, so the documented aggregates are all the harness offers. The three-way parity test below is the non-vacuous evidence for this change. ## Layering `docs/plans/layering-surface-baseline.json`: **273 before, 273 after.** `devtools gate layering` passed, `count=0`, `baselined_count=230`. The view now reaches `cli.lowering` + `cli.operation_kernel` instead of `polylogue.api`, so no baselined surface→substrate edge was added; the facade edge it drops belongs to `cli/messages.py`, which keeps other users of it until `messages`/`raw` migrate. ## Verification ``` devtools test tests/unit/operations/test_read_operation_declarations.py devtools test: PASSED exit=0 diagnosis=pytest_passed devtools test tests/unit/operations/test_session_read_parity.py devtools test: PASSED exit=0 diagnosis=pytest_passed devtools test tests/unit/cli/test_messages.py tests/unit/cli/test_query_verbs_runtime.py \ tests/unit/cli/test_query_set_read.py tests/unit/cli/test_read_view_classification.py devtools test: PASSED exit=0 diagnosis=pytest_passed devtools verify --quick # all gates ok devtools gate layering # count=0 devtools render all --check # exit 0, zero "out of sync" ``` **Read parity (the gap the design names for S8).** `tests/unit/operations/test_session_read_parity.py` runs the same `session.read` over three genuinely distinct routes on one seeded archive with hook events attached, and compares the bodies: - the **daemon** route, over the real UDS listener (`running_daemon_operations`), including envelope validation; - the **direct** route, the in-process handler over a pinned reader; - the **API** route, `Polylogue.get_hook_event_summary_for_session` — the facade MCP and the Python API already use. All three agree on the hooks body; a second test holds the transcript window across daemon and direct, so the `kind` discriminator is shown not to have changed the default read. **Broad run.** `devtools test tests/unit/cli tests/unit/operations` reports 9 failures. All 9 were reproduced at `890a2921e` (master): - 4 × `test_plain_cli_snapshots.py` — the known re-recording owned elsewhere; - `test_interaction_oracles.py::test_completion_script_parses_in_each_installed_real_shell`, `test_query_expression.py::…test_descriptor_runtime_transform_units_reject_aggregate_pipeline`, 2 × `test_archive_maintenance_cli.py`, and `test_mutation_actuators.py::…test_a_session_absent_from_the_index_is_still_tombstoned` — confirmed red on master by a separate run at that commit. Zero regressions attributable to this change. Anti-vacuity is named per test. The load-bearing ones: answering the hooks kind from the transcript branch, letting the daemon and direct routes use different readers, relaxing either result validator, or swallowing the refusal and printing an empty body each turn a test red. ## Closure `devtools schema closure` — every touched file reports `out`: - `polylogue/operations/read_contracts.py` → out - `polylogue/operations/daemon_reads.py` → out - `polylogue/cli/lowering.py` → out - `polylogue/cli/read_views/messages.py` → out - `polylogue/cli/messages.py` → out - `tests/unit/operations/test_session_read_parity.py` → out - `tests/unit/operations/test_read_operation_declarations.py` → out - `tests/unit/cli/test_messages.py` → out No rebuild-boundary constraint. ## Residuals - `SessionReadKind` is `{"transcript", "hooks"}`. The other five evidence families (`events`, `file-edits`, `agent-policies`, `web-content`, `effective_context`) each need a **sync reader on `ArchiveStore` that does not exist yet** — only `hook_event_summary_for_session` was already there; the rest are async repository methods. That substrate work is what each of those family PRs has to do first, and it is why `hooks` went first. - `messages` and `raw` still route through `cli/messages.py`, so `read_views/messages.py` is not deleted by this PR. - The API facade's `get_hook_event_summary_for_session` is retained: MCP and the Python API are its remaining consumers, and S8 does not own their migration. - `hooks` declares no view-specific options, so no option ownership moved. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01DYUNBGoE652b3nfmq3CtqK --------- Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
Summary
S8 of the CLI unification begins with a judgment call, not a migration: the
design (§2.3) left the read-view classification open and asked for it to be
decided "against
structural_query_units()at S8". This lands that decision(D3) as a declaration every view must satisfy, plus the test that keeps the
table total.
Problem
READ_VIEW_HANDLER_METADATAdescribed what options a view accepts but nothow the view reaches durable evidence. Each S8 family would otherwise have
re-derived that per PR, and the design's own hypothesis was wrong in a way
that is easy to repeat.
The design guessed that the per-session evidence views whose names resemble
query units would lower to
query.unitswith asession:filter. Checkedagainst the relations:
observed-eventunit reads the materializedquery_observed_eventsprojection (
archive/query/metadata.py,sql_query_method="query_observed_events");the
eventsview rendersSession.session_events, the parsedsession-timeline evidence (
api/archive.py:get_session_events). Differentrelation, different grain.
fileunit reads affected file paths viaquery_files; thefile-editsview renders the structuredfile_editsdiffs(
api/archive.py:get_file_edits).hooks(hook_events),agent-policies(session_agent_policies),web-content(web_content_constructs) andeffective_context(thecompaction-aware replay) have no unit descriptor at all —
structural_query_units()isaction, assertion, block, context-snapshot, delegation, file, message, observed-event, run.Solution
ReadViewHandlerMetadatagains a keyword-onlyexecution_kindand theoperationsit executes through. The decided partition:session-read-projectionagent-policies,dialogue,effective_context,events,file-edits,hooks,messages,raw,summary,transcript,web-contentquery-units-projectiondistinct-operationcontext,context-image,lineage,topology(context.compile/session.lineageland with S9)rendererchronicle,correlation,neighbors,temporal_validate_read_view_classificationruns at import, so a view cannot be addedwith an execution kind that contradicts the operations it names. The module
stays metadata-only: operation names are checked against
DAEMON_OPERATION_SPECSin the test, not the module.No execution path changes in this PR; the eleven
session.readfamiliesmigrate one per candidate on top of this table.
Golden bytes
scripts/golden_find_bytes.pyrun at890a2921e(master) and at this head:37 goldens (13 skipped), byte-identical (
cmpclean). Expected — this is adeclaration-only change.
The non-empty companion cases the brief attributes to S4/S6/S7's author are
not present on master and not in #5156/#5157/#5158's file lists, so the
documented aggregates are all the harness currently offers. Listed as a
residual.
Layering
docs/plans/layering-surface-baseline.json: 273 entries before, 273 after(unchanged — no import added or removed).
devtools gate layeringpassed withcount=0,baselined_count=230.Verification
Anti-vacuity: the three new tests go red if a read-view profile is added
without a classification, if a row names an operation the protocol does not
declare, if a
session.readprojection reaches for another operation, if arenderer composes nothing, or if any view is moved between kinds — including
reclassifying one of the per-session evidence views onto
query.units, thehypothesis the relation evidence above refutes.
Closure
devtools schema closure— both touched files reportout:polylogue/cli/read_view_registry.py→ outtests/unit/cli/test_read_view_classification.py→ outNo rebuild-boundary constraint.
Residuals
query-units-projectionis a declared kind with no members. It is keptrather than dropped because the S8 per-family PRs must be able to move a
view into it if a relation turns out to be unit-expressible; the test
enforces that such a move names a real grammar unit.
distinct-operationrows carry no operation name becausesession.lineageandcontext.compileare not declared until S9. Theimport-time validator enforces the empty tuple so the rows cannot quietly
claim a route they do not have.
session.readacross daemon,direct and the API's
get_sessionon the lineage corpus) belongs to thefirst family migration, not to this declaration-only change.
correlationis classifiedrendereroversession.readper D7; its localgit/ghevidence step is not an operation and is not modelled here.🤖 Generated with Claude Code
https://claude.ai/code/session_01DYUNBGoE652b3nfmq3CtqK