Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
80 commits
Select commit Hold shift + click to select a range
0d1f4ee
Establish explicit semantic phase results
itsfuad Sep 1, 2026
03b4004
Unify canonical module identity and constant results
itsfuad Sep 1, 2026
c8ebf84
Derive prelude identity and diagnose identity conflicts
itsfuad Sep 2, 2026
499acc9
Resolve exported constant facts through defining module
itsfuad Sep 2, 2026
5b30c29
Note redundant prelude imports and global qualifiers
itsfuad Sep 2, 2026
de8185a
Add a test-tier phase-coverage contract for AST node kinds
itsfuad Sep 2, 2026
84b8f03
Diagnose module identity conflicts before mutating indexes
itsfuad Sep 2, 2026
b08a64d
Give every identity component a dump artifact path segment
itsfuad Sep 2, 2026
e4d87b1
Fail LLVM emission on unclassified MIR nodes
itsfuad Sep 2, 2026
c88d02a
Correct node-contract classifications and drop pass-throughs
itsfuad Sep 2, 2026
18b4800
Require every node-bearing AST field to be traversed
itsfuad Sep 2, 2026
17c0025
Assemble canonical module identity in one place
itsfuad Sep 2, 2026
26600b0
Traverse attribute arguments and harden AST contracts
itsfuad Sep 2, 2026
164baea
Diagnose module identity conflicts before they load
itsfuad Sep 2, 2026
f63b87c
Encode dump artifact paths injectively
itsfuad Sep 2, 2026
29dc746
Test LLVM emission rejects unknown MIR nodes
itsfuad Sep 2, 2026
4994e0d
Drop vacuous identity determinism assertion
itsfuad Sep 2, 2026
8ad69ae
Classify ownership through one capability query
itsfuad Sep 2, 2026
f3347bf
Record compiler framework direction report
itsfuad Sep 2, 2026
c8eca73
Publish value use kinds from typechecking
itsfuad Sep 2, 2026
d4545ba
Locate module identity conflicts at the offending import
itsfuad Sep 2, 2026
540596b
Reject prelude modules without derivable identity
itsfuad Sep 2, 2026
3e5de2e
Fail LLVM emission on blocks without a terminator
itsfuad Sep 2, 2026
c173dce
Drop stale publishedUse comment line
itsfuad Sep 2, 2026
5bdc22e
Publish alloc operand use kind before operand typing
itsfuad Sep 2, 2026
c687b50
Make the cleanup plan the only source of planned drops
itsfuad Sep 2, 2026
52ff007
Validate published ownership evidence at the phase boundary
itsfuad Sep 2, 2026
7ec06e9
Delete the unconsumed match carrier move channel
itsfuad Sep 3, 2026
866d498
Correct the ownership slice completion claims
itsfuad Sep 3, 2026
202304e
Name the diagnostics module scope for what it is
itsfuad Sep 3, 2026
a6aaaab
Drop unreachable dependency-alias completion guards
itsfuad Sep 3, 2026
5de78e6
Document the change paths through the compiler
itsfuad Sep 3, 2026
6fa713a
Replace nullable iteration evidence with a closed plan
itsfuad Sep 3, 2026
62fa4e7
Describe iteration evidence as the closed plan it now is
itsfuad Sep 3, 2026
7b11a33
Verify control-flow topology at the phase boundary
itsfuad Sep 3, 2026
3afde13
Record the CFG verifier in the change-path gap list
itsfuad Sep 3, 2026
557e8b5
Require a phase decision for every type syntax kind
itsfuad Sep 3, 2026
2a5fcf0
Seal the MIR instruction and terminator node sets
itsfuad Sep 3, 2026
b9dc982
Name the block a loop exits to
itsfuad Sep 3, 2026
cd4e2a4
Record the CFG topology audit outcome
itsfuad Sep 3, 2026
f3d72a2
Explain the type declaration reindex in module registration
itsfuad Sep 3, 2026
fee7791
Document the effect stream migration plan
itsfuad Sep 4, 2026
8302559
Add semantic effect artifact and phase slot
itsfuad Sep 4, 2026
d77fb9e
Publish semantic effects for every CFG site
itsfuad Sep 4, 2026
c9c37d4
Publish arm payload bindings before the arm body reads them
itsfuad Sep 4, 2026
baefd36
Consume published effects in definite initialization
itsfuad Sep 4, 2026
b9dc61b
Validate published effects at the phase boundary
itsfuad Sep 4, 2026
b1a2505
Correct the effect stream plan against what shipped
itsfuad Sep 4, 2026
4b5ada6
Inline two single-use helpers in the effect producer
itsfuad Sep 4, 2026
80ac95e
Answer copy class and drop obligation in one traversal
itsfuad Sep 4, 2026
3e06e02
Replace the three ownership predicates with the capability query
itsfuad Sep 4, 2026
da4543b
Enumerate ownership uses from the published effect stream
itsfuad Sep 4, 2026
1001510
Require a phase decision for every semantic type kind
itsfuad Sep 4, 2026
5d1534c
Require a phase decision for every lowered node kind
itsfuad Sep 4, 2026
5a74aa2
Derive liveness definitions from published effects
itsfuad Sep 4, 2026
a99f3b7
Publish use kinds, borrows and discards from one expression walk
itsfuad Sep 4, 2026
7c3f846
Publish the place a value is used from, not just its root
itsfuad Sep 4, 2026
b1cdadf
Bracket the operations a call evaluates
itsfuad Sep 4, 2026
cb38303
Publish the sequence a loop iterates
itsfuad Sep 4, 2026
1666395
Let a place name a temporary, not only a binding
itsfuad Sep 4, 2026
58a80dc
Publish a method receiver as a use, not a field projection
itsfuad Sep 4, 2026
0ecc08c
Bring the migration record in line with what shipped
itsfuad Sep 4, 2026
6079643
Specify the expression walk replacement as one change
itsfuad Sep 4, 2026
2e1ccb2
Consume published effects in ownership's expression walk
itsfuad Sep 4, 2026
04748a8
Add a code tour from source file to executable
itsfuad Sep 4, 2026
6d1ce2a
Validate the shape of lowered HIR and MIR
itsfuad Sep 5, 2026
064e73f
Prove cleanup happens exactly once at runtime
itsfuad Sep 5, 2026
0a72ed1
Settle the type capability inventory and its boundaries
itsfuad Sep 5, 2026
a67c129
Unify compiler structural and semantic infrastructure
itsfuad Sep 5, 2026
463a0ac
Support Go 1.23.2 as compiler baseline
itsfuad Sep 5, 2026
43f71cb
Document final compiler architecture
itsfuad Sep 5, 2026
33ce2a5
Use module symbols for ownership policy
itsfuad Sep 5, 2026
e52be14
Fix projection operand evaluation in semantic effects
itsfuad Sep 5, 2026
2de5d99
Strengthen graph and semantic artifact contracts
itsfuad Sep 5, 2026
f6a2d50
Preserve enum reference-field provenance across replacement
itsfuad Sep 5, 2026
62613b8
Remove redundant type traversal and fingerprint indirection
itsfuad Sep 5, 2026
018295d
Reconcile compiler architecture guarantees and review outcomes
itsfuad Sep 5, 2026
7c0b397
Harden IR validators against typed-nil interface slots
itsfuad Sep 6, 2026
58a737e
Centralize typed-nil detection in pkg/typednil
itsfuad Sep 6, 2026
564e694
Drop unused loop-part role map in HIR validator
itsfuad Sep 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
156 changes: 156 additions & 0 deletions COMPILER_FRAMEWORK_REPORT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
# Compiler Framework Final Report

