Skip to content

Add fact lifecycle and relation indexing to TermIdentitySidecar - #116

Open
MesTTo wants to merge 3 commits into
trueagi-io:mainfrom
MesTTo:pr/mork-term-identity-facts
Open

Add fact lifecycle and relation indexing to TermIdentitySidecar#116
MesTTo wants to merge 3 commits into
trueagi-io:mainfrom
MesTTo:pr/mork-term-identity-facts

Conversation

@MesTTo

@MesTTo MesTTo commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Adds the thin fact layer over the term-identity interning base: FactId liveness via a weight tombstone (remove_fact tombstones, insert_fact revives the same FactId — the Lucene "live documents" model), live_fact_count, and facts_by_relation, an index from a relation head to its facts so a consumer (EGraph::from_equalities in #117, RelationAdjacency::from_sidecar in #121) scans one relation instead of the whole sidecar.

Scope is deliberately trimmed to what those consumers use. It excludes incremental maintenance (prefix staleness watermarks, delta application, PathMap re-sync scans): incremental maintenance is deferred, and PathMap's own shared_node_id COW identity is the right staleness primitive when it becomes needed, not a value-count watermark. The structural hash reuses Expr::hash (gxhash128 over the term's byte span) rather than a hand-rolled hash — the hash is only a collision-bucket filter (exact bytes decide identity), so the swap is identity-preserving; modeled in Alloy (github.com/MesTTo/alloy-mork: fac22).

MesTTo added 3 commits July 4, 2026 06:33
Adds the thin fact layer over the interning base: FactId liveness via a weight
tombstone (remove_fact tombstones, insert_fact revives the same FactId, the
Lucene "live documents" model), live_fact_count, and facts_by_relation, an index
from a relation head to its facts so a consumer (EGraph::from_equalities,
RelationAdjacency::from_sidecar) scans one relation instead of the whole sidecar.

Deliberately excludes incremental maintenance (prefix staleness watermarks,
delta application, PathMap re-sync scans): incremental maintenance is deferred
project-wide, and PathMap's own shared_node_id COW identity is the right
staleness primitive when it becomes needed, not a value-count watermark.
Replaces the hand-rolled 128-bit FNV in TermIdentitySidecar with the canonical
Expr::hash (gxhash128 over the term's byte span), the same structural hash the
rest of MORK already uses. The hash is only a collision-bucket filter -- exact
encoded bytes are compared before an identity is reused -- so the swap cannot
change which terms share a TermId, on ground or adversarial input. Modeled in
Alloy (fac22_term_identity in MesTTo/alloy-mork): HashSwapPreservesIdentity is
UNSAT. Addresses the maintainer's "reuse, don't reimplement" direction (no bespoke
hash where the crate has one). term_identity (4) and egraph (2) suites pass.
@MesTTo
MesTTo force-pushed the pr/mork-term-identity-facts branch from 0edb750 to de28f19 Compare July 4, 2026 07:58
@MesTTo MesTTo mentioned this pull request Jul 4, 2026
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