Skip to content

feat(sandbox): make the Go daemon the default for every sandbox - #5568

Merged
pedrofrxncx merged 1 commit into
mainfrom
feat/sandbox-go-daemon-default
Aug 2, 2026
Merged

pedrofrxncx merged 1 commit into
mainfrom
feat/sandbox-go-daemon-default

Conversation

@pedrofrxncx

@pedrofrxncx pedrofrxncx commented Aug 2, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Flips resolveDaemonImpl so a sandbox lands on the Go daemon unless something explicitly says otherwise. One line of behavior; the rest is the comments and tests that asserted the old direction.

  • resolve-daemon-impl.ts: flags?.sandbox_go_daemon ? "go" : "ts" → flags?.sandbox_go_daemon === false ? "ts" : "go". Precedence is unchanged (prop → org flag → default); only the default and the flag's polarity move.
  • sandbox_go_daemon becomes an opt-out: absent/unset/true → Go, explicit false → TS. Schema description updated to say so. No rename — the flag name still reads correctly, and renaming it would orphan whatever rows already set it.
  • SANDBOX_START's daemonImpl prop is untouched and still wins in both directions, so a single sandbox can be pinned back to ts without opting the org out.
  • Comment fixes in lifecycle.ts and start.ts that described Go as an opt-in rollout.

Rollback

Three levels, cheapest first:

  1. Per sandbox — SANDBOX_START { daemonImpl: "ts" }.
  2. Per org — ORGANIZATION_SETTINGS_UPDATE { flags: { sandbox_go_daemon: false } }.
  3. Fleet — unset STUDIO_SANDBOX_GO_TEMPLATE_NAME in the studio chart. resolveClaimTemplate collapses every go back to ts when there's no Go SandboxTemplate to point a claim at, so the whole fleet reverts on the next claim with no code deploy. Live sandboxes always drain on the binary they booted with.

Depends on

decocms/deco-apps-cd#191 must merge and sync first. It KEDA-scales the studio-sandbox-{stg,prod}-go warm pools. Without it those pools are canary-sized at a static 1 replica while KEDA scales only the TS pools — this change would send the whole fleet at a 1-pod pool and cold-start most sandboxes.

Testing

bun test on the three affected files — 32 pass. Inverted the existing assertions rather than appending:

  • resolve-daemon-impl.test.ts: "defaults to ts" → "defaults to go"; "honors the org flag" → "treats the org flag as an opt-out"; the explicit-prop case now pins ts with no flag set, which is the escape hatch that matters once Go is the default.
  • start.test.ts: the two daemonImpl reaching-runner.ensure cases swapped, and the "pin inside a flagged org" case became "pin without opting the org out".
  • claim-template.test.ts needed no change — resolveClaimTemplate is downstream of this and its contract (no Go template ⇒ ts) is unchanged.

bun run fmt, bun run lint (0 errors) clean. generate:tool-contracts produced no diff for this change — the flag description doesn't reach tool-io.ts.

Caveat worth a second opinion

The prod Go canary has been up ~31h with essentially no real traffic through it — 2 pods, both warm-pool, and no Go SandboxClaim live at the time I checked. So this flip is the first meaningful Go traffic in prod rather than a graduation from a proven canary. The three rollback levels above are why I think that's acceptable, but if you'd rather bake stg first, merge decocms/deco-apps-cd#191, then hold this and flip a couple of orgs' sandbox_go_daemon by hand for a day.


Summary by cubic

Makes the Go sandbox daemon the default for all new sandboxes. The sandbox_go_daemon flag is now an opt-out (false pins TS), and SANDBOX_START’s daemonImpl still overrides per sandbox.

  • Migration

    • Per sandbox: SANDBOX_START { daemonImpl: "ts" }.
    • Per org: set flags.sandbox_go_daemon = false.
    • Fleet rollback: unset STUDIO_SANDBOX_GO_TEMPLATE_NAME to route new claims to TS; live sandboxes drain on their boot binary.
  • Dependencies

    • decocms/deco-apps-cd#191 must merge and sync first to scale studio-sandbox-{stg,prod}-go warm pools.