## Problem

Peeper previously repeated the same structural and semantic work in several
phases. A feature could compile while one resolver/type/flow/ownership/cleanup
path was forgotten, then fail much later. Fixing one missed path often created a
new mismatch because phases independently walked the same syntax or type shape.

`ast.Inspect` already demonstrated the preferred solution: one package owns
structure; many consumers reuse it.

## Final decision

Framework is **not** a compiler-wide visitor pattern and **not** an effect stream
used for everything. Final design combines:

- canonical structural kernels;
- phase-owned semantic evidence;
- generic graph/worklist mechanics;
- explicit exhaustive decisions only at genuine semantic extension points.

Detailed contract: [`docs/compiler-architecture.md`](docs/compiler-architecture.md).

## Implemented architecture

This describes current source, including local correctness follow-up; it does not
assert that uncommitted work is released or that roadmap milestones are complete.

### Semantic type structure

`typeinfo.Type` is sealed by canonical child and ownership-composition methods.
`typeinfo.ForEachChild` exposes immediate semantic children with relation metadata.
Recursive containment and copy/drop capability queries reuse this structure.

Result: adding a container around an existing subtype declares its relation once;
nested reference/ownership/drop behavior is derived instead of added to several
walks.

### Shared graph topology

`graph.Directed` owns ordered outgoing/incoming indexes. Existing graph users and
CFG use this kernel while CFG retains typed branch/case semantics.

Result: adjacency/reverse-adjacency mechanics have one owner. CFG terminators and
ordered sites remain canonical topology; block/site indexes are derived, frozen by
consumer convention, and rebuilt together for topology changes. Validators inspect
all stored edges, including foreign components, and exact site-edge metadata.

### Shared fixed-point scheduling

`graph.Worklist` owns queueing, pending deduplication, and rescheduling. Flow,
definite-init, ownership, and liveness keep their own lattices and transfers.

Result: repeated scheduler mechanics are centralized without creating a generic
pass framework that hides semantics.

### Canonical places

`place.Project` and `place.Decompose` own selector/index place grammar. Effect and
ownership code no longer maintain private selector/index peeling logic.

### Semantic effects as downstream boundary

Effects now carry enough identity for generic consumers:

- definitions carry initializer identity;
- writes carry source owner/value identity;
- borrows carry exact borrowed operand identity;
- sequence loops publish `Iterate` with loop/place/carrier identity.

