A Timeout Could Not Refund the Permit
Engineering journal · 2–5 August 2026

At the end of July I had tested the case where the protected operation stopped when the local authority path was unavailable. August sharpened a different question. If a one-use permit is sent to the remote authority and the connection fails before the answer arrives, what does the local daemon still know?
For the implementation background, see Python’s asyncio.to_thread.
Follow a permitted operation through all three boundaries
The August work started by testing what happened at a controlled effect when authority changed. A lease is time-bound authority to act within a scope. The ownership epoch identifies which successive owner the lease belongs to. A one-use operation permit narrows authority further to the requested operation. A client can still hold a lease-shaped object after the boundary that issued it has revoked it. That is why the test question has to be about whether the effect was reached and which owner the evidence names.
A positive control matters here. If a protected subprocess always stops because it cannot start, the expiry test might pass for the wrong reason. A permitted synthetic operation demonstrates that the wiring can reach the effect in the right case. Expiry, revoked owner, ownership transfer, daemon restart and unavailable remote authority cover different breaks in the chain. Retained test commits distinguish them. They do not establish which combinations were active across all installed providers and hosts.
A deadline does not resolve the remote outcome
The related 4 August changes bound the caller’s response time and the permit request timeout. A deadline can stop the local caller waiting. It cannot prove the remote request was cancelled. The remote service could have accepted the message and lost the reply, or the message may never have arrived. Treating these cases as one generic failure discards the part of the outcome that is known.
| Role in prose | Exact path, commit, or symbol | Notes |
|---|---|---|
| Daemon module | packages/agent-control-plane/src/agent_control_plane/daemon.py | Permit consumption and timeout validation |
| Permit consume commit | 8899d84988c6 | Retires local permit before remote I/O (lines 353–362) |
| Timeout pair commit | 72533347e84a | Validates authorization vs host deadline (lines 187–196) |
| Remote consume call | consume_operation_permit | Offloaded via asyncio.to_thread |
Historical source excerpt. packages/agent-control-plane/src/agent_control_plane/daemon.py at 8899d84988c6, lines 353–362.
permit = self._permits.pop(permit_id, None)
if permit is None:
raise RuntimeError("operation permit unavailable")
await asyncio.to_thread(
self._client.consume_operation_permit,
str(permit_id),
{"operation_id": operation_id, "resource": resource.value},
self._key,
)
return permit
Explain this code line by line
- Remove the exact permit from the daemon's local set and retain the removed object.
- Check whether the local set contained the permit.
- Without a local capability, stop before any network call.
- Await the remote consume operation through a worker thread.
- Use the remote client's authority-specific consume method.
- Pass the identity of the same locally removed permit.
- Bind the request to the operation and resource.
- Supply the daemon-held client credential without transferring it to the calling tool.
- Complete the await. If the remote call raises, the local capability remains removed.
- On success, return the permit object to the calling boundary.
Historical source excerpt. packages/agent-control-plane/src/agent_control_plane/daemon.py at 72533347e84a, lines 187–196.
try:
(
operation_permit_authorization_timeout_seconds,
operation_permit_host_deadline_seconds,
) = validate_operation_permit_timeouts(
operation_permit_authorization_timeout_seconds,
operation_permit_host_deadline_seconds,
)
except ValueError:
raise ValueError("unsafe host configuration") from None
Explain this code line by line
- Begin timeout configuration validation.
- Begin unpacking the validated pair.
- Keep the validated authorization timeout.
- Keep the validated host deadline.
- Call the shared validator.
- Pass the authorization timeout.
- Pass the host deadline.
- Finish validating the two values.
- Catch failure of the configuration validation.
- Present the bounded configuration error without a nested traceback.
Suppose a client holds permit P and the daemon makes a consume attempt. The response disappears. At the local boundary, the protected operation stops and the local permit entry has already gone. At the remote boundary, there are still two compatible histories: the authority recorded P as spent, or it never saw the consume. Neither history returns local authority. A second local attempt with P stops before remote I/O. Any new permission would have to come from a new authority decision bound to current context.
| Boundary | On the ambiguous attempt | On local replay |
|---|---|---|
| Daemon’s one-use set | Entry removed once | No matching entry |
| Remote authority | Result unknown to this caller | The daemon makes no second request with P |
| Protected effect | Denied on the ambiguous attempt | Denied before the remote consume path |
This model has a cost. A network fault can leave a legitimate operation unfinished and the one-use grant unavailable. That is preferable to recycling an authority decision merely because its answer disappeared. Recovery needs reconciliation or an expressly new grant. The implementation does not claim to recover availability automatically.
Where the tests and the release stopped
The 5 August report records a red regression where the second call could reach remote consume, two passing focused checks after the change, and 90 passed with one skipped in a broader selection. It records a merged change and successful main pipeline including the control-plane image. The live reconciliation at that checkpoint still observed the earlier GitOps revision and image. These give separate source, build and runtime records. The reported checks also leave mutation-enforcement activation outside this slice.
The practical operator question after a timeout therefore has three parts. Was the local grant removed? What did the remote authority acknowledge? What effect was actually recorded? When the middle answer is unknown, the other two remain usable. The same discipline applies to provider reports next. A service can supply a measurement without acquiring the authority to decide what that measurement permits.
The note that a green build leaves unanswered
The history includes separate test commits for a governed MCP subprocess, a stale epoch, a daemon restart, and an unavailable remote route. Keeping them as separate fixtures is valuable. To test expiry I need a lease that was initially useful and a clock or deadline that can genuinely expire it. To test a transfer I need the old and new identity to be distinguishable. To test a network partition the authority can remain logically valid while its answer becomes unavailable. A generic permission-denied result would make all these situations look equivalent. The controlled effect and the grant identity show which condition actually reached the intended check.
A caller deadline and the permit timeout attempt to limit different waits. The configuration code checks paired timeout values together before an unsafe configuration can reach the launch path. A useful trace would record when the caller stopped waiting and whether the daemon ever got a remote answer. Thread offloading keeps the asynchronous event loop available while the blocking remote call is in progress. It does not give the caller a reliable ability to reverse an operation already under way on the remote side. This is why a local record is meaningful even when the wire outcome remains unknown.
There is a subtler verification objective than “fails closed.” On the red version the first fault can still prevent the business effect but leave the grant locally replayable. An assertion that counts only completed effects would pass. The focused regression also observes remote consumption attempts and calls the boundary again with the same local identity. The repaired behavior keeps the second attempt local. That separates the exact impact of the patch from the wider enforcement claims.
The retained main pipeline includes an integration job, an image build and a notification job. Those are legitimate results from CI. The contemporaneous running pod still used the earlier digest. A notification is therefore one more stage in the release chain rather than observed host activation. The later promotion needs its own applied revision and concrete image identity. With the evidence split at those boundaries, I can say where the work was successful while keeping agent operation authority conservative.
Put the regression at the decision that really failed
A test that watched only the filesystem would miss a retry that reached the authority boundary without changing a file. This regression isolated that boundary. It called the daemon permit authority directly and used a stub that raised a connection error. After the fix the second call raised locally and the stub’s consume count stayed at one. The fixture exercised neither a real connection nor a file sink. Separate subprocess and partition tests supplied effect-path evidence.

