Skip to content

🤖 tests: close the four clock lint gaps of the agent-loop ratchet - #7490

Merged
ThomasK33 merged 6 commits into
mainfrom
followups/clock-lint-gaps
Oct 25, 2026
Merged

ThomasK33 merged 6 commits into
mainfrom
followups/clock-lint-gaps

Conversation

@ThomasK33

@ThomasK33 ThomasK33 commented Oct 25, 2026 •

Copy link
Copy Markdown
Member

Summary

The three clock lint rules of the agent-loop refactor now catch the four forms that review of #7272 found missing. Each gap has its own rule test, which fails on the rules of main and passes here. No file in the rules' lists uses a new form except one, and it gets an allow entry with a reason. Lint only: app behavior does not change.

Items of #7282 in this PR

Item Result
local/no-raw-clock misses timers imported under another name; local/no-host-imports does not list timers or timers/promises Done. The rule reads the imports of timers and timers/promises (named, namespace and default), and both configs list both modules as host modules.
local/no-global-clock-patch misses Date.now = () => t Done. Direct assignment to Date.now or globalThis.Date.now counts as a patch.
local/no-raw-clock misses a direct Date() call Done.
local/no-raw-clock does not count AbortSignal.timeout() Done. Its one hit, tools/skillsCatalogFetch.ts, gets an allow entry of 1 (see below).

Implementation

  • All three rules live in eslint-local-rules.mjs, which oxlint also loads, so the rule changes reach both linters. The module lists and allow maps are repeated in eslint.config.mjs and .oxlintrc.json. make check-oxlint-config passes.
  • The timer import scan runs on Program, so a call above a hoisted import still counts. An unaliased import { setTimeout } from "timers/promises" counts once.
  • Review rounds 1 to 4 made the rules resolve names by binding: a timer alias, Date, AbortSignal or require counts only when it resolves to the host global, and a local value that shadows Date, global or globalThis does not count. A type-only declaration such as interface Date does not shadow the value. The rules also count require("timers") and await import("timers") loads, { default as timers } imports, static computed members such as timers["setTimeout"], and treat global like globalThis. Two shared helpers (memberName, isHostGlobal) hold this logic for all three rules.
  • Limits: the rules catch direct spellings and skip shadowed names. They do not follow aliases through variables, destructuring, Reflect, eval or other dynamic access, so const d = Date; d.now() passes. A comment at local/no-raw-clock records this.
  • skillsCatalogFetch.ts allow entry: the search request bounds a network call with AbortSignal.timeout(). The file calls the module-level node host services, not injected ones, so it has no HostClock to arm the deadline on. Its RAW_CLOCK_CEILING entry records that the read was there when the ratchet landed.

Validation

  • With the rules and config of origin/main, the 5 new tests fail ("reports a Date() call", "reports AbortSignal.timeout()", "reports timers imported from the timers modules under another name", "reports a direct Date.now assignment ...", "the configured module list covers the timers modules"). With this PR, all 27 tests in the two rule test files pass. Each case that review rounds 1 to 4 added has a test that failed before its fix.
  • With the allow entry removed, oxlint reports AbortSignal.timeout() in skillsCatalogFetch.ts, so oxlint runs the new check.
  • make lint-eslint linted all files (the rule file changed) with no error.

Refs #7282

Gates on 3af4ba3fef: make static-check, make lint-eslint, make test (0 failures), crap, DRY and mutation checks, loop-test tripwire RUNS=3 against origin/main: 0 trips.
Gates on 8d1c71052e (review rounds 1 to 3): make static-check, make lint-eslint (all files), make test (0 failures). 6a0dfcc45d adds only the Limits comment.
Gates on 25dd4e69cc (review round 4, rule file and its tests only): make static-check, make lint-eslint (all files), the 27 rule tests.


Generated with xum • Model: anthropic:claude-opus-5-5 • Thinking: high

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 25, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-25T18:37:30.934226Z 25dd4e6 Manual request
🔒 Security Review ✅ Completed 2026-10-25T18:37:22.187865Z 25dd4e6 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3af4ba3fef

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread eslint-local-rules.mjs Resolved
Comment thread eslint-local-rules.mjs Resolved
Comment thread eslint-local-rules.mjs Resolved
@github-actions

github-actions Bot commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

🟢 e2e stories (Haiku): 14 passed

27 agent steps · 9 replayed from cache · 24 model calls · 137.2k tokens (68% cached)
Spend: $0.09 of the $1.00 cap (proxy ledger)

