Personal Telegram developer console for GitHub
audit/telegram-menu-e2e-wave2
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 | # Safe GitHub Operator Implementation Plan |
| 2 | |
| 3 | > **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking. |
| 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, 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, 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 | |
| 13 | ## Global Constraints |
| 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 | - 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 | ## Review Focus |
| 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. |
| 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 | --- |
| 31 | |
| 32 | ### Task 1: Approval service and policy semantics |
| 33 | |
| 34 | **Files:** |
| 35 | - Create: `src/core/approval.js` |
| 36 | - Modify: `src/core/action-policy.js` |
| 37 | - Test: `test/approval.test.js` |
| 38 | - Test: `test/action-policy.test.js` |
| 39 | |
| 40 | **Interfaces:** |
| 41 | - Produces: `ApprovalService.issue(payload) -> token`, `ApprovalService.verify(token, expectations) -> payload`, `ApprovalService.consume(token, expectations) -> payload`. |
| 42 | - Produces: `ActionPolicy.evaluate({ action, isOwner, approved })`. |
| 43 | |
| 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 | |
| 52 | **Files:** |
| 53 | - Modify: `src/core/router.js` |
| 54 | - Test: `test/plugin-router.test.js` |
| 55 | - Test: `test/audit.test.js` |
| 56 | |
| 57 | **Interfaces:** |
| 58 | - Consumes: `context.approved === true` after approval verification. |
| 59 | - Produces: policy-enforced execution and approval lifecycle audit records without signed tokens. |
| 60 | |
| 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 | |
| 68 | **Files:** |
| 69 | - Modify: `src/github.js` |
| 70 | - Test: `test/github.test.js` |
| 71 | |
| 72 | **Interfaces:** |
| 73 | - Produces: `listWorkflowRuns`, `getWorkflowRun`, `listWorkflowJobs`, `rerunFailedWorkflowRun`, `cancelWorkflowRun`. |
| 74 | |
| 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` |
| 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. |
| 90 | - Produces compact Telegram views and callback IDs using repository/run IDs. |
| 91 | |
| 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 | |
| 97 | ### Task 5: Telegram confirmation flow and durable replay protection |
| 98 | |
| 99 | **Files:** |
| 100 | - Modify: `src/bot.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 | |
| 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 | |
| 122 | **Files:** |
| 123 | - Modify: `package.json` |
| 124 | - Modify: `README.md` |
| 125 | - Modify: `PROJECT_MEMORY.md` |
| 126 | |
| 127 | **Interfaces:** |
| 128 | - Produces `npm start` -> `wrangler dev` for local Worker development. |
| 129 | |
| 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 | |
| 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. |
| 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. |