--- gsd_state_version: 1.0 milestone: v1.0 milestone_name: — Production-ready surfaces status: Phase 04 multi-agent follow-up complete last_updated: "2026-04-24T14:10:00Z" progress: total_phases: 5 completed_phases: 2 total_plans: 12 completed_plans: 9 percent: 75 --- # State ## Project Reference See: .planning/PROJECT.md (updated 2026-04-02) **Core value:** Пользователь ведёт диалог с Lambda через любой мессенджер без изменения ядра **Current focus:** Phase 04 multi-agent routing follow-up fully implemented; ready for live validation or Phase 05 planning ## Current Phase **Phase 4** implementation complete: Matrix MVP + multi-agent routing All 5 tasks of the multi-agent routing follow-up are committed on `feat/matrix-direct-agent-prototype`: - `7627012` / `242f4aa` / `9ccba16` — agent registry loader, RoutedPlatformClient facade, fail-fast on missing registry in real mode - `a65227e` — dispatch chat_id contract alignment - `74cf028` — `!agent` command, `selected_agent_id` persistence, unbound-room binding on first selection - `7623039` — attachment normalization in core message handler - `e733119` — stale room blocking, `agent_id` binding on `!new`, durable restart state tests 135 Matrix tests pass. The branch is ready for review and merge. ## Decisions - Продолжаем с Threaded Mode несмотря на баги Mac клиента (2026-04-02) - Invite flow Matrix переведён на idempotent-проверку через `user_meta.space_id`, а не через invite-room metadata (2026-04-02) - Неизвестные Matrix rooms больше не auto-register в роутере; используется явный fallback `unregistered:{room_id}` с warning-логом (2026-04-02) - [Phase 01]: Use ChatContext.surface_ref as the Matrix room identifier for !rename updates. - [Phase 01]: Keep !archive limited to core archive state in Phase 1; Space child removal remains deferred. - [Phase 01]: Matrix OutgoingUI no longer emits reactions; confirmation state is persisted and resumed via `!yes` / `!no`. - [Phase 01]: `!settings` now renders a dashboard snapshot instead of advertising mutable subcommands. - [Phase 01]: Split Matrix regression coverage into dedicated invite/chat/send_outgoing/confirm test modules. - [Phase 01]: Kept 01-04 scoped to test coverage without widening into production-code changes. - [Phase 01]: Matrix command callbacks now include room_id in payload for !yes and !no so confirm handlers can resolve runtime state without changing core protocol types. - [Phase 01]: Pending confirmations are stored under the D-08 composite key of matrix user id plus room id, with a narrow legacy fallback only for callers that omit room context. - [Phase 01]: Removed Matrix reaction conversion entirely and kept command callbacks limited to !yes/!no. - [Phase 01]: Kept !settings as a pure snapshot surface while preserving mutable subcommands outside the dashboard. - [Phase 01]: Seeded invite and dispatcher tests with explicit next_chat_index and room ids instead of treating C1 as Matrix transport identity. - [Phase 04]: Replaced AgentSessionClient with AgentApiWrapper and persistent agent connection lifecycle in Matrix runtime. - [Phase 04]: Added !save, !load, !reset, and !context commands with pending-state interception and local prototype session metadata. - [Phase 04]: Added Matrix-only Docker packaging for MVP deployment; platform services remain external to this compose setup. - [Phase 04]: Replaced the Matrix prod path again with direct upstream `AgentApi` per request; removed the local runtime wrapper from the prod flow. - [Phase 04]: Adopted `AGENT_BASE_URL` as the primary runtime contract and kept `AGENT_WS_URL` only as backward-compatible env fallback. - [Phase 04 follow-up]: Kept shared PlatformClient unchanged; introduced Matrix-specific RoutedPlatformClient to avoid breaking Telegram adapter. - [Phase 04 follow-up]: agent_routing_enabled flag on MatrixRuntime activates stale-room check only in real multi-agent mode (RoutedPlatformClient). - [Phase 04 follow-up]: !new binds agent_id at room creation time using selected_agent_id from user metadata. - [Phase 04 follow-up]: platform_chat_seq (PLATFORM_CHAT_SEQ_KEY) is stored in SQLiteStore and survives restart — confirmed by test. ## Blockers - Lambda platform SDK не готов — Phase 2 заблокирована до готовности платформы ## Accumulated Context ### Roadmap Evolution - Phase 01.1 inserted after Phase 01: Matrix restart reconciliation and dev reset workflow (URGENT) - Phase 4 added: Matrix MVP: shared agent context and context management command - Phase 04 follow-up added inline: multi-agent routing (RoutedPlatformClient, !agent, stale room blocking, restart persistence) - New platform signal: upcoming proper `chat_id` support should enable file-level context separation and stronger context management in a future follow-up phase. ## Performance Metrics | Phase | Plan | Duration | Tasks | Files | Recorded | | --- | --- | --- | --- | --- | --- | | 01 | 01 | 1 min | 3 | 3 | 2026-04-02T19:50:50Z | | 01 | 02 | 1 min | 2 | 2 | 2026-04-02 | | 01 | 03 | 3 min | 2 | 5 | 2026-04-02T19:57:34Z | | 01 | 04 | 3 min | 2 | 7 | 2026-04-02T20:03:38Z | | 01 | 05 | 2 min | 2 | 7 | 2026-04-03T09:28:47Z | | 01 | 06 | 4 min | 2 | 7 | 2026-04-03T09:35:47Z | | 04 | 01 | 1 session | 1 wave | 8 | 2026-04-17 | | 04 | 02 | 1 session | 2 commits + summary | 8 | 2026-04-17 | | 04 | 03 | 1 session | 1 commit + summary | 4 | 2026-04-17 | | 04 | follow-up | 1 session | 5 tasks | 10+ | 2026-04-24 | ## Session - Last session: 2026-04-24T14:10:00Z - Stopped at: Phase 04 multi-agent follow-up fully committed (e733119); 135 tests green; branch feat/matrix-direct-agent-prototype ready for review/merge - Resume file: HANDOFF deleted; no pending tasks