Written for commit f999e8d. Summary will update on new commits.

Review in cubic

@pedrofrxncx
pedrofrxncx enabled auto-merge (squash) August 2, 2026 15:40

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 6 files

You’re at about 90% of the monthly reviewed-line limit. You may want to disable incremental reviews to conserve quota. Reviews will continue until that limit is exceeded. If you need help avoiding interruptions, please contact [email protected].

Re-trigger cubic

@pedrofrxncx
pedrofrxncx merged commit 0667981 into main Aug 2, 2026
26 checks passed
@pedrofrxncx
pedrofrxncx deleted the feat/sandbox-go-daemon-default branch August 2, 2026 15:50
decocms Bot pushed a commit that referenced this pull request Aug 2, 2026
PR: #5568 feat(sandbox): make the Go daemon the default for every sandbox
Bump type: minor

- decocms (apps/api/package.json): 4.158.9 -> 4.159.0
- @decocms/native (apps/native/package.json): 4.158.9 -> 4.159.0
- @decocms/shared (packages/shared/package.json): 0.12.0 -> 0.13.0

Deploy-Scope: server
guitavano added a commit that referenced this pull request Aug 4, 2026
…5676)

* fix(sandbox): restore port-sniffer phrase gate + cross-chunk carry

The Go daemon's port sniffer (default since #5568, TS daemon deleted in
#5575) was an incomplete port of the TypeScript one: it dropped two
safeguards, so a Vite dev server that binds a non-config port (e.g. 5173)
is no longer detected. `getDevPort()` then falls back to the configured
`application.port` (3000) — the daemon proxies/probes 127.0.0.1:3000,
gets connection-refused forever, serves "Server is starting…" and never
leaves the `starting` lifecycle phase. The preview is stuck on the boot
skeleton even though `vite dev` is ready.

Restore both safeguards from the TS sniffer:

- **Phrase gate.** The bind URL must be preceded by `Local:` / `Listening
  on` on the same line. Without it, a bare `http://localhost:3000` line
  (a framework echoing the injected PORT, a proxied fetch, a sibling
  process) hijacks the lock before Vite's real `Local: http://localhost:5173/`.

- **Cross-chunk carry.** PTY reads aren't line-buffered, so the bind line
  can split across chunks. Carry a bounded, ANSI-stripped tail per source
  and match the concatenation. Also require a `/` or whitespace after the
  port so a split mid-number ("...:51" | "73/") waits instead of locking
  the truncated "51".

Tests cover both failure modes (bare-3000 hijack, split bind line).

Co-Authored-By: Claude Opus 4.8 <[email protected]>

* fix(sandbox): lock on any non-digit terminator, consume ANSI ESC

Review of the previous commit found the `[/\s]` trailing requirement
regressed the no-trailing-slash frameworks (next, bun) it claimed to
support: the ANSI stripper matches the bracket body but not the ESC, so a
colored `http://localhost:3000\x1b[0m\n` strips to `...:3000\x1b\n` — the
ESC sits between the port and the newline, `[/\s]` rejects it, and the
port is never sniffed (silently falling back to the wrong configured
port — the exact failure the sniffer exists to prevent).

- Require a non-digit terminator (`[^\d]`) instead of `[/\s]`. Still fixes
  the mid-number split (a buffer ending on digits has no following char →
  waits), but locks on any non-digit — `/`, `)`, `,`, whitespace,
  newline, or a leftover ESC — matching the eager TS behavior for the
  frameworks a strict `[/\s]` would have dropped.
- Make ansiPattern consume the ESC when present (`\x1b?`) so a stripped
  color code leaves nothing between the port and its terminator.

Tests: colored no-trailing-slash, non-slash terminator, Reset clears
carry, sibling URL before the banner (line-bound `[^\n]*?`), and
per-source carry isolation.

Co-Authored-By: Claude Opus 4.8 <[email protected]>

---------

Co-authored-by: Claude Opus 4.8 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant