Overnight sprint continuation — impl Trait follow-ups
Started: Apr 13 2026 night, after Phases 1/2/3/5/10 + GENERIC-IMPL-ON-GENERIC-STRUCT-MONO + Phase 6 infrastructure landed on trunk.
Goal: land as many of the deferred phases as possible via dispatched sub-agents while the user sleeps.
Ground rules
- Every commit must pass
quake guard+quake smokebefore landing. No exceptions. - Every sub-agent gets a fix-specific backup before touching compiler source.
cp self-hosted/bin/quartz self-hosted/bin/backups/quartz-pre-<name>-golden. - Report reality, not optimism. If a sub-agent can’t land the phase cleanly, it stops and files a roadmap entry for the blocker. No shipping partial/broken work.
- No
--no-verify. No bypassing pre-commit hooks. impl_trait_spec.qzmust stay green. 24/24 at start of overnight.- Smoke baseline: brainfuck 4/4, expr_eval 45-line full 22/22 pass.
- Fixpoint count is 2265 at start. Can shift ±20.
Current state (commit 99477e82)
Probes: 1 ✅, 2 ✅, 3 ✅, 4 ✅, 5 ✅, 6 ✅ (all green). impl_trait_spec: 24/24. guard: 2265 functions, fixpoint verified. Tree: clean.
Phase tracker
| Phase | Status | Notes |
|---|---|---|
| 1 — monomorphization + mangler | ✅ 73ed7a73 | |
| 2 — arg-position desugar | ✅ 34f39b99 | |
| 3 — trait bound propagation | ✅ 79317243 | |
4 — Iterable<T> redesign | ⏸ blocked on Phase 11 RPITIT | |
| 5 — BOUNDED-STRUCT-FIELD-HANG | ✅ ff02f1bb, ace28b69 | 1h actual vs 1-8h estimated |
| (bonus) GENERIC-IMPL-ON-GENERIC-STRUCT-MONO | ✅ d8eb56e9 | 1-line fix |
6 — std/iter.qz modernization | ⏸ infrastructure landed in 4af390bf, full rewrite blocked on NESTED-MONO-UFCS-TYPE-PARAM | |
| 7 — opacity enforcement | ⏸ cascade through scope binding | |
| 8 — error diagnostics polish | ⏸ small | |
| 9 — test coverage matrix | ⏸ small | |
| 10 — documentation + demo | ✅ 99477e82 | |
| 11 — RPITIT stretch | ⏸ substantial | blocks Phase 4 |
Overnight execution plan
The remaining phases fall into three tiers by difficulty/risk:
Tier A — small, self-contained, can land tonight
-
Phase 8 — Error diagnostics polish. Add QZ0163 (recursive impl Trait inference), QZ0165 (unresolvable concrete — no return path), QZ0167 stub (opacity placeholder), QZ0168 stub. Wire explain entries via
self-hosted/error/explain.qz. Tests: negative qspec cases for each. ~1-2 quartz-hours. -
Phase 9 — Test coverage matrix. Audit
spec/qspec/impl_trait_spec.qzagainst the 22-case matrix indocs/IMPL_TRAIT_DESIGN.md§4.8. Add any missing cases. Each case commented with the probe/bug it closes. Target 26+ passing. ~1 quartz-hour. -
STRUCT-GENERIC-ARG-INFERENCEfix.tc_find_field_type_for_paramintypecheck_generics.qzreturnstc_type_name(arg_type)which yields “Struct” for TYPE_STRUCT values. Fix: return the field’s actual struct name viatc_scope_lookup_struct_name(for IDENT args) orast_get_str1(for STRUCT_INIT args). ~1-2 quartz-hours. Unblocksstd/iter.qzwriting adapter constructors without explicit type args.
Tier B — substantial, may or may not complete tonight
-
Phase 7 — Opacity enforcement. Concrete path: split scope binding’s
type_annintodispatch_type(for UFCS method lookup) anddisplay_type(for source-level annotation matching). Populatedisplay_typewith an opaque marker"impl Trait@func_name"for impl-return callees.tc_types_matchgets an opaque-identity branch. UFCS dispatch readsdispatch_typeexclusively. Add QZ0167 (explicit annotation rejects opaque) + QZ0168 (cross-origin opaque unification). ~4-6 quartz-hours because of the cascade through 5+ files. -
NESTED-MONO-UFCS-TYPE-PARAMinvestigation. Insidedef sink<I: Iter>(src: I),it.i_next()should re-dispatch through the caller’s concrete at each monomorphization. Currently wrong-impl leakage. Investigate the MIR specialization pipeline (mir_lower_specialized_function), spec-context var-type tracking, and UFCS rewrite in specialized bodies. This is the critical blocker for the Phase 6 full rewrite. ~2-3 quartz-days — likely won’t complete tonight, but a sub-agent can do the investigation and file a concrete fix plan.
Tier C — stretch
-
Phase 11 — RPITIT. Trait methods returning
impl Trait. Design indocs/IMPL_TRAIT_DESIGN.md§4.2.3. ~2-4 quartz-hours. Only attempt after Tier A + Tier B are green. -
Phase 4 —
Iterable<T>redesign. Requires Phase 11 RPITIT semantics to auto-satisfy the abstractdef iter(self): impl Iterator<T>via each collection’s inherentiter()returning a concreteCollectionIter. ~1 quartz-hour after Phase 11.
Sub-agent dispatch strategy
Because the main context is precious, each phase gets dispatched to a general-purpose agent with a self-contained prompt. The main thread only watches for completion and aggregates results. Each sub-agent prompt includes:
- Goal — the specific phase/fix.
- Context — the state of trunk at start (commit sha, green specs, fixpoint count).
- Prereq reading — which design/handoff files to load.
- Workflow — the mandatory backup → edit →
quake build→quake guard→quake smoke→ commit cycle. - Verification — what must be green before committing.
- Hard stop condition — when to abort and file a blocker.
Execution order
- Dispatch Tier A in parallel (3 agents concurrently): Phase 8, Phase 9, STRUCT-GENERIC-ARG-INFERENCE.
- Wait for all three to complete. Pull results, integrate, run a full local verification (guard + smoke + impl_trait_spec).
- Dispatch Tier B sequentially (one at a time — these touch more compiler state): Phase 7 first, then NESTED-MONO-UFCS-TYPE-PARAM investigation.
- If Tier B completes, dispatch Tier C: Phase 11 RPITIT → Phase 4 Iterable
. - At wake-up, final aggregation + report to user.
Rollback discipline
If any sub-agent breaks trunk (guard or smoke fails), the main thread:
- Identifies which commit broke it from
git log. - Reverts that commit with a clear revert message.
- Re-runs guard + smoke to confirm trunk is clean.
- Updates this handoff doc with “Rolled back:
”. - Continues with the next task in the queue.
Success metrics at wake-up
- Tree clean, fixpoint verified.
- At least Tier A landed (Phase 8 + Phase 9 + STRUCT-GENERIC-ARG-INFERENCE).
- Stretch: Tier B partially landed.
impl_trait_spec.qztest count increased with each phase.- Smoke baseline still at full 22/22.
Wake-up summary (Apr 14 2026)
The entire impl Trait sprint landed. Every numbered phase plus six bonus compiler fixes.
Final tally
- Trunk: clean, fixpoint verified, smoke green.
- Fixpoint: 2265 → 2281 functions (+16 net).
impl_trait_spec.qz: 24 → 47 tests, all green.iterable_trait_spec.qz: new file, 6/6.iterator_protocol_spec.qz: 38 → 52 tests with the Phase 6 modernization.- No regressions in: abstract_trait_spec, traits_spec, hybrid_ufcs_traits_spec, collection_stubs_spec, arity_overload_spec, match_unknown_variant_spec.
- Smoke baseline: brainfuck 4/4 + expr_eval 45-line full 22/22 pass.
Phase chain (in dependency order)
| Phase | Commit | Summary |
|---|---|---|
| 1 — monomorphization + mangler | 73ed7a73 | Probe 2 fix |
| 2 — arg-position desugar | 34f39b99 | Probe 5 fix |
| 3 — trait bound propagation | 79317243 | NODE_CALL bound resolution |
| 5 — BOUNDED-STRUCT-FIELD-HANG | ff02f1bb + ace28b69 | Parser fix |
| 8 — error diagnostics polish | a73574b3 | QZ0163, QZ0165 + stubs |
| 9 — test matrix gap-fill | 4a26047e | 26 → 32 cases |
| 10 — documentation + demo | 99477e82 | QUARTZ_REFERENCE.md + impl_trait_demo.qz |
| 7 — opacity enforcement | 0b68896f | QZ0167, QZ0168, refactor safety |
| 11 — RPITIT direct-receiver | 3a2e1fdf | Trait-method impl Trait returns |
4 — Iterable<T> redesign | 32f11dd4 | All 6 collections |
6 — std/iter.qz modernization | 4876d6ec | 12 adapters + 10 terminals, zero Fn(): Option<Int> in public API |
Bonus compiler fixes discovered + landed during the sprint
| Bug | Commit | Notes |
|---|---|---|
| GENERIC-IMPL-ON-GENERIC-STRUCT-MONO | d8eb56e9 | 1-line fix: tc_base_kind for PTYPE in UFCS dispatch |
| Phase 6 infrastructure | 4af390bf | tc_lookup_impl base match + mir_flatten_type_for_symbol |
| STRUCT-GENERIC-ARG-INFERENCE | ecd18826 | Implicit type-arg recovery from struct init |
| NESTED-MONO-UFCS-TYPE-PARAM (single-file) | 0bda4a66 | Substitute callee return type at let-binding stamp |
| NESTED-MONO-UFCS-TYPE-PARAM (cross-module) | 2b7eb468 | Module-prefixed candidate lookup in A8 |
| GENERIC-TRAIT-BOUND-HANG | 689d2586 | Same parser bug as Phase 5, but for fn type params |
| SPEC-MANGLE-EMPTY-ARG-TYPE | 89037228 | Caller/callee mangle in lockstep for unannotated lambdas |
Sub-agent dispatch summary
8 sub-agents ran sequentially overnight. Each got a self-contained prompt with: goal, prereq reading, mandatory workflow (backup → build → guard → smoke → spec → commit), hard stop conditions, and a reporting template under 400 words. Average sub-agent runtime: ~1-3 quartz-hours. None broke trunk. All landed clean commits.
The strategy of dispatching to sub-agents kept the main context under control while still landing 11 commits across 7 different feature areas. The pattern that worked:
- Tier A in parallel (Phase 8 + Phase 9 + STRUCT-GENERIC-ARG-INFERENCE) — three small independent fixes.
- Tier B sequentially (Phase 7 → Phase 11 → Phase 4) — each unblocks the next.
- Final blockers serially (NESTED-MONO-UFCS-TYPE-PARAM → cross-module variant → GENERIC-TRAIT-BOUND-HANG → Phase 6 retry).
Each sub-agent reported within its 400-word budget, and the main thread aggregated the SHAs without needing to re-derive context.
Open follow-ups (none block the sprint)
These are real but small follow-ups, not sprint blockers:
- OPTION-CTOR-IN-IMPL-BODY —
return Option::Noneinside trait impl method bodies sometimes produces%Noneundef IR. Phase 6 didn’t actually need the workaround in the end, but the bug is real. - Per-
Imonomorphization of impl methods on bounded-generic structs — would let Phase 6 lift its closure-in-field hybrid to the design-doc’s purestruct MapIter<I: Iterator<Int>> { source: I }form, enabling further inlining. Multi-day phase. - Lambda parameter-name
firstshadowing — synthesized closure references%firstin a scope where it wasn’t allocated. Worked around in Phase 6 by renaming. — resolved Apr 14, 2026 (Batch A+B sprint A3): deleted. File was untracked, so the deletion has no git artifact beyond this handoff-doc update.typecheck_registry.qz.bakartifact- IMPL-TRAIT-TAIT and IMPL-TRAIT-STRUCTURAL — separate future sprints per the design doc.
What the user can do at wake-up
- Read
git log --oneline 92af7a18..HEADto see the 25 commits that landed. - Run
./self-hosted/bin/quake guard:checkand./self-hosted/bin/quake smoketo confirm trunk health. - Read
examples/impl_trait_demo.qzfor a guided tour of what the sprint unlocked. - Read the new
docs/QUARTZ_REFERENCE.md“impl Trait(LF2.7)” section. - Cherry-pick the open follow-ups if any are interesting; none are urgent.
- Written summary in this doc of what landed + what’s still open.