diff --git a/docs/superpowers/plans/2026-03-22-phase6-4a-retraction-edge-cases.md b/docs/superpowers/plans/2026-03-22-phase6-4a-retraction-edge-cases.md index 6e6e8be49a..01f899c588 100644 --- a/docs/superpowers/plans/2026-03-22-phase6-4a-retraction-edge-cases.md +++ b/docs/superpowers/plans/2026-03-22-phase6-4a-retraction-edge-cases.md @@ -2,7 +2,7 @@ > **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking. -**Goal:** Fix the retraction semantics bug in `filter_facts_for_query`, extract shared net-view logic as a single source of truth, add early fact-size validation for file-backed inserts, and cover both with integration tests. +**Goal:** Fix the retraction semantics bug in `filter_facts_for_query`, use the same net-view function in `get_current_value` and `filter_facts_for_query`, add early fact-size validation for file-backed inserts, and cover both with integration tests. **Architecture:** `net_asserted_facts` is added to `src/graph/storage.rs` and used by both `get_current_value` (fixing its ordering key from `tx_id` to `tx_count`) and `filter_facts_for_query` (fixing Step 2 to compute net view instead of naively filtering `asserted=true`). A `check_fact_sizes` guard is added to both write paths in `src/db.rs` before the WAL write. A `MAX_FACT_BYTES` constant is exported from `src/storage/packed_pages.rs`. @@ -284,8 +284,8 @@ Insert this function immediately after the closing `}` of `get_current_value` (l /// (NaN canonicalisation, ±0.0 disambiguation) consistently with the rest of /// the storage layer. /// -/// This is the single source of truth for retraction semantics, shared by -/// `get_current_value` and `filter_facts_for_query`. +/// `get_current_value` and `filter_facts_for_query` both use this function +/// to decide which facts survive retraction. pub(crate) fn net_asserted_facts(facts: Vec) -> Vec { use std::collections::HashMap; // key: (entity, attribute, canonical value bytes) → fact with highest tx_count diff --git a/docs/superpowers/plans/2026-03-31-phase-7-6-temporal-metadata.md b/docs/superpowers/plans/2026-03-31-phase-7-6-temporal-metadata.md index 6e07e39672..4bbc12af9f 100644 --- a/docs/superpowers/plans/2026-03-31-phase-7-6-temporal-metadata.md +++ b/docs/superpowers/plans/2026-03-31-phase-7-6-temporal-metadata.md @@ -2,7 +2,7 @@ > **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking. -**Goal:** Expose `:db/valid-from`, `:db/valid-to`, `:db/tx-count`, `:db/tx-id`, and `:db/valid-at` as first-class bindable values in Datalog `:where` patterns, unlocking the full four-class taxonomy of temporal queries. +**Goal:** Expose `:db/valid-from`, `:db/valid-to`, `:db/tx-count`, `:db/tx-id`, and `:db/valid-at` so Datalog `:where` patterns can bind these values. These bindings support four classes of temporal query. **Architecture:** A new `PseudoAttr` enum and `AttributeSpec` wrapper type replace `EdnValue` in `Pattern.attribute`. The parser detects `:db/*` keywords and constructs `AttributeSpec::Pseudo`; the matcher binds the corresponding fact-metadata field instead of matching a stored attribute name. `:db/valid-at` is query-level: the executor computes it once and passes it into the matcher via a new `from_slice_with_valid_at` constructor. diff --git a/docs/superpowers/plans/2026-05-01-phase8-completion.md b/docs/superpowers/plans/2026-05-01-phase8-completion.md index 5f8d8cdb9d..ec15641862 100644 --- a/docs/superpowers/plans/2026-05-01-phase8-completion.md +++ b/docs/superpowers/plans/2026-05-01-phase8-completion.md @@ -500,7 +500,7 @@ Replace the entire "Current Focus" block (from `## Current Focus` down to and in **Key Decisions Made**: - ✅ Datalog query language (simpler, better for temporal) -- ✅ Bi-temporal as first-class feature (not afterthought) +- ✅ Bi-temporal support for transaction time and valid time built in from the start - ✅ Keep single-file philosophy - ✅ Recursive rules with semi-naive evaluation - ✅ UTC-only timestamps (avoids chrono GHSA-wcg3-cvx6-7396) @@ -726,7 +726,7 @@ Query either axis independently or together: The unit of storage is `(entity, attribute, value, valid_from, valid_to, tx_id, tx_count, asserted)`. Entities are UUIDs. Attributes are keywords (`:person/name`). Values are strings, integers, floats, booleans, entity refs, keywords, or null. **Datalog queries** -Pattern matching with variable unification. Recursive rules use semi-naive fixed-point evaluation. Transitive closure and cycle-safe graph traversal are first-class. Stratified negation (`not` / `not-join`), scalar aggregation (`count`, `sum`, `min`, `max`, `count-distinct`, `sum-distinct`), arithmetic/predicate expression clauses (`[(< ?age 30)]`, `[(+ ?a ?b) ?c]`), disjunction (`or` / `or-join`), window functions (`sum/count/min/max/avg/rank/row-number :over (:partition-by … :order-by …)`), and user-defined functions (custom aggregates + predicates via `FunctionRegistry`) are all supported. +Pattern matching with variable unification. Recursive rules use semi-naive fixed-point evaluation and support transitive closure and cycle-safe graph traversal. Stratified negation (`not` / `not-join`), scalar aggregation (`count`, `sum`, `min`, `max`, `count-distinct`, `sum-distinct`), arithmetic/predicate expression clauses (`[(< ?age 30)]`, `[(+ ?a ?b) ?c]`), disjunction (`or` / `or-join`), window functions (`sum/count/min/max/avg/rank/row-number :over (:partition-by … :order-by …)`), and user-defined functions (custom aggregates + predicates via `FunctionRegistry`) are all supported. **Prepared statements** Parse and plan a query once; execute thousands of times with different bind values. `$slot` tokens accepted in entity, value, `:as-of`, and `:valid-at` positions. `BindValue` variants: `Entity(Uuid)`, `Val(Value)`, `TxCount(u64)`, `Timestamp(i64)`, `AnyValidTime`. diff --git a/docs/superpowers/plans/2026-05-03-clippy-lint-enforcement.md b/docs/superpowers/plans/2026-05-03-clippy-lint-enforcement.md index 54ff0a9df0..7bc9fee5e5 100644 --- a/docs/superpowers/plans/2026-05-03-clippy-lint-enforcement.md +++ b/docs/superpowers/plans/2026-05-03-clippy-lint-enforcement.md @@ -2,7 +2,7 @@ > **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking. -**Goal:** Add production-grade clippy lints to the entire workspace and fix all 336 existing violations so `cargo clippy --workspace` is error-free. +**Goal:** Enable the selected Clippy lints across the workspace and fix all 336 existing violations so `cargo clippy --workspace` is error-free. **Architecture:** Lint rules live in `[workspace.lints.clippy]` in the root `Cargo.toml`; every workspace member opts in via `[lints] workspace = true`. Test code is exempted via `#![cfg_attr(test, allow(...))]` at each crate root. Violations are fixed file-by-file using `?`/`try_from`/`.get()` patterns — no `unwrap`, no direct indexing, no lossy casts in production paths. diff --git a/docs/superpowers/plans/2026-05-13-datalog-tutorial.md b/docs/superpowers/plans/2026-05-13-datalog-tutorial.md index 2c01468d63..21f6645509 100644 --- a/docs/superpowers/plans/2026-05-13-datalog-tutorial.md +++ b/docs/superpowers/plans/2026-05-13-datalog-tutorial.md @@ -1297,9 +1297,9 @@ fn main() -> anyhow::Result<()> { } ``` -Note: the `or-join` + arithmetic approach above is a pedagogically honest demonstration of -how to work around Minigraf's lack of `if/else` in expressions. Simplify the aggregate UDF -example if the `or-join` makes it too complex for the tutorial page — an alternative is to +Note: this example uses `or-join` and arithmetic because Minigraf does not support +`if/else` in expressions. Simplify the aggregate UDF example if the `or-join` +makes it too complex for the tutorial page. An alternative is to pre-aggregate in Rust before transacting a `:order/signed-weight` fact. **Page structure:** diff --git a/docs/superpowers/specs/2026-03-22-phase6-4a-retraction-edge-cases-design.md b/docs/superpowers/specs/2026-03-22-phase6-4a-retraction-edge-cases-design.md index a3f8fd8e46..47ea9380e1 100644 --- a/docs/superpowers/specs/2026-03-22-phase6-4a-retraction-edge-cases-design.md +++ b/docs/superpowers/specs/2026-03-22-phase6-4a-retraction-edge-cases-design.md @@ -2,7 +2,7 @@ > **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking. -**Goal:** Fix a known correctness bug where retracted facts remain visible in Datalog query results, extract shared retraction logic as a single source of truth, and add tests for retraction semantics plus two additional edge cases (oversized facts, checkpoint-during-crash). +**Goal:** Fix a known correctness bug where retracted facts remain visible in Datalog query results, share one net-view function between `get_current_value` and `filter_facts_for_query`, and add tests for retraction semantics plus two additional edge cases (oversized facts, checkpoint-during-crash). **Architecture:** Three coherent pieces: (1) extract `net_asserted_facts` helper in the storage layer, (2) apply it in the query executor to fix Step 2 of `filter_facts_for_query`, (3) add integration tests covering retraction scenarios and edge cases. @@ -70,8 +70,8 @@ Extract a module-level `pub(crate)` function. Use `encode_value` from `crate::st /// Uses `encode_value` for the value key to ensure correct handling of /// floating-point edge cases (NaN canonicalisation, ±0.0 disambiguation). /// -/// This is the single source of truth for retraction semantics, used by both -/// `get_current_value` and `filter_facts_for_query`. +/// `get_current_value` and `filter_facts_for_query` both use this function +/// to decide which facts survive retraction. pub(crate) fn net_asserted_facts(facts: Vec) -> Vec { use std::collections::HashMap; use crate::storage::index::encode_value; diff --git a/docs/superpowers/specs/2026-03-25-phase-7-2b-arithmetic-predicates-design.md b/docs/superpowers/specs/2026-03-25-phase-7-2b-arithmetic-predicates-design.md index 25fbcefb4c..62b6dc5c95 100644 --- a/docs/superpowers/specs/2026-03-25-phase-7-2b-arithmetic-predicates-design.md +++ b/docs/superpowers/specs/2026-03-25-phase-7-2b-arithmetic-predicates-design.md @@ -8,9 +8,9 @@ ## Overview -Add arithmetic and predicate expression clauses to the Datalog `:where` clause, expressed as a unified `Expr` AST. This unlocks filter predicates (`[(< ?v 100)]`) and arithmetic bindings (`[(+ ?a ?b) ?result]`) without requiring application-side post-processing. +Add arithmetic and predicate expression clauses to the Datalog `:where` clause, expressed as a unified `Expr` AST. This lets queries filter rows with predicates (`[(< ?v 100)]`) and bind arithmetic results (`[(+ ?a ?b) ?result]`) without requiring application-side post-processing. -This is a load-bearing dependency for Phase 7.7 (temporal range queries via `:db/valid-from` / `:db/valid-to` pseudo-attributes) and Phase 7.9b (UDF predicates via `FunctionRegistry`). +These clauses are required for Phase 7.7 (temporal range queries via `:db/valid-from` / `:db/valid-to` pseudo-attributes) and Phase 7.9b (UDF predicates via `FunctionRegistry`). --- diff --git a/docs/superpowers/specs/2026-03-31-phase-7-6-temporal-metadata-design.md b/docs/superpowers/specs/2026-03-31-phase-7-6-temporal-metadata-design.md index b7039f88d6..91e371d774 100644 --- a/docs/superpowers/specs/2026-03-31-phase-7-6-temporal-metadata-design.md +++ b/docs/superpowers/specs/2026-03-31-phase-7-6-temporal-metadata-design.md @@ -8,7 +8,7 @@ ## Goal -Expose `valid_from`, `valid_to`, `tx_count`, `tx_id`, and the query-level `valid_at` point as first-class bindable values in Datalog `:where` clauses, unlocking the full four-class taxonomy of temporal queries. +Allow Datalog `:where` patterns to bind `valid_from`, `valid_to`, `tx_count`, `tx_id`, and the query's `valid_at` time. These bindings support four classes of temporal query. --- diff --git a/docs/superpowers/specs/2026-04-18-phase-8-1b-wasi-wasm-design.md b/docs/superpowers/specs/2026-04-18-phase-8-1b-wasi-wasm-design.md index 29ffd05bf5..7c8ee4ecdd 100644 --- a/docs/superpowers/specs/2026-04-18-phase-8-1b-wasi-wasm-design.md +++ b/docs/superpowers/specs/2026-04-18-phase-8-1b-wasi-wasm-design.md @@ -10,7 +10,7 @@ Compile Minigraf to `wasm32-wasip1` (WASI) so it runs inside server-side WASM runtimes — Wasmtime, Wasmer, Cloudflare Workers (WASI), and Fastly Compute — with a working in-memory REPL and no JavaScript bridge required. -This is orthogonal to Phase 8.1a (browser WASM with IndexedDB). Both share the `wasm32` architecture but use different targets and storage models: +Phase 8.1b is independent of Phase 8.1a (browser WASM with IndexedDB). Both use `wasm32`, but with different build targets and storage models: - **8.1a**: `wasm32-unknown-unknown` + `wasm-bindgen` → browser (IndexedDB) - **8.1b**: `wasm32-wasip1` → server-side WASM runtimes (in-memory; file-backed is out of scope) diff --git a/docs/superpowers/specs/2026-05-03-clippy-lints-design.md b/docs/superpowers/specs/2026-05-03-clippy-lints-design.md index 32ac90614d..fbadf01b52 100644 --- a/docs/superpowers/specs/2026-05-03-clippy-lints-design.md +++ b/docs/superpowers/specs/2026-05-03-clippy-lints-design.md @@ -2,7 +2,7 @@ **Date:** 2026-05-03 **Status:** Approved -**Scope:** Add production-grade clippy lints across the entire workspace and fix all existing violations +**Scope:** Enable the selected Clippy lints across the workspace and fix all existing violations --- diff --git a/docs/superpowers/specs/2026-05-13-datalog-tutorial-storyline-design.md b/docs/superpowers/specs/2026-05-13-datalog-tutorial-storyline-design.md index 86c689b421..cf4b572958 100644 --- a/docs/superpowers/specs/2026-05-13-datalog-tutorial-storyline-design.md +++ b/docs/superpowers/specs/2026-05-13-datalog-tutorial-storyline-design.md @@ -8,10 +8,9 @@ ## Overview -The Minigraf Datalog tutorial will be delivered as a series of wiki pages (GitHub Wiki), -driven by a single coherent real-world storyline. The storyline provides narrative scaffolding -so readers encounter each language feature in a context they already understand emotionally — -rather than in a contrived, isolated example. +The Minigraf Datalog tutorial will be delivered as a series of GitHub Wiki pages. +The pages follow one real-world storyline so readers meet each language feature +in a familiar context rather than in an isolated example. The domain is **e-commerce order management**, chosen because: - Nearly every reader has placed an online order diff --git a/docs/superpowers/specs/2026-05-19-perf-tuning-design.md b/docs/superpowers/specs/2026-05-19-perf-tuning-design.md index ea5520b9ea..07af03404b 100644 --- a/docs/superpowers/specs/2026-05-19-perf-tuning-design.md +++ b/docs/superpowers/specs/2026-05-19-perf-tuning-design.md @@ -28,8 +28,8 @@ sense in context. It is the reference complement to the tutorials — scannable, ### Section 1 — Cost Model -A table of every operation with its cost class and a short note. Purpose: give users a mental model -before they reach for any knob. +List each operation, its cost class, and a short note. The table helps readers +understand the cost of each operation before changing any tuning settings. | Operation | Cost | Notes | |---|---|---| diff --git a/docs/superpowers/specs/2026-08-24-wal-sync-mode-design.md b/docs/superpowers/specs/2026-08-24-wal-sync-mode-design.md index fccdad496b..cf1632d6b0 100644 --- a/docs/superpowers/specs/2026-08-24-wal-sync-mode-design.md +++ b/docs/superpowers/specs/2026-08-24-wal-sync-mode-design.md @@ -26,7 +26,7 @@ For high-write-volume callers (bulk ingestion, migration, seeding) issuing many Discovered while diagnosing event-loop blocking in `temporal-reasoning`'s git-history ingestion, which issues ~20-25 separate `execute()`/`checkpoint()` calls per commit. -Three independent improvements, increasing risk/leverage: +Three independent improvements, ordered from lower to higher risk and potential benefit: 1. `sync_all()` → `sync_data()` (fdatasync): skips the inode-metadata flush `sync_all()` also does. The WAL is pure-append, so no metadata beyond file length (which `sync_data()` still diff --git a/docs/superpowers/specs/2026-08-25-structured-error-codes-design.md b/docs/superpowers/specs/2026-08-25-structured-error-codes-design.md index 80bbc18cf4..6e2a62d312 100644 --- a/docs/superpowers/specs/2026-08-25-structured-error-codes-design.md +++ b/docs/superpowers/specs/2026-08-25-structured-error-codes-design.md @@ -323,7 +323,8 @@ uncoded. code+category, not text): the initial draft of this spec. Rejected on review — it left `ERROR_REFERENCE.md` sync as a code-list check only, with no mechanism catching drift between a call site's actual wording and its -documented "Error text." Moving the template into `REGISTRY` costs a small -hand-rolled runtime formatter (Rust's `format!` needs a compile-time -literal, which a data-driven template can't supply) but makes the registry -the true single source of truth the acceptance criteria call for. +documented "Error text." Moving the template into `REGISTRY` requires a small +custom formatter because Rust's `format!` needs a compile-time literal, which a +data-driven template cannot supply. In return, the registry defines each +error's code, category, and message template in one place, as the acceptance +criteria call for.