bootcc Autonomous Operating Contract #
This file is the standing, machine-parseable agreement every bootcc work
session follows. It exists so that a brand-new crush run session (with no
memory of prior sessions) can pick up and continue the multi-week project
without any human input.
Work is executed as a self-perpetuating crank: an agent does one small, verifiable increment, commits it, advances the state, and the driver launches the next session.
Golden rules (do not violate) #
- Work only inside
/home/lrvick/Sources/bootcc. Everything commits there. Never touch anything else. - One small increment per session. Each session completes exactly one
item from
TASKS/NEXT.md, no more, no less. - Prove it builds + tests before committing. The universal check is the
gate:
It runs, in one place:cd /home/lrvick/Sources/bootcc && sh tools/gate.shmake(build + full test suite), themake clean+make+cmpdeterminism check, the trailing-newline sweep, and the real-tcc.c frontier ratchet. It prints GO / NO-GO; only on GO do you commit. The gate also rewritestools/.frontier_state- commit that file with the increment. - Commit after every verified increment. Prefix messages with the task id. Attribute footer is already configured; keep it.
- M2-Planet subset discipline: bootcc source must compile under the
vendored M2-Planet (
makedoes this). That means: integer-only, nofor(;;)(usewhile(1)), nolong long, no variadic stdlib, bounded strings, and no trailing-code after a non-empty function body's closing brace. Every source file must end with a trailing newline (M2 fails on a missing final newline; the gate sweeps this for every file). - Never rely on GCC. bootcc must be fully buildable and fully
validated with M2-Planet/M2libc alone. The product build
(
build/amd64/bootcc) is pure M2 and must stay that way. GCC (and the gcc-builtbuild/amd64/frontier-probe) may exist ONLY as an optional drift-detection oracle: a byte comparison of the SAME engine sources compiled two ways (m2==gcc). It is never a build input, never a gate requirement, and never the path used to validate an increment. When an oracle binary is cached in a scratch dir it must be rebuilt whenever the engine sources change (existence-only caching yields stale-oracle false failures). Validate engine work on the M2-builtbuild/amd64/bootccand against TCC 0.9.27 runtime parity, not on the gcc probe. - Never brute-force a large component in one shot. If a task needs
~200 lines of new logic, split it into smaller self-contained increments and do ONE per session. If a piece keeps failing, reduce scope or write a tiny failing probe first.
- Update state every session. At session end: append to
LOG.mdand rewriteTASKS/NEXT.mdto the concrete next increment.
Guardrails (machine-enforced, no discretion) #
These exist so a fully unattended crank cannot burn hours on a hang, commit a regression, or silently walk backward on the long-term goal.
1. The gate (tools/gate.sh) is the single definition of a completed #
increment
Worktree changes + make green + rebuild determinism + trailing newlines
(every file except the four crafted EOF tests whose goldens pin
no-trailing-newline EOF line reporting) + frontier non-regression. NO-GO
means the increment is not done: keep working or park (below). Never commit
on NO-GO.
2. The frontier ratchet (tools/frontier.sh + tools/.frontier_state) #
The frontier measures how far bootcc gets on the REAL TinyCC 0.9.27 tcc.c
(-P tokens -> -s symbols -> -x first-error line -> -x clean -> -e
first-error line -> -e clean), encoded as a comparable STAGE:DETAIL
scalar. The gate refuses to pass if the scalar regresses. The state file is
committed with every increment, so the ratchet lives in git history. A
regression is only ever overridden with tools/frontier.sh --force and a
LOG.md entry explaining exactly why it was justified.
3. Watchdog timeouts in every harness #
Every bootcc/driver/toolchain/tcc -run invocation in tests/run-*.sh runs
under coreutils timeout (default 60s, override with BOOTCC_TEST_TIMEOUT;
build steps get 300-600s). A hung case fails that case (exit 124), never the
session. This exists because one unbounded infinite loop once burned 8.5
hours of CPU.
4. Park rules (stop, write state, yield) #
An agent that is not making progress must PARK, not spin:
- Three strikes: if the SAME task fails the same way three times
(three distinct fix attempts, each proven with
make/make testgreen but not solving the task), stop. WriteTASKS/PARKED.md(see format below) and end the session. - Stall rule: if K=3 consecutive increments pass the gate without the
frontier scalar advancing (i.e. work that does not move the long-term
goal), park the current task line and pick the next QUEUE line that can
advance the frontier; if none exists, write
TASKS/PARKED.mdand stop. - Park format (
TASKS/PARKED.md, append a dated section per park):
A fresh session that reads a parked section must run its## PARKED <date>: <task id + one line> state: <what is true right now, with evidence: commands + output> tried: <the 3 attempts, each 1-2 lines> why: <best hypothesis for why it is stuck> unpark: <the concrete experiment that would unblock this>unparkexperiment BEFORE anything else on that task. - STOP file: if a
STOPfile exists in the repo root, do NO work and exit immediately (human halt convention; the human removes it to resume).
5. What a session may NOT do #
- commit on gate NO-GO
- override the ratchet without a LOG.md entry
- delete, shrink, or loosen a test/golden to make a failure go away
- touch
vendor/(checksum-gated third party) - run unbounded: every external command that could loop gets a timeout
Where things live #
PLAN.md— the original architecture plan.LOG.md— running log of every completed increment (append only).STATE.md— one-paragraph "where we are right now" (fresh session's first read).TASKS/NEXT.md-- the single next task spec this session must do.src/-- bootcc source.tests/-- golden tests driven bymake test(all watchdoged).makefile-- M2-Planet build + tests.vendor/-- pinned M2-Planet/M2libc (do not modify).tools/gate.sh-- the definition of a completed increment (GO / NO-GO).tools/frontier.sh+tools/.frontier_state-- the real-tcc.c progress measure and its ratchet.
Session startup ritual #
At the very start of a session, read in this order:
AUTONOMY.md(this file)STATE.mdTASKS/NEXT.mdgit log --oneline -5(see the last few commits)
Then do the task, test, commit, update STATE.md + TASKS/NEXT.md + LOG.md.
Session end ritual #
sh tools/gate.shprints GO (it runsmake+ determinism + trailing-newline sweep + frontier ratchet; on GO it rewritestools/.frontier_state).git add -A && git commitwith a good message (includes the frontier state file).- Append a line to
LOG.md(note the frontier scalar if it advanced). - Rewrite
TASKS/NEXT.mdwith the next single increment. - Update
STATE.mdto one line summarising the new position. - Do NOT push.
If you get stuck #
- Re-read the exact M2-subset rules in
PLAN.mdsection 2. - Reduce the increment to the smallest provable piece.
- Write a tiny probe (
/tmp/x.c) and M2-compile it to confirm a construct is accepted before relying on it. - It is fine to leave a later sub-item marked "deferred (see TASKS/NEXT.md)".