Phase 0: Graph indexing and integrity #48
No reviewers
Labels
No labels
bug
cli
core
docs
event
experiment
figure
invariant
metrics
oracle
phase-0
phase-1
phase-2
phase-3
phase-4
phase-5
phase-6
provenance
revocation
tests
workload
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
erikinkinen/AES!48
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "0-graph-indexing-and-integrity"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes #6
Summary
This PR implements graph indexing and structural validation for the authority graph in Phase 0. It introduces adjacency and reverse indexes to enable efficient edge queries by subject and object, implements a formal invariant checker (
validate_graph()) that verifies structural consistency, and enforces deterministic iteration order across all graph stores.These additions complete the foundational infrastructure layer required for Phase 0, providing both runtime verification of graph invariants and query capabilities needed for future revocation semantics.
Scope
Included
EdgeStore::find_from()EdgeStore::find_to()EdgeStore::find_between()) for subject-object pairsvalidate_graph()function that checks invariants I2, I6, and I7Explicitly excluded
Design intent
The core design principle is structural integrity at the substrate level. The authority graph must be query-able, well-formed, and mechanically verifiable before any semantic behavior is introduced.
Adjacency and reverse indexes are maintained as internal implementation details of
EdgeStore. They are automatically updated during edge creation (create()andadd()) to ensure consistency without imposing coordination burden on callers. The index structure usesstd::mapwith stable numeric IDs as keys, guaranteeing deterministic iteration order (I10).The
validate_graph()function provides runtime verification of Phase 0 invariants:Validation is intentionally separate from normal graph operations. It is designed for testing, debugging, and post-replay verification, not as a runtime precondition. This separation keeps the critical path fast while ensuring that structural violations can be detected mechanically.
Deterministic iteration is enforced by using
std::mapordered by numeric ID across all stores. This satisfies invariant I10 and ensures that graph state is reproducible across runs, which is essential for replay validation and future event logging.Phase discipline
This PR belongs to Phase 0 and completes the foundational graph infrastructure layer.
All changes respect Phase 0 boundaries:
The introduced structures are forward-compatible with later phases:
validate_graph()can be extended with additional invariant checksThis PR does not modify existing Phase 0 invariants; it implements enforcement mechanisms for invariants already defined in
docs/model.md.Verification
Notes
For reviewers: Focus on the consistency guarantees between the global edge set and the adjacency/reverse indices. The index update logic in
edge_store.cppis critical and should be verified against the invariant definitions indocs/model.md.Known limitations: Currently, edge deletion is not implemented. When added, it must maintain index consistency by removing entries from both adjacency and reverse indices.
Follow-up work: Integration with event logging and replay validation will be addressed separately once the Phase 0 event system is designed.
validate_graph()invariant checker (#6)