surfaces/.planning/phases/01-matrix-qa-polish/01-06-PLAN.md
Mikhail Putilovskij 6ced154124 feat(matrix): land QA follow-ups and refresh docs
- harden Matrix onboarding/chat lifecycle after manual QA
- refresh README and Matrix docs to match current behavior
- add local ignores for runtime artifacts and include current planning/report docs

Closes #7
Closes #9
Closes #14
2026-04-05 19:08:58 +03:00

165 lines
9.3 KiB
Markdown
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
phase: 01-matrix-qa-polish
plan: 06
type: execute
wave: 2
depends_on: ["01-05"]
files_modified:
- adapter/matrix/reactions.py
- adapter/matrix/converter.py
- adapter/matrix/handlers/settings.py
- tests/adapter/matrix/test_converter.py
- tests/adapter/matrix/test_reactions.py
- tests/adapter/matrix/test_dispatcher.py
- tests/adapter/matrix/test_invite_space.py
autonomous: true
gap_closure: true
requirements: []
must_haves:
truths:
- "Matrix adapter no longer presents or parses reaction-era UX for confirmations or skill toggles."
- "A Matrix user who opens `!settings` sees a strict read-only snapshot without mutation prompts."
- "Matrix room behavior remains correct when chat ids are allocated dynamically instead of assuming legacy `C1` transport identity."
artifacts:
- path: "adapter/matrix/reactions.py"
provides: "Command-only Matrix helper text with no reaction numbering."
- path: "adapter/matrix/converter.py"
provides: "Matrix command conversion without reaction callback support."
- path: "tests/adapter/matrix/test_dispatcher.py"
provides: "Settings and invite regressions aligned to room-based Matrix behavior."
key_links:
- from: "adapter/matrix/reactions.py"
to: "tests/adapter/matrix/test_reactions.py"
via: "command-only skills/help text"
pattern: "!skill on/off"
- from: "adapter/matrix/handlers/settings.py"
to: "tests/adapter/matrix/test_dispatcher.py"
via: "strict read-only dashboard assertions"
pattern: "Изменить"
---
<objective>
Remove the remaining reaction-era Matrix UX, make `!settings` strictly read-only, and harden Matrix tests so they stop hiding dynamic or room-based behavior behind legacy `C1` assumptions.
Purpose: Verification still found user-facing reaction remnants and brittle tests that can pass while the actual adapter contract is wrong. This plan cleans those leftovers without rewriting Phase 01 history.
Output: Command-only Matrix adapter helpers, strict `!settings` snapshot output, and updated Matrix regressions aligned with room ids and dynamic chat allocation.
</objective>
<execution_context>
@/Users/a/.codex/get-shit-done/workflows/execute-plan.md
@/Users/a/.codex/get-shit-done/templates/summary.md
</execution_context>
<context>
@.planning/STATE.md
@.planning/ROADMAP.md
@.planning/phases/01-matrix-qa-polish/01-CONTEXT.md
@.planning/phases/01-matrix-qa-polish/01-VERIFICATION.md
@.planning/phases/01-matrix-qa-polish/01-03-SUMMARY.md
@.planning/phases/01-matrix-qa-polish/01-04-SUMMARY.md
@.planning/phases/01-matrix-qa-polish/01-05-PLAN.md
@adapter/matrix/reactions.py
@adapter/matrix/converter.py
@adapter/matrix/handlers/settings.py
@tests/adapter/matrix/test_converter.py
@tests/adapter/matrix/test_reactions.py
@tests/adapter/matrix/test_dispatcher.py
@tests/adapter/matrix/test_invite_space.py
<interfaces>
From `adapter/matrix/reactions.py`:
```python
def build_skills_text(settings: UserSettings) -> str
def build_confirmation_text(description: str) -> str
```
From `adapter/matrix/converter.py`:
```python
def from_room_event(event: Any, room_id: str, chat_id: str) -> IncomingEvent | None
```
From `adapter/matrix/handlers/settings.py`:
```python
async def handle_settings(
event: IncomingCommand, auth_mgr, platform, chat_mgr, settings_mgr
) -> list
```
</interfaces>
</context>
<tasks>
<task type="auto" tdd="true">
<name>Task 1: Remove reaction-era Matrix UX and update the immediately affected regressions</name>
<files>adapter/matrix/reactions.py, adapter/matrix/converter.py, adapter/matrix/handlers/settings.py, tests/adapter/matrix/test_reactions.py, tests/adapter/matrix/test_converter.py, tests/adapter/matrix/test_dispatcher.py</files>
<read_first>adapter/matrix/reactions.py, adapter/matrix/converter.py, adapter/matrix/handlers/settings.py, tests/adapter/matrix/test_reactions.py, tests/adapter/matrix/test_converter.py, tests/adapter/matrix/test_dispatcher.py, .planning/phases/01-matrix-qa-polish/01-CONTEXT.md</read_first>
<behavior>
- Test 1: `build_skills_text` renders only command-driven guidance and never mentions `1⃣..9️⃣`, `👍`, `❌`, or reaction lookup.
- Test 2: `converter.py` no longer treats Matrix reaction events as supported callbacks.
- Test 3: `handle_settings` returns a dashboard snapshot with skills/soul/safety/chats status and does not advertise `Изменить: !skills, !soul, !safety`.
</behavior>
<action>
Finish the cleanup promised by D-06, D-12, and the verification report, and rewrite the tests that would otherwise block the task from being executable. Remove reaction-only constants and lookup helpers from `adapter/matrix/reactions.py` if they are no longer needed, or reduce the module to text-formatting helpers only. Remove `from_reaction` support from `adapter/matrix/converter.py` and any imports that only exist for reaction handling. Update `handle_settings` so the primary dashboard is a strict read-only snapshot; it may still show current skills, soul, safety, and active chats, but it must not tell the user to mutate settings from that surface.
In the same task, update `tests/adapter/matrix/test_reactions.py`, `tests/adapter/matrix/test_converter.py`, and the `!settings` assertion in `tests/adapter/matrix/test_dispatcher.py` so the verify command matches the code you just changed. Do not leave those test rewrites for Task 2.
Do not remove the dedicated mutable subcommands themselves (`!skills`, `!soul`, `!safety`) because D-13 and D-14 explicitly keep them. The restriction applies only to the `!settings` dashboard copy.
</action>
<verify>
<automated>cd /Users/a/MAI/sem2/lambda/surfaces-bot && pytest tests/adapter/matrix/test_reactions.py tests/adapter/matrix/test_converter.py tests/adapter/matrix/test_dispatcher.py -q</automated>
</verify>
<acceptance_criteria>
- `adapter/matrix/reactions.py` contains no reaction-number skill labels or reaction lookup helpers in user-facing output.
- `adapter/matrix/converter.py` no longer exports or relies on `from_reaction`.
- `adapter/matrix/handlers/settings.py` no longer renders the mutation prompt in the `!settings` dashboard.
- `tests/adapter/matrix/test_reactions.py`, `tests/adapter/matrix/test_converter.py`, and the dashboard assertion in `tests/adapter/matrix/test_dispatcher.py` are updated in the same task.
- Mutable settings subcommands remain implemented outside the `!settings` snapshot.
</acceptance_criteria>
<done>Matrix adapter surfaces are command-only and `!settings` is strictly read-only.</done>
</task>
<task type="auto" tdd="true">
<name>Task 2: Remove the remaining brittle `C1` assumptions from room-based Matrix regressions</name>
<files>tests/adapter/matrix/test_dispatcher.py, tests/adapter/matrix/test_invite_space.py</files>
<read_first>tests/adapter/matrix/test_dispatcher.py, tests/adapter/matrix/test_invite_space.py, .planning/phases/01-matrix-qa-polish/01-VERIFICATION.md</read_first>
<behavior>
- Test 1: Invite tests assert dynamic chat allocation or stored metadata progression instead of assuming the canonical Matrix identifier is always `C1`.
- Test 2: Dispatcher regressions distinguish Matrix room ids from logical core chat ids and avoid using `C1` as a proxy for transport identity.
- Test 3: The full Matrix suite stays green after those room-based assertions are tightened.
</behavior>
<action>
Update the remaining Matrix regressions so they match the intended room-based adapter behavior. In invite and dispatcher tests, stop using `C1` as a stand-in for Matrix room identity where that hides dynamic behavior; instead assert against stored `room_meta`, `next_chat_index`, chat lists returned by the manager, or explicit non-`C1` setup values. Keep any remaining `C1` use only where the core chat manager contract itself is under test and not acting as a proxy for Matrix room ids.
Prefer small, explicit fixtures over broad rewrites. The tests should make it obvious which identifier is the Matrix `room_id` and which is the logical core `chat_id`. This task should only clean up the residual room-vs-chat assumptions that remain after Task 1's reaction/settings rewrites.
</action>
<verify>
<automated>cd /Users/a/MAI/sem2/lambda/surfaces-bot && pytest tests/adapter/matrix -q</automated>
</verify>
<acceptance_criteria>
- `tests/adapter/matrix/test_dispatcher.py` distinguishes room ids from chat ids in its Matrix-facing assertions.
- `tests/adapter/matrix/test_invite_space.py` validates dynamic chat metadata progression without hardcoding the phase outcome as `C1`.
- `pytest tests/adapter/matrix -q` passes after the updates.
</acceptance_criteria>
<done>The Matrix regression suite enforces command-only, room-based behavior and no longer masks defects with legacy assumptions.</done>
</task>
</tasks>
<verification>
Run `pytest tests/adapter/matrix -q` and confirm the full Matrix suite is green with no reaction-era behavior covered as supported flow.
Run `pytest tests/ -q` after the wave completes, per `01-VALIDATION.md`, and confirm the full repository suite remains green.
</verification>
<success_criteria>
- No Matrix adapter code parses or advertises reaction-era skill/confirmation UX.
- `!settings` is a strict snapshot surface.
- The full repository suite stays green after the Matrix gap-closure wave.
</success_criteria>
<output>
After completion, create `.planning/phases/01-matrix-qa-polish/01-06-SUMMARY.md`
</output>