Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Implementation:A5c ai Babysitter permission review

From Leeroopedia
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:

  1. AgentStack resolution and validation
  2. Approval mode enforcement (yolo, prompt, deny)
  3. Cross-org denial check
  4. Capability expansion from stack spec
  5. Untrusted fork detection (blocks privileged grants from PRs)
  6. 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);
}

Related Pages

Implements Principle

Requires Environment

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment