Strange LoopsGrammarLawsEvidenceDecisions

Rendered from notes/2026-11-11-declared-keys.md in the repository.

On this page

D8c: declared keys, design note

Moved here from ROADMAP.md on 2026-11-21, unchanged but for links. Every choice is ruled. What was built from it is in the changelog, under 2026-11-14 and 2026-11-15.

By margins-claude, drafted 2026-11-11 for Kyle's rulings before any code. Nothing here was built when he ruled. Kyle ruled on 2026-11-13, and on 2026-11-14, after a consult, on how a slot that follows keys reads a thing's envelope (section 3). Every choice is marked Ruled; none is open. The experiments and proofs are in the margins repo: sl-py/keyfold.py, keyslice.py, keygap.py, keyanchor.py, keyslice_anchored.py, keyenv.py and lean/Convex.lean.

The problem. Once an emit sets only some keys, a thing's state is the merge of its live setters, not one head's payload. where, by, the numeric folds and the slots that follow prev all read one record's payload. With anchored writers the head of a task is often the emit that last changed its title, so "count the open tasks" over heads is wrong.

Terms. A record sets key k when k is in its sets, or when it has no sets (a whole-read emit, which sets every key). A setter of k is live for k when no admitted descendant of it over prev sets k. Every record sets the envelope, whatever its sets. A record is live for the envelope when no admitted record of its thing is above it over prev: it is a head. A record is live when it is live for some key, the envelope among them. So every head is live, a pure join too. For a thing with only whole-read emits, the live records are its heads.

1. sets in the envelope

2. The keyed fold

Ruled: a second value of follow, not a new fold type: {"latest-by": "of", "follow": "keys"}. follow names how supersession is read. "prev" reads a thing as its heads; "keys" reads it as its live setters. Both readings are wanted, so a spec says which; follow-invalid refuses any other value.

The result, per thing, gives the live setters of each key some live record declares, the live whole-read emits, and the heads. Here W and W2 are whole-read, B sets status from W, and W2 is concurrent with B:

{"things": {"task:1": {"keys": {"status": [{"id": "r:W2", "shown": "here"}, {"id": "r:B", "shown": "withheld"}]},
                       "whole": [{"id": "r:W2", "shown": "here"}, {"id": "r:W", "shown": "here"}],
                       "heads": [{"id": "r:W2", "shown": "here"}, {"id": "r:B", "shown": "withheld"}]}},
 "unread": 0}

3. How the other slots read a keyed thing

Ruled: "follow": "keys" is allowed on count, sum, min, max and collect, with or without by, and there the unit is the thing. Slots without follow, and slots with "follow": "prev", keep reading records as written, each from its own payload. So both readings exist and a spec says which it wants. Kyle said of an undeclared payload key (2026-11-10) that the keyed fold does not read it and a whole-record fold, a where test or a lens still can. Ruled: a slot that follows keys does not read it, and the record readings do.

For a slot that follows keys:

The alternatives were to give "follow": "prev" this meaning (then no spec could ask for a fork's heads one by one), or to leave the other slots unable to read keyed things (then no spec can count open tasks once writers set keys).

Ruled 2026-11-14: the envelope is read from the heads (Kyle: "Rule B"; consult of 2026-11-13, sl-py/keyenv.py and lean/Convex.lean in the margins repo). A payload key has setters. kind, observer, about and the times belong to a record, and nothing replaces them key by key. So every emit sets the envelope: the envelope's live setters are the heads, and there is one notion of current, not two. A task moves from one project to another as it does under "follow": "prev" (spec/run/24-by-follow).

What the ruling carries with it:

The alternatives considered:

What the ruling costs: an emit no longer says only what it changes, since it restates the mentions. A changeset that leaves them out takes the thing out of its project. And concurrent emits to different keys, which are no conflict in the payload, are two heads whose envelopes are both read until a join.

4. The laws

LawSaysState
witnessedA part reads each key's live setters as the whole does exactly when every held setter that is dead for a key has a setter of that key above it through held records.Proved over the model and over realm (witnessed_iff, keyedIn_part, keyedIn_slice): keyed.witnessed, keyed.slice.
convexA part that is convex over prev and holds the live setters is witnessed. Not the other way.Proved, with no cycle over prev as a premise (witnessed_of_convex, keyedIn_convex, convex_not_needed): keyed.convex.
anchoredWhen every emit that sets k names every held live record that sets k, the live records alone are a witnessed part. The envelope is such a k, and every record sets it.Proved, with no cycle as a premise (anchored_slice, keyedIn_live, keyedIn_live_slice): keyed.anchored.
ClosedThe anchored law needs a sender that holds what the writers of its records had seen.Proved as a premise; found by experiment (55 wrong in 35,200 when the sender is missing records, none for a convex part). Proved: the rule gives anchored names to a closed holding (anchored_of_written), and a holding that is not closed reads wrongly (closed_needed).
headsA head is a live setter of a key every record sets. So witnessed and anchored cover the heads, and every live record is a head or named by one: the heads list the slice. With the anchor rule over payload keys only, the live records read alone can take a superseded record for a head.Proved (heads_slice, live_named_by_head, heads_need_env): keyed.heads.
receiver's flagA receiver can tell which of its own records a missing name might have replaced; the flag is sound and tight.Proved (flag_tight). Step 5 uses it; not needed for D8c.

5. The writer

Built 2026-11-14 in loops emit; see the changelog, 2026-11-14, "The writer".

6. Out of scope

Order of work: sets in the model with its refusal; liveness per key, the envelope among the keys, and latest-by following keys with heads in its result; vectors, JavaScript, Rust; then the other slots following keys, selecting by heads and reading payload fields from live setters; then the laws ported, the heads law among them (done, for one thing and for a spec); then the anchor and the copied about in loops emit. All of it is built.