Personal Telegram developer console for GitHub

docs: record full repository audit and Telegram production fix

davoodmehraban89 committed Oct 3, 2026 at 00:50 UTC d41aaeca99e11d2f59b0ecabb9454e598dc51cd4
1 file changed +74 -52
PROJECT_MEMORY.md
+74 -52
@@ -16,15 +16,16 @@
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 and required Telegram transport checks.
20 -- `src/bot.js` — Telegram update/callback router.
21 -- `src/telegram.js` — Telegram Bot API client; explicit error propagation and fail-closed token handling.
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 router; callback acknowledgement is best-effort and cannot block menu rendering.
21 +- `src/telegram.js` — Telegram Bot API client; explicit error propagation, fail-closed token handling and Cloudflare-safe default `fetch` invocation.
22 - `src/github.js` — authenticated GitHub REST reader; explicit errors, numeric repository-id resolution, tree/blob access.
23 -- `src/menu.js` — hierarchical inline menus, one-message editing, repository/file browser.
23 +- `src/menu.js` — hierarchical stateless inline menus, one-message editing, repository/file browser.
24 - `src/config.js` — non-secret static config.
25 -- `.github/workflows/ci.yml` — Node 22 project test runtime, official GitHub Actions on Node-24-based v7 releases, non-zero test-discovery guard.
25 +- `.github/workflows/ci.yml` — Node 22 tests, official GitHub Actions v7 releases and non-zero test-discovery guard.
26 - `.github/workflows/deploy.yml` — production Cloudflare Worker deploy after successful CI on `main`; deploys the exact verified commit.
27 -- `test/` — security, worker, navigation, menu, GitHub and Telegram regression coverage.
27 +- `test/` — security, Worker, navigation, menu, GitHub and Telegram regression coverage.
28 +- `wrangler.jsonc` — Worker configuration; `keep_vars: true`, workers.dev enabled and observability enabled.
29
30 ## Runtime Configuration
31 Worker runtime names:
@@ -45,12 +46,14 @@ GitHub Actions deployment secrets:
46 - Non-owner updates are ignored before private-data access.
47 - GitHub token absence and GitHub API failures are explicit errors; no fabricated fallback data.
48 - Telegram network/API failures propagate; fake transport success is prohibited.
49 +- Runtime diagnostic logs redact Telegram, webhook and GitHub secrets.
50 - Temporary setup/diagnostic exposure is disabled in source/tests.
51 - Operational UI does not invent SLA, latency or external health claims.
52
53 ## Telegram UX / GitHub Reader
54 - `/start` creates the initial menu message.
55 - Callback navigation uses `editMessageText` on the same Telegram message.
56 +- Callback acknowledgement failure/staleness no longer blocks in-place navigation.
57 - Main sections: Repositories, Status, Tools, Settings, Security.
58 - Repository sections: Files, Pull Requests, Commits, Actions status, Back.
59 - Back navigation and breadcrumb-style text exist.
@@ -60,66 +63,84 @@ GitHub Actions deployment secrets:
63 - File previews are HTML-escaped and bounded; oversized/non-base64 blobs are not rendered directly.
64 - Directory interactive entries are capped at 30 and omitted counts are disclosed.
65
63 -## Deep File Browser — Verified/Merged 2026-10-02
64 -- PR `#8` merged to `main` at commit `b2a2b61ffb92dc14508e16a19c6221a805445c76`.
65 -- Regression-first RED evidence: 29 tests / 25 pass / 4 expected fail before implementation.
66 -- PR green CI: run `37055283770` = 29/29 pass.
67 -- Post-merge `main` CI: run `37055466988` = 29/29 pass.
68 -- Deep folder/file browsing remains single-message navigation.
69 -
70 -## GitHub Actions Runtime Upgrade — Verified/Merged 2026-10-02
71 -- PR `#9` merged to `main` at commit `7574fb1a373c3ab7b81f3f6857452059287cd44e`.
72 -- `actions/checkout` upgraded from v4 to v7.
73 -- `actions/setup-node` upgraded from v4 to v7.
74 -- Project test runtime remains Node 22.
75 -- `package-manager-cache: false` preserves prior no-cache behavior.
76 -- PR code CI run `37055691513` = 29/29 pass.
77 -- PR documentation-head CI run `37055861886` = 29/29 pass.
78 -- Post-merge `main` CI run `37056086860` = 29/29 pass.
79 -- The prior GitHub Actions Node-20-runtime deprecation warning is absent from the verified PR and post-merge runs.
80 -
66 ## Production Deploy Automation — Verified 2026-10-02
82 -- Real Telegram screenshot first exposed a stale/unresponsive production Worker relative to current source.
83 -- Root cause in repository: CI had no Cloudflare deploy step, so green/merged `main` did not guarantee Worker deployment.
84 -- PR `#10` added `.github/workflows/deploy.yml` and was fast-forwarded to `main` at commit `c86b86ec8f5678b9223b7bcb6a73e0377116e670`.
85 -- PR CI run `37057306685` passed.
86 -- Post-merge `main` CI run `37057386587` passed.
87 -- Initial deployment workflow run `37057406559` failed before deploy because GitHub Actions Cloudflare credentials were absent.
88 -- Repository secrets `CLOUDFLARE_API_TOKEN` and `CLOUDFLARE_ACCOUNT_ID` were then configured by the owner.
89 -- Failed jobs for workflow run `37057406559` were re-run; credential preflight passed and the Cloudflare deploy step completed successfully.
90 -- Cloudflare API verification after the successful deploy shows latest deployment `b2f47b95-277f-423b-aab5-1d7020e60501`, created `2026-10-02T20:45:26.729642Z`.
91 -- Latest active Worker version is `51`, version id `dc70c38f-d84e-40f5-8db1-8ae909dae6d7`, receiving 100% of traffic.
92 -- Worker subdomain remains enabled. Direct public HTTP probing of the workers.dev hostname from the assistant web environment is unavailable, so Telegram/mobile smoke remains the final runtime acceptance gate.
67 +- PR `#10` added `.github/workflows/deploy.yml` and merged to `main` at `c86b86ec8f5678b9223b7bcb6a73e0377116e670`.
68 +- GitHub repository secrets for Cloudflare deployment are configured.
69 +- Re-run of deployment workflow `37057406559` passed credential preflight and deployed successfully.
70 +- Automatic deploy now runs after successful `main` CI and uses the exact verified commit.
71 +
72 +## Full Repository Audit + Telegram Runtime Incident — Verified 2026-10-02
73 +Audit scope covered the full recursive repository tree, including workflows, Worker config, all `src/` modules, all tests, README/project memory and package metadata.
74 +
75 +### Root cause
76 +- Telegram requests were reaching the production Worker, so webhook registration, secret header and owner gate were not the blocker.
77 +- Production observability showed `POST /telegram/webhook` returning HTTP 400 with:
78 + `Telegram API sendMessage network failure: Illegal invocation: function called with incorrect this reference`.
79 +- Root defect was in `src/telegram.js`: the platform-global `fetch` had been stored directly as an instance property and later called as `this.fetchFn(...)`, which supplied `TelegramClient` as the receiver. Cloudflare Workers rejects that receiver binding.
80 +- Node unit tests had previously missed this platform-specific semantic difference.
81 +
82 +### PR #11 — redacted runtime diagnostics
83 +- Added regression-first diagnostics without exposing secrets.
84 +- RED commit: `079f9b7977e1120d1bcdbbcd75d91e6a322e5a49`.
85 +- Implementation commit: `2851c7045141aaeff501564d4a6bf8f22e333754`.
86 +- PR CI run `37064293599` = 30/30 pass.
87 +- Squash-merged to `main` at `cfd7a0b4803b13c76646b71666e7e0c66e023c99`.
88 +- Post-merge CI `37064405261` and deploy `37064436885` succeeded.
89 +
90 +### PR #12 — Cloudflare fetch receiver fix
91 +- Added a regression test that reproduces Cloudflare-style illegal receiver invocation.
92 +- RED commit: `99cf3468f820eb06390b7001c1d1eb5e5fb4ebbd`.
93 +- Fix commit: `c487727c968e4f00aecf0985a38b152f58e3b9b4`.
94 +- Fix: default transport now uses `(...args) => fetch(...args)` instead of storing bare platform `fetch`.
95 +- PR CI `37064953868` = 31/31 pass.
96 +- Squash-merged to `main` at `bd01d8ede44331f50e1115d569095fb12246331d`.
97 +- Post-merge CI `37065054623` and deploy `37065141745` succeeded.
98 +- Cloudflare telemetry after this deploy showed current-version Telegram webhook requests returning HTTP 200; the `Illegal invocation` errors existed only on the older Worker version.
99 +
100 +### PR #13 — callback resilience + documentation alignment
101 +- Added regression coverage requiring menu editing to continue even if `answerCallbackQuery` is stale/fails.
102 +- RED commit: `13daeb442d6a2e1189a5cec2148aab9c2ea7c338`.
103 +- Callback fix commit: `28e2e6b619c646796600048a34616138fbbc207c`.
104 +- README alignment commit: `67b04e04214e334a88aea0ecdc4598bc5fbd027c`.
105 +- PR CI `37065725004` = 32/32 pass.
106 +- Squash-merged to `main` at `6c90cbb8384c9591ba89367b48e4ce7e785ce72f`.
107 +- Post-merge CI `37065832210` succeeded.
108 +- Post-merge deploy `37065860268` succeeded.
109 +- Cloudflare latest deployment after PR #13: `13a5abdc-92a0-415f-b30b-ab422ae8b8ce`, version `812c52f7-f0b3-48bf-917c-151f4618dabd`, 100% traffic.
110 +- Live Telegram webhook on this exact Worker version returned HTTP 200 with Worker outcome `ok`.
111 +- Observability query found no new `telegram_webhook_error` on fixed/current versions; retained error events were from the old pre-fix version only.
112
113 ## Current Work / Last Checkpoint
114 WHERE WE ARE:
96 -- Source, tests, security gates, one-message navigation, deep file browsing and CI are green on `main`.
97 -- Production deploy automation exists and has successfully deployed through GitHub Actions using repository secrets.
98 -- Cloudflare confirms Worker version 51 is active at 100% traffic.
99 -- Real Telegram mobile smoke after this successful deployment is still NOT VERIFIED.
115 +- Full repository audit completed.
116 +- The production `/start` failure root cause was identified, reproduced with a regression test, fixed, merged and deployed.
117 +- Main CI and Cloudflare deploy are green.
118 +- Latest production Worker receives Telegram webhook traffic successfully with HTTP 200.
119 +- Callback navigation was additionally hardened against stale callback acknowledgements.
120 +- README now matches the deployed stateless Worker architecture.
121
122 WHAT REMAINS:
102 -1. Repeat owner-device Telegram smoke on the freshly deployed Worker: `/start → Repositories → repository → Files → folder → file preview → root → project → Commits/PR/Status → Back → Main`.
103 -2. Confirm callbacks edit the same Telegram message and create no extra bot-message flood.
104 -3. Confirm `/start` returns the new main menu instead of the stale repository-button view.
105 -4. Confirm a non-owner Telegram account receives no private bot response.
106 -5. If desired later, tighten the Cloudflare CI token scope from the official `Edit Cloudflare Workers` template to a least-privilege Worker-scoped token.
123 +1. Owner-device visual smoke: confirm the new main menu is visible after `/start`.
124 +2. Exercise `Repositories → repository → Files → folder → file preview → root → project → Commits/PR/Status → Back → Main` and confirm the same Telegram message is edited throughout.
125 +3. Optional non-owner smoke to confirm no private bot response.
126
127 ## Acceptance Rules
128 A checkpoint is complete only after:
129 `IMPLEMENTED → VERIFIED → FIXED IF NEEDED → RE-VERIFIED`
111 -Minimum automated gates:
130 +Minimum automated/runtime gates:
131 - Non-zero discovered test files.
132 - Security tests green.
133 - Navigation/bot/menu/index tests green.
134 - GitHub fail-closed/data-trust tests green.
116 -- Telegram missing-token/API-error tests green.
117 -- Production deploy workflow green before live behavior is called verified.
135 +- Telegram missing-token/API-error and Cloudflare fetch-receiver regression tests green.
136 +- Production deploy workflow green.
137 +- Cloudflare telemetry must show successful production webhook behavior before runtime is called verified.
138
119 -## Known Gaps / Technical Debt
120 -- Real mobile Telegram smoke must be repeated after successful production deploy.
121 -- Direct workers.dev health probing is unavailable from the current assistant web environment; Cloudflare control-plane deployment state is verified instead.
122 -- Persistent navigation/session storage is not required for the current stateless callback flow.
139 +## Known Gaps / Low-Priority Technical Debt
140 +- Owner-device visual/interactive smoke remains the final UI acceptance gate.
141 +- `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.
142 +- Extremely long path-based refresh callback data could theoretically approach Telegram's 64-byte callback-data limit; normal deep navigation uses SHA-based callbacks and is not affected by the incident fixed here.
143 +- Persistent navigation/session storage is intentionally not required for the current stateless callback flow.
144
145 ## Project Boundaries
146 - Nexa Dev Bot is independent from Finora / Factor-easy and has no Supabase requirement in this project.
@@ -128,6 +149,7 @@ Minimum automated gates:
149
150 ## Important Paths
151 - `PROJECT_MEMORY.md`
152 +- `README.md`
153 - `src/index.js`
154 - `src/bot.js`
155 - `src/menu.js`
@@ -146,4 +168,4 @@ Minimum automated gates:
168 - `wrangler.jsonc`
169
170 ## Next Executable Action
149 -Run `/start` on the owner Telegram account and complete the mobile navigation smoke against the freshly deployed Worker version 51.
\ No newline at end of file
171 +Run `/start` on the owner Telegram account. If the main menu renders, complete the one-message navigation smoke and record the result here.
\ No newline at end of file