diff --git a/.planning/ROADMAP.md b/.planning/ROADMAP.md index 43f3e6b..0f7c692 100644 --- a/.planning/ROADMAP.md +++ b/.planning/ROADMAP.md @@ -8,13 +8,15 @@ **Depends on:** Telegram QA complete -**Plans:** 4 plans +**Plans:** 6 plans Plans: - [x] 01-01-PLAN.md — Space+rooms infrastructure (store helpers, handle_invite rewrite, room_router) - [x] 01-02-PLAN.md — Chat command handlers (!new, !archive, !rename) Space-aware - [x] 01-03-PLAN.md — Reaction removal + !yes/!no confirmation + settings dashboard -- [ ] 01-04-PLAN.md — Test suite (fix 4 broken + 12 new MAT-01..MAT-12) +- [x] 01-04-PLAN.md — Test suite (fix 4 broken + 12 new MAT-01..MAT-12) +- [x] 01-05-PLAN.md — Gap closure for Matrix `!yes` / `!no` pending-confirm scope +- [ ] 01-06-PLAN.md — Remaining Phase 01 gap closure work **Deliverables:** - Space+rooms architecture for Matrix adapter diff --git a/.planning/STATE.md b/.planning/STATE.md index 60d5d21..9cc9bdd 100644 --- a/.planning/STATE.md +++ b/.planning/STATE.md @@ -2,13 +2,13 @@ gsd_state_version: 1.0 milestone: v1.0 milestone_name: — Production-ready surfaces -status: in_progress -last_updated: "2026-04-02T19:57:34.111Z" +status: Executing Phase 01 +last_updated: "2026-04-03T09:28:47.448Z" progress: total_phases: 3 completed_phases: 0 - total_plans: 4 - completed_plans: 3 + total_plans: 6 + completed_plans: 5 --- # State @@ -18,7 +18,7 @@ progress: See: .planning/PROJECT.md (updated 2026-04-02) **Core value:** Пользователь ведёт диалог с Lambda через любой мессенджер без изменения ядра -**Current focus:** Phase 01 — matrix-qa-polish (next: 01-04) +**Current focus:** Phase 01 — matrix-qa-polish ## Current Phase @@ -33,6 +33,10 @@ See: .planning/PROJECT.md (updated 2026-04-02) - [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. ## Blockers @@ -45,8 +49,10 @@ See: .planning/PROJECT.md (updated 2026-04-02) | 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 | ## Session -- Last session: 2026-04-02T19:57:34Z -- Stopped at: Completed 01-03-PLAN.md +- Last session: 2026-04-03T09:28:47Z +- Stopped at: Completed 01-05-PLAN.md diff --git a/.planning/phases/01-matrix-qa-polish/01-05-SUMMARY.md b/.planning/phases/01-matrix-qa-polish/01-05-SUMMARY.md new file mode 100644 index 0000000..542f774 --- /dev/null +++ b/.planning/phases/01-matrix-qa-polish/01-05-SUMMARY.md @@ -0,0 +1,100 @@ +--- +phase: 01-matrix-qa-polish +plan: 05 +subsystem: matrix +tags: [matrix, confirmations, regression-testing, adapter] +requires: + - phase: 01-matrix-qa-polish + provides: Text confirmation flow and Matrix regression baseline from plans 01-03 and 01-04 +provides: + - Stable Matrix pending-confirm storage scoped by user id and room id + - Matrix command callbacks that retain originating room context + - Adapter-level confirm and cancel regressions covering send_outgoing round trips +affects: [matrix-adapter, matrix-tests, phase-01-closeout] +tech-stack: + added: [] + patterns: [Matrix callback payloads carry room context, pending confirmations are keyed by user id plus room id] +key-files: + created: + - .planning/phases/01-matrix-qa-polish/01-05-SUMMARY.md + modified: + - adapter/matrix/bot.py + - adapter/matrix/converter.py + - adapter/matrix/handlers/confirm.py + - adapter/matrix/store.py + - tests/adapter/matrix/test_converter.py + - tests/adapter/matrix/test_confirm.py + - tests/adapter/matrix/test_send_outgoing.py +key-decisions: + - "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." + - "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." +patterns-established: + - "Matrix adapter send paths must derive transport-specific identity from room metadata before writing adapter-local state." + - "Adapter regressions should use mismatched Matrix room ids and logical chat ids to catch scope drift." +requirements-completed: [] +duration: 2 min +completed: 2026-04-03 +--- + +# Phase 01 Plan 05: Matrix Confirmation Scope Summary + +**Matrix confirmations now survive the real send_outgoing -> !yes/!no adapter round trip by keeping pending state scoped to the Matrix user and Matrix room.** + +## Performance + +- **Duration:** 2 min +- **Started:** 2026-04-03T09:26:32Z +- **Completed:** 2026-04-03T09:27:55Z +- **Tasks:** 2 +- **Files modified:** 7 + +## Accomplishments + +- Aligned the Matrix adapter runtime so command callbacks keep room context and pending confirmation state uses the D-08 `(user_id, room_id)` scope. +- Added a compatibility fallback in confirm handlers for legacy callers that do not send `payload["room_id"]`. +- Added adapter-level regressions for `OutgoingUI` -> `!yes` and `OutgoingUI` -> `!no` using distinct Matrix room ids and logical chat ids. + +## Task Commits + +Each task was committed atomically: + +1. **Task 1: Preserve Matrix user-and-room identity through the `!yes` / `!no` callback path** - `35695e0` (fix) +2. **Task 2: Add end-to-end adapter regression tests for `send_outgoing` -> `!yes` / `!no`** - `716dec5` (test) + +## Files Created/Modified + +- `adapter/matrix/bot.py` - derives the Matrix user id from room metadata before persisting pending confirmations. +- `adapter/matrix/converter.py` - carries Matrix `room_id` in `IncomingCallback.payload` for `!yes` and `!no`. +- `adapter/matrix/handlers/confirm.py` - resolves pending confirmations by `(event.user_id, payload["room_id"])` with legacy fallback behavior. +- `adapter/matrix/store.py` - supports composite pending-confirm keys while remaining compatible with older single-key callers. +- `tests/adapter/matrix/test_converter.py` - asserts Matrix callbacks preserve logical `chat_id` and include `payload["room_id"]`. +- `tests/adapter/matrix/test_confirm.py` - validates composite-key confirm/cancel behavior and the legacy fallback path. +- `tests/adapter/matrix/test_send_outgoing.py` - exercises `send_outgoing` to confirm/cancel round trips under user-and-room scope. + +## Decisions Made + +- Kept the contract change inside the Matrix adapter by extending callback payloads instead of changing `core.protocol.IncomingCallback`. +- Preserved the old chat-id-only lookup only as a fallback path for older tests or non-room-aware callers. + +## Deviations from Plan + +None - plan executed exactly as written. + +## Issues Encountered + +None. + +## User Setup Required + +None - no external service configuration required. + +## Next Phase Readiness + +- The Phase 01 confirmation blocker from `01-VERIFICATION.md` is closed for the Matrix adapter runtime path. +- Phase 01 still needs the remaining plan work outside `01-05`, but this gap no longer blocks end-to-end `!yes` / `!no` behavior. + +## Self-Check: PASSED + +- Found `.planning/phases/01-matrix-qa-polish/01-05-SUMMARY.md` +- Found commit `35695e0` +- Found commit `716dec5`