feat(monetize): replace pause annotation with ERC-8004-friendly drain#535
Closed
bussyjd wants to merge 2 commits into
Closed
feat(monetize): replace pause annotation with ERC-8004-friendly drain#535bussyjd wants to merge 2 commits into
bussyjd wants to merge 2 commits into
Conversation
The legacy obol.org/paused annotation tore down HTTPRoutes immediately, which is indistinguishable from a crash to remote x402 buyers and ERC-8004 reputation scorers. obol sell stop was also broken: it patched status.conditions which the controller immediately overwrote. This replaces both with a real drain: - New ServiceOffer spec.drainAt (date-time) + spec.drainGracePeriod (duration; default 1h) mark an offer as winding down. - While draining, /skill.md and /.well-known/agent-registration.json advertise the offer with available=false and drainEndsAt set, so external discovery can react before traffic disappears. - The HTTPRoute + payment gate stay up until DrainEndsAt, letting in-flight buyers complete payments. - After the grace period, the controller tears down the route, sets Draining=False reason=Drained, and leaves the CR (delete is the canonical removal command). obol sell stop sets spec.drainAt, supports --grace <duration> and --force/--now (zero grace = abrupt teardown for behavior parity with the old annotation).
…e drain signal
Design review concluded the `available` boolean was redundant — the
presence of `drainEndsAt` is sufficient to signal drain state. This
makes the drain wire shape purely additive: active offers serialize
identically to pre-drain releases.
Wire changes:
- ServiceCatalogEntry.Available field removed.
- DrainEndsAt is the only drain signal. Consumers detect drain with
`if (entry.drainEndsAt) { /* draining */ }`.
- /skill.md detail block: no Available bullet on active offers; only
draining offers get a "Drain ends at" bullet.
- /skill.md table column renamed Available → Status; active rows show
"—", draining rows show "draining · ends <RFC3339>".
JSON Schema: `available` removed from required and from properties;
`drainEndsAt` description updated to "Presence = draining."
Tests updated to assert active entries carry NO `available` or
`drainEndsAt` keys in the raw JSON, and the markdown detail block for
active offers contains no Available line.
6 tasks
Collaborator
Author
|
Superseded by bundle PR #536 — closing in favor of the consolidated merge target. Original branch and history preserved. |
This was referenced May 24, 2026
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.
Problem
Two things were broken about the legacy "pause" path:
obol.org/paused: "true"made the controller delete the HTTPRouteimmediately. From a remote x402 buyer's perspective that's
indistinguishable from a crash — and ERC-8004 reputation scorers
that watch a seller's
/.well-known/agent-registration.jsonsee anabrupt disappearance with no advertised wind-down.
obol sell stopwas broken. It patchedstatus.conditions[Ready]=False,which the controller overwrote on the next reconcile. The CLI looked
like it worked; in practice the offer stayed live.
Design
Replace pause with a real drain:
route disappears, so external observers can react gracefully.
buyers can complete in-flight payments.
and marks
Draining=False reason=Drained. The CR stays —obol sell deleteis still the canonical removal command.Pure-additive wire shape
Drain is purely additive in the catalog. Active offers serialize
identically to pre-drain releases: no new fields, no shape change. The
only new wire surface is
drainEndsAt, which is set on draining offersonly. Consumers detect drain with:
There is no
availablefield. Presence ofdrainEndsAtis the signal.This was an explicit design review outcome (commit
dd89750): aseparate boolean was redundant and would have been a schema-breaking
change for strict consumers. Now there is zero schema breakage.
API
ServiceOfferSpec:drainAt*metav1.TimedrainGracePeriod*metav1.Duration1hdrainAtthe route stays up.0stears down on the next reconcile.ServiceOfferhelpers:IsDraining(),DrainEndsAt() time.Time,DrainExpired(now time.Time) bool.CLI:
Discovery surfaces:
/api/services.json: draining entries gain a singledrainEndsAt: <RFC3339>key. Active entries serialize unchanged.
/skill.md: per-service detail block adds a- **Drain ends at**:bullet only for draining offers. The table gains a
Statuscolumn(active:
—, draining:draining · ends <RFC3339>).Drain lifecycle
sequenceDiagram autonumber participant Op as Operator participant CR as ServiceOffer CR participant Ctl as serviceoffer-controller participant Disc as /skill.md +<br/>/.well-known/agent-registration.json participant Route as HTTPRoute + x402 Middleware participant Buyer as Remote buyer Op->>CR: obol sell stop my-svc<br/>(patch spec.drainAt=now,<br/>drainGracePeriod=1h) CR-->>Ctl: Update event Ctl->>Ctl: IsDraining=true,<br/>DrainExpired=false Ctl->>Disc: emit drainEndsAt=T+1h<br/>(no `available` field) Ctl->>Route: KEEP UP Ctl->>CR: Draining=True reason=Draining Ctl->>Ctl: AddAfter(T+1h) Buyer->>Disc: poll catalog Disc-->>Buyer: drainEndsAt set → migrate Buyer->>Route: in-flight paid request Route-->>Buyer: 200 OK Note over Ctl: ...grace period elapses... Ctl->>Ctl: DrainExpired=true Ctl->>Route: deleteRouteChildren() Ctl->>CR: Draining=False reason=Drained,<br/>PaymentGateReady=False,<br/>RoutePublished=False Op->>CR: obol sell delete (later, canonical removal)Why ERC-8004 reputation matters
ERC-8004 makes seller reputation an on-chain signal that buyers and
discovery agents can score. An abrupt route teardown looks identical to
a process crash or upstream outage — a negative reputation event.
Advertising a planned wind-down (
drainEndsAt) lets buyers and scorersdistinguish "this seller is gracefully retiring this offer" from
"this seller's infrastructure is unreliable." Even short grace windows
(a few minutes) move the signal from "outage" to "planned maintenance."
Migration
If you were setting
obol.org/paused: "true"directly, the annotationno longer has any effect. To match the old abrupt-teardown semantics:
For the recommended graceful behavior, drop
--forceand let buyerssee the wind-down via discovery.
Test plan
go build ./...go test ./internal/monetizeapi/... ./internal/serviceoffercontroller/... ./internal/x402/... ./cmd/obol/... ./internal/schemas/...ServiceOffer.IsDraining,DrainEndsAt,DrainExpired(nil, mid-drain, expired, --force zero-grace)drainEndsAt, noavailable), mid-drain (onlydrainEndsAt), drain-expired (filtered from catalog)/skill.mddetail block carries no Available bullet on active offers; only draining offers get a Drain-ends-at bulletobol sell stophas--grace(default 1h) and--force(alias--now)availableordrainEndsAtkeysobol sell stop my-svc -n llm→ confirm/api/services.jsonentry gains adrainEndsAt,/skill.mdshows the drain banner, paid requests still 200 OKkubectl get httproute -n llmno longer shows the offer's routeobol sell stop my-svc -n llm --force→ confirm route disappears on the next reconcile