Repository navigation
Conversation
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.
Why
internal/runtimestill split maintenance behavior across one-off tickers: check-in scheduling, WorkBuddy's daily pass, worker liveness, resource sampling, exhausted-quota probing, plus a hardcoded 10-minute "renew the credential" pass that only ran for a subset of providers. Credential renewal, liveness and credit refresh were provider-local (client.Refresh,client.Probe), so every provider had to re-implement its own cadence, backoff and failure accounting.This PR moves all of it into one task registry and gives renewal / liveness / credits first-class, provider-driven implementations.
What changed
runtime/manager_tasks.go): check-in, WorkBuddy daily, resource sampling, worker liveness, exhausted-quota probing, credential renewal, liveness, periodic credits. Cadence and semantics unchanged; the registry just owns start/stop, tick cancellation, and shutdown draining.runtime/maintenance_credential.go): five-minute sweep, renews five minutes beforeexpires_at(configurable look-ahead), per-account backoff1m / 5m / 30m / 2h, and only a definitive auth refusal (three consecutive) markslogin_required. Generic network errors are failures, not logouts.ProviderMaintenanceinproviders/interfaces.go): providers that actually can read usage/catalog (kiro,codex,zhipu,command,opencode) implementLiveness; everyone else falls back to the existing probe. Default six hours, configurable,0disables.036_request_outcome_facts.sql,037_account_maintenance_state.sql,038_checkin_record_source.sql— attempt outcome facts, per-account maintenance state, and check-in source.Tests
go build ./...go test ./internal/store/ ./internal/accounts/ ./internal/control/ ./internal/providers/... ./internal/runtime/— all passcd frontend && npm run syncNew tests:
runtime/maintenance_credential_test.go(renewal look-ahead, backoff,login_requiredonly after repeated auth refusal),store/maintenance_test.go, provider maintenance tests for each implementing package.Notes