Implementation:A5c ai Babysitter permission review
| Knowledge Sources | |
|---|---|
| Domains | Kubernetes, Security, Permission_Management |
| Last Updated | 2026-10-23 00:00 GMT |
Overview
Concrete tool for reviewing and resolving agent dispatch permissions against Kubernetes RBAC resources.
Description
The createPermissionReviewer factory returns a permission reviewer that evaluates dispatch requests against K8s CRD resources (AgentStack, AgentServiceAccount, AgentSecretGrant, AgentToolGrant, etc.). The reviewPermissions method performs:
- AgentStack resolution and validation
- Approval mode enforcement (yolo, prompt, deny)
- Cross-org denial check
- Capability expansion from stack spec
- Untrusted fork detection (blocks privileged grants from PRs)
- Service account and secret grant resolution
The subjectMatches helper matches grant/binding subjects against service account refs or agent stack names, handling both legacy string and structured object subject formats.
Usage
- Agent dispatch Step 1: Review permissions before allowing an agent dispatch to proceed.
Code Reference
Source Location
- Repository: Babysitter
- File: packages/kradle/core/src/agent-permission-review.js:L22-33 (subjectMatches), L35-100+ (createPermissionReviewer)
Signature
function subjectMatches(subject, serviceAccountRef, agentStack): boolean;
function createPermissionReviewer(options = {}): {
role: 'agent-permission-review',
reviewPermissions(input): Decision
};
// reviewPermissions input:
// { repository, ref, actor, agentStack, triggerSource, taskKind, runnerPool,
// toolRefs, skillRefs, mcpServerRefs, contextLabelRefs, workspacePolicyRef,
// isFork, resources }
// Decision:
// { decision: 'allowed'|'denied'|'requires-approval', reasons, grants, capabilities, crossOrgDenials, untrustedForkWarnings }
Import
import { createPermissionReviewer, subjectMatches } from "@a5c-ai/kradle";
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| repository | string | Yes | Repo path (org/repo) |
| ref | string | Yes | Git ref |
| actor | string | Yes | Dispatching user |
| agentStack | string | Yes | Stack name |
| isFork | boolean | No | Fork flag |
| resources | object | Yes | K8s CRD resources |
Outputs
| Name | Type | Description |
|---|---|---|
| Decision | object | allowed/denied/requires-approval with reasons, grants, capabilities |
Usage Examples
Review Dispatch Permissions
import { createPermissionReviewer } from "@a5c-ai/kradle";
const reviewer = createPermissionReviewer();
const decision = reviewer.reviewPermissions({
repository: "my-org/my-repo",
ref: "refs/heads/main",
actor: "user@example.com",
agentStack: "claude-stack",
isFork: false,
resources: {
AgentStack: [/* ... */],
AgentServiceAccount: [/* ... */],
AgentSecretGrant: [/* ... */],
},
});
if (decision.decision === 'denied') {
console.error("Denied:", decision.reasons);
}