feat(store): migrate local state to typed ids#245
Merged
Conversation
Collaborator
Author
Current migrated state examplesGenerated from the current local migrated store. Secret-bearing auth, token, and API key fields are redacted.
|
Collaborator
Author
Update
|
Collaborator
Author
|
@RussellLuo Fixed the review you gave me and did UTF-8 naming and other minor improvements. |
jialudev
pushed a commit
to jialudev/csgclaw
that referenced
this pull request
Jun 29, 2026
- consolidate durable data into state.json and keep IM topology in a separate lightweight store - move message history and thread context into dedicated session files - migrate local entities and directories to immutable typed IDs - update API, Web, and CLI surfaces for the new storage model
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
~/.csgclaw/state.jsonwithauth.opencsg,model_providers.items,agents.model_defaults,agents.items, andparticipants.items.~/.csgclaw/im/state.jsonwithcurrent_user_id, IM users, and room membership only.im/sessions/*.jsonland thread context inim/threads/<room_id>/<root_message_id>.json.agent-*,pt-*,user-*,room-*,team-*,msg-*,task-*, andapproval-*.model_config, IM-user avatars, user-based IM membership,MODELtable output, and full CLI table values without truncation.Current State Shape
The current migrated root store has these top-level sections:
{ "version": 1, "auth": { "opencsg": { "tokens": "<redacted>", "account": "<redacted>", "last_refresh": "<redacted>", "ai_gateway_builtin_api_key": "<redacted>" } }, "model_providers": { "items": { "claude_code": "<provider>", "codex": "<provider>", "csghub-lite": "<provider>", "default": "<provider>", "opencsg": "<provider>" } }, "agents": { "model_defaults": { "model_provider_id": "codex", "model_id": "gpt-5.5", "reasoning_effort": "medium" }, "items": [ { "id": "agent-zoyz2k", "name": "dev", "role": "worker", "runtime": { "kind": "codex", "state": "running", "sandbox_id": "<sandbox-id>" }, "model_config": { "model_provider_id": "codex", "model_id": "gpt-5.5", "reasoning_effort": "medium" } }, { "id": "agent-manager", "name": "manager", "role": "manager", "runtime": { "kind": "picoclaw_sandbox", "state": "running", "sandbox_id": "<sandbox-id>" }, "model_config": { "model_provider_id": "codex", "model_id": "gpt-5.5", "reasoning_effort": "medium" } } ] }, "participants": { "items": [ { "id": "pt-admin", "name": "admin", "type": "human", "channel": "csgclaw", "channel_user_kind": "local_user_id", "channel_user_ref": "user-admin", "lifecycle_status": "active", "mentionable": true }, { "id": "pt-manager", "name": "manager", "type": "agent", "agent_id": "agent-manager", "channel": "csgclaw", "channel_user_kind": "local_user_id", "channel_user_ref": "user-manager", "lifecycle_status": "active", "mentionable": true }, { "id": "pt-manager-ec18f310", "name": "manager", "type": "agent", "agent_id": "agent-manager", "channel": "feishu", "channel_user_kind": "app_id", "lifecycle_status": "active", "mentionable": true } ] } }The current migrated IM state is intentionally smaller and user-based:
{ "current_user_id": "user-admin", "users": [ { "id": "user-admin", "name": "admin", "role": "admin", "avatar": "avatar/pic-8.png", "is_online": true }, { "id": "user-zoyz2k", "name": "dev", "role": "worker", "avatar": "avatar/cartoon-8.png", "is_online": true }, { "id": "user-manager", "name": "manager", "role": "manager", "avatar": "avatar/cartoon-7.png", "is_online": true } ], "rooms": [ { "id": "room-1782371895502009000", "title": "all-members", "members": [ "user-admin", "user-zoyz2k", "user-manager", "user-dahym7", "user-eczpyv" ], "messages": "sessions/room-1782371895502009000.jsonl", "threads": "<lightweight thread refs>" }, { "id": "room-1782371840126766000", "title": "dev", "is_direct": true, "members": ["user-admin", "user-zoyz2k"], "messages": "sessions/room-1782371840126766000.jsonl", "threads": "<lightweight thread refs>" } ] }Full redacted examples for the current local
~/.csgclaw/state.jsonand~/.csgclaw/im/state.jsonare in this PR comment:#245 (comment)
Store Layout
~/.csgclaw/state.json: durable root app state, OpenCSG auth, model providers, compact agents, and participants.~/.csgclaw/agents/<agent-id>/: agent runtime directories keyed by immutableagent-*IDs, not display names.~/.csgclaw/im/state.json: IM users and room topology keyed by immutableuser-*androom-*IDs.~/.csgclaw/im/sessions/<room_id>.jsonl: message history.~/.csgclaw/im/threads/<room_id>/<root_message_id>.json: heavy thread context.~/.csgclaw/cliproxy-auth/: CLIProxyAPI-owned auth files moved out of the genericauth/directory.CLI And API Impact
model_configas the primary model selection contract.MODEL, related participant names and IDs, and full values without truncation.ID NAME ROLE ONLINE; local IM handles are removed.user-*IDs.Notice
Validation
main.