Skip to content

source-hygiene: ratchet polling sites, string-typed ids and authored prose to a mind - #5854

Closed
joelteply wants to merge 2 commits into
canaryfrom
fable/ratchets-polling-ids-prose
Closed

joelteply wants to merge 2 commits into
canaryfrom
fable/ratchets-polling-ids-prose

Conversation

@joelteply

Copy link
Copy Markdown
Contributor

Why

Serves the minds by locking three of Joel's repeated rules into the build so the substrate they run on stops regressing (Phase 0/3, "stop adding to the slop": ratchets fail the build). Rules:

  • "long processes use handles and events, never polling"
  • "ids are structured data", never strings or prefixes
  • "her text is rendered from typed data, never authored prose", "ratchet literals to 0"

What

All four ratchets run on the existing seam: SourceRule, the token lexer, and hold_sites, which records per crate and judges against the base tree via the ratchets binary. Each file has one #[cfg(test)] mod with // what this catches:. Every new file is under 250 lines, and no file over 1,000 lines was touched.

ratchet file base = head touched file ends clean
polling_sites polling_sites.rs 68 yes
string_id_fields string_ids.rs 395 no (retyping a field moves its callers)
hand_rolled_short_ids string_ids.rs 27 no
prose_literals prose_literals.rs 32 yes

The total is judged against the base. Per-crate counts are recorded and printed (name@crate) but not judged per crate, so a crate cut that moves sites between crates still passes.

polling_sites. A production tokio::time::sleep / thread::sleep / awaited sleep / sleep_until / interval .tick() counts when its innermost loop / while / for..in either:

  • calls a re-read: filesystem, try_wait, Command, connect / HTTP / execute, query / list / status / snapshot / load / try_recv, or read_* / list_* / fetch_* / check_* / poll_*; or
  • names itself in its wait: POLL, retry, backoff.

Macros (select!, probe!) and atomic fetch_add and friends don't count. The cadence and backoff owners from CONCURRENCY-STYLE-GUIDE are allowed by module path, not by comment:

  • persona/substrate_governor, runtime/cadence_table.rs, runtime/brain_region.rs, runtime/module_harness.rs, runtime/governor_bus.rs
  • system_resources/{memory,disk,fd}_pressure, paging/broker.rs, modules/pressure_broker_module.rs
  • airc/daemon_liveness.rs (the one reconnect owner) and provisioning/rate_limit.rs (the host-told retry owner)

For scale: the audited production tree has 134 waits, 112 of them in loops. The ~302 figure from the audit included tests.

string_id_fields. Fields of production brace structs named id, *_id or *_ids, typed String, &str, Box/Arc/Rc<str>, or Option / Vec / VecDeque / HashSet / BTreeSet of one. Enum struct-variants are not counted yet.

hand_rolled_short_ids. This supersedes #5389's rule: same predicate and name, now with per-crate counts and *_id[..8] slicing added. #5389 becomes only the migration and should drop its shown_ids.rs and lib.rs line on rebase. Its migration will lower this count.

prose_literals. A string literal of 4 or more words counts ({..} placeholders and escapes removed). The cut is a definition, not a tuned number: a label names one thing in at most three words, and a sentence needs more. Literals inside attributes, log/panic/assert macros and .expect(..) are skipped. "Reaches a mind" is a list of module paths, derived from where her prompt messages are built and documented in the rule:

  • llm_deliberation_faculty/prompt/ and llm_deliberation_faculty/tool_surface.rs
  • cognition/tool_surface* and cognition/deliberation_prompt.rs
  • continuum-prompt prompt_assembly and prompt_prefix.rs
  • persona/supervisor/build_persona_system_prompt.rs
  • sdk_codegen/{ai_help,call_form,refusal}.rs

