You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-`cli/`: `osb` command-line client and bundled CLI skills
16
+
-`tests/`: cross-language end-to-end SDK tests
17
+
-`docs/`, `examples/`, `sandboxes/`, `oseps/`: documentation, samples, images/environments, and proposals
12
18
13
19
## Routing
14
20
15
21
- For `server/**`, or lifecycle server behavior, sandbox creation flow, or user-visible server config, read `server/AGENTS.md`.
16
22
- For `sdks/**`, or SDK generation, handwritten adapters, or cross-language SDK alignment, read `sdks/AGENTS.md`.
17
23
- For `specs/**`, or API contract, schema, or example changes, read `specs/AGENTS.md`.
24
+
- For `kubernetes/**`, or CRDs, controller behavior, task execution, Helm/Kustomize deployment, pool scheduling, pause/resume snapshots, or Kind e2e tests, read `kubernetes/AGENTS.md`.
18
25
- For cross-cutting changes spanning spec, server, and SDKs, start with `specs/AGENTS.md` and then read affected consumer guides.
26
+
- For runtime component changes under `components/**`, read the nearest `README.md` or `DEVELOPMENT.md`; keep component APIs aligned with `specs/` and SDK consumers.
27
+
- For CLI changes under `cli/**`, read `cli/README.md` and verify command help/output behavior alongside unit tests.
28
+
- For cross-language e2e tests under `tests/**`, read the language-local README and keep test assumptions aligned with current server and SDK behavior.
19
29
- For areas without a local `AGENTS.md`, use the nearest `README.md`, `DEVELOPMENT.md`, and CI workflow as the next source of truth.
20
30
31
+
## Working Principles
32
+
33
+
- Think before coding: state assumptions, surface ambiguity, and ask or push back when the request has conflicting interpretations.
34
+
- Simplicity first: implement the smallest solution that satisfies the request; avoid speculative features, one-off abstractions, and unnecessary configurability.
35
+
- Surgical changes: touch only files and lines needed for the task, match local style, and do not refactor or delete unrelated pre-existing code.
36
+
- Goal-driven execution: translate non-trivial work into verifiable success criteria, add or update focused tests when behavior changes, and loop until checks pass or blockers are clear.
37
+
21
38
## Guardrails
22
39
23
40
Always:
@@ -26,6 +43,7 @@ Always:
26
43
- Treat `specs/*` as public contract sources.
27
44
- Keep spec, implementation, SDKs, docs, examples, config, and CLI behavior aligned when user-visible behavior changes.
28
45
- When changing `specs/*`, also update or verify affected server, SDK, docs, and release outputs when practical.
46
+
- When changing CRDs or Kubernetes public behavior, update or verify generated manifests, Helm/Kustomize deployment output, server Kubernetes integration, and docs when practical.
29
47
- Prefer additive, backward-compatible changes for public interfaces.
30
48
- Regenerate derived outputs when the source-of-truth file changes.
31
49
- Update tests when behavior changes or bugs are fixed.
@@ -35,6 +53,7 @@ Always:
35
53
Ask first:
36
54
37
55
- Breaking public API, SDK, config, protocol, or CLI changes
Use this file as the Claude Code entry point for the OpenSandbox monorepo. Treat `AGENTS.md` as the canonical router and prefer the nearest local `AGENTS.md` for task-specific rules.
4
+
5
+
## Read First
6
+
7
+
- Root rules: `AGENTS.md`
8
+
- Server changes: `server/AGENTS.md`
9
+
- SDK changes: `sdks/AGENTS.md`
10
+
- Spec changes: `specs/AGENTS.md`
11
+
- Kubernetes changes: `kubernetes/AGENTS.md`
12
+
- Areas without a local `AGENTS.md`: read the nearest `README.md`, `DEVELOPMENT.md`, and relevant CI workflow.
13
+
14
+
## Repository Map
15
+
16
+
-`server/`: FastAPI lifecycle control plane, Docker/Kubernetes runtime integration, snapshot metadata, and server tests
-`cli/`: `osb` command-line client and bundled CLI skills
24
+
-`tests/`: cross-language end-to-end SDK tests
25
+
-`docs/`, `examples/`, `sandboxes/`, `oseps/`: documentation, samples, images/environments, and proposals
26
+
27
+
## Working Principles
28
+
29
+
- Think before coding: state assumptions, surface ambiguity, and ask or push back when the request has conflicting interpretations.
30
+
- Simplicity first: implement the smallest solution that satisfies the request; avoid speculative features, one-off abstractions, and unnecessary configurability.
31
+
- Surgical changes: touch only files and lines needed for the task, match local style, and do not refactor or delete unrelated pre-existing code.
32
+
- Goal-driven execution: translate non-trivial work into verifiable success criteria, add or update focused tests when behavior changes, and loop until checks pass or blockers are clear.
33
+
34
+
## Guardrails
35
+
36
+
Always:
37
+
38
+
- Keep changes focused on the user request.
39
+
- Keep spec, implementation, SDKs, docs, examples, config, CLI, and Kubernetes behavior aligned when user-visible behavior changes.
40
+
- Prefer additive, backward-compatible changes for public interfaces.
41
+
- Regenerate derived outputs when source-of-truth files change.
42
+
- Update tests when behavior changes or bugs are fixed.
43
+
- Prefer focused package/file checks before full-suite validation.
44
+
- Mention unrun or blocked verification in the final handoff.
45
+
46
+
Ask first:
47
+
48
+
- Breaking public API, SDK, config, protocol, CLI, CRD, annotation, label, Helm value, or deployment changes
49
+
- Intentional drift between a public contract and its implementation
50
+
- User-visible config or behavior changes without a clear migration story
51
+
52
+
Never:
53
+
54
+
- Edit generated output as the only fix.
55
+
- Mix unrelated component work into the same change.
56
+
- Refactor adjacent code just because it is nearby.
57
+
58
+
## Review Focus
59
+
60
+
- Prioritize breaking changes in specs, SDK interfaces, config, CLI behavior, CRDs, annotations, labels, and protocols.
61
+
- Flag protocol changes that are unnecessary, inconsistent, or hard to implement.
62
+
- Flag source-of-truth boundary violations and missing downstream updates.
63
+
- Call out missing tests and compatibility risks explicitly.
Copy file name to clipboardExpand all lines: kubernetes/AGENTS.md
+22-5Lines changed: 22 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,22 +1,25 @@
1
1
# Kubernetes AGENTS
2
2
3
-
You are working on the OpenSandbox Kubernetes operatorand task-executor. Treat CRD types and annotation contracts as public interfaces, and prefer additive, backward-compatible changes.
3
+
You are working on the OpenSandbox Kubernetes operator, snapshot controller flow, and task-executor. Treat CRD types and annotation/label contracts as public interfaces, and prefer additive, backward-compatible changes.
4
4
5
5
For detailed development setup, architecture deep-dive, coding standards, testing guide, and deployment workflows, see [DEVELOPMENT.md](./DEVELOPMENT.md).
6
6
7
7
## Scope
8
8
9
-
-`apis/`: CRD type definitions (BatchSandbox, Pool)
9
+
-`apis/`: CRD type definitions (BatchSandbox, Pool, SandboxSnapshot)
10
10
-`cmd/controller/`: controller manager entry point
11
11
-`cmd/task-executor/`: task-executor entry point
12
12
-`internal/controller/`: BatchSandbox and Pool reconcilers, allocator, eviction, update, and strategy logic
13
+
-`internal/controller/*pause*`, `internal/controller/*snapshot*`: pause/resume and rootfs snapshot reconciliation
13
14
-`internal/scheduler/`: in-process task scheduler (assigns tasks to sandbox pods)
14
15
-`internal/task-executor/`: task execution runtime (process/container), manager, and HTTP server
15
16
-`internal/utils/`: shared helpers (pod, finalizer, field index, expectations, logging)
16
17
-`pkg/client/`: generated clientset, informer, and lister
17
18
-`pkg/task-executor/`: task-executor public types and config
19
+
-`pkg/utils/`: public-ish helper contracts used by server-side Kubernetes integration
@@ -45,14 +48,17 @@ The controller communicates allocation state through annotations on BatchSandbox
45
48
46
49
-`sandbox.opensandbox.io/alloc-status`: JSON `{"pods":["pod-1","pod-2"]}` — current pod allocation
47
50
-`sandbox.opensandbox.io/alloc-release`: JSON `{"pods":["pod-3"]}` — pods released back to pool
51
+
-`sandbox.opensandbox.io/endpoints`: JSON endpoint list consumed by server-side endpoint resolution
48
52
49
-
Do not change annotation keys or JSON shapes without updating both the writer (`allocator.go`, `apis.go`) and all readers (`batchsandbox_controller.go`, `allocation_store_test.go`).
53
+
Do not change annotation keys or JSON shapes without updating both writers and all readers, including controller tests and any server-side Kubernetes integration that parses them.
-`sandbox.opensandbox.io/pool-revision`: revision hash for rolling updates
55
59
-`batch-sandbox.sandbox.opensandbox.io/pod-index`: pod index within a BatchSandbox
60
+
-`pool.opensandbox.io/evict`: marks idle pool pods for eviction
61
+
-`pool.opensandbox.io/eviction-handler`: selects pool eviction handler implementation
56
62
57
63
## Commands
58
64
@@ -129,12 +135,21 @@ cd kubernetes
129
135
make manifests generate
130
136
```
131
137
138
+
Pause/resume focused checks:
139
+
140
+
```bash
141
+
cd kubernetes
142
+
go test ./internal/controller/ -run 'Test(DispatchPauseResume|HandlePause|HandleResume|ContinueResume|CompletePause|SyncPauseOrClear|SandboxSnapshot)' -v
143
+
make test-e2e-pause-resume
144
+
```
145
+
132
146
## Architecture Overview
133
147
134
-
Two controllers run inside the controller manager:
148
+
Core reconciliation flows:
135
149
136
-
1.**BatchSandboxReconciler**: Owns Pod objects. Handles pod scaling (non-pooled mode), pool allocation parsing, task scheduling, status updates, and expiry cleanup.
150
+
1.**BatchSandboxReconciler**: Owns Pod objects. Handles pod scaling (non-pooled mode), pool allocation parsing, task scheduling, status updates, expiry cleanup, and pause/resume handoff.
137
151
2.**PoolReconciler**: Owns Pod objects and watches BatchSandbox objects. Handles pod allocation to sandboxes, pool scaling (buffer/pool min/max), rolling updates, eviction, and status.
152
+
3.**SandboxSnapshot flow**: Internal CR and commit Job orchestration used by pause/resume to persist and restore root filesystems.
Copy file name to clipboardExpand all lines: server/AGENTS.md
+24-3Lines changed: 24 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,20 +1,29 @@
1
1
# Server AGENTS
2
2
3
-
You are working on the OpenSandbox lifecycle server. Keep the route layer thin and put behavior in services, validators, or runtime helpers.
3
+
You are working on the OpenSandbox lifecycle server. Keep the route layer thin and put behavior in services, validators, repositories, or runtime helpers.
4
4
5
5
## Scope
6
6
7
7
-`opensandbox_server/**`
8
8
-`tests/**`
9
+
-`configuration.md`, `docker-compose.example.yaml`, and other server-facing docs/examples
9
10
10
11
If the task changes lifecycle API contracts in `../specs/sandbox-lifecycle.yml`, also read `../specs/AGENTS.md`.
12
+
If the task changes Kubernetes runtime behavior, also read `../kubernetes/AGENTS.md`.
11
13
12
14
## Key Paths
13
15
14
-
-`opensandbox_server/main.py`: app entry point and startup wiring
16
+
-`opensandbox_server/cli.py`: `opensandbox-server` CLI entry point and config initialization
17
+
-`opensandbox_server/main.py`: FastAPI app entry point and startup wiring
15
18
-`opensandbox_server/api/`: FastAPI routes and request/response schemas
16
19
-`opensandbox_server/services/`: business logic and runtime integration
20
+
-`opensandbox_server/services/docker/`: Docker runtime, endpoints, port allocation, diagnostics, and snapshot runtime
21
+
-`opensandbox_server/services/k8s/`: Kubernetes providers, templates, informer, egress, pool, diagnostics, and pause/resume runtime integration
22
+
-`opensandbox_server/repositories/`: persistence backends, including snapshot metadata
0 commit comments