Joseph Ferano d57eeb3265 The refusal was about teardown, and a region has none
A (Vec Value) where a Value may itself hold a (Vec Value) — the recursive
dynamic value an EDN reader has to answer with when nobody hands it a target
struct type — was refused five different ways, and every one of the five gave
the same reason: the container runtime is type-erased, so it copies and
releases slots bytewise and cannot reach inside a slot. A free would release
the slots and leave every block they point at stranded.

That reason is about teardown, and it does not hold for a region. free-all
never releases an individual slot; it takes the whole arena, and every block
the elements own is in it, because they came out of it. The refusals were
over-broad, and what they were guarding was never ownership — ownership
tracking is untouched here, moves are still moves, and Types.is_move_only is
the same function it was.

So the question moved rather than disappeared. It could not stay at the type,
because can-free is a capability on an allocator value and with-allocator
rebinds a dynamic variable: which tier a (vec-new) will meet is not a property
of the place its type is written. What is decided at compile time is only
whether to ask, which is a property of the element type; the answer is a
run-time branch on the allocator, one per container and never per element,
because the alternative is a walk at release and a walk at release is the
registry of destructors the frame tier's reset exists to not have. It is
emitted at every growth and not only at the construction, because ZII means a
container can exist without ever passing through (vec-new) — a case field left
out of a literal, a global that starts zeroed — and those adopt the context on
their first push.

free on such a container is refused rather than made quietly shallow. It cannot
recurse, which is the whole premise, and releasing the outer block alone would
be "I freed it" written over a program that stranded everything inside; this
runtime refuses that collapse everywhere else. The message names free-all,
which is reachable by construction. clone stays refused for a reason the region
does not dissolve, and the old message had bundled the two failures under one
sentence: what disqualifies clone is not that it copies a header — so do at and
get, and they are fine, because they promise nothing — it is that clone
allocates a new block and promises independence, and a bytewise copy hands back
elements still pointing into the original's region.

A struct or union field is admitted only where the field's container holds
owning elements, because that container can only have been built against a
region. A field holding a plain (Vec u8) stays refused: nothing would force
that one into a region, and two copies of the aggregate would be two headers
over one heap block. vec-in-struct.flan still pins that.

The epoch already covered use after free-all, including the case this makes
reachable — an inner header copied out of an arena-held element into a local
still traps, because an Allocator is a pointer and a copied-by-value one would
carry its own epoch.

arena-value.flan builds the value by hand; arena-edn.flan reads a real document
through the tokenizer, and its reader takes no allocator and names none,
because spec-memory.md already puts the allocator in the calling convention.
arena-region.flan is the branch itself: run 0 is the (Vec (Vec i32)) control
that must not trap, and runs 1 and 2 are the two ways this dies.
2026-09-17 20:37:08 +07:00
..

What is in here, and what is still true

These are the documents that are written once and read occasionally: the reasons behind the code, the reports from finished investigations, and the record of individual work sessions. The documents that are edited every day stay at the repository root, because source comments cite them by bare filename from dozens of places and a path that moves is a path that rots. So plan.org, NEXT.md, spec-memory.md and spec-conditions.md are one directory up, and everything here points back at them.

A note on how to read the citations below: a document in this directory that says plan.org means the one at the repository root. Nothing in docs/ is named for a file at the root, so there is no ambiguity, and rewriting a hundred prose mentions into ../plan.org would have cost more in readability than it bought in precision.

If you have thirty seconds

Read BUILT.md. It is by far the largest document here and it is the one that pays: it holds the reason behind every part of the compiler that exists, from why nothing is ever dlclosed to why the printer is a compile-time walk over a type rather than a runtime function. It is current, it is maintained, and deleting it would mean deriving all of it again. If you want to know why a thing is the shape it is, the answer is in here.

After that, ../NEXT.md at the root for what is actually in flight, and REFERENCES.md here for where the evidence comes from — the reference clones on this machine, what each one answers, and the standing rule that a claim in these notes was read out of a clone rather than recalled.

The current documents

File What it is
BUILT.md Why the parts that exist are shaped the way they are. The longest and the most load-bearing document in the repository. Current.
DISCUSS.md Open questions, raised and deliberately not answered. Nothing in it is a decision or a task; entries that have since been answered say so and point at where the answer landed. Current, though it is half archive by now.
PORTING.md What the author's game, siam-farmer, needs from Flan that Flan does not have yet, measured against the code that exists rather than against a plan. It is the requirements document the language is actually steering by. Current.
REFERENCES.md The reference clones under ~/Repositories, what each one is consulted for, and the specific files and lines already cited from them. Current.

The reports

File What it is
SPIKE-GENERICS.md Milestone 5's parametric polymorphism, run early and out of order as a spike. The spike succeeded and generics landed, so this is the report of finished work rather than a live plan — but its findings about where the cost falls are still the reason the implementation looks the way it does. Historical, findings still stand.
overview.md The first brainstorm, from before the language had S-expressions. It says in its own first line that it is superseded and no longer accurate. Kept for history only; its table of what changed is the only part worth reading. Superseded.

handoffs/

One report per work session, each written by whoever held the branch at the time. They are the operational record: what was attempted, what was measured, what was decided without being able to ask, and what was left open for the next lane. They are all historical the moment they are written — a handoff describes a session that has ended — but they are cited by name from source comments and from NEXT.md, because the reasoning behind a guard or a calling convention is often only written down once and this is where it was written.

Six of them are the hand-written x86-64 backend, read in the order the work happened: handoffs/HANDOFF-x86-rt.md set the remaining-items list that the four after it close, handoffs/HANDOFF-x86-redef.md built the redefinition emitter, handoffs/HANDOFF-x86-aggregates.md took that across the struct boundary, handoffs/HANDOFF-x86-guards.md settled the two guards nothing reaches, handoffs/HANDOFF-x86-debug.md added debug information, and handoffs/HANDOFF-x86-cost.md measured what the backend costs and set the survey running on its own so a refusal cannot sit unnoticed again.

The other six sessions are unrelated to each other. handoffs/HANDOFF-arith.md is why a divide by zero is a condition rather than a SIGFPE. handoffs/HANDOFF-raylib-ports.md is the running record of the last two raylib example ports, whose lasting findings were folded into PORTING.md, and handoffs/HANDOFF-cimport-ptr.md is the arm cimport.ml's header check had been promising in a comment and not implementing — which is what those two ports found, worked around and wrote up. handoffs/HANDOFF-devtest-noise.md is the linker error dune test used to print on every run. handoffs/HANDOFF-emacs-flake.md is the test_emacs flake that turned out to be SIGPIPE killing the daemon mid-reply, and it is worth reading for the two mechanisms it rules out as much as for the one it found. handoffs/HANDOFF-tidy.md is this reorganisation.