Entity / Laws
Proving laws are kept with Graph.validate
Whenever a transition writes a field read by a law, Graph.validate (foldkit-surface) asks for evidence proving the law holds. Only real checkers issue evidence values (Evidence.runtimeOnly is the explicit fallback for runtime-enforced checks):
| Evidence | Producer | Proves |
|---|---|---|
Enumerated | Laws.check (kept) | All finite cases or disjoint fields checked |
Bounded | Laws.check (bounds) | Numeric interval arithmetic proved safe |
Walked | Walk.run (foldkit-remote/testing) | Seeded message walks never broke the law |
Scenario | Scenario.run (foldkit-remote/testing) | Cross-backend case agreed on all runners |
RuntimeOnly | Evidence.runtimeOnly with why | Server writer or journal rejects violations |
Passing Laws.check evidence alongside Evidence.runtimeOnly clears law-unwitnessed findings in Graph.validate:
ts
import { Option } from 'effect'
import { Evidence, Graph, Module, Surface } from 'foldkit-surface'
import { Remote } from 'foldkit-remote'
const ShopApp = Surface.application({
Model: Schema.Struct({ remote: Remote.Model }),
Message: Remote.Message,
})
const ShopModule = Module.make(ShopApp, [
Remote.make({
model: ShopApp.model.remote,
entities: [Product],
mutations: [Publish, Release, Restock],
}),
])
const enumerated = multiReport.pairs.flatMap(pair => Option.toArray(pair.evidence))
Graph.validate(ShopModule, { evidence: enumerated }).map(finding => finding.message)
// ['write:Restock writes Product.stock, which Product.reservedWithinStock reads, and no evidence shows it keeps Product.reservedWithinStock']
const restocked = Evidence.runtimeOnly({
transition: 'write:Restock',
law: 'Product.reservedWithinStock',
why: 'the writer judges the row a restock leaves, and refuses one that leaves reserved over stock',
})
Graph.validate(ShopModule, { evidence: [...enumerated, restocked] }) // []Document laws work the same way: every durable Message writes to the shared slice, so Graph.validate expects walk, scenario, or runtimeOnly evidence for each durable Message against each document law:
ts
const BoardModule = Module.make(BoardApp, [Board])
Graph.validate(BoardModule).map(finding => finding.message)
// ['durable:CreatedTodo writes todos, which sync:capped-board.atMost100Todos reads, ...',
// 'durable:DuplicatedTodo writes todos, which sync:capped-board.atMost100Todos reads, ...']Use Graph.toMarkdown to export the full transition-to-law evidence table.