The local token is already retired while the remote answer is still uncertain.
The test-first report goes one step farther. After the first ambiguous consume, a second local call reached remote consume again. That is the failed assertion that matters. The defect was the order in which the daemon retired its copy of the grant. Retiring it before the network call gives the next attempt a local answer even when the remote service is unreachable. The second call must stop when it looks up the permit. This does not decide whether the first remote request committed. It reduces the set of decisions the local process can accidentally make while it does not know.
It helps to think about what an authority record is worth after two different failures. If the request never arrived, the remote ledger could still show an unused grant. If the request arrived and its reply was lost, the remote ledger could show it as consumed. Neither possibility justifies putting the removed entry back in memory. Reconciliation can consult the appropriate durable authority record, while a subsequent protected operation needs its own authorized path. The example describes the boundary. The retained test does not attest to every network fault or server recovery trajectory.
Check whether loss of the response stops the actual effect
There are three different clocks. The caller-facing response deadline bounds how long the tool caller waits. The shorter authorization timeout in this change applies to permit issuance. The enclosing host deadline covers issuance, consumption and the sink. The timeout-pair validator rejects unsafe combinations before use. When remote I/O has already begun, a local timeout still leaves the remote outcome unresolved.
I would keep three independent observations next to one another in the evidence trail. First, whether a specific local permit remained available. Second, whether the server supplied an affirmative outcome to this attempt. Third, whether the requested effect changed the resource. The red fixture showed the grant could be retried. It did not measure a resource change. The corrected fixture isolates that mismatch. The neighboring regression fixtures for expiry, owner transfer and daemon restart defend other boundaries. Passing one of them cannot substitute for testing the ambiguous consume.
The original delivery record supplies the 2 focused passes and broader 90 passes with one skip. It also separates the main pipeline from the image then running in the cluster. An image build and deploy notification completed, while the pod still reported the earlier applied digest and the enforcement flags were off. That evidence demonstrates a source-level ordering repair. The checks required before today’s change can be used in a live protected effect belong to their own rollout record.
The next chapter moves the authority decision upstream. A client should be able to report provider health without getting to declare the approval it needs for a routing change.
Glossary and primary references
Capability
A bounded grant that authorizes an operation.
Ambiguous result
A caller lacks reliable evidence of what happened on the remote side.
Replay
A second use of an input or authority already used in a prior attempt.