All 14 tests in 9 files
Test Agent Time
🟢 chatRestart.e2e.ts · 1 passed 2 steps · 4 calls 24.3s
🟢 a chat survives a restart of the server 2 steps · 4 calls 24.3s
🟢 compaction.e2e.ts · 1 passed 3 steps · 7 calls 41.6s
🟢 /compact replaces the old chat with a summary 3 steps · 7 calls 41.6s
🟢 pluginTrustRestart.e2e.ts · 1 passed 4 steps · 2 calls 9.7s
🟢 a trusted plugin hook stays trusted after the server restarts 4 steps · 2 calls 9.7s
🟢 settingsRoundTrip.e2e.ts · 1 passed 3 steps · 1 call 12.0s
🟢 a chat survives trips through Settings 3 steps · 1 call 12.0s
🟢 sidebarPerWorkspace.e2e.ts · 1 passed 4 steps · 1 call 4.7s
🟢 a new workspace starts with its right sidebar collapsed while another keeps it open 4 steps · 1 call 4.7s
🟢 smoke.e2e.ts · 1 passed 2 steps · 1 call 5.4s
🟢 the agent opens the playground workspace 2 steps · 1 call 5.4s
🟢 streamErrors.e2e.ts · 1 passed 1 step · 1 call 8.2s
🟢 stream errors show in the chat, and the chat recovers 1 step · 1 call 8.2s
🟢 todoNudge.e2e.ts · 1 passed 2 steps · 1 call 8.8s
🟢 the agent finishes open TODO items after the turn-end nudge 2 steps · 1 call 8.8s
🟢 touchAlignment.e2e.ts · 6 passed 6 steps · 6 calls 25.6s
🟢 the Settings close button is level with the title on a touch screen 390px wide 1 step · 1 call 4.0s
🟢 the Settings close button is level with the title on a touch screen 768px wide 1 step · 1 call 4.5s
🟢 Backup settings checkboxes are small and level with their labels on a touch phone 1 step · 1 call 7.8s
🟢 the heartbeat checkbox is small and level with its label on a touch phone 1 step · 1 call 3.2s
🟢 a reply's model and time stay on one line on a touch phone 1 step · 1 call 3.1s
🟢 the workspace actions menu stays on the title row on a touch phone 1 step · 1 call 3.0s

e2e 0.20.0 · 2m 23s · web · run artifacts

🟢 e2e Electron stories (Haiku): 3 passed

3 agent steps · 3 model calls · 7.9k tokens (33% cached)
Spend: $0.01 of the $1.00 cap (proxy ledger)

All 3 tests in 3 files
Test Agent Time
🟢 electron/deepLink.e2e.ts · 1 passed 1 step · 1 call 8.5s
🟢 a deep link of a second launch starts a chat in the running app 1 step · 1 call 8.5s
🟢 electron/menuBar.e2e.ts · 1 passed 1 step · 1 call 6.1s
🟢 the workspace menu bar is the desktop title bar 1 step · 1 call 6.1s
🟢 electron/smoke.e2e.ts · 1 passed 1 step · 1 call 5.3s
🟢 Xum Electron opens the playground workspace 1 step · 1 call 5.3s

e2e 0.20.0 · 21.9s · electron · run artifacts

🟢 e2e agent repros (Haiku): no tests selected

Spend: $0.00 of the $1.00 cap (proxy ledger)

e2e 0.20.0 · 5.3s · 2 targets (web, phone) · run artifacts

@ThomasK33

Copy link
Copy Markdown
Member Author

@codex review

Round 2: head b71e010 fixes the 3 round-1 findings in eslint-local-rules.mjs. Timer aliases now resolve by binding, CommonJS timer loads are tracked, and global counts like globalThis in both rules. Each has a new rule test.

@chatgpt-codex-connector

Copy link
Copy Markdown

🛡️ Codex Security Review · Automatically triggered

Security review completed. No security issues were found in this pull request.

Reviewed commit: b71e0105ae

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b71e0105ae

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread eslint-local-rules.mjs Resolved
Comment thread eslint-local-rules.mjs Resolved
@ThomasK33

Copy link
Copy Markdown
Member Author

@codex review

Round 3: head 42567a0 fixes the 2 round-2 findings. Locals named global or globalThis no longer count as the global object, and import { default as timers } counts as a timers module binding. Each has a new rule test.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 42567a0ee1

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread eslint-local-rules.mjs Resolved
Comment thread eslint-local-rules.mjs Resolved
Comment thread eslint-local-rules.mjs Resolved
Comment thread eslint-local-rules.mjs Resolved
Comment thread eslint-local-rules.mjs Resolved
@ThomasK33

