Skip to content

Deepen captured Command log and Session trace reading #1222

Closed

Description

@JacobStephens2

What to build

Keep reading an exact Command log or Session trace through one captured reader that owns both current-inventory eligibility and writer completion. An open Console log stream should validate and read its selected file without rebuilding the inventory of every Command before each batch.

Preserve the current listing, IDs, presentation, offsets and completion rules. This is one standalone Ticket: the change fits one fresh context window and has no prerequisite work.

Acceptance criteria

  • A reader created by log inventory captures the inventory root and validates the selected file's current eligibility inside its read operation, before observing writer completion and draining bytes. Console callers no longer pair a whole-inventory lookup with each captured read.
  • Initial lookup and inventory listing keep their current behavior and IDs. JSON polling still resolves a fresh reader per request; this Ticket introduces no reader registry, token, cross-request retention or direct-ID lookup optimization.
  • Eligibility matches current enumeration: exactly owner/repository/commands/kind/file beneath the captured root; owner, repository and kind are real directory entries; the file is a real regular entry with a .log or .logs.jsonl suffix. Preserve the existing filename predicate rather than requiring a timestamp, storage token or Command record.
  • Preserve configured-root aliases and literal commands directory aliases: these are followed by today's listing. Continue excluding symlink entries for owner, repository, kind and file, old sessions storage, raw Session files, span files and saved notifications. Keep existing path-byte ID encoding, including directory names that are not UTF-8.
  • Removing an eligible file or replacing an enumerated ancestor/file with a symlink makes a later inventory-created read fail. A recorded outcome alone still cannot prove writer exit; losing a Command record or dispatched Session reference still retains the captured writer. Session transitions, PID reuse checks, malformed owning records, truncation, byte budgets and final draining retain their current rules.
  • Command-selected CLI reading retains its existing unconstrained selection behavior. Exact-file CLI reading uses the same inventory-created read operation as Console reading, including eligibility checks after selection.
  • After selection, an unrelated malformed inventory subtree cannot break the selected read, and selected reads do not enumerate the whole store. Cover this at the reader interface with retained files; keep HTTP coverage for initial HTML, JSON polling and SSE wiring, and CLI coverage for exact-file reads.
  • Add reader-interface coverage for eligible unowned/non-stamped files, excluded storage/suffixes, ancestor/file replacement, permitted root/commands aliases, and writer-completion behavior. Reuse existing reader, CLI and HTTP regressions; replace any redundant orchestration-only tests rather than duplicating them.
  • Update the domain-to-code navigation entry for log reading. Search the hand-written site and user guide for affected exact-log reading claims and correct any that become inaccurate. No new glossary term or ADR is required by this reversible implementation change.
  • Run focused reader, exact-log CLI and Console tests, then the repository's affected-test selector against main.

Blocked by

None (can start immediately).

Decisions

The design tree is complete. Its root is concentrating exact retained-file eligibility and byte reading; the dependent branches below were settled in order.

Round 1: scope and compatibility

  1. Deepen the existing reader module. Inventory-created readers will own membership validation as well as captured-writer observation and byte draining, because callers currently have to coordinate these operations to read correctly. This increases depth without adding another forwarding module.
  2. Keep listing and initial resolution intact. Leave full inventory construction at selection and listing, and keep finite polling's fresh selection per request, because replacing lookup or retaining state across HTTP requests would expand this Ticket into separate ownership and lifecycle work. This plan claims savings for subsequent reads of a captured reader, not every finite poll.
  3. Use captured inventory context only for inventory-created readers. Retain the lexical configured root with the selected path; command-selected readers keep their current constructor and behavior, because their Session references need not satisfy inventory layout. Membership state stays private; callers keep the existing read interface.

