Personal Telegram developer console for GitHub
docs: align operator plan with durable replay design
davoodmehraban89 committed
Oct 3, 2026 at 07:23 UTC
e59bc07accdf976a2cdb8e61f0ba0a2de83b6a1b
1 file changed
+43
-33
docs/superpowers/plans/2026-10-03-safe-github-ops.md
+43
-33
@@ -4,9 +4,9 @@
4
5
**Goal:** Add reusable Telegram approvals and safe GitHub workflow operations on top of the production-accepted plugin foundation.
6
7
-**Architecture:** Keep the existing `resolve -> policy -> execute` boundary. Add an HMAC-backed approval service between the first approval-required dispatch and a second approved dispatch, then extend the existing GitHub plugin/service/menu with workflow read/write actions. No new external dependency is required.
7
+**Architecture:** Keep the existing `resolve -> policy -> execute` boundary. Add an HMAC-backed approval service between the first approval-required dispatch and a second approved dispatch, persist one-time consume semantics through a SQLite Cloudflare Durable Object, then extend the existing GitHub plugin/service/menu with workflow read/write actions.
8
9
-**Tech Stack:** JavaScript ES modules, Node test runner, Cloudflare Workers Web Crypto, Telegram Bot API, GitHub REST API.
9
+**Tech Stack:** JavaScript ES modules, Node test runner, Cloudflare Workers Web Crypto, Cloudflare Durable Objects with SQLite storage, Telegram Bot API, GitHub REST API.
10
11
**Spec:** `docs/superpowers/specs/2026-10-03-safe-github-ops-design.md`
12
@@ -14,7 +14,8 @@
14
- Owner-only authorization remains enforced at the Worker boundary.
15
- `READ` executes immediately; `WRITE` and `DESTRUCTIVE` require verified approval.
16
- Approval tokens use HMAC-SHA-256 and never appear in audit logs.
17
-- No new paid service/resource is enabled.
17
+- One-time approval consumption is persisted through `APPROVAL_REPLAY_GUARD`; missing replay protection fails closed.
18
+- No optional AI/browser/third-party paid service is enabled in this phase; the Durable Object namespace is part of the required security architecture for replay protection.
19
- Existing GitHub repository/file UX remains backward compatible.
20
- Provider failures remain explicit; no fabricated success.
21
@@ -22,7 +23,8 @@
23
- Tampered/expired/wrong-owner approval callback must never reach provider execution.
24
- Telegram callback-data size overflow must fail closed before rendering an unusable button.
25
- GitHub token 401/403/409/422 responses must surface as failures, not success.
25
-- Duplicate approval callback must not intentionally execute provider code twice in the same Worker isolate.
26
+- Duplicate approval callback must not execute provider code twice even across Worker isolates.
27
+- Missing Durable Object binding must fail closed for approved WRITE execution.
28
- Existing READ navigation and Cloudflare fetch regression must remain green.
29
30
---
@@ -39,11 +41,11 @@
41
- Produces: `ApprovalService.issue(payload) -> token`, `ApprovalService.verify(token, expectations) -> payload`, `ApprovalService.consume(token, expectations) -> payload`.
42
- Produces: `ActionPolicy.evaluate({ action, isOwner, approved })`.
43
42
-- [ ] Write failing tests for valid issue/verify, tamper, expiry, wrong owner, wrong action, oversize and replay.
43
-- [ ] Run targeted tests and verify RED.
44
-- [ ] Implement minimal approval service using Web Crypto HMAC-SHA-256 and bounded base64url payloads.
45
-- [ ] Extend policy to allow approved owner WRITE/DESTRUCTIVE actions.
46
-- [ ] Run targeted tests and verify GREEN.
44
+- [x] Write failing tests for valid issue/verify, tamper, expiry, wrong owner, wrong action, oversize and replay.
45
+- [x] Run targeted tests and verify RED.
46
+- [x] Implement minimal approval service using Web Crypto HMAC-SHA-256 and bounded base64url payloads.
47
+- [x] Extend policy to allow approved owner WRITE/DESTRUCTIVE actions.
48
+- [x] Run targeted tests and verify GREEN.
49
50
### Task 2: Router approved dispatch and audit lifecycle
51
@@ -56,10 +58,10 @@
58
- Consumes: `context.approved === true` after approval verification.
59
- Produces: policy-enforced execution and approval lifecycle audit records without signed tokens.
60
59
-- [ ] Add failing tests proving unapproved write does not execute and approved write does.
60
-- [ ] Verify RED.
61
-- [ ] Pass `approved` into policy and add safe audit fields.
62
-- [ ] Verify GREEN and full router/audit tests.
61
+- [x] Add failing tests proving unapproved write does not execute and approved write does.
62
+- [x] Verify RED.
63
+- [x] Pass `approved` into policy and add safe audit fields.
64
+- [x] Verify GREEN and full router/audit tests.
65
66
### Task 3: GitHub workflow REST service
67
@@ -70,43 +72,50 @@
72
**Interfaces:**
73
- Produces: `listWorkflowRuns`, `getWorkflowRun`, `listWorkflowJobs`, `rerunFailedWorkflowRun`, `cancelWorkflowRun`.
74
73
-- [ ] Add failing path/method/body/error tests.
74
-- [ ] Verify RED.
75
-- [ ] Implement minimal authenticated REST methods through existing request helper/repository resolver.
76
-- [ ] Verify GREEN including 401/403/404/409/422 failure handling.
75
+- [x] Add failing path/method/body/error tests.
76
+- [x] Verify RED.
77
+- [x] Implement minimal authenticated REST methods through existing request helper/repository resolver.
78
+- [x] Verify GREEN including 401/403/404/409/422 failure handling.
79
80
### Task 4: GitHub plugin actions and workflow views
81
82
**Files:**
83
- Modify: `src/plugins/github/manifest.js`
84
- Modify: `src/plugins/github/plugin.js`
83
-- Modify: `src/menu.js`
85
- Test: `test/github-plugin.test.js`
86
- Test: `test/navigation.test.js`
87
88
**Interfaces:**
89
- Produces READ actions for workflow runs/jobs and WRITE actions for rerun/cancel.
89
-- Produces compact Telegram views and callback IDs using repository/run/job IDs.
90
+- Produces compact Telegram views and callback IDs using repository/run IDs.
91
91
-- [ ] Add failing route/view/risk tests.
92
-- [ ] Verify RED.
93
-- [ ] Add manifest actions, callback resolvers and bounded workflow views.
94
-- [ ] Verify GREEN and existing navigation regression suite.
92
+- [x] Add failing route/view/risk tests.
93
+- [x] Verify RED.
94
+- [x] Add manifest actions, callback resolvers and bounded workflow views.
95
+- [x] Verify GREEN and existing navigation regression suite.
96
96
-### Task 5: Telegram confirmation flow
97
+### Task 5: Telegram confirmation flow and durable replay protection
98
99
**Files:**
100
- Modify: `src/bot.js`
100
-- Test: `test/bot.test.js`
101
+- Modify: `src/index.js`
102
+- Create: `src/core/durable-replay-store.js`
103
+- Create: `src/durable/approval-replay-guard.js`
104
+- Modify: `wrangler.jsonc`
105
+- Test: `test/approval-flow.test.js`
106
+- Test: `test/durable-replay.test.js`
107
108
**Interfaces:**
109
- Consumes router `requiresApproval` response.
110
- Produces `approve:<token>` and `cancel:<token>` callbacks and a second approved dispatch.
111
+- Persists nonce consumption through `APPROVAL_REPLAY_GUARD` so a token cannot be consumed again from another Worker isolate.
112
106
-- [ ] Add failing tests for confirmation rendering, cancel, verified approval, malformed/expired token and duplicate consume.
107
-- [ ] Verify RED.
108
-- [ ] Integrate `ApprovalService` with bot callback flow; never log token.
109
-- [ ] Verify GREEN and existing `/start`, `/repos`, stale callback tests.
113
+- [x] Add failing tests for confirmation rendering, cancel, verified approval, malformed/expired token and duplicate consume.
114
+- [x] Verify RED.
115
+- [x] Integrate `ApprovalService` with bot callback flow; never log token.
116
+- [x] Add Durable Object replay adapter/guard and fail closed when the binding is unavailable.
117
+- [x] Export `ApprovalReplayGuard` and declare its SQLite Durable Object binding in Wrangler.
118
+- [x] Verify GREEN and existing `/start`, `/repos`, stale callback tests.
119
120
### Task 6: Local runtime command and documentation
121
@@ -118,17 +127,18 @@
127
**Interfaces:**
128
- Produces `npm start` -> `wrangler dev` for local Worker development.
129
121
-- [ ] Change local start command without altering production deploy workflow.
122
-- [ ] Document safe operations and provider permission requirement.
130
+- [x] Change local start command without altering production deploy workflow.
131
+- [x] Document safe operations, Durable Object replay guard and provider permission requirement.
132
- [ ] Update project checkpoint with exact test/PR/deploy evidence after verification.
133
134
### Task 7: PR, CI, deployment and runtime verification
135
136
**Files:** none unless fixes are required.
137
129
-- [ ] Run full CI through PR and inspect logs for discovered test count/pass/fail/skip.
138
+- [x] Run full PR CI and inspect logs: run `37094394332`, 15 test files, 78/78 tests passed, 0 failed/skipped.
139
- [ ] Review complete PR diff for scope and secret leakage.
140
- [ ] Merge only after green CI.
141
- [ ] Verify post-merge main CI and exact-commit Cloudflare deployment.
142
+- [ ] Verify the `APPROVAL_REPLAY_GUARD` binding and SQLite Durable Object on the active Cloudflare deployment.
143
- [ ] Verify owner-device READ navigation telemetry on current version.
134
-- [ ] Attempt a write smoke only if the existing runtime GitHub token already permits the chosen operation; otherwise record provider-permission smoke as `NOT VERIFIED` without rotating secrets automatically.
144
+- [ ] Attempt a write smoke only if the configured runtime GitHub token already permits the chosen operation and the owner explicitly confirms it in Telegram; otherwise record provider-permission smoke as `NOT VERIFIED` without rotating secrets automatically.