Open Source · Examples

Use examples to prove the boundary—not just copy syntax.

The public source contains runnable examples/templates for guarded Node.js calls, MCP/file workflows and outbound actions. The important part is understanding which execution path is actually controlled.

Minimal Node.js SDK

const ruleoak = await createRuleOak({ workspace: '.ruleoak', policy })
const guarded = ruleoak.guardFunction({
  name: 'filesystem.write',
  category: 'file',
  operation: 'write',
  resource: ([path]) => path,
  execute: async (path, bytes) => writeFile(path, bytes)
})

Ensure callers do not retain a parallel unguarded executor for the same consequential action.

MCP stdio

ruleoak mcp wrap -- node server.js

Confirm the client configuration actually points through the wrapper, then run protect check.

Outbound HTTP/webhook

Normalize the request, authorize it, consume one-use authority, execute once, then use an explicit domain postcondition/external identifier after ambiguous transport failure.

Source-candidate review

ruleoak dev ./candidate-source.zip --intent "<bounded intended change>"

The candidate producer is not automatically the evidence authority.

Before adapting an example

Define the real resource identity, bypass paths, idempotency/retry semantics, external postcondition and evidence-retention requirements for your environment.