Skip to content

Release v1.11.0: operator commands under 'rail0 admin' (health, stuck transactions, sync errors, payment trace, write mode), refused in agent mode and 7 more - #215

Merged
pviti merged 12 commits into
mainfrom
milestone/next
Nov 26, 2026
Merged

pviti merged 12 commits into
mainfrom
milestone/next

Conversation

@pviti

@pviti pviti commented Nov 24, 2026 •

Copy link
Copy Markdown
Member

Summary

The CLI gets its operator side: rail0 admin, for whoever runs the gateway. The rest is maintenance.

Nothing changes for a merchant's commands: no flag or output of an existing command is different. One thing changes for an operator: a key whose account holds the operator role no longer works in agent mode, also for that account's own payments.

rail0 CLI v1.11.0

Added

Changed

Full diff: v1.10.0...v1.11.0


Version: minor, computed from the pull requests merged since v1.10.0 (a breaking change → major, feat → minor, anything else → patch). Decided by:

Merging this pull request also releases v1.11.0: its changes and the version bump
ship together, under the one approval. On the push to main,
.github/workflows/release.yml re-runs CI on the merge commit, creates the tag, and GoReleaser builds the binaries and publishes the GitHub release, and
posts the release to Slack.

The release notes are the text between the release-notes markers above, read from this
pull request when it merges: edit them here, before merging.

Opened by bin/release-prepare.

pviti and others added 4 commits November 24, 2026 17:58
Moves the CLI from rail0-go v1.10.1 to v1.10.2 (released 2026-11-24), so
the next CLI release builds against the latest SDK.

v1.10.2 changes nothing the CLI uses: it drops the retired
`signup_unavailable` hint and updates the release flow. `go build ./...`
and `go test ./...` pass locally.
Merges `main` into `milestone/next` so that `bin/release-prepare` can
run: `main` carries the merge commit of the v1.10.0 release, which the
milestone did not have.