Top offenders

  • polling_sites, by crate: core 21, engine 15, kernel 6, live 6, academy 4, hands 4. By file:
    • kernel/system_resources/bounded_command.rs 3
    • genome/.../engine_lora_adapter/train_status.rs 3
    • academy/cognition/swe_bench/fetch_hf_rows.rs 3
    • live/audio/resource_lifecycle.rs 2
    • live/consumers/avatar.rs 2
    • engine/inference/stderr_relay/follow.rs 2
  • string_id_fields, by crate: mind 67, engine 56, core 48, kernel 33, live 30, academy 21. By file:
    • core/contracts/event_classes.rs 18
    • memory/memory/types.rs 8
    • engine/ai/types.rs 8
    • core/modules/auth.rs 8
    • kernel/routing/airc_realtime.rs 7
    • models/commands/pull.rs 6
  • hand_rolled_short_ids, by crate: mind 9, core 7, live 4, rooms 3. By file:
    • live/session/orchestrator.rs 4
    • core/modules/verdict_board.rs 3
    • core/ipc/positron_nav_source.rs 3
    • rooms/card_facts.rs 2
    • mind/persona/{recorder,perception_region}.rs 2 each
  • prose_literals, by crate: cognition 15, prompt 14, kernel 2, mind 1. By file:
    • prompt/prompt_assembly.rs 14 (the presence blocks, 102 to 116 words each)
    • cognition/deliberation_prompt.rs 6 (TOOLS_INTRO 233 words, ACTING_BLOCK 215)
    • kernel/sdk_codegen/ai_help.rs 2
    • cognition/.../prompt/newest_result.rs 2
    • build_persona_system_prompt.rs 1 (196 words)

Known gaps (inference, not measured)

  • Some test-only files without #![cfg(test)] still read as production, for example resource_admission/aging_tests.rs. This is a lexer gap that predates this PR.
  • Positron sources that tick and re-read through domain-named calls (vitals_emitter, positron_live_source) are not caught by the re-read list.

Measured

Branch head 3ddb337, based on canary e14d6d6, measured 2026-11-07 on the M5 (cargo serialized at nice 19):

  • cargo test -p source-hygiene: 104 passed, 0 failed (lib run 6.0 s).
  • cargo run -p source-hygiene --bin ratchets -- origin/canary: exit 0. Base equals head for every ratchet: polling_sites 68 → 68, string_id_fields 395 → 395, hand_rolled_short_ids 27 → 27, prose_literals 32 → 32. All other ratchets are unchanged.
  • Negative controls: an_added_poll_is_counted_and_a_pacer_is_not, an_added_string_id_field_is_counted_and_typed_ids_are_not, each_hand_rolled_form_is_counted_and_the_owner_is_not, added_prose_is_counted_and_labels_and_logs_are_not.

Do not merge without review.

🤖 Generated with Claude Code

https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

…to a mind

Three owner rules held only in prose get enforced checks on the existing seam
(SourceRule + lexer tokens + hold_sites per crate, base-vs-head via `ratchets`):

- polling_sites (68): a production sleep/sleep_until or interval tick whose
  innermost loop re-reads the filesystem, a child, a peer or a store, or whose
  wait names itself a poll/retry/backoff. Cadence owners (SubstrateGovernor,
  CadenceTable, BrainRegion, module harness, pressure monitors + broker, the
  daemon liveness reconnect owner, provisioning/rate_limit) allowed by module
  path. Touched files end clean.
- string_id_fields (395): struct fields id / *_id / *_ids typed String,
  &str, Box/Arc/Rc<str> or Option/Vec/VecDeque/HashSet/BTreeSet of one.
- hand_rolled_short_ids (27): #5389's predicate, superseded here with
  per-crate counts and `_id[..8]` slicing; #5389 becomes the migration only.
- prose_literals (32): literals of >= 4 words in the modules whose text
  reaches a resident (prompt assembly, deliberation_prompt, tool_surface,
  continuum-prompt prompt_assembly/prefix, build_persona_system_prompt,
  sdk_codegen ai_help/call_form/refusal), logs/attributes/asserts skipped.
  Touched files end clean.

Each has a negative-control test (an added offender is counted).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
@joelteply

Copy link
Copy Markdown
Contributor Author

Closing as superseded in the main by canary 800c21c (#5990, shape ratchets): its shapes/waits.rs (waits_that_decide_flow: sleep/interval/timeout that moves work forward) and shapes/string_identities.rs (string-typed ids) count what this branch's polling_sites.rs and string_ids.rs counted, over every core crate, through the current ratchet::hold_sites(name, violations, touched, advice) signature. This branch no longer compiles against it (E0061: hold_sites takes the Touched argument it does not pass, string_ids.rs:182 and :197; E0603). Two rules here are NOT on canary and remain owed by Fable: prose_literals (authored prose reaching a mind) and hand_rolled_short_ids ([..8] id slices instead of airc's shown_form). Each should land as a rule under core/source-hygiene/src/shapes/ beside #5990's, with its measured baseline.

@joelteply joelteply closed this Nov 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant