Repository navigation
fix(hosts): rate-limit heartbeats and close enrollment and audit gaps - #100
Merged
Merged
Conversation
This was referenced Oct 16, 2026
wstein
force-pushed
the
fix/87-heartbeat-codes-audits
branch
from
October 16, 2026 10:35
3065854 to
4129072
Compare
Owner
Author
|
Review CLEAR on |
wstein
force-pushed
the
fix/87-heartbeat-codes-audits
branch
from
October 16, 2026 10:42
4129072 to
5e4002d
Compare
Owner
Author
wstein
marked this pull request as ready for review
October 16, 2026 10:55
Owner
Author
|
Ready per owner: review CLEAR on this head; local |
wstein
force-pushed
the
fix/87-heartbeat-codes-audits
branch
from
October 16, 2026 11:19
5e4002d to
6a19eeb
Compare
Owner
Author
|
Restacked onto pilot |
Every heartbeat writes a transaction plus an undeletable audit row, so a buggy or compromised agent could grow the audit table without bound and starve owner writes. host-enrollment.md fixes the cadence at 10 s. Owner decision H54:a: spacing is measured from when each heartbeat arrives (monotonic receive time), not from the previous commit, so a slow ack followed by a catch-up heartbeat is not punished. A token bucket (capacity 3, one token per 5 s) allows that small burst; the first heartbeat after hello is free. A heartbeat arriving with no token is answered with heartbeat_too_fast and the connection is closed. It is refused without a heartbeat write (no host_heartbeat audit, no lease renewal); the close itself still records the slot update and one host_connection_unknown audit. The rule is recorded in the contract's live expiry section. Existing tests advance the monotonic clock. Refs: #87 Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Earlier unexpired codes stayed valid after a new issue, so redeeming a stale code later retired the identity the agent had just enrolled with. Issuing now marks the host's outstanding unconsumed codes revoked in the same transaction, reusing the existing revoked_at column (no migration). Refs: #87 Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
authorize! called Accounts.authorize inside the transaction and then
Repo.rollback(:forbidden), which also rolled back the denial audit that
authentication.md section 4 treats as security evidence. The in-transaction
check now rolls back with a {:denied, action} marker and the caller records
the denial with Accounts.deny after the rollback.
The outside-transaction pre-check is kept in Hosts (as in ConfigTrust), so
non-Principal callers still get {:error, :forbidden} and ordinary denials
are audited without taking the immediate lock. The post-rollback deny only
covers a denial that appears inside the transaction.
Refs: #87
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Expire the credential between the pre-check and the transaction (clock flips after the pre-check's reads) so only the in-transaction check denies; covers Hosts.revoke and ConfigTrust.approve. Both tests fail when authorize! rolls back with :forbidden again. Refs: #87 Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
wstein
force-pushed
the
fix/87-heartbeat-codes-audits
branch
from
October 16, 2026 11:33
6a19eeb to
cba2cc9
Compare
Owner
Author
4 tasks done
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.
Implements #87: heartbeat rate limit, older enrollment codes, and denial audits.
54e534c: heartbeats are rate-limited by a receive-time token bucket (capacity 3, one token per 5 s; the first heartbeat after hello is free), per owner decision H54:a. A refused heartbeat writes nothing and closes the connection; the close still records the slot update and onehost_connection_unknownaudit. The rule is inhost-enrollment.md.ee245a8: issuing an enrollment code revokes the host's earlier unconsumed codes.e383084: the pre-check stays outside the transaction; a denial raised inside the transaction is audited after rollback.3065854: tests prove an in-transaction denial keeps its audit row (Hosts.revoke,ConfigTrust.approve).Review: CLEAR (Opus 5.5) on 3065854 after three rounds.
make checkon this head is pending. Stacked on the pilot PR (H51:b).🤖 Generated with Claude Code