Skip to content

Sans-IO baseline: make check ledgers that freeze IO in logic - #971

Merged
GLinnik21 merged 2 commits into
mainfrom
sansio/pr0-ledgers
Oct 24, 2026
Merged

GLinnik21 merged 2 commits into
mainfrom
sansio/pr0-ledgers

Conversation

@GLinnik21

@GLinnik21 GLinnik21 commented Oct 24, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

First step of the Sans-IO series: no product behaviour changes. make check gains enforcing ledgers that freeze today's IO-in-logic sites, so each later PR can only shrink them.

  • Mechanism: the blocking ledger in ci/check-deps.sh is generalised into ci/ledger.awk plus one shell function, and reused. A ledger is an exact multiset of <path>::<enclosing fn>[::<spelling>]. It fails on a new site, a stale line, a # count: mismatch or an alias, and it skips test code by Rust tokens (strings and comments ignored). blocking finds the same 2 sites as before; its parsing is now stricter, and the docs say so.
  • Ledgers under ci/allow/<rule>/<area>.txt — one file per crate, one per module for data/ — so two later PRs never edit the same count line:
Rule What it freezes Sites
workers worker starts (task::spawn*, spawn_small*, spawn_off_frame*, storage_worker::submit*, bare and braced imports) in screens, ui, appkit, machine, data, session, plex/session.rs, player lifecycle, route plan 27
globals client_for, current_server, current_snapshot, keypin::revision/blocked_for, session::peek, grant::offers, player::TX in lifecycle.rs, including renamed imports 105
forks production test/prod forks (cfg(not(test)), cfg(not(any(test, …))), cfg!(test), multi-line forms) across data, plex, media, session 62
fxlanes AppFx arms of Bridge::app_effect that don't go through Fx::Deliver, including or-patterns and catch-all arms 11
  • Docs: new docs/sans-io.md (the rule, the scope, each ledger, how a migration PR deletes its lines), linked from docs/stores-as-machines.md, plus one AGENTS.md working rule.
  • Cleanup: machine/src/machine.rs drops its stale "Phase 2-i contract spike" paragraph and #![allow(dead_code)]; nothing needed it.

No Makefile, Cargo or workflow change, so there is no build-bench table.

Verification

  • make check on the committed head 5072bfa: green. test result: ok. 1867 passed; 0 failed; 64 ignored; 0 measured; 0 filtered out; finished in 61.04s; harness Ran 539 tests / OK; check-deps ok — blocking (2 sites), workers (27 sites), globals (105 sites), forks (62 sites), fxlanes (11 sites).
  • make check-nodef clean.
  • 17 new DepGates tests, each planting into a private copy of the tree. They are red against the old script, except the ones that check blocking is unchanged and that test code is skipped: those pass on both by design.
  • One independent review round, plus 19 planted probes rerun on the fixed head:
    • a site inside a #[cfg(test)] mod or fn passes;
    • each of these fails: a new store site, let and use … as aliases, {self, spawn}, {self, peek}, a bare keypin::revision, super::TX, a new side-queue arm, an or-pattern arm, a catch-all arm, a deleted ledgered site, a misfiled line, a wrong count.
  • check-deps.sh time: 10.3 s before, 12.3 s after.
  • Not run locally: GNU awk / mawk (only BSD awk is installed here). The script uses POSIX awk only. This PR's Linux CI run is the first execution under them.
  • Known gap: use …::keypin::{self as k} followed by k::revision() still gets through. Matching {self as x} would flag ordinary imports.

Closes #970

🤖 Generated with Claude Code

