Personal Telegram developer console for GitHub
spec/repository-workspace-editor
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. Verify live `main`, recent CI/deploy and relevant runtime evidence before changes. |
| 13 | 2. Prefer live evidence over chat memory. |
| 14 | 3. Keep durable checkpoints here and never store secrets/tokens/private keys. |
| 15 | 4. Do not call a phase production-accepted from CI alone; deployment and owner-device/runtime evidence are separate gates. |
| 16 | 5. Production WRITE / DESTRUCTIVE provider actions must remain behind Safe Approval and durable one-time replay protection. |
| 17 | |
| 18 | ## Current Architecture |
| 19 | - Cloudflare Worker webhook boundary in `src/index.js`. |
| 20 | - Telegram coordinator and Safe Approval lifecycle in `src/bot.js`. |
| 21 | - Plugin Registry + central Action Policy + Audit Logger + Plugin Router in `src/core/`. |
| 22 | - HMAC approval tokens in `src/core/approval.js`. |
| 23 | - Durable Object replay guard via `APPROVAL_REPLAY_GUARD` / `ApprovalReplayGuard`. |
| 24 | - Owner-scoped Repository Workspace storage via `WORKSPACE_STORE` / `WorkspaceStore` on the implementation branch; production deployment is still NOT VERIFIED. |
| 25 | - GitHub plugin in `src/plugins/github/`; provider adapter in `src/github.js`. |
| 26 | - Exact-commit CI/deploy workflows under `.github/workflows/`. |
| 27 | |
| 28 | ## Security / Data-Trust Invariants |
| 29 | - Non-owner Telegram updates are ignored before private-data access. |
| 30 | - `READ` is owner-only; `WRITE` / `DESTRUCTIVE` require verified owner approval. |
| 31 | - Approval is owner/action/risk/target/expiry-bound and one-time consumed through Durable Object storage. |
| 32 | - Provider mutation never executes before policy approval. |
| 33 | - Provider errors are explicit; no fabricated success or fallback data. |
| 34 | - Secrets, source/draft text and signed approval callback tokens must not appear in logs/docs. |
| 35 | - Telegram callback data and rendered provider text must remain bounded. |
| 36 | |
| 37 | ## Production-Accepted Foundation |
| 38 | ### Plugin Foundation v1 |
| 39 | - PR #14 squash merge `9d95a18659cead269ffa98af08d6bbf041c6135f`. |
| 40 | - Owner-device READ smoke and Cloudflare runtime telemetry accepted. |
| 41 | |
| 42 | ### Safe Actions / GitHub Operator foundation |
| 43 | - PR #15 merged to `main` at `59f0b431b8af86d3aa2b9acb4f5889911972e71a`. |
| 44 | - Post-merge CI run `37095115793` succeeded with 78/78 tests. |
| 45 | - Deploy run `37095129406` succeeded; production Durable Object binding verified. |
| 46 | - CI/Actions pagination subsequently landed on `main` at `074033f5a067283727a38e034a6d19436fcce475`. |
| 47 | |
| 48 | ### Approval and provider-error UX hardening |
| 49 | - PR #17 merged at `2c131ea5fc564faae20cd7aff1ac00831f7fe185`; expired/replayed approvals now visibly update Telegram. |
| 50 | - PR #18 merged at `a2e8a65763516765d47b535e514990f8698ad2a2`; approved provider failures now visibly update Telegram. |
| 51 | - Main CI #155 / run `37099455730` succeeded with 82/82 tests. |
| 52 | - Deploy #90 / run `37099465363` succeeded on the exact merge SHA. |
| 53 | - Active Cloudflare production version after deploy: `1865c8ac-5d05-40cd-8478-8d9f5473e34b` at 100% traffic. |
| 54 | |
| 55 | ## Production Safe Approval WRITE Acceptance — 2026-10-03 |
| 56 | Target: |
| 57 | - CI run #134, Actions run ID `37094321256`. |
| 58 | |
| 59 | Verified sequence: |
| 60 | 1. An early owner approval reached the provider but GitHub returned `403 Resource not accessible by personal access token`; the same approval token was then replayed and correctly rejected as already used. |
| 61 | 2. The owner updated the existing fine-grained GitHub token permission so Actions has write access; no token value was stored or logged. |
| 62 | 3. A fresh owner request produced `approval_required` -> `approval_issued`. |
| 63 | 4. Owner pressed Confirm; production audit recorded `approval_verified` -> approved `action_attempt` with `owner_write_approved`. |
| 64 | 5. Production audit on Worker version `1865c8ac-5d05-40cd-8478-8d9f5473e34b` recorded `action_result=success` for `github.workflow.run.rerun_failed`. |
| 65 | 6. GitHub run #134 moved from `run_attempt=1` to `run_attempt=2`, proving the provider WRITE was accepted. |
| 66 | 7. Attempt 2 itself failed only because it reran the historical PR #15 merge ref from before the later Durable Object binding/config fix; this is historical-code behavior, not a current-main regression. |
| 67 | |
| 68 | Conclusion: |
| 69 | - Owner-bound production approval: VERIFIED. |
| 70 | - No provider WRITE before approval: VERIFIED. |
| 71 | - Durable one-time replay protection: VERIFIED. |
| 72 | - GitHub Actions WRITE authorization and provider POST: VERIFIED. |
| 73 | - Telegram success feedback after accepted provider WRITE: VERIFIED. |
| 74 | |
| 75 | ## GitHub Advanced READ Rollout — PR #19 |
| 76 | - Design: `docs/superpowers/specs/2026-10-03-github-advanced-read-design.md`. |
| 77 | - Plan: `docs/superpowers/plans/2026-10-03-github-advanced-read.md`. |
| 78 | - Scope is READ-only: workflow job detail/log tail, artifacts metadata, branches/compare, PR detail/files/checks, issues, releases and bounded pagination. No new provider mutation was added in this slice. |
| 79 | - PR #19 merged to `main` at `ff270005fca1eda601df0a615ca81033c7340b3a`. |
| 80 | - Post-merge CI #172 / run `37102293956` succeeded on that exact SHA with 22 test files and 97/97 tests passing, 0 fail/skip/cancelled. |
| 81 | - Deploy #108 / run `37102308006` succeeded from that exact SHA. |
| 82 | - Active Cloudflare production version after deploy: `bc23d9e5-1490-429c-9369-4e751f173df5` at 100% traffic. |
| 83 | |
| 84 | ### TDD evidence |
| 85 | - Provider RED CI #156 / run `37100585034`: 87 tests total, 82 pass / 5 expected failures for missing Advanced provider readers. |
| 86 | - Provider compatibility fix followed after CI #157 exposed two regressions (log clamp and page-1 PR URL compatibility). |
| 87 | - Provider GREEN CI #158 / run `37100892060`: 19 test files, 87/87 pass, 0 fail/skip/cancelled. |
| 88 | - Plugin RED CI #159 / run `37100960176`: 92 tests total, 87 pass / 5 expected failures for undeclared/unimplemented Advanced routes and views. |
| 89 | - Plugin GREEN CI #161 / run `37101099153`: 20 test files, 92/92 pass, 0 fail/skip/cancelled. |
| 90 | - Review hardening RED CI #164 / run `37101390354`: 95 tests total, 92 pass / 3 expected failures for artifact pagination, PR diff pagination and visible READ-provider errors. |
| 91 | - Review hardening GREEN CI #166 / run `37101635682`: 21 test files, 95/95 pass, 0 fail/skip/cancelled. |
| 92 | - Mixed Issue/PR pagination RED CI #167 / run `37101783124`: 97 tests total, 95 pass / 2 expected failures. |
| 93 | - Final pre-merge GREEN CI #170 / run `37102060845`: 22 test files, 97/97 pass, 0 fail/skip/cancelled. |
| 94 | |
| 95 | ### Implemented in PR #19 |
| 96 | - Bounded raw workflow-job log tail with HTML escaping and visible truncation state. |
| 97 | - Workflow job detail and per-job drill-down from run jobs. |
| 98 | - Workflow artifact metadata view with bounded pagination. |
| 99 | - Branch list and compare-to-default using a validated 40-hex head SHA. |
| 100 | - Advanced PR list/detail/files-diff/checks views; PR diff page size matches rendered page size so files are not silently skipped. |
| 101 | - Issues and releases views; Issue pagination preserves GitHub raw-page continuation even when PR entries are filtered out. |
| 102 | - Pagination is clamped to page 1..100 and page size <=20 where list pagination is exposed. |
| 103 | - New READ callbacks resolve without provider calls before central policy evaluation; callback lengths are regression-tested against Telegram limits. |
| 104 | - READ provider failures visibly update Telegram instead of appearing silent. |
| 105 | |
| 106 | ## GitHub Advanced READ Production Acceptance — PR #20 |
| 107 | - Live owner-device smoke found two gaps: Issues returned GitHub 403 due missing `Issues: Read`, while Releases successfully returned an empty source-backed list. |
| 108 | - PR #20 `fix: clarify Issues permission and empty Releases state` merged to `main` at `7c0df4c8616c6859a2dfc4c35b0e22d6e47215bc`. |
| 109 | - Post-merge CI #177 / run `37106715317` completed successfully on that exact SHA with 23 test files and 99/99 tests passing, 0 fail/skip/cancelled. |
| 110 | - Deploy #113 / run `37106727515` completed successfully after checking out that exact SHA. |
| 111 | - Active Cloudflare production version after deploy: `5741faa0-720f-48d5-9e76-64726a5f5167` at 100% traffic. |
| 112 | - Owner updated the existing fine-grained PAT to add only Repository permissions -> Issues -> Read-only; token value was not rotated/stored/logged. |
| 113 | - Owner-device Telegram smoke after that permission change showed Issues no longer returns 403 and Releases renders the explicit no-published-release state. |
| 114 | - Cloudflare production telemetry on version `5741faa0-720f-48d5-9e76-64726a5f5167` recorded `github.issues.list` with `outcome=success` and `github.releases.list` with `outcome=success` for the owner-device interactions. |
| 115 | |
| 116 | Conclusion: |
| 117 | - GitHub Advanced READ production acceptance: VERIFIED. |
| 118 | - Issues least-privilege provider authorization: VERIFIED. |
| 119 | - Releases source-backed empty state: VERIFIED. |
| 120 | - Telegram owner-device/runtime evidence: VERIFIED. |
| 121 | |
| 122 | ## Repository Workspace / Code Editor Phase 1 — PR #21 IN PROGRESS |
| 123 | - Design spec: `docs/superpowers/specs/2026-10-03-repository-workspace-editor-design.md`. |
| 124 | - Implementation plan: `docs/superpowers/plans/2026-10-03-repository-workspace-editor.md`. |
| 125 | - Implementation branch: `spec/repository-workspace-editor`. |
| 126 | - PR #21 targets `main` and contains the complete Phase-1 implementation pending merge/deploy/owner-device acceptance. |
| 127 | - Phase 1 remains branch-first only: no direct default-branch mutation, no force update, no automatic merge/rebase/conflict resolution. |
| 128 | |
| 129 | ### Locked implementation constraints |
| 130 | - Owner-scoped short navigation refs; raw long paths never appear in callback data. |
| 131 | - Editable Phase-1 text ceiling: 3,000 Unicode code points and 12,000 UTF-8 bytes; overflow is rejected, never silently truncated. |
| 132 | - Sensitive/private-key-like paths, binary-like content and Git LFS pointers are not editable. |
| 133 | - Navigation/workspace handles are 10 URL-safe chars; commit-intent IDs are exactly 8 URL-safe chars. |
| 134 | - Target branch is `nexa/edit-<workspaceId>`. |
| 135 | - Draft/source content is never placed in callback data or audit metadata. |
| 136 | - Repeated Ready on unchanged material reuses the existing immutable intent. |
| 137 | - Provider Git commit creation remains NOT VERIFIED live until owner-device production acceptance passes. |
| 138 | |
| 139 | ### Task 1 — Workspace policy/diff primitives: COMPLETE |
| 140 | - `src/core/workspace-policy.js` implements editable-file policy, commit-message normalization, target-branch normalization, SHA-256 digests and bounded unified diff with exact full-content counts. |
| 141 | - RED evidence was captured before implementation. |
| 142 | - GREEN checkpoint CI #185 completed with 105/105 passing at that task head. |
| 143 | |
| 144 | ### Task 2 — Durable owner-scoped Workspace Store: COMPLETE |
| 145 | - Added `WORKSPACE_STORE` / `WorkspaceStore` client + Durable Object state machine. |
| 146 | - Owner isolation, navigation/workspace expiry, one-shot pending input, READY invalidation/reuse, COMMITTING/COMMITTED state and cancellation are covered by tests. |
| 147 | - GREEN checkpoint CI #192 completed with 113/113 passing at that task head. |
| 148 | - Production deployment of the new binding/class: NOT VERIFIED. |
| 149 | |
| 150 | ### Task 3 — Path-safe repository browser/editor entry: COMPLETE |
| 151 | - Workspace file navigation uses short Durable refs after policy; legacy tree/blob/path-bearing callbacks remain compatible. |
| 152 | - Eligible file preview exposes Edit; sensitive/LFS/oversized files remain readable with edit disabled. |
| 153 | - `wedit` pins current default-branch HEAD/tree and exact file/blob/content before creating a durable local draft. |
| 154 | - Archived repositories cannot create editable drafts. |
| 155 | - GREEN checkpoint CI #200 / run `37112677199`, job `111173499300`: 121/121 pass, 0 fail/skip/cancelled. |
| 156 | |
| 157 | ### Task 4 — Telegram Draft Input, Diff and Sealed Intent UX: COMPLETE |
| 158 | - RED CI #201 / run `37113613413`, job `111176071940`: 126 tests total, 121 pass / 5 expected failures for missing message routing and `wtext`/`wmsg`/`wdiff`/`wready` behavior. |
| 159 | - Added policy-routed `dispatchMessage`; source text is not audit metadata. |
| 160 | - Bot preserves `/start`/`/menu`/`/repos`/`/status` precedence, then owner pending workspace text is routed with the exact untrimmed message body. |
| 161 | - Pending draft/message input is one-shot; rejected draft input does not mutate the prior draft. |
| 162 | - Diff is HTML escaped and bounded while additions/deletions are computed over complete content. |
| 163 | - READY requires changed content + normalized commit message, binds stable digests/base/path/branch/timestamp, reuses unchanged intent and emits only short `wscommit:<repoId>:<intentId>` callback data. |
| 164 | - GREEN CI #207 / run `37114230736`, job `111177792978`: 27 test files, 127/127 pass, 0 fail/skip/cancelled. |
| 165 | |
| 166 | ### Task 5 — GitHub Git Data commit primitives: COMPLETE |
| 167 | - RED CI #209 / run `37114394075`, job `111178254379`: 132 tests total, 127 pass / 5 expected failures for missing Git Data primitives. |
| 168 | - `requestJson` supports opt-in `allowNotFound`; only HTTP 404 may return `null`, while 403/409/422 and other provider errors remain explicit. |
| 169 | - Added `getGitRef`, `createGitBlob`, multi-file-capable `createGitTree`, deterministic `createGitCommit`, and create-only `createGitBranchRef`. |
| 170 | - Branch paths containing `/` are safely encoded for ref reads; every provider/object SHA is full 40-hex validated. |
| 171 | - Commit author/committer identity and timestamp are deterministic, making ambiguous Git object creation retries material-stable. |
| 172 | - Phase 1 intentionally exposes no update-ref/force-ref primitive. |
| 173 | - GREEN CI #210 / run `37114509763`, job `111178575800`: 28 test files, 132/132 pass, 0 fail/skip/cancelled. |
| 174 | - These Git Data writes are verified only against mocked provider contracts; live GitHub branch commit remains NOT VERIFIED. |
| 175 | |
| 176 | ### Task 6 — Safe Approval + idempotent branch commit orchestration: COMPLETE IN CI |
| 177 | - Workspace commit approval uses a compact owner/action/risk/repo/8-char-intent-bound HMAC token; full Telegram `approve:` callback is regression-tested within the 64-byte limit. |
| 178 | - `wscommit` returns approval metadata before execution; pre-approval route evaluation performs zero GitHub Git Data writes. |
| 179 | - Approved orchestration revalidates immutable workspace material, exact base HEAD and target-branch absence before object creation. |
| 180 | - Commit flow is blob -> tree -> deterministic commit -> persist candidate SHA -> create-only branch ref -> durable `COMMITTED` result. |
| 181 | - `COMMITTING` and already `COMMITTED` retries reconcile idempotently; ambiguous create-ref failures are accepted only if the target ref resolves to the exact recorded candidate SHA. |
| 182 | - Audit metadata is allowlisted and excludes source/draft text and signed token material. |
| 183 | - Existing workflow-run Safe Approval behavior and replay protection remain covered. |
| 184 | - GREEN CI #219 / run `37115479051`, job `111181371564`: 30 test files, 141/141 pass, 0 fail/skip/cancelled. |
| 185 | - Live Repository Workspace provider mutation remains NOT VERIFIED. |
| 186 | |
| 187 | ### Task 7 — Whole-branch review/hardening: IN PROGRESS |
| 188 | - Review found one visible-error gap: approved workspace provider error text was inserted into Telegram HTML without escaping. |
| 189 | - RED CI #220 / run `37115793196`, job `111182246421`: 31 test files, 142 tests total, 141 pass / exactly 1 expected failure on that regression. |
| 190 | - Fix escapes provider error text before Telegram rendering. |
| 191 | - GREEN CI #221 / run `37115965768`, job `111182732367`: 31 test files, 142/142 pass, 0 fail/skip/cancelled. |
| 192 | - Secret-pattern review found no actual PAT/Telegram secret in the PR diff; occurrences of `ghp_` / `github_pat_` are only the documented scan-pattern names. `approve:` occurrences are expected callback construction/parsing and explicit negative audit tests, not logged live tokens. |
| 193 | - A fresh CI is still required after this durable checkpoint because the documentation commits move the PR head. |
| 194 | |
| 195 | ### Not yet production-accepted |
| 196 | - PR #21 is not yet merged/deployed at this checkpoint. |
| 197 | - Exact post-merge `main` CI: NOT VERIFIED. |
| 198 | - Production `WORKSPACE_STORE` / `WorkspaceStore` binding/runtime: NOT VERIFIED. |
| 199 | - Live owner-device browse/edit/diff/READY pre-approval smoke: NOT VERIFIED. |
| 200 | - Live proof of zero provider WRITE before workspace approval: NOT VERIFIED for this new action. |
| 201 | - Live approved branch-only GitHub commit and exact provider SHA feedback: NOT VERIFIED. |
| 202 | - Main/default branch remaining unchanged after the branch-only commit: NOT VERIFIED live. |
| 203 | |
| 204 | ## Next Executable Actions |
| 205 | 1. Run fresh CI on the final checkpoint head and review exact PR #21 diff/metadata. |
| 206 | 2. Mark PR #21 ready and merge only that reviewed green head. |
| 207 | 3. Verify exact post-merge `main` CI, deploy SHA, active Cloudflare version and both Durable Object bindings/classes. |
| 208 | 4. Perform owner-device production smoke up to the Approval screen; verify no target branch/provider WRITE exists before confirmation. |
| 209 | 5. Owner confirms the fresh Safe Approval; verify the new `nexa/edit-*` branch, exact commit SHA, main unchanged, Cloudflare audit success and Telegram success feedback. |
| 210 | 6. Do not call Repository Workspace Phase 1 production-accepted until Telegram, GitHub and Cloudflare runtime evidence agree. |
| 211 | |
| 212 | ## Remaining Roadmap |
| 213 | 1. Repository Workspace / Code Editor Phase 1 production acceptance, then multi-file expansion. |
| 214 | 2. Remaining useful GitHub Advanced WRITE actions, always through Safe Approval. |
| 215 | 3. Cloudflare Ops plugin: deployments, versions, bindings, health, telemetry/runtime errors and approval-gated rollback/deploy operations. |
| 216 | 4. CI/CD Control Plane and release acceptance orchestration. |
| 217 | 5. Monitoring + Incident Manager. |
| 218 | 6. Automation Engine with resumable/idempotent approval-aware workflows. |
| 219 | 7. AI Copilot with no direct production mutation. |
| 220 | 8. Browser QA real production smoke. |
| 221 | 9. Telegram Mini App backed by the same workspace/control-plane APIs. |
| 222 | 10. Plugin ecosystem and multi-project control plane. |
| 223 | 11. Final hardening, recovery drills, docs and versioning. |
| 224 | |
| 225 | ## Project Boundaries |
| 226 | - Nexa Dev Bot is independent from Finora / Factor-easy unless an explicit adapter is added. |
| 227 | - Do not mix other projects' Supabase/database state into Nexa by default. |
| 228 | - Keep secrets out of code, logs and documentation. |