@widnyana/design-thinking 0.0.20 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,15 +1,18 @@
1
- # Graph Protocol
1
+ # Design Thinking: Output Format
2
2
 
3
- The notation spec for **Design Graphs**. A Design Graph is the annotated call graph
4
- of a concrete problem: nodes are functions, edges are data flow, and every node
5
- carries annotations for data (A), cardinality, failure (E), and requirements (R).
3
+ How a [Design Thinking](design-thinking.md) result is written down: the
4
+ annotated call graph of a concrete problem. Nodes are functions, edges are
5
+ data flow, and every node carries annotations for data (A), cardinality,
6
+ failure (E), and requirements (R).
6
7
 
7
- The Protocol is stack-agnostic. A graph written for Go, Rust, Python, TypeScript,
8
+ The format is stack-agnostic. A graph written for Go, Rust, Python, TypeScript,
8
9
  SQL, or a spreadsheet renders identically. Only the vocabulary inside the
9
10
  annotations changes (e.g. what "retry" means in your language).
10
11
 
11
12
  Every tool in this package (`/cg`, `/cg-plan`, `/cg-review`, `/cg-map`, and the
12
- `/dt` active mode) MUST emit output in the format below.
13
+ `/dt` active mode) MUST emit output in the format below. Interface work uses
14
+ the [Design Graph](design-graph.md) skeleton instead; delegation to agents adds
15
+ the [Graph Protocol](graph-protocol.md) blocks.
13
16
 
14
17
  ---
15
18
 
@@ -21,7 +24,7 @@ empty for the problem at hand (say so: `SCOPE: none`), never to skip thinking.
21
24
  ```
22
25
  PROBLEM: <one-line statement of what you're building or examining>
23
26
 
24
- X → DesignGraph<A, E, R>
27
+ X → Graph → Effect<A, E, R>
25
28
  │ │ │ │ │
26
29
  │ │ │ │ └─ R: what each node needs (§5)
27
30
  │ │ │ └──── E: where the graph breaks (§4)
@@ -52,7 +55,7 @@ The header names the problem and anchors the three channels. `X` is your problem
52
55
  everything after it is the graph you build.
53
56
 
54
57
  ```
55
- X → DesignGraph<A, E, R>
58
+ X → Graph → Effect<A, E, R>
56
59
  │ │ │ │ │
57
60
  │ │ │ │ └─ R: what each node needs (§5)
58
61
  │ │ │ └──── E: where the graph breaks (§4)
@@ -194,7 +197,7 @@ produced which error. Mark it clearly; it should be rare.
194
197
  ```
195
198
  PROBLEM: sync a list of URLs to local files, resumable, with a status line
196
199
 
197
- X → DesignGraph<A, E, R>
200
+ X → Graph → Effect<A, E, R>
198
201
  │ │ │ │ │
199
202
  │ │ │ │ └─ R: Http, Clock, Logger (§5)
200
203
  │ │ │ └──── E: NetErr, DiskErr (§4)
@@ -225,4 +228,83 @@ VERDICT: happy path reads as the pipeline above; all NetErr handling lives a
225
228
  ```
226
229
 
227
230
  Note the stack vocabulary: `context manager` for scope, exceptions caught at
