Skip to main content

RulesAction

Enum RulesAction 

Source
pub enum RulesAction {
    Add {
        id: String,
        kind: String,
        matcher: String,
        severity: String,
        reason: String,
        namespace: String,
        disabled: bool,
        sign: bool,
    },
    List,
    Check {
        kind: String,
        payload: String,
        agent_id: Option<String>,
    },
    Enable {
        id: String,
        sign: bool,
    },
    Disable {
        id: String,
        sign: bool,
    },
    Remove {
        id: String,
        sign: bool,
    },
    Keygen {
        out: Option<PathBuf>,
        force: bool,
    },
    SignSeed {
        key: Option<PathBuf>,
        db: Option<PathBuf>,
    },
}

Variants§

§

Add

Add a new agent-action rule. Requires operator keypair on disk; signs the canonical row encoding before persisting.

Fields

§id: String

Rule id (e.g. R005, tmp-noisy-build). Must be unique.

§kind: String

Action kind: bash / filesystem_write / network_request / process_spawn / custom.

§matcher: String

Matcher JSON. Shape depends on --kind. See docs/governance/agent-action-rules.md.

§severity: String

Severity: refuse / warn / log.

§reason: String

Human-readable reason surfaced to the agent on a match.

§namespace: String

Optional namespace scope. Defaults to _global.

§disabled: bool

Land the rule with enabled = 0 (operator activates later via ai-memory rules enable <id> --sign).

§sign: bool

Sign the rule with the operator keypair on disk. Required for non-dry-run inserts; without --sign the CLI refuses.

§

List

List every rule (enabled + disabled). Read-only, no key required.

§

Check

Evaluate a proposed action against the live rule set without committing it. Read-only. The output is the same JSON [Decision] shape the MCP / HTTP path returns.

Fields

§kind: String

Action kind: same vocabulary as add --kind.

§payload: String

Action payload JSON. For Bash: {"command":"ls"}. For FilesystemWrite: {"path":"/tmp/x"}. Etc.

§agent_id: Option<String>

Optional agent id; defaults to the resolved NHI id for audit-row provenance.

§

Enable

Activate a rule (flip enabled = 1). Requires --sign.

Fields

§id: String

Rule id.

§sign: bool

Sign the activation with the operator key.

§

Disable

Deactivate a rule (flip enabled = 0). Requires --sign.

Fields

§id: String

Rule id.

§sign: bool

Sign the deactivation with the operator key.

§

Remove

Remove a rule from the table. Requires --sign.

Fields

§id: String

Rule id.

§sign: bool

Sign the removal with the operator key.

§

Keygen

v0.7.0 L1-6 — generate a fresh Ed25519 operator keypair and write the private 32-byte seed to --out (mode 0600 on Unix) plus a base64-encoded public key sibling at <out>.pub (mode 0644). Default --out is ~/.config/ai-memory/operator.key.

Refuses to overwrite an existing file unless --force is passed; even with --force a stderr warning is emitted (an existing operator key is the keystone of the signature verify chain — a silent overwrite would invalidate every prior signed rule).

The 32-byte seed never appears in stdout, stderr, or any memory the agent emits. Only the fingerprint sha256(public_key)[:16] is logged.

Fields

§out: Option<PathBuf>

Output path for the 32-byte private seed. The base64 public key sibling is written to <out>.pub.

§force: bool

Overwrite an existing private/public key pair. Emits a stderr warning even when set. Default: refuse to overwrite.

§

SignSeed

v0.7.0 L1-6 — sign every seeded rule (R001..R004 today) with the operator key. Sets signature = ed25519(canonical_payload) and attest_level = 'operator_signed'. enabled stays at 0 — the operator audits and activates manually after this runs.

The canonical payload includes enabled, so a direct UPDATE governance_rules SET enabled = 1 after signing would fail signature verification at load time — that is the bypass-prevention property.

Fields

§key: Option<PathBuf>

Path to the operator private seed (32 bytes) — same shape rules keygen --out writes. Defaults to ~/.config/ai-memory/operator.key.

§db: Option<PathBuf>

Override the DB path (useful for smoke tests against a scratch sqlite file). Defaults to the same --db the rest of the rules verbs use (the top-level ai-memory --db flag).

Trait Implementations§

Source§

impl FromArgMatches for RulesAction

Source§

fn from_arg_matches(__clap_arg_matches: &ArgMatches) -> Result<Self, Error>

Instantiate Self from ArgMatches, parsing the arguments as needed. Read more
Source§

fn from_arg_matches_mut( __clap_arg_matches: &mut ArgMatches, ) -> Result<Self, Error>

Instantiate Self from ArgMatches, parsing the arguments as needed. Read more
Source§

fn update_from_arg_matches( &mut self, __clap_arg_matches: &ArgMatches, ) -> Result<(), Error>

Assign values from ArgMatches to self.
Source§

fn update_from_arg_matches_mut<'b>( &mut self, __clap_arg_matches: &mut ArgMatches, ) -> Result<(), Error>

Assign values from ArgMatches to self.
Source§

impl Subcommand for RulesAction

Source§

fn augment_subcommands<'b>(__clap_app: Command) -> Command

Append to Command so it can instantiate Self via FromArgMatches::from_arg_matches_mut Read more
Source§

fn augment_subcommands_for_update<'b>(__clap_app: Command) -> Command

Append to Command so it can instantiate self via FromArgMatches::update_from_arg_matches_mut Read more
Source§

fn has_subcommand(__clap_name: &str) -> bool

Test whether Self can parse a specific subcommand

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more