feat!: add Tier 1 graph algorithms and honor temporal mode#85
Merged
Conversation
Adds `shortestPath`, `reachable`, `canReach`, `neighbors`, and `degree` as a lazily-built facade on Store. All traversal algorithms compile to a single recursive-CTE query that reuses the dialect's existing path-tracking primitives (`initializePath` / `extendPath` / `cycleCheck`), so SQLite and PostgreSQL share the same semantics as subgraph extraction and the recursive query builder. These cover the high-utility primitives identified in the graph-algorithms evaluation: recommendations, routing, access control, dependency analysis — without requiring in-memory graph libraries for small to medium fanout. Includes the `14-research-copilot.ts` showcase demonstrating all five algorithms alongside semantic search and ontology-expanded topic matching over a landmark-ML-papers corpus, plus full docs at `/graph-algorithms`.
ab7f4bc to
42308ac
Compare
All `store.algorithms.*` and `store.subgraph()` now accept `temporalMode` and `asOf` options, defaulting to `graph.defaults.temporalMode`. Both surfaces were previously hardcoded (algorithms filtered only `deleted_at IS NULL`; subgraph was effectively `"includeEnded"`), which left them inconsistent with `store.query()` and collection reads. Also consolidates the recursive-CTE helper previously duplicated across subgraph and the algorithms module into a single `src/store/recursive-cte.ts`, and unifies `AlgorithmCyclePolicy` with `RecursiveCyclePolicy` so both surfaces share one canonical cycle-policy union. BREAKING: `store.subgraph()` previously hardcoded soft-delete-only filtering. It now follows `graph.defaults.temporalMode` (typically `"current"`). Callers that relied on walking through validity-ended rows must pass `temporalMode: "includeEnded"` explicitly. Soft-delete handling is unchanged under the default `"current"` mode, so most callers see no difference. - `executeCanReach` self-path short-circuit removed: `canReach(a, a)` now flows through the CTE and returns `false` when `a` isn't visible under the resolved mode (matches `shortestPath(a, a)`). - `resolveTemporalOptions(ctx, options)` helper collapses the duplicated fallback + conditional-spread pattern at each call site. - New `TEMPORAL_ANCHORS` test utility shared by algorithms and subgraph temporal tests.
42308ac to
e4936ad
Compare
Merged
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.
store.algorithms.*withshortestPath,reachable,canReach,neighbors, anddegreeas a lazily-built facade onStore. All traversal algorithms compile to a single recursive-CTE query that shares the dialect's path-tracking primitives with.recursive()andstore.subgraph(), so SQLite and PostgreSQL have identical semantics.temporalMode/asOfthrough every algorithm and throughstore.subgraph(), defaulting tograph.defaults.temporalMode. Algorithms and subgraph previously used hardcoded filters (algorithms:deleted_at IS NULL; subgraph: effectively"includeEnded") that diverged fromstore.query()and the collection APIs.buildReachableCteintosrc/store/recursive-cte.ts(shared between algorithms and subgraph), aliasesAlgorithmCyclePolicytoRecursiveCyclePolicy, and adds aresolveTemporalOptionshelper to collapse duplicated fallback logic across call sites.store.subgraph()now followsgraph.defaults.temporalMode(typically"current") instead of hardcoded soft-delete-only filtering. Callers that relied on walking through validity-ended rows must passtemporalMode: "includeEnded"explicitly. Soft-delete handling under the default"current"mode is unchanged.executeCanReachself-path short-circuit socanReach(a, a)honors the temporal filter and matchesshortestPath(a, a)whenaisn't visible under the resolved mode.Docs
/graph-algorithmspage with Shared Options table, per-algorithm reference, and a Temporal Behavior section.schemas-stores.mdupdated for the new subgraph options and algorithm quick-reference.queries/temporal.mdcross-references the expanded surface.14-research-copilot.tsshowcase example demonstrating all five algorithms alongside semantic search and ontology-expanded topic matching.