Personal Telegram developer console for GitHub

docs: add 2026-10-05-cp2-multifile-workspace implementation plan

davoodmehraban89 committed Oct 5, 2026 at 05:29 UTC 056756527e03f6ceff0f221ee7bdcd7cae7e0281
1 file changed +96
docs/superpowers/plans/2026-10-05-cp2-multifile-workspace.md new
+96
@@ -0,0 +1,96 @@
1 +# CP2 Multi-file Repository 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:** Extend the existing branch-only Workspace to atomically edit a bounded set of text files.
6 +
7 +**Architecture:** Version the durable Workspace schema, represent files as an ordered bounded collection, seal immutable multi-file Ready intents, and reuse the existing Git Data commit path to create one tree/commit on `nexa/edit-*`. Preserve single-file compatibility and fail closed on stale base/material.
8 +
9 +**Tech Stack:** Node.js ESM, Cloudflare Workers/Durable Objects, Telegram Bot API, GitHub Git Data API, node:test.
10 +
11 +**Spec:** docs/superpowers/specs/2026-10-05-control-plane-completion-design.md
12 +
13 +## Global Constraints
14 +- Never mutate `main` directly.
15 +- Owner-only; WRITE requires Safe Approval and durable replay protection.
16 +- Per-file existing text/binary/sensitive/LFS policy remains authoritative.
17 +- Callback data <=64 UTF-8 bytes; Telegram text <=4096 chars.
18 +- No draft/source content in audit metadata.
19 +
20 +## Review Focus
21 +- Existing single-file records migrate/read without corruption.
22 +- Duplicate/renamed paths cannot create ambiguous tree entries.
23 +- Aggregate payload limit fails explicitly before persistence.
24 +- Base SHA changes invalidate sealed intent.
25 +- Retry after provider partial failure is idempotent.
26 +
27 +---
28 +
29 +### Task 1: Versioned multi-file Workspace model
30 +**Files:**
31 +- Modify: `src/durable/workspace-store.js`
32 +- Modify: `src/core/workspace-store.js`
33 +- Test: `test/workspace-store.test.js`
34 +- Test: `test/workspace-store-file-input.test.js`
35 +
36 +**Interfaces:**
37 +- Consumes: existing owner-scoped workspace ID and single-file records.
38 +- Produces: `files[]` records with path/baseSha/baseText/draftText and schemaVersion.
39 +
40 +- [ ] Write failing tests for legacy-read migration, add/update/remove file, duplicate path rejection and aggregate bound.
41 +- [ ] Run targeted tests and confirm RED.
42 +- [ ] Implement minimal versioned storage and migration.
43 +- [ ] Run targeted tests and confirm GREEN.
44 +- [ ] Commit.
45 +
46 +### Task 2: Multi-file policy, diff and immutable Ready intent
47 +**Files:**
48 +- Modify: `src/core/workspace-policy.js`
49 +- Modify: `src/plugins/github/workspace.js`
50 +- Test: `test/workspace-policy.test.js`
51 +- Test: `test/workspace-editor-v2.test.js`
52 +
53 +**Interfaces:**
54 +- Consumes: versioned workspace files.
55 +- Produces: aggregate diff summary and immutable intent containing ordered file descriptors.
56 +
57 +- [ ] Add RED tests for per-file policy, aggregate diff, unchanged workspace, stale material/base and intent reuse.
58 +- [ ] Implement bounded aggregate validation/diff and intent sealing.
59 +- [ ] Run targeted tests GREEN and commit.
60 +
61 +### Task 3: Atomic multi-file Git tree commit
62 +**Files:**
63 +- Modify: `src/plugins/github/workspace-commit.js`
64 +- Modify: `src/github.js`
65 +- Test: `test/workspace-approved-recovery.test.js`
66 +- Test: `test/workspace-recovery-validation.test.js`
67 +
68 +**Interfaces:**
69 +- Consumes: approved immutable multi-file intent.
70 +- Produces: exactly one branch commit/tree on `nexa/edit-<workspaceId>`.
71 +
72 +- [ ] Add RED tests for one atomic tree, stale base rejection, partial-failure retry and reconciliation.
73 +- [ ] Implement minimal multi-blob/tree orchestration reusing current Git Data primitives.
74 +- [ ] Run targeted tests GREEN and commit.
75 +
76 +### Task 4: Telegram/Mini App multi-file UX and recovery
77 +**Files:**
78 +- Modify: `src/workspace-editor.js`
79 +- Modify: `src/plugins/github/plugin.js`
80 +- Modify: `src/bot.js`
81 +- Test: `test/telegram-menu-e2e.test.js`
82 +- Test: `test/workspace-editor-worker.test.js`
83 +
84 +**Interfaces:**
85 +- Consumes: workspace file collection and aggregate diff.
86 +- Produces: bounded add/select/remove/diff/ready/recovery views.
87 +
88 +- [ ] Add RED navigation/callback-limit/recovery tests.
89 +- [ ] Implement views without embedding raw long paths in callback data.
90 +- [ ] Run targeted tests GREEN and commit.
91 +
92 +### Task 5: CP2 release gate
93 +- [ ] Run full `npm test`; expect zero failures/skips caused by CP2.
94 +- [ ] Review diff for direct-main mutation, sensitive logging and callback overflow.
95 +- [ ] Update README/Guide/PROJECT_MEMORY for multi-file behavior.
96 +- [ ] PR, CI, Preview, locked-head merge, post-merge CI, exact-SHA deploy and production smoke.