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

Commands are grouped, and each MCP tool is its command's twin

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

What changes

Commands are grouped. Every command of opensocial is opensocial <group> <action> <group> …, in ten singular groups: group (create, show, seed, move), profile (set), rule (set, delete), role (set, delete, grant), member (list, assign, eject), join (list, deny), invite (send, list), space (create, records), mod (list, history, resolve, label) and account (import). An opposite is --undo on the action (invite send --undo, role grant --undo, mod label --undo). opensocial --help lists them by group. No old names are kept: nobody uses the host yet. group-host move-host stands alone as it was: it is the host's one command.

Each MCP tool is its command's twin. There are 20 tools, each <group>_<action>, taking what the command takes but the group, its flags in snake case (--display-name, display_name). Both come from one list, TOOLS in crates/group-host-mcp/src/lib.rs: the tool's schema is made from the lexicon of what it asks or writes, the command reads its words by that schema, and plan says what a call comes to (a method asked, a record of the group's written, an invite written or taken back, a role's grant set or dropped), which the host carries out for an MCP client and the command for a person. The old tools are renamed, split or joined to match: getGroup is group_show, putProfile is profile_set, putRule/deleteRule are rule_set/rule_delete, putRole/deleteRole are role_set/role_delete, putPermissions (the whole record) is role_grant (one role's grant), putMembership/deleteMembership are member_assign/member_eject, sendInvite/takeBackInvite are invite_send and its undo, applyLabel/negateLabel are mod_label and its undo, listMembers is member_list, and the rest take their command's name. A moderation subject is given as text, a DID or an at:// URI with a cid, rather than the union. What either side lacked is added: every tool's command (profile set, rule, role, join, invite list, space, mod), and role_grant. Only group create, group seed, group move and account import have no tool: an MCP client acts in the one group it was connected to, and these make or move a group or an account.

The MCP side says MCP. The host's assistants.rs is mcp.rs, its tests tests/mcp.rs, its functions and types MCP-named (McpRequest, McpGrant, register_mcp_client, …), and its tables mcp_client, mcp_request and mcp_grant, renamed by a migration (the two tests that roll migrations back now undo a later rename too). getAuthorization's assistant is mcp, retracted in harness/lexicons.mjs with why (the console here was its only reader). The design page is docs/design/mcp.md. The console's copy says "AI app": "Your AI apps", "No AI apps connected", "An AI app calling itself …".

AGENTS.md says how to add one, in "Commands and tools". docs/reference/cli.md and docs/reference/mcp.md are laid out by group; mcp.md's tables name each tool's command and lexicon, and the docs site shows that lexicon under the tool (a record's fields too), as a tool's name is no longer its method's.

Why

The tools had grown as methods by their NSIDs beside record writes named for what they did, and matched the command in nothing; the command had seven words of its own. Grouping by what a command acts on gives a new one an obvious home, and making the tool and the command from one entry, carried out from one plan, keeps them from drifting.

The HTTP side of MCP stays in the host as mcp.rs rather than moving to group-host-mcp/src/http.rs: each of its steps is the host's (its store for clients, requests and grants; the console's approval page through getAuthorization; the router it asks itself through; the writes it makes as the group), so moving it would mean a trait over most of Host with one implementer. What is the MCP crate's (the protocol, the tools, the plans) is there.

How it was checked

Here: cargo fmt, clippy with warnings denied, the tests of group-host-mcp (the tool list, each schema, each plan, regrant), group-host --test mcp (each kind of plan carried out as the member, and refused as the host refuses), and opensocial's (the words read by each schema, every command in the usage, and the commands against the reference PDS: invites sent, listed and taken back, members assigned and ejected, join requests listed and denied, rules, roles, grants and the profile written, labels applied and taken back, history, resolving). node harness/lexicons.mjs, node harness/docs.mjs, node harness/layers.mjs, and the docs site's build. Left to CI: the coverage gate, svelte-check and the console's build, and e2e.

Shortcomings

role grant replaces a role's whole grant; to add one scope, give them all. A write replaces its record whole, so profile set drops a field not given, a picture with it. Anyone's prompts naming the old tools break at once.

🤖 Generated with Claude Code

Asked for changes

This pull groups the opensocial commands into ten groups. It makes each MCP tool the twin of its command, built from one TOOLS list with one plan per call. It also renames the host's assistant code and tables to mcp, with a migration, and updates AGENTS.md and the docs. The design looks sound and the docs are updated with it. The check, lexicons, docs, web and e2e runs pass. The test run fails at head 246f877, so the coverage gate has not passed. I read the failure and the migration it hits, not the whole 5k-line diff.

test fails because of the new migration. crates/group-host/tests/moderation.rs:737, keeps_what_was_resolved_escalated_and_noted_as_a_status_set, panics with no such table: assistant_client.

  • The test drops the mod_event columns, then sets user_version to MIGRATIONS.len() - 1 so that the last migration runs again.
  • That used to be the mod_event migration.
  • This pull appends the assistant_* to mcp_* rename after it, so the last migration is now the rename. Re-running it on a database that already has mcp_client fails.
  • Fix the test so it re-runs the mod_event migration. Use len() - 2, or better, find that migration by its content so the next appended migration doesn't break it again.
  • The coverage gate can't be judged until this passes.

Behaviour change to confirm: profile set drops a field it isn't given, including the picture. You say so under Shortcomings, but a person running opensocial profile set --display-name X will lose the avatar silently. Consider reading the current record and merging, or at least warning in the command's output.

Asked for changes

The migration-test failure from round 1 looks fixed, but the pull now conflicts with main, so no check has run on the new head.

  • Test fix (done). moderation.rs now finds the mod_event migration by its content. It renames the later tables back to their old names and resets user_version to that migration's position. The new IF EXISTS / IF NOT EXISTS on the index statements makes the rename migration safe to re-run. identity.rs now drops renamed tables as well. I read these two diffs and the head's conflict list, not the whole 5k-line change.
  • Conflict with main (blocking). The head conflicts at 1c5a313 in docs/design/assistants.md, docs/reference/mcp.md, harness/e2e/flows.spec.mjs, harness/lexicons.mjs, web/src/lib/organisms/ConnectedApps.svelte, web/src/routes/g/[handle]/+page.server.ts and web/src/routes/g/[handle]/+page.svelte.
    • Every workflow (check, test, lexicons, docs, web, e2e) failed at 0daabdc with this conflict error and ran nothing.
    • Whether the migration fix makes test pass is therefore still unverified.
    • main has changed the same MCP and console files this pull renames. Please rebase or merge main, and resolve mcp.md, lexicons.mjs and the console files carefully so nothing main added is dropped.
  • Still open from round 1: profile set drops the avatar. You list it under Shortcomings and did not change it. opensocial profile set --display-name X still silently erases the picture and any field not given. I'd still prefer reading the current record and merging, or printing a warning. I'm not blocking on this.

Once rebased and green, this should be ready.

Asked for changes

The merge with main is done and the checks now run. check, lexicons, docs, web and e2e pass at 30dc1b9. The test run fails at the coverage gate.

  • Migration-test fix (done). The round 1 mod_event migration failure is gone. The run reaches the coverage report.
  • Conflict with main (done). The head merges main cleanly and the workflows ran.
  • Coverage gate (blocking). .knotless/workflows/test.yml runs cargo llvm-cov --fail-under-lines 100 --fail-under-functions 100. The report ends with 2 functions and 2 lines missed. group-host/src/mcp.rs and opensocial/src/lib.rs each have 1 function and 1 line uncovered (totals: 99.92% functions, 99.99% lines). Both files are new or rewritten by this pull. Run --show-missing-lines locally to find them, then cover them with a test or remove dead code. The tail of the log I could read doesn't name the lines.
  • Still open from earlier rounds: profile set drops the avatar. It is unchanged and listed under Shortcomings. I'm not blocking on it.

I did not re-read the whole diff this round. I only checked the run results and the gate.

Approved

Every workflow now passes at 47a5e28: check, test, lexicons, docs, web and e2e. That includes the coverage gate I blocked on last round. The last commit, "No closure only a failure runs, in carrying out a plan", removed the two uncovered functions and lines.

Earlier asks:

  • Migration-test fix (done). It was done in round 2.
  • Conflict with main (done). It was done in round 3.
  • Coverage gate (done). test is green.
  • profile set drops the avatar and any field not given. This is unchanged. The pull lists it under Shortcomings and I never blocked on it. I'd still like a read-and-merge or a warning as a follow-up.

I did not re-read the whole diff this round. I only checked the run results.

Merged as 6ea2c17