D3.2 client driver + starter YAML configs (Phase 3 scaffold complete, 118/118 tests)#239
Conversation
…ft guard)
Final Phase 3 scaffold deliverable — curl-driven lab iteration against
the shipped /v1/shader/sweep endpoint.
Files:
configs/codec/README.md — inventory + DoS-ceiling note +
anti-#219 stub:true flag explanation
configs/codec/00_pr220_baseline.yaml
- PR #220 baseline regression: 6 subspaces × 256 centroids ×
identity rotation. Expected ICC ≈ 0.195 mean when D2.2 lands
real decode-and-compare.
configs/codec/10_wider_codebook.yaml
- PR #220 fix (a): centroids ∈ {256, 512, 1024}. Cardinality 3,
three distinct kernel signatures → warm cache after one pass.
configs/codec/12_hadamard_pre_rotation.yaml
- PR #220 fix (c): Hadamard × centroids cross-product (2×2 = 4).
Hadamard stays Tier-3 F32x16 per Rule C.
scripts/codec_sweep.sh
- yq YAML → JSON conversion
- POST to ${SHADER_LAB_URL}/v1/shader/sweep (default localhost:3001)
- jq-pretty request + response
- Stub honesty check: prints results[0].stub flag
→ verifies Phase 0 returns true (machine-checkable anti-#219)
- Requires: yq (mikefarah/yq ≥ v4), curl, jq
wire.rs +1 test: sweep_request_yaml_shape_deserializes_via_serde_json
- Inline JSON fixture mirroring the canonical YAML → JSON shape
- If this test breaks, the YAML configs are stale relative to
the Rust DTOs → scripts/codec_sweep.sh would fail at runtime
- Caught a real drift during development: PascalCase "Identity"
vs the DTO's rename_all="lowercase" (YAMLs correctly use
lowercase; test fixture had the typo)
Phase state:
Phase 0 ✅ complete
Phase 1 scaffold ✅ (D1.1 / D1.2 / D1.3 shipped; D1.1b queued)
Phase 2 scaffold ✅ (D2.1 harness + D2.3 handler; D2.2 queued)
Phase 3 scaffold ✅ — D3.1 batch handler + D3.2 client driver shipped
⏳ D3.1b real Lance append writer queued
DoS-ceiling note: sweep handler rejects grids with cardinality
> 10_000 before enumeration (PR #238 P1 fix). README documents the
ceiling so config authors can budget axis lengths.
Rule D honored: adding a new codec candidate = authoring a new
YAML file in configs/codec/. Zero Rust changes. Zero rebuilds.
Rules F honored at the client boundary: YAML → JSON → HTTP ingress.
Single deserialisation at the shader-lab's handler; everything
after is in-memory Rust (WireSweepRequest → CodecParams → grid
enumerate() → per-candidate WireSweepResult).
https://claude.ai/code/session_01SbYsmmbPf9YQuYbHZN52Zh
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f33e41dc04
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| echo "=== Stub honesty check ===" | ||
| stub_flag=$(echo "$response" | jq '.results[0].stub // "no results"') | ||
| echo "results[0].stub = $stub_flag" | ||
| echo "Expected: true (Phase 0 stub; D2.2 flips to false when real decode lands)." |
There was a problem hiding this comment.
Fail fast when stub honesty check does not hold
The script labels this section as a "Stub honesty check" but only echoes results[0].stub and never exits non-zero when the flag is false or missing. In Phase 0/2 runs, that means a non-stub (or malformed/error) response can look like a successful sweep in automation, undermining the anti-#219 safeguard the script is supposed to enforce. Add an explicit condition that aborts when results[0].stub is not true.
Useful? React with 👍 / 👎.
…ace merge + adhering-agent review checklist Four additions to .claude/CODING_PRACTICES.md — extends the existing EmbedAnything-patterns content with the SoA / object-does-the-work / substrate-level patterns that crystallized during the codec-sweep lab-infra session (PRs #225–#239). 1. SoA + Object-Does-The-Work Patterns (~100 lines) - Checklist for new DTOs / kernels / caches: sealed builders, stable signatures excluding drift, typed errors, Cache<H> generic-over-handle, stub flag for Phase-N-before-Phase-N+k, feature matrix tested, serialisation at edges, DoS ceilings at construction not enumeration - Five additional anti-patterns (6-10) surfaced by session corrections: stateless-shader vs stateful-engine misframed, hallucinating ndarray surface, feature-matrix blindness, epiphany-dumping orientation-as-discovery, raw struct literals bypassing builders - 10 shipped-pattern reference entries citing the actual files + test counts - 8 principles: object does the work, SoA over AoS, same- substrate-different-view, Stream/Resonance/Bus lifecycle, weights are seeds, scaffold-before-codegen, feature matrix is part of contract, pin your toolchain - Read order for new sessions 2. MANDATORY: `ndarray::simd::*` canonical import (new section) - Correct/wrong examples per Rule B + invariant I2 - AMX sibling module + tile primitives + simd_caps canonical paths - Polyfill hierarchy (Tier 1 AMX → Tier 4 AVX-2, no consumer scalar tier) - Reviewer trigger for `std::arch::*` or `ndarray::hpc::simd_avxNNN::*` reach 3. 3-Way BindSpace Mutation Scheme (new section) - Table: Xor (single-writer reversible) / Bundle (multi-writer saturating, E-SUBSTRATE-1 guaranteed associative in expectation) / Superposition (preserve ambiguity) - When to use each + explicit DON'T-INTERCHANGE rule - Iron rule citation (CLAUDE.md I-SUBSTRATE-MARKOV): Xor on multi-writer path breaks the Markov guarantee - Reviewer trigger for Xor on concurrent-writer paths 4. Adhering-Agent Review Checklist (new section) - Per-agent table mapping 18 specialist agents + 5 meta-agents to the specific checklist sections they own - Spawn pattern: hand PR scope to 1-2 matching agents with pointer to this doc; they walk their rubric and return PASS/FAIL with specific line citations - Agents READ this doc as their rubric, not their personality The doc is now both the author-side pattern guide AND the reviewer-side checklist. Specialist agents adhere to it; PRs are reviewed against it; new sessions load it as part of the mandatory pre-read set. Cross-ref: CLAUDE.md I-SUBSTRATE-MARKOV + I-NOISE-FLOOR-JIRAK; lab-vs-canonical-surface.md invariants I1-I11 + six rules A-F; cognitive-shader-architecture.md 7-layer stack + SoA column types; ripple-dto-contracts.md Stream/Resonance/Bus/ThoughtStruct lifecycle; this session's PRs #225-#239 shipping the SoA patterns in practice. https://claude.ai/code/session_01SbYsmmbPf9YQuYbHZN52Zh
… log Codex P2 review catch — the "Stub honesty check" block was echoing results[0].stub but always exiting 0, which undermined the anti-#219 safeguard the script claims to enforce. In Phase 0/2 runs, a non-stub or malformed response could look like a successful sweep in automation. Fix: after extracting the flag, case on it: - true → OK, echo success (Phase 0 stub honored) - false → FAIL exit 3, diagnostic message naming two possible causes (server running non-scaffold code OR wrong endpoint hit) - * → FAIL exit 3, points at the malformed response section The fix embodies the session's own principle ("the object does the work" / "stub flag is machine-checkable anti-#219"): a script that claims to check a flag but doesn't exit on failure is exactly the pattern we warn against in CODING_PRACTICES.md. The script now actually enforces what it documents. Cross-ref: PR #239 D3.2; EPIPHANIES.md 2026-04-20 "D0.2 stub flag is anti-#219 defense at the type level"; Codex P2 review 2026-04-21. https://claude.ai/code/session_01SbYsmmbPf9YQuYbHZN52Zh
… log Codex P2 review catch — the "Stub honesty check" block was echoing results[0].stub but always exiting 0, which undermined the anti-#219 safeguard the script claims to enforce. In Phase 0/2 runs, a non-stub or malformed response could look like a successful sweep in automation. Fix: after extracting the flag, case on it: - true → OK, echo success (Phase 0 stub honored) - false → FAIL exit 3, diagnostic message naming two possible causes (server running non-scaffold code OR wrong endpoint hit) - * → FAIL exit 3, points at the malformed response section The fix embodies the session's own principle ("the object does the work" / "stub flag is machine-checkable anti-#219"): a script that claims to check a flag but doesn't exit on failure is exactly the pattern we warn against in CODING_PRACTICES.md. The script now actually enforces what it documents. Cross-ref: PR #239 D3.2; EPIPHANIES.md 2026-04-20 "D0.2 stub flag is anti-#219 defense at the type level"; Codex P2 review 2026-04-21. https://claude.ai/code/session_01SbYsmmbPf9YQuYbHZN52Zh
… construction)
Applies the CODING_PRACTICES "builder is the only path" principle at
the type-system level. Ten key Wire DTOs now forbid raw struct-literal
construction from external crates:
WireCalibrateRequest WireSweepGrid
WireCalibrateResponse WireSweepRequest
WireCodecParams WireSweepResult
WireTensorView WireSweepResponse
WireTokenAgreement WireTokenAgreementResult
External callers (hypothetical downstream consumer crates) are now
forced through one of these paths to construct these types:
1. serde deserialize — JSON/YAML at REST/gRPC ingress (the intended
path per Rule F "serialise once at edges only")
2. TryFrom<WireCodecParams> for CodecParams — the shipped validated
conversion that runs precision-ladder + overfit guard
3. Future Builder::build() if one is added for a specific DTO
Internal construction (tests in wire.rs, grpc.rs conversion code,
serve.rs handler body) is UNAFFECTED — #[non_exhaustive] only
gates external-crate callers. Same-crate code retains struct-literal
access.
Why this matters in practice:
- `WireCodecParams { subspaces: 6, centroids: 0, ... }` compiled
today (skipping the ZeroDimension guard). External users can now
only get a CodecParams through the TryFrom conversion, which
runs the full validation chain at ingress.
- Future new fields on these DTOs won't break external callers
(they were already non-exhaustive-forbidden from raw struct
literals), so downstream rebuilds don't need coordinated updates.
- The "object does the work" principle now has teeth — the type
system enforces what the docs say.
Test Plan:
- cargo test --features lab --lib: 118/118 pass (unchanged)
- cargo clippy --features lab -- -D warnings: CLEAN
- No internal construction path broken (tests + grpc.rs +
serve.rs handler all inside the crate)
Also in this commit (cherry-picked from orphan branch state that was
not in the #239 merge):
- scripts/codec_sweep.sh: Codex P2 fix — stub honesty check now
exits 3 on missing/false flag instead of just logging. Script
actually enforces the anti-#219 safeguard it documents.
- CODING_PRACTICES.md: polyfill chain diagram + mandatory cargo
clippy + feature-matrix discipline section (~131 LOC).
Cross-ref: CODING_PRACTICES.md anti-pattern #10 "Raw struct literals
bypassing builders"; session epiphany "the object does the work";
Codex P2 review 2026-04-21 on the stub honesty script.
https://claude.ai/code/session_01SbYsmmbPf9YQuYbHZN52Zh
Summary
D3.2 — Client-side driver + starter YAML configs. Curl-driven lab iteration against the shipped
/v1/shader/sweependpoint.118/118
cognitive-shader-driver --features servetests pass (+1 new spec-drift guard).What lands
3 starter YAML configs + README
configs/codec/00_pr220_baseline.yaml— PR D1+D2+D5: CAM-PQ calibration pipeline — honest negative result #220 regression (6 subspaces × 256 centroids × identity)configs/codec/10_wider_codebook.yaml— PR D1+D2+D5: CAM-PQ calibration pipeline — honest negative result #220 fix (a): centroids ∈ {256, 512, 1024}configs/codec/12_hadamard_pre_rotation.yaml— PR D1+D2+D5: CAM-PQ calibration pipeline — honest negative result #220 fix (c): Hadamard × centroids cross-productconfigs/codec/README.md— inventory + DoS ceiling + anti-codec research: CAM-PQ solves argmax blind spot (ICC 0.9998 at 6 B/row) + production plan #219 stub-flag notescripts/codec_sweep.sh${SHADER_LAB_URL}/v1/shader/sweep(defaultlocalhost:3001)results[0].stub == true(Phase 0 machine-checkable anti-codec research: CAM-PQ solves argmax blind spot (ICC 0.9998 at 6 B/row) + production plan #219)Spec-drift guard test (
wire.rs)sweep_request_yaml_shape_deserializes_via_serde_jsonuses an inline JSON fixture mirroring the canonical YAML shape. If YAML configs drift from the DTOs, this test breaks before the script fails at runtime.Test caught a real issue during development: PascalCase
"Identity"in the fixture vs the DTO'srename_all = "lowercase". The checked-in YAMLs correctly use lowercase — the test fixture had the typo. Fixed = YAMLs validated against the real DTOs.Phase state after merge
Rules honored
shader-lab.WireSweepRequest→CodecParams→ gridenumerate()→ per-candidateWireSweepResult).enumerate(). README documents the ceiling so config authors can budget.Board hygiene (same commit)
STATUS_BOARD.md— D3.2 Queued → In PR.https://claude.ai/code/session_01SbYsmmbPf9YQuYbHZN52Zh