Skip to content

Bot token lifetime test uses a fixed clock - #788

Merged
zlareb1 merged 1 commit into
mainfrom
fix/library-token-test-clock
Nov 17, 2026
Merged

zlareb1 merged 1 commit into
mainfrom
fix/library-token-test-clock

Conversation

@zlareb1

@zlareb1 zlareb1 commented Nov 17, 2026 •

Copy link
Copy Markdown
Member

Changelog category (leave one):

  • CI Fix or Improvement (changelog entry is not required)

Changelog entry

The bot token lifetime test holds its clock still while asserting an exact response lifetime.

Why

The token endpoint records the start time before reading the bot, then reports the time left when building the response. Crossing a whole second during the lookup returns 3,599 seconds while the token claims still span 3,600 seconds. The happy-path test expects exactly 3,600 response seconds without controlling that clock.

Scope and risk

One unit test uses the existing ManualClock seam. Its response, scope and token-claim assertions stay unchanged. The adjacent slow-lookup test still advances time and checks the remaining lifetime. Authentication runtime and token lifetimes are unchanged.

Compatibility, rollout and rollback

Wire changes and operator steps: none. Reverting restores the wall-clock-dependent test and changes no stored data.

Tests

  • A one-case control advances the fake bot lookup by one second. The unchanged test fails with a 3,599-second response and a 3,600-second claim lifetime, matching the CI assertion failure.
  • With the fixed clock, the happy-path case and the unchanged slow-lookup case pass under that control: two tests, no skips.
  • The same two cases pass in a plain run without the control plugin. Ruff check, Ruff format check and git diff --check pass.
  • Reproduce the selected plain checks with .venv/bin/python -m pytest tests/unit/test_machines.py -q -n 0 -k 'a_bots_key_gets_an_hour_long_scoped_token or a_slow_bot_lookup_does_not_lengthen_its_token'.
  • The affected full CI unit shard passes: 5,922 tests, with one existing skip and one existing xfail.
  • The unchanged Go parser cost case failed once at 0.056 versus 0.459 CPU seconds. One retry of that same shard at the unchanged head passes all 6,709 tests. The specific variation remains unproven; no parser code, cost limit or assertion changes.
  • All 41 required CI checks pass, including all six unit shards, combined coverage at 91%, module floors, 251 offline benchmark tests, both PostgreSQL authority versions and integration checks. No full local suite was run.

AI assistance in the code

  • AI-generated: Codex. Checked both clock reads, unchanged assertions and the controlled boundary result.

  • I can explain every line of this diff and how it interacts with the rest of Loom.

Checklist

  • Required format, lint, type, unit and integration CI checks pass.
  • Generated files: none change.
  • Migrations: none.
  • Plugin behavior: unchanged.
  • Frontend: unchanged.
  • Operator steps and wire changes: none.
  • Repository text follows the public-copy rules.
  • Commits are signed off.

The response reports the time left after the bot lookup. Hold the happy-path clock still so crossing a second cannot change its exact lifetime assertion.

Signed-off-by: zlareb1 <[email protected]>
@zlareb1
zlareb1 merged commit 5f7b3b0 into main Nov 17, 2026
76 of 77 checks passed
@zlareb1
zlareb1 deleted the fix/library-token-test-clock branch November 17, 2026 22:15
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