Documentation
¶
Overview ¶
Package policy enforces local-first guardrails on operations that change a database. An optional policy file lets an operator (or an org that ships one alongside a project) make targets read-only — a global kill switch, or per-target protection — without any server or account system. Every mutating entry point asks Allow() before proceeding; a blocked attempt is an error.
Index ¶
Constants ¶
const DefaultFile = "litescope.policy.yaml"
DefaultFile is the conventional per-project policy filename.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Policy ¶
type Policy struct {
// ReadOnly blocks every mutating operation, everywhere.
ReadOnly bool `yaml:"read_only"`
// Protected lists substrings of a target (database path or fleet name);
// writes to a target containing any of them are blocked.
Protected []string `yaml:"protected"`
// contains filtered or unexported fields
}
Policy is the parsed guardrail configuration.
func Load ¶
Load resolves a policy from, in order: $LITESCOPE_POLICY, ./litescope.policy.yaml, ~/.litescope/policy.yaml. It returns an empty (allow-all) policy when none exists — a missing file is not an error.
func (*Policy) Allow ¶
Allow returns nil if a write to target is permitted, or an error describing why it is blocked. A nil policy allows everything.