Personal Telegram developer console for GitHub

docs: design Cloudflare Ops READ plugin

davoodmehraban89 committed Oct 4, 2026 at 16:58 UTC b63c728b9332765787ef58717c6cd1c8f14b3b55
1 file changed +192
docs/superpowers/specs/2026-10-04-cloudflare-ops-read-design.md new
+192
@@ -0,0 +1,192 @@
1 +# Cloudflare Ops READ Plugin — Design
2 +
3 +Date: 2026-10-04
4 +Status: Design approved in chat; implementation pending written-spec review
5 +Base: `main` at `11dc458890bfe0e1dc0e5374f405d5e8965cc355`
6 +
7 +## 1. Goal
8 +
9 +Add Cloudflare as a first-class, read-only operational provider in Nexa Dev Bot so the Telegram owner can inspect the real production Worker state without exposing sensitive diagnostics through the public HTTP surface.
10 +
11 +This phase is deliberately READ-only. It does not add deploy, redeploy, rollback, settings mutation, secret mutation, route mutation, or any other Cloudflare WRITE/DESTRUCTIVE action.
12 +
13 +## 2. Product outcome
14 +
15 +From the owner-only Telegram operational console, Nexa can report source-backed Cloudflare information for the configured Worker, including:
16 +
17 +- active deployment and active Worker version;
18 +- traffic allocation for the active deployment;
19 +- Worker bindings as safe names/types only;
20 +- Durable Object bindings and class names where the Cloudflare API exposes them;
21 +- observability/logging/tracing state;
22 +- safe runtime/version metadata useful for operations;
23 +- explicit provider failures instead of fabricated healthy state.
24 +
25 +The existing public `/status` endpoint remains minimal health-only and MUST NOT expose these diagnostics.
26 +
27 +## 3. Architectural approach
28 +
29 +Cloudflare becomes an independent provider/plugin under `src/plugins/cloudflare/`, following the existing provider/plugin separation rather than embedding Cloudflare API calls in `src/ops-menu.js`.
30 +
31 +The provider owns Cloudflare HTTP/API semantics and normalization. The Telegram/Ops layer consumes a narrow normalized interface and owns presentation only.
32 +
33 +Expected logical components:
34 +
35 +1. **Cloudflare client/provider** — authenticated GET requests, response validation, redacted errors, normalization.
36 +2. **Cloudflare plugin registration** — declares READ actions and risk metadata through the existing plugin/action registry pattern.
37 +3. **Operational diagnostics integration** — obtains a Cloudflare snapshot without coupling menu rendering to Cloudflare REST payload shapes.
38 +4. **Telegram views** — render production state, refresh/recovery controls, and explicit unavailable/error states.
39 +
40 +No Cloudflare provider code may depend on Telegram formatting.
41 +
42 +## 4. Configuration and credentials
43 +
44 +Runtime configuration must use bindings/secrets; credentials MUST NOT be hard-coded.
45 +
46 +Required Cloudflare provider inputs are the account identifier, Worker/script name, and an API credential with only the permissions required by the READ endpoints used by this feature.
47 +
48 +Implementation must first inspect the current runtime/config pattern and reuse existing configuration where practical. If a new Worker secret is required, only its configured/missing state may be rendered or logged; its value must never enter source, tests, audit records, Telegram messages, PR text, or diagnostics.
49 +
50 +The existing GitHub Actions deployment credentials are not assumed to be available automatically inside the running Worker.
51 +
52 +## 5. Cloudflare API contract
53 +
54 +Before implementation, each Cloudflare endpoint must be selected from the current Cloudflare OpenAPI/documentation rather than model memory.
55 +
56 +The initial provider should use the minimum endpoint set needed to obtain:
57 +
58 +- Worker deployments;
59 +- Worker versions/version metadata;
60 +- Worker settings/bindings and observability configuration.
61 +
62 +The provider must tolerate fields absent from Cloudflare responses and normalize optional values rather than leaking raw provider payloads into the UI.
63 +
64 +## 6. Security boundary
65 +
66 +All new actions in this phase are `READ`.
67 +
68 +Existing Nexa owner-only authorization remains authoritative. This feature creates no alternative HTTP diagnostics endpoint and no bypass around Telegram owner validation.
69 +
70 +The provider and presentation layer MUST NOT expose:
71 +
72 +- API tokens or authorization headers;
73 +- secret binding values;
74 +- Telegram/GitHub credentials;
75 +- signed approval material;
76 +- source/draft text;
77 +- raw Cloudflare error bodies when they could contain sensitive material.
78 +
79 +Bindings may expose only safe metadata required for operations, such as binding name, type, and Durable Object class name. Secret-text bindings are represented as configured metadata only.
80 +
81 +Cloudflare failure must fail explicitly. A failed API request must never be translated into a healthy/green provider state.
82 +
83 +## 7. Public status boundary
84 +
85 +`/status` remains a public minimal health endpoint.
86 +
87 +Detailed Cloudflare account, deployment, binding, observability, version, or provider-error information is owner-only through Telegram. Regression coverage must prevent accidental publication of the new snapshot through `/status`.
88 +
89 +## 8. Telegram UX
90 +
91 +The operational console should expose a clearly named Cloudflare view from the existing Ops/Status area rather than creating a misleading top-level placeholder.
92 +
93 +The view should show, when available:
94 +
95 +- provider connection state;
96 +- Worker/script identity;
97 +- active deployment/version;
98 +- traffic percentage/allocation;
99 +- observability/logging/tracing state;
100 +- safe binding summary;
101 +- refresh control;
102 +- back/recovery navigation.
103 +
104 +Unavailable data must be labelled unavailable/unknown, not guessed. Provider errors must be concise and redacted.
105 +
106 +Telegram message text must remain within the 4096-character limit and callback data within 64 bytes. If binding detail could overflow the message, the UI must summarize or paginate rather than truncate security-relevant state ambiguously.
107 +
108 +## 9. Data flow
109 +
110 +1. Owner opens Cloudflare/Ops view in Telegram.
111 +2. Existing bot owner boundary authorizes the request.
112 +3. Ops orchestration calls the Cloudflare READ provider/plugin.
113 +4. Provider performs authenticated Cloudflare GET requests.
114 +5. Provider validates and normalizes responses into a safe operational snapshot.
115 +6. UI renders only the normalized snapshot.
116 +7. Errors are redacted and rendered as explicit provider failures.
117 +
118 +No Safe Approval is required because this phase performs no provider mutation.
119 +
120 +## 10. Error handling
121 +
122 +The provider must distinguish at least:
123 +
124 +- provider not configured;
125 +- authentication/permission failure;
126 +- Worker/script not found;
127 +- Cloudflare/network/provider failure;
128 +- malformed/unexpected provider response;
129 +- partial-data state when one safe READ succeeds and another fails.
130 +
131 +A partial snapshot may render successful facts alongside an explicit warning for unavailable sections. It must not report the overall Cloudflare provider as fully healthy if required probes failed.
132 +
133 +## 11. Testing strategy
134 +
135 +Implementation follows TDD: RED before production implementation.
136 +
137 +Minimum automated coverage:
138 +
139 +- provider request construction and authenticated READ behavior;
140 +- normalization of deployments, versions, settings/bindings, and observability;
141 +- no secret binding values in normalized output;
142 +- redaction of provider errors;
143 +- explicit configured/missing behavior;
144 +- partial failure behavior;
145 +- plugin registry contains Cloudflare READ actions with correct risk class;
146 +- Telegram Cloudflare view renders source-backed data and recovery navigation;
147 +- Telegram 4096-character and callback 64-byte constraints;
148 +- public `/status` remains minimal and contains no Cloudflare operational detail;
149 +- existing GitHub, Workspace, Safe Approval, replay protection, Guide, and Ops regressions remain green.
150 +
151 +After relevant tests pass, run the complete `npm test` suite.
152 +
153 +## 12. Delivery and verification
154 +
155 +Implementation must occur on a separate implementation branch after this design is reviewed and an implementation plan is approved.
156 +
157 +Definition of done for the implementation phase:
158 +
159 +- RED evidence captured;
160 +- implementation and tests complete;
161 +- full suite green;
162 +- security/diff review complete;
163 +- PR opened;
164 +- PR CI green;
165 +- Cloudflare Preview green where relevant;
166 +- locked-head merge;
167 +- post-merge main CI green on exact merge SHA;
168 +- Deploy workflow green on exact merge SHA;
169 +- active Cloudflare Worker deployment/version independently verified;
170 +- runtime bindings/observability re-verified;
171 +- documentation/Guide synchronized if the user-visible control changes.
172 +
173 +## 13. Explicit non-goals
174 +
175 +Not included in this phase:
176 +
177 +- deploy/redeploy;
178 +- rollback;
179 +- Worker settings mutation;
180 +- secret or binding mutation;
181 +- routes/domains mutation;
182 +- log streaming or persistent incident storage;
183 +- automated remediation;
184 +- scheduled monitoring/notifications;
185 +- multi-account Cloudflare management;
186 +- public operational diagnostics.
187 +
188 +Those require separate scope and, for mutation, Safe Approval/risk design.
189 +
190 +## 14. Acceptance criteria
191 +
192 +The phase is accepted only when an owner can open the Cloudflare operational view in Telegram and see real, current, safely normalized Worker state; provider failures are explicit; no secret value is exposed; no Cloudflare mutation path exists; `/status` remains minimal; and the full regression suite and production deployment verification pass.
\ No newline at end of file