Skip to content

feat(admin): operator commands for disputes across accounts and for the operator role (list, grant, revoke) - #225

Merged
pviti merged 1 commit into
milestone/nextfrom
feature/admin-disputes-operators
Nov 27, 2026
Merged

pviti merged 1 commit into
milestone/nextfrom
feature/admin-disputes-operators

Conversation

@pviti

@pviti pviti commented Nov 26, 2026 •

Copy link
Copy Markdown
Member

go.mod requires the released rail0-go v1.12.0 (commercelayer/rail0-go#96 and commercelayer/rail0-go#98 are in it).

What

Two more groups under rail0 admin (OP8 and OP11 of the operator proposal).

Command What it does Writes
admin disputes Every dispute across accounts. --status, --payment, --chain, --reason, --from, --to no
admin operators Who holds the operator role: account, grantor, note, since when, until when no
admin operators grant <account> Give the role, with --note and --expires yes
admin operators revoke <account> Remove it yes

Refused in agent mode like the rest of the group: the role is given and taken by a person at a terminal.

Decisions worth a look

  1. grant and revoke both ask first, naming the account. They read the account, and the question says its name, its contact and, for a grant, what the role opens and until when. --yes skips it. They are the two most consequential writes of the group.
  2. --expires takes a duration or a time: 7d, 12h, or an ISO-8601 instant. A duration is turned into an instant here, in UTC. A value not in the future is refused before anything is sent. A time-boxed grant typed as an absolute timestamp is easy to get wrong, hence the duration.
  3. A deactivated account can be granted the role (the gateway allows it): the question says the grant opens nothing until the account is activated.
  4. A duplicate grant gets its own hint. The gateway's 409 comes from a unique index and cannot say what collided; the command says the account already holds a grant and that revoking it is how to change its note or expiry.
  5. revoke takes the account's id, not the grant's, as the gateway does and as admin operators lists it.
  6. disputes --reason is checked against the dictionary the merchant commands already use (rail0 disputes reasons), like payments dispute --reason.
  7. An expired grant is marked in the table ((expired), from the local clock); the JSON is the gateway's record, unchanged.

Tests

gofmt, go vet ./..., go test ./... green; docs/cli and docs/man regenerated.

cmd/admin_operators_test.go: the dispute filters and their three local refusals; the grant refused without write mode with nothing sent, the account read before the question, nothing granted without an answer, the note trimmed and the expiry worked out from 7d, a bare grant sending neither; the revoke with the same three steps; parseGrantExpiry (durations, instants, a zone offset, six refusals); the question's wording, for a deactivated account too; the conflict hint.

Checked against staging (test operator key, session revoked afterwards)

  • admin operators (two grants), admin disputes --status open, --reason, --chain, --pretty.
  • Writes, only where nothing can change: without write mode → write_mode_required; in write mode → revoke of the session's own account: 422 self_revoke; grant on an account that already holds the role: 409; an unknown account: 404; revoke on an account with no grant: 404; the question at a terminal, answered no.
  • Agent mode: unavailable_in_agent_mode.

Not done live: no grant was created and none was revoked. The two successful paths are covered by the unit tests only.

…he operator role

rail0 admin disputes            every dispute, by status, payment, chain, reason, time
rail0 admin operators           who holds the operator role
rail0 admin operators grant     give it, with --note and --expires (a duration or a time)
rail0 admin operators revoke    remove it, by the account's id

grant and revoke need write mode, read the account and ask first naming it; a
duplicate grant gets a hint of its own. Refused in agent mode like the rest of
the group.

rail0-go at the branch of commercelayer/rail0-go#98.
@pviti
pviti force-pushed the feature/admin-disputes-operators branch from 1f1dc5c to e80104d Compare November 27, 2026 15:49
@pviti
pviti changed the base branch from feature/admin-webhooks-audit to milestone/next November 27, 2026 15:49
@pviti
pviti marked this pull request as ready for review November 27, 2026 15:50
@pviti
pviti merged commit d505a24 into milestone/next Nov 27, 2026
1 check passed
@pviti
pviti deleted the feature/admin-disputes-operators branch November 27, 2026 15:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant