Personal Telegram developer console for GitHub
feat/plugin-foundation-v1
audit/commit-drilldown
audit/finalize-workspace-menu-security
audit/ops-actionability
audit/pr-menu-consolidation
audit/status-menu-consolidation
audit/telegram-menu-e2e
audit/telegram-menu-e2e-wave2
chore/actions-node24-runtime
cleanup/remove-diag
design/cloudflare-ops-read
docs/control-plane-2-7-design
docs/guide-v2-1-sync
docs/menu-audit-final-sync
docs/phase2-acceptance-closeout
docs/phase2-multifile-design
feat/bootstrap-worker
feat/cloudflare-ops-read
feat/cp2-multifile-final
feat/cp2-multifile-workspace
feat/cp3-github-write-final
feat/cp4-cloudflare-ops-final
feat/cp5-cicd-control-plane
feat/cp6-incident-manager
feat/cp7-automation-engine
feat/deep-file-browser
feat/final-delivery-16-20
feat/github-advanced-read
feat/in-app-guide-v2
feat/navigation-recovery-ux-v2
feat/ops-console-v2-1
feat/persistent-menu-code-input
feat/phase2-multifile-workspace
feat/phase2-multifile-workspace-v2
feat/plugin-foundation-v1
feat/safe-github-ops
feat/self-register-webhook
feat/studio-g0-foundation
feat/telegram-main-inline-menu
feat/telegram-pr-merge
feat/ux-platform-8-12
feat/v3a-readonly-copilot
feat/workspace-file-upload
feature/mobile-repo-browser
feature/multi-file-change-set
fix/approval-expiry-feedback
fix/callback-resilience-and-docs
fix/ci-actions-pagination
fix/cloudflare-fetch-binding
fix/editor-request-body-cap
fix/editor-safe-file-options
fix/issues-permission-release-empty-ux
fix/main-menu-callback-fallback
fix/phase2-file-editor-selection
fix/phase2-final-ux
fix/phase2-workspace-ref-persistence
fix/production-auto-deploy
fix/provider-write-error-feedback
fix/repository-id-navigation-fallback
fix/repository-pr-navigation
fix/telegram-callback-updates
fix/telegram-runtime-diagnostics
fix/workspace-editor-flow-v2
fix/workspace-recovery-validation
hardening/ci-zero-test-telegram-token
hardening/pr1-destructive-totp
hardening/pr2-kill-switch
main
multifile-workspace
nexa/edit-BwJEIIY3PW
nexa/edit-IPHT8irO7b
nexa/edit-b4Od3BIMYd
p2-multifile
phase2-20261005
phase2-20261005-a
phase2-20261005-b
phase2-20261005-c
phase2-20261005-d
phase2-20261005-e
phase2-20261005-f
phase2-20261005-g
phase2-20261005-h
phase2-20261005-i
phase2-20261005-j
phase2-20261005-k
phase2-20261005-l
phase2-20261005-m
phase2-20261005-n
phase2-20261005-o
phase2-20261005-p
phase2-20261005-q
phase2-20261005-r
phase2-20261005-s
phase2-20261005-t
phase2-20261005-u
phase2-20261005-v
phase2-20261005-w
phase2-20261005-x
phase2-20261005-y
phase2-20261005-z
phase2-acceptance-closeout
phase2-add-file-hotfix
phase2-change-set
phase2-design-20261005
phase2-design-final
phase2-implementation
phase2-multifile-implementation
phase2-multifile-spec
phase2-spec-final
phase2-workspace
phase2/multifile-workspace
plan/nexa-studio-v2-reviewed
security/remove-telegram-setup
spec/repository-workspace-editor
v3a/multifile
work/multifile
| 1 | # PROJECT_MEMORY.md |
| 2 | |
| 3 | ## Project Identity |
| 4 | - Name: Nexa Dev Bot |
| 5 | - Repository: `davoodmehraban89/nexa-dev-bot` |
| 6 | - Canonical branch: `main` |
| 7 | - Visibility: private |
| 8 | - Purpose: owner-only Telegram developer console for GitHub visibility and controlled developer operations. |
| 9 | - This file is the continuity source of truth; live repository/runtime evidence overrides stale text. |
| 10 | |
| 11 | ## AI Handoff Protocol |
| 12 | 1. Read this file before changes. |
| 13 | 2. Verify repository head, recent commits, CI and relevant runtime evidence. |
| 14 | 3. Prefer live evidence over chat memory. |
| 15 | 4. Keep durable checkpoints documented here. |
| 16 | 5. Never store secrets, tokens or private keys in the repository. |
| 17 | |
| 18 | ## Architecture |
| 19 | - `src/index.js` — Cloudflare Worker HTTP boundary; webhook secret, owner authorization, required Telegram transport checks and redacted runtime diagnostics. |
| 20 | - `src/bot.js` — Telegram update/callback coordinator; constructs the plugin kernel, keeps callback acknowledgement best-effort, routes GitHub operations through policy, and retains compatibility paths for non-GitHub menus. |
| 21 | - `src/core/plugin-registry.js` — validates plugin/action manifests and rejects duplicate IDs or invalid risk values. |
| 22 | - `src/core/action-policy.js` — central `READ` / `WRITE` / `DESTRUCTIVE` policy evaluation. |
| 23 | - `src/core/audit.js` — best-effort structured action audit with recursive secret redaction. |
| 24 | - `src/core/router.js` — policy-enforcing plugin router using the security-critical `resolve -> policy -> execute` flow. |
| 25 | - `src/plugins/github/manifest.js` — GitHub plugin capability/action declarations. |
| 26 | - `src/plugins/github/plugin.js` — GitHub plugin adapter around existing `GitHubService` and `MenuManager` behavior. |
| 27 | - `src/telegram.js` — Telegram Bot API client; explicit error propagation, fail-closed token handling and Cloudflare-safe default `fetch` invocation. |
| 28 | - `src/github.js` — authenticated GitHub REST reader; explicit errors, numeric repository-id resolution, tree/blob access. |
| 29 | - `src/menu.js` — hierarchical stateless inline menus, one-message editing, repository/file browser. |
| 30 | - `src/config.js` — non-secret static config. |
| 31 | - `.github/workflows/ci.yml` — Node 22 tests, official GitHub Actions v7 releases and non-zero test-discovery guard. |
| 32 | - `.github/workflows/deploy.yml` — production Cloudflare Worker deploy after successful CI on `main`; deploys the exact verified commit. |
| 33 | - `wrangler.jsonc` — Worker configuration; `keep_vars: true`, workers.dev enabled and observability enabled. |
| 34 | |
| 35 | ## Runtime Configuration |
| 36 | Worker runtime names: |
| 37 | - `TELEGRAM_BOT_TOKEN` |
| 38 | - `TELEGRAM_WEBHOOK_SECRET` |
| 39 | - `OWNER_TELEGRAM_ID` |
| 40 | - `GITHUB_TOKEN` |
| 41 | - optional `GITHUB_OWNER` |
| 42 | |
| 43 | GitHub Actions deployment secrets: |
| 44 | - `CLOUDFLARE_API_TOKEN` |
| 45 | - `CLOUDFLARE_ACCOUNT_ID` |
| 46 | |
| 47 | ## Verified Security / Data Trust |
| 48 | - Webhook only at `POST /telegram/webhook`. |
| 49 | - Missing webhook secret, owner ID or bot token fails closed. |
| 50 | - Wrong Telegram secret returns 403. |
| 51 | - Non-owner updates are ignored before private-data access. |
| 52 | - GitHub token absence and GitHub API failures are explicit errors; no fabricated fallback data. |
| 53 | - Telegram network/API failures propagate; fake transport success is prohibited. |
| 54 | - Runtime diagnostic logs redact Telegram, webhook and GitHub secrets. |
| 55 | - Temporary setup/diagnostic exposure is disabled in source/tests. |
| 56 | - Operational UI does not invent SLA, latency or external health claims. |
| 57 | - Plugin manifests must declare action risk as `READ`, `WRITE`, or `DESTRUCTIVE`. |
| 58 | - Undeclared/unknown plugin actions are denied. |
| 59 | - `WRITE` and `DESTRUCTIVE` plugin actions are not executed before an approval flow exists. |
| 60 | - Plugin route resolvers must be side-effect-free; provider/view work is deferred to `execute()` after policy evaluation. |
| 61 | |
| 62 | ## Telegram UX / GitHub Reader |
| 63 | - `/start` creates the initial menu message. |
| 64 | - Callback navigation uses `editMessageText` on the same Telegram message. |
| 65 | - Callback acknowledgement failure/staleness no longer blocks in-place navigation. |
| 66 | - Main sections: Repositories, Status, Tools, Settings, Security. |
| 67 | - Repository sections: Files, Pull Requests, Commits, Actions status, Back. |
| 68 | - Back navigation and breadcrumb-style text exist. |
| 69 | - Repository callbacks use numeric GitHub repository IDs. |
| 70 | - Folder navigation uses `tree:<repoId>:<sha>` and file previews use `blob:<repoId>:<sha>`. |
| 71 | - Tree/blob SHA input is validated. |
| 72 | - File previews are HTML-escaped and bounded; oversized/non-base64 blobs are not rendered directly. |
| 73 | - Directory interactive entries are capped at 30 and omitted counts are disclosed. |
| 74 | |
| 75 | ## Production Deploy Automation — Verified 2026-10-02 |
| 76 | - PR `#10` added `.github/workflows/deploy.yml` and merged to `main` at `c86b86ec8f5678b9223b7bcb6a73e0377116e670`. |
| 77 | - GitHub repository secrets for Cloudflare deployment are configured. |
| 78 | - Re-run of deployment workflow `37057406559` passed credential preflight and deployed successfully. |
| 79 | - Automatic deploy now runs after successful `main` CI and uses the exact verified commit. |
| 80 | |
| 81 | ## Full Repository Audit + Telegram Runtime Incident — Verified 2026-10-02 |
| 82 | Audit scope covered the full recursive repository tree, including workflows, Worker config, all `src/` modules, all tests, README/project memory and package metadata. |
| 83 | |
| 84 | ### Root cause |
| 85 | - Telegram requests were reaching the production Worker, so webhook registration, secret header and owner gate were not the blocker. |
| 86 | - Production observability showed `POST /telegram/webhook` returning HTTP 400 with `Telegram API sendMessage network failure: Illegal invocation: function called with incorrect this reference`. |
| 87 | - Root defect was in `src/telegram.js`: the platform-global `fetch` had been stored directly as an instance property and later called with the wrong receiver. |
| 88 | - Node unit tests had previously missed this platform-specific semantic difference. |
| 89 | |
| 90 | ### PR #11 — redacted runtime diagnostics |
| 91 | - RED commit `079f9b7977e1120d1bcdbbcd75d91e6a322e5a49`. |
| 92 | - Implementation commit `2851c7045141aaeff501564d4a6bf8f22e333754`. |
| 93 | - PR CI `37064293599` = 30/30 pass. |
| 94 | - Squash merge `cfd7a0b4803b13c76646b71666e7e0c66e023c99`. |
| 95 | - Post-merge CI `37064405261` and deploy `37064436885` succeeded. |
| 96 | |
| 97 | ### PR #12 — Cloudflare fetch receiver fix |
| 98 | - RED commit `99cf3468f820eb06390b7001c1d1eb5e5fb4ebbd`. |
| 99 | - Fix commit `c487727c968e4f00aecf0985a38b152f58e3b9b4`. |
| 100 | - Default transport now uses `(...args) => fetch(...args)` instead of storing bare platform `fetch`. |
| 101 | - PR CI `37064953868` = 31/31 pass. |
| 102 | - Squash merge `bd01d8ede44331f50e1115d569095fb12246331d`. |
| 103 | - Post-merge CI `37065054623` and deploy `37065141745` succeeded. |
| 104 | - Cloudflare telemetry showed current-version Telegram webhook requests returning HTTP 200; `Illegal invocation` existed only on the older Worker version. |
| 105 | |
| 106 | ### PR #13 — callback resilience + documentation alignment |
| 107 | - RED commit `13daeb442d6a2e1189a5cec2148aab9c2ea7c338`. |
| 108 | - Callback fix commit `28e2e6b619c646796600048a34616138fbbc207c`. |
| 109 | - README alignment commit `67b04e04214e334a88aea0ecdc4598bc5fbd027c`. |
| 110 | - PR CI `37065725004` = 32/32 pass. |
| 111 | - Squash merge `6c90cbb8384c9591ba89367b48e4ce7e785ce72f`. |
| 112 | - Post-merge CI `37065832210` and deploy `37065860268` succeeded. |
| 113 | - Cloudflare deployment `13a5abdc-92a0-415f-b30b-ab422ae8b8ce`, version `812c52f7-f0b3-48bf-917c-151f4618dabd`, served 100% traffic. |
| 114 | - Live Telegram webhook on that Worker version returned HTTP 200 / outcome `ok`. |
| 115 | |
| 116 | ## Plugin Foundation v1 — Implementation Checkpoint 2026-10-03 |
| 117 | |
| 118 | ### Approved design and plan |
| 119 | - Design: `docs/superpowers/specs/2026-10-03-nexa-plugin-foundation-design.md`. |
| 120 | - Design commit on `main`: `adabadefd74de656b20d112c325be4defcbf2103`. |
| 121 | - Plan: `docs/superpowers/plans/2026-10-03-nexa-plugin-foundation.md`. |
| 122 | - Initial plan commit on `main`: `5f9a1991dbc3a1e79f5c04dfbe591c4d35e74a97`. |
| 123 | - Feature branch: `feat/plugin-foundation-v1`. |
| 124 | - PR: `#14`. |
| 125 | |
| 126 | ### Architecture implemented on PR #14 |
| 127 | - Plugin Registry with manifest/action validation. |
| 128 | - Central Action Policy with owner READ allow and WRITE/DESTRUCTIVE approval-required decisions. |
| 129 | - Recursive-redaction Audit Logger. |
| 130 | - Plugin Router enforcing `resolve -> policy -> execute`. |
| 131 | - GitHub manifest and plugin adapter. |
| 132 | - `/repos` and GitHub callbacks migrated through the plugin kernel. |
| 133 | - `/start`, `/status`, tools/settings/security and other non-GitHub menu flows remain compatibility routes in Foundation v1. |
| 134 | |
| 135 | ### Security-critical design correction during implementation |
| 136 | The initial plan described a handler returning an already-produced view/result. TDD review identified that this could allow provider/view work before policy. The implemented contract is safer: route resolution returns `{ actionId, execute }`; resolution must be side-effect-free, policy is evaluated next, and only then may `execute()` run. Tests prove denied, undeclared, WRITE and DESTRUCTIVE actions do not call `execute()`. |
| 137 | |
| 138 | ### TDD evidence |
| 139 | - Registry RED `2460b0854f6dbd99a80cfb9561850fdd23f1ac0e` / CI `37069219176`; GREEN `3f644caef41a9136cb5f0a78b0c66798238a257d` / CI `37069339637`. |
| 140 | - Policy RED `77efe66f008fcb417b0b66f22b186885d3fecdd3` / CI `37069430240`; GREEN `cbdba6b1b70342d6325d229cec1725c05862a537` / CI `37069629741`. |
| 141 | - Audit RED `a6f9735185f7a0ce45fe744b9a13b1fa3d885681` / CI `37069736330`; GREEN `92dfcba318f5199e6c9e54da5fbba91a15122ca3` / CI `37069824796`. |
| 142 | - Router RED `4e3fca87139310c24c3c83a5181fc638f887882d` / CI `37069955642`; GREEN `00fcd1041e2f8074dc34727635395896eace0cba` / CI `37070015843`. |
| 143 | - GitHub adapter RED `ae6829729779c2f656e99958a379c805eb1bebc4` / CI `37070181121`; GREEN adapter head `c9aed93bc1a3bd8ac047a3639722633bcd9c624e` / CI `37070481981`. |
| 144 | - Bot migration RED `f1ee926320dc918d0d0c8b21d60710077a9d119b` / CI `37070633843`; GREEN integration `d628a4ed0b07dfa4c748b6161515565b1eef3073` / CI `37070778956`. |
| 145 | - CI `37070778956` inspected in full: 12 test files discovered; 52 tests, 52 pass, 0 fail, 0 skipped/cancelled/todo. |
| 146 | |
| 147 | ### Current verification state |
| 148 | VERIFIED on PR merge result: |
| 149 | - Plugin registry validation. |
| 150 | - READ/WRITE/DESTRUCTIVE policy semantics. |
| 151 | - Recursive audit redaction and non-breaking sink failure. |
| 152 | - Undeclared and approval-required actions do not execute provider code. |
| 153 | - GitHub callback/command ownership mapping. |
| 154 | - Existing `/start`, same-message navigation, stale callback handling, security gates, GitHub fail-closed behavior and Cloudflare fetch-receiver regression remain green. |
| 155 | |
| 156 | NOT YET VERIFIED for Foundation v1: |
| 157 | - Final documentation-head PR CI after this checkpoint commit. |
| 158 | - Merge of PR #14 to `main`. |
| 159 | - Post-merge `main` CI. |
| 160 | - Cloudflare deployment of the merged Foundation revision. |
| 161 | - Production Telegram webhook telemetry on that new Worker version. |
| 162 | - Owner-device visual/interactive smoke after Foundation deploy. |
| 163 | |
| 164 | ## Current Work / Last Checkpoint |
| 165 | WHERE WE ARE: |
| 166 | - Foundation v1 implementation is on PR #14 and has passed the full automated suite on the pre-documentation head. |
| 167 | - Final documentation alignment is being committed before merge. |
| 168 | - Production is still the previously verified pre-Foundation version until PR #14 is merged and deploy succeeds. |
| 169 | |
| 170 | WHAT REMAINS: |
| 171 | 1. Verify final PR #14 CI after documentation changes. |
| 172 | 2. Mark PR ready and merge after green CI/scope review. |
| 173 | 3. Verify post-merge main CI and Cloudflare deploy. |
| 174 | 4. Verify current-version Telegram webhook telemetry. |
| 175 | 5. Record owner-device smoke for the Foundation build. |
| 176 | |
| 177 | ## Acceptance Rules |
| 178 | A checkpoint is complete only after `IMPLEMENTED -> VERIFIED -> FIXED IF NEEDED -> RE-VERIFIED`. |
| 179 | Minimum automated/runtime gates: |
| 180 | - Non-zero discovered test files. |
| 181 | - Security tests green. |
| 182 | - Navigation/bot/menu/index tests green. |
| 183 | - Plugin registry/policy/audit/router tests green. |
| 184 | - GitHub plugin/fail-closed/data-trust tests green. |
| 185 | - Telegram missing-token/API-error and Cloudflare fetch-receiver regression tests green. |
| 186 | - Production deploy workflow green. |
| 187 | - Cloudflare telemetry must show successful production webhook behavior before runtime is called verified. |
| 188 | |
| 189 | ## Known Gaps / Low-Priority Technical Debt |
| 190 | - Post-Foundation owner-device visual/interactive smoke remains a final UI acceptance gate. |
| 191 | - `package.json` still has `"start": "node src/index.js"`, which is not a useful local Cloudflare Worker development command; it does not affect production deployment. |
| 192 | - Extremely long path-based refresh callback data could theoretically approach Telegram's 64-byte callback-data limit; normal deep navigation uses SHA-based callbacks. |
| 193 | - Persistent navigation/session storage is intentionally not required for the current stateless callback flow. |
| 194 | - Foundation v1 establishes approval-required policy results but intentionally does not implement the Telegram confirmation UX; that belongs to the first write-capable plugin phase. |
| 195 | |
| 196 | ## Project Boundaries |
| 197 | - Nexa Dev Bot is independent from Finora / Factor-easy and has no Supabase requirement in this project. |
| 198 | - Do not mix state or migrations from other projects. |
| 199 | - Keep secrets out of code, logs and documentation. |
| 200 | |
| 201 | ## Important Paths |
| 202 | - `PROJECT_MEMORY.md` |
| 203 | - `README.md` |
| 204 | - `docs/superpowers/specs/2026-10-03-nexa-plugin-foundation-design.md` |
| 205 | - `docs/superpowers/plans/2026-10-03-nexa-plugin-foundation.md` |
| 206 | - `src/index.js` |
| 207 | - `src/bot.js` |
| 208 | - `src/core/plugin-registry.js` |
| 209 | - `src/core/action-policy.js` |
| 210 | - `src/core/audit.js` |
| 211 | - `src/core/router.js` |
| 212 | - `src/plugins/github/manifest.js` |
| 213 | - `src/plugins/github/plugin.js` |
| 214 | - `src/menu.js` |
| 215 | - `src/telegram.js` |
| 216 | - `src/github.js` |
| 217 | - `test/plugin-registry.test.js` |
| 218 | - `test/action-policy.test.js` |
| 219 | - `test/audit.test.js` |
| 220 | - `test/plugin-router.test.js` |
| 221 | - `test/github-plugin.test.js` |
| 222 | - `test/security.test.js` |
| 223 | - `test/navigation.test.js` |
| 224 | - `test/bot.test.js` |
| 225 | - `.github/workflows/ci.yml` |
| 226 | - `.github/workflows/deploy.yml` |
| 227 | - `wrangler.jsonc` |
| 228 | |
| 229 | ## Next Executable Action |
| 230 | Verify final PR #14 CI after documentation commits; if green, perform final scope/secret review, mark ready, merge, verify main CI/deploy, then verify production telemetry and owner-device smoke. |