Skip to content

refactor: ponytail cleanup - remove waste and simplify#178

Merged
vmvarela merged 2 commits into
masterfrom
refactor/ponytail-cleanup
Jun 18, 2026
Merged

refactor: ponytail cleanup - remove waste and simplify#178
vmvarela merged 2 commits into
masterfrom
refactor/ponytail-cleanup

Conversation

@vmvarela

Copy link
Copy Markdown
Owner

Summary

Ponytail refactor (full intensity) of the sql-pipe codebase. Deleted waste, simplified structures, shortest diff.

Changes

Phase 1: Delete loop invariant comments (-98 lines)

Removed 39 formal loop invariant/bounding function comment blocks across 8 files. These academic-style // Loop invariant I: / // Bounding function: comments added noise without value — no formal verification tooling consumes them.

Files: args.zig, csv.zig, format.zig, json.zig, loader.zig, main.zig, modes/sample.zig, xml.zig

Phase 2: Extract loadInput() helper (-38 lines)

Eliminated duplicated format dispatch logic in main.zig. Two nearly identical 42-line switch blocks (file loading + stdin loading) replaced with a single 22-line loadInput() helper + concise call sites.

Adding a new input format now requires one change instead of two.

Phase 3: Simplify inferTypes() (-27 lines)

Replaced 11 parallel boolean/enum arrays with a single ColumnInference struct in loader.zig:

  • 11 allocations → 1 allocation
  • 11 defer chains → 1 defer chain
  • Manual initialization loop → struct field defaults

Impact

Metric Value
Net lines removed -154
Logic changes Zero
Unit tests 78/78 passed
Integration tests 225/225 steps, 20/20 passed

Validation

All tests pass:

  • zig build unit-test -Dbundle-sqlite=true — 78/78
  • zig build test -Dbundle-sqlite=true — 225/225 steps

- Delete 39 formal loop invariant comment blocks (98 lines) across 8 files
  These academic-style comments added noise without value for straightforward loops

- Extract loadInput() helper in main.zig (-38 lines)
  Eliminated duplicated format dispatch logic between file and stdin loading
  Two 42-line switch blocks replaced with single 22-line helper + concise call sites

- Simplify inferTypes() in loader.zig (-27 lines)
  Replaced 11 parallel boolean/enum arrays with single ColumnInference struct
  Reduced from 11 allocations to 1, eliminated initialization loop

Total: -154 lines, zero logic changes, all structural simplifications.
All 78 unit tests + 20 integration tests (225 steps) pass.
@github-actions github-actions Bot added the type:chore Maintenance, refactoring, tooling label Jun 18, 2026
- Add execSql, columnText, columnName helpers to sqlite.zig (13 call sites)
- Add readAllInput, checkMaxRows helpers to sqlite.zig (11 call sites)
- Add fatalNoRows helper to xml.zig (3 call sites)
- Add firstJsonObject helper to json.zig (3 call sites)
- Delete unused LoadOpts struct from format.zig

Net reduction: -66 lines (pass 2), -229 lines (combined pass 1+2)
All tests pass: 78 unit + 20 integration (225 steps)
@vmvarela vmvarela merged commit 061a9fc into master Jun 18, 2026
4 checks passed
@vmvarela vmvarela deleted the refactor/ponytail-cleanup branch June 18, 2026 18:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type:chore Maintenance, refactoring, tooling

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant