Files
zeekayandHanzo Dev 6c28746c8b semantic: the pipeline, the stores, and the decision layer
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]>
2026-09-05 23:14:11 -07:00

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)
}