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 workspace provisioning

From Leeroopedia
Knowledge Sources
Domains Kubernetes, Workspace_Management, Volume_Provisioning
Last Updated 2026-10-23 00:00 GMT

Overview

Concrete tool for provisioning volume-backed git workspaces with PVC lifecycle for agent dispatch.

Description

The createAgentWorkspaceController factory returns a controller with workspace lifecycle methods:

  • createWorkspace — Creates a KradleWorkspace CRD with either a PVC manifest (persistent) or emptyDir (ephemeral). PVC storage class defaults to the cluster default unless overridden. Capacity defaults to 10Gi, access modes to ['ReadWriteOnce'].
  • findReusableWorkspace — Searches for an existing Ready PVC-backed workspace for the same org/repo/branch, enabling workspace reuse across runs.

Ephemeral workspaces use emptyDir (binds instantly, no CSI provisioning, reclaimed with pod). Persistent workspaces create a PersistentVolumeClaim.

Usage

  • Agent dispatch Step 3: Provision a workspace before creating the K8s Job.

Code Reference

Source Location

  • Repository: Babysitter
  • File: packages/kradle/core/src/agent-workspace-controller.js:L11-80+

Signature

function createAgentWorkspaceController(): {
  role: 'agent-workspace-controller',
  createWorkspace(input): { error, workspace, pvcManifest? },
  findReusableWorkspace(input): KradleWorkspace | null,
};

// createWorkspace input:
// { name, organizationRef, repository, volumeSpec, branch, namespace, ephemeral }
// volumeSpec: { storageClassName?, capacity?, accessModes? }

Import

import { createAgentWorkspaceController } from "@a5c-ai/kradle";

I/O Contract

Inputs

Name Type Required Description
name string No Workspace name (auto-generated if absent)
organizationRef string Yes Organization reference
repository string Yes Repository URL
volumeSpec.storageClassName string No K8s storage class
volumeSpec.capacity string No Storage size (default 10Gi)
ephemeral boolean No Use emptyDir instead of PVC

Outputs

Name Type Description
workspace KradleWorkspace CRD Workspace resource with PVC or emptyDir
pvcManifest object PVC manifest (null for ephemeral)

Usage Examples

Persistent Workspace

import { createAgentWorkspaceController } from "@a5c-ai/kradle";

const controller = createAgentWorkspaceController();
const { error, workspace, pvcManifest } = controller.createWorkspace({
  organizationRef: "my-org",
  repository: "https://github.com/my-org/my-repo.git",
  branch: "main",
  namespace: "kradle",
  volumeSpec: { capacity: "20Gi" },
});

if (error) {
  console.error("Workspace creation failed:", error);
}

Ephemeral Workspace

const { workspace } = controller.createWorkspace({
  organizationRef: "my-org",
  repository: "https://github.com/my-org/my-repo.git",
  ephemeral: true,
});
// No pvcManifest — Job mounts emptyDir for /workspace

Reuse Existing Workspace

const reusable = controller.findReusableWorkspace({
  organizationRef: "my-org",
  repository: "https://github.com/my-org/my-repo.git",
  branch: "main",
  resources: existingK8sResources,
});

Related Pages

Implements Principle

Requires Environment

Uses Heuristics

Page Connections

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