Skip to content

feat(sessions): the no-output watchdog as a session check, and an on-demand snapshot for the token-refresh sweep (task #211, step 2) - #672

Merged
aixle-com[bot] merged 12 commits into
developfrom
feature/session-checks-no-output
Nov 9, 2026
Merged

aixle-com[bot] merged 12 commits into
developfrom
feature/session-checks-no-output

Conversation

@NOX73

@NOX73 NOX73 commented Nov 9, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Step 2 of task #211 (decision 11.2). Step 1 is merged as #671 (ed446d4d on develop), and this pull request now targets develop. It moves the no-output watchdog and the token-refresh sweep onto the session monitor that #671 added.

Sessions::Checks::NoOutput replaces Sessions::NoOutputWatchdog, Activities::Workflow::ScanNoOutputSessionsActivity, no_output_scan_workflow and its 5-minute schedule. It is the last check in Sessions::Monitor::CHECKS and reads the same snapshot as the quota scan's checks, with no exec of its own.

  • It has the same threshold (30 minutes), the same screen rule (SCREEN_RULE_RUNTIMES = %w[kiro_cli]; other runtimes use the log's mtime) and the same messages (expired login, turn end without finish_session, no output).
  • It skips the same sessions: interactive steps and auth-paused steps, while every other ready step is read from its start.
  • Its failure goes through Base#fail_session: a compare-and-set under the row lock.
  • Kept state: screen_digest and screen_changed_at, owned by the check and written in the pass's single update.

The token-refresh sweep uses an on-demand snapshot (decision 12). Right before it rotates a grant, RefreshExpiringTokensActivity#parked? reads each holder through Sessions::Monitor.snapshot, which uses the same read path and parts registry as the pass. It then runs Checks::NoOutput#silent_for?(snapshot, IDLE_BEFORE_REFRESH) on that snapshot. The read feeds the same kept record as the passes. A holder that cannot be read still counts as busy.

Kept state, now complete

Check Kept between passes Written by its action, under the row lock
QuotaError — —
BlockingPrompt — —
AuthPause — auth_paused_at, auth_pause_reason, auth_renewed_at, auth_heal_attempts, auth_heal_attempted_at
TurnEnd turn_end_screen, turn_end_seen_at turn_end_nudges
NoOutput screen_digest, screen_changed_at —

Behaviour changes, each explained

  • Cadence. The check runs on the monitor's 1-minute pass instead of every 5 minutes, so a silent session ends 30 to 31 minutes after its screen stopped changing, instead of 30 to 35. The threshold is unchanged. This follows from decision 1 (one mechanism every N minutes).
  • The screen digest is taken from the last 40 nonblank lines of the 1000-line scrollback instead of from a capture-pane -S -40. The two are the same lines unless the shorter capture held fewer than 40 nonblank lines. At the switch-over, such a session's digest changes once and its record restarts from the log's mtime, which only delays a verdict.
  • The expired-login message is detected on the current screen, the last 40 nonblank lines. The old capture was 40 lines plus the pane height.
  • On a pass where TurnEnd typed a reminder (:nudged, which stops the pass for that session), the no-output check does not run for that session. A session that was just typed into is not judged silent on the snapshot taken before the typing. Before, the two separate scans could both act within the same minute.
  • The token-refresh probe is capped at Settings.runners.scan_op_timeout (15 s) for a runner holder, as the pass is. Before, it used the 60 s default op timeout. A holder that does not answer still reads as busy.

Merge of develop after #671

#671 was squash-merged, so git saw step 1's files as added on both sides. develop was merged into this branch (a4150009), and every conflict was resolved to step 2's version: develop holds step 1 exactly plus #670, and #670 touched none of the conflicted files. git diff origin/develop HEAD equals step 2's own diff 15f98e2b..42c9c376 (23 files, +514/−531), apart from hunk positions in docs/design/agent-runtimes/DESIGN.md.

Related issues

Board task #211. Step 1 is #671 (merged).

Type of change

  • Refactor / chore

How was this tested?

Ported tests, with the same assertions:

  • no_output_watchdog_test → test/services/sessions/checks/no_output_test.rb, run through the monitor and the fake runtime instead of a mocked LiveLogReader. It adds tests for the kept record, the auth-pause and interactive skips, and the re-check of a session that started finishing during the read.
  • The scan's 5-minute cadence test → test/temporal/activities/workflow/monitor_sessions_no_output_test.rb, at the 1-minute cadence. It asserts that the session ends within threshold + 1 minute, and that one exec per pass serves every check.

New tests in refresh_expiring_tokens_activity_test.rb:

  • A holder that started a turn after the last pass blocks the rotation. The last pass recorded the Kiro holder as parked for 20 minutes, but the on-demand read sees its working screen. Result: skipped_busy: 1, no refresh request, the old token is kept, and the read went through the snapshot and fed the record.
  • A holder still parked on the same screen lets the rotation go ahead.

Targeted runs on Coder after each round are recorded on board task #211.

Docs: docs/architecture/workflows.md (the no-output check row, the on-demand snapshot, the silence watchdog), docs/design/agent-credential-lifecycle.md, docs/design/agent-runtimes/DESIGN.md (8c now feeds the snapshot source).

Checklist

  • All my commits are signed off for the DCO (git commit -s).
  • I added/updated tests where it makes sense.
  • I updated documentation where it makes sense.

Aixle Flow added 10 commits November 8, 2026 17:08
…ks for the quota scan's checks (task #211, step 1)

Signed-off-by: Aixle Flow <[email protected]>
…demand snapshot for the token-refresh sweep (task #211, step 2)

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]>
…es (task #211, CR round 1)

Checks::NoOutput#message redacts the whole screen with
Sessions::SecretRedactor.for_session before AuthErrorDetector reads it,
as LiveLogReader#tail did. Checks::Base#fail_session redacts the final
message too, which also covers the quota, blocking-prompt and turn-end
messages.

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]>
@github-actions

github-actions Bot commented Nov 9, 2026 •

Copy link
Copy Markdown

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


1 out of 2 committers have signed the CLA.
✅ (NOX73)[https://github.com/NOX73]
❌ @Aixle Flow
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.
You can retrigger this bot by commenting recheck in this Pull Request. Posted by the CLA Assistant Lite bot.

Base automatically changed from feature/session-checks to develop November 9, 2026 11:22
NOX73 added 2 commits November 9, 2026 11:25
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.
TemporalService.connection in tests boots WorkflowEnvironment.start_local, the CLI dev server, which the SDK downloaded lazily from temporal.download on every run. A failed download errored whichever test first reached Temporal (4 errors in auth_pause_test.rb on CI run 42609000420). Seed it into TEMPORAL_TEST_SERVER_DIR next to the time-skipping server and point start_local at it.

Signed-off-by: Alex <[email protected]>
@aixle-com
aixle-com Bot merged commit 352f9e5 into develop Nov 9, 2026
16 of 17 checks passed
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]>
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.

1 participant