relations: shape queries (siblings, in/out-degree, undirected connected?) computed in SX + 18 tests
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 31s

Keep the Datalog ruleset minimal — every dl-query re-saturates, so shape
queries are SX BFS over erel, not extra closures. 110/110.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-06-07 12:56:35 +00:00
parent 1dacb0c8dd
commit 1c46fc2a69
7 changed files with 306 additions and 17 deletions

View File

@@ -18,7 +18,7 @@ links. Reuses `lib/datalog/` — does not reimplement the engine.
## Status (rolling)
`bash lib/relations/conformance.sh`**92/92** (Phases 14 complete)
`bash lib/relations/conformance.sh`**110/110** (Phases 14 complete + extensions)
## Ground rules
@@ -98,8 +98,27 @@ lib/relations/federation.sx
- [x] `lib/relations/tests/fed.sx` — federated reachability chains, trust gating,
revocation
## Extensions (post-roadmap)
- [x] **shape queries**`siblings` (nodes sharing a parent), `out-degree`/
`in-degree`, weakly-connected `connected?` (undirected reachability). Computed in
SX over the fast direct `erel` queries (BFS) — deliberately NOT added as Datalog
closures, to keep the per-query saturation cheap. `lib/relations/tests/shape.sx`.
## Progress log
- **Extension: shape queries** (110/110). Added `relations-siblings`,
`relations-out-degree`/`-in-degree`, `relations-connected?` (+ `relations/...`
current-db wrappers) and `shape.sx` (18 tests). Design note: an earlier attempt
added `sibling`/`uedge`/`ureach` as Datalog rules in the global `relations-rules`;
because every `dl-query` re-saturates the whole program, the extra recursive
undirected closure taxed EVERY query in EVERY suite and the full run blew past
10 min. Reverted the ruleset to the Phase-4 set and compute these in SX instead:
siblings = children-of(parents-of(node)) node; connected? = undirected BFS
expanding `relations-related` (children parents) per frontier with a visited
set. No new saturation cost; other suites unaffected. NB: the full 110-test
conformance takes several minutes under shared-machine contention (sibling loops)
— run with `timeout 1200` in the background; individual suites run in seconds.
- **Phase 4 — federation** (92/92). Re-derived acl's trust-gate shape (not
copied). engine.sx now derives the whole engine from an EFFECTIVE relation
`erel` rather than raw `rel`: `erel(S,D,K) :- rel(S,D,K)` (local, always) and