ianalin123 commited on
Commit
be602da
Β·
1 Parent(s): 2936d2e
Files changed (1) hide show
  1. plans/implementation_plan.md +485 -0
plans/implementation_plan.md ADDED
@@ -0,0 +1,485 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Optigami β€” Implementation Plan
2
+
3
+ > Derived from handoff doc critique, origami math/physics research, and plan review.
4
+ > Last updated: 2026-03-07
5
+
6
+ ---
7
+
8
+ ## Resolved Architectural Decisions
9
+
10
+ ### 1. Code-as-policy for training, step-level for demo
11
+
12
+ GRPO samples N completions for a fixed prompt, evaluates each independently, computes group advantages. That maps cleanly to **code-as-policy**: the model outputs a complete fold sequence as a JSON list, the environment executes it sequentially, terminal reward is computed once.
13
+
14
+ Step-level breaks GRPO's assumption: at step k, the prompt is conditioned on prior steps which differ across rollouts, so you're no longer comparing N completions to the same situation.
15
+
16
+ **Resolution:** Training is code-as-policy (full sequence β†’ single reward). Demo is step-by-step (one fold at a time with live feedback). Same environment, different prompt wrapper. Same model at inference β€” you just prompt it one fold at a time for the demo.
17
+
18
+ ### 2. 2D crease pattern is Phase 1, engineering metrics are Phase 2
19
+
20
+ **Phase 1 (hackathon MVP):** Build the crease pattern graph, check local foldability, use geometric coverage as progress proxy. Self-contained, can show reward improvement.
21
+
22
+ **Phase 2 (if time permits):** Apply fold angles to compute the 3D folded state, compute deployment ratio and bounding box. These become the primary reward, with crease coverage as scaffolding. This is where the "model discovers Miura-ori" story lives.
23
+
24
+ If the deadline forces a cut, Phase 1 ships and Phase 2 is explicitly called out as the next step.
25
+
26
+ ### 3. Scope to local flat-foldability (NP-hardness acknowledged)
27
+
28
+ Global flat-foldability (layer ordering) is NP-complete (Bern-Hayes 1996). We target **local flat-foldability** at each vertex, which is polynomial. This is a feature, not a limitation β€” the pitch: "our rewards check the conditions every origami designer verifies. Global layer ordering is provably NP-complete."
29
+
30
+ ### 4. Symmetry masking is a noted risk
31
+
32
+ For Level 1-2 targets the anchor set is small (≀8 points), manageable. For Level 3+, intersection vertices accumulate to 15-20+ points, giving O(300+) candidate fold lines. The unit square has dihedral-4 symmetry (4 rotations + 4 reflections). For Level 3+, if training shows no convergence after 500 steps, add explicit symmetry-based action pruning.
33
+
34
+ ---
35
+
36
+ ## File Structure
37
+
38
+ ```
39
+ optigami/
40
+ env/
41
+ __init__.py
42
+ graph.py # CreaseGraph: vertices, edges, cyclic ordering
43
+ paper_state.py # PaperState using CreaseGraph, add_crease
44
+ verifier.py # Kawasaki, Maekawa, BLB, coverage, deployment ratio
45
+ rewards.py # compute_reward (Phase 1 + Phase 2 extension)
46
+ environment.py # OpenEnv wrapper, code-as-policy and step modes
47
+ prompts.py # LLM observation formatting
48
+ fold_engine.py # Phase 2: apply fold angles, compute 3D bounding box
49
+ targets/
50
+ validator.py # crimp-check all .fold files before training
51
+ half_horizontal.fold
52
+ half_vertical.fold
53
+ diagonal.fold
54
+ cross_fold.fold
55
+ x_fold.fold
56
+ pinwheel_base.fold
57
+ preliminary_base.fold
58
+ fish_base.fold
59
+ train.py
60
+ requirements.txt
61
+ src/ # React demo visualizer (existing)
62
+ plans/
63
+ implementation_plan.md
64
+ ```
65
+
66
+ ---
67
+
68
+ ## Phase 1: CreaseGraph (`env/graph.py`)
69
+
70
+ Everything builds on this. Get it right first.
71
+
72
+ **Data:**
73
+ - `vertices`: `dict[vertex_id β†’ (x, y)]`
74
+ - `edges`: `dict[edge_id β†’ (v1, v2, assignment)]` where assignment ∈ `{M, V, B}`
75
+ - `vertex_edges`: `dict[vertex_id β†’ [edge_ids]]`
76
+
77
+ **Key operations:**
78
+ - `add_vertex(x, y, tol=1e-9)` β€” deduplicated by proximity
79
+ - `add_edge(v1, v2, assignment)` β€” no duplicates
80
+ - `get_cyclic_edges(vertex_id)` β€” incident edge IDs sorted by angle of the other endpoint around the vertex (the cyclic order Kawasaki requires)
81
+ - `interior_vertices()` β€” vertices not on the unit square boundary
82
+ - `split_edge(edge_id, new_vertex_id)` β€” splits an edge at a vertex, used when a new crease intersects an existing one
83
+
84
+ **`add_crease(p1, p2, assignment)` in `PaperState`:**
85
+ 1. Validate both endpoints are in the anchor set (within tolerance)
86
+ 2. Find all intersections with existing edges
87
+ 3. Add intersection vertices and split existing edges at them
88
+ 4. Add the new crease edge(s) (possibly split by intersections)
89
+ 5. Return `{valid, anchored, new_vertices, errors}`
90
+
91
+ **Anchor point set** (grows as creases are added):
92
+ - Boundary corners: `(0,0), (1,0), (1,1), (0,1)`
93
+ - Boundary midpoints of any existing boundary edge
94
+ - All crease-crease intersection vertices
95
+ - Midpoints of existing crease edges
96
+
97
+ ---
98
+
99
+ ## Phase 2: Verifiers (`env/verifier.py`)
100
+
101
+ ### Even-degree fast-fail
102
+
103
+ ```python
104
+ def has_even_degree(vertex_id, graph) -> bool:
105
+ return len(graph.get_cyclic_edges(vertex_id)) % 2 == 0
106
+ ```
107
+
108
+ Runs before Kawasaki. Odd-degree interior vertices are impossible β€” short-circuit immediately.
109
+
110
+ ### Kawasaki-Justin
111
+
112
+ Sector angles must be computed in **cyclic angular order** around each vertex β€” not by magnitude, not arbitrarily. The handoff's sorted-angle approach was wrong; cyclic order is recovered by sorting incident edge directions by `arctan2`.
113
+
114
+ ```python
115
+ def check_kawasaki_at_vertex(vertex_id, graph) -> tuple[bool, float]:
116
+ cyclic_edges = graph.get_cyclic_edges(vertex_id) # sorted by angle
117
+ n = len(cyclic_edges)
118
+ if n % 2 != 0:
119
+ return False, float('inf')
120
+ if n < 4:
121
+ return True, 0.0 # boundary vertex, not an interior fold vertex
122
+
123
+ v = graph.vertices[vertex_id]
124
+ angles = []
125
+ for eid in cyclic_edges:
126
+ v1, v2, _ = graph.edges[eid]
127
+ other = v2 if v1 == vertex_id else v1
128
+ other_pos = graph.vertices[other]
129
+ angles.append(np.arctan2(other_pos[1] - v[1], other_pos[0] - v[0]))
130
+ # angles is already in cyclic order (cyclic_edges sorted by angle)
131
+
132
+ sectors = []
133
+ for i in range(n):
134
+ diff = angles[(i+1) % n] - angles[i]
135
+ if diff < 0:
136
+ diff += 2 * np.pi
137
+ sectors.append(diff)
138
+
139
+ alt_sum = sum(s * ((-1)**i) for i, s in enumerate(sectors))
140
+ return abs(alt_sum) < 1e-9, abs(alt_sum)
141
+ ```
142
+
143
+ ### Maekawa-Justin
144
+
145
+ Boundary edges (`B`) must not be counted β€” only fold edges (`M`, `V`). The handoff counted boundary edges, which breaks Maekawa for any crease touching the paper edge.
146
+
147
+ ```python
148
+ def check_maekawa_at_vertex(vertex_id, graph) -> bool:
149
+ fold_edges = [eid for eid in graph.vertex_edges[vertex_id]
150
+ if graph.edges[eid][2] in ('M', 'V')]
151
+ if len(fold_edges) < 4:
152
+ return True # not an interior fold vertex yet
153
+ M = sum(1 for eid in fold_edges if graph.edges[eid][2] == 'M')
154
+ V = len(fold_edges) - M
155
+ return abs(M - V) == 2
156
+ ```
157
+
158
+ ### Big-Little-Big (BLB)
159
+
160
+ At any interior vertex, if a sector angle is a strict local minimum, the two crease lines bounding that sector must have **opposite MV parity**. This is the key pruning rule between Maekawa and layer-ordering β€” a pattern can satisfy Maekawa while violating BLB, meaning no valid layer ordering exists.
161
+
162
+ ```python
163
+ def check_blb_at_vertex(vertex_id, graph) -> list[tuple]:
164
+ """Returns list of (edge_a, edge_b) pairs where BLB is violated."""
165
+ cyclic_edges = graph.get_cyclic_edges(vertex_id)
166
+ n = len(cyclic_edges)
167
+ if n < 4:
168
+ return []
169
+ sectors = _compute_sectors(vertex_id, cyclic_edges, graph)
170
+ violations = []
171
+ for i in range(n):
172
+ prev_s = sectors[(i-1) % n]
173
+ next_s = sectors[(i+1) % n]
174
+ if sectors[i] < prev_s and sectors[i] < next_s: # strict local min
175
+ left_eid = cyclic_edges[i]
176
+ right_eid = cyclic_edges[(i+1) % n]
177
+ a_left = graph.edges[left_eid][2]
178
+ a_right = graph.edges[right_eid][2]
179
+ if a_left in ('M', 'V') and a_right in ('M', 'V') and a_left == a_right:
180
+ violations.append((left_eid, right_eid))
181
+ return violations
182
+ ```
183
+
184
+ ### Geometric Coverage (with excess penalty)
185
+
186
+ One-sided coverage alone rewards placing target creases but doesn't penalize surplus creases. Both are returned separately so the reward function can weight them independently.
187
+
188
+ ```python
189
+ def geometric_coverage(state, target_edges, tol_pos=0.05, tol_angle=5.0) -> tuple[float, float]:
190
+ """
191
+ Returns (coverage, economy).
192
+ coverage: fraction of target creases matched by current creases [0, 1]
193
+ economy: penalty for excess creases [0, 1], 1.0 = no excess
194
+ """
195
+ matched = 0
196
+ for t_edge in target_edges:
197
+ for c_edge in state.crease_edges():
198
+ if _edges_match(t_edge, c_edge, tol_pos, tol_angle):
199
+ matched += 1
200
+ break
201
+ n_target = max(len(target_edges), 1)
202
+ n_current = len(state.crease_edges())
203
+ coverage = matched / n_target
204
+ economy = max(0.0, 1.0 - max(0, n_current - n_target) / n_target)
205
+ return coverage, economy
206
+ ```
207
+
208
+ ---
209
+
210
+ ## Phase 3: Reward Function (`env/rewards.py`)
211
+
212
+ ### Phase 1 reward
213
+
214
+ Single consistent definition. `progress` carries 45% β€” it's the only signal with real geometric content at every step. Validity signals split 20% total. Economy penalizes excess creases.
215
+
216
+ ```python
217
+ def compute_reward_phase1(state, action_result, target) -> dict:
218
+ r = {}
219
+
220
+ r['format'] = 1.0 if action_result['valid'] else 0.0
221
+ if not r['format']:
222
+ return {**r, 'total': -0.1}
223
+
224
+ r['anchored'] = 1.0 if action_result['anchored'] else 0.3
225
+
226
+ interior = state.graph.interior_vertices()
227
+ n = max(len(interior), 1)
228
+
229
+ kaw = [check_kawasaki_at_vertex(v, state.graph) for v in interior]
230
+ mae = [check_maekawa_at_vertex(v, state.graph) for v in interior]
231
+ blb = [check_blb_at_vertex(v, state.graph) for v in interior]
232
+
233
+ r['kawasaki'] = sum(ok for ok, _ in kaw) / n
234
+ r['maekawa'] = sum(mae) / n
235
+ r['blb'] = 1.0 - sum(len(v) > 0 for v in blb) / n
236
+
237
+ coverage, economy = geometric_coverage(state, target['edges'])
238
+ r['progress'] = coverage
239
+ r['economy'] = economy
240
+
241
+ all_valid = (r['kawasaki'] == 1.0 and r['maekawa'] == 1.0 and r['blb'] == 1.0)
242
+ r['completion'] = 10.0 if (r['progress'] > 0.9 and all_valid) else 0.0
243
+ r['efficiency'] = -0.01
244
+
245
+ r['total'] = (
246
+ 0.05 * r['anchored'] +
247
+ 0.08 * r['kawasaki'] +
248
+ 0.07 * r['maekawa'] +
249
+ 0.05 * r['blb'] +
250
+ 0.45 * r['progress'] +
251
+ 0.10 * r['economy'] +
252
+ r['completion'] +
253
+ r['efficiency']
254
+ )
255
+ return r
256
+ ```
257
+
258
+ ### Phase 2 reward extension
259
+
260
+ When `fold_engine.py` is available, replace `progress` and `economy` with engineering metrics. No pre-specified target pattern required β€” the model optimizes objectives directly and can discover that Miura-ori is optimal.
261
+
262
+ ```python
263
+ def compute_reward_phase2(state, action_result, folded_state) -> dict:
264
+ # ... same gates as phase 1 ...
265
+
266
+ r['deployment_ratio'] = compute_deployment_ratio(folded_state)
267
+ # = unfolded_area / folded_bounding_box_area
268
+
269
+ r['bbox_compactness'] = 1.0 - (folded_bbox_area / unfolded_area)
270
+ # higher = more compact fold
271
+
272
+ r['total'] = (
273
+ 0.05 * r['anchored'] +
274
+ 0.08 * r['kawasaki'] +
275
+ 0.07 * r['maekawa'] +
276
+ 0.05 * r['blb'] +
277
+ 0.30 * r['deployment_ratio'] +
278
+ 0.20 * r['bbox_compactness'] +
279
+ 0.05 * r['economy'] +
280
+ r['completion'] +
281
+ r['efficiency']
282
+ )
283
+ return r
284
+ ```
285
+
286
+ ---
287
+
288
+ ## Phase 4: Prompts (`env/prompts.py`)
289
+
290
+ ### Code-as-policy prompt (training mode)
291
+
292
+ ```
293
+ You are an origami designer. Generate a complete fold sequence for a unit square [0,1]x[0,1].
294
+
295
+ TARGET CREASE PATTERN:
296
+ Valley fold: (0.0, 0.5) -> (1.0, 0.5)
297
+ Mountain fold: (0.5, 0.0) -> (0.5, 1.0)
298
+
299
+ RULES (your sequence must satisfy at every interior vertex):
300
+ - Kawasaki: alternating sector angles sum equally (each half = 180 degrees)
301
+ - Maekawa: |mountain_count - valley_count| = 2
302
+ - Big-Little-Big: folds bounding the smallest sector must have opposite types
303
+
304
+ ANCHOR POINTS (valid fold endpoints):
305
+ Corners: (0,0) (1,0) (1,1) (0,1)
306
+ Midpoints: (0.5,0) (1,0.5) (0.5,1) (0,0.5)
307
+ Note: the square has 4-fold dihedral symmetry β€” symmetric fold sequences are equivalent.
308
+
309
+ Output a JSON list of fold operations in order. Both endpoints must be anchor points.
310
+
311
+ <folds>
312
+ [
313
+ {"instruction": "...", "from": [x1, y1], "to": [x2, y2], "assignment": "M"|"V"},
314
+ ...
315
+ ]
316
+ </folds>
317
+ ```
318
+
319
+ ### Step-level prompt (demo mode)
320
+
321
+ Same information, but shows only the current step's observation with prior fold history and last-step reward appended. Same model, different prompt wrapper.
322
+
323
+ ```
324
+ ... [same header] ...
325
+
326
+ CURRENT STATE (step 2 of 8):
327
+ Creases placed:
328
+ 1. Mountain fold: (0.5, 0.0) -> (0.5, 1.0)
329
+
330
+ AVAILABLE ANCHOR POINTS:
331
+ Corners: (0.0,0.0) (1.0,0.0) (1.0,1.0) (0.0,1.0)
332
+ Edge midpoints:(0.5,0.0) (1.0,0.5) (0.5,1.0) (0.0,0.5)
333
+ Intersections: (0.5,0.5)
334
+
335
+ LAST REWARD: format=1.0 kawasaki=1.0 maekawa=1.0 blb=1.0 progress=0.32 total=0.33
336
+
337
+ Add the next crease. Output JSON only:
338
+ {"instruction": "...", "from": [x1, y1], "to": [x2, y2], "assignment": "M"|"V"}
339
+ ```
340
+
341
+ ---
342
+
343
+ ## Phase 5: Target Files + Validator (`env/targets/`)
344
+
345
+ Targets are hand-authored `.fold` JSON. Before any target enters training, `validator.py` runs:
346
+
347
+ 1. Parse FOLD JSON, reconstruct the CreaseGraph
348
+ 2. For each interior vertex: even-degree β†’ Kawasaki β†’ Maekawa β†’ BLB
349
+ 3. Enumerate at least one valid MV assignment via the crimp algorithm
350
+ 4. Fail loudly with vertex + violation details if any check fails
351
+
352
+ **Target set:**
353
+
354
+ | File | Creases | Level | Interior vertices |
355
+ |------|---------|-------|-------------------|
356
+ | `half_horizontal.fold` | 1 | 1 | 0 |
357
+ | `half_vertical.fold` | 1 | 1 | 0 |
358
+ | `diagonal.fold` | 1 | 1 | 0 |
359
+ | `cross_fold.fold` | 2 | 2 | 1 (degree 4) |
360
+ | `x_fold.fold` | 2 | 2 | 1 (degree 4) |
361
+ | `pinwheel_base.fold` | 4 | 2 | 4 |
362
+ | `preliminary_base.fold` | 4 | 3 | 4 |
363
+ | `fish_base.fold` | 6 | 3 | 6 |
364
+
365
+ Level 1 targets have zero interior vertices β€” Kawasaki/Maekawa are vacuously satisfied, the only reward signal is `progress`. The model learns to place geometrically correct folds before worrying about vertex constraints.
366
+
367
+ ---
368
+
369
+ ## Phase 6: OpenEnv Wrapper (`env/environment.py`)
370
+
371
+ Both modes supported. The `info` dict explicitly labels what is and isn't checked.
372
+
373
+ ```python
374
+ class OrigamiEnvironment(Environment):
375
+
376
+ async def step(self, action):
377
+ if isinstance(action, list):
378
+ return self._execute_sequence(action) # code-as-policy
379
+ else:
380
+ return self._execute_single(action) # step mode
381
+
382
+ def _execute_sequence(self, folds):
383
+ for fold in folds:
384
+ result = self.paper.add_crease(
385
+ fold['from'], fold['to'], fold['assignment']
386
+ )
387
+ if not result['valid']:
388
+ break # partial credit: reward up to failure point
389
+ reward = compute_reward_phase1(self.paper, result, self.target)
390
+ return self._get_observation(), reward, True, self._info()
391
+
392
+ def _info(self):
393
+ interior = self.paper.graph.interior_vertices()
394
+ return {
395
+ 'local_foldability': all(
396
+ check_kawasaki_at_vertex(v, self.paper.graph)[0] and
397
+ check_maekawa_at_vertex(v, self.paper.graph)
398
+ for v in interior
399
+ ),
400
+ 'blb_satisfied': all(
401
+ len(check_blb_at_vertex(v, self.paper.graph)) == 0
402
+ for v in interior
403
+ ),
404
+ 'global_foldability': 'not_checked', # NP-complete (Bern-Hayes 1996)
405
+ 'n_interior_vertices': len(interior),
406
+ }
407
+ ```
408
+
409
+ ---
410
+
411
+ ## Phase 7: Training Script (`train.py`)
412
+
413
+ Code-as-policy GRPO. Each completion is a complete fold sequence. N=8 completions per prompt evaluated in parallel, each with its own fresh `PaperState`. Terminal reward only.
414
+
415
+ ```python
416
+ def origami_reward_fn(completions, prompts, targets):
417
+ rewards = []
418
+ for completion, target in zip(completions, targets):
419
+ try:
420
+ folds = parse_fold_list(completion) # extract JSON from <folds> tags
421
+ paper = PaperState()
422
+ for fold in folds:
423
+ paper.add_crease(fold['from'], fold['to'], fold['assignment'])
424
+ r = compute_reward_phase1(paper, {'valid': True, 'anchored': True}, target)
425
+ rewards.append(r['total'])
426
+ except Exception:
427
+ rewards.append(-0.1)
428
+ return rewards
429
+ ```
430
+
431
+ Log all reward components separately (kawasaki, maekawa, blb, progress, economy) β€” the decomposed curves are the demo artifact showing the model learning to satisfy geometric constraints.
432
+
433
+ ---
434
+
435
+ ## Phase 8: Fold Engine / Phase 2 (`env/fold_engine.py`)
436
+
437
+ For flat-folded patterns (all creases at 180Β°), the folded bounding box is computable from crease pattern + simplified layer assignment. For Level 1-3 targets the layer assignment is tractable (polynomial for single-vertex, and our simple patterns have at most a few interior vertices).
438
+
439
+ Apply fold angles via reflection transforms, project to get 2D bounding box of the folded state, compute:
440
+
441
+ ```
442
+ deployment_ratio = 1.0 / (folded_bbox_area / unfolded_area)
443
+ ```
444
+
445
+ Higher = more compact = better engineering. With this signal the model can discover optimal fold patterns (Miura-ori, accordion folds) without a pre-specified target.
446
+
447
+ ---
448
+
449
+ ## Build Order
450
+
451
+ ```
452
+ [ ] 1. requirements.txt (shapely, numpy, pytest)
453
+ [ ] 2. env/graph.py β€” CreaseGraph with cyclic ordering, split_edge
454
+ [ ] 3. Unit test: two crossing creases -> 1 interior vertex of degree 4, correct cyclic order
455
+ [ ] 4. env/paper_state.py β€” PaperState.add_crease with intersection handling
456
+ [ ] 5. env/verifier.py β€” even-degree, Kawasaki, Maekawa, BLB, geometric_coverage
457
+ [ ] 6. Unit test: degree-4 vertex with known valid/invalid angles -> Kawasaki pass/fail
458
+ [ ] 7. Unit test: single crease -> zero interior vertices -> verifiers return defaults (True)
459
+ [ ] 8. Unit test: excess crease penalty activates correctly
460
+ [ ] 9. targets/validator.py β€” crimp-check routine
461
+ [ ] 10. env/targets/*.fold β€” 4 Level 1 + 4 Level 2 targets, all passing validator
462
+ [ ] 11. env/rewards.py β€” Phase 1 compute_reward
463
+ [ ] 12. env/prompts.py β€” code-as-policy prompt + step-level prompt
464
+ [ ] 13. env/environment.py β€” both sequence and step modes + info dict
465
+ [ ] 14. Integration test: known valid sequence on half_horizontal, reward >= 0.9
466
+ [ ] 15. Integration test: invalid MV assignment on cross_fold, BLB fires
467
+ [ ] 16. train.py β€” GRPO with code-as-policy reward fn
468
+ [ ] 17. First training run on Level 1 targets, log all reward components to W&B
469
+ [ ] 18. env/fold_engine.py β€” Phase 2: fold angles -> 3D state -> deployment ratio
470
+ [ ] 19. Visualizer (React): render crease graph from FOLD JSON, animate fold history
471
+ ```
472
+
473
+ Steps 2-3 and 5-8 are highest risk. Get the graph data structure and cyclic Kawasaki check correct before building anything on top of them. Steps 14-15 are the checkpoint before touching the training script.
474
+
475
+ ---
476
+
477
+ ## Key Risks
478
+
479
+ | Risk | Likelihood | Mitigation |
480
+ |------|-----------|------------|
481
+ | Cyclic sector angle computation incorrect | High | Explicit unit tests with known valid/invalid patterns |
482
+ | Level 3+ action space too large to learn | Medium | Dihedral symmetry hints in prompt; hard masking if no convergence after 500 steps |
483
+ | GRPO reward signal too sparse (no interior vertices on Level 1) | Medium | Level 1 reward is purely `progress`; works without vertex constraints |
484
+ | fold_engine Phase 2 infeasible in hackathon time | Medium | Phase 1 ships independently; Phase 2 is an extension |
485
+ | Layer ordering required for deployment ratio on complex patterns | Low | Level 1-3 patterns are tractable; flag NP-hardness in info dict |