Skip to content

docs: reserved-namespaces forecast + 3+ char-first convention for new builtins#343

Merged
danieljohnmorris merged 4 commits into
mainfrom
chore/reserved-name-strategy
May 17, 2026
Merged

docs: reserved-namespaces forecast + 3+ char-first convention for new builtins#343
danieljohnmorris merged 4 commits into
mainfrom
chore/reserved-name-strategy

Conversation

@danieljohnmorris
Copy link
Copy Markdown
Collaborator

Summary

Three consecutive releases broke carry-forward scripts via short-name builtin collisions: v0.11.3 reserved avg, v0.11.4 tightened +=, v0.11.6 reserved ct. Each time ILO-P011 fired cleanly at parse time with a good rename hint, but the persona had no way to see it coming. Marketing-analyst rerun7 (originating P2 in the assessment doc) called this the predictable-cadence tax: not the rename itself, but the ~6-turn investigation cycle of parse-error → read message → check ai.txt for new builtin → confirm version → apply rename.

This PR closes the forecast gap with combined option (a) + (c) from the originating entry:

  • (a) Reserved namespaces section in SPEC.md — full enumeration of every 2-char and 3-char builtin currently reserved, plus the forward-compat rule. Agents now have a stable published surface to budget against once instead of once per release.
  • (c) 3+ char-first convention in AGENTS.md — new builtins land under names of 4 characters or longer; a short alias is only added later when the long form is unambiguous and the short doesn't shadow a plausible user binding. Existing short builtins grandfather, so this is a forward-looking policy, no renames.
  • Drift-guard test — asserts the SPEC enumeration matches Builtin::ALL at test time so the published forecast cannot silently fall out of sync with the registry.

Manifesto framing: every name-collision incident now turns into a single-character rename (the existing ILO-P011 hint already nails that), and every release ships with a forecast that lets agents avoid the collision in the first place. The published 2-char namespace becomes a forever-safe binding surface for user code.

Rejected option (b) loud→warn: demoting ILO-P011 to a warning would re-introduce the silent-mis-dispatch in call position that the existing error message specifically guards against — exactly the manifesto-violation we're guarding against.

What's in the diff (per commit)

  • docs: add reserved-namespaces section to SPEC — new ### Reserved namespaces subsection after the existing reserved-words section. Enumerates every 2-char (at hd tl rd wr ct) and 3-char short-name builtin, plus the longer ones in prose. Publishes the safe-name strategy (2-char names not on the list are permanently safe, new builtins land 4+ chars). ai.txt and skills/ilo/SKILL.md regenerate through the existing build.rs mirror.
  • docs: record 3+ char-first convention for new builtins in AGENTS.md — new ## Adding builtins section spelling out the rule for contributors, including the alias-only-when-safe guard for short aliases.
  • tests: drift-guard SPEC reserved-names enumeration vs Builtin::ALLtests/regression_reserved_names_doc.rs with two tests: one that parses the SPEC enumeration and diffs it against the registry, one that asserts the section + forecast string still exist. Failure messages point the maintainer at AGENTS.md.
  • examples: reserved-names learning artefactexamples/reserved-names.ilo showing the would-error forms as commented reference + a working 4-char binding. Doubles as engine-harness regression coverage.

Repro before/after

Before: marketing-analyst rerun7, carry-forward script with ct=r.10, hits ILO-P011: 'ct' is a builtin and cannot be used as a binding name. Persona has to grep ai.txt for new builtin entries to figure out what changed. ~6 turn investigation overhead.

After: persona reads SPEC ### Reserved namespaces once, picks cty (unreserved 2-char name, permanently safe) and never collides again. New builtins land under 4+ chars per AGENTS.md so the 2-char surface stops accumulating reservations.

Test plan

  • cargo test --release --features cranelift — full suite green
  • cargo clippy --release --features cranelift --all-targets -- -D warnings — clean
  • cargo fmt --check — clean
  • Drift-guard tests pass with the current registry
  • Drift-guard intentionally fails (verified during development) when the SPEC enumeration disagrees with Builtin::ALL — the message names the offending builtin and points at the AGENTS rule
  • examples/reserved-names.ilo runs across every engine via the existing tests/examples_engines.rs harness, returns 3 as expected

Follow-ups

  • None mandatory. The forecast is now public; any future builtin addition that needs a short alias goes through the AGENTS.md rule, the drift-guard catches the doc update at CI time, and the changelog entry surfaces it to agents on the next persona run.

Three consecutive releases (v0.11.3 avg, v0.11.4 +=, v0.11.6 ct) have
broken carry-forward scripts by adding short-name builtins that collided
with existing user bindings. ILO-P011 catches each at parse time with a
clean rename hint, but the agent has no forward-looking signal: nothing
in the spec told them ct was about to be reserved.

Adds a Reserved namespaces subsection enumerating every 2-char and 3-char
builtin currently reserved, plus the forward-compat rule that new
builtins land under names of 4 characters or longer. That gives agents a
deterministic safe-name strategy: any 2-char name not on the list is
permanently safe, and the 3-char list is publicly stable.

ai.txt and skills/ilo/SKILL.md regenerate through build.rs so the
agent-facing surfaces stay in sync.
Pairs with the SPEC Reserved namespaces forecast: SPEC tells agents
which short names are taken; AGENTS tells contributors why we don't
take any more. New builtins land under names of 4 characters or longer,
and a 2- or 3-char alias is only added later when the long form is
unambiguous and the short doesn't shadow a plausible user binding.

Existing short builtins (avg, ct, sin, flat, frq, ...) are grandfathered;
the rule applies to new entries only. The drift-guard test ties this
back to the SPEC enumeration so the published forecast cannot silently
fall out of sync with the registry.
Asserts every <=3-char entry in Builtin::ALL appears in the SPEC
Reserved namespaces enumeration, and that the SPEC doesn't list names
that aren't builtins. Without this, the forecast we publish to agents
("2-char names not on this list are user-safe forever") can drift
silently the next time a builtin is added without updating the doc —
which is exactly the failure mode that broke marketing-analyst rerun7
when ct landed in v0.11.6 with no spec entry.

Two tests: one for drift in either direction with a precise error
message naming the offending builtin and pointing at AGENTS.md > Adding
builtins, and a structural test asserting the SPEC section and the
forward-compat rule string both still exist.
Demonstrates the safe-name strategy in context: shows the would-error
forms (ct=..., avg=...) as commented-out reference, then a working
4-char binding (mycnt) that's guaranteed forward-compatible because
new builtins land under 4+ char names.

Doubles as engine-harness regression via the example test runner.
@codecov
Copy link
Copy Markdown

codecov Bot commented May 17, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.

📢 Thoughts on this report? Let us know!

@danieljohnmorris danieljohnmorris merged commit c0d25b1 into main May 17, 2026
5 checks passed
@danieljohnmorris danieljohnmorris deleted the chore/reserved-name-strategy branch May 17, 2026 13:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant