You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
PR #34 splits pi-guardrails into a cleaner architecture with src/core, src/shared, and separate extensions for policies, path access, and permission gate. Once that lands, we should add a small stable integration API so other Pi extensions can voluntarily ask guardrails for an allow/block decision before performing sensitive actions.
"Zones" or Rule Sets #29 — zones/rule-set style policies. Zones should be provider-side policy logic, not something baked into the public integration protocol.
Goal
Provide a stable, versioned, low-maintenance API that external extensions can use without pi-guardrails maintaining tool-specific adapters.
The API should let a cooperating extension say:
I am about to perform this action on this resource. Should I allow it?
Then pi-guardrails can answer:
allow, block, ask, or error.
Non-goals
Do not maintain per-tool adapters for MCP tools or other third-party extensions.
Do not monkey-patch filesystem or process APIs.
Do not require external extensions to import or depend on @aliou/pi-guardrails.
Do not expose internal src/core types as public API.
Do not bake zones concepts into the protocol.
Do not change existing telemetry events like guardrails:blocked and guardrails:dangerous as part of v1.
Proposed protocol
Use the Pi extension event bus with a request/response pattern.
Request event:
guardrails:check
Response event:
guardrails:decision
The caller emits guardrails:check, waits for a matching guardrails:decision by requestId, then enforces the decision before doing the work.
Zones should be a policy implementation detail behind the provider.
The protocol should not mention zones. It should only describe the attempted action. A zones implementation can then use path prefixes, CWD priority, and operation-specific policy internally to answer the same guardrails:check request.
Note
This comment has been written by Pi (
openai-code/gpt-5.5).Context
This should be done after PR #34 is merged.
PR #34 splits
pi-guardrailsinto a cleaner architecture withsrc/core,src/shared, and separate extensions for policies, path access, and permission gate. Once that lands, we should add a small stable integration API so other Pi extensions can voluntarily ask guardrails for an allow/block decision before performing sensitive actions.This is related to:
Goal
Provide a stable, versioned, low-maintenance API that external extensions can use without
pi-guardrailsmaintaining tool-specific adapters.The API should let a cooperating extension say:
Then
pi-guardrailscan answer:Non-goals
@aliou/pi-guardrails.src/coretypes as public API.guardrails:blockedandguardrails:dangerousas part of v1.Proposed protocol
Use the Pi extension event bus with a request/response pattern.
Request event:
guardrails:checkResponse event:
guardrails:decisionThe caller emits
guardrails:check, waits for a matchingguardrails:decisionbyrequestId, then enforces the decision before doing the work.Proposed request shape
Proposed decision shape
Canonical v1 actions
Start small.
Resource kinds:
fileprocessCanonical file operations:
readwritedeleteliststatCanonical process operations:
execspawnKeep
networkandcustomas escape hatches or future expansion points, but implementation can initially ignore or error on unsupported kinds.Example: MCP tool writing a file
{ "protocolVersion": "1", "requestId": "abc-123", "caller": { "extensionId": "pi-mcp-adapter" }, "action": { "resource": { "kind": "file", "type": "mcp-tool" }, "operation": "write", "targets": [ { "uri": "file:///repo/package.json" } ], "attributes": { "toolName": "write_file" } }, "context": { "cwd": "/repo" }, "options": { "interactive": true, "timeoutMs": 1000 } }Timeout behavior
The caller owns timeout behavior.
Recommended caller behavior:
guardrails:check.requestIduntiltimeoutMs.This keeps
pi-guardrailsoptional and lets integrations choose the right safety posture.How this addresses #27
For non-bash tools,
pi-guardrailsdoes not need to understand each tool.The tool author knows the intended action and can send a generic check request before doing it. Guardrails only evaluates the normalized action.
How this relates to #29
Zones should be a policy implementation detail behind the provider.
The protocol should not mention zones. It should only describe the attempted action. A zones implementation can then use path prefixes, CWD priority, and operation-specific policy internally to answer the same
guardrails:checkrequest.Implementation sketch after #34
guardrails:checklistener inpi-guardrails.guardrails:decisionwith a matchingrequestId.The helper should be optional. Plain JSON events should remain the actual API.