feat(corpus): word-grain count walk — the grain payoff, pure CkLang, x2.72 #71

Manually merged
tvidal merged 6 commits from feat/071-feat-corpus-word-grain-count-walk-the-grain-pa into master 2026-03-30 14:57:08 +02:00
Owner

feat(corpus): word-grain count walk — the grain payoff, pure CkLang, x2.72

Along the way:

  • feat(turbofish §1b): the two-surface law — coercion letter form, bare-angle qualified trait calls; E0747 minted; debts #21/#25 closed, #33 split
  • docs: session handoff — ninth (turbofish/orchestrate) session; §1b two-surface slice LANDED (a11c1bd); --opt landed separately (a1b2281); E0747 + V4 minted; debts #21/#25 closed, #33 split (impls gated on the ScalarKind→LeafRepr collapse slice, co-owning #43); int→float RULED (explicit Convert over the fcvt leaf, ratified spellings recorded); live-parallel landing protocol + budget-honesty mandates recorded; two new debts (44-45)
  • test(garage): manual-only slow tier — the 5 s drag races leave the default suite
  • feat(corpus): primes v4 (recycled region, x1.19) + wheel_v1 (wheel-30, x4.68)
  • feat(scalar-repr): the ScalarKind→ValueRepr collapse + the ruled int→float law

Touches 127 files: Floor.ck, Prelude.ck, handoff.md, plan.md, scripts/test.sh, slice_turbofish.md and 121 more.

feat(corpus): word-grain count walk — the grain payoff, pure CkLang, x2.72 Along the way: - feat(turbofish §1b): the two-surface law — coercion letter form, bare-angle qualified trait calls; E0747 minted; debts #21/#25 closed, #33 split - docs: session handoff — ninth (turbofish/orchestrate) session; §1b two-surface slice LANDED (a11c1bd); --opt landed separately (a1b2281); E0747 + V4 minted; debts #21/#25 closed, #33 split (impls gated on the ScalarKind→LeafRepr collapse slice, co-owning #43); int→float RULED (explicit Convert over the fcvt leaf, ratified spellings recorded); live-parallel landing protocol + budget-honesty mandates recorded; two new debts (44-45) - test(garage): manual-only slow tier — the 5 s drag races leave the default suite - feat(corpus): primes v4 (recycled region, x1.19) + wheel_v1 (wheel-30, x4.68) - feat(scalar-repr): the ScalarKind→ValueRepr collapse + the ruled int→float law Touches 127 files: `Floor.ck`, `Prelude.ck`, `handoff.md`, `plan.md`, `scripts/test.sh`, `slice_turbofish.md` and 121 more.
tvidal approved these changes 2026-03-30 12:05:51 +02:00
tvidal left a comment

Reads well. One question on src/rust/crates/ck_driver/tests/primes_actor_garage_bitwise_v4_run.rs, nothing blocking.

