Overnight Autonomous Work Plan — April 7, 2026
Context
This session completed:
- DG.2 triple-quoted string dogfooding (13 files, 186 conversions)
- API cleanup Phase 1 (band duplicate, addressof, hashmap_del rename)
- Match arm enhancements (char patterns, negative ints, string constants)
- Length-based pre-dispatch optimization for string match
- 700+ arm string match dogfooding (then replaced with world-class Set lookup)
- Unified intrinsic registry (696 intrinsics, single source of truth)
- Bootstrap recovery from near-catastrophic binary loss
- New golden backup protocol in CLAUDE.md
What To Work On (Stack-Ranked by Impact)
1. API Surface Cleanup — Phases 2-4 (Estimated: 2-3 hours)
Complete the remaining phases from the API cleanup plan. Phase 1 is done.
Phase 2: Remove Aliases (specs need updating)
- Remove
set_contains/Set$contains(keepset_has/Set$has) — O(1) =hasper API guidelines - Remove
set_remove/Set$remove(keepset_delete/Set$delete) — key/value deletion =delete - Remove standalone
reverse()(keepreversed()andvec_reverse()) - Remove standalone
sort()(keepsorted()andvec_sort()) - For each: update typecheck_builtins.qz, mir_intrinsics registry, codegen handlers, then migrate affected spec files
Phase 3: Source Migration + len Removal
- Migrate
vec_len→vec_sizein compiler source (64 sites, 55 in lsp.qz) - Migrate
sb_len→sb_size(~3 sites) - Remove
str_len/String$len,vec_len/Vec$len,arr_len,array_len,slice_len,range_len,channel_len+ UFCS variants from typecheck_builtins.qz
Phase 4: Documentation
- Fix STYLE.md
v.clear!→v.clear() - Update INTRINSICS.md: replace
str_lenrefs withstr_size, markset_hasas canonical - Update QUARTZ_REFERENCE.md:
v.len()→v.size
Critical constraint: Every change requires quake build + quake fixpoint. Use the GOLDEN BACKUP PROTOCOL:
- NEVER overwrite
quartz-goldenuntil fixpoint passes - Restore from golden on ANY failure
- Commit binary to git after major successful builds
2. Verify All examples/ Compile (Estimated: 1-2 hours)
Run every file in examples/ and benchmarks/ against the current compiler. Fix any breakage.
This is item #1 on the ship-blocking list.
for f in examples/*.qz benchmarks/*/*.qz; do
echo "=== $f ==="
./self-hosted/bin/quartz "$f" > /dev/null 2>&1 && echo "OK" || echo "FAIL"
done
Fix any failures — they might need updated syntax, new intrinsic names, etc.
3. MIR Heap Corruption Investigation (Estimated: 2-3 hours)
Root cause the bug discovered today:
mir_ctx_mark_struct_var→realloc→ heap corruption- Triggered when
init_intrinsic_registry()(696map_setcalls) runs during MIR lowering - Workaround: init before MIR lowering starts
- Files:
self-hosted/backend/mir.qz(line ~2117), the Vec thatmir_ctx_get_struct_typesreturns
Investigation steps:
- Read
mir_ctx_mark_struct_varandmir_ctx_get_struct_types - Understand the struct_types Vec lifecycle — when allocated, when freed, who holds pointers
- Check if any MIR lowering code caches a pointer to struct_types that goes stale after realloc
- Write a targeted test that reproduces the bug (function with 100+ calls to functions that allocate)
- Fix the root cause (likely: cache invalidation after Vec realloc)
4. Getting Started Guide (Estimated: 1-2 hours)
Create docs/GETTING_STARTED.md — ship-blocking item.
- Install: clone repo, ensure LLVM is installed, build
- Hello World: write, compile, run
- First real program: a small CLI tool using argparse + file I/O
- Next steps: links to QUARTZ_REFERENCE.md, examples/, STYLE.md
Execution Order
- API cleanup Phases 2-4 (highest impact, mechanical, safe)
- Verify examples/ (quick validation, finds lurking bugs)
- MIR investigation (deep work, fixes a real bug)
- Getting Started guide (documentation, no compiler risk)
Golden Backup Protocol (CRITICAL)
Before EVERY quake build after compiler changes:
# Step 1: Verify golden exists
ls self-hosted/bin/backups/quartz-golden
# Step 2: Build
./self-hosted/bin/quake build
# Step 3: Verify fixpoint
./self-hosted/bin/quake fixpoint
# Step 4: ONLY after fixpoint passes, rotate golden
mv self-hosted/bin/backups/quartz-golden self-hosted/bin/backups/quartz-prev
cp self-hosted/bin/quartz self-hosted/bin/backups/quartz-golden
# Step 5: Commit binary periodically
git add self-hosted/bin/quartz && git commit -m "Update compiler binary"
IF fixpoint fails: cp self-hosted/bin/backups/quartz-golden self-hosted/bin/quartz
Key Files Reference
self-hosted/backend/intrinsic_registry.qz— Single source of truth for intrinsicsself-hosted/middle/typecheck_builtins.qz— Builtin type registrations (API cleanup target)self-hosted/backend/mir.qz— MIR context (heap corruption bug location)self-hosted/backend/mir_intrinsics.qz— 13 lines, imports intrinsic_registryself-hosted/backend/codegen_intrinsics.qz— 152 lines, dispatch onlydocs/Roadmap/ROADMAP.md— Roadmap (update after completing work)docs/API_GUIDELINES.md— API naming conventions (hasvscontains,deletevsremove)
What NOT To Do
- Do NOT attempt the intrinsic registry refactor again (it’s done)
- Do NOT modify
mir_lower_expr_handlers.qzormir_lower_stmt_handlers.qzwithout careful fixpoint testing - Do NOT create new modules without verifying imports resolve correctly
- Do NOT overwrite
quartz-goldenuntil fixpoint is verified - Do NOT commit without running the pre-commit fixpoint hook