Repository navigation
Serve the hooks read view from the session.read operation - #5167
Merged
Merged
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
First S8 family migration on the D3 classification. The hooks view no longer opens an archive through the API facade: it lowers onto `session.read` and renders what the operation returns. `session.read` grows a `kind` discriminator. `transcript` is the message window it already served; `hooks` is the first per-session evidence relation, read through the pinned reader (`hook_event_summary_for_session`). Evidence kinds are bounded read models answered whole, so the result model refuses a partial evidence body, refuses an evidence body on a transcript window, and refuses a transcript that carries none. The view no longer branches on whether a daemon is present -- which executor answers is the kernel's decision, recorded in the result's own authority. A refused read now exits non-zero naming the refusal instead of printing a not-found notice and returning zero, so it can never be read as "this session recorded no hook events". Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01DYUNBGoE652b3nfmq3CtqK
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Advanced Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The first S8 family migration. The
hooksread view stops opening an archivethrough the API facade and instead lowers onto
session.readand renders whatthe operation returns.
Problem
read --view hooksreached durable evidence by opening thePolyloguefacadein-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:
resident reached the decision, because there was no dispatch at all.
Session not found: <ref>throughenv.ui.errorand returned normally. An operator scripting
read --view hookscould notdistinguish "this session recorded no hook events" from "this reference does
not resolve", because both produced a zero exit and no evidence.
Solution
session.readgrows akinddiscriminator (polylogue/operations/read_contracts.py):transcript— the message window it already served; unchanged.hooks— the first per-session evidence relation, read through the pinnedreader's
hook_event_summary_for_sessionrather 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
hooksresult that reports itself partial._WHOLE_EVIDENCE_KINDSnames which kinds that last rule binds, so a kind thatlater genuinely needs paging graduates to the windowed contract instead of
silently truncating.
lower_session_readgainskind=and refuses window coordinates alongside anevidence kind.
run_read_hooksbecomes lowering + dispatch + render; it neveropens 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 (
UsageErrorfor anordinary refusal,
ClickExceptionfordaemon_required/result_too_large), soit exits non-zero naming itself rather than rendering as an empty summary.
cli/messages.py::run_hooksis deleted.read_views/messages.pysurvivesbecause
messagesandrawstill live there; it goes when the last of itsviews migrates.
Behaviour change, stated plainly: a missing session under
read --view hooksnow 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
hooksconsistent withthe transcript path, which already refuses an unresolvable reference.
Golden bytes
scripts/golden_find_bytes.pyat890a2921e(master) vs this head:37 goldens (13 skipped), byte-identical (
cmpclean). The documentedfindsurface 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 layeringpassed,count=0,baselined_count=230.The view now reaches
cli.lowering+cli.operation_kernelinstead ofpolylogue.api, so no baselined surface→substrate edge was added; thefacade edge it drops belongs to
cli/messages.py, which keeps other users ofit until
messages/rawmigrate.Verification
Read parity (the gap the design names for S8).
tests/unit/operations/test_session_read_parity.pyruns the samesession.readover three genuinely distinct routes on one seeded archive with hook events
attached, and compares the bodies:
running_daemon_operations),including envelope validation;
Polylogue.get_hook_event_summary_for_session— the facadeMCP 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
kinddiscriminator is shown not to havechanged the default read.
Broad run.
devtools test tests/unit/cli tests/unit/operationsreports 9failures. All 9 were reproduced at
890a2921e(master):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, andtest_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 reportsout:polylogue/operations/read_contracts.py→ outpolylogue/operations/daemon_reads.py→ outpolylogue/cli/lowering.py→ outpolylogue/cli/read_views/messages.py→ outpolylogue/cli/messages.py→ outtests/unit/operations/test_session_read_parity.py→ outtests/unit/operations/test_read_operation_declarations.py→ outtests/unit/cli/test_messages.py→ outNo rebuild-boundary constraint.
Residuals
SessionReadKindis{"transcript", "hooks"}. The other five evidencefamilies (
events,file-edits,agent-policies,web-content,effective_context) each need a sync reader onArchiveStorethat does notexist yet — only
hook_event_summary_for_sessionwas already there; therest are async repository methods. That substrate work is what each of those
family PRs has to do first, and it is why
hookswent first.messagesandrawstill route throughcli/messages.py, soread_views/messages.pyis not deleted by this PR.get_hook_event_summary_for_sessionis retained: MCP and thePython API are its remaining consumers, and S8 does not own their migration.
hooksdeclares no view-specific options, so no option ownership moved.🤖 Generated with Claude Code
https://claude.ai/code/session_01DYUNBGoE652b3nfmq3CtqK