Reads well. One question on `src/rust/crates/ck_driver/tests/primes_actor_garage_bitwise_v4_run.rs`, nothing blocking.
@ -0,0 +219,4 @@
}
/// The corpus app directory `<repo>/tests/corpus/<name>`.
fn corpus_app(name: &str) -> PathBuf {
Owner

corpus_app reads, decides and writes in one function. The deciding part is the piece I would want to test on its own. Worth splitting?

`corpus_app` reads, decides and writes in one function. The deciding part is the piece I would want to test on its own. Worth splitting?
Author
Owner

Split. The decision in corpus_app is a pure function now, with its own tests in src/rust/crates/ck_driver/tests/primes_actor_garage_bitwise_v4_run.rs.

Split. The decision in `corpus_app` is a pure function now, with its own tests in `src/rust/crates/ck_driver/tests/primes_actor_garage_bitwise_v4_run.rs`.
hkowalski approved these changes 2026-03-30 14:04:26 +02:00
hkowalski left a comment

Second read on src/rust/crates/ck_driver/tests/primes_actor_garage_bitwise_v4_run.rs. Nothing to add.

Second read on `src/rust/crates/ck_driver/tests/primes_actor_garage_bitwise_v4_run.rs`. Nothing to add.
primes_actor_garage_bitwise_v3: byte-for-byte _v2 except the count walk's
GRAIN — 7,812 load::<u64> words + SWAR popcount in CkLang over existing
leaves (band/ushr + overflow-free shift-adds) replace 499,999 per-candidate
bit probes. Zero compiler change, no new surface, no new floor leaf; the
compiler emits what is written, leaf for leaf (a real call per word), and
the win is entirely the source's grain choice.

Measured (same-core 5 s races, i9-14900KS, all passes 78,498-validated):
P-core 3,622 -> 9,848/9,904 (x2.72); E-core 2,002 -> 4,331 (x2.16).
Strike walk untouched: striking is the algorithm=base contract and its
same-word RMW chains are the measured P-core store-forward hazard.

The doctrine-shaped lesson (plan.md payoff record): the grain of a Region
walk is a SOURCE decision — the performance the "temporal projection /
register window" school buys with alias analysis and deferred stores,
CkLang buys by writing the word.

Debt #43 minted (handoff.md): Floor::load::<u32> is an unsupported Floor IR
form — only corpus-exercised widths lower; close as ONE generic width law
with a real consumer, never a per-width arm.

Gates: fmt 0 - clippy 0 warnings - architecture 15/15 -
primes_actor_garage_bitwise_v3_run green (5 s race, freestanding, 15,304
bytes) - runtime_registry green (v3 registered).
The §1b two-surface slice (slice_turbofish.md, plan_values_02 §1b as amended
2026-07-17), landed whole:

- The two surfaces, one mechanism: `x::<T>` stays SPECIALIZATION; `<value>::T`
  is COERCION, letter-led (`1::u8`, `x::f32`, `"hi"::String`,
  `[1,2,3]::List<Int,12>`). Value-primary receivers parse a CoercionTarget
  CST node; bare-ident receivers disambiguate at RESOLUTION (local/param head
  -> coercion; module/type head -> path access). Both surfaces route into the
  existing synth_* coercion readers — no second mechanism. E0747 rejects
  specialization-on-non-generic (`1::<u8>`).
- Bare-angle qualified trait calls: `Add<i64,i64,i64>::add(x,y)` parses via a
  bounded speculative scan (generic args iff the matching `>` is followed by
  `::`; comparisons proven unaffected, regression fixtures), resolves by
  skipping the trait head, and lowers into the ONE coherence dispatch (data-
  last MethodCall -> TY4 row -> FnId). receiver_subst binds the primary trait
  var to its OWN parameter slot (was: receiver-always — correct for method
  sugar, wrong for Op<A,B,R>; red-proven by hetero_qualified_dispatch.cktest).
- Debt #25 (i64→usize miscompile): fixed by the rework, verified by the
  two-surface roundtrip stone (exit 42).
- Debt #33 SPLIT: the call surface debt #33 named is landed and runs
  (qualified_trait_call stone, exit 42). The two heterogeneous Prelude impls
  stay un-landed: their `Convert<i8,f32>` body needs the fcvt_from_sint leaf,
  deferred (owner ruling 2026-07-18) to the slice that collapses ScalarKind
  into LeafRepr instead of widening the 4-bucket shim. The .ck law is
  authored and type-proven; int↔float via `::T` coercion stays refused (B1
  unreachable! untouched).
- Corpus migration: ~570 sites to the letter form (inventory + 4 missed
  inline-source sites + the register-law-era seam files: v2 (3-way merged)
  and v3 (d3e6d21, born mid-landing) re-migrated; all genuine `::<`
  specializations left; E0713 message strings left).
- Inherited-defect fixes: ListExpr::elements() counted the coercion target as
  a list element (off-by-one in the fit gate; two goldens were blessed against
  the buggy output — re-blessed from corrected output).
- Arch rule V4 (architecture/values.rs), red-proven: the two surfaces stay
  distinct at the CST-read boundary (no coercion reader names Turbofish, no
  specialization reader names CoercionTarget). Fixture matrix green.
- Caps held by extraction, never raised: expr.rs 853->652 (path cluster ->
  path.rs), lower/mod.rs -> qualified_call.rs, resolve_expr split; MAX_FILE_LOC
  822, MAX_FN_LOC 80 unchanged. Ratchet MAX_UNTRAPPED_DIAGNOSTICS 98 unchanged.

Gates at this commit (orchestrator-run on the merged tree): fmt 0 · clippy
-D warnings 0 · suite 154 full summaries, 153 green + the runtime-coverage
gate red SOLELY on two untracked in-progress corpus apps of the parallel
session (v4, wheel_v1 — not in this commit; the gate is green on this
commit's content) · 3 by-design soft-asserts. Turbofish Rust partition:
front-end crates +776/-276; driver tests +533/-13; corpus 70 files.
The `primes_actor_garage*` runtime gates each pay a ~5 s docker race, so the
default `cargo test` (and with it `./scripts/test.sh` and the pre-commit hook)
carried ~20 s of stopwatch per run that measures performance, not correctness.
Owner decision (2026-07-18): the races become the MANUAL-ONLY garage tier —

- every garage race is `#[ignore]`d with the decision recorded in the
  attribute reason and the file header;
- `./scripts/test.sh --garage` is the one path that runs the tier (exactly
  the ignored tests of the `primes_actor_garage*_run` integration tests);
- no automatic layer runs them: pre-commit/unit-test layers stay fast, and
  this is an explicit owner-accepted gate exception, not silent debt — the
  headers say so in as many words.

Front-end coverage of the garage apps is unaffected: the corpus harness still
parses/resolves them in the default suite; only the stopwatch runs move.

Default suite after: ~19 s wall, 0 failures. Garage tier: ~31 s, all races
green.
Two new drag-race siblings, both pure CkLang over existing leaves — zero
compiler change — each isolating one SOURCE decision, measured pinned
(P-core, docker cpuset 4, --opt speed, 5 s races, every pass 78,498-validated):

- primes_actor_garage_bitwise_v4 — ALLOCATION LIFETIME: the flag region is
  `Alloc::os_acquire`d once in `spawn` and recycled every pass by an in-place
  word-grain clear (7,812 store::<u64>s, four per iteration — zero per-pass
  kernel crossings); the strike computes its byte handle once per strike with
  a strength-reduced bit-space cursor (`b += f` replaces `j += 2f` + a
  per-strike shift); the count walk takes two words per iteration into two
  independent partial sums. 9,736 -> 11,585 passes/5 s vs v3 (x1.19). Two
  measured REJECTS recorded in the header: register-aggregated strikes
  (7,576 — a serial accumulator chain loses to independent byte RMWs the OOO
  core overlaps) and L1 segmentation (no gain — the walk is not L1-miss
  bound). Same `algorithm=base,faithful=yes,bits=1` line as its siblings.

- primes_actor_garage_wheel_v1 — ALGORITHM CLASS, honestly tagged
  `algorithm=wheel`: a wheel-30 sieve on the v4 chassis. Multiples of 2/3/5
  never exist in the bitmap (one bit per residue of {1,7,11,13,17,19,23,29}
  mod 30, one byte per 30 numbers, 33,334 live bytes as whole words), sieving
  starts at f = 7, and each prime's walk unrolls its 8 multiplier residue
  classes — 8 independent byte RMWs + 8 register adds per wheel turn, exact
  single-strike epilogues per class. `/30` and `%30` are a magic-constant
  multiply-shift; the wheel's shape is DATA (a 64-byte table region filled
  once in `spawn`), not compiler machinery. 54,152 passes/5 s vs v4's 11,571
  on the same binary (x4.68). Validator counts 2/3/5 back in; negative-tested
  (a wrong count formula crashes on pass one, no score posts).

Both gates follow the sibling pattern verbatim (crash-or-clean exit 0,
well-formed line, freestanding ELF checks), are registered in
`RUNTIME_TESTED`, and are born into the manual-only garage tier
(`#[ignore]`, `./scripts/test.sh --garage`; owner decision 2026-07-18).
v4's source is on the post-a11c1bd two-surface coercion form (`x::u64`
letter coercions, turbofish kept on genuine specializations).

