Skip to content

feat(cognitive-shader-driver): add Σ-codebook-index column to FingerprintColumns (B2)#323

Merged
AdaWorldAPI merged 1 commit into
mainfrom
claude/b2-bindspace-sigma-column
Apr 30, 2026
Merged

feat(cognitive-shader-driver): add Σ-codebook-index column to FingerprintColumns (B2)#323
AdaWorldAPI merged 1 commit into
mainfrom
claude/b2-bindspace-sigma-column

Conversation

@AdaWorldAPI
Copy link
Copy Markdown
Owner

Summary

Track-B PR 2. BindSpace SoA carries μ-fingerprints today (content /
cycle (Vsa16kF32) / topic / angle) but no Σ. Per Pillar-6 (PR #289)
and Σ-Codebook viability (#288, R²=0.9949 at k=256), every row should
also carry a Σ codebook index alongside its μ.

This PR adds the index column only — one byte per row indexing into a
256-entry Σ codebook.

What changes

  • FingerprintColumns gains pub sigma: Box<[u8]>.
  • FingerprintColumns::zeros(len) allocates vec![0u8; len].into_boxed_slice()
    for sigma alongside the four existing planes.
  • New accessors:
    • pub fn sigma_at(&self, row: usize) -> u8
    • pub fn write_sigma(&mut self, row: usize, idx: u8)
  • BindSpace::byte_footprint includes the new sigma byte per row.

What does not change

  • The Σ codebook itself is not loaded here — that is a B3 concern.
    The codebook static + boot-load-from-disk lives in
    lance-graph-contract::sigma_propagation, contributed by B1.
    This PR only allocates the per-row index column so the SoA layout is
    ready when B3 wires the lookup in.
  • No public API on BindSpace / BindSpaceBuilder changes outside the
    new struct field. Existing callers continue to work unmodified.

Cost

1 byte / row on the existing ~6.2 KB row footprint = 0.02 % growth.

Verified at len = 1:

component bytes
content + topic + angle (3 × 2048) 6144
cycle (16 384 × f32) 65536
sigma (NEW, 1 × u8) 1
edge (u64) 8
qualia (18 × f32) 72
meta (u32) 4
temporal (u64) 8
expert (u16) 2
entity_type (u16) 2
total 71777 (was 71776)

The bindspace_footprint_adds_columns test asserts the new total
exactly so future drift trips a unit test.

Test plan

  • cargo test --manifest-path crates/cognitive-shader-driver/Cargo.toml --lib bindspace:: — 12 / 12 pass on this branch
  • sigma_column_zeros_initialised_to_index_zero — every row in a fresh FingerprintColumns::zeros(8) reads back 0
  • sigma_column_round_trips_per_row — distinct indices (0, 17, 200, 255) round-trip through write_sigma / sigma_at; overwrite replaces (does not OR/accumulate)
  • fingerprint_columns_sigma_len_matches_other_columns — implied row counts agree across all five planes for len ∈ {0, 1, 7, 64, 1000}
  • bindspace_zeros_shapes — extended to assert bs.fingerprints.sigma.len() == 10
  • bindspace_footprint_adds_columns — updated to 71777 (was 71776)

References

https://claude.ai/code/session_01PjcbSTd9zdVPkta9qwkVKo

…rintColumns (B2)

Track-B PR 2. BindSpace SoA carries μ-fingerprints today (content / cycle /
topic / angle) but no Σ. Per Pillar-6 (PR #289) and Σ-Codebook viability
(#288, R²=0.9949 at k=256), every row should also carry a Σ codebook index
alongside its μ.

This PR allocates the index column only — one byte per row indexing into
a 256-entry Σ codebook. The codebook itself is intentionally NOT loaded
here; that is a B3 concern (the codebook static + boot-load-from-disk
lives in `lance-graph-contract::sigma_propagation`, contributed by B1).

Changes
-------
- `FingerprintColumns` gains `pub sigma: Box<[u8]>`.
- `FingerprintColumns::zeros(len)` allocates `vec![0u8; len].into_boxed_slice()`
  for sigma alongside the existing four planes.
- New accessors `sigma_at(row) -> u8` and `write_sigma(row, idx)`.
- `BindSpace::byte_footprint` includes the new sigma byte per row.
- Existing `bindspace_zeros_shapes` / `bindspace_footprint_adds_columns`
  tests updated to cover sigma.

Tests added
-----------
- sigma_column_zeros_initialised_to_index_zero
- sigma_column_round_trips_per_row
- fingerprint_columns_sigma_len_matches_other_columns

Cost
----
1 byte / row on the existing ~6.2 KB row footprint = 0.02 % growth.
For len = 1: 71776 → 71777 bytes (verified by byte_footprint test).
@AdaWorldAPI AdaWorldAPI merged commit 5d77208 into main Apr 30, 2026
4 checks passed
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