Skip to content

refactor(drivercontrol): keep the hold test seams out of the API - #2021

Merged
frahlg merged 1 commit into
masterfrom
2013-hold-test-seams
Nov 15, 2026
Merged

frahlg merged 1 commit into
masterfrom
2013-hold-test-seams

Conversation

@frahlg

@frahlg frahlg commented Nov 15, 2026

Copy link
Copy Markdown
Member

Split out of #2013 so it can merge on its own. The commit is hannesb90's, unchanged. It answers the three low notes from the review of #1997.

  • The test seams move behind Holds.Seams(). These are the hook arguments on Send and SendDefault, State.Lock/Unlock, ArmLocked, Expire, Peek, Len and State. Seams() panics outside a test binary (testing.Testing()). The API's hold-race tests still reach the seams, which an export_test.go would not allow.
  • TryActive reads a hold without waiting, for the control tick. Nothing calls it yet.

No behaviour change, so there is no changeset.

Evidence

🤖 Generated with Claude Code

The low notes from the review of #1997, for the step that adds a
planned-value caller:

- The test seams were part of the production API: two hook parameters on
  Send and SendDefault, and exported State.Lock, State.Unlock, ArmLocked,
  Expire, Peek, Len and State.CurrentHold. A planned-value caller could
  have held the per-driver lock through them. They are now behind
  Holds.Seams, which panics outside a test binary. An export_test.go
  would not do: the API package's hold-race tests need them too.
- Holds.State, which created an entry for any name, is reachable only
  through Seams.
- Active takes the per-driver lock and so waits for a command in flight.
  TryActive is the same read for the control tick: it never waits, and
  says so when a command or a default holds the lock.

The hold-race tests are unchanged apart from the call target.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Signed-off-by: hannesb90 <[email protected]>
@frahlg frahlg added the no-changeset PR intentionally exempt from the changeset requirement (dev tooling / non-shipping) label Nov 15, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-15T16:42:19.001562Z 8a1bd51 PR opened
ℹ️ 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: 8a1bd51dba

ℹ️ 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".

// lock: the hold is then changing, and the caller should treat the driver as
// held and look again on its next tick rather than send anything.
func (h *Holds) TryActive(name string) (hold *Hold, known bool) {
state, locked := h.tryLockExisting(name)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Make the map lookup nonblocking in TryActive

When one command holds a driver's state lock and a second Send for that driver enters lock, the second request holds h.mu while waiting for state.mu. TryActive then blocks in tryLockExisting at h.mu.Lock(), even when querying a different driver, rather than returning known=false. The new accessor therefore violates its non-waiting contract under overlapping requests; the added test only covers an uncontended map mutex. Use a nonblocking map-lock acquisition as well, returning an unknown result when it cannot be acquired.

Useful? React with 👍 / 👎.

@frahlg frahlg left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Reviewed. This is the drivercontrol commit from #2013, which a Sonnet agent reviewed at 6730139. Seams() checks testing.Testing() and panics outside a test binary, and nothing outside tests calls it. The API still calls Send and SendDefault, now without hook arguments, and their behaviour is unchanged. TryActive takes h.mu and then TryLock, which keeps the lock order. make verify is clean on 8a1bd51, and go test -race on drivercontrol and the API's hold tests passed.

@frahlg
frahlg merged commit 27567fd into master Nov 15, 2026
21 of 22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no-changeset PR intentionally exempt from the changeset requirement (dev tooling / non-shipping)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants