~ knotless Search/
↑↓ move↵ open⇧↵ all results
0
0

profile set and role grant change only what they are given

Merged
Merged chadtmiller.com asked to merge into main from chadtmiller.com/group-host:commands/partial

What changes

profile set and profile_set change only what they are given. The command and its tool read the profile as it is, set each field given, take away a field given empty ("", an empty list, or null), and write the rest back unchanged, pictures included. Neither requires a display name or join policy any more. The host reads the record directly; the command reads it through listSpaceRecords, which keeps the blob references whole.

role grant and role_grant add to a role's grant. The scopes and assignable roles given are added to what the role had, each once. With --undo (undo) they are taken away; with none named, or none left, the grant goes.

Why

Replacing the record whole made opensocial profile set riders --description … drop the avatar and every other field not repeated, and made adding one scope mean listing them all. Command lines usually edit the fields given (gh repo edit) and add or remove items in a list (gh pr edit --add-label), and an MCP client filling in a tool's parameters is the caller most likely to leave fields out.

How it was checked

  • group-host-mcp: the plans for both tools, edited keeping what is not given and taking away what is given empty, and regrant adding once, taking away, and dropping a grant left empty.
  • group-host tests/mcp.rs: profile_set keeps the rest of the profile, and a field given empty is taken away.
  • opensocial tests/commands.rs: profile set across three calls, --topics "" taking topics away; role grant adding two scopes to member and --undo taking one back.
  • fmt, clippy, harness/docs.mjs, harness/lexicons.mjs. The coverage gate is left to CI.

Shortcomings

The read and the write are two steps, with no swapRecord between them, so a change made in between is overwritten, as the console's settings page does today. rule set and role set still replace their record whole.

🤖 Generated with Claude Code

Approved

This makes profile set/profile_set and role grant/role_grant change only what they are given. profile_set now plans an Edit, and edited merges the given fields into the record as it is. Null, "" and [] take a field away, and unset fields and blob references are kept. regrant now adds scopes and assignable roles once each, --undo takes them away, and the grant is dropped when nothing is named or nothing is left. The host and the CLI both read the current record before writing. The docs, the usage text and the tests were updated with the code, as AGENTS.md asks. I found nothing that must change.

Two small things, neither blocking:

  • In typed, the new _ if value.is_empty() => Value::Null arm applies to every non-string, non-list, non-bool flag in every command. Before, --order "" on rule set was a "wants JSON" error; now it sends null. It only matters for the commands that take such flags.
  • The host test and the CLI test don't have an avatar blob in the profile, so keeping a blob reference whole is only covered by the unit test in protocol.rs. The PR body claims pictures survive. A test that sets an avatar and then runs profile set --description would pin that down.

I did not check CI results.

Merged as 4920cc1