Gates: fmt 0 / clippy -D warnings 0 / default suite green (~19 s) / garage
tier green (all six races, ~31 s).
KILL: the 4-bucket ScalarKind width enum (Int/Str/Variant/Byte) — deleted
whole (grep-proven; arch rule V5 bans the token, red-proven). The FS4
mem_types channel and the mock-state layout vocabulary now carry the general
ck_lower::layout::ValueRepr; every leaf width rides ValueRepr::Scalar(LeafRepr)
by the one generic (float,size) law — u16/u32 and the float widths no longer
drop to None (closes debt #43).

ADD: the owner-ruled int→float law (2026-07-18), verbatim: Floor.fcvt_from_sint
pure 1:1 leaf (root + live Floor.ck + Floor.ckh, target generic first; F2
closed set grown by the ruling); impl Convert<i8,f32>; the two delegating Add
impls re-authored over explicit Convert (closes debt #33 remainder;
cross-class ::T coercion stays refused — ck_types untouched).
Format::FromSint emit shape: target type is data off the FS4 channel, zero
per-type dispatch.

Also: debt #35 armed at ONE site (cross_module provider bodies via
method_impls_for_body — the minimal wiring the delegating impls need to run;
the five remaining sites stay debt #35 for the operators slice);
lower_provider_fn R4 cap held by extracting provider_variant_facts.

Stones: mem_width_roundtrip (u16+u32 region roundtrip, exit 42),
int_float_add (both delegating impls via qualified calls, exit 42) — both
registered in RUNTIME_TESTED. Arch: V5 banned-token rule, error-level,
red-proven.

Net Rust (production crates src): +113/−112 (net +1); .ck +55/−18 tracked
(+74 corpus). Gates: fmt 0, clippy 0, suite green except the 3 by-design
soft-asserts.
tvidal manually merged commit c2f50e349d into master 2026-03-30 14:57:08 +02:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
3 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
northgale/cklang-bootstrap!71
No description provided.