Skip to content

app/: staff commands ported from the Loco server (user:set-staff, org:add-member, org:set-plan, org:delete, stripe:setup) (sc-8900) - #146

Merged
ndbroadbent merged 2 commits into
mainfrom
app-staff-commands
Dec 3, 2026
Merged

ndbroadbent merged 2 commits into
mainfrom
app-staff-commands

Conversation

@ndbroadbent

@ndbroadbent ndbroadbent commented Dec 3, 2026 •

Copy link
Copy Markdown
Member

This ports the Loco server's staff tasks (git show 0788198^:server/src/tasks/...) to Laravel Rust commands in app/src/console/staff.rs, registered in with_commands. It is PR (b) of the staff tooling work. It doesn't depend on #145 (/mcp/admin).

Arguments are the old ones as clap options: Loco's email:x becomes --email x.

Command What it does Idempotent Refuses
user:set-staff --email <addr> --staff <true|false> Sets users.staff. Email matching ignores case. yes an unknown user (no user …), or --staff that isn't true/false
org:add-member --org <slug> --user <email or forge login> [--role admin|member|read] Adds the user with source = staff, or takes over an existing membership: sets the role and source staff, and clears synced_at so the forge sync leaves it alone. A new member gets the "added to org" email once, as the old grant did. Role defaults to member. yes a bad role, an unknown org, an unknown user
org:set-plan --org <slug> --plan <free|team|staff> Sets the plan. Team set here is comped. yes a bad plan, an unknown org
org:delete --org <slug> Deletes an empty organization and its Stripe customer. (second run: no organization) an org with projects, with a subscription, or whose Stripe customer has subscriptions or invoices; one with a Stripe customer when Stripe isn't configured
stripe:setup billing::stripe::ensure_catalog (products, prices, portal configuration) yes Stripe not configured

Tests: app/tests/staff_commands.rs covers each command's change, a repeat run, and each refusal. Writing them caught a NULL-decoding bug in the user lookup, fixed here. Stripe's API calls (deleting a customer, the catalog) aren't exercised; the tests cover the refusals that come before them.

Gates (build box): cargo fmt --all --check, cargo clippy --locked --workspace --all-targets -- -D warnings and cargo test --locked --workspace all pass. One earlier run had 5 api_builds failures that didn't recur on the rerun and aren't in code this PR touches; I didn't keep their panic messages.

Docs: docs/deploy.md's Commands section lists the commands, replacing the "no app/ command: … by hand" note that #132 added.

VisualCI build: no visual or JSON changes expected.


Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

Review fix (second commit)

user:set-staff --staff false now revokes the user's OAuth connections that hold the admin scope (revoke_admin_connections). It marks the connection (family) revoked, so its access and refresh tokens stop working, and so does a code not yet exchanged for tokens. Their mcp connections are left alone. The command prints how many it revoked.

/mcp/admin (#145) already re-checks users.staff on every call, so this is defence in depth: the tokens themselves become useless. Before #145 there are no admin tokens to revoke.

Test: user_set_staff_false_revokes_admin_connections covers an admin token, an mcp token and a pending admin code. The admin token and the code are revoked, the mcp one isn't, and a second run revokes 0.

Gates on the build box: fmt, clippy -D warnings and cargo test --locked --workspace all pass.

ndbroadbent and others added 2 commits December 4, 2026 07:53
…t-staff, org:add-member, org:set-plan, org:delete, stripe:setup (sc-8900)

Co-authored-by: Claude <noreply@anthropic.com>
…nections (sc-8900)

Co-authored-by: Claude <noreply@anthropic.com>
@ndbroadbent
ndbroadbent merged commit bc795a9 into main Dec 3, 2026
14 checks passed
@ndbroadbent
ndbroadbent deleted the app-staff-commands branch December 3, 2026 19:05
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