Documentation Index
Fetch the complete documentation index at: https://docs.manthan.systems/llms.txt
Use this file to discover all available pages before exploring further.
The governance package handles the full policy lifecycle - creating, compiling, signing, versioning, and validating policies.
Install
npm install @parmanasystems/governance
Key exports
| Export | Description |
|---|
createPolicy | Scaffold a new policy directory with a starter policy.json |
generateBundle | Compile and sign a policy into a content-addressed bundle |
upgradePolicy | Create the next version of a policy |
validatePolicy | Verify that all version bundles are valid |
compilePolicy | Run the 8-phase compiler against a policy directory |
definePolicy | Construct a PolicyDefinition object in code |
Creating a policy programmatically
import { createPolicy, generateBundle } from "@parmanasystems/governance";
// Scaffold the policy directory
const policyDir = createPolicy("loan-approval");
// Creates: policies/loan-approval/1.0.0/policy.json
// Edit policy.json to add your rules, then generate the bundle
const result = generateBundle(
"loan-approval",
"1.0.0",
policyDir,
{ privateKeyPath: "./trust/root.key" }
);
console.log(result.bundle_hash); // deterministic SHA-256 of policy content
Compiling a policy
import { compilePolicy } from "@parmanasystems/governance";
const result = compilePolicy("./policies/loan-approval/1.0.0");
if (!result.valid) {
console.error(result.errors);
// e.g. ["[POL-021] No catch-all rule found"]
}
Upgrading a policy
import { upgradePolicy } from "@parmanasystems/governance";
// Creates policies/loan-approval/1.0.1/ from 1.0.0/
const newDir = upgradePolicy("loan-approval");
Validating all versions
import { validatePolicy } from "@parmanasystems/governance";
const valid = validatePolicy("loan-approval");
// Returns true only when all version bundles are signed and their manifests are intact
Defining a policy in code
import { definePolicy } from "@parmanasystems/governance";
const policy = definePolicy({
policyId: "payment-approval",
policyVersion: "1.0.0",
schemaVersion: "1.0.0",
signalsSchema: {
amount: { type: "integer" },
verified: { type: "boolean" },
},
rules: [
{
id: "approve-standard",
condition: "amount < 10000 && verified == true",
action: "approve",
},
],
});
See also