Repository navigation
A bot's token lives what its request asks, up to its maximum - #137
Merged
Merged
Conversation
A bot or trust carries max_access_token_s (60 to 86400 s, default 3600; migration 073 adds the column), set by an operator (loom bot create --max-access-token-ttl) or a platform admin (/v1/admin/bots.create) and listed by bots.list. /oauth/token's client-credentials and token-exchange grants take expires_in (whole seconds, at least 60): the token lives what was asked up to that maximum, an hour when nothing is asked (or the maximum when shorter), and a workload token's exchange still never outlives the token handed over. A malformed expires_in is refused (invalid_request) before the assertion is spent or the exchange counted. The answer's expires_in says what was issued; auth.machine_token records ttl_s and auth.machine_created the maximum. Revocation is unchanged and does not wait for expiry: subject revocations, cutoffs (disable, replace, claim-release, revoke_subject with or without issued_before) and parent revocations refuse a token by its subject and issue time and never lapse; /oauth/revoke keeps one token's row until that token's own exp. Unit tests pin the lifetimes, the refusals, and that each revocation cuts a day-long agent token; an integration case registers a day-long bot over the API, reads the column back, and revokes its subject. Signed-off-by: pufit <[email protected]>
The bots and CI guide (docs/operations/sso.md) says how a request asks for a longer token, what bounds it, what ends it at once, and what does not (a namespace delete, the issuer's key rotation: replace or disable the bot); security.md says the issued lifetime and that no revocation waits for a token's expiry; rolling-upgrades.md gains rule 25 for the new column: N-1 issues an hour, refuses the field and writes 3600 back when it saves a bot, each only shortening tokens. Signed-off-by: pufit <[email protected]>
pufit
force-pushed
the
pufit/trust-token-ttl
branch
from
October 21, 2026 17:36
77429c0 to
c6b2c89
Compare
zlareb1
approved these changes
Oct 21, 2026
Signed-off-by: pufit <[email protected]>
… by open PRs Signed-off-by: pufit <[email protected]>
Signed-off-by: Lareb Zafar <[email protected]>
Signed-off-by: Lareb Zafar <[email protected]>
Signed-off-by: Lareb Zafar <[email protected]>
Replacing the shared monotonic clock can expire the model-call switch snapshot on a short-uptime runner. Replace only the hold module clock so unrelated caches keep real time. Signed-off-by: Lareb Zafar <[email protected]>
Keep token lifetime limits and platform-admin flags through saving, listing and exchange. Migration 077 follows the merged admin migration without changing its fleet admission floor. Signed-off-by: Lareb Zafar <[email protected]>
A long integration run can outlive the session token. Fresh per-test credentials keep the one-hour lifetime and preserve caller-supplied keys. Signed-off-by: Lareb Zafar <[email protected]>
Signed-off-by: Lareb Zafar <[email protected]>
An adaptive queue may flush its first request immediately after an idle period. Use a fixed window for the shared-flush assertion and drain tasks even if the cleanup flush fails. Signed-off-by: Lareb Zafar <[email protected]>
Clear graph-write buffers and timers at teardown so model transitions do not inherit pending work. Wait for a settings reset before reading the baseline on another worker, and check that cleanup succeeds. Signed-off-by: Lareb Zafar <[email protected]>
Signed-off-by: Lareb Zafar <[email protected]> # Conflicts: # tests/unit/conftest.py # tests/unit/test_integration_credentials.py
…me the lifetime they get The bot row always carries max_access_token_s on this schema, so the fallback is gone. The SDK docstrings no longer promise an hour-long token, the day-token integration test signs its own client assertion instead of calling MachineLogin internals, and the edited security paragraphs are rewrapped. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Lareb Zafar <[email protected]>
…cs name the token lifetime The guide, the Python SDK reference and the TypeScript README no longer promise an hour-long bot token; bot_from's docstring keeps the platform-admin warning and says the maximum caps the default too; the rolling-upgrade rule says the mixed-version gate does not check it. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Lareb Zafar <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Lareb Zafar <[email protected]>
…names the access-token maximum asked_lifetime refuses a non-digit value outright instead of reading it as 0; loom bot list prints 'max access token', apart from the workload token age, and the create help no longer ties the limit to an exchange. An empty expires_in is tested to ask nothing; two doc-comment paragraphs are rewrapped. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Lareb Zafar <[email protected]>
…eapply it The module docstring, the SSO guide and the security page say a token lasts an hour or the bot's shorter maximum; the rollout notes name loom bot create --replace for reapplying a maximum an older server reset, and that it ends the bot's tokens. token_lifetime says why it still caps at a day. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Lareb Zafar <[email protected]>
…tion 77 An older replica issues an hour whatever the maximum and writes 3600 back when it saves the bot, silently widening a tightened cap. create_bot now refuses a nondefault maximum until a fresh fleet view shows every replica at 77, through the same fleet check the platform-admin flag uses at 76. Tests cover the refusal and the ttl_s and max_access_token_s audit fields; the upgrade guide's rollback section carries rule 26, and the CLI default reads TOKEN_TTL. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Lareb Zafar <[email protected]>
…long token back in A subject revocation with --expires-at lapses then, and a bot token allowed a day outlives an hour-long expiry. create_bot is also tested to refuse a nondefault maximum when the fleet view cannot be read. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Lareb Zafar <[email protected]>
…empty view token_lifetime drops the day cap no writer can exceed (bot_from bounds the maximum). The create refusal says an empty loom.instances view refuses as an older replica does; the SSO guide opens with the default lifetime the maximum can shorten, and its edited paragraphs are rewrapped. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Lareb Zafar <[email protected]>
…migration file The check runs on empty, older, mixed and current fleets, and its floor must match 077_machine_access_token_ttl.sql, as the platform-admin floor matches 076. The refusal names the lifetime in the words loom bot create's operator used. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Lareb Zafar <[email protected]>
…stants it checks ACCESS_TOKEN_MIGRATION is public, the message is built from it and TOKEN_TTL, and the tests match on the constant, so a renumbered migration changes the gate and its message together. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Lareb Zafar <[email protected]>
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.
Related: #110
Changelog category (leave one):
Changelog entry (one or two sentences a user of Loom can read without the diff; the release pull request collects these into the release notes):
Bots and workload trusts can set a maximum token lifetime from 60 seconds to one day. Clients request a lifetime with
expires_in; requests without it retain the one-hour default, capped by the identity's maximum.Why
Machine identities issue one-hour tokens regardless of how long a client needs them. A per-identity maximum lets an operator choose the renewal interval, while each request can ask for a shorter lifetime.
Scope and risk
MachineLoginnever sendexpires_in, so SDK clients keep the one-hour default (or the bot's shorter maximum) and renew from theexpires_inthe server answers. A client that wants a longer token asks for it in its own token request.Compatibility, rollout and rollback
/oauth/tokenaccepts optional ASCII-digitexpires_inof at least 60 seconds. An empty value means no request; repeated fields use the last value. The request is capped bymax_access_token_s, and malformed values returninvalid_request. The response shape is unchanged./v1/admin/bots.createacceptsmax_access_token_sfrom 60 to 86400, default 3600./v1/admin/bots.listreturns it.loom bot create --max-access-token-ttlsets it;loom bot listshows nondefault limits.auth.machine_tokenrecordsttl_s;auth.machine_createdrecordsmax_access_token_s.max_access_token_s UInt32 DEFAULT 3600after the merged platform-admin migration 076. Migration 076 and the admin fleet admission floor remain unchanged. No backfill is required.expires_in, issue one-hour tokens, reject the creation field, and reset the maximum to 3600 when saving a bot, which can lengthen a sub-hour token as well as shorten a longer one. So registration answers 503OVERLOADED(retry once the rollout ends) to a maximum other than 3600 until a fresh fleet view shows every replica in every deployment at migration 77, through the same fleet check that platform-admin tokens use at 76; an unread view refuses too. A request'sexpires_inneeds no gate, since an older build answers it with an hour. After a rollback, reapply each maximum withloom bot create --replaceonce the newer build serves; the upgrade guide's rollback section says so.Tests
tests/unit/test_machines.py: the hour unasked, a request capped by the bot's maximum, a maximum under an hour shortening the default, very long and zero-padded digit strings, and refusal of a lifetime under 60 s, negative, fractional, in exponent form, in words, with a leading space or in non-ASCII digits, before the assertion is spent or the exchange counted. A CI exchange never outlives its workload token, every revocation cuts a day-long agent token,/oauth/revokekeeps its row until that token expires, and each issued token's audit row carries itsttl_s.tests/unit/test_account_admin.py,test_admin_account_routes.pyandtest_bot_cli.py: the 60 s to one-day bound inbot_from, over/v1/admin/bots.create(422 outside it) and inloom bot create; the saved, listed and audited maximum; the refusal of a nondefault maximum while an older replica serves, with the fleet check run on empty, older, mixed and current fleets and its floor matched to the migration file; andloom bot listprinting a nondefault maximum after the proofs.tests/unit/test_schema_baseline.pyand the journal check cover migration 077 andschemas/schema.sql.tests/integration/test_bots.py: a bot allowed a day gets an hour unasked, its maximum when it asks for more, and exactly a day when it asks for one; a subject revocation ends that day-long token at once.make format-check lint typecheckand the auth, admin and CLI unit suites (52 and 166 passed). The full unit, integration and mixed-version suites run in CI; the mixed-version gate does not exercise rule 26.AI assistance in the code (leave one; writing this description with AI is fine):
AI-generated (Claude Code and Codex): coding agents wrote the implementation and review fixes. Independent source review covered OAuth validation, proof consumption, revocation, persistence and rollout behavior.
I can explain every line of this diff and how it interacts with the rest of Loom.
Checklist
make format-check,make lint,make typecheckandmake test-unitpass; the integration suite passes (format, lint and typecheck pass locally; the unit and integration suites are ticked once CI is green).