Skip to content
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
0a11d9d
CM-1: Precompute TypedItemKind — eliminate ad-hoc item classification…
briansrls Apr 5, 2026
edcafa3
CM-2: Precompute ServiceFieldSet — eliminate ad-hoc transport interro…
briansrls Apr 5, 2026
d80fb68
CM-3: Precompute FunctionSignature — eliminate ad-hoc param/return/bo…
briansrls Apr 5, 2026
3dc783f
CM-4: precompute ResourceDefinition — eliminate ad-hoc resource/capab…
briansrls Apr 5, 2026
841276f
Thread ownership proofs from compile to emit — eliminate duplicate an…
briansrls Apr 5, 2026
f27f472
Fix stage0 freshness: restore generated go_source_extension literal
briansrls Apr 6, 2026
2c9a56d
Merge remote-tracking branch 'origin/main' into cm-track
briansrls Apr 6, 2026
158a905
Wire unit_only through Go/Python emit + reconcile stage0 with main
briansrls Apr 6, 2026
03f523a
Add CM.md: catalog missing compiler models and heuristic inventory
briansrls Apr 6, 2026
d5ff7f8
Merge origin/main into cm-track (PR #321: shared_types, TLC-1, Servic…
briansrls Apr 6, 2026
e1dc518
Promote CM to Lane 4 with uncheateable acceptance criteria
briansrls Apr 6, 2026
0ae93f9
Replace grep ratchets with structural unrepresentability claims
briansrls Apr 6, 2026
15f5e7e
CM.md: ground design in foundational primitives, not classification
briansrls Apr 6, 2026
461faf2
Merge origin/main; address CM review feedback in ROADMAP
briansrls Apr 6, 2026
653bfe4
.
briansrls Apr 6, 2026
c6ff6cc
.
briansrls Apr 6, 2026
a843255
.
briansrls Apr 6, 2026
3e734ca
.
briansrls Apr 6, 2026
ab41a86
CM: foundational ontology, known gaps, fix invariant violations
briansrls Apr 6, 2026
b195427
CM: reframe as retrospective lens, not parallel lane
briansrls Apr 6, 2026
ef5d0b5
Fix remaining duplicate-authority references in ROADMAP and inventory
briansrls Apr 6, 2026
0ed4188
CM: add fail-open analysis — where CM helps and where it doesn't
briansrls Apr 6, 2026
aeb150e
Address review: resolve contradictions, add arity boundaries
briansrls Apr 6, 2026
d2c235d
ROADMAP: fold CM findings into lanes, trim CM section
briansrls Apr 6, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
144 changes: 104 additions & 40 deletions ROADMAP.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,14 @@ Modeling guidelines: [MODELING.md](MODELING.md)
┌─ Lane 1: M2 (boundary sufficiency) ──┐
M1 COMPLETE─┤ ├→ M4 (structural identity)
Bootstrap D ┼─ Lane 2: CG (codegen correctness) ───┘ └→ M5 → M6 → M7
COMPLETE ├─ Lane 3: CX (315 → 0; ratchet at 315, main at 164)
COMPLETE ├─ Lane 3: CX (164 → 0)
└─ PERF (continuous — parallel to all lanes)
CM: cross-cutting design lens (informs all lanes) → src/v2/CM.md

Lane 1 owns: 04_infer, 04_types, 02_parse, 04_method
Lane 2 owns: 05_emit, 05_emit_rust, 04_emit_info, ownership, languages
Lane 3 owns: complexity, dsl/std/
CM informs how Lanes 1-3 approach work; does not own files separately
PERF owns: performance ratchets, bootstrap convergence tests, timing budgets
M4 follows Lanes 1+2 (needs structural facts + clean render path)
```
Expand Down Expand Up @@ -636,17 +638,15 @@ No test >2s without justification. Self-compile time tracked per-PR.

---

# Layer 3: Deferred

Theory, long-horizon, and items that land after root-cause tracks complete.
# CM: Compiler Concept Modeling (Lane 4)

## CM: Compiler Concept Modeling (continuous track)
**Full analysis and heuristic inventory:** [`src/v2/CM.md`](src/v2/CM.md)

**Root cause:** The compiler interrogates structural properties (connective,
children count, param count, transport presence) to answer semantic questions
that should be modeled facts. Each ad-hoc question is a symptom of a missing
concept. Until the compiler models its own domain in `.dag`, these questions
will keep spawning in every new feature and every refactor.
**Root cause:** The compiler doesn't model what it does. Every stage
re-derives structural facts that earlier stages already knew. This is
the cause — M2 boundary gaps, CG emit heuristics, and L1 type-name
comparisons are symptoms. Fixing symptoms relocates them; modeling the
concepts dissolves them.

**Principle:** Model actual facts, let properties emerge. Improper
modeling spawns downstream questions. Model the underlying concept and
Expand All @@ -660,38 +660,102 @@ it is an intentional primitive. Recursion is emergent because programs
don't "know" they're recursing. The CX analyzer's heuristics (Theme A)
are CM gaps: each name-matching classifier is a missing concept in std/.

### Concept categories (by impact)

| Category | Pattern | Sites | Missing concept |
|----------|---------|-------|-----------------|
| Item classification | body+params+uses+connective combinatorics 3× | ~40 branches | Precomputed `ItemKind` on Node |
| Connective branching | `Conj`/`Disj`/`NoConnective` if-else everywhere | 30+ branches | Explicit `TypeStructure` (product/coproduct/scalar) |
| Collection detection | Name + children-count checks for List/Map/Set | ~15 sites | Structural `CollectionShape` from algebra |
| Arity as semantics | `params |> count` as proxy for callable/generic | ~10 sites | Explicit `Callable`/`GenericSignature` properties |
| Optional handling | Cardinality modifier + synthetic Some bridges | ~10 sites | First-class Optional as coproduct (M7) |
| Function application | Type-name + arity check for call vs value-ref | ~5 sites | Modeled apply/call concept (M4 Tier 2.6) |
| Transport/service | `transport != none && children > 0` repeated | ~8 sites | Explicit `ServiceDefinition` property |
| Function signatures | body+params+uses conjunctions | ~12 sites | `FunctionSignature` semantic property |
| Property/resource | `properties |> count > 0` as resource proxy | ~5 sites | Explicit `ResourceDefinition` marker |
| Underresolved types | Sentinel names ("Dynamic", "Error") | ~6 sites | Explicit `ResolutionState` enum |

### Dissolution strategy

Items dissolve into existing milestones as they become unblocked:

- **M4** dissolves: collection detection, arity-as-semantics, function
application (Tier 2.6), connective branching (partially)
- **M7** dissolves: Optional handling, connective branching (fully),
underresolved type sentinels
- **Independent**: item classification, transport/service, function
signatures, property/resource — these can be precomputed in inference
and stored on EmitGraphInfo without waiting for other milestones
**Relationship to other lanes:** M2, CG, and CX all generate work items
that are actually CM problems. When a PR "moves a heuristic upstream,"
that's CM work wearing an M2/CG hat. CM is the lane that asks: what
should the model be so the heuristic never existed?

## MM-1: Item identity

**Problem:** Parser produces uniform `Node` for types, functions,
services, resources. Four stages independently re-derive item kind from
`{connective, body, transport, params, children, uses, type_annotation,
properties}`, producing three incompatible taxonomies.

**Current counts (2026-04-05):**
- `classify_typed_item` / `classify_item`: 4 independent forests, ~27 branches total
- Raw structural interrogation in emit (`.connective ==`, `.body !=`, `.transport ==`): 55 sites
- `TypedItemUnhandled` / `""` / `false` fail-open fallbacks: 8 sites

**Work items:**
- [ ] Design: determine irreducible structural facts about items
- [ ] Design: decide carry-on-item vs single-classification vs direct structural match
- [ ] Implement: single authority for item facts, fail-closed by construction
- [ ] Delete: all `classify_*` forests, all fail-open fallbacks, all name-keyed side-tables

**Acceptance:** Item classification is unrepresentable in emit. Emit
modules cannot access raw item structural fields (`body`, `transport`,
`uses`, `type_annotation`, `properties`) for dispatch. The boundary type
carries pre-resolved facts. Classification forests can't exist because
there's nothing to classify.

## MM-2: Type structure

**Problem:** `Conj/Disj/NoConnective` is a primitive, but its
interpretation (product → struct, sum → enum, leaf → primitive) is
re-derived at every consumption site.

**Current counts (2026-04-05):**
- `.connective ==` in emit + lookup + types: 57 sites
- `TypeSummary.repr` (StructRepr/EnumRepr) exists but only used by some consumers
- Type rendering dispatch in `05_emit.dag:1095-1191`: 97 lines, 7 branches

**Work items:**
- [ ] Design: determine whether `TypeSummary.repr` can become the single interpretation authority
- [ ] Design: determine whether non-emit consumers (lookup, types) should use same or different concept
- [ ] Implement: single interpretation of connective, consumed everywhere
- [ ] Delete: all inline `.connective == Conj` / `Disj` checks in emit

**Acceptance:** Connective interpretation is unrepresentable in emit.
Emit modules do not import `Connective` / `Conj` / `Disj` /
`NoConnective`. They receive a resolved type structure and dispatch on

This comment was marked as resolved.

that. Type rendering is an exhaustive match on a sum type.

This comment was marked as resolved.


## MM-3: Expression semantics

**Problem:** Method identity is a string. Call semantics (nullary
invocation, method kind, built-in refinement) re-derived from name
matching at every consumption site.

**Current counts (2026-04-05):**
- `method_def.name` / `method_name ==` dispatch: 21 sites (emit_rust: 12, infer: 5, complexity: 4)
- Nullary function detection: 3 sites in emit_rust, 0 in Go/Python (bug)
- Built-in call type refinement by name: 4 sites in infer

**Work items:**
- [ ] Design: `AlgebraMethodKind` enum on `MethodSemantics` (fold/map/filter/sort_by/...)
- [ ] Design: nullary invocation — `NullaryCallBinding` vs ExprVar→ExprCall normalization
- [ ] Implement: method dispatch via kind enum, not name string
- [ ] Implement: nullary invocation modeled in IR
- [ ] Fix: Go/Python emit must handle nullary function references

**Acceptance:** Method name dispatch is unrepresentable in emit.
`AlgebraMethodSemantics` carries a `kind` enum; emit matches on kind,
not name. Nullary invocation is a structural fact on the expression,
not a type-name check at render time.

## CM acceptance (structural)

Each criterion is a claim: "this class of mistake is unrepresentable."
The boundary type between stages carries the needed facts so the wrong
question can't be asked. See `src/v2/CM.md` for full design rationale.

| Model | Claim | How to verify |
|-------|-------|---------------|
| MM-1 | Emit receives item facts structurally; classification is unnecessary | Boundary type carries resolved facts; emit dispatches on those, not raw Node fields |
| MM-2 | Emit receives resolved type structure; connective re-interpretation is unnecessary | Boundary type carries product/sum/leaf interpretation; emit never re-derives from connective |
| MM-3 | Emit receives method identity as a typed concept; name dispatch is unnecessary | `MethodSemantics` carries a kind enum; emit matches on kind, not name strings |

**Invariant guardrail:** Any new fact layer or boundary type introduced
under CM must be (a) an exact derivation from upstream data, (b) non-lossy
(preserves every distinction downstream consumers need), and (c) landed
with a real downstream consumer in the same change. Speculative metadata
is rejected — the repo has already deleted prior boundary layers that
introduced unused or lossy fact tables.

### Acceptance
---

No ad-hoc structural interrogation in emission. Inference precomputes
all semantic facts. Compiler concepts modeled in `.dag` declarations
readable by the compiler itself.
# Layer 3: Deferred

## P1: Modeling Consolidation

Expand Down
Loading
Loading