Repository navigation
refactor(storage_engine): remove the dead materialization machinery - #368
Merged
Merged
Conversation
This comment has been minimized.
This comment has been minimized.
Persistent rules are stored definitions that every read evaluates from the snapshot's base facts. The materialization path built around the incremental engine was reachable only from tests and described a design that will not be built: auto_materialize recomputed every rule on each publish, CompiledRule.clauses was always empty, and no server path ever enabled the incremental engine. Removed: auto_materialize, set_auto_materialize, refresh_materializations, evaluate_rule, materialize_derived_relation, enable_incremental and the KnowledgeGraph's incremental engine, shadow_write, install_catalog's register_rule branch and compile_for_dd, DerivedRelationsManager/CompiledRule (src/derived_relations.rs), the IncrementalEngine derived-relations API, materialized_relations in snapshots, the change log and staged views, materialize_tests.rs, the storage error variants only those paths produced, and CommitError::Unknown, which only a failed shadow write produced. publish_snapshot now takes the single plain path with no DerivedRelationsManager lock. IncrementalEngine keeps its worker-thread skeleton (new, worker_loop, insert, delete and the base-relation reads) as the seed of the per-graph view maintainer. Comments in src/ now describe recompute-on-read.
jsam
force-pushed
the
fm/m9-v0-dead-code
branch
from
October 5, 2026 19:44
5dd5add to
be56809
Compare
jsam
marked this pull request as ready for review
October 5, 2026 20:36
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Intent
please leave this query batching functionliaty just refactor things so its clear and optimized for this ... auto materialize needs to be default mode of operation where rules get deployed as views and everything else is a query .. make the docs true with the correct systems design ... this is not accceptable state for production readiness (Context: implement #307 exactly as written.)
Issue #307, "Remove the dead materialization machinery (V0)", part of epic #305 (persistent rules become incrementally maintained views; everything else is a query):
Problem. auto_materialize, refresh_materializations, evaluate_rule, materialize_derived_relation, set_auto_materialize (src/storage_engine/mod.rs), DerivedRelationsManager/CompiledRule (src/derived_relations.rs, 797 lines; clauses always empty per src/storage_engine/catalog_change.rs), the materialized_relations field threaded through snapshots and the change log (src/storage_engine/snapshot.rs; src/storage_engine/precondition.rs), install_catalog's dd.register_rule branch (catalog_change.rs), shadow_write (program_commit.rs) and materialize_tests.rs are reachable only from tests and describe a design that will not be built. They mislead readers (and the architecture doc) and add a lock around every snapshot publish when enabled.
Target. Delete all of the above and the IncrementalEngine derived-relations API (register_rule, set_materialized, notify_base_update, derived_relations()), keeping the worker-thread skeleton (IncrementalEngine::new/worker_loop/insert/delete in src/incremental.rs) as the seed of the later view maintainer. publish_snapshot takes the simple branch only. Docs in src/ rewritten to tell the truth (persistent rules are recomputed on read today).
Acceptance. grep -rn "materializ" src/ returns only comments explaining recompute-on-read; all tests pass; cargo clippy -D warnings clean; snapshot publish has no DerivedRelationsManager lock; binary size and test count reported in the PR.
What Changed
src/derived_relations.rs(DerivedRelationsManager/CompiledRule),materialize_tests.rs,auto_materialize/set_auto_materialize/refresh_materializations/evaluate_rule/materialize_derived_relationinKnowledgeGraph, thematerialized_relationsfield in snapshots and the change log, thedd.register_rulebranch ininstall_catalog, andshadow_writein program commit.publish_snapshotnow has a single path with noDerivedRelationsManagerlock, andapply_deltano longer takes a time argument or returns an error.IncrementalEngineto the worker-thread skeleton (new, the worker loop,insert,delete), dropping its derived-relations API and the tests for it. Also removed the now-unreachableStorageError::IncrementalEngineError/DDWorkerDisconnectedvariants,CommitError::Unknown, and thewrite_runhandler arm that mappedCommitError::Unknown.src/comments. They now say persistent rules are recomputed on read, and thatIncrementalEngineis an unused skeleton that the planned view maintainer will replace.Risk Assessment
✅ Low: The change deletes code that only tests could reach. publish_snapshot, WriteProgram::view, ChangeLog and apply_delta all reduce exactly to their previous materialized-set-empty branches, so server behaviour is unchanged. The docs fix round now matches the code, with no leftover references to the deleted machinery.
Testing
I built the release server and client and ran the server in a throwaway data directory. I drove six live scenarios over the CLI client and raw WebSocket: persistent-rule recompute-on-read (including recursion), conditional delete and rule drop, atomic program commit and rollback, standing-query deltas over a rule-derived relation, session rules, and restart persistence. All passed, with no panics in the server logs. The acceptance grep for
materializin src/ is empty, and the new targeted unit test passes. Transcripts are saved in the evidence directory. There is no UI surface, so no screenshots were taken.Evidence: Persistent rules recompute on read (insert/delete/recursion/session rule)
Evidence: Conditional delete and rule drop
Evidence: Atomic program commit and rollback over WebSocket
Evidence: Standing query deltas over a persistent rule
Evidence: Rules and facts survive a server restart
Numbers
Measured against the merge base
09d1d0cb, release profile, same machine:inputlayer-serverbinaryinputlayerCLI binary#[test]functions insrc/,tests/,benches/Removed tests exercised only the deleted paths: the incremental-engine mirror (
test_dd_*), the materialization pipeline, snapshot materialization, and theDerivedRelationsManager/ derived-API unit tests. Kept and re-pointed: the two SCC rule tests (now on a plain storage engine) and the residency test (its in-memory state is now a vector index instead of the incremental engine). Added:test_snapshot_evaluates_persistent_rules_on_read.cargo test --workspace --all-features: 4,343 passed, 0 failed, 0 ignored.cargo clippy --all-targets -- -D warnings: clean.Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
🔧 **Rebase** - 4 issues found → auto-fixed ✅
src/derived_relations.rs- merge conflict rebasing onto origin/mainsrc/incremental.rs- merge conflict rebasing onto origin/mainsrc/statement/mod.rs- merge conflict rebasing onto origin/mainsrc/storage_engine/mod.rs- merge conflict rebasing onto origin/main🔧 Fix applied.
✅ Re-checked - no issues remain.
🔧 **Review** - 1 issue found → auto-fixed ✅
docs/content/docs/internals/architecture.mdx:80- The user intent says to "make the docs true", but the architecture docs still describe code this change deletes. docs/content/docs/internals/architecture.mdx:80 lists theauto_materialize: boolfield. Line 95 describesmaterialized_relations. Lines 97-103 have section 2.4 on IncrementalEngine/DerivedRelationsManager,enable_incremental()andset_auto_materialize(). Line 579 has a file-table row forsrc/derived_relations.rs. Line 651 names "theshadow_writehook", which is now removed. The same stalederived_relations.rs # DerivedRelationsManagerentry also appears at docs/internals/README.md:67, docs/internals/coding-standards.md:395 and docs/content/docs/internals/coding-standards.mdx:395. Fix: rewrite section 2.4 to describe only the remaining IncrementalEngine worker skeleton (unused by the server; seed of the Epic: persistent rules are incrementally maintained views; everything else is a query (E0) #305 view maintainer). Drop the deleted fields and file rows. Reword line 651 so it says the commit path will need a new hook instead of pointing at the deleted shadow_write.🔧 Fix applied.
✅ Re-checked - no issues remain.
✅ **Test** - passed
✅ No issues found.
cargo build --release --bin inputlayer-server --bin inputlayer-clientStarted a release inputlayer-server on port 18571 with a throwaway --data-dir in /tmp and a bootstrap API key set by environment variablesinputlayer-client -k <key> s1.iql: recursive persistent rulereachable, then insert, delete, chained rule, session rule and.rule listinputlayer-client -k <key> s2.iql: conditional delete,.rule drop, then a reachable queryWebSocket client (node): multi-statement program with facts, rule and query; a failing program rolled back (.rule drop missing)WebSocket client (node):.subscribe adults ?adult(N)while a second connection inserts and deletes facts, checking the subscription deltasRestarted the server on the same data dir, then queried.rule list,?reachable,?adultand a new insertgrep -rn materializ src/(empty)cargo test --lib test_snapshot_evaluates_persistent_rules_on_read✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.