Skip to content

Check log inventory eligibility inside the captured reader - #1226

Merged
JacobStephens2 merged 5 commits into
mainfrom
issue-1222
Oct 24, 2026
Merged

JacobStephens2 merged 5 commits into
mainfrom
issue-1222

Conversation

@JacobStephens2

@JacobStephens2 JacobStephens2 commented Oct 24, 2026 •

Copy link
Copy Markdown
Owner

Summary

An exact Command log or Session trace selected from the log inventory now checks its own eligibility inside each read. The Console's log stream no longer rebuilds the whole inventory before every batch.

 Console log SSE, per batch
   authorize account (on revision change)
-  catalog::find(config, id)          # load every Command, history and Session
   reader.read(offset, Lines, budget)
+    catalog::still_listed(root, path)  # owner/repo/commands/kind/file only
     observe captured writer
     drain bytes
  • catalog::load attaches the configured root to each reader it creates (Reader::within). Command-selected readers (logs widgets#7) get no root and are unchanged.
  • catalog::still_listed sits beside the enumeration it mirrors and shares its filename predicate (listed_name). The root and the literal commands path may be aliases; the owner, repository and kind folders and the file must be real entries, not symlinks.
  • What stays the same: initial HTML, JSON polling (still a fresh find per request), listing, IDs, offsets and completion.
  • logs --file <id> --follow uses the same reader, so it now stops with an error when its file leaves the inventory. Previously it stopped only when the file was removed. The guide says so, and docs/code-navigation.md points at the new owner.

Evidence

These reader-interface tests in src/logs/reading/reader_tests.rs use real temporary files and native process identities:

removing_or_symlinking_an_enumerated_entry_ends_inventory_reads
  for each of owner, repository, kind, file: replace it with a symlink to the moved original
    inventory reader       -> error "log is not in the current inventory"
    command-selected reader -> still reads "kept\n", not done
removing_a_finished_listed_file_ends_its_inventory_reads
configured_root_and_commands_aliases_stay_readable   (root alias + retargeted commands alias)
a_selected_read_ignores_an_unrelated_malformed_subtree
  acme/other/commands is a regular file -> catalog::load fails, selected read still returns "second\n"
inventory_reads_unowned_files_by_path_bytes_and_refuses_excluded_storage
  unowned .log, unstamped .logs.jsonl, non-UTF-8 kind folder -> readable
  sessions/, raw .jsonl, .spans.jsonl, .notification.txt, ".log", commands/loose.log -> not selectable
  • Before: with the eligibility check disabled, which is equivalent to main's exact-file reader, cargo test --bin thirdshift logs::reading::tests::reader_tests fails: removing_or_symlinking_an_enumerated_entry_ends_inventory_reads FAILED and removing_a_finished_listed_file_ends_its_inventory_reads FAILED.
    After: logs::reading::tests: 19 passed.
  • Focused runs:
    • cargo test --test show_logs: 16 passed, 1 ignored. This covers exact-file raw follow through writer exit.
    • cargo test --test console: 82 passed, 1 ignored. This covers the inventory, HTML, JSON polling and SSE wiring.
  • Affected-test selection against main: npm test --prefix site passed 49/49. cargo test --no-fail-fast: 60 targets passed; the binary target had 1286 passed and 3 failed.
    • The 3 failures are worktree::synchronization_tests::*shadowing_branch_and_tag_names, which fail with git tag … fatal: no tag message? because this machine's global git config sets tag.gpgsign = true. They pass with GIT_CONFIG_GLOBAL=/dev/null and are unrelated to this change.
    • After the suite, origin/main gained only a version bump (Cargo.toml/Cargo.lock, release 0.14.9). It was merged and the reader tests were re-run.

Merge Danger

Door: two-way

The only change on disk is the code; reverting restores the per-batch inventory lookup.

Blast Radius: log-reading

Exact-file CLI follows now end with an error when a selected file's owner, repository or kind folder, or the file itself, is replaced by a symlink. The Console already ended in that case.

Unaddressed findings

Addressed, Standards:

  • The layout check moved into catalog.rs (still_listed).
  • listed was renamed: listed_name for the filename predicate, find for the test helper, and the boolean-flag closure is gone.
  • The refusal message is now one UNLISTED constant.
  • The removal scenario is its own test.

Addressed, Spec:

  • Added a command-selected reader assertion.
  • Ran the affected-test selection.

Standards

  • Divergent Change: reader.rs now covers "inventory eligibility" alongside writer lifetime and draining (src/logs/reading/reader.rs:124-126). Declined. Plan decision 1 has the reader own the check: "Inventory-created readers will own membership validation as well as captured-writer observation and byte draining". The layout rules themselves moved to catalog.rs; the reader only enforces them before observing the writer.
  • inventory_reads_unowned_files_by_path_bytes_and_refuses_excluded_storage exercises catalog selection rather than Reader. Declined. The acceptance criteria ask for "reader-interface coverage for … excluded storage/suffixes". An inventory-created reader can only come from catalog::find, so that is the interface a refused file reaches. Decision 9 says to assert "bytes, offsets, completion and refusal, not private membership state".

Spec

  • The commands == "commands" and filename-predicate conjuncts of the per-read check can't be reached by an inventory-created reader (src/logs/reading/catalog.rs:97-103). Declined. Decision 4 says to "validate the captured relative layout … sharing the existing filename predicate with listing", so the check states the full rule. Testing those conjuncts directly would mean asserting private membership state, which decision 9 rules out. The excluded names are refused at selection in the test above.
  • No redundant orchestration-only tests were replaced. No change needed. No existing HTTP or CLI test covered a file leaving the inventory mid-stream, so nothing duplicated the new reader tests.

Security

  • None introduced. The per-read check (catalog::still_listed) only narrows a path that catalog::load has already selected under the configured root. Its alias and symlink rules match enumeration: DirEntry::file_type versus symlink_metadata, with the root and commands followed. Console account re-authorization still runs before each read. The check-then-open window was already there between find and the open on main, and plan decision 6 leaves it out of scope; using it requires write access to the trusted logs folder. cargo test --bin thirdshift reader_tests: 11 passed.

Security review outcome

No unaddressed introduced findings.

Review coverage

Both reviewers read every changed file at b003b04. site/docs/index.html is generated from docs/guide.md: node generate-docs.mjs --check passed, and both reviewers also read its one-line hunk. The review fixes in 96e67c9 change src/logs/reading/catalog.rs, src/logs/reading/reader.rs, src/logs/reading/reader_tests.rs and docs/code-navigation.md. Neither reviewer re-read those revisions.

Closes #1222

Built with claude · claude-opus-5-5 · high

Inventory-created readers capture the configured root and validate the
selected file's layout, entries and filename at each read, before writer
observation and draining. The Console log stream no longer reloads the
whole inventory before each batch, and exact-file CLI reads share the check.

Closes #1222
Address review: catalog owns still_listed and the shared refusal message,
the reader only calls it, and tests show command-selected readers stay
unconstrained.
…lows it

APFS rejects file names that are not UTF-8 with EILSEQ, so the macOS gate
could not create the fixture directory. Linux runs keep the coverage.
@JacobStephens2
JacobStephens2 merged commit b73d4b3 into main Oct 24, 2026
18 checks passed
@JacobStephens2
JacobStephens2 deleted the issue-1222 branch October 24, 2026 04:21
@JacobStephens2 JacobStephens2 mentioned this pull request Oct 24, 2026
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.

Deepen captured Command log and Session trace reading

1 participant