228
- layer joins for E, plain functions for nodes. Protocol unchanged.
231
+ layer joins for E, plain functions for nodes. Format unchanged.
232
+
233
+ ---
234
+
235
+ ## Call graph block (`/cg`, architecture traces, "how does X work")
236
+
237
+ When the answer is a trace of existing code, the GRAPH section uses this
238
+ block. Plain text only, no rendered diagrams.
239
+
240
+ ````
241
+ graph: <short title>
242
+
243
+ Production:
244
+ ```ts
245
+ EntryPoint
246
+ → ComponentA
247
+ → ComponentA.method
248
+ → [condition] ComponentB
249
+ → {queue_or_store}
250
+ ```
251
+
252
+ Tests:
253
+ ```ts
254
+ TestEntryPoint
255
+ → ComponentATestLayer
256
+ → ComponentA.method
257
+ → ComponentBTestLayer
258
+ ```
259
+
260
+ src:
261
+ EntryPoint → path/to/file.ts:LINE
262
+ ComponentA → path/to/component.ts:LINE
263
+ ComponentA.method → path/to/component.ts:LINE
264
+ ComponentB → path/to/other.ts:LINE
265
+ ````
266
+
267
+ Rules:
268
+
269
+ - `ts` fence for every stack (it renders arrows well), two-space-indented `→`
270
+ children. The root has no arrow; indentation is the call hierarchy.
271
+ - Use the real functions, methods, services, jobs, queues, and stores.
272
+ - Production always. Tests only when the test graph differs (that difference
273
+ IS the swapped R from §9). Never invent a test graph.
274
+ - `src:` gives verified `path:line` evidence for every unique node. Never
275
+ guess paths, symbols, callers, or line numbers.
276
+ - Mark planned nodes `[new]`; never invent future line numbers.
277
+ - Skip the graph for a trivial single-fact question (a port, a version).
278
+
279
+ ---
280
+
281
+ ## Completeness checklist
282
+
283
+ A result is complete when all of the following hold:
284
+
285
+ - [ ] Every node has a cardinality marker — `(1)`, `(N)`, or `(T)`.
286
+ - [ ] Every node lists its `R:` — even if `R: none` (that is a feature: the
287
+ node is runnable standalone).
288
+ - [ ] Every edge crossing a trust boundary is marked `🔒 unknown → trusted`.
289
+ - [ ] Every failure mode has a strategy — `⟳retry`, `↯escape(alt)`, or
290
+ `☠die`. No unmarked breaks, no silent swallowing.
291
+ - [ ] Every layer scopes its E before handing off (inner errors translated,
292
+ never leaked).
293
+ - [ ] Every resource has an acquire point and a structural release point.
294
+ - [ ] BEHAVIOR lists only layers that can be removed without touching the
295
+ happy path.
296
+ - [ ] TEST LAYERS shows a full R substitution — if it can't, the graph has
297
+ hidden dependencies.
298
+ - [ ] VERDICT explicitly answers whether code and graph match, and names the
299
+ mismatches.
300
+
301
+ ## The three uses
302
+
303
+ 1. **Plan** (`/cg-plan`) — draw the graph first. Code is written only after
304
+ the VERDICT has a target to be checked against. If code contradicts the
305
+ graph, fix the graph or fix the code; never let them drift silently.
306
+ 2. **Extract** (`/cg`) — reconstruct the graph the code *actually*
307
+ implements, not the one the author intended.
308
+ 3. **Review** (`/cg-review`) — render the implemented graph, diff it against
309
+ the intended graph (or this checklist), group findings by § number, end
310
+ with a VERDICT line.
@@ -1,102 +1,223 @@
1
1
  ---
2
2
  name: design-graph
3
3
  description: >
4
- Design Graph — the artifact: annotated call graph of a concrete problem;
5
- nodes = functions, edges = data flow; every node annotated with A,
6
- cardinality, E, R. Use when drawing a graph before writing code or
7
- reconstructing and diffing one against existing code. Includes the
8
- completeness checklist.
4
+ Design Graph: the interface method. Job → Flow → Surface<C, V, N>:
5
+ surfaces, content (C), void states (V: empty, loading, partial, error,
6
+ denied), needs (N), field boundaries, motion layers, attention scope, proof
7
+ by swapping N. Use when designing or reviewing screens, flows, or components.
9
8
  disable-model-invocation: true
10
9
  ---
11
10
 
