Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/docker-build-push.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,8 @@ jobs:

# 고쳐야 할 자리는 셋이고 형태가 둘이다:
# 1) 컨테이너의 image: 줄 (control-plane, 1곳)
# 2) DATA_PLANE_IMAGE / DATA_PLANE_CLAUDE_CODE_IMAGE 의 env value (2곳)
# 2) DATA_PLANE_*_IMAGE 의 env value (DATA_PLANE_IMAGE · CLAUDE_CODE ·
# APPROVAL_GATED · MINIMAX_CODE — 이미지 문자열이 같아 아래 sed 하나가 모두 잡는다)
# env value 는 kustomize 의 images 변환이 건드리지 못하는 자리라(문자열일
# 뿐 image 필드가 아니다) 여기서 함께 다뤄야 한다.
#
Expand Down
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,13 @@ docs/ value / PRD·AC / journeys / mockups / CRIU verification n
receives a non-secret placeholder. Every data plane pod uses the dedicated
`data-plane` ServiceAccount, whose cluster-wide built-in `view` binding gives
read-only Kubernetes access while excluding Secrets.
`minimax-code` runs the MiniMax Code CLI (`mcode exec`) on that same one-shot
runner, queue, cursor and archive (AC-G1~G4). It gets the same loopback proxy
sidecar reading its own `minimax-code-credentials` Secret — whose
`auth-token` may be a MiniMax Token Plan subscription key — and no Claude
plugin bootstrap; its archive sits behind its own
`MINIMAX_CODE_ARCHIVE_ENABLED` gate. See
[`docs/prd/minimax-code-workload.md`](docs/prd/minimax-code-workload.md).
- **Lifecycle**: 60-min max idle → workload snapshot + pod reclaim (AC-B1);
access → restore into a new pod (AC-B2). Shell uses CRIU behind
`CRIU_ENABLED`; Claude uses a filesystem archive behind the independent,
Expand Down
30 changes: 17 additions & 13 deletions control-plane/api/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@ info:
session-scoped auxiliary pods that serve it (AC-A2). Non-active access is
uniform "ensure active then serve": read, write and switch promote
idle->active (AC-C1) or restore snapshot->active (AC-B2) before serving.
A session picks a workload type at creation (AC-E1): `shell` (the default)
or `claude-code`. The type is immutable for the session's lifetime — no
A session picks a workload type at creation (AC-E1): `shell` (the default),
`claude-code`, `approval-gated` or `minimax-code`. The type is immutable for the session's lifetime — no
endpoint changes it, and a restore keeps it — so switching workloads means
creating a new session. For `shell`, write injects the payload into the PTY
stdin (AC-D2); for `claude-code`, write asynchronously queues one prompt
execution (AC-E2). Both read paths return workload output after an offset
stdin (AC-D2); for `claude-code` (and the agent types that reuse its
execution model), write asynchronously queues one prompt execution
(AC-E2, AC-G2). Both read paths return workload output after an offset
cursor, with offset=0 returning the full history (AC-D3/E3). A passive
`GET /sessions/{id}/stream` exposes the same append-only bytes as
cursor-resumable SSE without restoring snapshots or refreshing idle
Expand Down Expand Up @@ -334,7 +335,8 @@ paths:
operationId: snapshotSession
description: >
Immediately captures the workload using its configured strategy
(CRIU checkpoint for shell, filesystem archive for claude-code), moves
(CRIU checkpoint for shell, filesystem archive for claude-code and
minimax-code), moves
the session to snapshot state, and reclaims its pod. Calling this for
an already-snapshotted session is idempotent.
parameters:
Expand Down Expand Up @@ -450,15 +452,17 @@ components:
enum: [active, idle, snapshot]
WorkloadType:
type: string
enum: [shell, claude-code, approval-gated]
enum: [shell, claude-code, approval-gated, minimax-code]
default: shell
description: >
Which data plane workload the session runs (AC-E1/AC-F1). Fixed at
creation and immutable afterwards. `shell` is an interactive PTY shell
(AC-D1~D5); `claude-code` is the Claude Code CLI workload (AC-E2~E6);
`approval-gated` is the same agent execution model behind a human
approval gate, provisioned as a workload pod plus a session-scoped
helper pod (AC-F1~F6). Each non-default type requires the control plane
helper pod (AC-F1~F6); `minimax-code` is the MiniMax Code CLI
(`mcode`) on that same execution model, with its own provider Secret
behind the same credential proxy (AC-G1~G4). Each non-default type requires the control plane
to have an image configured for it, and creating a session of a type
with no configured image fails rather than falling back to a shell.
Checkpoint:
Expand All @@ -480,8 +484,8 @@ components:
type: string
description: >
Immutable model identifier for the agent workload types. Present
for `claude-code` and `approval-gated`, which share this contract
(AC-E6, reused by AC-F1); omitted at creation resolves to
for `claude-code`, `approval-gated` and `minimax-code`, which share
this contract (AC-E6, reused by AC-F1 and AC-G1); omitted at creation resolves to
`platform-default`.
Whenever the primary container starts, including a restart, that
alias resolves through the optional Secret model and then the CLI
Expand All @@ -498,8 +502,8 @@ components:
Session-scoped pods that serve the workload pod without running the
workload themselves (AC-A2's auxiliary-pod clause). They share the
workload pod's lifetime and are reclaimed with it, so this is absent
exactly when `pod` is. `shell` and `claude-code` sessions provision
none; an `approval-gated` session lists its one helper pod here
exactly when `pod` is. `shell`, `claude-code` and `minimax-code`
sessions provision none; an `approval-gated` session lists its one helper pod here
(AC-F4).
createdAt: { type: string, format: date-time }
lastAccess: { type: string, format: date-time }
Expand All @@ -525,8 +529,8 @@ components:
type: string
pattern: '^(~[A-Za-z0-9][A-Za-z0-9._:/-]{0,126}|[A-Za-z0-9][A-Za-z0-9._:/-]{0,127})$'
description: >
Model for this session. Valid when workloadType is `claude-code` or
`approval-gated`; omitted resolves to `platform-default`. A concrete
Model for this session. Valid when workloadType is `claude-code`,
`approval-gated` or `minimax-code`; omitted resolves to `platform-default`. A concrete
value is passed literally and takes precedence over the platform
Secret default. The catalog returned by GET /config is advisory,
not an allowlist. Credentials are never accepted in this request.
Expand Down
21 changes: 19 additions & 2 deletions control-plane/cmd/control-plane/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ func main() {
logger := slog.New(slog.NewJSONHandler(os.Stdout, nil))

cfg, err := loadConfig()
if err == nil {
err = validateMiniMaxSecret(cfg.miniMax, cfg.claudeCredentialsSecret)
}
if err != nil {
logger.Error("invalid runtime configuration", "err", err)
os.Exit(1)
Expand All @@ -57,6 +60,7 @@ func main() {
"data_plane_image", cfg.dataPlaneImage,
"data_plane_claude_code_image", cfg.dataPlaneClaudeCodeImage,
"data_plane_approval_gated_image", cfg.dataPlaneApprovalGatedImage,
"data_plane_minimax_code_image", cfg.miniMax.image,
"data_plane_shell", cfg.dataPlaneShell,
"claude_code_default_model", cfg.claudeCodeDefaultModel,
"claude_code_models", len(cfg.claudeCodeModels),
Expand All @@ -74,7 +78,9 @@ func main() {
k8s.WithWorkloadImage(session.WorkloadTypeClaudeCode, cfg.dataPlaneClaudeCodeImage),
// Same for approval-gated (AC-F1).
k8s.WithWorkloadImage(session.WorkloadTypeApprovalGated, cfg.dataPlaneApprovalGatedImage),
k8s.WithWorkloadImage(session.WorkloadTypeMiniMaxCode, cfg.miniMax.image),
k8s.WithClaudeCredentialsSecret(cfg.claudeCredentialsSecret),
k8s.WithMiniMaxCredentialsSecret(cfg.miniMax.credentialsSecret),
k8s.WithApprovalGatewaySecret(cfg.approvalGatewaySecret),
k8s.WithSharedVolume(cfg.sharedVolumeStorageClass, cfg.sharedVolumeSize),
k8s.WithCheckpointPrivileged(cfg.criuEnabled))
Expand All @@ -88,7 +94,7 @@ func main() {
// sent to the configured durable store only behind an explicit mechanism
// gate: CRIU_ENABLED for shell, CLAUDE_CODE_ARCHIVE_ENABLED for claude-code.
var cstore criu.CheckpointStore
if cfg.criuEnabled || cfg.claudeArchiveEnabled {
if cfg.criuEnabled || cfg.claudeArchiveEnabled || cfg.miniMax.archiveEnabled {
cstore, err = buildCheckpointStore(cfg)
if err != nil {
logger.Error("checkpoint store misconfigured", "err", err)
Expand Down Expand Up @@ -119,8 +125,17 @@ func main() {
))
logger.Info("claude-code filesystem archive enabled", "store", cfg.checkpointStoreDesc())
}
miniMaxArchive, err := miniMaxArchiveOption(cfg.miniMax, agentClient, cstore)
if err != nil {
logger.Error("minimax-code archive misconfigured", "err", err)
os.Exit(1)
}
if miniMaxArchive != nil {
serviceOpts = append(serviceOpts, miniMaxArchive)
logger.Info("minimax-code filesystem archive enabled", "store", cfg.checkpointStoreDesc())
}
mgr := service.New(orch, store, shellCkpt, agentClient, serviceOpts...)
snapshotEnabled := shellCkpt.Enabled() || cfg.claudeArchiveEnabled
snapshotEnabled := shellCkpt.Enabled() || cfg.claudeArchiveEnabled || cfg.miniMax.archiveEnabled

// AC-B1: the operational idle->snapshot trigger. Manual snapshots reach the
// same manager operation through the product API, without the idle wait.
Expand Down Expand Up @@ -210,6 +225,7 @@ type config struct {
checkpointS3Prefix string
checkpointS3SessionName string
checkpointS3Endpoint string
miniMax miniMaxConfig
}

// buildCheckpointStore builds the checkpoint archive backend.
Expand Down Expand Up @@ -278,6 +294,7 @@ func loadConfig() (config, error) {
checkpointS3Region: env("CHECKPOINT_S3_REGION", env("AWS_REGION", "")),
checkpointS3Prefix: env("CHECKPOINT_S3_PREFIX", "checkpoints"),
checkpointS3SessionName: env("CHECKPOINT_S3_SESSION_NAME", ""),
miniMax: loadMiniMaxConfig(),
}, nil
}

Expand Down
64 changes: 64 additions & 0 deletions control-plane/cmd/control-plane/minimax_code.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
package main

import (
"errors"
"fmt"
"strings"

"github.com/dlddu/session-platform/control-plane/internal/adapter/agent"
"github.com/dlddu/session-platform/control-plane/internal/adapter/criu"
"github.com/dlddu/session-platform/control-plane/internal/service"
"github.com/dlddu/session-platform/control-plane/internal/session"
)

// miniMaxConfig is the minimax-code slice of the control-plane configuration
// (AC-G1, AC-G3, AC-G4). It is kept apart from claude-code's fields so that
// turning one type on never changes what the other does.
type miniMaxConfig struct {
// image is the data plane image for `workloadType=minimax-code` sessions.
// Unset means the type is not deployable here: creating such a session
// fails loudly rather than getting a shell pod (AC-G1, same rule as AC-E1).
image string
// credentialsSecret names the Secret whose base-url/auth-token (and
// optional model/ca-cert) keys reach this type's credential proxy sidecar.
credentialsSecret string
// archiveEnabled is this type's own mechanism gate: workspace, conversation
// and output archives go to CHECKPOINT_S3_* only when it is explicitly on,
// exactly as CLAUDE_CODE_ARCHIVE_ENABLED is for claude-code (AC-G4).
archiveEnabled bool
}

func loadMiniMaxConfig() miniMaxConfig {
return miniMaxConfig{
image: env("DATA_PLANE_MINIMAX_CODE_IMAGE", ""),
credentialsSecret: env("MINIMAX_CODE_CREDENTIALS_SECRET", "minimax-code-credentials"),
archiveEnabled: envBool("MINIMAX_CODE_ARCHIVE_ENABLED", false),
}
}

// validateMiniMaxSecret refuses a configuration where minimax-code would read
// the claude-code Secret. AC-G3 promises the two types never share provider
// credentials, and naming the same Secret twice would break that silently.
func validateMiniMaxSecret(cfg miniMaxConfig, claudeSecret string) error {
if strings.TrimSpace(cfg.credentialsSecret) == strings.TrimSpace(claudeSecret) {
return fmt.Errorf("MINIMAX_CODE_CREDENTIALS_SECRET must differ from CLAUDE_CODE_CREDENTIALS_SECRET (both %q)", claudeSecret)
}
return nil
}

// miniMaxArchiveOption returns the service option that installs the
// filesystem-archive checkpointer for minimax-code, or nil when the gate is off.
// The gate needs the image for the same reason claude-code's does: a gate that
// is on for a type nobody can create is a misconfiguration worth failing on.
func miniMaxArchiveOption(cfg miniMaxConfig, client *agent.HTTPClient, store criu.CheckpointStore) (service.Option, error) {
if !cfg.archiveEnabled {
return nil, nil
}
if cfg.image == "" {
return nil, errors.New("MINIMAX_CODE_ARCHIVE_ENABLED needs DATA_PLANE_MINIMAX_CODE_IMAGE")
}
return service.WithWorkloadCheckpointer(
session.WorkloadTypeMiniMaxCode,
criu.NewAgentArchiveCheckpointer(client, store),
), nil
}
58 changes: 58 additions & 0 deletions control-plane/cmd/control-plane/minimax_code_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
package main

import (
"testing"

"k8s.io/client-go/kubernetes/fake"

"github.com/dlddu/session-platform/control-plane/internal/adapter/agent"
)

func TestLoadMiniMaxConfigDefaults(t *testing.T) {
t.Setenv("DATA_PLANE_MINIMAX_CODE_IMAGE", "")
t.Setenv("MINIMAX_CODE_CREDENTIALS_SECRET", "")
t.Setenv("MINIMAX_CODE_ARCHIVE_ENABLED", "")
got := loadMiniMaxConfig()
want := miniMaxConfig{credentialsSecret: "minimax-code-credentials"}
if got != want {
t.Fatalf("config = %+v, want %+v", got, want)
}
}

func TestLoadMiniMaxConfigReadsEnvironment(t *testing.T) {
t.Setenv("DATA_PLANE_MINIMAX_CODE_IMAGE", "ghcr.io/example/data-plane:1")
t.Setenv("MINIMAX_CODE_CREDENTIALS_SECRET", "mm-secret")
t.Setenv("MINIMAX_CODE_ARCHIVE_ENABLED", "true")
got := loadMiniMaxConfig()
want := miniMaxConfig{image: "ghcr.io/example/data-plane:1", credentialsSecret: "mm-secret", archiveEnabled: true}
if got != want {
t.Fatalf("config = %+v, want %+v", got, want)
}
}

// AC-G3: the two agent types must not be configured onto one Secret.
func TestValidateMiniMaxSecret(t *testing.T) {
if err := validateMiniMaxSecret(miniMaxConfig{credentialsSecret: "minimax-code-credentials"}, "claude-code-credentials"); err != nil {
t.Fatalf("distinct secrets: %v", err)
}
if err := validateMiniMaxSecret(miniMaxConfig{credentialsSecret: " shared "}, "shared"); err == nil {
t.Fatal("shared secret: want an error")
}
}

// AC-G4: the archive gate is off by default, and turning it on for a type with
// no image is a startup error rather than a silently dead gate.
func TestMiniMaxArchiveOption(t *testing.T) {
client := agent.NewHTTPClient(fake.NewSimpleClientset(), "sessions")

if opt, err := miniMaxArchiveOption(miniMaxConfig{}, client, nil); err != nil || opt != nil {
t.Fatalf("gate off: option %v, err %v; want neither", opt != nil, err)
}
if _, err := miniMaxArchiveOption(miniMaxConfig{archiveEnabled: true}, client, nil); err == nil {
t.Fatal("gate on without an image: want an error")
}
opt, err := miniMaxArchiveOption(miniMaxConfig{archiveEnabled: true, image: "img"}, client, nil)
if err != nil || opt == nil {
t.Fatalf("gate on with an image: option %v, err %v; want an option", opt != nil, err)
}
}
32 changes: 18 additions & 14 deletions control-plane/internal/adapter/k8s/client_orchestrator.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,11 +192,12 @@ const (
// dedicated data plane pod per session through client-go, and dials the pod's
// session agent to prove the shell is reachable (AC-D1).
type ClientOrchestrator struct {
client kubernetes.Interface
namespace string
image string
claudeCredentialsSecret string // platform Secret referenced by claude-code pods
approvalGatewaySecret string // platform Secret referenced by approval-gated helper pods
client kubernetes.Interface
namespace string
image string
claudeCredentialsSecret string // platform Secret referenced by claude-code pods
approvalGatewaySecret string // platform Secret referenced by approval-gated helper pods
miniMaxCredentialsSecret string
// AC-F5's per-session shared claim — see shared_volume.go.
sharedVolumeStorageClass string
sharedVolumeSize resource.Quantity
Expand Down Expand Up @@ -301,15 +302,16 @@ func WithReadiness(pollInterval, timeout time.Duration) Option {
// namespace (see BuildClient).
func NewClientOrchestrator(client kubernetes.Interface, namespace string, opts ...Option) *ClientOrchestrator {
o := &ClientOrchestrator{
client: client,
namespace: namespace,
image: defaultDataPlaneImage,
agentPort: AgentPort,
claudeCredentialsSecret: defaultClaudeCredentialsSecret,
approvalGatewaySecret: defaultApprovalGatewaySecret,
sharedVolumeSize: resource.MustParse(defaultSharedVolumeSize),
pollInterval: defaultPollInterval,
readyTimeout: defaultReadyTimeout,
client: client,
namespace: namespace,
image: defaultDataPlaneImage,
agentPort: AgentPort,
claudeCredentialsSecret: defaultClaudeCredentialsSecret,
approvalGatewaySecret: defaultApprovalGatewaySecret,
miniMaxCredentialsSecret: defaultMiniMaxCredentialsSecret,
sharedVolumeSize: resource.MustParse(defaultSharedVolumeSize),
pollInterval: defaultPollInterval,
readyTimeout: defaultReadyTimeout,
}
for _, opt := range opts {
opt(o)
Expand Down Expand Up @@ -619,6 +621,8 @@ func (o *ClientOrchestrator) buildPod(sessionID, checkpointRef, suffix string, w
}
// No sidecar: moving the proxy out of this pod is the whole point of
// AC-F2's arrangement.
case session.WorkloadTypeMiniMaxCode:
sidecars, volumes = o.miniMaxCodePod(&container, image, model)
}
if o.checkpointPrivileged && workloadType == session.WorkloadTypeShell {
// See WithCheckpointPrivileged. This makes CRIU-enabled session shells
Expand Down
Loading
Loading