GLinnik21 and others added 2 commits October 24, 2026 04:54
Logic never performs IO: a machine (a screen, a data/ store, the session
owner, the player's foreground lifecycle, a route planner) starts no worker,
reads no process-global registry and has no cfg(test) fork; its work leaves as
a typed effect and every result returns as one addressed event. The migrations
that get there are many PRs, and each needs a floor it cannot fall back through
while it lands. This PR is that floor and changes no product behaviour.

check-deps.sh gains four rules, each an exact multiset of production sites that
only shrinks (a new site, a stale line, a wrong `# count:` or a line filed in
the wrong area fails):

- workers: a production worker start in a machine (task::spawn, spawn_small*,
  spawn_off_frame*, storage_worker::submit, submit_retained, .submit_ticket).
- globals: a production read of a process-global registry in a machine
  (client_for, current_server, current_snapshot, keypin::revision/blocked_for,
  session::peek, grant::offers, player::TX in the player lifecycle).
- forks: a production test/production fork across data/, plex/, media/ and
  session/ (cfg(not(test)), not(any(test, feature = "test-support")), cfg!(..)).
- fxlanes: a Bridge::app_effect arm that does not push Fx::Deliver.

They are seeded from the tool's own output (27 / 105 / 62 / 11 sites), one file
per rule and area under ci/allow/<rule>/ so two migrations in different areas
never edit one `# count:` header.

The `blocking` ledger's awk becomes the shared ci/ledger.awk (a lexer that
blanks comments and literals, a brace-depth enclosing-fn stack, a three-valued
cfg evaluator) behind one ledger_scan / ledger_check pair in check-deps.sh;
`blocking` grades exactly as before. The lexer copies and blanks stretches of a
line in one piece instead of a character at a time (2.5x faster, output
byte-identical over every .rs file in the tree), and one awk pass prefilters
the candidate files for the three file-scanning rules, which keeps the whole
script at about +1.8 s over its previous ~10 s.

Also: docs/sans-io.md states the rule, the scope, each ledger and how a
migration shrinks one (linked from docs/stores-as-machines.md, one bullet in
AGENTS.md); tests/test_harness.py grades every rule with planted violations
(new site, stale line, count mismatch, alias, test-only code) and pins the
per-rule totals; machine.rs drops its stale "contract spike" paragraph and
`#![allow(dead_code)]`, which nothing needs any more.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…ng does now

The ledgers' scanner missed shapes a machine could use to hide a site:

- globals: `keypin::revision`, `keypin::blocked_for` and `grant::offers` could be
  renamed (`use .. revision as rev`) or imported bare; both now fail like
  `session::peek`. The bare-import patterns ate the closing `}` of a braced group
  whose LAST item was the name (`{self, spawn}`, `{spawn}`, `{self, peek}`), so
  every such call went unseen; fixed for spawn, submit, peek and the new names.
  lifecycle.rs reads the player transport as `super::TX` and a bare `TX` too, and
  a rename of `TX` or `player` is refused; the file is always a candidate.
- fxlanes: an arm is a site for EVERY `AppFx::X` on its head, wrapped or not, and
  an arm with no variant (`other =>`, `_ =>`) is the site `AppFx::_`. The match is
  found by its opening line, so arm order no longer matters.
- the test skip of a `#[cfg(test)]` item ends at the close of its own `{..}` (or
  its `;`), so a signature spilling over lines or a `where` clause no longer ends
  it early and grades the body as production.
- a path-qualified macro invocation at module level is an item named for its
  macro: `origin.rs::?` becomes `origin.rs::latched_flag!`, the only ledger line
  that moves (forks 62, unchanged); no `::?` key may be ledgered.

Docs: `blocking` is more accurate on the shared scanner than before, not
unchanged (any cfg-test item, extra attributes, `test-support`/`all(test, ..)`,
strings and block comments, a call after a "http://" string), same sites; forks
counts an inline `cfg!(..)` whatever it evaluates to; a site can move between
same-named fns of one file unseen. DepGates keeps one LEDGER_RULES.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@GLinnik21 GLinnik21 added the internal Tooling, CI, tests and code health; no user-facing change label Oct 24, 2026
@GLinnik21
GLinnik21 merged commit ae611ee into main Oct 24, 2026
19 checks passed
@GLinnik21
GLinnik21 deleted the sansio/pr0-ledgers branch October 24, 2026 03:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

internal Tooling, CI, tests and code health; no user-facing change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

make check: ledgers that freeze IO in logic (Sans-IO baseline)

1 participant