Files
403031b4fa agentic/ucp: Sweep deletes UCP's records and no other package's (#83)
ucp.Idempotency.Sweep queried every idempotency row in the system namespace,
oldest first, and deleted each one older than Keep (48 h). That namespace also
holds other packages' guards: billing's payment-webhook and intent guards
(scopes webhook and billing-intent) and the ACP, AP2 and MPP ledgers. A host
that scheduled the sweep would therefore delete billing's webhook guards, and a
processor's retry after 48 h would be processed again. Those guards never
expire, so they also sat at the oldest end and took every place under limit.

Every UCP record is now kept under the one scope "ucp", with the request's
scope folded into the key, and Sweep filters on that scope by equality. A
prefix range over "ucp:<scope>" would have sorted by the database's collation,
and on a Unicode collation ";" sorts before ":". Sweep also skips any row of
another scope that reaches it. The record id changes with the layout; no host
mounts UCP yet, so no stored record depends on it.

Testing: go test ./agentic/ucp/... passes; TestSweepTouchesOnlyUCPRecords seeds billing's webhook and billing-intent guards older than two UCP records and sweeps with room for two: the old Sweep deleted both guards and the new one deletes the two UCP records and nothing else. go vet ./agentic/ucp is clean.
Risk: low. UCP is mounted nowhere yet (hanzo-inc/cloud#928 is a draft), so the new record id breaks no stored record; Sweep can only delete fewer rows than before.
How to revert: git revert this commit.

Reported on hanzo-inc/cloud#424.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-22 13:24:47 -05:00
..