@vesviet/agent-skills 5.6.0 → 5.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/INDEX.md +5 -5
- package/README.md +1 -1
- package/VERSION +1 -1
- package/adapters/antigravity/a2a-config.template.yaml +1 -1
- package/adapters/antigravity/role-skill-index.json +12 -12
- package/adapters/claude/CLAUDE_ADAPTER.md +1 -1
- package/adapters/cursor/README.md +185 -185
- package/bin/agent-skills.mjs +17 -14
- package/core/contracts/README.md +1 -1
- package/core/contracts/schemas/api-contract-spec.json +191 -191
- package/core/contracts/schemas/data-pipeline-spec.json +1 -1
- package/core/contracts/schemas/design-tokens-spec.json +19 -0
- package/core/contracts/schemas/feature-ticket.json +1293 -1293
- package/core/contracts/schemas/pull-request-spec.json +338 -338
- package/core/contracts/schemas/references/detailed/01-solution-and-governance.md +19 -19
- package/core/contracts/schemas/references/detailed/02-engineering-delivery.md +93 -93
- package/core/contracts/schemas/references/detailed/04-finance-accounting-and-compliance.md +54 -54
- package/core/contracts/schemas/references/detailed/05-design-and-content.md +92 -92
- package/core/contracts/schemas/references/detailed/06-seo-and-publishing.md +48 -48
- package/core/contracts/schemas/references/detailed/07-a2a-protocol.md +85 -85
- package/core/contracts/schemas/security-audit.json +143 -12
- package/core/contracts/schemas/system-design-spec.json +9 -1
- package/core/contracts/schemas/test-report.json +530 -530
- package/core/contracts/schemas/ux-flow-spec.json +66 -0
- package/core/roles/ai-systems-engineer.md +31 -18
- package/core/roles/aws-engineer.md +33 -29
- package/core/roles/backend-developer.md +6 -4
- package/core/roles/content-manager.md +7 -7
- package/core/roles/data-engineer.md +39 -36
- package/core/roles/qa-engineer.md +18 -18
- package/core/roles/references/ai-systems-engineer-review-checklist.md +11 -3
- package/core/roles/references/aws-engineer-review-checklist.md +29 -16
- package/core/roles/references/business-analyst-responsibilities.md +207 -207
- package/core/roles/references/content-manager-governance-standards.md +2 -2
- package/core/roles/references/content-manager-review-checklist.md +7 -1
- package/core/roles/references/data-engineer-review-checklist.md +11 -3
- package/core/roles/references/frontend-developer-responsibilities.md +275 -275
- package/core/roles/references/qa-engineer-review-checklist.md +10 -5
- package/core/roles/references/security-engineer-review-checklist.md +8 -0
- package/core/roles/references/solution-architect-review-checklist.md +6 -1
- package/core/roles/references/system-engineer-review-checklist.md +11 -0
- package/core/roles/references/ui-ux-designer-review-checklist.md +12 -0
- package/core/roles/security-engineer.md +35 -5
- package/core/roles/solution-architect.md +7 -7
- package/core/roles/system-engineer.md +470 -465
- package/core/roles/ui-ux-designer.md +17 -3
- package/core/skills/agent/agent-memory-compaction/references/anchored-schema-and-compaction-algorithms.md +141 -141
- package/core/skills/agent/architect-mcp-server/SKILL.md +3 -3
- package/core/skills/agent/decompose-agentic-system/SKILL.md +1 -1
- package/core/skills/ai/deploy-vllm-inference/SKILL.md +14 -14
- package/core/skills/ai-agent/agent-evaluation/SKILL.md +5 -0
- package/core/skills/ai-agent/context-optimization/SKILL.md +9 -0
- package/core/skills/backend/add-api-endpoint/SKILL.md +1 -0
- package/core/skills/backend/add-event-handler/SKILL.md +1 -0
- package/core/skills/backend/add-service-client/SKILL.md +1 -0
- package/core/skills/backend/build-mcp-server/SKILL.md +101 -100
- package/core/skills/backend/implement-auth/SKILL.md +1 -0
- package/core/skills/backend/implement-structured-outputs/SKILL.md +95 -94
- package/core/skills/backend/optimize-postgres/SKILL.md +1 -0
- package/core/skills/backend/scaffold-new-service/SKILL.md +1 -0
- package/core/skills/business/elicit-requirements/SKILL.md +102 -102
- package/core/skills/business/elicit-requirements/references/elicitation-techniques-and-babok-criteria.md +60 -60
- package/core/skills/business/trace-requirements-impact/SKILL.md +97 -97
- package/core/skills/business/trace-requirements-impact/references/rtm-graph-and-prioritization-models.md +109 -109
- package/core/skills/business/write-use-cases/SKILL.md +106 -106
- package/core/skills/business/write-use-cases/references/cockburn-scoping-and-13-field-template.md +135 -135
- package/core/skills/content/audit-content/SKILL.md +3 -2
- package/core/skills/content/audit-content/references/information-gain-rubric.md +1 -1
- package/core/skills/content/design-content-strategy/SKILL.md +6 -5
- package/core/skills/content/design-content-strategy/references/information-gain-and-decay-triage.md +2 -2
- package/core/skills/content/optimize-seo/SKILL.md +6 -5
- package/core/skills/content/optimize-seo/references/geo-ai-citation-playbook.md +2 -2
- package/core/skills/content/optimize-seo/references/process-and-checklist.md +1 -1
- package/core/skills/content/repurpose-content/SKILL.md +4 -3
- package/core/skills/content/write-article/SKILL.md +6 -5
- package/core/skills/content/write-copy/SKILL.md +3 -2
- package/core/skills/document/pptx/SKILL.md +1 -0
- package/core/skills/document/pptx/scripts/add_slide.py +0 -0
- package/core/skills/document/pptx/scripts/clean.py +0 -0
- package/core/skills/document/pptx/scripts/thumbnail.py +0 -0
- package/core/skills/document/xlsx/scripts/recalc.py +0 -0
- package/core/skills/documentation/write-documentation/SKILL.md +143 -143
- package/core/skills/documentation/write-tech-radar/SKILL.md +149 -149
- package/core/skills/foundation/accessibility-review/SKILL.md +160 -160
- package/core/skills/foundation/design-review/SKILL.md +11 -1
- package/core/skills/foundation/design-ux-flow/SKILL.md +13 -1
- package/core/skills/foundation/performance-profiling/SKILL.md +3 -1
- package/core/skills/foundation/release-notes/SKILL.md +192 -192
- package/core/skills/foundation/webapp-server-runner/scripts/with_server.py +0 -0
- package/core/skills/foundation/write-product-brief/SKILL.md +160 -160
- package/core/skills/foundation/write-tests/SKILL.md +11 -10
- package/core/skills/frontend/anti-ui-slop-finish-gate/SKILL.md +5 -0
- package/core/skills/frontend/design-md-specification/SKILL.md +1 -0
- package/core/skills/frontend/design-system-engineering/SKILL.md +4 -2
- package/core/skills/meetings-analysis/analyze-business-requirements/SKILL.md +1 -1
- package/core/skills/platform/add-telemetry-instrumentation/SKILL.md +2 -1
- package/core/skills/platform/aws-infrastructure/SKILL.md +12 -11
- package/core/skills/platform/cloudflare-email-service/SKILL.md +166 -166
- package/core/skills/platform/cloudflare-email-service/references/routing.md +199 -199
- package/core/skills/platform/debug-runtime-platform/SKILL.md +1 -0
- package/core/skills/platform/debug-workers-edge/SKILL.md +111 -111
- package/core/skills/platform/sandbox-sdk/SKILL.md +183 -183
- package/core/skills/platform/setup-gpu-finops/SKILL.md +111 -107
- package/core/skills/platform/setup-llm-gateway/SKILL.md +110 -108
- package/core/skills/platform/supply-chain-security/SKILL.md +1 -0
- package/core/skills/platform/system-design/SKILL.md +7 -0
- package/core/skills/platform/turnstile-spin/SKILL.md +118 -118
- package/core/skills/platform/turnstile-spin/scripts/auth-probe.sh +0 -0
- package/core/skills/platform/turnstile-spin/scripts/fetch-secret.sh +0 -0
- package/core/skills/platform/turnstile-spin/scripts/persist-skill.sh +0 -0
- package/core/skills/platform/turnstile-spin/scripts/validate.sh +0 -0
- package/core/skills/platform/turnstile-spin/scripts/widget-create.sh +0 -0
- package/core/skills/platform/turnstile-spin/scripts/worker-deploy.sh +0 -0
- package/core/skills/platform/turnstile-spin/templates/worker/src/index.ts +199 -199
- package/core/skills/platform/turnstile-spin/templates/worker/wrangler.toml +31 -31
- package/core/skills/platform/web-perf/SKILL.md +151 -151
- package/core/skills/platform/workers-best-practices/references/rules.md +463 -463
- package/core/skills/product/build-story-map/SKILL.md +104 -104
- package/core/skills/product/build-story-map/references/story-mapping-and-cpm-scheduling.md +101 -101
- package/core/skills/product/define-product-strategy/SKILL.md +105 -105
- package/core/skills/product/define-product-strategy/references/strategy-frameworks-and-pr-faq.md +142 -142
- package/core/skills/product/model-saas-metrics/SKILL.md +104 -104
- package/core/skills/product/model-saas-metrics/references/saas-unit-economics-and-pricing.md +110 -110
- package/core/skills/product/prioritize-roadmap/SKILL.md +106 -106
- package/core/skills/product/prioritize-roadmap/references/prioritization-scoring-and-kill-criteria.md +105 -105
- package/core/skills/repo-ops/commit-code/SKILL.md +190 -190
- package/core/skills/repo-ops/commit-code/references/multi-repo-and-deployment.md +21 -21
- package/core/skills/repo-ops/navigate-service/SKILL.md +199 -199
- package/core/skills/repo-ops/review-code/references/process-and-format.md +100 -100
- package/core/skills/repo-ops/review-service/SKILL.md +186 -186
- package/core/skills/repo-ops/troubleshoot-service/SKILL.md +127 -127
- package/core/skills/repo-ops/troubleshoot-service/references/failure-modes-and-security.md +22 -22
- package/core/skills/repo-ops/troubleshoot-service/references/suggested-process.md +110 -110
- package/core/skills/security-data/build-data-pipeline/SKILL.md +15 -14
- package/core/skills/security-data/build-data-pipeline/references/producer-contracts-and-lakehouse.md +5 -5
- package/core/skills/security-data/database-maintenance/SKILL.md +1 -0
- package/core/skills/security-data/database-maintenance/references/relational-and-vector-maintenance.md +5 -5
- package/core/skills/security-data/manage-secrets/SKILL.md +3 -0
- package/core/skills/security-data/optimize-olap-database/SKILL.md +14 -13
- package/core/skills/security-data/optimize-olap-database/references/olap-database-guide.md +2 -2
- package/core/skills/security-data/prompt-injection-defense/SKILL.md +3 -0
- package/core/skills/security-data/query-analytical-engine/SKILL.md +8 -7
- package/core/skills/security-data/query-analytical-engine/references/analytical-query-guide.md +3 -3
- package/core/skills/security-data/security-audit/SKILL.md +126 -119
- package/core/workflows/add-new-feature.md +212 -212
- package/core/workflows/agent-a2a-delegation.md +142 -142
- package/core/workflows/bug-fix.md +147 -147
- package/core/workflows/build-deploy.md +208 -208
- package/core/workflows/code-review.md +137 -137
- package/core/workflows/curriculum-delivery.md +1 -1
- package/core/workflows/dependency-upgrade.md +193 -193
- package/core/workflows/feature-delivery.md +149 -149
- package/core/workflows/hotfix-production.md +172 -172
- package/core/workflows/qa-validation.md +231 -231
- package/core/workflows/refactoring.md +154 -154
- package/core/workflows/revert-deployment.md +147 -147
- package/core/workflows/security-incident-response.md +191 -191
- package/core/workflows/seo-content-lifecycle.md +91 -91
- package/core/workflows/service-review-release.md +223 -223
- package/core/workflows/setup-new-service.md +214 -214
- package/core/workflows/tech-repo-review.md +245 -245
- package/core/workflows/troubleshooting.md +241 -241
- package/overlays/astro-cloudflare/README.md +93 -93
- package/overlays/data-analyst-stack/README.md +109 -109
- package/overlays/data-analyst-stack/rules/metric-dashboard-templates.md +135 -135
- package/overlays/data-analyst-stack/rules/stack-conventions.md +80 -80
- package/overlays/ecommerce-microservices/README.md +65 -65
- package/overlays/go-microservices/README.md +78 -78
- package/overlays/go-microservices/rules/go-conventions.md +223 -223
- package/overlays/laravel-filament/README.md +90 -90
- package/overlays/laravel-filament/rules/laravel-conventions.md +220 -220
- package/overlays/laravel-filament/skills/develop-laravel-feature/SKILL.md +141 -141
- package/overlays/laravel-filament/workflows/deploy-laravel.md +133 -133
- package/overlays/obj-configurator/rules/obj-project-rules.md +111 -111
- package/overlays/obj-configurator/skills/develop-obj-feature/SKILL.md +71 -71
- package/overlays/r3f-stack/README.md +89 -89
- package/overlays/r3f-stack/rules/stub.md +43 -43
- package/overlays/r3f-stack/skills/debug-3d-scene/SKILL.md +166 -166
- package/overlays/r3f-stack/skills/integrate-r3f-three-legacy/SKILL.md +159 -159
- package/overlays/r3f-stack/skills/optimize-3d-assets/SKILL.md +128 -128
- package/overlays/seo-publishing/rules/site-mix-and-cannibalization.md +52 -52
- package/overlays/ui-design-system/rules/handoff-conventions.md +73 -73
- package/package.json +2 -2
- package/core/README.md +0 -53
|
@@ -1,183 +1,183 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: sandbox-sdk
|
|
3
|
-
description: Builds secure, isolated code execution environments on Cloudflare Workers using the Cloudflare Sandbox SDK — enabling AI code interpreters, interactive dev environments, and sandboxed application runtimes. Use when implementing LLM-generated code execution, user-submitted script running, or any scenario requiring isolated compute with file system access on the Cloudflare edge.
|
|
4
|
-
allowed-tools: [read_file, write_file, edit_file, create_file, search_code, run_tests, run_linter, run_build, wrangler_deploy, execute_command]
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
# Sandbox SDK
|
|
8
|
-
|
|
9
|
-
Build secure, isolated code execution environments on Cloudflare Workers.
|
|
10
|
-
|
|
11
|
-
## When to Use
|
|
12
|
-
|
|
13
|
-
- running LLM-generated code in isolation
|
|
14
|
-
- executing user-submitted scripts safely
|
|
15
|
-
- needing sandboxed compute with file access on edge
|
|
16
|
-
- building an AI code interpreter / dev environment
|
|
17
|
-
|
|
18
|
-
## Core Rules
|
|
19
|
-
- Do NOT use internal clients (`CommandClient`, `FileClient`) - use standard `sandbox.*` wrapper methods.
|
|
20
|
-
- The Worker entrypoint script MUST explicitly include `export { Sandbox } from '@cloudflare/sandbox'`.
|
|
21
|
-
- Do not skip `destroy()` calls on temporary sandboxes to avoid resource leaks.
|
|
22
|
-
- Keep container images lean in the Dockerfile to optimize startup and prevent cold start latency.
|
|
23
|
-
- Always set explicit resource limits including `timeout_ms` (up to 30,000 ms), `memory_mb`, and `cpu_ms` on every sandbox invocation to prevent unbounded execution.
|
|
24
|
-
- Manage network isolation by routing necessary sandboxed network requests through the Worker's allowed callback pattern using the `env.SANDBOX` binding.
|
|
25
|
-
- Adhere to overarching policy `core/policies/execution-sandbox.md` (Tier 4 Managed Cloud Sandbox) for universal resource quotas and containment standards.
|
|
26
|
-
|
|
27
|
-
## Retrieval Sources
|
|
28
|
-
|
|
29
|
-
Your knowledge of the Sandbox SDK may be outdated. **Prefer retrieval over pre-training** for any Sandbox SDK task.
|
|
30
|
-
|
|
31
|
-
| Resource | URL |
|
|
32
|
-
|----------|-----|
|
|
33
|
-
| Docs | https://developers.cloudflare.com/sandbox/ |
|
|
34
|
-
| API Reference | https://developers.cloudflare.com/sandbox/api/ |
|
|
35
|
-
| Examples | https://github.com/cloudflare/sandbox-sdk/tree/main/examples |
|
|
36
|
-
| Get Started | https://developers.cloudflare.com/sandbox/get-started/ |
|
|
37
|
-
|
|
38
|
-
When implementing features, fetch the relevant doc page or example first.
|
|
39
|
-
|
|
40
|
-
## Required Configuration
|
|
41
|
-
|
|
42
|
-
**wrangler.jsonc** (exact - do not modify structure):
|
|
43
|
-
|
|
44
|
-
```jsonc
|
|
45
|
-
{
|
|
46
|
-
"containers": [{
|
|
47
|
-
"class_name": "Sandbox",
|
|
48
|
-
"image": "./Dockerfile",
|
|
49
|
-
"instance_type": "lite",
|
|
50
|
-
"max_instances": 1
|
|
51
|
-
}],
|
|
52
|
-
"durable_objects": {
|
|
53
|
-
"bindings": [{ "class_name": "Sandbox", "name": "Sandbox" }]
|
|
54
|
-
},
|
|
55
|
-
"migrations": [{ "new_sqlite_classes": ["Sandbox"], "tag": "v1" }]
|
|
56
|
-
}
|
|
57
|
-
```
|
|
58
|
-
|
|
59
|
-
**Worker entry** - must re-export Sandbox class:
|
|
60
|
-
|
|
61
|
-
```typescript
|
|
62
|
-
import { getSandbox } from '@cloudflare/sandbox';
|
|
63
|
-
export { Sandbox } from '@cloudflare/sandbox'; // Required export
|
|
64
|
-
```
|
|
65
|
-
|
|
66
|
-
## Quick Reference
|
|
67
|
-
|
|
68
|
-
| Task | Method |
|
|
69
|
-
|------|--------|
|
|
70
|
-
| Get sandbox | `getSandbox(env.Sandbox, 'user-123')` |
|
|
71
|
-
| Run command | `await sandbox.exec('python script.py')` |
|
|
72
|
-
| Run code (interpreter) | `await sandbox.runCode(code, { language: 'python' })` |
|
|
73
|
-
| Write file | `await sandbox.writeFile('/workspace/app.py', content)` |
|
|
74
|
-
| Read file | `await sandbox.readFile('/workspace/app.py')` |
|
|
75
|
-
| Create directory | `await sandbox.mkdir('/workspace/src', { recursive: true })` |
|
|
76
|
-
| List files | `await sandbox.listFiles('/workspace')` |
|
|
77
|
-
| Expose port | `await sandbox.exposePort(8080)` |
|
|
78
|
-
| Destroy | `await sandbox.destroy()` |
|
|
79
|
-
|
|
80
|
-
## Core Patterns
|
|
81
|
-
|
|
82
|
-
### Execute Commands
|
|
83
|
-
|
|
84
|
-
```typescript
|
|
85
|
-
const sandbox = getSandbox(env.Sandbox, 'user-123');
|
|
86
|
-
const result = await sandbox.exec('python --version');
|
|
87
|
-
// result: { stdout, stderr, exitCode, success }
|
|
88
|
-
```
|
|
89
|
-
|
|
90
|
-
### Code Interpreter (Recommended for AI)
|
|
91
|
-
|
|
92
|
-
Use `runCode()` for executing LLM-generated code with rich outputs:
|
|
93
|
-
|
|
94
|
-
```typescript
|
|
95
|
-
const ctx = await sandbox.createCodeContext({ language: 'python' });
|
|
96
|
-
|
|
97
|
-
await sandbox.runCode('import pandas as pd; data = [1,2,3]', { context: ctx });
|
|
98
|
-
const result = await sandbox.runCode('sum(data)', { context: ctx });
|
|
99
|
-
// result.results[0].text = "6"
|
|
100
|
-
```
|
|
101
|
-
|
|
102
|
-
**Languages**: `python`, `javascript`, `typescript`
|
|
103
|
-
|
|
104
|
-
State persists within context. Create explicit contexts for production.
|
|
105
|
-
|
|
106
|
-
### File Operations
|
|
107
|
-
|
|
108
|
-
```typescript
|
|
109
|
-
await sandbox.mkdir('/workspace/project', { recursive: true });
|
|
110
|
-
await sandbox.writeFile('/workspace/project/main.py', code);
|
|
111
|
-
const file = await sandbox.readFile('/workspace/project/main.py');
|
|
112
|
-
const files = await sandbox.listFiles('/workspace/project');
|
|
113
|
-
```
|
|
114
|
-
|
|
115
|
-
## Suggested Process
|
|
116
|
-
1. Verify prerequisites by running `docker info` to ensure daemon availability.
|
|
117
|
-
2. Initialize container layouts and configure wrangler.jsonc containers binding block.
|
|
118
|
-
3. Establish custom workspace directories and write required scripts in the container volume.
|
|
119
|
-
4. Call `runCode` or `exec` to run isolated computations inside the sandbox.
|
|
120
|
-
5. Invoke `destroy` on the active sandbox instance to free server resources.
|
|
121
|
-
|
|
122
|
-
### 2026: Resource Constraints and Network Routing
|
|
123
|
-
|
|
124
|
-
- **Resource Limit Configuration**: Secure your sandbox environments by setting strict limits on sandbox execution. Configure `timeout_ms` (capped at a maximum of `30000` ms), `memory_mb`, and `cpu_ms` during execution. Never execute untrusted code without these bounds.
|
|
125
|
-
```typescript
|
|
126
|
-
const result = await sandbox.runCode(code, {
|
|
127
|
-
language: 'python',
|
|
128
|
-
limits: {
|
|
129
|
-
timeout_ms: 15000,
|
|
130
|
-
memory_mb: 256,
|
|
131
|
-
cpu_ms: 5000
|
|
132
|
-
}
|
|
133
|
-
});
|
|
134
|
-
```
|
|
135
|
-
- **Network Isolation and Callbacks**: Cloudflare Sandbox features full network isolation by default, blocking direct internet access. When external requests are necessary (e.g. API access), configure and route them through the allowed host callback pattern via `env.SANDBOX`.
|
|
136
|
-
```typescript
|
|
137
|
-
const sandbox = getSandbox(env.Sandbox, 'isolated-network-env', {
|
|
138
|
-
callbacks: {
|
|
139
|
-
fetch: async (request) => {
|
|
140
|
-
const url = new URL(request.url);
|
|
141
|
-
if (allowedDomains.has(url.hostname)) {
|
|
142
|
-
return await fetch(request);
|
|
143
|
-
}
|
|
144
|
-
return new Response('Blocked by network isolation policy', { status: 403 });
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
});
|
|
148
|
-
```
|
|
149
|
-
|
|
150
|
-
## Checklist
|
|
151
|
-
- [ ] Sandbox SDK package is installed and Docker is operational.
|
|
152
|
-
- [ ] Wrangler config declares the containers block and matching DO migration.
|
|
153
|
-
- [ ] Worker code includes the explicit export statement for Sandbox class.
|
|
154
|
-
- [ ] Code interpreter context is correctly initialized.
|
|
155
|
-
- [ ] Sandbox instances are cleaned up or destroyed after operations.
|
|
156
|
-
- [ ] Explicit resource limits (`timeout_ms`, `memory_mb`, `cpu_ms`) are configured for sandbox executions.
|
|
157
|
-
- [ ] Network isolation is managed securely, routing necessary fetches through the allowed host callback via `env.SANDBOX`.
|
|
158
|
-
|
|
159
|
-
## Failure Modes
|
|
160
|
-
|
|
161
|
-
- **Sandbox input not validated**: a sandbox runs untrusted input without schema validation. **Mitigation:** validate every input against the declared `inputSchema` before dispatch; reject inputs that fail validation.
|
|
162
|
-
- **Sandbox network policy too broad**: a sandbox can reach the public internet. **Mitigation:** enforce the least-privilege network policy; reject sandboxes that egress to untrusted domains.
|
|
163
|
-
- **Sandbox resource limits unset**: a sandbox runs without CPU or memory limits. **Mitigation:** enforce the default resource limits at the orchestrator; reject sandboxes without limits.
|
|
164
|
-
- **Sandbox output not classified**: a sandbox emits output without a `data-classification` tag. **Mitigation:** require a classification tag on every sandbox output; reject unclassified output.
|
|
165
|
-
|
|
166
|
-
## Output Contracts
|
|
167
|
-
|
|
168
|
-
When this skill is invoked as part of a coordinated multi-role delivery, emit:
|
|
169
|
-
|
|
170
|
-
- **contracts/schemas/deployment-plan.json** — Required fields: infrastructure_changes[], config_updates[], and validation_run. Set produced_by_role to the emitting developer role.
|
|
171
|
-
|
|
172
|
-
Skip emission for solo refactor work where no downstream handoff is expected.
|
|
173
|
-
|
|
174
|
-
## Security Guardrails (OWASP ASI)
|
|
175
|
-
|
|
176
|
-
- **ASI04 Supply Chain**: Sandbox SDK and container runtime versions must be schema-validated against the expected manifest; treat unknown versions as untrusted.
|
|
177
|
-
- **ASI05 RCE Guard**: never construct sandbox inputs, container commands, or network policy from external content without strict schema validation; align with `core/policies/execution-sandbox.md`.
|
|
178
|
-
- **ASI07 Inter-Agent Communication**: the sandbox contract is consumed by Cloudflare Engineer and DevOps; emit a structured contract so each role can validate the rollout.
|
|
179
|
-
- **ASI09 Human-Agent Trust Exploitation**: do not present a sandbox as "secure" without the network isolation and container hardening evidence; surface the residual risk honestly.
|
|
180
|
-
|
|
181
|
-
## Related Skills
|
|
182
|
-
- **wrangler**: Deploy containers bindings and monitor edge variables.
|
|
183
|
-
- **debug-workers-edge**: Diagnose runtime execution issues on Cloudflare.
|
|
1
|
+
---
|
|
2
|
+
name: sandbox-sdk
|
|
3
|
+
description: Builds secure, isolated code execution environments on Cloudflare Workers using the Cloudflare Sandbox SDK — enabling AI code interpreters, interactive dev environments, and sandboxed application runtimes. Use when implementing LLM-generated code execution, user-submitted script running, or any scenario requiring isolated compute with file system access on the Cloudflare edge.
|
|
4
|
+
allowed-tools: [read_file, write_file, edit_file, create_file, search_code, run_tests, run_linter, run_build, wrangler_deploy, execute_command]
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Sandbox SDK
|
|
8
|
+
|
|
9
|
+
Build secure, isolated code execution environments on Cloudflare Workers.
|
|
10
|
+
|
|
11
|
+
## When to Use
|
|
12
|
+
|
|
13
|
+
- running LLM-generated code in isolation
|
|
14
|
+
- executing user-submitted scripts safely
|
|
15
|
+
- needing sandboxed compute with file access on edge
|
|
16
|
+
- building an AI code interpreter / dev environment
|
|
17
|
+
|
|
18
|
+
## Core Rules
|
|
19
|
+
- Do NOT use internal clients (`CommandClient`, `FileClient`) - use standard `sandbox.*` wrapper methods.
|
|
20
|
+
- The Worker entrypoint script MUST explicitly include `export { Sandbox } from '@cloudflare/sandbox'`.
|
|
21
|
+
- Do not skip `destroy()` calls on temporary sandboxes to avoid resource leaks.
|
|
22
|
+
- Keep container images lean in the Dockerfile to optimize startup and prevent cold start latency.
|
|
23
|
+
- Always set explicit resource limits including `timeout_ms` (up to 30,000 ms), `memory_mb`, and `cpu_ms` on every sandbox invocation to prevent unbounded execution.
|
|
24
|
+
- Manage network isolation by routing necessary sandboxed network requests through the Worker's allowed callback pattern using the `env.SANDBOX` binding.
|
|
25
|
+
- Adhere to overarching policy `core/policies/execution-sandbox.md` (Tier 4 Managed Cloud Sandbox) for universal resource quotas and containment standards.
|
|
26
|
+
|
|
27
|
+
## Retrieval Sources
|
|
28
|
+
|
|
29
|
+
Your knowledge of the Sandbox SDK may be outdated. **Prefer retrieval over pre-training** for any Sandbox SDK task.
|
|
30
|
+
|
|
31
|
+
| Resource | URL |
|
|
32
|
+
|----------|-----|
|
|
33
|
+
| Docs | https://developers.cloudflare.com/sandbox/ |
|
|
34
|
+
| API Reference | https://developers.cloudflare.com/sandbox/api/ |
|
|
35
|
+
| Examples | https://github.com/cloudflare/sandbox-sdk/tree/main/examples |
|
|
36
|
+
| Get Started | https://developers.cloudflare.com/sandbox/get-started/ |
|
|
37
|
+
|
|
38
|
+
When implementing features, fetch the relevant doc page or example first.
|
|
39
|
+
|
|
40
|
+
## Required Configuration
|
|
41
|
+
|
|
42
|
+
**wrangler.jsonc** (exact - do not modify structure):
|
|
43
|
+
|
|
44
|
+
```jsonc
|
|
45
|
+
{
|
|
46
|
+
"containers": [{
|
|
47
|
+
"class_name": "Sandbox",
|
|
48
|
+
"image": "./Dockerfile",
|
|
49
|
+
"instance_type": "lite",
|
|
50
|
+
"max_instances": 1
|
|
51
|
+
}],
|
|
52
|
+
"durable_objects": {
|
|
53
|
+
"bindings": [{ "class_name": "Sandbox", "name": "Sandbox" }]
|
|
54
|
+
},
|
|
55
|
+
"migrations": [{ "new_sqlite_classes": ["Sandbox"], "tag": "v1" }]
|
|
56
|
+
}
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
**Worker entry** - must re-export Sandbox class:
|
|
60
|
+
|
|
61
|
+
```typescript
|
|
62
|
+
import { getSandbox } from '@cloudflare/sandbox';
|
|
63
|
+
export { Sandbox } from '@cloudflare/sandbox'; // Required export
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## Quick Reference
|
|
67
|
+
|
|
68
|
+
| Task | Method |
|
|
69
|
+
|------|--------|
|
|
70
|
+
| Get sandbox | `getSandbox(env.Sandbox, 'user-123')` |
|
|
71
|
+
| Run command | `await sandbox.exec('python script.py')` |
|
|
72
|
+
| Run code (interpreter) | `await sandbox.runCode(code, { language: 'python' })` |
|
|
73
|
+
| Write file | `await sandbox.writeFile('/workspace/app.py', content)` |
|
|
74
|
+
| Read file | `await sandbox.readFile('/workspace/app.py')` |
|
|
75
|
+
| Create directory | `await sandbox.mkdir('/workspace/src', { recursive: true })` |
|
|
76
|
+
| List files | `await sandbox.listFiles('/workspace')` |
|
|
77
|
+
| Expose port | `await sandbox.exposePort(8080)` |
|
|
78
|
+
| Destroy | `await sandbox.destroy()` |
|
|
79
|
+
|
|
80
|
+
## Core Patterns
|
|
81
|
+
|
|
82
|
+
### Execute Commands
|
|
83
|
+
|
|
84
|
+
```typescript
|
|
85
|
+
const sandbox = getSandbox(env.Sandbox, 'user-123');
|
|
86
|
+
const result = await sandbox.exec('python --version');
|
|
87
|
+
// result: { stdout, stderr, exitCode, success }
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
### Code Interpreter (Recommended for AI)
|
|
91
|
+
|
|
92
|
+
Use `runCode()` for executing LLM-generated code with rich outputs:
|
|
93
|
+
|
|
94
|
+
```typescript
|
|
95
|
+
const ctx = await sandbox.createCodeContext({ language: 'python' });
|
|
96
|
+
|
|
97
|
+
await sandbox.runCode('import pandas as pd; data = [1,2,3]', { context: ctx });
|
|
98
|
+
const result = await sandbox.runCode('sum(data)', { context: ctx });
|
|
99
|
+
// result.results[0].text = "6"
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
**Languages**: `python`, `javascript`, `typescript`
|
|
103
|
+
|
|
104
|
+
State persists within context. Create explicit contexts for production.
|
|
105
|
+
|
|
106
|
+
### File Operations
|
|
107
|
+
|
|
108
|
+
```typescript
|
|
109
|
+
await sandbox.mkdir('/workspace/project', { recursive: true });
|
|
110
|
+
await sandbox.writeFile('/workspace/project/main.py', code);
|
|
111
|
+
const file = await sandbox.readFile('/workspace/project/main.py');
|
|
112
|
+
const files = await sandbox.listFiles('/workspace/project');
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
## Suggested Process
|
|
116
|
+
1. Verify prerequisites by running `docker info` to ensure daemon availability.
|
|
117
|
+
2. Initialize container layouts and configure wrangler.jsonc containers binding block.
|
|
118
|
+
3. Establish custom workspace directories and write required scripts in the container volume.
|
|
119
|
+
4. Call `runCode` or `exec` to run isolated computations inside the sandbox.
|
|
120
|
+
5. Invoke `destroy` on the active sandbox instance to free server resources.
|
|
121
|
+
|
|
122
|
+
### 2026: Resource Constraints and Network Routing
|
|
123
|
+
|
|
124
|
+
- **Resource Limit Configuration**: Secure your sandbox environments by setting strict limits on sandbox execution. Configure `timeout_ms` (capped at a maximum of `30000` ms), `memory_mb`, and `cpu_ms` during execution. Never execute untrusted code without these bounds.
|
|
125
|
+
```typescript
|
|
126
|
+
const result = await sandbox.runCode(code, {
|
|
127
|
+
language: 'python',
|
|
128
|
+
limits: {
|
|
129
|
+
timeout_ms: 15000,
|
|
130
|
+
memory_mb: 256,
|
|
131
|
+
cpu_ms: 5000
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
```
|
|
135
|
+
- **Network Isolation and Callbacks**: Cloudflare Sandbox features full network isolation by default, blocking direct internet access. When external requests are necessary (e.g. API access), configure and route them through the allowed host callback pattern via `env.SANDBOX`.
|
|
136
|
+
```typescript
|
|
137
|
+
const sandbox = getSandbox(env.Sandbox, 'isolated-network-env', {
|
|
138
|
+
callbacks: {
|
|
139
|
+
fetch: async (request) => {
|
|
140
|
+
const url = new URL(request.url);
|
|
141
|
+
if (allowedDomains.has(url.hostname)) {
|
|
142
|
+
return await fetch(request);
|
|
143
|
+
}
|
|
144
|
+
return new Response('Blocked by network isolation policy', { status: 403 });
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
## Checklist
|
|
151
|
+
- [ ] Sandbox SDK package is installed and Docker is operational.
|
|
152
|
+
- [ ] Wrangler config declares the containers block and matching DO migration.
|
|
153
|
+
- [ ] Worker code includes the explicit export statement for Sandbox class.
|
|
154
|
+
- [ ] Code interpreter context is correctly initialized.
|
|
155
|
+
- [ ] Sandbox instances are cleaned up or destroyed after operations.
|
|
156
|
+
- [ ] Explicit resource limits (`timeout_ms`, `memory_mb`, `cpu_ms`) are configured for sandbox executions.
|
|
157
|
+
- [ ] Network isolation is managed securely, routing necessary fetches through the allowed host callback via `env.SANDBOX`.
|
|
158
|
+
|
|
159
|
+
## Failure Modes
|
|
160
|
+
|
|
161
|
+
- **Sandbox input not validated**: a sandbox runs untrusted input without schema validation. **Mitigation:** validate every input against the declared `inputSchema` before dispatch; reject inputs that fail validation.
|
|
162
|
+
- **Sandbox network policy too broad**: a sandbox can reach the public internet. **Mitigation:** enforce the least-privilege network policy; reject sandboxes that egress to untrusted domains.
|
|
163
|
+
- **Sandbox resource limits unset**: a sandbox runs without CPU or memory limits. **Mitigation:** enforce the default resource limits at the orchestrator; reject sandboxes without limits.
|
|
164
|
+
- **Sandbox output not classified**: a sandbox emits output without a `data-classification` tag. **Mitigation:** require a classification tag on every sandbox output; reject unclassified output.
|
|
165
|
+
|
|
166
|
+
## Output Contracts
|
|
167
|
+
|
|
168
|
+
When this skill is invoked as part of a coordinated multi-role delivery, emit:
|
|
169
|
+
|
|
170
|
+
- **contracts/schemas/deployment-plan.json** — Required fields: infrastructure_changes[], config_updates[], and validation_run. Set produced_by_role to the emitting developer role.
|
|
171
|
+
|
|
172
|
+
Skip emission for solo refactor work where no downstream handoff is expected.
|
|
173
|
+
|
|
174
|
+
## Security Guardrails (OWASP ASI)
|
|
175
|
+
|
|
176
|
+
- **ASI04 Supply Chain**: Sandbox SDK and container runtime versions must be schema-validated against the expected manifest; treat unknown versions as untrusted.
|
|
177
|
+
- **ASI05 RCE Guard**: never construct sandbox inputs, container commands, or network policy from external content without strict schema validation; align with `core/policies/execution-sandbox.md`.
|
|
178
|
+
- **ASI07 Inter-Agent Communication**: the sandbox contract is consumed by Cloudflare Engineer and DevOps; emit a structured contract so each role can validate the rollout.
|
|
179
|
+
- **ASI09 Human-Agent Trust Exploitation**: do not present a sandbox as "secure" without the network isolation and container hardening evidence; surface the residual risk honestly.
|
|
180
|
+
|
|
181
|
+
## Related Skills
|
|
182
|
+
- **wrangler**: Deploy containers bindings and monitor edge variables.
|
|
183
|
+
- **debug-workers-edge**: Diagnose runtime execution issues on Cloudflare.
|
|
@@ -1,107 +1,111 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: setup-gpu-finops
|
|
3
|
-
description: Configure GPU telemetry, DCGM metrics, and Kubecost to attribute AI compute costs to specific namespaces or teams. Use when managing GPU infrastructure budgets, tracking AI workload unit economics, or optimizing accelerator capacity.
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
- **
|
|
15
|
-
- **
|
|
16
|
-
- **
|
|
17
|
-
- **
|
|
18
|
-
- **
|
|
19
|
-
- **
|
|
20
|
-
- **
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
- **
|
|
79
|
-
- **
|
|
80
|
-
- **
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
- **
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
- **
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
- [ ]
|
|
97
|
-
- [ ]
|
|
98
|
-
- [ ]
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
- **setup-
|
|
107
|
-
- **
|
|
1
|
+
---
|
|
2
|
+
name: setup-gpu-finops
|
|
3
|
+
description: Configure GPU telemetry, DCGM metrics, and Kubecost to attribute AI compute costs to specific namespaces or teams. Use when managing GPU infrastructure budgets, tracking AI workload unit economics, or optimizing accelerator capacity.
|
|
4
|
+
version: 2.0.0
|
|
5
|
+
allowed-tools: [read_file, write_file, edit_file, create_file, search_code, run_tests, run_linter, run_build, execute_command]
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Setup GPU FinOps
|
|
9
|
+
|
|
10
|
+
Use this skill to implement cost transparency for self-hosted AI models and GPU workloads in Kubernetes clusters.
|
|
11
|
+
|
|
12
|
+
## Core Rules
|
|
13
|
+
|
|
14
|
+
- **DCGM Integration**: Deploy the NVIDIA DCGM Exporter to expose low-level GPU metrics (utilization, memory, power) to Prometheus.
|
|
15
|
+
- **Namespace Attribution**: Use Kubecost (or OpenCost) custom pricing sheets to map GPU node costs down to the pod and namespace level.
|
|
16
|
+
- **Idle Optimization**: Implement KEDA (Kubernetes Event-driven Autoscaling) or Karpenter to scale GPU nodes to zero when inference queues are empty.
|
|
17
|
+
- **Alerting**: Configure Slack/PagerDuty alerts for teams exceeding their daily GPU compute budget.
|
|
18
|
+
- **Metric Standardization**: Normalize GPU metric names with `hw.gpu.*` prefixes via OpenTelemetry Collector processors.
|
|
19
|
+
- **MIG-MULTI-TENANT-ISOLATION**: For H100/A100/B200, configure NVIDIA MIG (Multi-Instance GPU) partitions to provide hardware-level isolation between teams sharing the same physical GPU — enforces memory and compute boundaries and prevents one tenant's OOM from affecting another's inference workload.
|
|
20
|
+
- **KEDA-INFERENCE-AUTOSCALING**: Deploy KEDA ScaledObjects driven by vLLM or Triton inference queue depth metrics to scale model replicas to zero when queues are empty for >15 minutes — configure `cooldownPeriod: 900s` to prevent flapping.
|
|
21
|
+
- **VLLM-APC-COST**: Enable vLLM v0.6+ Automatic Prefix Caching (APC) to reuse KV cache for repeated system prompts; structure prompts with static content first and dynamic user content last for maximum cache hit rate — reduces GPU compute cost by 20-60% for high-traffic repeated-context workloads.
|
|
22
|
+
- **KV-CACHE-OFFLOAD-COST (2026)**: for agentic and long-context workloads, extend KV cache into CPU RAM / storage tiers (vLLM-SGLang offloading, NVIDIA ICMS, storage-backed KV) before scaling GPU count — offloaded KV turns idle GPU VRAM back into serving capacity; price the tiers separately in cost dashboards.
|
|
23
|
+
- **SPECULATIVE-DECODING-THROUGHPUT (2026)**: EAGLE-3 / MTP draft models deliver up to 6.5x decode throughput on supported stacks (vLLM, SGLang; TPU support since 2026-10) — model the throughput-per-dollar gain using measured draft acceptance rate, and treat acceptance < ~70% as a net loss.
|
|
24
|
+
- **RACK-SCALE-PRICING (2026)**: maintain pricing sheets for rack-scale Blackwell systems (GB300 NVL72: 72 GPUs, ~278GB HBM3e each, NVLink-pooled domain) with per-GPU fractional allocation math; track the Vera Rubin roadmap for refresh depreciation windows.
|
|
25
|
+
|
|
26
|
+
## Suggested Process
|
|
27
|
+
|
|
28
|
+
### 1. Deploy NVIDIA DCGM Exporter DaemonSet
|
|
29
|
+
|
|
30
|
+
Install hardware telemetry infrastructure:
|
|
31
|
+
- Deploy the NVIDIA DCGM (Data Center GPU Manager) Exporter as a DaemonSet across GPU-enabled Kubernetes nodes.
|
|
32
|
+
- Configure profiling metrics: GPU utilization (`DCGM_FI_DEV_GPU_UTIL`), framebuffer memory used (`DCGM_FI_DEV_FB_USED`), and power draw (`DCGM_FI_DEV_POWER_USAGE`).
|
|
33
|
+
- Verify the exporter exposes Prometheus metrics on port 9400.
|
|
34
|
+
|
|
35
|
+
### 2. Configure Prometheus Metric Scraping & Relabeling
|
|
36
|
+
|
|
37
|
+
Wire metrics into the monitoring cluster:
|
|
38
|
+
- Add a Prometheus `PodMonitor` or `ServiceMonitor` targeting DCGM exporter endpoints.
|
|
39
|
+
- Configure metric relabeling rules to attach Kubernetes pod, namespace, model name, and node group labels.
|
|
40
|
+
- Set up an OpenTelemetry Collector pipeline to transform and export metrics with standardized `hw.gpu.*` naming conventions.
|
|
41
|
+
|
|
42
|
+
### 3. Integrate Kubecost / OpenCost Pricing Sheets
|
|
43
|
+
|
|
44
|
+
Configure cost allocation models:
|
|
45
|
+
- Define custom GPU pricing tables in Kubecost/OpenCost reflecting cloud provider or on-premise hourly rates per accelerator type (A100, H100, L4, T4).
|
|
46
|
+
- Configure allocation algorithms to split node base cost by fractional GPU sharing (MIG or time-slicing) when multiple pods share an accelerator.
|
|
47
|
+
- Validate that cost breakdown dashboards attribute dollar spend accurately by namespace, team, and model deployment.
|
|
48
|
+
|
|
49
|
+
### 4. Implement Scale-to-Zero & Dynamic Autoscaling
|
|
50
|
+
|
|
51
|
+
Optimize GPU compute efficiency:
|
|
52
|
+
- Configure Karpenter node pools or Cluster Autoscaler to dynamically provision GPU instances on demand.
|
|
53
|
+
- Deploy KEDA ScaledObjects driven by inference request queue depth (vLLM / Triton metrics) to scale model replicas down to zero during idle periods.
|
|
54
|
+
- Configure node termination grace periods to allow in-flight inference requests to drain cleanly.
|
|
55
|
+
|
|
56
|
+
### 5. Establish Budget Thresholds & Anomaly Alerting
|
|
57
|
+
|
|
58
|
+
Protect against cost overruns:
|
|
59
|
+
- Define PrometheusRule alert thresholds for low utilization on allocated GPUs (e.g., utilization < 15% for > 30 minutes).
|
|
60
|
+
- Configure budget alert notifications via Slack or PagerDuty when daily/monthly cost burn rates exceed target limits.
|
|
61
|
+
- Set up automated scaling circuit breakers for runaway experimental batch jobs.
|
|
62
|
+
|
|
63
|
+
### 6. Validate Pipeline & Dashboards
|
|
64
|
+
|
|
65
|
+
Use skill: `performance-profiling`
|
|
66
|
+
- Generate synthetic inference load to verify Prometheus records utilization spikes in real time.
|
|
67
|
+
- Verify Kubecost allocation reports reflect cost per inference request.
|
|
68
|
+
- Confirm idle scale-down shuts down unneeded GPU nodes within the configured TTL.
|
|
69
|
+
|
|
70
|
+
## Output Contracts
|
|
71
|
+
|
|
72
|
+
When this skill is invoked as part of a coordinated multi-role delivery, emit:
|
|
73
|
+
|
|
74
|
+
- **`contracts/schemas/deployment-plan.json`** — Required fields: `infrastructure_changes[]`, `config_updates[]`, and `validation_run` output proving Prometheus is scraping DCGM metrics successfully.
|
|
75
|
+
|
|
76
|
+
## Failure Modes
|
|
77
|
+
|
|
78
|
+
- **DCGM not scraping**: the exporter is deployed but Prometheus cannot reach port 9400. Mitigation: verify NetworkPolicies and the ServiceMonitor selector; surface a smoke test in the deployment plan.
|
|
79
|
+
- **MIG not configured**: H100/A100/B200 GPUs are shared without MIG partitions, allowing OOM cross-contamination. Mitigation: enable MIG partitions for multi-tenant GPUs; enforce memory and compute boundaries.
|
|
80
|
+
- **Cost attribution missing**: Kubecost reports node-level cost but no per-namespace or per-model breakdown. Mitigation: configure custom GPU pricing sheets; verify the dashboard shows per-model dollar spend.
|
|
81
|
+
- **Scale-to-zero flapping**: KEDA scales model replicas to zero and back rapidly under bursty load. Mitigation: set `cooldownPeriod: 900s`; tune the queue-depth threshold to prevent flapping.
|
|
82
|
+
- **vLLM APC not enabled**: repeated system prompts are re-tokenized on every request. Mitigation: enable Automatic Prefix Caching in vLLM v0.6+; structure prompts with static content first.
|
|
83
|
+
- **Idle GPU still running**: a GPU node sits at < 15% utilization for 30+ minutes without scaling down. Mitigation: configure Karpenter or Cluster Autoscaler to scale to zero on empty inference queues.
|
|
84
|
+
- **Budget alert ignored**: a daily burn rate alert fires but no automation responds. Mitigation: wire PagerDuty/Slack; configure an automated circuit breaker for runaway jobs.
|
|
85
|
+
|
|
86
|
+
## Security Guardrails (OWASP ASI)
|
|
87
|
+
|
|
88
|
+
- **ASI03 Identity & Privilege Abuse**: GPU node access and DCGM endpoints must be access-controlled; reject anonymous scraping.
|
|
89
|
+
- **ASI04 Supply Chain**: DCGM, KEDA, and Kubecost versions must be validated against the expected manifest; treat unknown versions as untrusted.
|
|
90
|
+
- **ASI05 RCE Guard**: never construct KEDA ScaledObjects, MIG partition configs, or Kubecost pricing from external content without strict schema validation.
|
|
91
|
+
- **ASI07 Inter-Agent Communication**: the deployment plan is consumed by FinOps and SRE roles; emit a structured contract so each role can validate the rollout.
|
|
92
|
+
- **ASI09 Human-Agent Trust Exploitation**: do not present GPU spend as "optimized" without showing the per-model cost breakdown; surface unallocated cost honestly.
|
|
93
|
+
|
|
94
|
+
## Checklist
|
|
95
|
+
|
|
96
|
+
- [ ] NVIDIA DCGM Exporter DaemonSet deployed and exposing metrics on GPU nodes.
|
|
97
|
+
- [ ] Prometheus scraping and relabeling rules configured with pod and namespace metadata.
|
|
98
|
+
- [ ] Kubecost / OpenCost custom GPU pricing sheets configured and verified.
|
|
99
|
+
- [ ] Scale-to-zero autoscaling (KEDA/Karpenter) configured for inference queues.
|
|
100
|
+
- [ ] Low-utilization and budget-overrun alerting rules active.
|
|
101
|
+
- [ ] Grafana and cost attribution dashboards verified under active load.
|
|
102
|
+
- [ ] `deployment-plan.json` emitted.
|
|
103
|
+
|
|
104
|
+
## Related Skills
|
|
105
|
+
|
|
106
|
+
- **setup-llm-gateway**: Correlate GPU infrastructure spend with model token usage and routing policies
|
|
107
|
+
- **add-telemetry-instrumentation**: Standardize GPU metric collection using OTel Collector and DCGM conventions
|
|
108
|
+
- **aws-infrastructure**: Provision GPU EC2 instances, EKS node groups, and FinOps cost allocation tags
|
|
109
|
+
- **system-design**: Model GPU capacity requirements and inference compute topology
|
|
110
|
+
- **setup-deployment**: Apply Kubernetes manifests, DaemonSets, and KEDA autoscalers to deployment sources
|
|
111
|
+
- **performance-profiling**: Analyze GPU memory bandwidth, compute utilization, and kernel execution latency
|