Repository navigation
feat(sessions): one snapshot per session per pass, and Sessions::Checks for the quota scan's checks (task #211, step 1) - #671
Merged
Conversation
added 5 commits
November 8, 2026 17:08
…ks for the quota scan's checks (task #211, step 1) Signed-off-by: Aixle Flow <[email protected]>
…nd their kept state (task #211) Signed-off-by: Aixle Flow <[email protected]>
…nd the session's locks, heal counters under the lock, a real-shell snapshot test (task #211, CR round 1) - Sessions::AuthPause#pause! and #unpause! lock the workflow run, then the session, and change the marker and the run's state in one transaction. A delivery can no longer land between the marker and the run's pause, and two sessions of one run unpaused at once resume it. - #resume! returns the unpause's result and logs only what happened. The resume prompt is still typed before the compare-and-set. - #heal! counts its attempt under the session's row lock, re-reading the counter and, from the pass, heal_due? there. - A test runs Snapshot::Command#argv through /bin/sh with stub tmux and stat. Signed-off-by: Aixle Flow <[email protected]>
… and turn-end confirmation, a threaded unpause test (task #211, CR round 2) - Sessions::AuthPause#pause! redacts the banner before storing auth_pause_reason. - #expire! and #unpause_quietly take the auth_paused_at the pass observed and act only if the locked row still holds it; #expire! computes the expiry from the locked row. - Checks::TurnEnd#give_up requires turn_end_screen and turn_end_seen_at to match the confirmation it acts on, under the lock. - The two-sessions-of-one-run unpause test moves to auth_pause_concurrency_test.rb, on two threads with their own connections. Signed-off-by: Aixle Flow <[email protected]>
…he concurrency test's sessions have a prompt (task #211, CR round 2) Signed-off-by: Aixle Flow <[email protected]>
4 tasks done
|
Thanks for your pull request! Before we can merge it, we need you to sign our Contributor License Agreement. It is a one-time step and covers all your future contributions. To sign, reply to this pull request with exactly: I have read the CLA Document and I hereby sign the CLA Aixle Flow seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. |
aixle-com Bot
pushed a commit
that referenced
this pull request
Nov 9, 2026
Step 1 (#671) was squash-merged into develop as ed446d4. Conflicts are resolved to step 2's version: develop already holds step 1 exactly, and Signed-off-by: Alex <[email protected]> #670 touched none of the conflicted files.
Merged
aixle-com Bot
pushed a commit
that referenced
this pull request
Nov 10, 2026
Conflicts resolved: - Files touched on staging only by the pre-squash branches of task #209 (PR #669) and task #211 (PRs #667/#668) take develop's version, which carries the reviewed, merged form of the same work (#670, #671, #672). - test/integration/web/company/billing_test.rb: keeps the billing redesign's (#646) test body with develop's 14-day trial values (#678). - CHANGELOG.md: develop's 1.11.0 entry for the 14-day trial; the billing redesign entry already present above is kept once. Signed-off-by: Alex <[email protected]>
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
Step 1 of task #211 (decision 11.1): the mechanism, the interface, and the four checks that ran on the quota scan's read. Step 2 (the no-output watchdog and the token-refresh sweep) is a separate PR stacked on this one.
The mechanism:
Sessions::Monitor.session_monitor_workflow(replacesquota_error_scan_workflow, every minute, now withoverlap: skip) runsActivities::Workflow::MonitorSessionsActivity. For each live workflow step (running/ready, with a container) a pass:applies_to?; a session no check applies to is not read;Sessions::Snapshot.read→Snapshot::ExecSource, throughContainerRuntime.for_session, capped atscan_op_timeout);UPDATE(Checks::KeptState).Every pass logs
[Sessions::Monitor] pass read=<n> duration_ms=<ms> …and returnsreadandduration_mswith its counts.Monitor.snapshotgives the same read on demand (step 2 uses it).The parts registry:
Sessions::Snapshot::Parts::REGISTRY.scrollback(capture-pane -S -1000),log_mtime(statof/tmp/terminal_output.log) andclients(tmux list-clientswith the container clock).Snapshot::Commandbuilds one script from the requested parts. Each part sits between a header and a footer that carries its exit status and a random marker for each read, so one failing part leaves the others readable and pane text cannot forge a delimiter. The shared helpers areSnapshot#screen(the last 40 nonblank lines throughScreenDigest),#screen_digest,#last_output_at(counted only from a read that also captured the pane),#quiet_for?andClients#input_within?. The source can be swapped per runtime (Snapshot.source_for, for task 8c).The interface:
Sessions::Checks::Base. Each check implements.applies_to?,.parts,.kept_keysand#call(snapshot), and#callreturns aChecks::Result(an outcome, plus whether processing stops). The checks run in today's order:Checks::QuotaErrorChecks::BlockingPromptChecks::AuthPause(its actions stay inSessions::AuthPause)Checks::TurnEnd(replacesSessions::TurnEndNudge)The
*Detectorclasses stay as the text parsers.Re-check before acting, and conditional state changes.
Base#fail_session→ newSessionService.fail_session_if(session:, expected_state:, error_message:) { |locked| … }. Under the row lock (for an admitted session, through the newSessionAdmissionService.fail_if!under the writer lock), it checks that the session is still in the state the pass read, that the check still applies, and that the check's own condition still holds. The state change happens in the same transaction, the method reports whether it applied, and only the Temporal signal goes after the commit. This closes the gap #666 accepted ingive_up.Sessions::AuthPause#pause!,#unpause_quietlyand#expire!are compare-and-sets too. A change that did not apply returns:taken_overand stops processing.Removed reads:
capture-paneexec;statexec on a quota hit;AuthPause'sstatexec (LiveLogReader#tail(lines: 1));TurnEndNudge'stmux list-clientsexec;AuthPause#banner_in.Kept state (each check owns its keys, written once per session per pass)
auth_paused_at,auth_pause_reason,auth_renewed_at,auth_heal_attempts,auth_heal_attempted_at(delivery'sresume!andlogin_refused!also write them)turn_end_screen,turn_end_seen_atturn_end_nudges(counted before typing)Inventory
Checked against the code. The quota scan (4 checks), the no-output watchdog and
RefreshExpiringTokensActivity#parked?are the only pieces that read a live terminal to decide something. Outside the mechanism:ScanDeadContainersActivity(runtime API, no exec);CleanupStaleActivity(DB timestamps);Sessions::LogTail/LiveLogReader(the UI tail,get_session_log,session_log): reads for people;AgentBaseStrategy's launch-time wait for the shell prompt: part of starting the CLI.Behaviour
Thresholds, messages, skips and order are unchanged. Differences:
overlap: skip(decision 8).|| truecapture while thestatexec failed). No check acted on that case before.Related issues
Board task #211. Follows #666 (#208).
Type of change
How was this tested?
The existing tests were ported, with the same assertions:
scan_quota_errors_activity_test→test/temporal/activities/workflow/monitor_sessions_activity_test.rbturn_end_nudge_test→test/services/sessions/checks/turn_end_test.rb(the stale-copy cases now return:taken_overinstead ofnil)auth_pause_testNew tests:
test/services/sessions/snapshot_test.rb: one exec, only the requested parts, per-part failure, mtime only with a captured pane, marker-looking pane text, unreachable container.test/services/sessions/checks/interface_test.rb: every check is aBase, the order, no shared kept keys, one-UPDATE kept-state write, key ownership.test/services/session_service_fail_session_if_test.rb: a session finished after the read stays finished; a guard that no longer holds; the admitted path.finishingduring the read is not failed (quota and blocking prompt), the auth pause does not pause afinishingsession or fail an unpaused one, and every pass logs its duration and read count.Run on Coder (
aixle-prod-2c822a0f, checkoute7ba0d17): rubocop on the 36 changed Ruby files passed, and 654 targeted Rails tests passed with 0 failures. The suites covered sessions, the workflow activities, session/admission services, credential delivery and sync, the Temporal registry and service, hosted-runtime-unchanged, runner session launch, the runner contract, the detectors, complete-step, agent credentials, docs, config and resources.Checklist
git commit -s).docs/architecture/workflows.md→ "Session monitoring";docs/design/agent-credential-lifecycle.md).