Commit c2379c4
committed
feat(knowable-from): VART backend — Phase 3 reference impl
New optional feature `vart-backend` on `ogar-knowable-from`. Wires
`VartKnowableFromStore` — a `KnowableFromStore` impl backed by
AdaWorldAPI/vart (the versioned adaptive radix trie from the
SurrealKV ecosystem). Closes PR #25's "reference backend" promise.
# Mechanism
Each `register` call:
- locks the internal `Mutex<Tree<VariableSizeKey, u64>>`
- advances the trie's logical version: new_version = tree.version() + 1
- inserts (key=NULL-terminated class_identity, value=new_version,
version=new_version, ts=0) via `insert_or_replace` (upsert)
- returns new_version as the `knowable_from` stamp
Each `knowable_from(class_identity)`:
- locks the trie
- looks up at the latest version snapshot
- returns the value (Option<u64>)
# Why this matches the substrate's invariants
- NiblePath-shaped class_identity (e.g. `ogit-erp/sale.order`) is
prefix-radix-indexed natively — same primitive bardioc PR #18 /
lance-graph PR #470 describe for `inv.object_instance`.
- Immutable / copy-on-write — every register produces a new
logical version; readers at any prior version see the world-as-
of-that-version (audit-as-version per ADR-008 / ADR-013).
- Append-only by construction — VART doesn't expose mutate-in-place
semantics for past versions, so the registry log is forensically
queryable.
# Why the schema_ddl_hint is discarded here (v1)
VART's value type is `u64` to keep the trie homogeneous. The hint
parameter is accepted for trait conformance and explicitly noted as
discarded in v1 code comments. The `surrealql-hint` feature (PR #33)
renders DDL at the helper layer (`register_class_knowable_from`),
upstream of the backend — the loop closes at the wrapper, not the
backend. A future PR can wire a parallel `Tree<VariableSizeKey,
String>` for hints if a real consumer needs them.
# NULL-termination for prefix safety
Per VART's variable-length-key discipline (src/lib.rs L42-48 of the
upstream), class identities like `ogit-op/Work` and `ogit-op/WorkPackage`
would address overlapping subtrees without NULL termination. The
`make_key` helper appends \0 before constructing the `VariableSizeKey`.
# Tests (6 new; 10 prior → 16 total)
vart_empty_returns_none_and_version_zero
vart_register_returns_monotonic_versions
vart_knowable_from_returns_latest_for_key
vart_re_register_same_class_advances_version
vart_prefix_keys_do_not_collide [NULL-term receipt]
vart_same_name_different_prefixes_do_not_collide
[end-to-end through
register_class_knowable_from;
covers the PR #31 P2 case
against the real backend]
# Cargo deps + CI
- `vart` as `optional = true` behind `vart-backend` feature.
Pinned to AdaWorldAPI/vart fork (git dep); zero runtime
sub-deps per its Cargo.toml.
- CI: `cargo test -p ogar-knowable-from --features vart-backend`
added — same crate-scoped pattern as the other feature-gated
test steps.
# Verification
cargo test --workspace -> clean
cargo test -p ogar-knowable-from -> 10/10 (default)
cargo test -p ogar-knowable-from --features vart-backend -> 16/16
cargo test -p ogar-knowable-from --features surrealql-hint -> 10/10
cargo check --workspace --all-targets -> clean
PII abort-guard (word-boundary): CLEAN on all touched files.
# Position in sequencing
Per `docs/RDF-OWL-ALIGNMENT.md §10`:
Phase 1 (#30): RDF-OWL-ALIGNMENT doc MERGED
Phase 2a (#37): ogar-adapter-ttl MERGED
Phase 2b (#38): ogar-adapter-clickhouse-ddl MERGED
Phase 2c ogar-from-osm-pbf QUEUED (gates
on runtime
D-OSM-3)
Phase 3 (this): vart-backend on ogar-knowable-from OPENS
Phase 4+: ogar-pattern / ogar-actionable / ... QUEUED
https://claude.ai/code/session_01PBTGaPCSnnt6u3pjXpbLwY1 parent f8297bc commit c2379c4
3 files changed
Lines changed: 242 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
20 | 28 | | |
21 | 29 | | |
22 | 30 | | |
23 | 31 | | |
24 | 32 | | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
312 | 312 | | |
313 | 313 | | |
314 | 314 | | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
315 | 446 | | |
316 | 447 | | |
317 | 448 | | |
| |||
548 | 679 | | |
549 | 680 | | |
550 | 681 | | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
| 685 | + | |
| 686 | + | |
| 687 | + | |
| 688 | + | |
| 689 | + | |
| 690 | + | |
| 691 | + | |
| 692 | + | |
| 693 | + | |
| 694 | + | |
| 695 | + | |
| 696 | + | |
| 697 | + | |
| 698 | + | |
| 699 | + | |
| 700 | + | |
| 701 | + | |
| 702 | + | |
| 703 | + | |
| 704 | + | |
| 705 | + | |
| 706 | + | |
| 707 | + | |
| 708 | + | |
| 709 | + | |
| 710 | + | |
| 711 | + | |
| 712 | + | |
| 713 | + | |
| 714 | + | |
| 715 | + | |
| 716 | + | |
| 717 | + | |
| 718 | + | |
| 719 | + | |
| 720 | + | |
| 721 | + | |
| 722 | + | |
| 723 | + | |
| 724 | + | |
| 725 | + | |
| 726 | + | |
| 727 | + | |
| 728 | + | |
| 729 | + | |
| 730 | + | |
| 731 | + | |
| 732 | + | |
| 733 | + | |
| 734 | + | |
| 735 | + | |
| 736 | + | |
| 737 | + | |
| 738 | + | |
| 739 | + | |
| 740 | + | |
| 741 | + | |
| 742 | + | |
| 743 | + | |
| 744 | + | |
| 745 | + | |
| 746 | + | |
| 747 | + | |
| 748 | + | |
| 749 | + | |
| 750 | + | |
| 751 | + | |
| 752 | + | |
| 753 | + | |
| 754 | + | |
| 755 | + | |
| 756 | + | |
| 757 | + | |
| 758 | + | |
| 759 | + | |
| 760 | + | |
| 761 | + | |
| 762 | + | |
| 763 | + | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
551 | 773 | | |
0 commit comments