Personal Telegram developer console for GitHub
feat/safe-github-ops
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 | 6. Never call a phase production-accepted from CI alone; deployment and live-runtime evidence are separate gates. |
| 18 | |
| 19 | ## Current Architecture |
| 20 | - `src/index.js` — Cloudflare Worker HTTP boundary; webhook-secret/owner checks, health/status, redacted runtime diagnostics, and named export of `ApprovalReplayGuard`. |
| 21 | - `src/bot.js` — Telegram update/callback coordinator and Safe Actions confirmation lifecycle. |
| 22 | - `src/core/plugin-registry.js` — plugin/action manifest validation. |
| 23 | - `src/core/action-policy.js` — central `READ` / `WRITE` / `DESTRUCTIVE` policy. |
| 24 | - `src/core/audit.js` — structured best-effort audit with recursive redaction. |
| 25 | - `src/core/router.js` — security-critical `resolve -> policy -> execute` router; provider work must remain deferred until policy allows it. |
| 26 | - `src/core/approval.js` — compact HMAC approval tokens, owner/action/risk/expiry binding, and fail-closed consume. |
| 27 | - `src/core/durable-replay-store.js` — Worker-side adapter for persistent approval consume semantics. |
| 28 | - `src/durable/approval-replay-guard.js` — Durable Object atomic one-time consume + expiry cleanup. |
| 29 | - `src/plugins/github/manifest.js` — GitHub action/risk declarations. |
| 30 | - `src/plugins/github/plugin.js` — GitHub repository/file/Actions UI and safe workflow controls. |
| 31 | - `src/github.js` — authenticated GitHub REST client; read APIs plus controlled Actions write APIs. |
| 32 | - `src/telegram.js` — Telegram Bot API client with explicit error propagation and Cloudflare-safe fetch invocation. |
| 33 | - `src/menu.js` — bounded stateless inline views and file browser. |
| 34 | - `.github/workflows/ci.yml` — Node 22 test gate with non-zero test-discovery guard. |
| 35 | - `.github/workflows/deploy.yml` — exact-commit Cloudflare deployment after successful `main` CI. |
| 36 | - `wrangler.jsonc` — Worker config plus SQLite Durable Object binding `APPROVAL_REPLAY_GUARD` -> `ApprovalReplayGuard`. |
| 37 | |
| 38 | ## Runtime Configuration |
| 39 | Worker runtime names: |
| 40 | - `TELEGRAM_BOT_TOKEN` |
| 41 | - `TELEGRAM_WEBHOOK_SECRET` |
| 42 | - `OWNER_TELEGRAM_ID` |
| 43 | - `GITHUB_TOKEN` |
| 44 | - optional `GITHUB_OWNER` |
| 45 | - optional `APPROVAL_SIGNING_SECRET`; approval falls back to `TELEGRAM_WEBHOOK_SECRET` when absent |
| 46 | - `APPROVAL_REPLAY_GUARD` Durable Object binding from Wrangler config |
| 47 | |
| 48 | GitHub Actions deployment secrets: |
| 49 | - `CLOUDFLARE_API_TOKEN` |
| 50 | - `CLOUDFLARE_ACCOUNT_ID` |
| 51 | |
| 52 | ## Security / Data-Trust Invariants |
| 53 | - Telegram webhook is `POST /telegram/webhook`; missing required security/transport configuration fails closed. |
| 54 | - Non-owner updates are ignored before private-data access. |
| 55 | - Missing GitHub token/provider failures are explicit; no fabricated fallback data or fabricated success. |
| 56 | - Runtime diagnostics and audit records must not disclose Telegram/GitHub/webhook/approval signing secrets or signed approval callback tokens. |
| 57 | - Plugin route resolution must be side-effect-free; provider/view work happens only inside deferred `execute()` after policy evaluation. |
| 58 | - `READ` executes for the authorized owner. |
| 59 | - `WRITE` and `DESTRUCTIVE` do not execute on the first request; they require a verified owner-bound approval. |
| 60 | - Approval token is short-lived, HMAC-signed, action-bound, owner-bound and target-bound. |
| 61 | - Approval consume fails closed without persistent replay protection. |
| 62 | - `(ownerId, nonce)` is consumed atomically through the Durable Object, preventing cross-isolate replay. |
| 63 | - GitHub workflow write endpoints never run before approval. |
| 64 | |
| 65 | ## Telegram / GitHub Capabilities |
| 66 | Existing READ navigation remains backward compatible: |
| 67 | - `/start`, `/menu`, `/repos`, `/status` |
| 68 | - repository detail, files/tree/blob preview, PRs, commits, status |
| 69 | - same-message callback navigation via `editMessageText` |
| 70 | - stale `answerCallbackQuery` failure does not block navigation |
| 71 | |
| 72 | Safe GitHub Operator additions in PR #15: |
| 73 | - repository -> `🧪 CI / Actions` |
| 74 | - list workflow runs |
| 75 | - inspect workflow run status/branch/SHA/event |
| 76 | - inspect jobs and steps |
| 77 | - request `Re-run failed jobs` |
| 78 | - request `Cancel workflow run` |
| 79 | - both WRITE actions render explicit Confirm/Cancel UI before provider mutation |
| 80 | - malformed/expired/wrong-owner/mismatched/replayed approval fails closed |
| 81 | |
| 82 | ## Historical Accepted Milestones |
| 83 | ### Runtime incident fixes — 2026-10-02 |
| 84 | - PR #11 added redacted diagnostics; squash merge `cfd7a0b4803b13c76646b71666e7e0c66e023c99`. |
| 85 | - PR #12 fixed Cloudflare `fetch` receiver / `Illegal invocation`; squash merge `bd01d8ede44331f50e1115d569095fb12246331d`. |
| 86 | - PR #13 hardened callback resilience and documentation; squash merge `6c90cbb8384c9591ba89367b48e4ce7e785ce72f`. |
| 87 | - Production telemetry after the fix showed current-version Telegram webhook HTTP 200 / outcome `ok`. |
| 88 | |
| 89 | ### Plugin Foundation v1 — Production Accepted 2026-10-03 |
| 90 | - Design: `docs/superpowers/specs/2026-10-03-nexa-plugin-foundation-design.md`. |
| 91 | - Plan: `docs/superpowers/plans/2026-10-03-nexa-plugin-foundation.md`. |
| 92 | - PR #14 squash merge: `9d95a18659cead269ffa98af08d6bbf041c6135f`. |
| 93 | - Post-merge CI `37071695354` succeeded. |
| 94 | - Verified suite at acceptance: 12 test files, 52/52 pass, 0 fail/skip. |
| 95 | - Deploy `37071717251` succeeded; later documentation checkpoint also passed CI/deploy. |
| 96 | - Owner-device production smoke completed. |
| 97 | - Smoke telemetry on Worker version `425d7418-1efa-498e-8615-1718596943d9`: 35 webhook events, zero observed webhook errors, sampled HTTP 200/outcome `ok`, 22 redacted GitHub READ audit events. |
| 98 | |
| 99 | ## Safe Actions + GitHub Advanced — PR #15 Pre-Merge Checkpoint 2026-10-03 |
| 100 | ### Scope |
| 101 | - Branch: `feat/safe-github-ops` |
| 102 | - PR: `#15` — `feat: add safe GitHub operator foundation` |
| 103 | - Design: `docs/superpowers/specs/2026-10-03-safe-github-ops-design.md` |
| 104 | - Plan: `docs/superpowers/plans/2026-10-03-safe-github-ops.md` |
| 105 | |
| 106 | ### Implemented |
| 107 | - HMAC approval service with compact Telegram-safe callback tokens. |
| 108 | - Policy support for verified approved WRITE/DESTRUCTIVE execution. |
| 109 | - Router approved context while preserving `resolve -> policy -> execute`. |
| 110 | - Persistent cross-isolate replay prevention with SQLite Durable Object. |
| 111 | - Fail-closed behavior if `APPROVAL_REPLAY_GUARD` is unavailable. |
| 112 | - Approval lifecycle audit events without signed token leakage. |
| 113 | - GitHub Actions read APIs: runs, run detail, jobs/steps. |
| 114 | - GitHub Actions controlled write APIs: rerun failed jobs, cancel run. |
| 115 | - Telegram Confirm/Cancel workflow and second approved dispatch. |
| 116 | - `npm start` now uses Wrangler local Worker development rather than `node src/index.js`. |
| 117 | - README/spec/plan aligned to durable replay architecture. |
| 118 | |
| 119 | ### TDD / verification evidence |
| 120 | - Earlier RED/GREEN cycles covered approval token semantics, policy, router, GitHub service, plugin views and Telegram approval flow. |
| 121 | - Durable replay tests cover missing namespace fail-closed, owner+nonce scoping, duplicate rejection, expiry cleanup, and Wrangler export/binding contract. |
| 122 | - A deliberate config/export RED run `37094233142` had 73 tests with exactly 1 expected failure for missing production binding/export. |
| 123 | - Export and Wrangler SQLite Durable Object config then fixed that failure. |
| 124 | - PR CI `37094394332`: **15 test files; 78 tests; 78 pass; 0 fail; 0 skipped/cancelled**. |
| 125 | - Final documentation-aligned head `53a766ac9a2fab49a2bde29d0c5ae9b586f4c555` passed fresh PR CI `37094713808`. |
| 126 | - Fresh PR patch reviewed after documentation corrections; no out-of-scope provider mutations were added. |
| 127 | - Secret-pattern scan found no `ghp_` or `github_pat_` token material; no production secret values are intentionally stored in the patch. |
| 128 | |
| 129 | ### Not yet production-accepted |
| 130 | - PR #15 is not yet merged at this checkpoint. |
| 131 | - Post-merge `main` CI is not yet verified. |
| 132 | - Cloudflare deployment of the Durable Object binding is not yet verified. |
| 133 | - Active-production `APPROVAL_REPLAY_GUARD`/SQLite class is not yet verified through Cloudflare runtime evidence. |
| 134 | - Owner-device production READ path `/start -> Repositories -> project -> CI / Actions` is not yet smoke-tested on the new deployment. |
| 135 | - Live GitHub WRITE provider smoke is **NOT VERIFIED** and must only occur through an actual owner confirmation in Telegram; no secret rotation is performed automatically. |
| 136 | |
| 137 | ## Acceptance Rules |
| 138 | A phase is complete only after `IMPLEMENTED -> VERIFIED -> FIXED IF NEEDED -> RE-VERIFIED`. |
| 139 | Minimum gates: |
| 140 | - Non-zero discovered tests and security regressions green. |
| 141 | - Plugin/policy/audit/router tests green. |
| 142 | - Telegram navigation and Cloudflare fetch-receiver regressions green. |
| 143 | - PR review clean and secrets not leaked. |
| 144 | - Merge exact reviewed head. |
| 145 | - Post-merge `main` CI green. |
| 146 | - Exact-commit Cloudflare deploy green. |
| 147 | - Production telemetry confirms successful webhook behavior on current version. |
| 148 | - Any external WRITE smoke requires the Safe Actions confirmation path; anything not actually executed is explicitly `NOT VERIFIED`. |
| 149 | |
| 150 | ## Current Work / Last Checkpoint |
| 151 | WHERE WE ARE: |
| 152 | - Foundation v1 remains production-accepted. |
| 153 | - Safe Actions + GitHub Advanced implementation is complete on PR #15 and final PR CI is green at head `53a766ac9a2fab49a2bde29d0c5ae9b586f4c555` / run `37094713808`. |
| 154 | - Durable replay protection is implemented in code/config and tested, but production deployment verification is still pending. |
| 155 | |
| 156 | NEXT EXECUTABLE ACTIONS: |
| 157 | 1. Run CI once more if this memory checkpoint changes PR head. |
| 158 | 2. Mark PR #15 ready for review and squash-merge only if the new head is green and mergeable. |
| 159 | 3. Verify exact post-merge `main` CI. |
| 160 | 4. Verify Cloudflare deploy and active Durable Object binding/version. |
| 161 | 5. Inspect current-version Cloudflare telemetry. |
| 162 | 6. Request owner-device READ smoke only if live external interaction is still needed for acceptance. |
| 163 | 7. Do not perform GitHub workflow WRITE smoke without the owner pressing the Telegram Confirm button. |
| 164 | |
| 165 | ## Remaining Roadmap After PR #15 Acceptance |
| 166 | Proceed as separate verified vertical slices, not one mega-PR: |
| 167 | 1. Cloudflare Ops plugin: deployments, versions, logs, health and safe rollback controls. |
| 168 | 2. Broader CI/CD control and release acceptance orchestration. |
| 169 | 3. AI Copilot adapter: code/PR/log/CI analysis, test/fix proposals; no autonomous production mutation. |
| 170 | 4. Browser QA: real DOM smoke, screenshots and production-flow checks behind explicit runtime configuration. |
| 171 | 5. Monitoring + Incident Manager. |
| 172 | 6. Automation Engine with approval-aware durable workflows. |
| 173 | 7. Telegram Mini App control center. |
| 174 | 8. Plugin ecosystem adapters as useful: Supabase, Sentry, Notion, Linear/Jira, Railway/Render; no cross-project assumptions. |
| 175 | 9. Multi-project control plane. |
| 176 | 10. Final hardening: permission penetration tests, rate limiting, replay/idempotency drills, rollback/recovery drill, documentation and release/versioning. |
| 177 | |
| 178 | ## Project Boundaries |
| 179 | - Nexa Dev Bot is independent from Finora / Factor-easy unless a future explicit multi-project adapter is added. |
| 180 | - Do not mix Supabase state/migrations from other projects into Nexa by default. |
| 181 | - Keep secrets out of code, logs and documentation. |