Skip to content

fix: Grammar/Markov hardening — slice unification, kernel wiring, parser tests, triangle distance#282

Merged
AdaWorldAPI merged 5 commits into
mainfrom
claude/grammar-fixes-r2-2026-04-29
Apr 29, 2026
Merged

fix: Grammar/Markov hardening — slice unification, kernel wiring, parser tests, triangle distance#282
AdaWorldAPI merged 5 commits into
mainfrom
claude/grammar-fixes-r2-2026-04-29

Conversation

@AdaWorldAPI
Copy link
Copy Markdown
Owner

Summary

Addresses all 3 CRITICAL + 6 HIGH findings from PR #279 review:

  • CRITICAL feat: bump arrow 57, datafusion 51, lance 2 #1 — Slice coordinate unification. markov_bundle.rs now imports from role_keys exclusively (was equal-partition 16384/5 = 3277; canonical is domain-specific 2000/2000/2000/1500/1500). Integration test integration_role_alignment.rs (THE test that should have blocked feat: DeepNSM grammar parser — Markov ±5 bundler, role keys, thinking styles #279) asserts alignment.
  • CRITICAL Module 6: #[track_caller] error macros for zero-cost location capture #2rotate_right removed. Post-bundle rotation was corrupting role-slice alignment. Deleted entirely; documented for future per-sentence pre-bundle permute.
  • CRITICAL Claude/review lance graph architecture i6 t kf #3 — WeightingKernel wired into coherence. New coherence_at_with_kernel(i, kernel) and total_coherence_with_kernel(kernel) honour the kernel's weight function. Uniform vs MexicanHat produce different scores (tested).
  • HIGH — Bundle normalization. Divide by sum(|weights|) after accumulation; cosine comparisons now kernel-invariant.
  • HIGH — Parser test coverage. 4 new tests for parse_with_coverage, coverage_failed, maybe_emit_ticket.
  • HIGH — NSM-prime ID set. Replaced r < 64 heuristic with explicit NSM_PRIME_IDS: HashSet<u16> (COCA-mapped).
  • HIGH — Real classification distance. compute_classification_distance now does normalized Hamming over qualia fingerprint (was permanent 0.0 stub).
  • HIGH — role_candidates parameterized. Explicit threshold + top_k parameters; deprecated shim for old signature.
  • HIGH — Cosine length assert. Panics on mismatch (wiring bug, not runtime input error).
  • MEDIUM — attempted_inference parameterized. No longer hardcoded to Deduction; deprecated legacy shim.
  • MEDIUM — Per-slot has_unfillable. Any-slot-None triggers CounterfactualSynthesis (was all-slots-None).

Stats

  • 10 files changed, +1,206 / -129 lines
  • 5 commits (4 workers + 1 meta reconciliation)
  • 289 contract tests + 66 deepnsm tests + 8 integration tests = 363 tests pass

Test plan

  • cargo check -p lance-graph-contract — green
  • cargo check --manifest-path crates/deepnsm/Cargo.toml --all-features — green
  • cargo test -p lance-graph-contract --lib — 289 passed
  • cargo test --manifest-path crates/deepnsm/Cargo.toml --lib — 66 passed
  • cargo test --manifest-path crates/deepnsm/Cargo.toml --test integration_role_alignment — 8 passed
  • Uniform vs MexicanHat coherence differ on non-trivial chain
  • Bundle L2 norm kernel-invariant after normalization
  • Subject slice alignment with role_keys canonical

https://claude.ai/code/session_01SbYsmmbPf9YQuYbHZN52Zh

claude added 5 commits April 29, 2026 05:47
…orkers

B-fix-slices changed slice() return type from (usize, usize) tuple to
RoleKeySlice struct. Subsequent workers (B-fix-triangle, B-fix-parser via
trajectory.rs tests, markov_bundle tests) used the old tuple destructure.
This commit threads the new struct fields (slice.start, slice.stop)
through all consumers.

Tests: 289 pass on lance-graph-contract; 66 pass on deepnsm; 8 pass on
the integration_role_alignment test (THE test that should have blocked
PR #279).
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: eeddfe97d2

ℹ️ 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 +160 to +161
let total_bits = (n * 64) as f32;
bits_diff as f32 / total_bits
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Use qualia bit-width for distance normalization

hamming_normalized divides by 64 * n, but qualia_to_binary_fingerprint only sets 18 meaningful bits per word. With the current expected_qualia_footprint shape (vec![0u64; 1]), the maximum achievable classification distance is 18/64 = 0.28125, so the ticket router’s novel-domain gate (classification_distance > 0.7 in ticket_emit.rs) becomes unreachable when this distance is used, preventing Extrapolation routing in genuinely novel cases.

Useful? React with 👍 / 👎.

Comment on lines +39 to +45
for id in [
// Pronouns + demonstratives (rank 0..30 in COCA)
2, 4, 8, 12, 14, 18, 22, 26, 28,
// Common NSM-mapped function words (rank 30..200)
35, 45, 58, 67, 73, 89, 102, 117, 134, 158, 192,
// Mental predicates
201, 233, 287, 309, 354,
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 Replace placeholder NSM prime ranks with full mapped set

This table is currently an approximation with only a small subset of IDs, even though parser routing treats it as the authoritative NSM-prime detector. Because parse_with_coverage now relies entirely on is_nsm_prime, missing primes are counted as non-primes, which systematically depresses primes_found and can over-trigger Abduction (primes_found < 4) for otherwise semantically rich inputs.

Useful? React with 👍 / 👎.

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