Skip to content

D3.2 client driver + starter YAML configs (Phase 3 scaffold complete, 118/118 tests)#239

Merged
AdaWorldAPI merged 2 commits into
mainfrom
claude/teleport-session-setup-wMZfb
Apr 21, 2026
Merged

D3.2 client driver + starter YAML configs (Phase 3 scaffold complete, 118/118 tests)#239
AdaWorldAPI merged 2 commits into
mainfrom
claude/teleport-session-setup-wMZfb

Conversation

@AdaWorldAPI
Copy link
Copy Markdown
Owner

Summary

D3.2 — Client-side driver + starter YAML configs. Curl-driven lab iteration against the shipped /v1/shader/sweep endpoint.

118/118 cognitive-shader-driver --features serve tests pass (+1 new spec-drift guard).

What lands

3 starter YAML configs + README

scripts/codec_sweep.sh

scripts/codec_sweep.sh configs/codec/00_pr220_baseline.yaml

Spec-drift guard test (wire.rs)

sweep_request_yaml_shape_deserializes_via_serde_json uses 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's rename_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

Phase Status
Phase 0 (Wire surface) ✅ Complete
Phase 1 scaffold (D1.1/D1.2/D1.3) ✅ Complete
D1.1b Cranelift wiring ⏳ Queued
Phase 2 scaffold (D2.1 + D2.3) ✅ Complete
D2.2 real decode-and-compare ⏳ Queued
Phase 3 scaffold (D3.1 handler + D3.2 this PR) Complete after merge
D3.1b real Lance append writer ⏳ Queued
Phase 4-5 ⏳ Queued

Rules honored

  • Rule D — adding a codec candidate = authoring a YAML file. Zero Rust changes. Zero rebuilds against the running shader-lab.
  • Rule F — single deserialisation at the handler's HTTP ingress; everything after is in-memory Rust (WireSweepRequestCodecParams → grid enumerate() → per-candidate WireSweepResult).
  • DoS ceiling (PR D3.1 batch sweep handler + clippy -D warnings clean (117/117 tests) #238 P1) — sweep handler rejects cardinality > 10,000 before 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

…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
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread scripts/codec_sweep.sh
Comment on lines +58 to +61
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)."
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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
@AdaWorldAPI AdaWorldAPI merged commit 80b4ec0 into main Apr 21, 2026
0 of 6 checks passed
AdaWorldAPI pushed a commit that referenced this pull request Apr 21, 2026
… 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
AdaWorldAPI pushed a commit that referenced this pull request Apr 21, 2026
… 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
AdaWorldAPI pushed a commit that referenced this pull request Apr 21, 2026
… 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants