Skip to content

Fix SQLite bounded adjacency prefix parity - #301

Merged
forhappy merged 2 commits into
mainfrom
codex/fix-sqlite-adjacency-prefix
Aug 28, 2026
Merged

Fix SQLite bounded adjacency prefix parity#301
forhappy merged 2 commits into
mainfrom
codex/fix-sqlite-adjacency-prefix

Conversation

@forhappy

Copy link
Copy Markdown
Contributor

Summary

  • Order directional SQLite adjacency entries by canonical edge ID.
  • Merge requested relationship-kind buckets before applying query bounds, matching the graph.json engine.
  • Add an explicit adjacency capability marker so older endpoint-ordered sidecars fail with a rebuild instruction instead of silently returning a different truncated subset.
  • Filter pinned discovery adjacency by relationship kind before truncation.

Motivation

On the Django repository, SimpleTestCase::assertRaisesMessage has 2,312 callers. With max-edges 500 and max-nodes 500, graph.json and SQLite both reported truncation but returned different edge subsets because SQLite bounded each endpoint-ordered index scan before the global edge-ID merge.

This change makes bounded selection backend-neutral and fails closed for sidecars that cannot provide those semantics.

Verification

Against the final compass-v0.3.22 base:

  • cargo fmt --all -- --check
  • cargo test -p compass-query --test store_engine truncated_callers_use_the_same_edge_id_prefix_for_store_and_json --locked -- --exact
  • cargo test -p compass-graph --lib snapshot_without_edge_ordered_adjacency_requires_rebuild_for_directional_reads --locked
  • cargo clippy -p compass-graph -p compass-query --all-targets --all-features --locked -- -D warnings

Additional qualification with the same source patch before the final rebase:

  • cargo test -p compass-query --test store_engine --locked: 27 passed
  • cargo test -p compass-graph --test store_snapshot --locked: 21 passed
  • cargo clippy --workspace --lib --bins --locked -- -D warnings
  • cargo test --workspace --lib --bins --locked
  • sh scripts/check_product_boundary.sh
  • ./scripts/qualify_code_graph_v1.sh --fixtures-only, including scale ceilings and 57-language deterministic qualification

Real-repository verification used Django commit c9eb16a87e60c305fb3651459639f647cce498db: 76,570 nodes and 192,081 edges. The formerly divergent bounded callers query produced byte-identical 500-edge responses from both engines with SHA-256 a11a5acbffb1e0c04a25f92d2e6bfdc73c660855f39d51efe1aa1edf730518df. SQLite completed in 11.13 seconds at about 127 MiB peak RSS; cold JSON completed in 102.09 seconds at about 1.20 GiB peak RSS.

The existing macOS large unwind-table linker warning was observed; it did not affect the checks.

Compatibility and documentation

The canonical graph.json contract is unchanged. New sidecars carry the edge-ID-ordered adjacency capability. Existing sidecars remain usable for status, validation, backup, export, and recovery, but directional store queries require rebuilding with:

compass update --force --store sqlite
compass store validate compass-out --format json

MIGRATION.md, COMPATIBILITY.md, the store operations guide, the query-engine implementation guide, and CHANGELOG.md document the behavior.

Checklist

  • The change is focused and excludes unrelated formatting or generated files
  • Tests cover changed behavior, or this pull request changes documentation only
  • User-facing commands, flags, limits, and examples are documented
  • Compatibility or migration effects are described
  • No credentials, private source code, or sensitive report details are included
  • I agree to license my contribution under MIT OR Apache-2.0
  • I followed the Compass code of conduct

@forhappy

Copy link
Copy Markdown
Contributor Author

CI follow-up: dependency-policy failed because crates.io yanked chacha20 0.10.1 after the existing lockfiles were published. Commit 9939af8 updates only the main and fuzz lock entries to non-yanked 0.10.2. Both cargo-deny policy invocations now report advisories, bans, licenses, and sources OK; cargo check --workspace --locked also passes.

@forhappy
forhappy merged commit 4f166e5 into main Aug 28, 2026
14 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.

1 participant