Repository navigation
Conversation
Proposes logical rules: derivations with data-only emit templates whose facts are maintained inside the transaction that changes their support, ended (not erased) when support goes, and settled across chained rules in one stratified pass. Design only; no package changes. Amp-Thread-ID: https://ampcode.com/threads/T-01a1fc4c-95ef-732d-b7e6-65a5567128de Co-authored-by: Ben Jacobson <[email protected]>
Contributor
|
Documentation preview: https://triplex-docs-pr-116.bjacobso.workers.dev Commit: da4098a |
This branch has not been deployed
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.
Summary
Design proposal, for review: derived facts that retract themselves. Adds
docs/rfcs/derived-facts.mdonly. No package source, exports or Changeset; nothing to release.Triplex already covers most of a forward-chaining rules engine (facts as working memory, Datalog matching,
Derivationcandidates with provenance,reconcile, Materialization and the runner). Two pieces are missing, and hosts rebuild them inonDifftoday:insert-logical).Proposal: logical rules. A rule is an existing
Derivation.Definitionplus data-only emit templates. A runtime-wide layer, built likeCommitValidation.layer, runs a new derivation stage inside each application transaction, after the command's operations and beforeenforce, the journal entry and commit validators. It evaluates the affected rules against the in-progress state and writes whatever makes each owned attribute match the current output:Change.end, which keeps past valid time. Several supports give one fact.rebuild. Derived writes go throughenforceand validators, and a rejection rolls back the whole command.Out of scope: incremental matching (Rete or differential), salience, accumulators, and recursion through derived facts. The RFC asks for a commit-latency benchmark, beside
docs/datalog-performance.md, before the API is called supported. Section 9 lists open questions for the owner: naming, declaring ownership in the release, retroactive writes, where the maintainer lives, and cost budgets.Verification
oxfmt --check docs/rfcs/derived-facts.mdvitepress build docssucceeds. The Markdown fence check reports nothing for this file; its only failures are pre-existing ones in files that need built packages.pnpm check(not run; docs-only change)pnpm pack:check(not applicable; no package change)Architecture and release
ARCHITECTURE.mdis preserved (the design keeps everything in core, browser-safe).