Skip to content

Move J5's client-facing actions onto WebSocket methods #506

Closed

Description

@Jacksondr5

Direction (Jackson, 2026-10-09)

J5's client-facing actions move from J5's own HTTP routes onto WebSocket RPC methods, which is where upstream puts client mutations and where upstream's permission checks, scope middleware and instrumentation apply. Designed together with #137 (typed HTTP for J5 routes, which this may make unnecessary) and #182 (one change stream per environment to replace the J5 read polls).

Where J5 is

Transport Count What is on it
J5's own HTTP routes 37 The older features: Inbox, Fleet, Crews, sidebar reads, archive preflight, artifacts list/read/delete, the playbook library, peering, machine senders
WebSocket methods 32 The newer features: personas (18), skills (11), playbooks (2), the artifact change stream (1)

The split is historical. The older features were built as HTTP routes so they would not touch upstream's WebSocket contract. J5 RPC groups now merge into WsRpcGroup through one seam and their handlers live in J5-owned apps/server/src/j5/wsRpc.ts, so more J5 methods cost no new upstream edits.

The gap that prompted this

Found twice in review of the upstream advance (#500). Upstream's convention, now in AGENTS.md under Taste: client mutations use createEnvironmentRpcCommand, protected methods are listed in CLIENT_GUARDED_RPC_SCOPES (packages/contracts/src/clientRpcPermissions.ts), the command's permissionAtom drives whether a control is available, and grants are checked again at execution. In #500, J5's controls are hidden or disabled by the session's scopes, which is interface gating only:

  • Already on the helper, not registered. J5's persona actions use createEnvironmentRpcCommand, but no J5 method is in the guard map, so the helper computes an empty scope requirement and checks nothing.
  • Not on the helper at all. Crew proposal approve and decline, Crew archive and stop, a seat's runtime-request answer, Inbox answers, and playbook delete and rename call J5's HTTP routes through the unguarded createEnvironmentCommand (packages/client-runtime/src/j5/state.ts). The guard map is keyed by WebSocket method, so there is nothing to register them with.
  • Visible effect. A sheet that is already open keeps its submit button if the session's grants are narrowed meanwhile (seen in the mobile persona create and edit sheets). The server refuses, so this is an error message, not an authorization hole.

Work

  1. Register what is already RPC. One J5 spread into CLIENT_GUARDED_RPC_SCOPES for J5's protected methods; switch those controls to the commands' permissionAtom; extend the permission behavior tests as AGENTS.md asks.
  2. Move client-facing mutations to RPC, then register them the same way: Crew proposal preview and resolve, Crew archive and stop, runtime-request answers, Inbox answers, playbook library writes, artifact delete, peering management from the client.
  3. Reads, with feat(j5): one change stream per environment to replace the J5 read polls #182: replace the polls with the change stream and move the reads it leaves.
  4. Retire what is left over: the raw HTTP helper in upstream's environmentHttpAuth.ts (FORK.md case 34) once no J5 caller needs it, and refactor(j5): move Squadron and inbox routes to a typed HttpApiGroup #137 if nothing remains for it.

Stays on HTTP

  • Peer-server routes: another server calls them with its own credential.
  • Machine-sender routes: scripts and cron jobs call them with a token.
  • The MCP endpoint.

To check

  • Each route for a reason it must be HTTP (response size, use before the socket is up). The archive preflight and the sidebar reads first.
  • Older clients call the HTTP routes: either keep the routes for a release, or require clients and server to update together, as the ledger re-key did (register D29).

Activity

  1. changed the title [-]J5's client mutations have no execution-time permission check[/-] [+]Move J5's client-facing actions onto WebSocket methods[/+] on Oct 10, 2026
  2. Jacksondr5 commented on Oct 10, 2026

    @Jacksondr5
    OwnerAuthor

    For step 3 (reads): apps/server/src/j5/playbooks/playbookRpc.ts resolves the project or thread workspace in the handler file (inWorkspace, via resolvePlaybookWorkspaceRoot) before calling PlaybookStore, for export, delete and rename. The library's HTTP reads use the same helper. When those reads move, put the lookup behind one workspace-scoped playbook service so each handler calls one method, as docs/internals/effect-services.md asks. Raised in review of #524.

  3. Jacksondr5 commented on Oct 13, 2026

    @Jacksondr5
    OwnerAuthor

    Step 3 is in review as a two-PR stack (GitHub stack pingdotgg#587):

    Decided with Jackson, 2026-10-11: follow upstream's own rule. A small read is a socket query; a large, compressible payload stays on HTTP. So reading one artifact's content stays an HTTP route (it can be megabytes).

    What that leaves for step 4

    Left alone on purpose

    • The peer list's 30-second timer: peering has no change signal.
    • The playbook board's 30-second timer while a run is active: a playbook file edit has no signal.
    • A server without j5ProjectLedger is still asked the sidebar's row reads, the archive preflight and the artifact list, and answers "Unknown request tag", as it answered 404 before.
  4. Jacksondr5 commented on Oct 13, 2026

    @Jacksondr5
    OwnerAuthor

    Update: the two timers listed above as left alone are removed by a third PR on the stack, #593, at Jackson's request. It adds a peers revision to the change stream and has the playbook store watch the definition files of active runs. After the stack, J5's client code has no read timers. Still left alone: a server without j5ProjectLedger being asked the sidebar's row reads, the archive preflight and the artifact list.

  5. Jacksondr5 commented on Oct 13, 2026

    @Jacksondr5
    OwnerAuthor

    Done. Steps 1 and 2 landed in #524, step 3 in #584, #586 and #593. For step 4, Jackson decided on 2026-10-13 to keep the raw HTTP helper (FORK.md case 34) for its one remaining caller, the read of an artifact's content, and #137 is closed with that decision. J5's client code has no read timers, and the only J5 routes left on HTTP are artifact read, the peer-server routes, the machine-sender routes and the three the j5 a2a peer CLI calls.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions