Personal Telegram developer console for GitHub
docs: record verified security and CI repair checkpoint
davoodmehraban89 committed
Oct 2, 2026 at 22:21 UTC
49fc89d9f4d83942c9b2062fa87d1032f30dbf69
1 file changed
+136
-131
PROJECT_MEMORY.md
+136
-131
@@ -5,7 +5,7 @@
5
- Repository: `davoodmehraban89/nexa-dev-bot`
6
- Canonical branch: `main`
7
- Visibility: private
8
-- Purpose: personal Telegram developer console for GitHub repository visibility and operations.
8
+- Purpose: personal, owner-only Telegram developer console for GitHub repository visibility and controlled developer operations.
9
- This file is the Single Source of Truth for AI continuity. Repository/runtime evidence overrides stale text here.
10
11
## AI HANDOFF PROTOCOL
@@ -18,196 +18,198 @@
18
7. Never store passwords, tokens, API secrets, webhook secrets or private keys here.
19
20
## Product Vision
21
-Build a secure, professional, mobile-first Telegram control surface for GitHub projects with clean hierarchical navigation, minimal chat clutter, trustworthy live data, auditability and later developer automation.
21
+Build a secure, professional, mobile-first Telegram control surface for GitHub projects with hierarchical navigation, minimal chat clutter, trustworthy live data, auditability and later developer automation.
22
23
## Repository / Workspace
24
- Repository: `davoodmehraban89/nexa-dev-bot`
25
- Default branch: `main`
26
-- Verified GitHub integration permissions available to the connected tool: admin/read/write.
27
-- Verified main head at reconciliation: `2f55a22d9ca8c9dfec42ce7021ccc355bad49b92` (`Add files via upload`, 2026-10-02).
28
-- Existing feature branch `feat/telegram-main-inline-menu` is behind main by 6 commits and no longer represents the newest implementation baseline.
26
+- Connected GitHub integration has repository read/write access.
27
+- The former branch `feat/telegram-main-inline-menu` is stale and is not the implementation baseline.
28
+- Current implementation baseline is `main`.
29
30
## Architecture
31
-Verified current source layout on `main`:
32
-- `src/index.js` — Cloudflare Worker entrypoint / HTTP handler.
31
+Current source layout:
32
+- `src/index.js` — Cloudflare Worker HTTP boundary, webhook authentication and owner authorization.
33
- `src/bot.js` — Telegram update router and callback handling.
34
-- `src/telegram.js` — Telegram Bot API client.
35
-- `src/github.js` — GitHub API reader with fallback data.
34
+- `src/telegram.js` — Telegram Bot API client with explicit error propagation.
35
+- `src/github.js` — authenticated GitHub REST reader; fails explicitly instead of returning fabricated fallback data.
36
- `src/menu.js` — hierarchical inline-menu renderer and callback router.
37
-- `src/config.js` — static default repositories/service/security display configuration.
38
-- `.github/workflows/ci.yml` — Node CI.
39
-- `test/` — test files, including security and navigation regression tests.
37
+- `src/config.js` — minimal non-secret static configuration.
38
+- `.github/workflows/ci.yml` — Node.js CI.
39
+- `test/` — security, navigation, bot, menu, worker, GitHub and Telegram client regression tests.
40
41
## Technology Stack
42
- JavaScript ES modules
43
-- Node.js test runner
43
+- Node.js 22 test runner
44
- Telegram Bot API
45
- GitHub REST API
46
- Cloudflare Workers / Wrangler
47
- GitHub Actions
48
49
## Environments & Integrations
50
-Verified in repository:
51
-- Cloudflare Worker configuration exists in `wrangler.jsonc`, main entry `src/index.js`, `workers_dev: true`, observability enabled.
50
+Repository-verified:
51
+- Cloudflare Worker configuration exists in `wrangler.jsonc` with `src/index.js` as entrypoint.
52
- Telegram Bot API integration exists.
53
- GitHub API integration exists.
54
- CI workflow exists.
55
-Not verified in this reconciliation:
56
-- Current live Cloudflare deployment contents.
57
-- Current live Telegram webhook configuration.
58
-- Current production secret values.
55
+Runtime configuration names required by the code:
56
+- `TELEGRAM_BOT_TOKEN`
57
+- `TELEGRAM_WEBHOOK_SECRET`
58
+- `OWNER_TELEGRAM_ID`
59
+- `GITHUB_TOKEN`
60
+- optional `GITHUB_OWNER`
61
+Secret values must never be committed to this file or the repository.
62
63
## Current Production State
61
-**NOT VERIFIED.** Do not infer live deployment correctness from repository contents or CI alone.
62
-
63
-## Completed Work (Repository-Verified)
64
-- Continuity system exists.
65
-- Current `main` contains a modular redesign (`bot.js`, `menu.js`, `telegram.js`, `github.js`, `config.js`).
66
-- Inline hierarchical menu views exist for main menu, repositories, repo detail, files, commits, pull requests, service status, tools, settings and security.
67
-- Callback handling uses Telegram `editMessageText` for in-place menu navigation.
68
-- Main menu includes Repositories, Status, Tools, Settings and Security.
69
-- Breadcrumb-style path text and explicit back buttons are present.
70
-- Latest GitHub Actions run inspected: run `37047035443` for head `2f55a22...` concluded `success`.
71
-
72
-## Critical Verification Finding
73
-The latest CI success is **not a valid test pass**. `package.json` runs:
74
-`node --test tests/*.test.js`
75
-while the repository test directory is `test/` (singular). GitHub Actions run `37047035443` therefore executed **0 tests** (`# tests 0`, `# pass 0`, `# fail 0`) and still exited successfully.
76
-
77
-## Security Regression — VERIFIED BY SOURCE INSPECTION
78
-The modular uploaded implementation on current `main` removed security boundaries present in the older worker implementation/tests:
79
-- `src/index.js` currently accepts POST requests without validating `X-Telegram-Bot-Api-Secret-Token`.
80
-- `src/index.js` does not restrict POST handling to `/telegram/webhook`.
81
-- `src/bot.js` currently does not enforce `OWNER_TELEGRAM_ID` before handling messages/callbacks.
82
-- Existing `test/security.test.js` explicitly expects fail-closed webhook secret validation and owner-only behavior, but those tests are currently not executed because of the CI path bug.
83
-
84
-Status: **BLOCKING — NOT SAFE TO CALL PRODUCTION-READY.**
85
-
86
-## Data-Trust / Correctness Findings
87
-Current `src/github.js` silently falls back to static/default data when GitHub calls fail. This can make unavailable or failed integrations look successful and conflicts with the project requirement to never present fabricated/demo data as live operational truth.
88
-Current `src/config.js` contains static status claims such as `100% SLA`, connected/operational services and security state; these are display defaults, not verified runtime telemetry.
89
-The Tools view includes hard-coded success outputs (for example a fixed ping latency) rather than measured operations.
90
-Status: **IMPLEMENTED UI, NOT TRUSTWORTHY RUNTIME TELEMETRY YET.**
91
-
92
-## UX/UI State
93
-Implemented direction on current main:
94
-- hierarchical inline keyboards;
95
-- one-message in-place callback navigation after the initial message;
96
-- parent back buttons;
97
-- breadcrumbs.
98
-Important gap relative to owner preference:
99
-- this is an Inline Keyboard design attached to messages, not a persistent Telegram Reply Keyboard replacing the phone keyboard.
100
-- `/start`, `/repos`, `/status` still create a new message because they are command entry points; navigation after callback uses message editing.
101
-
102
-## GitHub Reader State
103
-Repository code includes views/services for:
104
-- repositories;
105
-- files;
106
-- commits;
107
-- pull requests;
108
-- workflow/status.
109
-Previously observed Telegram tests from the owner confirmed repository/files/commits/PR/status reading before the uploaded redesign.
110
-**Regression of those live flows after the new uploaded architecture is NOT VERIFIED.**
64
+- Source and automated CI state are verified as described below.
65
+- Live Cloudflare deployment contents after the latest security/quality repair: **NOT YET VERIFIED IN THIS CHECKPOINT**.
66
+- Live Telegram mobile behavior after the latest repair: **NOT YET VERIFIED IN THIS CHECKPOINT**.
67
+
68
+## Completed Work — Verified
69
+### Telegram UX
70
+- Hierarchical Inline Keyboard navigation exists.
71
+- `/start` creates the initial menu message.
72
+- Callback navigation uses `editMessageText` on the same message.
73
+- Main menu sections: Repositories, Status, Tools, Settings, Security.
74
+- Repository submenu: Files, Pull Requests, Commits, Status/Tests, Back.
75
+- Explicit Back navigation is present.
76
+- Breadcrumb-style path text is present.
77
+
78
+### Security boundary
79
+Implemented and test-verified in `src/index.js`:
80
+- Telegram webhook processing is restricted to `POST /telegram/webhook`.
81
+- Missing `TELEGRAM_WEBHOOK_SECRET` fails closed with 503.
82
+- Wrong `X-Telegram-Bot-Api-Secret-Token` is rejected with 403.
83
+- Missing `OWNER_TELEGRAM_ID` fails closed.
84
+- Message and callback senders must match `OWNER_TELEGRAM_ID`.
85
+- Unauthorized senders are ignored without Telegram/GitHub network calls.
86
+- Temporary `/telegram/setup` route remains disabled.
87
+- Temporary diagnostic behavior does not expose Telegram ID/authorization details.
88
+
89
+### Data trust
90
+- `src/github.js` no longer returns sample/default operational data when GitHub fails.
91
+- Missing `GITHUB_TOKEN` is an explicit error.
92
+- GitHub HTTP failures are surfaced as errors.
93
+- Repository discovery uses the authenticated `/user/repos` endpoint so private accessible repositories can be returned.
94
+- Repository detail uses live repository metadata.
95
+- PRs, commits, files and GitHub Actions status are source-backed.
96
+- Hard-coded service health, `100% SLA`, fixed latency and fake security/token status claims were removed.
97
+- GitHub-derived menu content is HTML-escaped before Telegram HTML rendering.
98
+
99
+### Telegram API correctness
100
+- `TelegramClient` now throws for network errors, HTTP-level Telegram API failures and Telegram `{ok:false}` responses.
101
+- `message is not modified` can therefore be handled deliberately by the bot callback layer rather than silently treated as success.
102
+
103
+### CI
104
+- Test discovery corrected from the wrong `tests/*.test.js` path to `test/*.test.js`.
105
+- TDD RED evidence was captured after enabling the real suite and during Telegram error-propagation work.
106
+- Fresh GREEN evidence: GitHub Actions run `37050047446`, commit `40e31294950ba6e3d85744728476e81cc239fbe9`.
107
+- Exact result: `26` tests, `26` passed, `0` failed, `0` skipped/cancelled.
108
109
## Current Work / Last Checkpoint
110
WHERE WE WERE:
114
-- Owner requested Nexa Dev UX redesign to hierarchical menus, back navigation and reduced message spam.
111
+- A modular menu redesign had been uploaded to `main`, but CI ran zero tests, webhook/owner security had regressed, GitHub failures could silently turn into fake data, and status screens contained fabricated operational claims.
112
113
WHAT CHANGED:
117
-- Three `Add files via upload` commits (`65a8fbec...`, `453c0ddf...`, `2f55a22d...`) placed a modular menu redesign directly on `main`.
118
-- `src/index.js` is now only the Worker entrypoint and imports `NexaDevBot`; the old monolithic implementation is no longer the main source shape.
114
+- Real CI test discovery restored.
115
+- Fail-closed webhook authentication and owner-only authorization restored.
116
+- GitHub fallback/sample operational data removed.
117
+- Status/security/tool screens made non-fabricated.
118
+- Navigation tests rewritten for the current one-message architecture.
119
+- Telegram API failures now propagate correctly.
120
+- Full automated suite is green: run `37050047446`, 26/26 passing.
121
122
WHERE WE ARE NOW:
121
-- Menu redesign is materially present in source.
122
-- CI is false-green because zero tests run.
123
-- Critical webhook/owner security checks are missing from current main implementation.
124
-- Runtime/mobile behavior after this redesign is NOT VERIFIED.
123
+- Repository-level security, data-trust and navigation regression gates are green.
124
+- The source implements the requested one-message hierarchical Inline Keyboard flow.
125
+- Live deployment and real-phone Telegram smoke after this latest repair remain the final verification gap.
126
127
WHAT REMAINS:
127
-1. Restore fail-closed Telegram webhook secret validation and owner-only authorization without breaking modular navigation.
128
-2. Restrict webhook processing to the intended endpoint.
129
-3. Fix `package.json` test glob from `tests/*.test.js` to `test/*.test.js` (or equivalent reliable test discovery).
130
-4. Run the real security/navigation/bot/menu/index tests; fix failures and re-run.
131
-5. Remove or clearly label mock/static fallback data; failures must not masquerade as verified live GitHub/service state.
132
-6. Re-verify `/start → Repos → Repo → Files/Commits/PR/Status → Back` on the real Telegram bot/mobile runtime.
133
-7. Decide whether the final main menu should remain Inline Keyboard or move to the owner's preferred persistent Reply Keyboard shell.
128
+1. Verify the live Cloudflare root/health endpoint is serving the latest application version.
129
+2. Verify `/telegram/setup` remains unavailable in live runtime.
130
+3. On the real Telegram bot/mobile client, smoke-test: `/start → Repositories → repository → Files/Commits/PR/Status → Back → Main`.
131
+4. Confirm callback navigation edits the same menu message and does not create message spam.
132
+5. Decide separately whether to keep Inline Keyboard as the final UX or add a persistent Reply Keyboard shell; this is not required for the current in-place navigation implementation.
133
134
## Master Roadmap
136
-Phase 1 — Secure Telegram navigation core.
137
-Phase 2 — Trustworthy GitHub repository browsing and status telemetry.
138
-Phase 3 — Developer tools and controlled operations.
139
-Phase 4 — Security hardening, auditability and observability.
140
-Phase 5 — Mobile QA, release validation and documentation.
135
+Phase 1 — Secure Telegram navigation core: **IMPLEMENTED + AUTOMATED-VERIFIED; LIVE MOBILE VERIFICATION PENDING**.
136
+Phase 2 — Trustworthy GitHub repository browsing/status: **IMPLEMENTED + AUTOMATED-VERIFIED; LIVE TOKEN/RUNTIME SMOKE PENDING**.
137
+Phase 3 — Developer tools and controlled write operations: planned.
138
+Phase 4 — Security hardening, auditability and observability: ongoing after live verification.
139
+Phase 5 — Mobile QA, release validation and documentation: current next checkpoint.
140
141
## Requirements
142
- Owner-only personal bot.
144
-- Fail closed if webhook authentication configuration is missing or wrong.
143
+- Fail closed if webhook authentication/owner configuration is absent or wrong.
144
- No secret values committed to repository.
145
- No fabricated operational success/status.
146
- Minimal chat spam.
147
- Hierarchical navigation with reliable Back behavior.
149
-- Preserve working GitHub Reader flows.
148
+- Preserve GitHub Reader functionality.
149
- Mobile-first Telegram usability.
150
- Completion claims require implemented + tested + re-verified evidence.
151
152
## User Decisions
153
- Nexa Dev Bot is independent from Finora / Factor-easy application development; do not mix project state or Supabase requirements from those projects into this repository.
155
-- GitHub repository: `davoodmehraban89/nexa-dev-bot`.
154
+- Canonical repository: `davoodmehraban89/nexa-dev-bot`.
155
- Professional layered menus are desired.
157
-- User strongly prefers execution over explanatory chat.
158
-- User requires verification from execution, architecture/quality and QA/user perspectives before saying work is complete.
156
+- User prefers execution over explanatory chat.
157
+- Before saying a task is complete, verify from three perspectives: Execution, Architecture/Quality, QA/User.
158
159
## Architecture Decisions
161
-- `PROJECT_MEMORY.md` is the canonical continuity file for this project.
162
-- Modular source files are now the current main architecture; do not revert to the old monolithic file merely because an older branch contains it.
163
-- Security enforcement belongs at the Worker/update boundary and must not rely on display-only configuration.
164
-- Runtime failures must be explicit rather than silently replaced with plausible mock data.
160
+- `PROJECT_MEMORY.md` is the canonical continuity file.
161
+- Keep the modular source architecture; do not revert to the old monolithic Worker implementation.
162
+- Security enforcement belongs at the Worker/update boundary.
163
+- External integration failures must be explicit rather than replaced with plausible mock data.
164
+- Callback navigation edits the current Telegram message rather than sending a new message.
165
+- Initial command entry (`/start`, `/repos`, `/status`) may create an entry message; callback navigation must remain in-place.
166
167
## Data Model
167
-No persistent application database is verified or required for the current menu/read-only GitHub scope.
168
+No persistent application database is required or verified for the current read-only GitHub/menu scope.
169
170
## Security Rules
170
-- Never store Telegram bot token, GitHub token, webhook secret or credentials in committed files.
171
-- Validate Telegram webhook secret before parsing/processing privileged updates.
172
-- Enforce `OWNER_TELEGRAM_ID` for both message and callback flows.
171
+- Never commit Telegram token, GitHub token, webhook secret or private keys.
172
+- Validate webhook secret before processing Telegram updates.
173
+- Enforce `OWNER_TELEGRAM_ID` for messages and callbacks.
174
- Unauthorized callers must not receive private repository data.
174
-- Temporary diagnostic/setup endpoints must remain disabled unless explicitly reintroduced for a bounded setup operation and removed afterward.
175
+- Do not reintroduce temporary diagnostic/setup endpoints without a bounded need and explicit cleanup.
176
+- Do not display secret values or infer that a token is valid from static configuration text.
177
178
## Testing & Acceptance Criteria
177
-Completed means:
179
+A checkpoint is complete only after:
180
`IMPLEMENTED → VERIFIED → FIXED IF NEEDED → RE-VERIFIED`
179
-Required minimum gates for the navigation/security slice:
180
-- CI must execute a non-zero test count.
181
+Automated minimum gates:
182
+- CI executes a non-zero test count.
183
- Security tests pass.
182
-- Navigation tests pass.
183
-- Bot/menu/index tests pass.
184
-- Live Telegram mobile smoke confirms one-message callback navigation and working Back path.
185
-- GitHub read paths return real data or explicit errors; no silent fake success.
186
-
187
-## Known Issues
188
-- CI run `37047035443` is false-green with 0 tests because of the wrong test directory glob.
189
-- Current main lacks webhook-secret validation.
190
-- Current main lacks owner authorization enforcement.
191
-- Static/mock fallback data can be presented as if live.
192
-- Several service/security/ping status strings are hard-coded and not runtime measurements.
193
-- Live Cloudflare/Telegram state after the uploaded redesign is not verified.
184
+- Navigation/bot/menu/index tests pass.
185
+- GitHub fail-closed/data-trust tests pass.
186
+- Telegram API error propagation tests pass.
187
+Current automated evidence: run `37050047446` = 26 pass / 0 fail.
188
+Final release gate still required:
189
+- live Cloudflare smoke;
190
+- real Telegram mobile smoke of complete menu/back flow.
191
+
192
+## Known Issues / Remaining Gaps
193
+- Live Cloudflare deployment after the latest repair is not yet verified in this checkpoint.
194
+- Real Telegram mobile smoke after the latest repair is not yet verified.
195
+- The current files view is a source-backed listing but does not yet provide full deep folder/file browsing buttons in the new modular UI.
196
+- Service Status intentionally avoids claiming external uptime/latency without measured telemetry.
197
198
## Risks
196
-- Unauthorized Telegram user could exercise bot flows if current main is deployed as-is.
197
-- A forged POST to the Worker could be processed because the webhook secret is not checked.
198
-- False-green CI can allow regressions to reach main.
199
-- Mock fallback data can mislead operational decisions.
199
+- If Cloudflare has not deployed current `main`, runtime may temporarily differ from repository state.
200
+- A runtime secret/configuration mismatch can make the secure webhook fail closed; this is preferable to unauthorized access.
201
+- Future GitHub write operations require explicit permission scoping and stronger audit/confirmation rules than current read-only flows.
202
203
## Technical Debt
202
-- Correct test discovery and add a non-zero-test assertion/gate.
203
-- Make Telegram API client throw/propagate API `ok:false` failures instead of treating JSON responses as success by default.
204
-- Replace hard-coded service telemetry with measured/unknown states.
205
-- Add robust HTML escaping for GitHub-derived titles/names displayed with Telegram HTML parse mode.
206
-- Add folder/file navigation buttons if full tree browsing is required; current files view primarily renders a textual listing with refresh/back controls.
204
+- Add measured deployment/runtime telemetry if desired rather than static service claims.
205
+- Add deeper interactive folder navigation to the modular files view if required.
206
+- Consider a durable navigation/session store only if future flows require cross-message/session state; current callback data is sufficient for the existing hierarchy.
207
+- Track GitHub Actions deprecation warning for older action runtimes and upgrade actions when appropriate.
208
209
## Deployment / Release State
209
-- GitHub Actions CI exists and latest inspected run is green but invalid as a quality gate due to 0 executed tests.
210
-- Cloudflare live deployment: NOT VERIFIED in this reconciliation.
210
+- GitHub Actions: green on verified code checkpoint `40e31294950ba6e3d85744728476e81cc239fbe9`, run `37050047446`, 26/26 tests passing.
211
+- Cloudflare live deployment: pending direct runtime verification after this memory update.
212
+- Telegram live/mobile: pending owner smoke test after runtime verification.
213
214
## Important File Paths
215
- `PROJECT_MEMORY.md`
@@ -222,16 +224,19 @@ Required minimum gates for the navigation/security slice:
224
- `test/bot.test.js`
225
- `test/menu.test.js`
226
- `test/index.test.js`
227
+- `test/github.test.js`
228
+- `test/telegram.test.js`
229
- `.github/workflows/ci.yml`
230
- `wrangler.jsonc`
231
232
## Reference Assets
229
-No canonical UI image asset for Nexa Dev Bot is currently verified in `docs/project-memory/assets/`.
233
+No canonical Nexa Dev UI image asset is currently stored under `docs/project-memory/assets/`.
234
Status: Missing Asset.
235
236
## Change Log
237
- 2026-10-02: Initial continuity memory created.
234
-- 2026-10-02: Reconciled memory after modular menu redesign uploads. Recorded current architecture, false-green zero-test CI, verified source-level security regressions, data-trust issues and exact repair sequence.
238
+- 2026-10-02: Reconciled memory after modular menu redesign upload and recorded false-green CI/security/data-trust regressions.
239
+- 2026-10-02: Repaired real test discovery, webhook/owner security, GitHub fail-closed behavior, non-fabricated UI status, current navigation coverage and Telegram API failure handling. Automated verification reached 26/26 green in run `37050047446`.
240
241
## Next Executable Action
237
-Create a bounded security/CI repair slice from current `main`: restore webhook secret + owner authorization, fix test discovery, run the real test suite, fix regressions, re-run, then verify the live Telegram mobile menu flow before declaring the redesign complete.
242
+Verify the live Cloudflare deployment against current `main`, then run the final owner-device Telegram smoke flow without changing architecture unless that live test exposes a defect.