agentleFS
matrixoriginmatrixorigin/Memoria/skills/plugin-development/SKILL.md

plugin-development

Skill624 starsChanged 6 months agoApache-2.0View on GitHub

Create, test, sign, and publish Memoria governance plugins. Covers Rhai and gRPC runtimes, manifest format, lifecycle. Use when developing or managing plugins.

4 other projects use a version of this.

Adopted by

Most recently taken up by

The file

Files
SKILL.md

Quick Start

memoria plugin init --dir ./my-plugin --name my-governance \
  --capabilities governance.plan,governance.execute

Creates:

my-plugin/
├── manifest.json    # Plugin metadata, permissions, limits
└── policy.rhai      # Governance logic (Rhai script)

manifest.json

{
  "name": "memoria-my-governance",
  "version": "0.1.0",
  "api_version": "v1",
  "runtime": "rhai",
  "entry": { "rhai": { "script": "policy.rhai", "entrypoint": "memoria_plugin" } },
  "capabilities": ["governance.plan", "governance.execute"],
  "compatibility": { "memoria": ">=0.1.0" },
  "permissions": { "network": false, "filesystem": false, "env": [] },
  "limits": { "timeout_ms": 500, "max_memory_mb": 32, "max_output_bytes": 8192 },
  "integrity": { "sha256": "", "signature": "", "signer": "" },
  "metadata": { "display_name": "My Governance Plugin" }
}

Key fields:

  • runtime: rhai (sandboxed) or grpc (remote service)
  • capabilities: must include governance.plan and/or governance.execute
  • integrity: auto-filled by memoria plugin publish

policy.rhai

fn memoria_plugin(ctx) {
    if ctx["phase"] == "plan" {
        let review = decision("my-plugin:check", "Description", 0.8);
        review["evidence"] = [evidence("source", "What was found")];
        return #{
            requires_approval: false,
            actions: [review],
            estimated_impact: #{ "my.metric": 1.0 }
        };
    }
    if ctx["phase"] == "execute" {
        return #{ warnings: [], metrics: #{ "my.metric": 1.0 } };
    }
    return #{};
}

Built-in helpers: decision(id, reason, confidence), evidence(source, description)

Runtime Types

RuntimeSandboxingUse Case
rhaiIn-process, memory/time limitedSimple rules, no external deps
grpcOut-of-process, network callComplex logic, external services

Development Workflow

1. Local dev (no signature, no DB)

MEMORIA_GOVERNANCE_ENABLED=true \
MEMORIA_GOVERNANCE_PLUGIN_DIR=./my-plugin \
memoria serve

2. Contract testing

See memoria-service/tests/plugin_contract.rs — uses GovernancePluginContractHarness.

3. Sign and publish

memoria plugin dev-keygen --dir ./my-plugin
memoria plugin signer-add --signer my-team --public-key <base64-ed25519>
memoria plugin publish --package-dir ./my-plugin
memoria plugin review --key governance:my-governance:v1 --version 0.1.0 --status active
memoria plugin activate --domain governance --binding default \
  --plugin-key governance:my-governance:v1 --version 0.1.0

4. Production

MEMORIA_GOVERNANCE_ENABLED=true
MEMORIA_GOVERNANCE_PLUGIN_BINDING=default
MEMORIA_GOVERNANCE_PLUGIN_SUBJECT=system

Lifecycle

scaffold → local dev → sign → publish → review → activate → scheduler loads

CLI Reference

CommandDescription
memoria plugin init --dir <d> --name <n>Scaffold
memoria plugin dev-keygen --dir <d>Generate ed25519 keypair
memoria plugin publish --package-dir <d>Sign and publish
memoria plugin listList published
memoria plugin review --key <k> --version <v> --status <s>Review
memoria plugin activate --domain <d> --binding <b> --plugin-key <k> --version <v>Activate
memoria plugin rulesList binding rules
memoria plugin score --key <k> --version <v>Compatibility score
memoria plugin matrixCompatibility matrix
memoria plugin eventsAudit events

Code Reference

FilePurpose
plugin/manifest.rsPluginManifest, PluginPackage, signing
plugin/repository.rsPublish, review, score, binding CRUD
plugin/rhai_runtime.rsRhaiGovernanceStrategy
plugin/grpc_runtime.rsGrpcGovernanceStrategy
plugin/governance_hook.rsContract testing harness
plugin/templates/Rhai template

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.