Copy link
Copy Markdown
Member Author

@codex review
Round 4: review head 6a0dfcc (round-3 fixes and the Limits comment).

@chatgpt-codex-connector

Copy link
Copy Markdown

🛡️ Codex Security Review · Automatically triggered

Security review completed. No security issues were found in this pull request.

Reviewed commit: 6a0dfcc45d

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6a0dfcc45d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread eslint-local-rules.mjs Resolved
Comment thread eslint-local-rules.mjs Resolved
@ThomasK33

Copy link
Copy Markdown
Member Author

@codex review
Round 5: review head 25dd4e6 (round-4 fixes).

@chatgpt-codex-connector

Copy link
Copy Markdown

🛡️ Codex Security Review · Automatically triggered

Security review completed. No security issues were found in this pull request.

Reviewed commit: 25dd4e69cc

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 25dd4e69cc

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread eslint-local-rules.mjs Resolved
Comment thread eslint-local-rules.mjs Resolved
Comment thread eslint.config.mjs Resolved
@ThomasK33

Copy link
Copy Markdown
Member Author

@codex review
Round 6: review head 25dd4e6 (no code change since round 5; the three round-5 findings got reasoned replies).

@chatgpt-codex-connector

Copy link
Copy Markdown

🛡️ Codex Security Review · Automatically triggered

Security review completed. No security issues were found in this pull request.

Reviewed commit: 25dd4e69cc

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Hooray!

Reviewed commit: 25dd4e69cc

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@ThomasK33
ThomasK33 added this pull request to the merge queue Oct 25, 2026
Merged via the queue into main with commit 71f3cff Oct 25, 2026
63 of 66 checks passed
@ThomasK33
ThomasK33 deleted the followups/clock-lint-gaps branch October 25, 2026 19:08
yermakoffivan pushed a commit to yermakoffivan/mux that referenced this pull request Oct 26, 2026
Refs coder#7282

## Summary

The 3 turn durations (stream end, stream abort, startup abort) now
measure on the stream's HostClock instead of the wall clock. Under a
test HostClock, a test that advances the TestClock now sees exactly that
time in each `duration`.

## Background

coder#7282: under a test HostClock, some comparisons mixed two clocks. The
last open items were the 3 durations that moved from `streamManager.ts`
into `turnEngine/`:

| Duration | Place | Before | After |
|---|---|---|---|
| stream end | `streamManager.ts` buildStreamEnd usage |
`nodeClock.nowMs() - startTime` | `hostClock.nowMs() - durationStartMs`
|
| stream abort | `turnEngine/AttemptLoop.ts` cleanupAbortedStream | same
| same |
| startup abort | `turnEngine/TurnRegistry.ts` startup stop |
`nodeClock.nowMs() - pending.startTime` | `hostClock.nowMs() -
pending.durationStartMs` |

## Implementation

1. The stream record and the pending startup get a second start field,
`durationStartMs`, read from StreamManager's existing `hostClock`
(`hostClockFor(runner)`).
2. `startTime` stays on the wall clock. It is a record time: the
assistant row stamp, the `stream-start` event and the
`starting-<startTime>` synthetic id use it.
3. TurnEngine, TurnRegistry and AttemptLoop take `hostClock` as a dep.

Out of scope (stays on the wall clock): the assistant and user row
stamps. Their consumers (heartbeatService, compaction boundaries in
agentSession, taskService, workspaceGoalService, workspaceService,
refineService, the renderer timeline) compare them with wall-clock
reads. Moving the assistant stamp alone would sort it before the user
row of the same turn under a TestClock. coder#7282 keeps that residual and
the 4 lint follow-ups from coder#7490.

## Validation

New `streamManager.durations.test.ts` (TestClock, no sleeps). On main
the 3 tests fail: 12, 8 and 0 ms instead of 90000, 45000 and 30000. With
the fix they pass. The existing wall-clock abort test in
`streamManager.usage.test.ts` still passes, because the live HostClock
is the wall clock.

## Risks

Low. In production the HostClock is the wall clock, so the durations are
unchanged. A stream record built without `durationStartMs` (only partial
test fixtures) would report `NaN`. Typecheck requires the field on every
real construction.

---

_Generated with `xum` • Model: `anthropic:claude-opus-5-5` • Thinking:
`high` • Cost: `$279.60`_

<!-- mux-attribution: model=anthropic:claude-opus-5-5 thinking=high
costs=279.60 -->
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