relations: Phase 1 schema + direct relations (rel facts, relate/unrelate, children/parents/related) + 22 tests
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 1m15s

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-06-07 11:42:32 +00:00
parent b821e6a79d
commit c67aefa211
8 changed files with 393 additions and 6 deletions

View File

@@ -18,7 +18,7 @@ links. Reuses `lib/datalog/` — does not reimplement the engine.
## Status (rolling)
`bash lib/relations/conformance.sh`**0/0** (not yet started)
`bash lib/relations/conformance.sh`**22/22** (Phase 1 complete)
## Ground rules
@@ -61,14 +61,14 @@ lib/relations/federation.sx
## Phase 1 — Schema + direct relations
- [ ] `lib/relations/schema.sx``rel(Src, Dst, Kind)` fact projection; a small
- [x] `lib/relations/schema.sx``rel(Src, Dst, Kind)` fact projection; a small
kind vocabulary (`parent`, `member`, `reply`, `variant`, `origin`, …) kept open
- [ ] `lib/relations/api.sx``(relations/relate src dst kind)` / `(unrelate …)`
- [x] `lib/relations/api.sx``(relations/relate src dst kind)` / `(unrelate …)`
over a live Datalog db (assert/retract); `(children-of db node kind)`,
`(parents-of db node kind)`, `(related db node kind)`
- [ ] `lib/relations/tests/direct.sx` — assert/retract, direct children/parents,
- [x] `lib/relations/tests/direct.sx` — assert/retract, direct children/parents,
kind filtering, unknown node → empty
- [ ] `lib/relations/conformance.sh` + scoreboard
- [x] `lib/relations/conformance.sh` + scoreboard
## Phase 2 — Reachability + cycles
@@ -100,7 +100,18 @@ lib/relations/federation.sx
## Progress log
(loop fills this in)
- **Phase 1 — schema + direct relations** (22/22). `schema.sx`: `rel(Src,Dst,Kind)`
fact constructor + accessors, open kind vocabulary (`parent member reply variant
origin link`), `relations-fact-valid?`/`relations-known-kind?`. `api.sx`: db built
via `dl-program-data facts relations-rules` (Phase 1 rules empty — direct queries
need none); `relations-children-of`/`-parents-of`/`-related` are plain `dl-query`
on the `rel` relation, plucking the bound column from substitution dicts;
current-db convenience layer (`relations/load!`, `relations/relate`,
`relations/unrelate`, `relations/children`/`parents`/`related`) over `dl-assert!`/
`dl-retract!`, mirroring lib/acl/api.sx. Tests cover direct children/parents, leaf/
root empties, kind isolation (parent query skips reply edge), retract, the api
layer, and schema/constructor shape. Note: query result order is nondeterministic
— tests use an order-insensitive `set=?`.
## Blockers