Ownership consumes `Define` and `Write` directly instead of separate `let`,
`const`, and assignment statement handlers. `effect.Visitor` is the compile-time
consumer contract: introducing a genuinely new semantic operation breaks every
exhaustive consumer until it explicitly implements that operation. Sequence-loop borrow lifetime is
published as an effect instead of rediscovered from `ForStmt` and typechecker plan
shape. Definite initialization and ownership/liveness consume the same ordered
effect stream.

### Bounded ownership provenance and lexical usage

Ownership still captures accepted reference-bearing value shapes before effects
can move them, using existing loans, flow origins, reference types and semantic
variant constructions. Holder-relative loan paths distinguish stored slots from
borrowed origins and loan IDs. Exact projected direct/optional enum reference-field
replacement preserves siblings and copied holders; carrier-level liveness remains
conservative. This is not a general aggregate provenance framework, nor support for
nested stored-reference aggregates. New reference-bearing shapes require an audit.

Usage warnings remain lexical: `semantics/usage` consumes symbol usage/mutability
flags from resolution, type/import lookup and typechecking, not reachable runtime
effects. Migrating them would require a separate warning-policy decision.

### Contract cleanup

Contracts that only verified duplicated downstream AST switches were removed.
Remaining contracts guard real closed extension points such as semantic type
identity/lowering/fingerprinting. Artifact validators remain primary guards for
cross-phase evidence shape/identity. They do not prove that a handled syntax case
published every required operation: producer ordering tests and executable source
fixtures cover semantic publication. Sealed type methods enforce presence, not
correct child enumeration. Empty effect artifacts can be valid.

Leaf type traversal methods return directly; exported fingerprints use their
existing `Type` parameter without a redundant assertion. Bounded pointer reflection
in `isNilType` remains to preserve typed-nil capability answers. No nil-only
interface or exhaustive replacement dispatcher is introduced.

### Go baseline

Repository now targets Go 1.23.2. Post-1.23 convenience APIs used by tests/runtime
were replaced with equivalent 1.23 code; no compiler semantics required Go 1.26.

## Extension result

For a new syntax construct expressed using existing semantic actions, expected
work is concentrated in syntax-aware owners, provided existing provenance shapes
also suffice:

```text
AST/parser -> resolver/typechecker as needed -> CFG/effects as needed -> HIR
|
v
existing definite-init/ownership/liveness/cleanup
```

For a new composite semantic type:

```text
declare type -> child relations + ownership shape
|
v
generic containment/copy/drop propagation
```

Representation-specific decisions such as equality, ABI lowering, exported
fingerprint, or genuinely special sizing remain explicit by design.

## Verification standard

Final handoff requires:

```text
GOTOOLCHAIN=local go test ./...
GOTOOLCHAIN=local go vet ./...
GOTOOLCHAIN=local go test -race <concurrency-sensitive compiler packages>
```

plus a fresh `go run ./scripts/bundle.go` followed by full `x_test` with explicit
absolute `PEEPER_BIN`. Run full tests, bundle and executable fixtures sequentially:
they share build artifacts. Without `PEEPER_BIN`, fixture execution is skipped.
See architecture verification commands for focused graph/project/pipeline races.

Passing tests alone
is not enough; architecture audit must also confirm canonical kernels have not
been bypassed.
13 changes: 12 additions & 1 deletion COMPILER_GUIDELINES.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,12 @@ design, do not follow it silently. Report conflict and evidence so maintainer ca
decide whether guideline or design must change.

Current ownership, pointer, copy, and optional design lives in
[docs/ownership-pointer-model.md](docs/ownership-pointer-model.md).
[docs/ownership-pointer-model.md](docs/ownership-pointer-model.md). The implemented
compiler architecture, canonical structural mechanisms, semantic evidence boundaries,
and contributor extension rules live in
[docs/compiler-architecture.md](docs/compiler-architecture.md). Migration history and
supporting analysis live under
[docs/compiler-framework/](docs/compiler-framework/README.md).

## 1. Priorities

Expand Down Expand Up @@ -140,6 +145,12 @@ fail clearly rather than be skipped silently.
Semantic switches remain appropriate when each node kind requires distinct
behavior. Centralize structural recursion, not semantic decisions.

Current canonical mechanisms are `ast.Inspect` for AST recursion,
`typeinfo.ForEachChild` for semantic-type structure, `place.Project`/`Decompose`
for storage projections, `graph.Directed` for topology, and `graph.Worklist` for
fixed-point scheduling. Analyses should extend these owners instead of creating a
parallel walk, adjacency store, or queue/queued-set implementation.

Before adding a walker or lookup:

1. search all existing implementations;
Expand Down
6 changes: 6 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ These files are canonical; do not copy their rules into new documents:
- [`COMPILER_GUIDELINES.md`](COMPILER_GUIDELINES.md): compiler phase,
representation, traversal, and incremental-analysis guidance.

For a change that touches the compiler pipeline or semantic model, read
[`docs/compiler-architecture.md`](docs/compiler-architecture.md) first. It defines
the canonical mechanisms, representation boundaries, and extension paths.
[`docs/compiler-framework/change-paths.md`](docs/compiler-framework/change-paths.md)
is the concrete file-by-file companion for common changes.

`AGENTS.md` contains automation workflow, not additional human-facing code
policy.

Expand Down
Loading
Loading