Skip to content

docs: session learnings – key recovery, reactions, E2EE troubleshooting#15

Merged
CybotTM merged 5 commits intomainfrom
fix/session-learnings
Mar 5, 2026
Merged

docs: session learnings – key recovery, reactions, E2EE troubleshooting#15
CybotTM merged 5 commits intomainfrom
fix/session-learnings

Conversation

@CybotTM
Copy link
Member

@CybotTM CybotTM commented Mar 5, 2026

Summary

Captures lessons learned from multiple E2EE debugging sessions:

  • Fix matrix-fetch-keys.py – Add line buffering for non-interactive contexts (Claude Code)
  • SKILL.md – Add key recovery commands, "Reading Room History" section, E2EE troubleshooting table
  • e2ee-guide.md – Fix misleading [Unable to decrypt] info (it's recoverable!), document --import-keys flag, add decision tree, troubleshooting table, matrix-nio#218 note, Element X compatibility warning
  • messaging-guide.md – Add "Reading Reactions" section with JSON analysis guidance and polls/attendance use case
  • api-reference.md – Add reaction, key backup, and account_data endpoints; add m.reaction event type
  • setup-guide.md – Add optional Step 8 for key backup setup, note on line buffering

Key Changes

Misleading documentation fixed

Previously, e2ee-guide.md stated [Unable to decrypt] was "normal E2EE behavior" with no remedy. In reality, key backup restore (--import-keys) recovers these messages. Now includes a decision tree and clear recovery steps.

Missing CLI flags documented

  • --import-keys on matrix-key-backup.py (critical for actually saving restored keys)
  • --listen mode on matrix-e2ee-verify.py

New content

  • Reactions analysis section with JSON structure and programmatic filtering
  • E2EE troubleshooting tables (both SKILL.md and e2ee-guide.md)
  • API reference for reactions, key backup, and account_data endpoints

@gemini-code-assist
Copy link

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request delivers substantial improvements to the Matrix communication skills documentation and underlying scripts. It focuses on clarifying complex E2EE concepts, particularly around key recovery and troubleshooting, making it easier for users to manage encrypted messages. The update also introduces comprehensive guidance on handling message reactions and expands the API reference for related functionalities. Furthermore, script stability in various execution environments has been enhanced through targeted fixes.

Highlights

  • Improved E2EE Key Recovery and Troubleshooting: The documentation for End-to-End Encryption (E2EE) has been significantly enhanced, providing clearer guidance on recovering keys for undecryptable messages, including a decision tree and explicit instructions for using the --import-keys flag with matrix-key-backup.py.
  • Enhanced Messaging Guide with Reactions: A new section has been added to the messaging guide, detailing how reactions work within Matrix, their JSON structure, programmatic analysis, and practical use cases like polls and attendance tracking.
  • Expanded API Reference: The API reference now includes endpoints for sending reactions, retrieving account data (such as key backup passphrase information), and managing key backups, along with documentation for the m.reaction event type.
  • Script Reliability Improvements: Addressed stdout buffering issues in matrix-fetch-keys.py and other scripts by implementing line buffering, preventing output from hanging in non-interactive environments.
  • Documented Missing CLI Flags: Critical CLI flags like --import-keys for matrix-key-backup.py and --listen mode for matrix-e2ee-verify.py have been properly documented, improving usability and clarity for script execution.
Changelog
  • skills/matrix-communication/SKILL.md
    • Added commands for fetching missing keys and restoring keys from server backup.
    • Introduced a 'Reading Room History' section with notes on key sync and message decryption.
    • Included an E2EE troubleshooting table covering common issues like '[Unable to decrypt]' and script hanging.
  • skills/matrix-communication/references/api-reference.md
    • Added API endpoints for sending reactions, retrieving account data (e.g., key backup info), and managing key backups.
    • Documented the m.reaction event type.
  • skills/matrix-communication/references/e2ee-guide.md
    • Clarified the meaning and recovery process for '[Unable to decrypt]' messages, including a decision tree.
    • Emphasized the --import-keys flag for matrix-key-backup.py.
    • Documented the --listen mode for matrix-e2ee-verify.py.
    • Added a comprehensive E2EE troubleshooting section and noted Element X compatibility.
    • Updated limitations regarding matrix-nio's native key backup support.
  • skills/matrix-communication/references/messaging-guide.md
    • Added a new section explaining how reactions work, their JSON structure, and programmatic analysis.
    • Provided a use case for reactions in polls and attendance tracking.
  • skills/matrix-communication/references/setup-guide.md
    • Added an optional Step 8 for key backup setup.
    • Included a note on line buffering for scripts in non-interactive contexts.
  • skills/matrix-communication/scripts/_lib/config.py
    • Applied code formatting for improved readability.
  • skills/matrix-communication/scripts/_lib/e2ee.py
    • Applied code formatting for improved readability.
  • skills/matrix-communication/scripts/_lib/formatting.py
    • Updated regex patterns for various markdown-to-HTML conversions to use double quotes consistently.
    • Adjusted code block, spoiler, link, mention, strikethrough, bold, italic, inline code, and newline processing.
    • Modified heading prefix logic.
  • skills/matrix-communication/scripts/_lib/http.py
    • Applied code formatting for improved readability.
  • skills/matrix-communication/scripts/_lib/rooms.py
    • Applied code formatting for improved readability.
  • skills/matrix-communication/scripts/_lib/utils.py
    • Applied code formatting for improved readability.
  • skills/matrix-communication/scripts/matrix-doctor.py
    • Removed unused import os.
    • Applied code formatting for improved readability.
    • Added noqa: F401 for unused imports.
  • skills/matrix-communication/scripts/matrix-e2ee-setup.py
    • Applied code formatting for improved readability.
  • skills/matrix-communication/scripts/matrix-e2ee-verify.py
    • Removed unused import json.
    • Added import socket and import secrets to correct scope.
    • Applied code formatting for improved readability.
    • Adjusted logic for sas.other_device_id and sas.other_olm_device.device_id.
    • Improved readability of multi-line print statements for verification emojis.
  • skills/matrix-communication/scripts/matrix-edit-e2ee.py
    • Applied code formatting for improved readability.
    • Changed generic except: to except Exception: for better error handling.
  • skills/matrix-communication/scripts/matrix-edit.py
    • Applied code formatting for improved readability.
  • skills/matrix-communication/scripts/matrix-fetch-keys.py
    • Added line buffering for sys.stdout and sys.stderr to prevent hanging in non-interactive contexts.
    • Applied code formatting for improved readability.
  • skills/matrix-communication/scripts/matrix-key-backup.py
    • Removed unused import struct.
    • Applied code formatting for improved readability.
    • Adjusted HKDF salt and info parameters.
    • Corrected MAC comparison logic.
  • skills/matrix-communication/scripts/matrix-react.py
    • Applied code formatting for improved readability.
  • skills/matrix-communication/scripts/matrix-read-e2ee.py
    • Applied code formatting for improved readability.
  • skills/matrix-communication/scripts/matrix-read.py
    • Applied code formatting for improved readability.
  • skills/matrix-communication/scripts/matrix-redact.py
    • Applied code formatting for improved readability.
  • skills/matrix-communication/scripts/matrix-resolve.py
    • Removed unused import matrix_request.
    • Applied code formatting for improved readability.
  • skills/matrix-communication/scripts/matrix-rooms.py
    • Applied code formatting for improved readability.
  • skills/matrix-communication/scripts/matrix-send-e2ee.py
    • Added import socket and from nio import KeysUploadResponse to correct scope.
    • Applied code formatting for improved readability.
  • skills/matrix-communication/scripts/matrix-send.py
    • Applied code formatting for improved readability.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request primarily focuses on enhancing the Matrix communication skill's documentation and E2EE (End-to-End Encryption) key management. Key changes include adding documentation for matrix-fetch-keys.py and matrix-key-backup.py scripts, along with new sections on 'Reading Room History' and 'E2EE Troubleshooting' in SKILL.md. The e2ee-guide.md is significantly updated to clarify slow initial syncs, provide a decision tree for decrypting messages, detail server-side key backup, and introduce a new troubleshooting table. API documentation for reactions and key backup is added to api-reference.md, and messaging-guide.md now includes a comprehensive section on 'Reading Reactions' and their programmatic analysis. A new optional step for key backup recovery is added to setup-guide.md. Minor code formatting and linting fixes are applied across several Python scripts (_lib/config.py, _lib/e2ee.py, _lib/formatting.py, _lib/http.py, _lib/rooms.py, _lib/utils.py, matrix-doctor.py, matrix-e2ee-setup.py, matrix-e2ee-verify.py, matrix-edit-e2ee.py, matrix-edit.py, matrix-fetch-keys.py, matrix-key-backup.py, matrix-react.py, matrix-read-e2ee.py, matrix-read.py, matrix-redact.py, matrix-resolve.py, matrix-rooms.py, matrix-send-e2ee.py, matrix-send.py), including changing except: to except Exception: for better error handling and adding line_buffering=True to matrix-fetch-keys.py for improved output in non-interactive environments. Review comments highlighted the need to set restrictive file permissions (0o600) for the sensitive backup_key.json file in matrix-key-backup.py and to log exceptions more explicitly when debug is enabled in matrix-edit-e2ee.py for better debugging.

CybotTM added 2 commits March 5, 2026 07:46
…ooting

- Add line buffering to matrix-fetch-keys.py for non-interactive contexts
- SKILL.md: add key recovery commands, room history section, E2EE troubleshooting table
- e2ee-guide.md: fix misleading "Unable to decrypt" info, document --import-keys flag,
  add --listen mode, add troubleshooting table, note matrix-nio #218 limitation
- messaging-guide.md: add "Reading Reactions" section with JSON analysis guidance
- api-reference.md: add reaction, key backup, and account_data endpoints
- setup-guide.md: add optional key backup setup step, note on line buffering

Signed-off-by: Sebastian Mendel <sebastian.mendel@netresearch.de>
Signed-off-by: Sebastian Mendel <info@sebastianmendel.de>
- Set 0o600 permissions on backup_key.json (sensitive crypto material)
- Log device verification exceptions when debug mode is enabled

Signed-off-by: Sebastian Mendel <sebastian.mendel@netresearch.de>
Signed-off-by: Sebastian Mendel <info@sebastianmendel.de>
@CybotTM CybotTM force-pushed the fix/session-learnings branch from 624352b to 7632535 Compare March 5, 2026 06:46
CybotTM added 3 commits March 5, 2026 07:49
- Set 0o600 permissions on backup_key.json (sensitive crypto material)
- Log device verification exceptions when debug mode is enabled
- Condense SKILL.md to stay under 500 word CI limit

Signed-off-by: Sebastian Mendel <sebastian.mendel@netresearch.de>
Signed-off-by: Sebastian Mendel <info@sebastianmendel.de>
Signed-off-by: Sebastian Mendel <sebastian.mendel@netresearch.de>
Signed-off-by: Sebastian Mendel <info@sebastianmendel.de>
Signed-off-by: Sebastian Mendel <sebastian.mendel@netresearch.de>
Signed-off-by: Sebastian Mendel <info@sebastianmendel.de>
@CybotTM CybotTM merged commit b7af62a into main Mar 5, 2026
5 checks passed
@CybotTM CybotTM deleted the fix/session-learnings branch March 5, 2026 07:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant