Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ done until its gate is met on the live node and the change is MERGED.
| 4 | No monolith | NEW RULE (Joel, 10-20): "No one can edit a large file." Every Rust file a PR touches ends at most 1,000 lines; the only PR that touches a monolith is the one that breaks it apart (CI gate). `source-hygiene::file_size` (lines past 1,000; 159,720 on 10-18) falls every week; split by OWNER, never one-off fixes appended to a monolith | owner of each file |
| 5 | No unwraps | `unwrap_justification` (2,135 on 10-18) falls every week; make the state unrepresentable | owner of each file |
| 6 | Microkernel | `layer_discipline` (256 upward imports on 10-18) falls; crates by device target; edit-to-proven <15 min | Sneasel — proposed |
| 7 | One budget | everything in a prompt (history, grounding, tools, reasoning, results) is a claim in ONE flex allocation; no fixed number; positron/RAG sources too. NEVER CLIP THE NEWEST END: her latest result is the step that ends the recursion; cut it and her next input can equal her last, so she repeats the act (Benchy, 125 identical acts in an hour on 10-20). Keep the newest interaction whole and the full result reachable; shrink oldest-first to a handle she can expand. `source-hygiene::head_cuts` (179 on 10-20) falls | Sneasel |
| 7 | One budget | everything in a prompt (history, grounding, tools, reasoning, results) is a claim in ONE flex allocation; no fixed number; positron/RAG sources too. NEVER CLIP THE NEWEST END: her latest result is the step that ends the recursion; cut it and her next input can equal her last, so she repeats the act (Benchy, 125 identical acts in an hour on 10-20). Keep the newest interaction whole and the full result reachable; shrink oldest-first to a handle she can expand. `source-hygiene` `self_sized` (one rule for every resource; ONE-BUDGET.md) falls, and a touched file ends with none | Sneasel |
| 8 | Learning | a reviewed correction applied on unseen tasks, retained after restart, vs the same base without the gene | Cormac, BigMama |
| 9 | One scheduler, the whole grid | every mind on every node (residents and minds leased in from other nodes) is served by ONE RTOS scheduler: one measured activity temperature per mind is its priority, aging means no mind is ever starved, hot minds keep warm KV and cooling minds page to RAM; windows never shrink to seat more; how many minds share the engine at once is the measured admission and sequence-capacity contract of #5188, never a fixed count | Codex — proposed (card b4eed65c) |
| 10 | Tools are working sets | the native tool surface is the command-namespace SUBTREES the activity declares (code/**, work/**, a game's controls); stable within a phase, a switch is a cached prefix, the long tail appends via help; tool share of the prompt measured before/after (44% on 10-18) | Sneasel (card ecd5dff3) |
Expand Down
2 changes: 1 addition & 1 deletion CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ done until its gate is met on the live node and the change is MERGED.
| 4 | No monolith | NEW RULE (Joel, 10-20): "No one can edit a large file." Every Rust file a PR touches ends at most 1,000 lines; the only PR that touches a monolith is the one that breaks it apart (CI gate). `source-hygiene::file_size` (lines past 1,000; 159,720 on 10-18) falls every week; split by OWNER, never one-off fixes appended to a monolith | owner of each file |
| 5 | No unwraps | `unwrap_justification` (2,135 on 10-18) falls every week; make the state unrepresentable | owner of each file |
| 6 | Microkernel | `layer_discipline` (256 upward imports on 10-18) falls; crates by device target; edit-to-proven <15 min | Sneasel — proposed |
| 7 | One budget | everything in a prompt (history, grounding, tools, reasoning, results) is a claim in ONE flex allocation; no fixed number; positron/RAG sources too. NEVER CLIP THE NEWEST END: her latest result is the step that ends the recursion; cut it and her next input can equal her last, so she repeats the act (Benchy, 125 identical acts in an hour on 10-20). Keep the newest interaction whole and the full result reachable; shrink oldest-first to a handle she can expand. The one exception: a newest result that alone exceeds what her window leaves it arrives at its summary plus that handle, because kept whole it stops her acting at all (Aris, 10-26). `source-hygiene::head_cuts` (179 on 10-20) falls | Sneasel |
| 7 | One budget | everything in a prompt (history, grounding, tools, reasoning, results) is a claim in ONE flex allocation; no fixed number; positron/RAG sources too. NEVER CLIP THE NEWEST END: her latest result is the step that ends the recursion; cut it and her next input can equal her last, so she repeats the act (Benchy, 125 identical acts in an hour on 10-20). Keep the newest interaction whole and the full result reachable; shrink oldest-first to a handle she can expand. The one exception: a newest result that alone exceeds what her window leaves it arrives at its summary plus that handle, because kept whole it stops her acting at all (Aris, 10-26). `source-hygiene` `self_sized` (one rule for every resource; ONE-BUDGET.md) falls, and a touched file ends with none | Sneasel |
| 8 | Learning | a reviewed correction applied on unseen tasks, retained after restart, vs the same base without the gene | Cormac, BigMama |
| 9 | One scheduler, the whole grid | every mind on every node (residents and minds leased in from other nodes) is served by ONE RTOS scheduler: one measured activity temperature per mind is its priority, aging means no mind is ever starved, hot minds keep warm KV and cooling minds page to RAM; windows never shrink to seat more; how many minds share the engine at once is the measured admission and sequence-capacity contract of #5188, never a fixed count | Codex — proposed (card b4eed65c) |
| 10 | Tools are working sets | the native tool surface is the command-namespace SUBTREES the activity declares (code/**, work/**, a game's controls); stable within a phase, a switch is a cached prefix, the long tail appends via help; tool share of the prompt measured before/after (44% on 10-18) | Sneasel (card ecd5dff3) |
Expand Down
133 changes: 0 additions & 133 deletions core/continuum-core/src/test_env/mind_integration/source_guards.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,139 +4,6 @@
//! they guard; the mind crate cannot name core's test environment, so they live here. Each
//! asserts exactly what it asserted before the move.

/// From `cognition::context_budget` (its sanctioned home for the calibration).
mod context_budget {
/// what this catches: THE SIXTH TIME. This defect has been fixed and has come back at
/// least five times — #45 (max_tokens clamps), #46 (per-tier context caps), #50 (single-
/// source the effective window), #124 (`EVAL_LANE_CONTEXT = 16_384`, deleted), and then
/// `EXAM_LANE_CTX = 16384` reintroduced the *same* constant in the *same file* three
/// weeks later under a determinism justification. Doc comments and task entries did not
/// stop it; each new author re-derives a "reasonable" number in good faith.
///
/// So this is a RED TEST, not a doc. It scans the whole crate for the shape — a
/// constant whose name says window/context/token/prompt/chars and whose value is a bare
/// literal — and fails on a new one. Adding a bound is still allowed: put it on
/// [`ContextBudget`] as a FRACTION, where it scales with the served window. If you are
/// here because this test failed, that is the fix; do not add your name to the list above.
///
/// A constant that genuinely is NOT a window-relative bound (a phrase length, a dedup key
/// prefix, another model's stated REQUIREMENT) declares itself with a
/// `context-budget-exempt: <why>` comment on the line above. Exemptions are cheap to write
/// and permanently visible in review — which is the point. A silent exemption is not
/// available, because silence is how this came back five times.
///
/// Weakening this test is the same act as re-introducing the constant.
#[test]
fn no_new_hardcoded_context_or_prompt_size_constant_anywhere_in_the_crate() {
// Crate-wide, not just cognition/: the 4096/2048 adapter floor (#46's own surface) sat
// outside cognition and would not have been caught by a cognition-only scan.
let named = |n: &str| {
// Categorically not size bounds, so they don't need to spend an exemption line:
// a duration (`*_MS`), an identifier (`*_ID`), or a vocabulary offset (`*_OFFSET`).
if n.ends_with("_MS") || n.ends_with("_ID") || n.ends_with("_OFFSET") {
return false;
}
["WINDOW", "CONTEXT", "CTX", "TOKEN", "PROMPT", "CHARS"]
.iter()
.any(|k| n.contains(k))
};
let mut offenders = Vec::new();
for file in crate::test_env::source_tree::crate_sources() {
// Vendored upstream code (candle/llama ports) is not ours to restyle; its
// constants are the upstream model's own defaults.
if file.rel.split('/').any(|c| c == "vendored") {
continue;
}
// This module IS the sanctioned home for the calibration; its doc table
// quotes the very constants it replaced.
if file.path.file_name().is_some_and(|f| f == "context_budget.rs") {
continue;
}
let (path, src) = (&file.path, &file.text);
let lines: Vec<&str> = src.lines().collect();
for (i, line) in lines.iter().enumerate() {
let t = line.trim_start();
// Declared non-bound: the marker appears anywhere in the contiguous
// comment block directly above (a reason worth writing often needs two
// lines, and a doc comment may sit between it and the const).
let exempt = lines[..i]
.iter()
.rev()
.take_while(|l| {
let t = l.trim_start();
t.starts_with("//") || t.is_empty()
})
.any(|l| l.contains("context-budget-exempt:"));
if exempt {
continue;
}
// Any visibility, `pub(in crate::path)` included: a split by owner widens
// a moved constant to that form, and a fixed prefix list lost it.
let unscoped = match t.strip_prefix("pub") {
Some(after) if after.starts_with('(') => {
after.split_once(')').map_or(t, |(_, rest)| rest.trim_start())
}
Some(after) => after.trim_start(),
None => t,
};
let Some(rest) = unscoped.strip_prefix("const ") else {
continue;
};
let Some((name, tail)) = rest.split_once(':') else {
continue;
};
if !named(name.trim()) {
continue;
}
let Some((ty, value)) = tail.split_once('=') else {
continue;
};
// Only sizes and RATIOS. A &str / bool / Duration named "...CONTEXT..." is
// not a bound.
//
// The float types are here because of a hole this test had for its whole
// life, found 2026-08-20 the first time anyone wrote a window-relative
// constant that wasn't a token COUNT: `WINDOW_COMPARABILITY_FACTOR: f64 =
// 2.0` (#2339, mine). Name matched, value was a bare literal, and it
// sailed through — because the type list stopped at the integers. A guard
// against invented numbers that a `f64` annotation defeats teaches exactly
// one lesson: type your magic number as a float. A ratio over the window is
// as much a fresh guess as a count of its tokens, and is caught the same way.
if !["u32", "usize", "u64", "i32", "i64", "f32", "f64"].contains(&ty.trim()) {
continue;
}
// A bare literal is the defect — decimal or float, since both are equally
// guessed. An expression built from another named bound (`MIN_SERVE_CTX * 8`)
// is a derivation, not a fresh guess.
let v = value.trim().trim_end_matches(';').trim();
let bare_literal = !v.is_empty()
&& v.chars().all(|c| c.is_ascii_digit() || c == '_' || c == '.')
// `.` only as a decimal point: `1.5` yes, `A.b` / `1..2` no.
&& v.matches('.').count() <= 1
&& v.starts_with(|c: char| c.is_ascii_digit());
if bare_literal {
offenders.push(format!(
"{}:{} — const {}: {} = {}",
path.file_name().unwrap_or_default().to_string_lossy(),
i + 1,
name.trim(),
ty.trim(),
v
));
}
}
}
assert!(
offenders.is_empty(),
"hardcoded context/prompt size constant(s) reintroduced in cognition — express \
these as a fraction on ContextBudget so they scale with the SERVED window \
(a 4k-shaped constant makes a 1M-context model useless and deletes the reason \
to run MoE at all):\n {}",
offenders.join("\n ")
);
}
}

/// From `cognition::experience` (the lived-turn producer's one caller).
mod experience {
// what this catches: the lived-turn producer wired per-CALL-SITE again.
Expand Down
4 changes: 2 additions & 2 deletions core/continuum-core/src/test_env/source_tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ impl SourceFile {
if self.is_test_file() {
return String::new();
}
source_hygiene::production_half(&self.text)
source_hygiene::lexer::production_half(&self.text)
.lines()
.map(code_only)
.collect::<Vec<_>>()
Expand Down Expand Up @@ -93,7 +93,7 @@ impl SourceFile {
/// nor trip a guard. Source-hygiene's splitter, which knows string literals: one
/// comment rule for the ratchets and these guards.
pub(crate) fn code_only(line: &str) -> &str {
source_hygiene::split_code_and_comment(line).0
source_hygiene::lexer::split_code_and_comment(line).0
}

/// The crates cut out of continuum-core whose modules core re-exports under their old
Expand Down
2 changes: 1 addition & 1 deletion core/continuum-kernel/src/gpu/backends/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ mod tests {
let src = include_str!("mod.rs");
let code: Vec<&str> = src
.lines()
.map(|l| source_hygiene::split_code_and_comment(l).0.trim())
.map(|l| source_hygiene::lexer::split_code_and_comment(l).0.trim())
.collect();

// For each `pub mod NAME;` remember whether a cfg attribute sits directly above
Expand Down
16 changes: 15 additions & 1 deletion core/source-hygiene/src/bin/ratchets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,23 +30,37 @@ fn run(base_ref: &str) -> Result<bool, String> {
let scratch = std::env::temp_dir().join(format!("source-hygiene-base-{}", std::process::id()));
let record = scratch.with_extension("counts");
let head_record = scratch.with_extension("head-counts");
let touched = scratch.with_extension("touched");
std::fs::write(&touched, touched_files(&base)?).map_err(|e| format!("cannot write the touched-file list {}: {e}", touched.display()))?;
git(&["worktree", "add", "--detach", &scratch.to_string_lossy(), &base])?;
eprintln!("ratchets: base {base} ({base_ref}) at {}", scratch.display());

// The base run records; its other tests may fail on the base tree (an uninitialized
// submodule for vendor_pin), which is not this PR's to judge, so only its record counts.
let _ = cargo_test(&repo, &[("SOURCE_HYGIENE_CORE", scratch.join("core").as_path()), ("SOURCE_HYGIENE_RECORD", record.as_path())]);
let judged = cargo_test(&repo, &[("SOURCE_HYGIENE_BASE", record.as_path()), ("SOURCE_HYGIENE_RECORD", head_record.as_path())]);
let judged = cargo_test(
&repo,
&[("SOURCE_HYGIENE_BASE", record.as_path()), ("SOURCE_HYGIENE_RECORD", head_record.as_path()), ("SOURCE_HYGIENE_TOUCHED", touched.as_path())],
);
print_movement(&record, &head_record);

let removed = git(&["worktree", "remove", "--force", &scratch.to_string_lossy()]);
let _ = std::fs::remove_file(&record);
let _ = std::fs::remove_file(&head_record);
let _ = std::fs::remove_file(&touched);
removed?;
judged
}

/// The receipt: every ratchet's base and head count, the moved ones first.
/// The Rust files this change touches, one repository path per line: the working tree against
/// `base` (so a local run judges uncommitted work too) and new files git does not track yet.
fn touched_files(base: &str) -> Result<String, String> {
let changed = git(&["diff", "--name-only", "--diff-filter=ACMR", base])?;
let untracked = git(&["ls-files", "--others", "--exclude-standard"])?;
Ok(changed.lines().chain(untracked.lines()).filter(|path| path.ends_with(".rs")).collect::<Vec<_>>().join("\n"))
}

fn print_movement(base: &Path, head: &Path) {
let read = |p: &Path| std::fs::read_to_string(p).map(|t| source_hygiene::ratchet::parse(&t)).unwrap_or_default(); // unwrap_or_default: a run that recorded nothing prints nothing; the judged run already failed loudly
let (base, head) = (read(base), read(head));
Expand Down
2 changes: 1 addition & 1 deletion core/source-hygiene/src/boundary_serialization.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
//! one is **the unjustified count may never rise** — every new site names its
//! boundary, every old one touched is a chance to ratchet down.

use super::{split_code_and_comment, SourceFile, SourceRule, Violation};
use super::{lexer::split_code_and_comment, SourceFile, SourceRule, Violation};

/// Same bar as the unwrap rule — a justification has to say something.
// context-budget-exempt: bounds the length of a COMMENT a human types, never a
Expand Down
Loading
Loading