No file changes (`git diff milestone/next` is empty): ancestry only. To
be merged **with a merge commit**, not squashed.
Merging pull request #215 publishes v1.10.1 through .github/workflows/release.yml.
@pviti pviti changed the title Release: Next release milestone Release: Next release milestone (release v1.10.1) Nov 24, 2026
pviti and others added 6 commits November 24, 2026 18:20
…olchain 1.26.11 (#216)

Closes Dependabot alert #2 and the standard-library finding of
`govulncheck`.

- **GHSA-q7gw-24fr-5p69 / GO-2026-6974** (medium): opentelemetry-go
1.35.0–1.46.x does not truncate attribute values made of U+FFFD runes.
The CLI gets otel only indirectly, through `go-ethereum/rpc`, and
configures no OpenTelemetry SDK, so it was not exploitable; the bump to
v1.47.0 (otel, trace, metric; otel/log comes in as a new indirect
requirement) closes the alert.
- **GO-2026-6859** (net/http, Go 1.26.10): an HTTP/1 server crash. The
CLI runs no server; `toolchain` goes to go1.26.11 anyway.

Left as is: **GO-2026-6278** (gorilla/websocket 1.5.3, weak PRNG for the
client mask key). The fix exists only as an unreleased pseudo-version,
the version is pinned by go-ethereum, and the CLI uses WebSocket only
with a `ws://` RPC URL.

`go build ./...` and `go test ./...` pass; `govulncheck ./...` now
reports only GO-2026-6278.
…signed or sent (#218)

Adds the hint for `transaction_in_flight`, the 409 the gateway answers
since 2026-11-17 (gateway a393742) when the other party of a payment
already has its release signed or sent: wait a moment and run the
release again; `rail0 payments get <id>` shows whether theirs settled.

The CLI's 429 output already prefers the gateway's own detail, so the
new 429 for too many transactions waiting to be confirmed (gateway
f26e7a6) needs nothing here. `transaction_not_overwritable` stays
unhinted: the CLI never calls the `/submitted` endpoints that raise it.

Companion to the SDK alignment PRs (rail0-ts, rail0-go, rail0-ruby).
…nsactions, sync errors, payment trace, write mode), refused in agent mode (#219)

## What

`rail0 admin`: commands for a gateway **operator**, a person at a
terminal. Never an agent.

| Command | What it does | Writes |
|---|---|---|
| `admin health` | One verdict, then a named check per thing that can be
wrong. Exit `0` when `ok`, `1` otherwise, after the report is printed |
no |
| `admin health --rpc` | Every active chain's RPC endpoints, probed from
the gateway | no |
| `admin transactions` | Transactions across every account: `--stuck`,
`--hash`, `--account`, `--chain`, `--status`, `--operation` | no |
| `admin sync-errors` | The ledger of indexer callbacks that could not
be applied, with filters | no |
| `admin sync-errors clear` | Deletes exactly what the same filters
list, after counting and asking | **yes** |
| `admin trace <payment>` | The payment with its transactions, sync
errors, webhook deliveries, disputes and operator actions; `--timeline`
for one chronological list | no |
| `admin write-mode [on\|off\|status]` | The hour in which the operator
may write | — |

They need a session whose account holds the operator grant; any other
session gets the gateway's `403`.

## Not for agents

- Every `rail0 admin` command answers `unavailable_in_agent_mode` (exit
`2`) in agent mode, before anything is read or sent. One wrapper
(`operatorOnly`) does it, and the help data lists the group as
unavailable **from the command tree**, so a command added later cannot
be forgotten.
- Agent mode never carries the write-mode token (`bearerToken`). With
write mode open in a terminal, an agent on the same machine still gets
`write_mode_required` for an operator's write through any other command.
Checked against staging.

Not changed: what an operator's session can already **read** in agent
mode through the existing commands (`payments list --scope all`,
`account get --account …`). That is the gateway's answer to the session,
not this group.

## Write mode

An operator session reads. `admin write-mode on` asks the gateway for
the write-mode token (one hour, audited, no signature) and stores it
beside the session's: same directory, `0600`, a file of its own, never
printed.

- **A state of the session, not of one command.** While it is on, every
command carries it, so the operator's writes outside `rail0 admin` work
too (`account update --account …`, `payments redrive`, a wallet switched
off). Today those answer `write_mode_required` from the CLI with no way
forward.
- **It ends** with the hour, with `write-mode off`, with `auth logout`
and with a new `auth login`. Each revokes the token on the gateway, not
only locally.
- **`auth logout` presents the session token explicitly.** A client
built the usual way would carry the write-mode token, and the gateway
would revoke that one and leave the session alive.
- A stored write-mode token that is expired, of another address, or left
with no session is removed instead of carried.

## `sync-errors clear`

- A filter is required. `--all` empties the ledger and cannot be
combined with a filter.
- It counts with the filter, asks naming the count (`--yes` skips), then
deletes with the same filter. Nothing matching: no `DELETE` is sent.
- Without write mode it stops before any request, with the gateway's own
code (`write_mode_required`, exit `4`) and the command that fixes it.

## Dependency

`go.mod` requires the pseudo-version of commercelayer/rail0-go#92's
branch (`client.Admin`), as `ci.yml` describes for unreleased SDK code.
**The release refuses it until `go.mod` requires a tagged SDK version**:
rail0-go must be released first.

## Verification

- `go build ./...`, `go vet ./...`, `gofmt -l`, `go test ./...`: clean.
`go run ./tools/gendocs` output committed.
- New tests (`cmd/admin_test.go`, `internal/token/token_test.go`): the
agent refusal for every command of the group, which token each request
carries, stale write-mode tokens, write mode on and off, the logout
order, the health verdict, the clear's guards and its filter, the
trace's requests, sections and timeline.
- Built binary against **staging**, with the test operator key: `admin
health` (verdict `degraded`: 827 unapplied sync callbacks, exit `1`),
`admin health --rpc` (six chains `ok`), `admin transactions` (126 rows,
`--stuck any` empty), `admin sync-errors`, `admin trace` by UUID and by
`rail0_id` (sections and timeline), write mode on, status and off (two
audit rows on staging), the agent refusals, `auth logout`.
- **Not verified live:** `sync-errors clear` deleting rows (no row was
deleted on staging; unit-tested against a fake gateway), a trace with
webhook deliveries or operator actions (the staging payments tried have
none).
… off and on), wallets (usage, switch) and onboarding requests (invite, correct, resend, cancel) (#220)

## What

Three more groups under `rail0 admin`, for a gateway operator: accounts,
wallets, onboarding requests (OP5 and OP6 of the operator proposal; #219
was OP0–OP4).

| Command | What it does | Writes |
|---|---|---|
| `admin accounts` | Every account; `--search` (name, email, wallet
address or its beginning, id), `--status`, `--operator` | no |
| `admin accounts get <account>` | The whole record: `active`, `status`,
`admin` | no |
| `admin accounts exposure <account>` | What a deactivation would leave
in motion | no |
| `admin accounts deactivate <account>` | Switch the account off |
**yes** |
| `admin accounts activate <account>` | Switch it back on | **yes** |
| `admin wallets --account …` | An account's wallets, with
`deactivated_by` | no |
| `admin wallets usage <wallet> --account …` | Payments as payee and
payer, transactions sent | no |
| `admin wallets deactivate <wallet> --account …` | Switch any wallet
off (the definitive revocation) | **yes** |
| `admin wallets activate <wallet> --account …` | Switch it back on |
**yes** |
| `admin onboardings` | Invites and sign-ups; `--status`, `--origin`,
`--send-failed` | no |
| `admin onboardings invite --name --email --address` | Create the
request, email the link | **yes** |
| `admin onboardings correct <request>` | New name / email / address,
new link | **yes** |
| `admin onboardings resend <request>` | The link again (also retries a
failed send) | **yes** |
| `admin onboardings cancel <request>` | Delete a request that is not
completed | **yes** |

Like the rest of the group: **refused in agent mode**, every one, before
anything is sent. The help data's list is still filled from the command
tree; the tree is now assembled in `admin.go` alone, because Go runs
that file's `init` before the other `admin_*.go` files' (the first run
of the test caught the new subcommands missing from the list).

## Decisions worth a look

1. **Every write checks write mode first** (`requireWriteMode`), before
anything is read or asked: the operator is not shown figures and a
question for a command that cannot run. `sync-errors clear` now uses the
same helper.
2. **`accounts deactivate` and the exposure.** The command reads the
account and its exposure and asks, with the figures in words (`9
payments in escrow, 2 open disputes (9.9 USDC on arc)`). Answering yes
to that question is the acknowledgement the gateway requires
(`acknowledge_open_exposure`). Where no question is asked (`--yes`, no
terminal) an account with something in motion stops with a new CLI code,
`exposure_not_acknowledged` (exit 2), unless `--acknowledge-exposure` is
passed too. So `--yes` alone never switches off an account that has
something in motion.
3. **An account already deactivated is left alone**: reported, nothing
written (no second audit row).
4. **`activate` (account and wallet) asks nothing**: it is reversible,
like `account update`.
5. **`admin wallets` always takes `--account`** and never defaults to
the operator's own account: a forgotten flag must not land on the
operator's own wallets. `admin accounts --search 0x…` finds the account
from an address.
6. **`wallets deactivate` shows the usage in its question** and says the
one thing that differs from the merchant's own switch-off: only an
operator can lift it.
7. **`onboardings invite` validates locally** that the three values are
there and that the address is one (`0x` + 40 hex, or an `@alias`). No
confirmation: it deletes nothing, and `cancel` reverses it. `cancel`
asks.
8. **`wallets usage` prints its three counts whatever they are**: the
SDK's generated type drops zeros, and "payer of 0 payments" is an
answer.

## Depends on

commercelayer/rail0-go#94: `go.mod` requires that branch's commit by
pseudo-version. After it merges, `go.mod` here moves to the merged
commit (as done for #219); the CLI release needs rail0-go released and
`go.mod` on the tag.

## Tests

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

`cmd/admin_accounts_test.go`: filters sent; every write refused without
write mode with nothing sent; the switch carries the write-mode token
and only its own field; the exposure rule (`--yes` alone refused, with
the figures in the message; with the flag the acknowledgement goes out);
no confirmation, no write; a deactivated account not written again;
wallets need `--account`; usage read before the question; invite refused
on a missing or malformed value; correct sends only the corrected value;
cancel asks.

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

- Reads: account list, `--search` by address prefix, `--operator true`,
`--status deactivated`, `get`, `exposure`, wallets of an account,
`usage`, onboarding list, `--status completed`, `--send-failed true`,
`--pretty` tables.
- Without write mode: all eight writes answer `write_mode_required`
(exit 4) and send nothing.
- In write mode, only paths that change nothing: `deactivate --yes` on
an account with exposure → `exposure_not_acknowledged`; the two
questions at a terminal, answered no; own account → gateway `422
self_deactivate`; unknown ids → `404` (`onboarding_not_found` on cancel,
resend, correct).
- Agent mode: `unavailable_in_agent_mode`.

**Not done live:** no account or wallet was switched, no invite was sent
(it emails a real mailbox), no request corrected, resent or cancelled.
Those paths are covered by the unit tests only.

## Not in this PR

- OP7–OP12 (webhooks and deliveries across accounts, disputes, audit,
config and catalogue, operators, payouts).
- A note in rail0-skill that `rail0 admin` is not for agents.
…seudo-version (#221)

rail0 admin (#219) was merged against an unreleased rail0-go commit.
rail0-go v1.11.0 is now published with client.Admin: go.mod and go.sum
point at it, so the CLI release does not ship a pseudo-version. go
build, go vet and go test pass locally.
Merging pull request #215 publishes v1.11.0 through .github/workflows/release.yml.
@pviti pviti changed the title Release: Next release milestone (release v1.10.1) Release: Next release milestone (release v1.11.0) Nov 26, 2026
@pviti pviti changed the title Release: Next release milestone (release v1.11.0) Release: operator commands under 'rail0 admin' (diagnostics, stuck transactions, sync errors, payment trace, accounts, wallets, onboarding, write mode), a hint for transaction_in_flight, security updates (release v1.10.1) Nov 26, 2026
@pviti pviti changed the title Release: operator commands under 'rail0 admin' (diagnostics, stuck transactions, sync errors, payment trace, accounts, wallets, onboarding, write mode), a hint for transaction_in_flight, security updates (release v1.10.1) Release: operator commands under 'rail0 admin' (diagnostics, stuck transactions, sync errors, payment trace, accounts, wallets, onboarding, write mode), a hint for transaction_in_flight, security updates (release v1.11.0) Nov 26, 2026
… a milestone's title says what it releases (#222)

## What

Two changes to `bin/release-prepare`, both about what a release pull
request (`milestone/next` → `main`) shows to whoever opens it. The same
change goes into rail0-ts, rail0-go, rail0-ruby and rail0-cli: it
touches only the part of the script and of its test that the four repos
share, which stays byte-identical.

### 1. A release pull request needs a summary

The script writes its block (notes, version, how the release happens)
between `<!-- release:start -->` markers and keeps whatever is above
them. That is where the description belongs, and until now nothing asked
for one: the release pull requests were opened with the line "Filled in
by bin/release-prepare.", which then stayed as the first thing shown in
the pull request, in the message of its merge commit and in every
preview. The block itself is a list of pull request titles, not a
description.

Now, on a branch:

- a **real run refuses**, before it commits or pushes anything, when
there is no summary above the block: an empty description, only an HTML
comment, or that old placeholder;
- `--dry-run` **warns** and still prints the version and the notes,
which is what to write the summary from.

The summary is written once and kept on every re-run.

### 2. A milestone branch's pull request gets its title from what it
releases

It used to keep the title it was opened with plus a suffix: `Release:
Next release milestone (release v1.11.0)`. A milestone pull request has
no change of its own to name, so the script now writes the title, the
way the gateway, indexer and admin release pull requests already do:

```
Release vX.Y.Z: <the first pull request that decided the version> and N more
```

"The first" is the lowest-numbered pull request among those at the level
that decided the bump (the breaking ones for a major, the `feat` for a
minor), without its Conventional Commits prefix. A subject over 180
characters is shortened. The title is rewritten on every run, so it
follows what is merged.

A **feature branch** that carries its own release is unchanged: it keeps
its title, whose type decides the version, with the ` (release vX.Y.Z)`
suffix. The release-only pull request opened from `main`
(`chore(release): vX.Y.Z`) is unchanged too.

`release.yml` does not read the title of a branch's pull request (it
finds the pull request from the merge commit), so nothing changes there.

## Tests

`bin/release-prepare-test` (run by CI), new cases on the milestone
branch:

- the title the dry run shows and the real run writes; a re-run writes
the same one;
- a later pull request that outranks the others takes the title, the
first by number wins among equals, and the count follows;
- no summary (empty, a comment, the old placeholder, a description that
is only the release block): the dry run warns and still prints the
release, the real run refuses and leaves no commit, no push and no edit
behind;
- a description with a summary is not warned about, and the summary
stays above the block.

Run by hand: the changed script, `--dry-run`, against the real rail0-cli
release pull request (#215, which has a summary): no warning, and the
title it would write is `Release v1.11.0: operator commands under 'rail0
admin' (health, stuck transactions, sync errors, payment trace, write
mode), refused in agent mode and 6 more`.

## After the merge

The open release pull request of this repository gets its new title the
next time `bin/release-prepare` runs on `milestone/next`. This pull
request is a `chore`: by itself it makes the next release a patch.
@pviti pviti changed the title Release: operator commands under 'rail0 admin' (diagnostics, stuck transactions, sync errors, payment trace, accounts, wallets, onboarding, write mode), a hint for transaction_in_flight, security updates (release v1.11.0) Release v1.11.0: operator commands under 'rail0 admin' (health, stuck transactions, sync errors, payment trace, write mode), refused in agent mode and 6 more Nov 26, 2026
… stored or opened on the spot (operator_session) (#226)

## What

**In agent mode the CLI never acts with a gateway operator's session.**

`rail0 admin` already refuses in agent mode, and agent mode never
carries the write-mode token. That left the reads: with an operator's
session the gateway widens the ordinary commands too, so an agent on a
machine where an operator had signed in could read every merchant
through them.

| Command | With an operator's session it reads |
|---|---|
| `payments list --scope all` (`--account`, `--has-error`,
`--expiring-within`) | every account's payments |
| `payments get <id>` | anyone's payment, the whole record |
| `account get --account <id>` | any account's profile, email included |
| `wallets --account <id>` | any account's wallets |

The CLI could not tell: the session token carries no role (the gateway
reads the grant on every request), and the `admin` flag of the sign-in
answer was not kept.

## How

The session itself is what agent mode refuses, at the two places a
command gets one. New error code `operator_session`, exit `4`.

1. **A stored session.** At sign-in the CLI now keeps what the gateway
answered, in a marker beside the token (`<digest>.operator`, `0600`).
The marker holds a fingerprint of the token it describes, so one left by
an earlier session can never answer for the session stored now. In agent
mode a marked session is **not carried** (`bearerToken`): what needs no
session still works (`health`, `chains`, `tokens`, `payment-methods`,
`help`); what reads the session locally answers `operator_session`; and
when the gateway answers 401 to a request sent without it on purpose,
the CLI says why instead of "sign in" (which would send the agent to
sign in again with the same key).
2. **A session opened on the spot**, by `auth login` or by a command
signing in with its `-p` key. When the gateway says it is an operator's,
it is **revoked at once** (best-effort `POST /auth/logout` with its own
token), taken off the client, never stored. A session a person stored
before is left exactly as it was.

`auth status` shows `"operator": true` for such a session, and in agent
mode `"usable_in_agent_mode": false`. `auth logout`, and `auth login`
with a key that is not an operator's, work in agent mode: they are the
way out.

Outside agent mode nothing changes: a person's operator session is
stored (and now marked) and used as before.

## Limits, stated in the README

The CLI knows what the gateway answered **at sign-in**. Three sessions
read as not an operator's until the next sign-in, at most the 24 hours a
session lasts:

- one stored by a CLI older than this change (no marker);
- one pasted with `auth login --token` (nothing was asked about it; that
flag is refused in agent mode);
- one whose account was granted the role after it signed in.

No request is added to find out: the answer comes with the sign-in the
CLI already makes. The only new request is the revoke of a session agent
mode has just refused.

## A consequence to know

An operator whose own account is also a merchant cannot drive that
account from an agent: its key signs in as an operator. Agent work needs
a key whose account does not hold the role.

## Tests

`gofmt`, `go vet ./...`, `go test ./...` green; `docs/` regenerated (no
command or flag changed).

- `internal/token`: the marker belongs to its token (another token
stored over it, another gateway, the session deleted), is `0600` and
holds no token.
- `cmd/operator_session_test.go`: a person's operator sign-in is stored
and marked, an ordinary one unmarks; in agent mode a stored operator
session is not on the request, the local session readers and
`ensureSession` with the same key answer `operator_session` with no new
sign-in attempted, and the stored session is not touched; a 401 is
rewritten only when a session was withheld; a sign-in that turns out to
be an operator's is revoked with its own token, cleared from the client
and not stored; an ordinary key signs in as before; `auth login` refused
in agent mode leaves the previously stored session in place; `auth
status` in both modes.

### Checked against staging (test keys, every session revoked
afterwards)

- Agent mode, `auth login` with the operator key: `operator_session`,
exit 4, no file written.
- A person signs in with the operator key: token and marker stored,
`auth status` says `operator: true`.
- Agent mode with that session stored: `payments list --scope all`,
`payments list`, `account get`, `wallets` → `operator_session` (exit 4);
`health`, `chains` → ok; `auth status` → `usable_in_agent_mode: false`.
The same `payments list --scope all` as a person still reads.
- Agent mode with the merchant test key: sign-in stored, `payments list`
works, `--scope all` is the gateway's `forbidden`.

## Release

No SDK change (built against rail0-go v1.11.0). Merged before the
v1.11.0 release pull request (#215) is out, it joins that release and
#215 needs a re-run of `bin/release-prepare` and its summary updated;
merged after, it opens the next one.
pviti added a commit to commercelayer/rail0-skill that referenced this pull request Nov 26, 2026
… are refused in agent mode (CLI 1.11.0) (#8)

## What

One rule added to the skill: **an agent does not use `rail0 admin`**.

`rail0 admin` is the CLI's operator side (diagnostics, reads across
every account, switching accounts and wallets off, onboarding, the
operator role), new in CLI 1.11.0. Agent mode refuses every one of those
commands (`unavailable_in_agent_mode`, exit `2`) before anything is
sent, and never carries an operator's write-mode token, so an operator's
write through any other command answers `write_mode_required` (exit
`4`).

The skill now says so where it already lists what is not the agent's
(`keys add`, `keys generate`, the session token), and tells the agent
what to do instead: name the command the task needs and leave it to the
person, without looking for a way around the refusal.

- `skills/rail0-payments/SKILL.md`: the rule, with the two answers the
CLI gives.
- `skills/rail0-payments/references/commands.md`: `rail0 admin` added to
what agent mode refuses.

## Not in this PR

No eval added. The rule describes CLI 1.11.0, which is not released yet
(commercelayer/rail0-cli#215): merging this before that release is
harmless, the sentence says "from CLI 1.11.0".

Targets `main`: this repository has no `milestone/next`.
@pviti pviti changed the title Release v1.11.0: operator commands under 'rail0 admin' (health, stuck transactions, sync errors, payment trace, write mode), refused in agent mode and 6 more Release v1.11.0: operator commands under 'rail0 admin' (health, stuck transactions, sync errors, payment trace, write mode), refused in agent mode and 7 more Nov 26, 2026
@pviti pviti self-assigned this Nov 26, 2026
@pviti
pviti merged commit 017064b into main Nov 26, 2026
2 checks passed
pviti added a commit that referenced this pull request Nov 27, 2026
Brings the merge commit of the v1.11.0 release (#215) from `main` into
`milestone/next`, so the next release pull request holds only what is
new and `bin/release-prepare` finds `main` contained in the branch.

No change of content beyond what `main` already has: the changelog and
the version of v1.11.0. To be merged **with a merge commit** (a squash
would lose the link to `main`).
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.

2 participants