Skip to content

SPO Integrity & Query Hardening — Modules 1-4#168

Open
AdaWorldAPI wants to merge 1 commit intomainfrom
claude/fix-spo-integrity-1vE5U
Open

SPO Integrity & Query Hardening — Modules 1-4#168
AdaWorldAPI wants to merge 1 commit intomainfrom
claude/fix-spo-integrity-1vE5U

Conversation

@AdaWorldAPI
Copy link
Owner

Module 1: stamp_word0() — hash fingerprint[1..] to avoid circular dependency where word[0] participates in its own MerkleRoot.

Module 2: verify_lineage() — O(depth) ancestry walk with stamp/merkle verification at each level.

Module 3: Epoch snapshots + changed_between() — DirtyBits-based change tracking via snapshot_epoch().

Module 4: SPO query rewrite —

  • Fix SparseContainer bitmap from [u64; 2] to [u64; BITMAP_WORDS] (CONTAINER_WORDS=256 needs 4 bitmap words, not 2)
  • Wire graph::spo into graph::mod (was never compiled)
  • Add TruthGate, SpoHit, SpoSemiring types
  • Add sxp2o/sxo2p/pxo2s scent-pruned projections
  • Fix label_fp density (~11%) for safe 3-axis packing
  • Fix tests for CAM content lookup and NARS reasoning

All 32 SPO tests + 3 bind_space integrity tests pass.

https://claude.ai/code/session_01GiNrnaSJnKqVdpcR4bTzs9

Module 1: stamp_word0() — hash fingerprint[1..] to avoid circular
dependency where word[0] participates in its own MerkleRoot.

Module 2: verify_lineage() — O(depth) ancestry walk with
stamp/merkle verification at each level.

Module 3: Epoch snapshots + changed_between() — DirtyBits-based
change tracking via snapshot_epoch().

Module 4: SPO query rewrite —
  - Fix SparseContainer bitmap from [u64; 2] to [u64; BITMAP_WORDS]
    (CONTAINER_WORDS=256 needs 4 bitmap words, not 2)
  - Wire graph::spo into graph::mod (was never compiled)
  - Add TruthGate, SpoHit, SpoSemiring types
  - Add sxp2o/sxo2p/pxo2s scent-pruned projections
  - Fix label_fp density (~11%) for safe 3-axis packing
  - Fix tests for CAM content lookup and NARS reasoning

All 32 SPO tests + 3 bind_space integrity tests pass.

https://claude.ai/code/session_01GiNrnaSJnKqVdpcR4bTzs9
Copy link

@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: 1ac2e55eec

ℹ️ 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 on lines +500 to +501
let (sx, sy, _) = rec_scent.axis_distances(&q_scent);
if sx.saturating_add(sy) > radius { continue; }

Choose a reason for hiding this comment

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

P1 Badge Scale scent gate before hard-filtering projection hits

The prefilter in sxp2o rejects candidates when sx + sy > radius, but sx/sy are nibble-histogram L1 distances while radius is later applied to Hamming ((dx + dy) / 2). These metrics are not on the same scale, so valid matches can be dropped before Hamming is computed (for example, many 1-bit nibble shifts can yield scent distance about 2× the Hamming delta). This makes projection queries return false negatives at tighter radii unless the scent threshold is calibrated separately from Hamming.

Useful? React with 👍 / 👎.

Comment on lines +1914 to +1916
let (_, root) = ClamPath::unpack_with_merkle(node.fingerprint[0]);
if root.is_zero() {
return false;

Choose a reason for hiding this comment

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

P2 Badge Verify stored Merkle roots against fingerprint content

verify_lineage only checks that unpacked roots are non-zero, so any non-zero fingerprint[0] is treated as valid lineage. That means unstamped or tampered nodes can pass integrity checks as long as the lower 40 bits are not zero, which defeats the purpose of lineage verification. The function should recompute the Merkle root from fingerprint[1..] at each node and compare it to the unpacked root.

Useful? React with 👍 / 👎.

AdaWorldAPI pushed a commit that referenced this pull request Mar 4, 2026
…egrity verification

Core fixes from PR #167/#168 review, rewritten from spec:

- sparse.rs: Widen bitmap [u64;2] → [u64;BITMAP_WORDS=4] to cover all 256 positions
- builder.rs: Fix invalid hex literal (0xCHA1_D15C → 0xC4A1_D15C), rewrite label_fp()
  to produce ~11% density sparse fingerprints via xorshift64 PRNG
- store.rs: Add TruthGate epistemic filter (OPEN/STRONG/CERTAIN), fix scent/Hamming
  scale mismatch with separate scent_radius parameter, add gated query methods
- geometry.rs: Add ContainerGeometry::Spo = 6 variant
- mod.rs: Wire pub mod spo (was missing — ~2000 lines of dead code)
- bind_space.rs: Add clam_merkle field to BindNode, stamp ClamPath + MerkleRoot
  on write_dn_node()/write_dn_path(), add verify_lineage() + Epoch snapshot

All 61 tests pass (24 SPO + 32 ClamPath + 5 bind_space integrity).

https://claude.ai/code/session_013JU8MRtxRRTtuc5217r6s5
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