mirror of
https://github.com/hanzoai/semantic.git
synced 2026-10-30 15:04:19 +00:00
A native Go port of semantica. This first commit is the shape rather than the implementation: the values that move between stages, one interface per stage, and the three stores as three interfaces because they answer three different questions. The decision layer is the reason the graph exists, so it is a package of its own rather than a corner of the graph code, and provenance keeps the PROV-O vocabulary verbatim so the record joins other PROV data untranslated. Co-authored-by: Hanzo Dev <[email protected]>
37 lines
1.1 KiB
Go
37 lines
1.1 KiB
Go
// Package decision is the layer the graph exists for: what an agent knew,
|
|
// what it chose, under which rule, and what followed. It is named for the
|
|
// act rather than the data because the data is already the graph.
|
|
package decision
|
|
|
|
import (
|
|
"context"
|
|
"time"
|
|
)
|
|
|
|
// Record is one decision an agent made and the evidence it stood on.
|
|
type Record struct {
|
|
ID string
|
|
Agent string
|
|
Choice string
|
|
Because []string // Triple or Entity ids that supported the choice
|
|
Rule string // the Policy that allowed it
|
|
At time.Time
|
|
}
|
|
|
|
// Policy says whether a choice is allowed. It answers before the act,
|
|
// so a refusal is a decision with a reason rather than an error.
|
|
type Policy interface {
|
|
Allow(ctx context.Context, agent, choice string) (bool, string)
|
|
}
|
|
|
|
// Recorder keeps decisions and can read them back by agent.
|
|
type Recorder interface {
|
|
Record(ctx context.Context, r Record) error
|
|
By(ctx context.Context, agent string) ([]Record, error)
|
|
}
|
|
|
|
// Cause walks the chain: which earlier decisions this one rests on.
|
|
type Cause interface {
|
|
Chain(ctx context.Context, id string) ([]Record, error)
|
|
}
|