Personal Telegram developer console for GitHub

docs: record deep file browser checkpoint

davoodmehraban89 committed Oct 2, 2026 at 23:07 UTC b2a2b61ffb92dc14508e16a19c6221a805445c76
1 file changed +94 -211
PROJECT_MEMORY.md
+94 -211
@@ -5,221 +5,114 @@
5 - Repository: `davoodmehraban89/nexa-dev-bot`
6 - Canonical branch: `main`
7 - Visibility: private
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
12 -1. Read this file completely before making changes.
13 -2. Verify the real repository head, recent commits, CI, source and runtime evidence.
14 -3. Prefer repository/runtime evidence over previous chat claims or stale memory.
15 -4. If this file is stale, repair it before implementation.
16 -5. Continue from `Current Work / Last Checkpoint`.
17 -6. After each durable checkpoint, update this file with evidence and remaining work.
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 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 -- Connected GitHub integration has repository read/write access.
27 -- Former branch `feat/telegram-main-inline-menu` is stale and is not the implementation baseline.
28 -- Current implementation baseline is `main`.
29 -- Latest code checkpoint before this memory-only commit: `e3fb9e9e34e4fa01e6aa24aded01d00c22680a51`.
30 -- Hardening PR: `#7` merged into `main` on 2026-10-02.
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
33 -Current source layout:
34 -- `src/index.js` — Cloudflare Worker HTTP boundary, webhook authentication, owner authorization and required Telegram transport configuration checks.
35 -- `src/bot.js` — Telegram update router and callback handling.
36 -- `src/telegram.js` — Telegram Bot API client with explicit fail-closed behavior and API error propagation.
37 -- `src/github.js` — authenticated GitHub REST reader; fails explicitly instead of returning fabricated fallback data.
38 -- `src/menu.js` — hierarchical inline-menu renderer and callback router.
39 -- `src/config.js` — minimal non-secret static configuration.
40 -- `.github/workflows/ci.yml` — Node.js CI with explicit zero-test discovery guard.
41 -- `test/` — security, navigation, bot, menu, worker, GitHub and Telegram client regression tests.
42 -
43 -## Technology Stack
44 -- JavaScript ES modules
45 -- Node.js 22 test runner
46 -- Telegram Bot API
47 -- GitHub REST API
48 -- Cloudflare Workers / Wrangler
49 -- GitHub Actions
50 -
51 -## Environments & Integrations
52 -Repository-verified:
53 -- Cloudflare Worker configuration exists in `wrangler.jsonc` with `src/index.js` as entrypoint.
54 -- Telegram Bot API integration exists.
55 -- GitHub API integration exists.
56 -- CI workflow exists.
57 -Runtime configuration required by code:
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.
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.
24 +- `src/config.js` — non-secret static config.
25 +- `.github/workflows/ci.yml` — Node 22 CI with non-zero test-discovery guard.
26 +- `test/` — security, worker, navigation, menu, GitHub and Telegram regression coverage.
27 +
28 +## Runtime Configuration
29 +Required names:
30 - `TELEGRAM_BOT_TOKEN`
31 - `TELEGRAM_WEBHOOK_SECRET`
32 - `OWNER_TELEGRAM_ID`
33 - `GITHUB_TOKEN`
34 - optional `GITHUB_OWNER`
63 -Secret values must never be committed to this file or the repository.
64 -
65 -## Current Production State
66 -- Source and automated CI state are verified as described below.
67 -- Live Cloudflare deployment contents after the latest hardening: **NOT VERIFIED IN THIS CHECKPOINT**.
68 -- Live Telegram mobile behavior after the latest hardening: **NOT VERIFIED IN THIS CHECKPOINT**.
35
70 -## Completed Work — Verified
71 -### Telegram UX
72 -- Hierarchical Inline Keyboard navigation exists.
36 +## Verified Security / Data Trust
37 +- Webhook only at `POST /telegram/webhook`.
38 +- Missing webhook secret, owner ID or bot token fails closed.
39 +- Wrong Telegram secret returns 403.
40 +- Non-owner updates are ignored before private-data access.
41 +- GitHub token absence and GitHub API failures are explicit errors; no fabricated fallback data.
42 +- Telegram network/API failures propagate; fake transport success is prohibited.
43 +- Temporary setup/diagnostic exposure is disabled.
44 +- Operational UI does not invent SLA, latency or external health claims.
45 +
46 +## Telegram UX
47 - `/start` creates the initial menu message.
74 -- Callback navigation uses `editMessageText` on the same message.
75 -- Main menu sections: Repositories, Status, Tools, Settings, Security.
76 -- Repository submenu: Files, Pull Requests, Commits, Status/Tests, Back.
77 -- Explicit Back navigation and breadcrumb-style path text are present.
78 -
79 -### Security boundary
80 -Implemented and automated-test verified:
81 -- Telegram webhook processing is restricted to `POST /telegram/webhook`.
82 -- Missing `TELEGRAM_WEBHOOK_SECRET` fails closed with 503.
83 -- Wrong `X-Telegram-Bot-Api-Secret-Token` is rejected with 403.
84 -- Missing `OWNER_TELEGRAM_ID` fails closed.
85 -- Message and callback senders must match `OWNER_TELEGRAM_ID`.
86 -- Unauthorized senders are ignored without private-data access.
87 -- Missing `TELEGRAM_BOT_TOKEN` now fails closed with 503 at the webhook boundary.
88 -- `TelegramClient` itself also throws if `TELEGRAM_BOT_TOKEN` is missing, preventing fake transport success.
89 -- Temporary setup and diagnostic behavior remains disabled.
90 -
91 -### Data trust
92 -- `src/github.js` no longer returns sample/default operational data when GitHub fails.
93 -- Missing `GITHUB_TOKEN` is an explicit error.
94 -- GitHub HTTP failures are surfaced as errors.
95 -- Repository discovery uses authenticated `/user/repos`.
96 -- Repository detail, PRs, commits, files and workflow status are source-backed.
97 -- Hard-coded service health, `100% SLA`, fixed latency and fake security/token status claims were removed.
98 -- GitHub-derived menu content is HTML-escaped before Telegram HTML rendering.
99 -
100 -### Telegram API correctness
101 -- `TelegramClient` throws for missing bot token, network errors, HTTP-level Telegram API failures and Telegram `{ok:false}` responses.
102 -- `message is not modified` can be handled deliberately by the callback layer rather than silently treated as success.
103 -
104 -### CI integrity
105 -- Test discovery corrected from `tests/*.test.js` to `test/*.test.js`.
106 -- CI now has an explicit `Verify test discovery` step that fails if no `test/*.test.js` files exist.
107 -- The guard currently discovers exactly 7 test files.
108 -- TDD RED evidence was observed during the missing-token hardening: first the worker returned 400 where the new test required 503; the implementation was then corrected.
109 -- Fresh GREEN evidence on merged `main`: GitHub Actions run `37053715526`, commit `e3fb9e9e34e4fa01e6aa24aded01d00c22680a51`.
110 -- Exact result: `28` tests, `28` passed, `0` failed, `0` skipped/cancelled.
48 +- Callback navigation uses `editMessageText` on the same Telegram message.
49 +- Main sections: Repositories, Status, Tools, Settings, Security.
50 +- Repository sections: Files, Pull Requests, Commits, Actions status, Back.
51 +- Back navigation and breadcrumb-style text exist.
52 +
53 +## Deep File Browser — 2026-10-02
54 +Branch/PR checkpoint:
55 +- Branch: `feat/deep-file-browser`
56 +- PR: `#8`
57 +- Red test commit: `f5a1a75180344b306c000b3db580cd55c06abc67`
58 +- Implementation head before this docs commit: `7a81ca8adf2594b2478b0c9d8f7d308ec6121ba8`
59 +- PR CI run: `37055098355`
60 +- Exact result: `29` tests, `29` passed, `0` failed, `0` skipped/cancelled.
61 +
62 +Implemented:
63 +- Repository menu callbacks now use numeric GitHub repository IDs returned by `/user/repos`.
64 +- Numeric IDs keep callback payloads short and allow repositories outside the configured default owner to resolve correctly.
65 +- Legacy name-based repository references remain supported.
66 +- Folder navigation uses Git tree SHA callbacks: `tree:<repoId>:<sha>`.
67 +- File preview uses Git blob SHA callbacks: `blob:<repoId>:<sha>`.
68 +- Tree/blob SHA input is validated as 40-char hexadecimal.
69 +- File/folder navigation remains in the same Telegram message.
70 +- File previews are HTML-escaped; oversized/non-base64 blobs are not rendered directly.
71 +- Directory views cap interactive entries at 30 and disclose omitted counts.
72 +- Root/project return buttons are always provided.
73 +
74 +TDD evidence:
75 +- New tests were committed first and CI failed with 4 expected navigation failures (`29 total / 25 pass / 4 fail`).
76 +- Implementation then changed `src/github.js` and `src/menu.js`.
77 +- Re-run CI passed `29/29`.
78
79 ## Current Work / Last Checkpoint
113 -WHERE WE WERE:
114 -- The menu redesign and earlier security/data-trust repairs were present, but two hardening gaps remained: CI could theoretically regress to zero discovered tests, and a missing Telegram bot token could still be represented as a fake successful transport call.
115 -
116 -WHAT CHANGED:
117 -- Added CI zero-test discovery guard.
118 -- Added regression test requiring `TelegramClient` to fail closed without `TELEGRAM_BOT_TOKEN`.
119 -- Removed mock success behavior from `TelegramClient`.
120 -- Added Worker-level required-token check returning 503 before Telegram update processing.
121 -- Updated worker tests to use a mocked Telegram transport only for the authorized test path.
122 -- PR `#7` merged into `main`.
123 -- Post-merge CI run `37053715526` passed 28/28 tests.
124 -
125 -WHERE WE ARE NOW:
126 -- Repository-level security, transport integrity, data-trust and navigation gates are green.
127 -- `main` contains the hardening changes.
128 -- Live deployment/runtime and real-phone Telegram smoke remain the outstanding verification boundary.
80 +WHERE WE ARE:
81 +- Deep interactive file/folder browsing is implemented and automated-test verified on PR #8.
82 +- PR #8 still requires the final docs-triggered CI re-run and merge to `main`.
83 +- Live Cloudflare verification remains blocked from the current execution environment by DNS resolution failure for the workers.dev hostname.
84 +- Real Telegram mobile smoke is still NOT VERIFIED.
85
86 WHAT REMAINS:
131 -1. Verify the live Cloudflare root/health endpoint is serving current code.
132 -2. Verify the live webhook rejects missing/wrong secrets and missing required runtime configuration as expected.
133 -3. On the real Telegram owner account, smoke-test: `/start → Repositories → repository → Files/Commits/PR/Status → Back → Main`.
134 -4. Confirm callback navigation edits the same menu message and does not create message spam.
135 -5. Confirm a non-owner Telegram account receives no bot response.
136 -6. Decide separately whether to keep Inline Keyboard as the final UX or later add a persistent Reply Keyboard shell; not required for current in-place navigation.
137 -
138 -## Master Roadmap
139 -Phase 1 — Secure Telegram navigation core: **IMPLEMENTED + AUTOMATED-VERIFIED; LIVE MOBILE VERIFICATION PENDING**.
140 -Phase 2 — Trustworthy GitHub repository browsing/status: **IMPLEMENTED + AUTOMATED-VERIFIED; LIVE TOKEN/RUNTIME SMOKE PENDING**.
141 -Phase 3 — Developer tools and controlled write operations: planned.
142 -Phase 4 — Security hardening, auditability and observability: ongoing after live verification.
143 -Phase 5 — Mobile QA, release validation and documentation: current next checkpoint.
144 -
145 -## Requirements
146 -- Owner-only personal bot.
147 -- Fail closed if webhook authentication, owner configuration or Telegram transport configuration is absent/wrong.
148 -- No secret values committed to repository.
149 -- No fabricated operational success/status.
150 -- Minimal chat spam.
151 -- Hierarchical navigation with reliable Back behavior.
152 -- Preserve GitHub Reader functionality.
153 -- Mobile-first Telegram usability.
154 -- Completion claims require implemented + tested + re-verified evidence.
155 -
156 -## User Decisions
157 -- 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.
158 -- Canonical repository: `davoodmehraban89/nexa-dev-bot`.
159 -- Professional layered menus are desired.
160 -- User prefers execution over explanatory chat.
161 -- Before saying a task is complete, verify from Execution, Architecture/Quality and QA/User perspectives.
162 -
163 -## Architecture Decisions
164 -- `PROJECT_MEMORY.md` is the canonical continuity file.
165 -- Keep the modular source architecture; do not revert to the old monolithic Worker implementation.
166 -- Security enforcement belongs at the Worker/update boundary.
167 -- External integration failures must be explicit rather than replaced with plausible mock data.
168 -- Callback navigation edits the current Telegram message rather than sending a new message.
169 -- Runtime client abstractions must fail closed when required credentials are missing; test doubles belong in tests, not production semantics.
170 -
171 -## Data Model
172 -No persistent application database is required or verified for the current read-only GitHub/menu scope.
173 -
174 -## Security Rules
175 -- Never commit Telegram token, GitHub token, webhook secret or private keys.
176 -- Validate webhook secret before processing Telegram updates.
177 -- Enforce `OWNER_TELEGRAM_ID` for messages and callbacks.
178 -- Require `TELEGRAM_BOT_TOKEN` before processing owner updates.
179 -- Unauthorized callers must not receive private repository data.
180 -- Do not reintroduce temporary diagnostic/setup endpoints without a bounded need and explicit cleanup.
181 -- Do not display secret values or infer that a token is valid from static configuration text.
182 -
183 -## Testing & Acceptance Criteria
87 +1. Verify CI for this documentation commit and merge PR #8 into `main` only if green.
88 +2. Verify post-merge CI on `main`.
89 +3. Verify the live Cloudflare root/health/status endpoints from an environment that can resolve the workers.dev hostname.
90 +4. Owner-device Telegram smoke: `/start → Repositories → repository → Files → folder → file preview → root → project → Commits/PR/Status → Back → Main`.
91 +5. Confirm callbacks create no extra bot messages.
92 +6. Confirm a non-owner Telegram account receives no private bot response.
93 +
94 +## Acceptance Rules
95 A checkpoint is complete only after:
96 `IMPLEMENTED → VERIFIED → FIXED IF NEEDED → RE-VERIFIED`
186 -Automated minimum gates:
187 -- CI discovers at least one test file and fails if it discovers zero.
188 -- Security tests pass.
189 -- Navigation/bot/menu/index tests pass.
190 -- GitHub fail-closed/data-trust tests pass.
191 -- Telegram missing-token/API-error propagation tests pass.
192 -Current automated evidence: run `37053715526` = 28 pass / 0 fail.
193 -Final release gate still required:
194 -- live Cloudflare smoke;
195 -- real Telegram mobile smoke of complete menu/back flow.
196 -
197 -## Known Issues / Remaining Gaps
198 -- Live Cloudflare deployment after the latest hardening is not yet verified here.
199 -- Real Telegram mobile smoke after the latest hardening is not yet verified.
200 -- Current files view is source-backed but deep interactive folder/file browsing remains limited in the modular UI.
201 -- Service Status intentionally avoids claiming external uptime/latency without measured telemetry.
202 -- GitHub Actions currently reports a deprecation warning for actions using Node 20 internals; builds still pass under the current runner.
203 -
204 -## Risks
205 -- If Cloudflare has not deployed current `main`, runtime may differ from repository state.
206 -- Missing runtime secrets now intentionally cause fail-closed behavior and service errors rather than silent fake success.
207 -- Future GitHub write operations require explicit permission scoping and stronger audit/confirmation rules than current read-only flows.
208 -
209 -## Technical Debt
210 -- Verify and document production deployment/runtime state.
211 -- Add deeper interactive folder navigation if required.
212 -- Consider durable navigation/session storage only if future flows require cross-message/session state.
213 -- Track GitHub Actions runtime deprecation warnings and upgrade actions when appropriate.
214 -
215 -## Deployment / Release State
216 -- GitHub `main` code checkpoint: `e3fb9e9e34e4fa01e6aa24aded01d00c22680a51`.
217 -- Hardening PR `#7`: merged.
218 -- GitHub Actions post-merge run: `37053715526` = 28/28 passing.
219 -- Cloudflare live deployment: NOT VERIFIED in this checkpoint.
220 -- Telegram live/mobile: NOT VERIFIED in this checkpoint.
221 -
222 -## Important File Paths
97 +Minimum automated gates:
98 +- Non-zero discovered test files.
99 +- Security tests green.
100 +- Navigation/bot/menu/index tests green.
101 +- GitHub fail-closed/data-trust tests green.
102 +- Telegram missing-token/API-error tests green.
103 +
104 +## Known Gaps / Technical Debt
105 +- Live Cloudflare deployment content is not verified in this environment.
106 +- Real mobile Telegram smoke is not verified yet.
107 +- GitHub Actions emits a Node-20-runtime deprecation warning for `actions/checkout@v4` and `actions/setup-node@v4`; current CI still passes, but action upgrades should be handled in a separate verified slice.
108 +- Persistent navigation/session storage is not required for current stateless callback flow.
109 +
110 +## Project Boundaries
111 +- Nexa Dev Bot is independent from Finora / Factor-easy and has no Supabase requirement in this project.
112 +- Do not mix state or migrations from other projects.
113 +- Keep secrets out of code, logs and documentation.
114 +
115 +## Important Paths
116 - `PROJECT_MEMORY.md`
117 - `src/index.js`
118 - `src/bot.js`
@@ -237,15 +130,5 @@ Final release gate still required:
130 - `.github/workflows/ci.yml`
131 - `wrangler.jsonc`
132
240 -## Reference Assets
241 -No canonical Nexa Dev UI image asset is currently stored under `docs/project-memory/assets/`.
242 -Status: Missing Asset.
243 -
244 -## Change Log
245 -- 2026-10-02: Initial continuity memory created.
246 -- 2026-10-02: Reconciled modular redesign and recorded false-green CI/security/data-trust regressions.
247 -- 2026-10-02: Repaired test discovery, webhook/owner security, GitHub fail-closed behavior, non-fabricated status screens and Telegram API error handling.
248 -- 2026-10-02: Hardening PR #7 added zero-test CI guard and fail-closed Telegram token handling; merged to `main`; post-merge CI `37053715526` passed 28/28.
249 -
133 ## Next Executable Action
251 -Verify the live Cloudflare deployment against current `main`, then run the final owner-device Telegram smoke flow. Do not change the architecture unless live evidence exposes a defect.
134 +Wait for the PR #8 CI run for this docs commit; if green, merge to `main`, verify `main` CI, then continue to live/mobile validation or the next independent hardening slice.