Documentation
¶
Overview ¶
export.go: storeDraft, the sidecar half of the tuple-authorized draft-export route (Task 6, pkg/web/workshopdraftsrv). Task 7 wires this behind the export_draft tool; this file only provides the client call.
pkg/controllers/agentsession/sidecarpod.go's identity branch is the only place a workshop sidecar gets its two controller-issued tokens: the projected SA token (mounted at /var/run/secrets/workshop/serviceaccount/token, RBAC-bounded to the workshop namespace W) and the operator bearer (env var "token", from the <session>-workshop-token Secret). server.go is where those two tokens land as the Server this binary's tools run against — Task 1 wires the struct and the shared error helpers; Task 2 onward add the tools themselves via their own register* functions called from Register.
tools_apply.go implements `apply` (announced with the workshop toolbox's `workshop_` prefix as `workshop_apply`): server-side-apply a candidate CR into the workshop namespace W under this sidecar's own field manager, then poll for the object's own controller to stamp its Valid/ SchemaValidated conditions before answering — design spec §2.4's "the approval card, rendered by the summarizer over render_summary, is the 'a human sees every CR before it lands' step".
stateImpact:external / approval-required is a DECLARATION on this tool's SidecarToolbox entry (Task 8), not something this handler enforces itself: by the time a call reaches handleApply, the runner's approval flow has already gated it. This file only applies.
tools_close.go implements close_others: the one tool a builder has for ending the person's OTHER open workshops, so they can start a new build when they are already at their limit.
The tool never closes anything itself. It writes a REQUEST onto its own Workshop CR (spec.closeRequests, the same grant request_install writes through) and reads the operator's answers back off status.closeRequests. The decision is the operator's, checked per target against the person this builder acts for — see pkg/controllers/workshop/close.go.
Two shapes of request, because the two sides see different things. Named targets are written one entry each. "All of mine" cannot be: this sidecar's Role is name-restricted to its own Workshop, so it cannot list the person's workshops and has nothing to name — it writes a wildcard target (WorkshopCloseTargetAll) instead and lets the controller, which can list, resolve it. That ask's own status entry is the tool's signal that the expansion finished; the per-target entries carrying its key are the answer.
A person may ask for "all of mine" more than once, so a call made once the last ask has been ANSWERED writes a key of its own — "*", then "*:2", "*:3" — and the controller expands each afresh onto the workshops no request has settled yet (nextWildcardKey). The call reports the entries stamped with the key it is waiting on and nothing else: another ask's answer is not this one's, and handing it back would show a person a list that stopped being true when they opened their next workshop.
A call made while an ask is STILL OUTSTANDING writes nothing and waits for that ask instead (recordWildcardAsk). "Check again with the same call" is what the skills tell a person to do while they wait, and a fresh ask made then would expand onto the workshops no request has settled — none of them — and answer "nothing new to close" about the very ask being waited on. What the answer cannot cover, closeEarlierAskAnswered and closeEarlierAskPending say out loud — one for an ask that landed during the wait, one for an ask still open when the wait ran out.
A named target arrives in whichever spelling the person used — the builder session's name (what the start-route refusal shows them) or the Workshop's — and closeTargetFor maps it to the one a request can carry. The answer is spelled back the way they said it. A name that cannot BE a target is refused here rather than written (closeTargetNameable): one list, one CRD pattern, so an unspellable name would fail the whole write and take the workshops named beside it with it. The wildcard's expanded targets were named by nobody, so they come back as builder-session names (closeDisplayName): the one spelling the person has actually been shown.
Either may carry a namespace in front ("namespace/name") for a workshop outside this builder's own, which is how the start-route refusal names one and how the operator resolves it. The suffix rule applies to the name half alone; the prefix is carried through untouched, in both directions.
tools_credential.go implements request_credential — the builder session's way to ask a person to connect a bot/shared credential (an API key, PAT, static secret, or shared OAuth-MCP connection) for an AgentIdentity the builder has already authored in the workshop (via workshop_apply). It records the request onto the builder session's own Workshop CR (spec.credentialRequests), which a later channelsd watcher (not this file) turns into a card the person sees. The sidecar never touches a secret value itself — refs and names only, same discipline as WorkshopInstallRequest/WorkshopCapabilityRequest (workshop_types.go).
tools_crud.go implements `get`, `list` and `delete` (announced with the workshop toolbox's `workshop_` prefix as `workshop_get`, `workshop_list`, `workshop_delete`): read/write access to the CR kinds a builder authors in the workshop namespace W (design spec §2.4). All three operate ONLY within s.Identity.Namespace — none accepts a namespace argument, so a CR outside W is simply not nameable through this surface; the apiserver's own RBAC (bound to the workshop SA token, see server.go's header) is the second, structural boundary behind it.
get/list are read-only/auto; delete is approval-gated — both policies are DECLARED on this sidecar's SidecarToolbox entry (Task 8), not enforced by this file.
tools_export.go implements `export_draft` and `load_draft`: the workshop half of the .oap round trip (design spec §2.4, §6, §13's amendment). Task 6 (export.go) already built the tuple-authorized storeDraft client and the operator-side route; this file bundles the builder's authored AgentClass into a portable .oap and stores it, and re-applies a stored .oap back into a (possibly fresh — the sweeper may have reaped and re-provisioned W since the export ran) workshop.
The workshop-authored kinds a builder writes fall into two shapes, and the export/load boundary treats them differently — see pkg/controllers/webhooks/workshop/webhook.go's isClusterScopedWorkshopKind:
- AgentClass, AgentIdentity, MCPServer, SidecarToolbox, AgentUI, Skill, ConfigMap: namespaced under W, with a plain unprefixed name. Nothing to strip; load_draft only needs to point them at the CURRENT workshop namespace.
- SpiceboxToolspec, SpiceboxToolkit: cluster-scoped. The admission webhook's checkClusterToolObject requires metadata.name prefixed "<workshopID>-" and metadata.labels[LabelWorkshopNamespace] == workshopID on CREATE. export_draft strips both (otherwise the installed class trips plan-2's ReferencesWorkshopTool rule, pkg/controllers/agentclass/builderclass.go, which refuses a class referencing a toolspec whose LabelWorkshopNamespace names a foreign workshop); load_draft re-adds both, keyed to whichever workshop it is running in NOW.
tools_handoff.go implements the two tools that hand a finished build off to a person: request_install (ask a platform admin to install the agent this workshop built) and recommend_capability (recommend a platform capability the build surfaced a need for; the builder then calls agent_work_complete — separately — to end the session). Both are once-only: each writes a single pointer field on the builder session's own Workshop CR (spec.installRequest / spec.capabilityRequest) exactly once, same discipline as WorkshopCredentialRequest's dedupe (tools_credential.go) but keyed by presence rather than by content, because a repeat call here is a second, distinct decision — not a retry of the same one — and must be refused rather than silently accepted as a no-op. A later plan's channelsd watcher turns these fields into an admin card; this file only records the request.
tools_inventory.go implements the `inventory` tool: a read-only snapshot of this cluster's REAL registered capabilities, channel kinds, and artifact renderers, plus the CR-backed SpiceboxClass catalog, sandbox backend registry, model catalog, cluster skills, this workshop's own MCP servers, and the cluster-tier governance ceilings. It exists so the builder agent never proposes a design the running cluster cannot actually serve, or that the cluster admin has forbidden — see the design spec's Assess step and Ruling C (ceilings come from ClusterAgentSettings).
Every in-process registry this file reads from is populated by registries.go's blank imports, never by this file itself — a registry registries.go forgets to link reports an empty set here, not a compile error, which is exactly what tools_inventory_test.go's drift test exists to catch. The CR-backed fields (SandboxClasses, Models, ClusterSkills, MCPCatalog, Ceilings) instead depend on RBAC granted to the workshop SA — config/manager/workshop-reader.yaml for the three cluster-scoped kinds, the workshop namespace's own Role for MCPServer.
tools_probe.go implements the three discovery tools design spec §2.4's "Tools" loop row calls for: `probe_mcp` (a live `tools/list` against a candidate MCP server URL) and `probe_image` / `cli_help` (discovering an image's tool surface / a CLI's --help text). The sidecar holds no `pods` verb (design spec §2.3: "The sidecar holds no LLM credential and has no pods verb: it cannot think and it cannot run an image") — probe_mcp needs no pod at all (it is a plain outbound HTTP call from THIS pod, guarded against SSRF), but probe_image/cli_help have to run an arbitrary caller-named image, which only the plan-3a WorkshopProbe controller is privileged to do. This file creates the CR and waits; it never runs a pod itself.
tools_project.go implements `project_agent` (announced with the workshop toolbox's `workshop_` prefix as `workshop_project_agent`): the sidecar half of plan 9b's stand-in-projection route (pkg/web/workshopprojectsrv, Task 1). A builder that was pulled into an existing conversation — see `agents_in_thread` (tools_thread.go) for how it learns who else is there — may want the agent it is building to hand work off to one of those other agents. Rehearsing that hand-off must never invoke the real agent (its real credentials, tools, or authz policy); this tool is what lets the builder ask the operator to project a credential-free PRACTICE DOUBLE of that other agent's class into its own workshop instead, so the hand-off itself — not the real agent's work — can be rehearsed.
New reach, stated plainly: the double carries the source class's own SystemPrompt into the workshop namespace, where this sidecar has full CRUD on AgentClass — so `workshop_get`/`workshop_list` read another agent's instructions back to the builder verbatim, something the sidecar otherwise has no access to at all.
WHAT BOUNDS THAT REACH IS THE SERVER, NOT THE CARD. stateImpact: external on this tool keys `workshop_draft:draft#project` (see the workshop SidecarToolbox manifest), so the approval a human gives is per PHASE and names the DRAFT: one approval covers every projection in that phase, and the card never shows the {namespace, name} a given call will actually project. The per-target bound is enforced where the projection happens — pkg/web/workshopprojectsrv refuses any class not reachable from this conversation's own agent set, the exact set this builder's `agents_in_thread` already returned it. That refusal, not the card, is the control; the card is what makes the REACH visible to the person, and this tool's own Description says what the reach is.
tools_render.go implements `render_summary`: a plain-language rendering of a custom resource — a candidate not yet applied (pass `manifest`) or one already applied (pass `kind`+`name`) — for an approval card or the running summary (design spec §2.4).
The Copy rule applies: the rendered sentence never names the underlying resource machinery — no "kind:"/"apiVersion:" field syntax, no `kubectl`, no CRD/YAML/namespace/relation vocabulary. A human approving workshop_apply reads this, not the manifest.
tools_testrun.go implements test_tool, read_test_log and stop_test: the builder session's ways to exercise a candidate AgentClass without a human running it directly through this sidecar. test_tool delegates a bounded single_turn task to it and reads back what the child DID (its tool calls and results), never what it said. It creates a SubagentRequest naming this builder session (B/X) as parent, in the workshop namespace W, waits for the child to reach a terminal phase, and reads its transcript back through s.readChildToolResults (transcript.go). The sidecar holds no delegate verb of its own beyond this CR create — the SubagentRequest controller (pkg/controllers/subagentrequest) validates roster membership and budget and creates the actual child session, exactly as it does for any other delegating runner.
read_test_log and stop_test act on the PERSON'S OWN test session, not a delegated child: tools_trytest.go's test_link/watch_test/test_sessions are how that session gets started and found by name; this file only reads its transcript and deletes it. The attended, builder-delegated run_test tool that used to fill this role is gone — a child running AS the person widens the builder's own identity, which the delegation gates refuse, so the person now starts their own test themselves (see tools_trytest.go's own doc).
tools_thread.go implements `agents_in_thread` (announced with the workshop toolbox's `workshop_` prefix as `workshop_agents_in_thread`): the sidecar half of plan 9a's reproduce-lookup route (pkg/web/workshopthreadsrv, Task 1). A builder session freshly pulled into a conversation another agent already worked has no way, from its own state alone, to tell who else has already been in that thread — this tool is that lookup, and it answers for the calling builder's OWN conversation only, never any other thread or namespace.
tools_trytest.go implements `test_link`, `watch_test` and `test_sessions`: the person tests the agent they are building by starting it THEMSELVES, as a root session in the workshop namespace, from the browser chat — never as a delegated child of this builder (a child running as the person widens the builder's identity, which the delegation gates refuse). The builder paints the link (ap:agentlink from test_link's result), asks the Workshop controller to watch (watch_test → spec.testWatch; the controller wakes the builder as the test starts, pauses, ends or times out), and finds the test session by name (test_sessions) to read its log.
tools_validate.go implements `validate_spec`, three checks in one call so the builder agent catches a structural, CEL, schema or whole-workshop error before ever calling workshop_apply — design spec's "Assess before Apply" step:
- The local half: round-trip the candidate's spec content through the SAME local-file validator and CEL compiler `oap tools validate` uses for its kind (cmd/oap/internal/toolscmd/validate.go), for the three kinds that have one. It writes the candidate to a throwaway temp file and calls that kind's own contract.Validator, exactly the shape a local file takes on disk before `oap tools apply` turns it into a CR.
- The server half: a DRY RUN of the exact server-side apply workshop_apply would make, for every kind the workshop can author (tools_crud.go's workshopKindTable). The apiserver answers with the CRD's own schema and rules, and nothing is created. This half exists because the local validators decode leniently — a field the CRD never declared passed them and failed only at the real apply — and because the kinds with no local validator at all (AgentIdentity, Skill, AgentUI, AgentClass) were otherwise discoverable only by approval-gated applies, one human click per guessed field (observed live on oap-desktop, 2026-09-13).
- The cross-check half (crossChecksByKind): rules about how the candidate combines with the resources ALREADY in the workshop namespace, which neither of the other two halves can state because each sees exactly one document. Today that is one rule, authored from either end: an MCPServer nobody can ever connect an account to, under a class that runs as the person.
validate_spec is read-only and auto — that policy is declared on this sidecar's SidecarToolbox entry (Task 8), not enforced by this file. The dry run keeps it true: DryRunAll is what makes the server half a read.
transcript.go: readChildToolResults, the sidecar half of the plan 4a tuple-authorized child-transcript read route (Task 2, pkg/web/workshoptranscriptsrv). test_tool and read_test_log call this to see what a session DID — its tool calls and their results — never what it SAID, plus the signed transitions that say what happened TO it when it did nothing at all.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Server ¶
type Server struct {
// K8s is the SA-token-bound controller-runtime client, RBAC-scoped to the
// workshop namespace Identity.Namespace by the apiserver — the sidecar
// itself never re-checks a CR's namespace before acting.
K8s client.Client
// Ops is the operator-bearer memory client this sidecar reaches the
// operator's HTTP memory routes (and, from Task 6, the export-draft
// route) through.
Ops memory.Memory
// Identity is this sidecar's workshop identity.
Identity WorkshopIdentity
// FieldOwner is the stable SSA field manager every workshop_apply call
// uses. Defaults to "workshop-sidecar" (defaultFieldOwner) via NewServer.
FieldOwner string
// ProbeHTTP overrides the HTTP client probe_mcp's tools/list call uses.
// Nil in production (and via NewServer) — probe.Client treats a nil
// HTTP field as "use the SSRF-guarded default"
// (pkg/tools/mcp/probe.Client.httpClient, backed by safehttp.Client()),
// which is the correct behavior here: the probed URL is model-supplied.
// Tests set this to a loopback-permitting client (e.g. http.DefaultClient)
// to reach an httptest fake MCP server.
ProbeHTTP *http.Client
// contains filtered or unexported fields
}
Server holds this sidecar's two controller-issued clients — K8s (the SA-token-bound, RBAC-bounded controller-runtime client) and Ops (the operator-bearer memory client) — plus the workshop identity, and registers every workshop build-tool onto an mcp.Server via Register. Task 1 wires the struct with no tools; each later task adds its own registerX call inside Register.
func NewDeclarationOnly ¶
func NewDeclarationOnly() *Server
NewDeclarationOnly builds a Server that serves ONLY tool declarations: it registers the full tool surface (tools/list answers exactly what a wired server announces) and refuses every tools/call via receiving middleware.
This is the admission-probe mode: buildProbePod (pkg/controllers/sidecartoolbox/probe.go) runs the image with no projected SA token, no operator bearer and no WORKSHOP_* identity, and only ever asks tools/list — so the image must be able to DESCRIBE itself without an identity while remaining unable to ACT without one. Declaration-only is an EXPLICIT choice by the binary's boot path (main.go's probe-mode predicate), never inferred from a nil client: a mis-wired production sidecar must crash, not silently degrade into a server that refuses everything.
func NewServer ¶
func NewServer(k8s client.Client, ops memory.Memory, identity WorkshopIdentity, fieldOwner string) *Server
NewServer builds a Server from its two clients and its workshop identity. fieldOwner defaults to defaultFieldOwner when empty.
func (*Server) Register ¶
Register wires every workshop build-tool onto mcpSrv. Task 1 registers none — each later task (inventory, apply/CRUD/render, validate, probes, export/load, test) adds its own registerX(mcpSrv) call here, so this function is the one place that lists the sidecar's full tool surface.
func (*Server) SetBuilderSession ¶
SetBuilderSession late-binds the builder AgentSession's real (namespace, name) onto an already-mounted Server. See sessionMu's own doc for why this exists at all (WorkshopIdentity is frozen at construction, before any session exists, in the one caller that needs this) and for the concurrency guard — safe to call while the Server is already serving other tool calls.
type WorkshopIdentity ¶
type WorkshopIdentity struct {
// Namespace is the provisioned workshop namespace W ("ws-<uid12>") this
// sidecar's SA token is RBAC-bounded to — every CR the sidecar reads or
// writes lives here.
Namespace string
// SessionNamespace/SessionName identify the BUILDER AgentSession (B/X)
// that owns this workshop — distinct from Namespace, which is the
// workshop's own namespace, not the builder session's.
SessionNamespace string
SessionName string
// WorkshopID is the workshop identifier the platform env carries
// (WORKSHOP_ID) — equal to Namespace today (both are W), carried as its
// own field because the two happen to share a value, not because they
// are the same concept.
WorkshopID string
}
WorkshopIdentity is which workshop namespace / builder session this sidecar process is scoped to, resolved once at startup from the env BuildSidecarPod's identity branch injects. Namespace is fixed for the process's life, but SessionNamespace/SessionName are late-bound in the one caller that needs it (the e2e harness, before any real session exists) — see Server.sessionRef(), not this struct's own fields, for what a caller should actually read.