Repository navigation
Share Console stream lifecycle behind one subscription - #1239
Merged
Merged
Conversation
Inbox notices and live log streams now ask one Console subscription when they may do their next work turn. It owns the non-refreshing viewer rechecks on account revisions, sleeping until Commands change or draining buffered log output, channel closure, permanent termination and the shared live-work observer lease. Callers keep their own payloads and error presentation. Tests cover the subscription's scheduling deterministically, extend the log route's revocation test to password reset and allowlist removal, add a regression for logs buffered beyond two batch budgets, and run the child-clock expiry check against both routes.
…re revocations Name the subscription's last authorized accounts and granted Commands revisions, cover closure during a successful check for both modes, share the revocation switch between the two stream tests, rename the buffered log regression after what it buffers and fail clearly when the expiry script cannot find its live log.
Merged
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
Inbox notices and live log streams now ask one Console subscription when they may do their next work turn. The subscription owns the viewer recheck, revisions, sleeping, channel closure, permanent termination and the shared observer lease. Each caller still builds its own payload and presents its own errors.
Log batches drain without waiting for another notification, and a log stream sleeps only after an empty unfinished read. A change that arrives during a read stays unseen, so the next wait returns at once.
Evidence
console::subscription::tests(10 tests): first readiness, account-only change, wait versus drain, coalescing, a revision arriving during authorization, a change during a read, closure (including closure during a check), denial and errors, permanent termination, and lease release on termination or drop. All pass.continuefailsa_revision_arriving_during_authorization_is_checked_before_work.has_changed()closure check failsclosure_permits_no_further_work_and_releases_the_lease.a_log_buffered_across_several_batches_streams_every_byte_without_another_change: the log is more than 3 × 256 KiB, the writer has finished, and nothing is appended. The stream delivers every line in order, with increasing offsets and exactly one finaldone:true.Wait, so the stream waits after every batch):reqwest::Error { kind: Decode, source: TimedOut }.an_open_log_stream_closes_when_its_session_is_revokednow covers CLI sign-out, password reset and allowlist removal, matching the Inbox test. Both pass.python3 tests/console/session-expiry.py --binary target/debug/thirdshift --settle-seconds 65now opens both routes. Output:{"expired_session_received_changes": {"inbox": false, "log": false}, "stream_closed": {"inbox": true, "log": true}, "reader_errors": []}.idle_viewers_sleep_and_log_appends_and_completion_wake_the_reader,outcome_does_not_finish_sse_or_polling_before_the_writer_exits,process_death_finishes_the_existing_reader_without_a_record_write,log_stream_starts_at_the_byte_offset_and_sends_only_appended_html.cargo test --no-fail-fast; nextest is not installed): 2,494 passed, 3 failed. Every integration target passes.worktree::synchronization_tests, withgit tag … failed: fatal: no tag message?. The cause is this host's globaltag.gpgsign = true.GIT_CONFIG_GLOBALpointing at a config that holds only a user identity,cargo test --bin thirdshift worktree::synchronization_testspasses 36 of 36.scripts/affected-tests origin/mainselects the full Rust suite. Itscargo testrun stopped at those same three unit failures, which is why the full suite was rerun with--no-fail-fast.cargo clippy --all-targetsreports no warnings, andcargo fmt --checkis clean.Merge Danger
Door: two-way
This internal refactor changes no data, config or domain behaviour, and a revert restores the old loops.
Blast Radius: Console streams
If the subscription were wrong, open Inbox pages or log readers could miss updates, stall on buffered output, or stay open after revocation. The tests above pin each of those cases. After an empty unfinished read, a log stream now wakes only on Commands or accounts revisions, no longer on executable-only revisions. Log appends and writer exits already bump Commands.
Review
Both axes were reviewed against
origin/main(4519277). The localmainref was stale. Every changed file was read by both reviewers; no changed file was left unread.Drainmode, was addressed in 239be80.Unaddressed findings
Standards
ready(...) -> Result<bool>could be a two-variant enum. Declined because the plan settles it. Decision 4 says readiness "returns an ordinary result containing a readiness boolean. True permits one work turn; false means normal terminal closure." (src/console/subscription.rs,pub async fn ready(&mut self, mode: Readiness) -> Result<bool>).state.doneinlogs.rs. Declined because both are required.denial_and_check_failures_end_the_subscription_permanentlycovers this.state.donemarks the caller's own final batch and read errors, which Decision 2 leaves with the caller.session-expiry.pywrites the Command record by hand, not through the Rust fixtures. The opaque failure the reviewer raised is fixed: the script now asserts that the log link exists. The record copy stays. Decision 11 asks to "Extend the existing child-clock expiry fixture", which is a standalone Python script that cannot call the Rustrecord()helper.Spec
None.
Security
None.
Closes #1238
Built with claude · claude-opus-5-5 · high
Security review outcome
No unaddressed introduced findings.