Converting Craft Patterns to Logic Blocks
Given a narrative pattern instruction, extract every variable, resolve every ambiguity, and emit a numbered logic block with explicit state.
Input (narrative):
Row 3: Sc in each st across, dec 1 st at each end. (18 sts)
Output (logic block):
BLOCK: ROW_03
TYPE: repeat_row
ENTRY_STATE: { stitch_count: 20, row: 2 }
ACTIONS:
1. STITCH sc COUNT 1 POSITION start
2. DECREASE type=sc COUNT 1 POSITION start
3. STITCH sc COUNT 16 POSITION middle
4. DECREASE type=sc COUNT 1 POSITION end
EXIT_STATE: { stitch_count: 18, row: 3 }
VALIDATION: entry_state.stitch_count - 2 == exit_state.stitch_count
No prose, no "as established," no implied counts. Every number is either given or computed and shown.
Progress:
- [ ] 1. Ingest raw pattern text/chart and identify craft type
- [ ] 2. Extract all explicit variables (stitch/row counts, gauge, materials, sizes)
- [ ] 3. Flag ambiguous or narrative language ("as before," "continue pattern," "approx")
- [ ] 4. Resolve ambiguities against context (repeats, prior rows, stated gauge)
- [ ] 5. Define entry/exit state for each logic block (counts, position, active color/yarn)
- [ ] 6. Convert each instruction line into numbered, atomic actions
- [ ] 7. Insert validation checks (state math must reconcile block-to-block)
- [ ] 8. Chunk blocks for mobile display (one block = one screen/step)
- [ ] 9. Run a full state-trace from cast-on/start to bind-off/finish
- [ ] 10. Output structured module (JSON/YAML) + human-readable rendering
1. Identify craft type and structural unit
- Crochet/Knitting: row or round
- Cross-stitch: symbol block or color pass
- Beadwork: bead-count segment
- Sewing: seam/step operation
2. Extract variables
Pull every quantifiable value: stitch/bead counts, dimensions, gauge, needle/hook size, yarn weight, color codes, repeat counts. Treat anything unstated as a gap requiring inference or a flagged assumption.
3. Flag and resolve ambiguity
Common ambiguous phrases and their resolution strategy:
| Phrase | Resolution |
|---|---|
| "continue as established" | Expand into explicit repeat of prior block's action sequence |
| "approx X inches" | Convert to stitch/row count using stated gauge |
| "work even" | No increase/decrease; state_delta = 0, repeat last row structure |
| "as many as needed to fit" | Compute from target dimension ÷ gauge; show formula |
Never carry forward a narrative reference — always inline the resolved value.
4. Define state
Every block must declare:
ENTRY_STATE: values inherited from previous blockEXIT_STATE: values produced by this block- State fields relevant to the craft:
stitch_count,round,active_color,bead_position,seam_allowance, etc.
5. Atomize actions
One action = one deterministic operation with explicit count and position (start/middle/end/specific index). No compound instructions like "sc2tog across" without expanding the loop count.
6. Validate
Each block's math must be checkable: entry_state ± deltas == exit_state. Run a cumulative trace across all blocks; a mismatch means an ambiguity was mis-resolved.
7. Package for mobile
Structure blocks so each renders as a single scrollable/swipeable unit: short action list (≤6 lines), state header, no scrolling required to see entry/exit counts.
Example 1 — Knitting decrease row
Input: Row 12: K2tog across to last 2 sts, K2. (approx half original sts)
Output:
BLOCK: ROW_12
ENTRY_STATE: { stitch_count: 40 }
ACTIONS:
1. DECREASE type=k2tog COUNT 19 POSITION sequential
2. KNIT COUNT 2 POSITION end
EXIT_STATE: { stitch_count: 21 }
VALIDATION: 40 - 19 == 21
NOTE: "approx half" resolved via explicit k2tog count, not estimation
Example 2 — Cross-stitch color pass
Input: Stitch all DMC 310 symbols in this section, then move to backstitch outline.
Output:
BLOCK: PASS_07
ENTRY_STATE: { active_color: null, stitches_placed: 0 }
ACTIONS:
1. SELECT_COLOR code=DMC310
2. STITCH_FULL_CROSS COUNT 84 POSITIONS [grid_refs...]
3. SELECT_STITCH_TYPE backstitch
4. STITCH_OUTLINE COUNT 12 POSITIONS [grid_refs...]
EXIT_STATE: { active_color: DMC310, stitches_placed: 84, outline_placed: 12 }
Example 3 — Beadwork repeat
Input: Repeat rows 4-6 until strand measures 18 inches.
Output:
BLOCK: REPEAT_GROUP_A
ENTRY_STATE: { strand_length_in: 6.0, gauge_in_per_cycle: 1.5 }
COMPUTED: cycles_needed = ceil((18 - 6.0) / 1.5) = 8
ACTIONS:
1. REPEAT rows=[4,5,6] COUNT 8
EXIT_STATE: { strand_length_in: 18.0, cycles_completed: 8 }
VALIDATION: 6.0 + (8 * 1.5) == 18.0
- Always show the formula when converting a measurement to a count (gauge math must be visible, not hidden).
- Treat every craft's native unit as the atomic block: row (knit/crochet), pass (cross-stitch), cycle (beadwork), operation (sewing).
- Carry state forward explicitly — never assume the reader remembers a count from three blocks ago.
- When a pattern is genuinely size-flexible (multiple sizes in one pattern), extract each size as a parallel variable set, not as prose ("for size M, ...").
- Keep each block mobile-screen-sized; split dense rows into sub-blocks rather than shrinking text.
- Log every resolved ambiguity as a
NOTEso the conversion is auditable against the original text.
- Do not leave any relative/narrative reference ("as before," "repeat pattern," "continue shaping") unexpanded — this reintroduces ambiguity the whole process exists to remove.
- Do not compute exit state without showing the delta — silent math breaks auditability.
- Do not merge multiple distinct actions into one instruction line for brevity; mobile logic blocks need one operation per line.
- Do not assume standard gauge/tension if the pattern doesn't state it — flag as a required input variable instead of guessing.
- Do not skip the full state-trace validation step; unreconciled counts are the most common source of downstream pattern errors.