12
- # Design Graph — The Artifact
11
+ > **Source**: Design Graph by [r17x](https://github.com/r17x), from
12
+ > https://gist.github.com/r17x/90eb2f7be93932b5693753aedb09c01a (`OPT_DESIGN_GRAPH.md`).
13
+ > Method text bundled as-is. The output skeleton at the end is added by this package.
13
14
 
14
- A **Design Graph** is the annotated call graph of a concrete problem. It is
15
- what you produce when you apply Design Thinking (see the `design-method` skill) to
16
- something, and it is written in Graph Protocol notation (see the `graph-protocol` skill).
15
+ # Design Graph
17
16
 
18
- Nodes are functions. Edges are data flow. The annotations answer, for every
19
- node: what flows through it (A), how many times it runs (cardinality), where
20
- and how it can fail (E), and what it needs to exist (R) — plus the global
21
- concerns: trust boundaries, behavior layers, resource scope, and test layers.
17
+ The same method, turned on the interface. A screen is not a picture — it is a node with three channels, and the layout you draw is the graph the user walks.
22
18
 
23
- A Design Graph is not documentation written after the fact. It is drawn
24
- **before** implementation (planning), **reconstructed** from implementation
25
- (review), and **compared** against implementation (verdict). The graph is the
26
- contract; the code is one instantiation of it.
27
- **Hard gate:** when a turn will produce code or file edits, the graph comes
28
- first — render it (and any clarifying questions), get the user's approval,
29
- and only then write code that matches it.
19
+ Design Thinking answers what flows through the program. Design Graph answers what the person in front of it can be looking at. Same three-channel discipline: one channel for the content, one for every way the content can be absent, one for what the surface needs before it may exist.
20
+
21
+ ```
22
+ Job → Flow → Surface<C, V, N>
23
+ │ │ │ │ │
24
+ │ │ │ │ └─ what the surface needs to exist (§5)
25
+ │ │ │ └──── every way the content is absent (§4)
26
+ │ │ └─────── what the person reads and does (§2)
27
+ │ │
28
+ │ └─ nodes = surfaces, edges = the moves between them
29
+ │
30
+ └─ the job: what the person came here to get done
31
+
32
+ §1 Surfaces the nouns: screens, panes, rows, fields, controls
33
+ §2 C happy path as flow graph
34
+ §3 Cardinality one record (Detail) or many (List / live)
35
+ §4 V void states: empty, loading, partial, error, denied
36
+ §5 N needs: data, permission, prior step, viewport
37
+ §6 Boundary validate at the field, not at submit
38
+ §7 Behavior motion and feedback wrap a surface, never reshape it
39
+ §8 Scope attention is acquired and must be released
40
+ §9 Proof swap N, same flow shape
41
+ §10 Craft markup = C, state styles = V
42
+ ```
43
+
44
+ Read the job. Draw the moves as a flow graph. Build an interface that IS the graph. If a surface can render a state the graph cannot name, the interface is lying.
45
+
46
+ ## 1. Name the surfaces
47
+
48
+ What are the things a person can look at? Before opening a layout tool, define the interface language.
49
+
50
+ - **Surfaces** -- the addressable places. A rail, a list, a detail pane, a drawer. Each one has a name and an owner.
51
+ - **Units** -- the repeated shape inside a surface. A row, a field, a metric. Named once, reused everywhere.
52
+ - **States** -- what a unit can be. Rest, hover, selected, disabled, stale. Enumerated, not improvised at build time.
53
+ - **Moves** -- what the person can do to get somewhere else. Open, select, dismiss, commit, undo.
54
+
55
+ These are the nouns. The moves are the verbs. A design system that names colours but not surfaces has no vocabulary — only a palette.
56
+
57
+ ## 2. Think C first
58
+
59
+ Map the successful job as a flow graph before drawing a single frame. Nodes are surfaces, edges are the moves between them.
60
+
61
+ ```
62
+ Rail(scope) -> List(C) -> Detail(C) -> Commit
63
+ ```
64
+
65
+ This graph is the information architecture. Every screen that does not appear on it is a screen nobody asked for. If two nodes need the same surface, that surface is a component; if a node has one edge in and one edge out, it may not need to be a screen at all.
66
+
67
+ ## 3. One or many?
68
+
69
+ Decide the cardinality of each node before its layout. Getting this wrong is the most expensive mistake in the graph, because it changes the shape of the surface, not its styling.
70
+
71
+ - **One record** -- a detail surface. Reading measure, full metadata, one primary action.
72
+ - **Many records** -- a list surface. Scannable, uniform rows, selection as a wash. Must survive 0, 1, and 10,000.
73
+ - **Live** -- values that change while being read. Show the timestamp, never move the row under the cursor.
74
+
75
+ Do not let a list masquerade as a card, and never let a live value pretend to be static. A surface designed for the average case has no design for the real one.
76
+
77
+ ## 4. Think V second
78
+
79
+ V is the void channel: every way the content can fail to be there. Each node enumerates its own, and each one is a designed surface, not a fallback.
80
+
81
+ - **Empty** -- nothing yet, and that is fine. One grey sentence saying what will appear here.
82
+ - **Loading** -- the shape is known, the values are not. A flat skeleton in the layout the content will occupy.
83
+ - **Partial** -- some of it arrived. Show what you have and mark what is missing — never block the whole surface for one field.
84
+ - **Error** -- it broke, and the person can act. Say what failed, in their words, next to the thing that failed.
85
+ - **Denied** -- they may not see it. Prefer never routing them here over explaining the refusal.
86
+
87
+ A surface with one designed state and four undesigned ones is 20% designed. The void states are where the interface earns trust, because they are the states the person meets on their worst day.
88
+
89
+ ## 5. Think N third
90
+
91
+ Mark what each surface needs before it is allowed to exist. "We cannot show X if we do not have Y."
92
+
93
+ N is the interface's version of compile-time proof. A surface declares its needs — a signed-in user, a selected record, a permission, a minimum viewport, a completed prior step — and the graph must satisfy them on the edge that reaches it.
94
+
95
+ - **Data** -- a record must be selected. No selection is a different node, not an empty pane.
96
+ - **Permission** -- if they cannot act, do not draw the affordance. A disabled button is a last resort.
97
+ - **Prior step** -- step 3 requires step 2. Unreachable is better than reachable and broken.
98
+ - **Viewport** -- three panes need width. Below it, the graph re-routes — the detail becomes a drawer, not a squeeze.
99
+
100
+ If a screen can be reached without its needs met, the flow graph has a hole. That hole is a bug in the design, not a case for the engineer to handle.
101
+
102
+ ## 6. Trust at boundary
103
+
104
+ Where does the person's own input enter the graph? Fields, uploads, pastes, drags, URLs they typed themselves.
105
+
106
+ Validate at the field, not at submit. The boundary of the interface is the control they are touching — that is where unknown becomes trusted, and where the message belongs. One definition of a field gives the label, the constraint and the error sentence together.
107
+
108
+ Trust nothing at the boundary. Trust everything past it. A form that only fails on submit has moved its boundary to the wrong place, and made the person pay for the move.
109
+
110
+ ## 7. Layer behavior
111
+
112
+ What wraps a surface without changing what it says? Motion, focus, feedback, density, keyboard affordance, reduced-motion.
113
+
114
+ These are layers around a node, never edits to it. A wash on hover, a reveal on entry, a ring on focus — the content graph is identical with them and without them. If removing the animation changes what the person can learn from the screen, the animation was carrying content and the layout was underbuilt.
115
+
116
+ The graph says WHAT the surface is. The layers say HOW it responds to being used.
117
+
118
+ ## 8. Scope attention
119
+
120
+ Which surfaces acquire the person's attention? Modals, drawers, menus, toasts, anything that takes the viewport or the focus ring.
121
+
122
+ Attention is a resource with acquire and release. Whatever takes focus returns it to where it came from — on confirm, on cancel, on escape, on interrupt. Whatever covers the graph must name the single move that uncovers it.
123
+
124
+ An overlay with no defined release is a leak. The person is left holding a surface the graph has forgotten about.
125
+
126
+ ## 9. Swap N to prove it
127
+
128
+ The flow graph does not change between the demo and the first real account. Only N changes.
129
+
130
+ Same nodes. Same C flowing through. Same V possible. Different context behind N. Run the graph four times and see whether it still holds:
131
+
132
+ - **Day one** -- nothing in the account. Every list is empty; the graph must still be legible.
133
+ - **Year three** -- 40,000 records, titles twice as long as the mock. Nothing may reflow into nonsense.
134
+ - **Least access** -- the read-only member. Which affordances vanish, and does the layout survive their absence?
135
+ - **Small and slow** -- one hand, poor network, reduced motion on. The graph re-routes; it does not degrade.
136
+
137
+ If the design only works with ideal data, it is not a design — it is a screenshot. This is the payoff of separating C, V and N: you prove the interface by swapping what is behind N and watching the graph hold its shape.
138
+
139
+ ## 10. Markup is C, state styles are V
140
+
141
+ The separation of C (§2) and V (§4) maps directly to how the interface is built:
142
+
143
+ - **the component tree** -- the happy path. Every element is content flowing through the graph. No state branching inside.
144
+ - **the recipe variants** -- the complete V enumeration. Before writing them, read the actual states the surface can be in. Every one is named and styled — none is left to the browser default.
145
+
146
+ This is not a stylistic preference. If state handling lives inside the tree, the content path and the void path are tangled — you cannot read the layout without wading through conditionals, and no one can tell which states were designed and which were merely reached.
147
+
148
+ The tree IS the flow graph from §2. The variants ARE the void enumeration from §4.
149
+
150
+ ### One method, two materials
151
+
152
+ The mapping is exact by construction. Anywhere the two columns disagree, one of the two graphs is wrong — most often the interface, because it is the one that gets drawn before it is thought.
153
+
154
+ | § | DESIGN THINKING | DESIGN GRAPH |
155
+ |---|-----------------|--------------|
156
+ | X | the problem to build | the job to get done |
157
+ | graph | functions and data flow | surfaces and moves |
158
+ | 1 | records, IDs, variants, errors | surfaces, units, states, moves |
159
+ | 2 | A — what flows | C — what is read and done |
160
+ | 3 | Effect or Stream | detail, list, or live |
161
+ | 4 | E — retry, escape, die | V — empty, loading, partial, error, denied |
162
+ | 5 | R — dependencies, proven | N — needs, satisfied on the edge |
163
+ | 6 | parse at the transport edge | validate at the field |
164
+ | 7 | pipe wraps the node | motion wraps the surface |
165
+ | 8 | scope the resource | scope the attention |
166
+ | 9 | swap R in tests | swap N in review |
167
+ | 10 | gen body = A, pipe = E | tree = C, variants = V |
30
168
 
31
169
  ---
32
170
 
33
- ## What a complete Design Graph contains
171
+ ## The Craft Pipeline
34
172
 
35
173
  ```
36
- PROBLEM: <one line>
37
-
38
- X → DesignGraph<A, E, R>
39
- │ │ │ │ │
40
- │ │ │ │ └─ R: what each node needs (§5)
41
- │ │ │ └──── E: where the graph breaks (§4)
42
- │ │ └─────── A: what flows through nodes (§2)
43
- │ │
44
- │ └─ nodes = functions, edges = data flow
45
- │
46
- └─ the problem
47
-
48
- SHAPES: … every noun the graph needs
49
- GRAPH: … ascii call graph with inline R:/E:/🔒/(n) annotations
50
- CARDINALITY: … every node marked (1) (N) or (T)
51
- BOUNDARIES: … every unknown → trusted crossing
52
- BEHAVIOR: … every orthogonal layer and what it wraps
53
- SCOPE: … every resource with acquire@x → release@x
54
- TEST LAYERS: … the R tests provide — same GRAPH, zero code change
55
- VERDICT: … code matches graph? A and E structurally separated?
174
+ JOB
175
+ -> "What are the surfaces?" -> define the interface language
176
+ -> "What is the successful path?" -> draw the flow graph (C)
177
+ -> "One record, many, or live?" -> mark cardinality per surface
178
+ -> "How can the content be absent?" -> annotate void states (V)
179
+ -> "What must be true to show this?" -> annotate needs on the edges (N)
180
+ -> "Where does their input enter?" -> validate at the field
181
+ -> "What wraps a surface without reshaping it?" -> layer motion and feedback
182
+ -> "What takes attention, and how is it given back?" -> scope every overlay
183
+ -> "Does it hold on day one and year three?" -> swap N and re-walk the graph
184
+ -> "Does the build separate C from V?" -> tree = C, variants = V
185
+ -> INTERFACE -> the interface IS the graph
56
186
  ```
57
187
 
58
- ## Completeness checklist
59
-
60
- A Design Graph is complete when all of the following hold:
61
-
62
- - [ ] Every node has a cardinality marker — `(1)`, `(N)`, or `(T)`.
63
- - [ ] Every node lists its `R:` — even if `R: none` (that is a feature: the
64
- node is runnable standalone).
65
- - [ ] Every edge crossing a trust boundary is marked `🔒 unknown → trusted`.
66
- - [ ] Every failure mode has a strategy — `⟳retry`, `↯escape(alt)`, or
67
- `☠die`. No unmarked breaks, no silent swallowing.
68
- - [ ] Every layer scopes its E before handing off (inner errors translated,
69
- never leaked).
70
- - [ ] Every resource has an acquire point and a structural release point.
71
- - [ ] BEHAVIOR lists only layers that can be removed without touching the
72
- happy path.
73
- - [ ] TEST LAYERS shows a full R substitution — if it can't, the graph has
74
- hidden dependencies.
75
- - [ ] VERDICT explicitly answers whether code and graph match, and names the
76
- mismatches.
77
-
78
- ## The three uses
79
-
80
- ### 1. Plan (`/cg-plan`)
81
- Draw the graph first. Code is written only after the VERDICT question — "does
82
- my code match this?" — has a target to be checked against. If a code
83
- suggestion contradicts the graph, fix the graph or fix the code; never let
84
- them drift silently.
85
-
86
- ### 2. Extract (`/cg`)
87
- Given existing code, reconstruct the graph the code *actually* implements —
88
- not the one the author intended. The reconstructed graph is the ground truth
89
- for review and refactoring.
90
-
91
- ### 3. Review (`/cg-review`)
92
- Render the implemented graph, then diff it against the intended graph (or
93
- against the method's completeness checklist when no intended graph exists).
94
- Every mismatch is a finding, grouped by § number. The review ends with a
95
- VERDICT line.
188
+ **If a surface can render a state the graph cannot name, the design is wrong.**
96
189
 
97
190
  ---
98
191
 
99
- ## Worked example
192
+ ## Output skeleton
193
+
194
+ Interface work renders in this fixed order, the UI twin of the
195
+ [Design Thinking output format](../../references/output-format.md). Same markers where the
196
+ meaning carries over (`(1)` detail, `(N)` list, `(T)` live, `🔒` field
197
+ boundary, `⛈` behavior layer).
100
198
 
101
- See the end of the `graph-protocol` skill for a complete, non-TS worked
102
- example (a resumable URL-sync CLI in Python) with all sections filled.
199
+ ```
200
+ JOB: <one line: what the person came here to get done>
201
+
202
+ Job → Flow → Surface<C, V, N>
203
+ │ │ │ │ │
204
+ │ │ │ │ └─ N: what the surface needs to exist (§5)
205
+ │ │ │ └──── V: every way the content is absent (§4)
206
+ │ │ └─────── C: what the person reads and does (§2)
207
+ │ │
208
+ │ └─ nodes = surfaces, edges = the moves between them
209
+ │
210
+ └─ the job
211
+
212
+ SURFACES: surfaces · units · states · moves
213
+ FLOW: ascii flow graph, annotated inline:
214
+ N: needs · V: empty|loading|partial|error|denied · 🔒 field → trusted
215
+ CARDINALITY: surface (1) detail · (N) list · (T) live
216
+ VOID: every surface × its designed void states
217
+ NEEDS: data · permission · prior step · viewport, satisfied on the edge
218
+ BOUNDARY: every field where input becomes trusted, with its error sentence
219
+ BEHAVIOR: motion, focus, feedback layers that wrap a surface without reshaping it
220
+ ATTENTION: overlays: acquire@move → release@confirm|cancel|escape
221
+ PROOF: day one · year three · least access · small and slow
222
+ VERDICT: does every rendered state have a name on the graph?
223
+ ```
@@ -1,35 +1,37 @@
1
1
  ---
2
- name: design-method
2
+ name: design-thinking
3
3
  description: >
4
- Design Thinking — the §1–§10 problem-first pipeline: shapes → graph(A) →
5
- cardinality → break points (E: ⟳ ↯ ☠) → requirements (R) → boundaries →
6
- behavior layers → scope → test layers → verdict. Stack-agnostic. Use when
7
- planning, designing, or refactoring any feature or system.
4
+ Design Thinking: the code method. X → Graph → Effect<A, E, R>, the §1-§10
5
+ pipeline: shapes, happy path (A), cardinality, break points (E: ⟳ ↯ ☠),
6
+ requirements (R), boundaries, behavior layers, scope, test layers, code.
7
+ Stack-agnostic. Use when planning, designing, reviewing, or refactoring code.
8
+ Output format lives in references/output-format.md.
8
9
  disable-model-invocation: true
9
10
  ---
10
11
 
11
- # Design Thinking — The Method
12
+ # Design Thinking
12
13
 
13
- A stack-agnostic design methodology. Read the problem. Draw the data flow as a
14
- call graph (the **Design Graph**). Write code that IS the graph. If the code
15
- doesn't match the graph, something is wrong.
14
+ The code method. Read the problem. Draw the data flow as a call graph. Write
15
+ code that IS the graph. If the code doesn't match the graph, something is wrong.
16
+
17
+ One of three methods with the same shape (see [design-graph.md](../../references/design-graph.md)
18
+ for the interface, [graph-protocol.md](../../references/graph-protocol.md) for delegation to
19
+ agents). The original is written in Effect-TS ([effect-ts.md](../../references/effect-ts.md)).
20
+ This version is stack-agnostic: where the original says `Effect`, `gen`, or
21
+ `pipe`, use your stack's equivalent (Result types, exceptions at layer joins,
22
+ middleware, RAII, constructor injection). The discipline never changes, only
23
+ the vocabulary.
16
24
 
17
- The method is language-neutral. Where it says "Effect", "gen", or "pipe" in the
18
- Effect-TS appendix (`effect-ts.md`), substitute your stack's equivalent: Result
19
- types, exceptions at layer joins, middleware, RAII, constructor injection —
20
- whatever your language provides. The discipline never changes, only the vocabulary.
21
25
  **Hard gate — applies in every harness (pi, omp, Claude Code, any agent):**
22
26
  When the user asks for a feature, change, fix, or refactor — or when any turn
23
- will end in proposed code or file edits — you MUST render the Design Graph
24
- (Graph Protocol) and any clarifying questions BEFORE touching any file, and
25
- implement only after the user approves the design. Reading and exploring code
26
- first is fine; the FIRST edit is not allowed before the graph. This rule is
27
- not optional and not stack-dependent.
28
-
29
- Render every result in Graph Protocol format (see the `graph-protocol` skill).
27
+ will end in proposed code or file edits — you MUST render the graph (in the
28
+ [output format](../../references/output-format.md)) and any clarifying questions BEFORE
29
+ touching any file, and implement only after the user approves the design.
30
+ Reading and exploring code first is fine; the FIRST edit is not allowed
31
+ before the graph. This rule is not optional and not stack-dependent.
30
32
 
31
33
  ```
32
- X → DesignGraph<A, E, R>
34
+ X → Graph → Effect<A, E, R>
33
35
  │ │ │ │ │
34
36
  │ │ │ │ └─ what each node needs (§5)
35
37
  │ │ │ └──── where the graph breaks (§4)
@@ -48,9 +50,12 @@ X → DesignGraph<A, E, R>
48
50
  §7 Behavior orthogonal layers wrap without changing the graph
49
51
  §8 Scope acquire/release tied to lifecycle
50
52
  §9 Test swap R, same graph shape
51
- §10 Structure happy path = A, failure handling = E, never tangled
53
+ §10 Code happy path body = A, failure join points = E
52
54
  ```
53
55
 
56
+ `Effect<A, E, R>` names any computation: it succeeds with A, fails with E,
57
+ and needs R to run.
58
+
54
59
  ## 1. Name the shapes
55
60
 
56
61
  What are the things? Before drawing a graph, define the domain language.
@@ -64,7 +69,7 @@ What are the things? Before drawing a graph, define the domain language.
64
69
  These are the nouns. The graph is the verbs. You cannot draw the graph until
65
70
  you know what flows through it.
66
71
 
67
- → *Protocol section: SHAPES.*
72
+ → *Output section: SHAPES.*
68
73
 
69
74
  ## 2. Think A first
70
75
 
@@ -78,7 +83,7 @@ What is the success data flow? What goes in, what comes out, what transforms
78
83
  happen in between? This graph IS your program structure. Draw it first. The
79
84
  code follows.
80
85
 
81
- → *Protocol section: GRAPH (edges) + header tree (A).*
86
+ → *Output section: GRAPH (edges) + header tree (A).*
82
87
 
83
88
  ## 3. One or many?
84
89
 
@@ -93,7 +98,7 @@ Is each node one-shot or a flow?
93
98
  Same three channels (A, E, R) in all cases. Different cardinality. Mark it on
94
99
  the graph so the code matches.
95
100
 
96
- → *Protocol section: CARDINALITY.*
101
+ → *Output section: CARDINALITY.*
97
102
 
98
103
  ## 4. Think E second
99
104
 
@@ -112,7 +117,7 @@ that as Result types, checked exceptions, error returns, or a strict rule that
112
117
  exceptions only cross at layer joins. You decide at each node: retry, escape,
113
118
  or propagate. Only `die` when the program's assumptions are violated.
114
119
 
115
- → *Protocol section: GRAPH (E annotations) + VERDICT.*
120
+ → *Output section: GRAPH (E annotations) + VERDICT.*
116
121
 
117
122
  ## 5. Think R third
118
123
 
@@ -126,7 +131,7 @@ database connection, a config value, an HTTP client. R shrinks as you provide
126
131
  layers. When R is empty, the program can run. If R is not empty, the compiler
127
132
  or the wiring tells you exactly what's missing.
128
133
 
129
- → *Protocol section: GRAPH (R annotations) + TEST LAYERS.*
134
+ → *Output section: GRAPH (R annotations) + TEST LAYERS.*
130
135
 
131
136
  ## 6. Trust at boundary
132
137
 
@@ -140,7 +145,7 @@ transformer. Define it once, use it everywhere.
140
145
  Trust nothing at the boundary. Trust everything inside. The boundary is the
141
146
  only place you parse. After that, the types guarantee shape.
142
147
 
143
- → *Protocol section: BOUNDARIES.*
148
+ → *Output section: BOUNDARIES.*
144
149
 
145
150
  ## 7. Layer behavior
146
151
 
@@ -153,7 +158,7 @@ without wading through retry logic and timeout configuration. Behavior is
153
158
  composed orthogonally. The graph says WHAT happens. The layers say HOW it
154
159
  behaves under pressure.
155
160
 
156
- → *Protocol section: BEHAVIOR.*
161
+ → *Output section: BEHAVIOR.*
157
162
 
158
163
  ## 8. Scope resources
159
164
 
@@ -164,7 +169,7 @@ Acquire/release must be structurally bound: RAII, `defer`, context managers,
164
169
  `try/finally` at the owning node — even on error, even on interrupt. Cleanup
165
170
  is structural, not a TODO comment you hope someone remembers.
166
171
 
167
- → *Protocol section: SCOPE.*
172
+ → *Output section: SCOPE.*
168
173
 
169
174
  ## 9. Swap R to prove it
170
175
 
@@ -178,9 +183,9 @@ doing too much.
178
183
  This is the payoff of separating A, E, and R — you prove the graph correct by
179
184
  swapping what's behind R.
180
185
 
181
- → *Protocol section: TEST LAYERS.*
186
+ → *Output section: TEST LAYERS.*
182
187
 
183
- ## 10. Separate A from E structurally
188
+ ## 10. Happy path is A, join points are E
184
189
 
185
190
  The separation of A (§2) and E (§4) maps directly onto code structure, in any
186
191
  language:
@@ -207,7 +212,7 @@ storage errors and produces a domain error. Auth catches domain errors and
207
212
  produces an access error. The handler catches access errors and produces the
208
213
  declared interface error. Each layer's handling is a complete enumeration of
209
214
  what IT received — not what originated three layers down. Consumers never see
210
- implementation errors from deeper layers. *(See protocol.md for the diagram.)*
215
+ implementation errors from deeper layers. *(See [output-format.md](../../references/output-format.md) for the diagram.)*
211
216
 
212
217
  ### Divergent strategies
213
218
 
@@ -242,6 +247,5 @@ PROBLEM
242
247
 
243
248
  ---
244
249
 
245
- *The original Effect-TS instantiation of this method ships verbatim in the
246
- package at `references/effect-ts.md` — for attribution and Effect-TS users
247
- only. Everything above is stack-agnostic.*
250
+ *For the original Effect-TS instantiation of this method, see
251
+ [effect-ts.md](../../references/effect-ts.md).*