Repository navigation
feat(sessions): the no-output watchdog as a session check, and an on-demand snapshot for the token-refresh sweep (task #211, step 2) - #668
Conversation
…demand snapshot for the token-refresh sweep (task #211, step 2) Signed-off-by: Aixle Flow <[email protected]>
| # between "the agent went quiet" and "reconnect this agent". 41% of the sessions this | ||
| # watchdog reaped in the 14 days to 2026-09-17 carried such a banner. | ||
| def message(snapshot) | ||
| auth = AuthErrorDetector.detect(snapshot.screen.join("\n")) |
There was a problem hiding this comment.
[Recommendation] The failure message is now built from the unredacted pane.
Before this change, NoOutputWatchdog#message ran AuthErrorDetector on LiveLogReader#tail's text. tail passes the pane through Sessions::SecretRedactor.for_session(session) (live_log_reader.rb, "A live read is the same bytes the stored log would carry … so it gets the same redaction"). Snapshot#screen comes from the raw capture-pane output, so the matched auth line now lands in terminal_sessions.error_message unredacted. From there it reaches the step's error and the Slack failure notice (Chat::RunFailure). AuthErrorDetector.extract_message also falls back to the whole screen, truncated to 500 characters, when no single line matches.
The chance of a secret config value on that line is low. Still, the task says behaviour is unchanged, and this is a redaction the old path gave and the new one silently drops.
Suggestion: redact the message before it is stored, for example Sessions::SecretRedactor.for_session(session).call(auth.message). Doing it in Base#fail_session would also cover the quota, blocking-prompt and turn-end messages, which were never redacted. Then add a test with a secret config item whose value appears on the banner line.
Source: existing implementation pattern (Sessions::LiveLogReader), task acceptance ("Behaviour is unchanged").
There was a problem hiding this comment.
Addressed in 75aa47a5. Checks::NoOutput#message redacts the whole screen with Sessions::SecretRedactor.for_session(session).call before AuthErrorDetector, as LiveLogReader#tail did, so a secret wrapped across lines is masked as before. Checks::Base#fail_session also redacts the final message, which covers the quota, blocking-prompt and turn-end messages. Test in checks/no_output_test.rb: a secret config item whose value is on the banner line does not reach error_message.
|
|
||
| ::Sessions::NoOutputWatchdog.new(session).silent_for?(IDLE_BEFORE_REFRESH) | ||
| check = ::Sessions::Checks::NoOutput | ||
| snapshot = ::Sessions::Monitor.snapshot(session, parts: check.parts) |
There was a problem hiding this comment.
[Must] (second review) Task decision 12 and docs/architecture/workflows.md say every holder is read on demand immediately before rotation, but the holder set is not synchronized with rotation here. run first classifies credentials through separate without_live_session/with_live_session queries, and refresh_held materializes holders before sequential probes. A session that becomes a holder after either classification or materialization is therefore either refreshed without any probe or omitted from both the safety decision and inline delivery. In a launch race, that new container can receive the revoked grant; refresh_if_expiring! can return :held before taking the refresh lease and reloading when another holder exists.
Please coordinate holder membership with the credential refresh lease: acquire the lease before the final holder query/probes, re-query and validate the complete holder set immediately before renewal, and make launches wait/reload when that lease is held before deciding :held. Deliver from the protected final holder set. Add an interleaving test that creates/starts another holder between the idle probe and renew! and verifies it cannot receive or retain the old grant.
…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]>
…ture/session-checks-no-output
…ture/session-checks-no-output
|
Reopened in Alex's name for the squash merge (task #211). |
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]>
Summary
Step 2 of task #211 (decision 11.2), stacked on #667: base
feature/session-checks. GitHub retargets it todeveloponce #667 merges. It moves the no-output watchdog and the token-refresh sweep onto the session monitor that #667 adds.Sessions::Checks::NoOutputreplacesSessions::NoOutputWatchdog,Activities::Workflow::ScanNoOutputSessionsActivity,no_output_scan_workflowand its 5-minute schedule. It is the last check inSessions::Monitor::CHECKSand reads the same snapshot as the quota scan's checks, with no exec of its own.SCREEN_RULE_RUNTIMES = %w[kiro_cli]; other runtimes use the log's mtime) and the same messages (expired login, turn end withoutfinish_session, no output).readystep is read from its start.Base#fail_session: a compare-and-set under the row lock.screen_digestandscreen_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 throughSessions::Monitor.snapshot, which uses the same read path and parts registry as the pass. It then runsChecks::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
auth_paused_at,auth_pause_reason,auth_renewed_at,auth_heal_attempts,auth_heal_attempted_atturn_end_screen,turn_end_seen_atturn_end_nudgesscreen_digest,screen_changed_atBehaviour changes, each explained
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.TurnEndtyped 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.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.Related issues
Board task #211. Depends on #667.
Type of change
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 mockedLiveLogReader. It adds tests for the kept record, the auth-pause and interactive skips, and the re-check of a session that startedfinishingduring the read.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:skipped_busy: 1, no refresh request, the old token is kept, and the read went through the snapshot and fed the record.Run on Coder (
aixle-prod-2c822a0f, checkout99d40423): rubocop on the 42 changed Ruby files againstdeveloppassed, and 659 targeted Rails tests passed with 0 failures. The targeted suites included sessions, the workflow activities, agent credentials, the token-refresh workflow, hosted-runtime-unchanged, runner session launch, the runner contract, docs and config.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
git commit -s).