thread-centric routing, spaces/profiles, registry/invites, and maintenance tooling#64
thread-centric routing, spaces/profiles, registry/invites, and maintenance tooling#64deathbyknowledge wants to merge 6 commits intomainfrom
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ff7a7c1233
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| if (params.modeHint === "me") { | ||
| return "per-user"; | ||
| } | ||
| if (params.peerKind === "dm") { | ||
| return params.dmDefaultMode; | ||
| } |
There was a problem hiding this comment.
Honor /group mode override when resolving thread mode
parseModeHint recognizes /group, but determineThreadMode only branches on "me", so a /group message never changes routing and just falls back to the bound/default mode. In conversations configured as per-user-in-group (or any future non-shared default), users cannot force a shared thread despite the explicit override path being wired in parseModeHint, which makes the new routing controls inconsistent.
Useful? React with 👍 / 👎.
| if (!threadId) { | ||
| threadId = crypto.randomUUID(); | ||
| migrated += 1; |
There was a problem hiding this comment.
Preserve thread ID when backfilling thread-scoped sessions
When backfilling an entry whose state identity is already thread:<id> but threadId is missing, this branch generates a fresh random threadId instead of reusing <id>. That breaks the expected 1:1 mapping between stateId and thread identity, and can leave existing metadata/routes keyed by the original thread ID unreachable (for example threadRef=id:<id> lookups after migration).
Useful? React with 👍 / 👎.
Summary
This PR completes the thread-centric multi-tenant redesign for GSV and migrates routing from a session-key-centric model to explicit runtime identities:
principalId(who sent)surfaceId(where it was sent)spaceId(tenant/state/policy boundary)agentId(persona/runtime)threadId(logical thread identity)stateId(execution identity / Session DO identity)It adds a registry-backed router, membership-aware authorization, onboarding/invite flows, migration/repair tooling, CLI + UI support, and broad test coverage.
Why this change
sessionKeywas carrying too many responsibilities (routing hint, state identity, and implicit tenant boundary). This created ambiguity and leakage risks in multi-user/group scenarios. This PR separates those concerns and makes routing + policy decisions explicit and enforceable.What changed
1) Core routing and state model
gateway/src/gateway/thread-routing.tsgateway/src/gateway/thread-state.ts(spaceId, agentId, threadId, stateId).stateIdsupports both:legacySession:<sessionKey>) with no-fork legacy execution identitythread:<threadId>)2) Registry store and tenant bindings
gateway/src/gateway/registry-store.ts3) Membership and authorization
gateway/src/gateway/authz.tsgsv__SessionSendgsv__SessionsList4) Onboarding + invite lifecycle
gateway/src/gateway/invites.ts/claim <code>):gateway/src/gateway/channel-inbound.ts5) RPC surface updates
gateway/src/protocol/methods.tsgateway/src/gateway/rpc-handlers/registry.tsgateway/src/gateway/rpc-handlers/index.tsgateway/src/gateway/rpc-registry.tssessionKey | threadRefpaths where applicable.6) Migration + repair tooling
registry.backfillregistry.repairgateway/src/gateway/registry-maintenance.ts7) CLI support
gsv registry principal ...gsv registry member ...gsv registry conversation ...gsv registry pending ...gsv registry invite ...gsv registry maintenance backfillgsv registry maintenance repaircli/src/main.rscli/src/commands.rscli/src/gateway_client.rs8) UI support
gateway/ui/src/ui/gateway-client.tsgateway/ui/src/ui/types.tsgateway/ui/src/react/views/PairingView.tsxgateway/ui/src/react/views/ChatView.tsxgateway/ui/src/react/views/SessionsView.tsxgateway/ui/src/react/state/store.ts9) Tool schema compatibility fix
gsv__SessionSendtool schema to remove top-level combinator usage rejected by OpenAI function schema validation.sessionKey || threadRefrequirement.Backward compatibility and migration
no-forkbehavior).sessionKeytargeting remains supported.Reviewer guide (recommended order)
A. Architecture and intent
SPEC.mdTODOS.mdB. Core runtime model
gateway/src/gateway/registry-store.tsgateway/src/gateway/thread-state.tsgateway/src/gateway/thread-routing.tsgateway/src/gateway/do.tsC. Policy and execution safety
gateway/src/gateway/authz.tsgateway/src/gateway/tool-executors.tsgateway/src/agents/tools/sessions.tsD. API layer
gateway/src/protocol/methods.tsgateway/src/gateway/rpc-handlers/registry.tsgateway/src/gateway/rpc-handlers/session-target.tsgateway/src/gateway/rpc-handlers/session.tsgateway/src/gateway/rpc-handlers/chat.tsE. Operator surface
cli/src/main.rscli/src/commands.rscli/src/gateway_client.rsF. UI surface
gateway/ui/src/react/views/PairingView.tsxgateway/ui/src/react/views/SessionsView.tsxgateway/ui/src/react/views/ChatView.tsxG. Tests
gateway/src/gateway/thread-routing.test.tsgateway/src/gateway/registry-maintenance.test.tsgateway/src/gateway/authz.test.tsgateway/src/gateway/invites.test.tsgateway/src/gateway/rpc-handlers/session-target.test.tsValidation run
Executed during this branch development:
gateway:bunx tsc --noEmitgateway: targeted Vitest suites for authz/tools/invites/session-target/routing/maintenancecli:cargo checkcli:cargo fmt --checkgateway/ui:npm run checkgateway e2e:npm run test:e2e -- --filter "Channel Mode"Commit map
For reviewers preferring incremental history:
a67a227fix session send tool schema compatibilitya8dd3f6add registry maintenance rpc methodsc28886badd registry maintenance cli commands4bf6842add routing and registry maintenance coverageff7a7c1complete thread-centric profile and routing implementation