Personal Telegram developer console for GitHub
fix/phase2-file-editor-selection
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 | # Phase 2 Multi-file Workspace 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:** Complete the existing partially implemented multi-file Workspace so an owner can build, review, seal, approve and atomically publish a bounded multi-file Change Set to a dedicated `nexa/edit-*` branch without weakening the current security gates. |
| 6 | |
| 7 | **Architecture:** Reuse the existing schemaVersion 2 Durable Workspace model, multi-file store methods and atomic Git blob/tree/commit orchestration already present on `main`. Finish the user-facing controller/editor/sealing path so every material file is represented in one deterministic immutable intent, and harden reconciliation/security tests around the existing single branch-ref publication point. |
| 8 | |
| 9 | **Tech Stack:** JavaScript ES modules, Node built-in test runner, Cloudflare Workers + Durable Objects, Telegram Bot API/Mini App, GitHub Git Data API. |
| 10 | |
| 11 | **Spec:** `docs/superpowers/specs/2026-10-05-phase2-multifile-workspace-design.md` |
| 12 | |
| 13 | ## Global Constraints |
| 14 | |
| 15 | - Owner-only Telegram boundary remains mandatory. |
| 16 | - READ stays owner-only; WRITE/DESTRUCTIVE stay behind central Policy and Safe Approval. |
| 17 | - Kill Switch is checked before mutation and mutation fails closed when Kill Switch state is unreadable. |
| 18 | - No direct default-branch mutation, force update, automatic merge/rebase or silent conflict resolution. |
| 19 | - The only publication point is advancing the dedicated `nexa/edit-<workspaceId>` branch ref after all blobs/tree/commit objects exist. |
| 20 | - Source/draft bodies, secrets and signed approval material never enter callbacks, audit, incident data or logs. |
| 21 | - Single-file Workspace remains compatible as a one-entry Change Set. |
| 22 | - Existing size/path/binary/LFS safety policy remains enforced for every file. |
| 23 | - Every implementation change follows RED → GREEN TDD and lands in small reviewable commits. |
| 24 | |
| 25 | ## Review Focus |
| 26 | |
| 27 | - Adding the same normalized path twice must be rejected without changing the Change Set. |
| 28 | - Reordering, adding, removing or editing files after Ready must invalidate the sealed intent and require a fresh approval. |
| 29 | - Mixed changed/unchanged files must seal and publish only a deterministic ordered descriptor set while keeping the aggregate intent stable. |
| 30 | - Failure after Git commit creation but before/around ref creation must reconcile against exact candidate/ref evidence and never publish a different commit. |
| 31 | - Multi-file Editor/API input must remain owner-bound and must never introduce a GitHub provider write path. |
| 32 | |
| 33 | --- |
| 34 | |
| 35 | ### Task 1: Complete multi-file Change Set controller and views |
| 36 | |
| 37 | **Files:** |
| 38 | - Modify: `src/plugins/github/workspace.js` |
| 39 | - Test: `test/workspace-multifile.test.js` |
| 40 | - Test: `test/workspace-editor-v2.test.js` |
| 41 | |
| 42 | **Interfaces:** |
| 43 | - Consumes: `DurableWorkspaceStoreClient.getWorkspace()`, `upsertWorkspaceFile()`, `updateWorkspaceFileDraft()`, `removeWorkspaceFile()`. |
| 44 | - Produces: controller callbacks that render all Change Set files, allow adding a safe repository file to the existing Workspace, remove a non-final file, and preserve the existing one-file UX. |
| 45 | |
| 46 | - [ ] **Step 1: Write failing controller tests** |
| 47 | - Workspace view with two files lists both paths and a bounded file count. |
| 48 | - A callback for adding a repository file resolves to a READ operation first and performs no provider mutation. |
| 49 | - Removing a file updates durable state and returns to the same Workspace. |
| 50 | - Duplicate path addition is surfaced as a validation error. |
| 51 | |
| 52 | - [ ] **Step 2: Run focused tests** |
| 53 | Run: `node --test test/workspace-multifile.test.js test/workspace-editor-v2.test.js` |
| 54 | Expected: new assertions FAIL because controller/UI only treats the primary file as editable material. |
| 55 | |
| 56 | - [ ] **Step 3: Implement bounded multi-file controller behavior** |
| 57 | Add callback parsing and rendering around existing store methods; keep callback payloads to opaque Workspace/navigation handles and never embed source/draft text. |
| 58 | |
| 59 | - [ ] **Step 4: Run focused tests** |
| 60 | Run: `node --test test/workspace-multifile.test.js test/workspace-editor-v2.test.js` |
| 61 | Expected: PASS. |
| 62 | |
| 63 | - [ ] **Step 5: Commit** |
| 64 | `git commit -am "feat(workspace): expose multi-file change set controls"` |
| 65 | |
| 66 | ### Task 2: Make Mini App editor file-aware without adding provider mutation |
| 67 | |
| 68 | **Files:** |
| 69 | - Modify: `src/workspace-editor.js` |
| 70 | - Test: `test/workspace-editor-v2.test.js` |
| 71 | - Test: `test/workspace-editor-worker.test.js` |
| 72 | |
| 73 | **Interfaces:** |
| 74 | - Consumes: Workspace `files[]`, `updateWorkspaceFileDraft({ ownerId, workspaceId, path, text, digest })`. |
| 75 | - Produces: GET response containing bounded file metadata and selected file draft; PUT accepting `workspaceId`, `path`, `text`. |
| 76 | |
| 77 | - [ ] **Step 1: Write failing editor API tests** |
| 78 | - GET returns all file paths plus the selected file. |
| 79 | - PUT for a non-primary path calls only `updateWorkspaceFileDraft`. |
| 80 | - Invalid/non-member path returns an explicit error. |
| 81 | - No GitHub/provider object is accepted or invoked. |
| 82 | |
| 83 | - [ ] **Step 2: Run focused tests** |
| 84 | Run: `node --test test/workspace-editor-v2.test.js test/workspace-editor-worker.test.js` |
| 85 | Expected: FAIL on non-primary selection/save. |
| 86 | |
| 87 | - [ ] **Step 3: Implement file selection** |
| 88 | Extend the editor request/page with a bounded file selector and path-scoped Draft save while preserving Telegram `initData` validation, CSP and existing size limits. |
| 89 | |
| 90 | - [ ] **Step 4: Run focused tests** |
| 91 | Run: `node --test test/workspace-editor-v2.test.js test/workspace-editor-worker.test.js` |
| 92 | Expected: PASS. |
| 93 | |
| 94 | - [ ] **Step 5: Commit** |
| 95 | `git commit -am "feat(workspace): make mini app editor file-aware"` |
| 96 | |
| 97 | ### Task 3: Seal deterministic multi-file Ready intents and aggregate Diff |
| 98 | |
| 99 | **Files:** |
| 100 | - Modify: `src/plugins/github/workspace.js` |
| 101 | - Modify: `src/core/workspace-policy.js` only if a focused aggregate helper is needed |
| 102 | - Test: `test/workspace-multifile.test.js` |
| 103 | - Test: `test/workspace-policy.test.js` |
| 104 | - Test: `test/workspace-store.test.js` |
| 105 | |
| 106 | **Interfaces:** |
| 107 | - Consumes: ordered `workspace.files[]`, `digestText()`, existing `sealIntent()`. |
| 108 | - Produces: immutable intent with `files: [{ path, sourceBlobSha, contentDigest }]`, aggregate deterministic `intentDigest`, one `commitMessageDigest`, target branch and exact base SHA/tree SHA. |
| 109 | |
| 110 | - [ ] **Step 1: Write failing sealing/diff tests** |
| 111 | - Two changed files produce one aggregate view and one ordered `files[]` intent. |
| 112 | - File order/list/material change alters the intent digest and invalidates prior Ready. |
| 113 | - Unchanged Change Set cannot Ready. |
| 114 | - Single-file intent stays compatible. |
| 115 | |
| 116 | - [ ] **Step 2: Run focused tests** |
| 117 | Run: `node --test test/workspace-multifile.test.js test/workspace-policy.test.js test/workspace-store.test.js` |
| 118 | Expected: FAIL because current controller seals only legacy primary-file fields. |
| 119 | |
| 120 | - [ ] **Step 3: Implement deterministic Change Set material** |
| 121 | Use the durable `files[]` order, validate every file against existing policy, include only bounded descriptors/digests in the sealed intent, and render per-file plus aggregate Diff without exposing draft bodies outside the normal bounded UI. |
| 122 | |
| 123 | - [ ] **Step 4: Run focused tests** |
| 124 | Run: `node --test test/workspace-multifile.test.js test/workspace-policy.test.js test/workspace-store.test.js` |
| 125 | Expected: PASS. |
| 126 | |
| 127 | - [ ] **Step 5: Commit** |
| 128 | `git commit -am "feat(workspace): seal deterministic multi-file intents"` |
| 129 | |
| 130 | ### Task 4: Harden atomic publication, reconciliation and security gates |
| 131 | |
| 132 | **Files:** |
| 133 | - Modify: `src/plugins/github/workspace-commit.js` |
| 134 | - Modify: `src/plugins/github/workspace.js` only for evidence output |
| 135 | - Test: `test/workspace-multifile-commit.test.js` |
| 136 | - Test: `test/kill-switch.test.js` |
| 137 | - Test: `test/approval-flow.test.js` |
| 138 | - Test: `test/audit.test.js` |
| 139 | |
| 140 | **Interfaces:** |
| 141 | - Consumes: existing GitHub `createGitBlob`, `createGitTree`, `createGitCommit`, `createGitBranchRef`, `getGitRef`, exact sealed intent and durable commit state. |
| 142 | - Produces: one deterministic candidate commit and one branch-ref publication result with bounded evidence. |
| 143 | |
| 144 | - [ ] **Step 1: Write failing negative tests** |
| 145 | - Partial blob/tree/commit failure never calls `createGitBranchRef`. |
| 146 | - Ambiguous ref-create failure reconciles only when observed ref equals exact candidate SHA. |
| 147 | - Existing unexpected target ref fails explicitly. |
| 148 | - Changed file list/order/digest after Ready is stale. |
| 149 | - Kill Switch locked/unreadable blocks provider mutation. |
| 150 | - Audit result contains descriptors/digests/SHA only, never source/draft content or approval token. |
| 151 | |
| 152 | - [ ] **Step 2: Run focused tests** |
| 153 | Run: `node --test test/workspace-multifile-commit.test.js test/kill-switch.test.js test/approval-flow.test.js test/audit.test.js` |
| 154 | Expected: any uncovered contract FAILS before production code is changed. |
| 155 | |
| 156 | - [ ] **Step 3: Implement minimal reconciliation/security fixes** |
| 157 | Preserve the branch ref as the only publication point; do not add compensating writes, force updates or default-branch mutation. |
| 158 | |
| 159 | - [ ] **Step 4: Run focused tests** |
| 160 | Run: `node --test test/workspace-multifile-commit.test.js test/kill-switch.test.js test/approval-flow.test.js test/audit.test.js` |
| 161 | Expected: PASS. |
| 162 | |
| 163 | - [ ] **Step 5: Commit** |
| 164 | `git commit -am "fix(workspace): harden atomic multi-file publication"` |
| 165 | |
| 166 | ### Task 5: Whole-phase regression, docs and production acceptance gate |
| 167 | |
| 168 | **Files:** |
| 169 | - Modify: `README.md` |
| 170 | - Modify: `docs/OPERATIONS_RUNBOOK.md` |
| 171 | - Modify: `PROJECT_MEMORY.md` |
| 172 | - Create: `docs/PHASE2_MULTIFILE_ACCEPTANCE.md` |
| 173 | - Test: `test/final-acceptance-contract.test.js` or a focused new `test/phase2-multifile-acceptance.test.js` |
| 174 | |
| 175 | **Interfaces:** |
| 176 | - Consumes: all prior task behavior. |
| 177 | - Produces: permanent regression contract and production acceptance record. |
| 178 | |
| 179 | - [ ] **Step 1: Add documentation contract test** |
| 180 | Assert docs state: multi-file Change Set, branch-only publication, exact base SHA, Safe Approval, Kill Switch, no direct `main` mutation, evidence requirements and single-file compatibility. |
| 181 | |
| 182 | - [ ] **Step 2: Run full suite** |
| 183 | Run: `npm test` |
| 184 | Expected: all tests PASS with zero fail/skip/cancelled. |
| 185 | |
| 186 | - [ ] **Step 3: Update operational docs** |
| 187 | Document the multi-file user flow, failure recovery, stale/reseal behavior and production smoke procedure without storing source bodies or secrets. |
| 188 | |
| 189 | - [ ] **Step 4: Re-run full suite** |
| 190 | Run: `npm test` |
| 191 | Expected: all tests PASS. |
| 192 | |
| 193 | - [ ] **Step 5: Commit** |
| 194 | `git commit -am "docs(workspace): record phase 2 multi-file acceptance gate"` |
| 195 | |
| 196 | - [ ] **Step 6: PR and production verification** |
| 197 | Open one Phase 2 PR from the implementation branch. Require exact-head green CI, review the exact diff, merge with expected-head locking, then verify post-merge exact-SHA CI and Cloudflare deploy/runtime evidence. |
| 198 | |
| 199 | - [ ] **Step 7: Owner-device production smoke** |
| 200 | On a safe repository text change set with at least two files: confirm exact aggregate/per-file Diff, enter one commit message, Ready, Safe Approval, verify no provider mutation before approval, then approve and verify one `nexa/edit-*` branch commit contains both intended changes while `main` remains unchanged. |
| 201 | |
| 202 | - [ ] **Step 8: Close acceptance** |
| 203 | Record exact merge SHA, CI run, deploy/version evidence, target branch, resulting commit SHA and owner-device/runtime outcome in `docs/PHASE2_MULTIFILE_ACCEPTANCE.md`. Only then mark Phase 2 complete. |