Skip to content

Commit 89d42d4

Browse files
authored
chore: sync alpha from main (20260402-100225) (#1154)
## Summary Automated merge of `main` into `alpha`. - Commits from `main` not yet in `alpha`: **12** - merge-base: `595d79011a81e828335e7ba8cd51d17a520c5f8b` - Generated: 20260402-100225 ## Review Instructions 1. Check for conflict markers (`<<<<<<<`) in changed files and resolve them. 2. Cherry-pick any alpha-specific fix commits onto this branch. 3. Verify CI passes. 4. Merge into `alpha` using **Create a merge commit** (not rebase). Generated by `scripts/rebase-main-to-alpha.sh`.
2 parents 961a409 + 3c9bf5a commit 89d42d4

34 files changed

Lines changed: 3430 additions & 812 deletions

File tree

.claude/skills/dev-cluster/SKILL.md

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ The Ambient Code Platform consists of these containerized components:
3737
**Commands:**
3838
- `make kind-up` - Create cluster, deploy with Quay.io images
3939
- `make kind-up LOCAL_IMAGES=true` - Create cluster, build and load local images
40+
- `make kind-up LOCAL_IMAGES=true LOCAL_VERTEX=true` - Same but with Vertex AI enabled (reads `ANTHROPIC_VERTEX_PROJECT_ID`, `CLOUD_ML_REGION`, `GOOGLE_APPLICATION_CREDENTIALS` from shell env)
4041
- `make kind-down` - Destroy cluster
4142
- `make kind-rebuild` - Rebuild all components, reload images, restart
4243
- `make kind-port-forward` - Setup port forwarding
@@ -51,6 +52,54 @@ The Ambient Code Platform consists of these containerized components:
5152

5253
**Access:** `http://localhost:$KIND_FWD_FRONTEND_PORT` (run `make kind-status` for assigned ports)
5354

55+
## CRITICAL: Always Use `make kind-up`, Never Manually Recover
56+
57+
**If `make kind-up` fails partway through, fix the root cause and re-run `make kind-up` (after `make kind-down`).** Do NOT manually patch deployments, create buckets, or set env vars to recover — the Makefile handles MinIO bucket creation, Vertex AI setup, token extraction, and port forwarding in a specific order. Manually recovering individual steps is slower, error-prone, and skips steps you don't know about.
58+
59+
## Vertex AI / GCP Configuration
60+
61+
When the user needs Vertex AI (Claude via GCP) instead of Anthropic API:
62+
63+
```bash
64+
# One-command setup — reads env vars from shell profile
65+
make kind-up LOCAL_IMAGES=true LOCAL_VERTEX=true
66+
```
67+
68+
**Prerequisites:** These env vars must be set in the user's shell (check `~/.bashrc` or `~/.zshrc`):
69+
- `ANTHROPIC_VERTEX_PROJECT_ID` — GCP project ID
70+
- `CLOUD_ML_REGION` — Vertex AI region (e.g., `us-east5`)
71+
- `GOOGLE_APPLICATION_CREDENTIALS` — Path to service account JSON or ADC file
72+
73+
The `LOCAL_VERTEX=true` flag runs `scripts/setup-vertex-kind.sh` which creates the `ambient-vertex` secret, patches `operator-config`, and restarts the operator. **Do not do these steps manually.**
74+
75+
## Feature Flags (Unleash)
76+
77+
The platform uses **Unleash** for feature flags, running in-cluster. Some endpoints are gated behind feature flags and will return 404 if the flag is not enabled. If you hit an unexpected 404 on an endpoint that exists in the code, check whether it's behind a `requireFeatureFlag()` middleware and ensure the flag is created and enabled in Unleash (admin token: `*:*.unleash-admin-token`, API at `http://localhost:4242` inside the cluster).
78+
79+
## Custom Workflow Branches
80+
81+
To test workflow changes from a different branch of `ambient-code/workflows`:
82+
83+
```bash
84+
kubectl set env deployment/backend-api -n ambient-code \
85+
OOTB_WORKFLOWS_BRANCH="your-branch-name"
86+
kubectl rollout restart deployment/backend-api -n ambient-code
87+
```
88+
89+
The backend caches workflows for 5 minutes. Restart clears the cache immediately.
90+
91+
## Google OAuth for Integrations
92+
93+
Testing Google Drive or other Google integrations requires OAuth credentials on the backend:
94+
95+
```bash
96+
kubectl set env deployment/backend-api -n ambient-code \
97+
GOOGLE_OAUTH_CLIENT_ID="your-client-id" \
98+
GOOGLE_OAUTH_CLIENT_SECRET="your-secret" \
99+
OAUTH_STATE_SECRET="$(openssl rand -hex 32)" \
100+
BACKEND_URL="http://localhost:$KIND_HTTP_PORT"
101+
```
102+
54103
## Workflow: Setting Up from a PR
55104

56105
When a user provides a PR URL or number, follow this process:
@@ -294,6 +343,18 @@ kubectl describe pod -l app=backend -n ambient-code
294343
# - Invalid configuration
295344
```
296345

346+
### Sessions fail with init-hydrate exit code 1
347+
**Cause:** MinIO `ambient-sessions` bucket doesn't exist. This happens when `make kind-up` fails partway through (e.g., due to image pull errors) and the `init-minio.sh` step is skipped.
348+
349+
**Solution:**
350+
```bash
351+
# Create the bucket manually
352+
kubectl exec deployment/minio -n ambient-code -- mc alias set local http://localhost:9000 minioadmin minioadmin123
353+
kubectl exec deployment/minio -n ambient-code -- mc mb local/ambient-sessions
354+
```
355+
356+
**Prevention:** If `make kind-up` fails, fix the underlying issue and re-run it rather than manually recovering individual steps. The Makefile runs `init-minio.sh` near the end of `kind-up`.
357+
297358
### Port forwarding not working
298359
**Cause:** Port already in use or forwarding process died
299360

@@ -382,6 +443,46 @@ npm run dev
382443
- Backend, operator, or runner changes (those still need image rebuild + load)
383444
- Testing changes to container configuration or deployment manifests
384445

446+
## Benchmarking Developer Loops
447+
448+
Use the benchmark harness when the user wants measured cold-start or rebuild timing rather than ad hoc impressions.
449+
450+
### Commands
451+
452+
```bash
453+
# Human-friendly local summary
454+
make benchmark
455+
456+
# Agent / automation friendly output
457+
make benchmark FORMAT=tsv
458+
459+
# Single component
460+
make benchmark COMPONENT=frontend MODE=cold
461+
make benchmark COMPONENT=backend MODE=warm
462+
```
463+
464+
### Agent Guidance
465+
466+
- Prefer `FORMAT=tsv` when another agent, script, or evaluation harness will consume the output.
467+
- Prefer the default `human` format for interactive local use in a terminal.
468+
- `frontend` benchmarking requires **Node.js 20+**.
469+
- `warm` currently measures **rebuild proxies**, not browser-observed hot reload latency.
470+
- If `reports/benchmarks/` is not writable in the current environment, the harness will fall back to a temp directory and print a warning.
471+
- Session benchmarking is **contract-only** in v1 (`bench_session_*` stubs in `scripts/benchmarks/bench-manifest.sh`).
472+
- Start with the **smallest relevant benchmark**:
473+
- backend/operator/public-api change -> `MODE=warm COMPONENT=<component> REPEATS=1`
474+
- frontend contributor setup -> `MODE=cold COMPONENT=frontend REPEATS=1`
475+
- only run all components when you explicitly need the whole matrix
476+
- Treat preflight failures as useful environment signals; do not work around them unless the user asks.
477+
- Use full-sweep benchmarking sparingly because each component still performs untimed setup before the measured warm rebuild.
478+
479+
### Interpreting Results
480+
481+
- `cold`: approximates first-contributor setup/install cost with isolated caches
482+
- `warm`: approximates incremental rebuild cost after setup has already completed
483+
- `budget_ok=false` on cold runs means the component exceeded the 60-second contributor budget
484+
- Large deltas on a single repeat should be treated cautiously; use more repeats before drawing conclusions
485+
385486
## Best Practices
386487

387488
1. **Use local dev server for frontend**: Fastest feedback loop, no image rebuilds needed

0 commit comments

Comments
 (0)