Round 2: implementation behind the seam

  1. Check membership locally at each read. Validate the captured relative layout and the selected entries' metadata, sharing the existing filename predicate with listing, because a bounded path check can establish eligibility without scanning unrelated Commands, histories or Sessions. Do not decode caller-provided IDs or introduce a new filename grammar.
  2. Match enumeration's alias behavior exactly. Check owner, repository, kind and final file without following their symlinks, while allowing the configured root and the literal commands path to resolve aliases, because those latter paths are passed directly to directory enumeration today. A filesystem prototype exposed this distinction; blanket ancestor-symlink rejection would change existing behavior.
  3. Validate membership, then run existing completion and drain logic. Reuse the captured writer and Session owner after eligibility succeeds, because refreshed inventory observations must not retarget an established reader or replace its writer. Keep the current path-reopen behavior; this change promises neither pinned file-inode identity nor an atomic defense against filesystem replacement races.
  4. Remove the Console's per-batch inventory lookup. Its existing reader handles eligibility before returning bytes, while the Console continues to own account authorization, conversation rendering, event framing and transport errors. This removes the caller's ordering obligation and preserves the distinction between membership failure, account revocation and normal completion.
  5. Apply the inventory constraint to every catalog-created reader. Initial pages, finite polls, SSE and exact-file CLI reads share the same implementation. This intentionally makes an exact-file CLI follow stop when its selected entry leaves the inventory, aligning it with Console behavior; command-selected CLI follows remain unchanged. No new adapter or trait is needed: existing filesystem and native process observations already provide the dependencies.

Round 3: verification and delivery

  1. Test through the reader interface with real temporary files. Reuse captured native process identities and the existing fixture children, because these exercise the same seam as callers without a new mock adapter. Assert bytes, offsets, completion and refusal, not private membership state or helper call order.
  2. Prove locality after capture. Add an unrelated repository whose literal commands path is a regular file after a valid reader is selected; selected reads must continue. Whole-store loading fails on that fixture today, so this gives a deterministic regression for accidental rescanning without timing thresholds, permissions assumptions or production benchmarks.
  3. Keep transport and lifetime regressions. Preserve coverage of CLI raw framing, Console line framing, final unterminated tails, bounded multiple batches, writer exit after outcome, record disappearance, Session replacement and converted Session references, because the optimization must not undo the recent captured-writer fixes. HTTP tests verify wiring; reader tests own eligibility behavior.
  4. Deliver one Ticket with no domain-document redesign. The existing Command log, Session trace and reader vocabulary is sufficient, and the implementation choice is easy to reverse, so no glossary change or ADR is warranted. Refresh navigation and any affected behavioral prose as part of implementation.

Review evidence: the filesystem prototype passed membership/listing parity, suffix and enumerated-symlink exclusions, permitted root and commands aliases, and independence from an unrelated invalid subtree. The repository was left unchanged; the required affected-test selector reported no changed files and no affected tests. Runtime Rust and HTTP regressions are implementation work, not claimed as executed by this review. All 131 open issue titles and bodies were checked; none proposes this deepening. Storage retention (#1155) and Inbox reconciliation (#919) concern different work.

Architecture review

Strength: Strong · Dependencies: local-substitutable

Files: src/logs/reading/catalog.rs, src/logs/reading/reader.rs, src/logs/reading/reader_tests.rs, src/logs/status/inspect.rs, src/console/logs.rs, tests/show_logs.rs, tests/console.rs, tests/console/watching.rs, docs/code-navigation.md

Before

flowchart LR
  C[Console Logs] -->|select once| I[Log inventory module]
  L[CLI exact-file logs] -->|select once| I
  C -. recheck membership each batch .-> I
  C -->|read| R[Captured reader module]
  L -->|read| R
  I --> F[Filesystem adapter]
  R --> F
  linkStyle 2 stroke:#dc2626,stroke-width:2px;
Loading

After

flowchart LR
  C[Console Logs] -->|select once| I[Log inventory module]
  L[CLI exact-file logs] -->|select once| I
  C -->|read| R[Captured reader module]
  L -->|read| R
  I -->|capture inventory context| R
  I --> F[Filesystem adapter]
  R -->|membership and bytes| F
  classDef deep stroke-width:3px;
  class R deep;
Loading

Problem: Console log reading exposes a shallow orchestration interface: membership rules leak across the seam, requiring a whole-store inventory before each captured read.

Solution: Deepen the captured reader module so its existing interface hides inventory membership validation before writer observation and byte draining.

Wins

  • Locality: eligibility and completion stay together
  • Leverage: CLI and Console share validation
  • Depth: callers lose membership ordering
  • Tests cross the reading seam
  • Captured reads avoid unrelated Commands

Activity

  1. added
    needs-triage
    ready-for-agent
    architect-plan
    in-progress
    and removed
    needs-triage
    ready-for-agent
    on Oct 24, 2026
  2. removed
    in-progress
    on Oct 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    architect-plan

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions