BBramaDocs
Browse documentation

Brama CLI command reference

brama maintain

Ask the serving gateway for one more maintenance pass through POST /v1/admin/maintain. The serving process runs its own passes and needs no schedule: one when it starts, then one at the next moment its usage ledger states something becomes due (a grant's stated expiry, a plan window's stated reset, a rate block's stated end), and one right after it refuses a request subscription_reauthorization_required. Each pass renews due grants and signs members in through Weles by itself; the log records maintenance_pass_finished with next_due_ms, and maintenance_woken_by_refusal. The pass runs inside the serving process because that process holds the usage ledger, the journal and the credentials; this command is for an operator who wants a pass now.

Invocation

brama maintain (--gateway <URL> | --gateway-consumer <CONSUMER>) [--bearer-role <ROLE>] [--json] [< bearer]
InputRequired/defaultMeaning
--gateway <URL>one of the twoThe gateway's origin.
--gateway-consumer <CONSUMER>one of the twoResolve the gateway through stado service directory connect brama --consumer <CONSUMER>.
--bearer-role <ROLE>optionalRead the console bearer at the moment of the pass from the token field of the vault item that plays this role, through stado credentials get --role <ROLE> --field token. No item is named, so replacing the item changes nothing here. Without it the bearer is read from standard input.
--jsonoptional; offPrint the gateway's report as JSON instead of lines.

The command can still be run on a schedule, for example stado schedule create --pinned-host <gateway host> --cron '* * * * *' 'brama maintain --gateway-consumer <consumer> --bearer-role brama-desktop-model-router', but nothing depends on one.

Output and state

The pass reads every plan usage report that is due (no reading, a reset window, a reading naming no reset, or a failed last read), records for every renewable provider the account each member's own grant states (the same work as brama subscription attribute, so a member imported without its account can be signed in through Weles), renews every grant whose stated expiry has passed and schedules a Weles sign-in for each member that needs one, decides whether a spent pool needs a new account (see brama subscription acquire; when it does, the purchase starts and the pass does not wait for it), and takes a fresh readiness reading for /readyz. Lines read:

plan usage: <N> subscription(s), <N> read
  failed <subscription> (<provider>): <error envelope>
account attribution failed for <provider>: <error>
credentials: <N> subscription(s), <N> refreshed, <N> refused, <N> sign-in check(s) scheduled
acquisition: "<provider>" "refused"|"started" ("<code>"): "<sentence>"
readiness: ready=<bool> <reason>

An acquisition refusal (for example pool_not_spent naming the account with plan left, or account_cap_reached naming the cap and the accounts) is a decision and does not make the pass fail; a purchase the pass started reports its verdict in the gateway's log (subscription_acquisition_finished) and the journal.

When renewal could not list the credentials, the credentials line is credentials: <inventory error>. It exits 0 only when the gateway's report says ok: true.

Refusals

SentenceExitMeaning
the parser's refusal for neither or both of --gateway and --gateway-consumer2The pass has to run in one serving gateway; nothing was contacted.
reading the console bearer from stdin: <error>1Standard input could not be read.
a gateway needs the console's bearer: --bearer-role, or the token on stdin1No bearer was given either way.
--bearer-role names the role the console's bearer item plays, and `<value>` is not one1The value is empty or is an item#field coordinate.
the item playing role <role> holds no value in its token field1The vault answered with an empty field.
`<stado> <arguments>` refused: <stado's own sentence>, or `<stado>` could not be run: <error>1The vault read or directory lookup failed in Stado; BRAMA_STADO_BIN names another Stado binary.
Stado's service directory answered `<answer>` for consumer `<consumer>`, which names no gateway origin1The directory has no Brama origin for that consumer.
the gateway <origin> did not answer: <error>1Transport failure; nothing ran.
the gateway refused the maintenance pass: HTTP <status>: <reason>1The gateway refused the request, for example a wrong bearer.

Back to the complete CLI command tree.