policy

package
v0.8.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 14, 2026 License: AGPL-3.0 Imports: 5 Imported by: 0

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

View Source
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

func Load() (*Policy, error)

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

func (p *Policy) Allow(target string) error

Allow returns nil if a write to target is permitted, or an error describing why it is blocked. A nil policy allows everything.

func (*Policy) Empty

func (p *Policy) Empty() bool

Empty reports whether the policy imposes no restrictions.

func (*Policy) Source

func (p *Policy) Source() string

Source returns the file the policy was loaded from ("" when none).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL