Skip to content

pilot-protocol/policy

Repository files navigation

policy

ci codecov License: AGPL-3.0

Policy plugin and expression language for the Pilot Protocol daemon. The repo ships two packages:

  • policy/ — a coreapi.Service adapter that loads per-network policy files and emits decisions on the event bus.
  • policy/policylang/ — the expr-lang/expr–backed evaluator. Used by the plugin and by cmd/pilotctl for policy linting.

Install

import (
    "github.com/pilot-protocol/policy"
    "github.com/pilot-protocol/policy/policylang"
)

Usage

p, err := policylang.Parse(jsonBytes)
if err != nil {
    return err
}
_ = p

rt.Register(policy.NewService(policy.Config{
    PolicyDir: "~/.pilot/policy",
}))

Layout

Root package (github.com/pilot-protocol/policy)

File What it does
runtime.go Loads/reloads policy files and watches the policy dir.
runner.go Per-network expression runner; binds events to the evaluator.
peer.go Per-peer rate/scope state used by directives.
aliases.go Re-exports policylang types for source compatibility.
service.go *Servicecoreapi.Service adapter. Build tag !no_policy.
service_disabled.go Stub when build tag no_policy is set.

Subpackage policylang/

File What it does
policy.go Policy struct and JSON unmarshal.
engine.go Compile and cache compiled programs; evaluate against env.
env.go Event/peer-context binding for the expr-lang VM.

Build tags

Tag Effect
no_policy Compiles a stub whose Start is a no-op.

License

AGPL-3.0-or-later. See LICENSE.

About

Pilot Protocol policy plugin + policy expression language (expr-lang/expr backed)

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages