Documentation
¶
Overview ¶
Package policy is the deny-by-default access engine. It decides whether a client may call a tool and filters the catalog a client may see.
Rules are explicit allow lists per client. A bare entry ("github__create_issue") allows exactly that tool. A wildcard ("github__*") allows the tools of that downstream, but only those observed at the last explicit Sync: a tool that appears at runtime is denied until a re-sync admits it, so a downstream cannot widen a client's access by exposing a new tool (design §6.5, ADR-0009).
The engine satisfies domain.Decider and domain.CatalogFilter and is safe for concurrent use: rules are immutable after New, and the synced wildcard expansion is guarded by a read-write mutex.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
Engine evaluates access decisions and catalog filtering. Its rule set is hot-reloadable: New builds it, Reload atomically swaps it, and every read takes the read lock, so a SIGHUP reload never drops a live evaluation (design §5).
func New ¶
New builds an engine from compiled rules. defaultAllow makes every call allowed (used when the configured default is "allow"); otherwise the engine is deny-by-default and only explicit allows pass. Input is assumed already validated by the config layer.
func (*Engine) Decide ¶
Decide reports whether the client may call the tool. It reads the rule set under the read lock so a concurrent Reload swap is observed atomically.
func (*Engine) Filter ¶
Filter returns the subset of the catalog the client is permitted to see. Filtering is security-load-bearing: a tool the client may not call is omitted entirely, including its schema and description (design §8).
func (*Engine) Reload ¶
Reload atomically swaps the engine's default and rule set, for a SIGHUP/file- watch config reload (design §5). It clears the wildcard pins computed for the old rules, so a wildcard admits nothing until the caller re-Syncs against the current catalog — a fail-closed transient (deny during reload), never an over-permit. It is safe to call concurrently with Decide and Filter.
func (*Engine) Sync ¶
Sync pins each client's wildcards to the tools present in the catalog. After Sync, a wildcard admits exactly the matching tools observed here; tools that appear later are denied until the next Sync. It holds the write lock across the computation so it reads a consistent rule set even if a Reload runs concurrently.