Skip to content

Unbounded-launch guard accepts costLimit (soft, spored-dependent) but refuses idleTimeout — inverted from Go #55

Closed

Description

@scttfrdmn

Go's zombie guard applies a default bound when a launch has none; spawn-ts refuses the launch. Both are cost-safe, and spawn-ts's guard is correctly placed — but the set of things that count as a bound is inverted from Go in a way that accepts a weaker guarantee and rejects a stronger one.

Go: default to 1h idle

applyIdleTimeoutDefault (cmd/zombie_guard.go:20) is the single source of truth, deliberately consolidated in the 2026-06 audit (M-health) after being copy-pasted across the single, batch-queue, and sweep launch paths:

func applyIdleTimeoutDefault(cfg *aws.LaunchConfig) bool {
	if cfg.TTL == "" && cfg.IdleTimeout == "" && !noTimeout {
		cfg.IdleTimeout = "1h"
		return true
	}
	return false
}

The launch proceeds with a printed notice. --no-timeout additionally requires confirmation (zombie_guard.go:58, 2026-06 audit L-ergo) — pass --yes or abort: "disabling the cost guardrails is an explicit, acknowledged choice".

Go's trigger is TTL == "" && IdleTimeout == "". Cost limit is not part of it.

spawn-ts: refuse, at the right seam

SpawnClient.launch (src/core/client.ts:346):

if (this.provider.isReal && spec.ttlMs === 0 && spec.costLimit === 0 && !input.allowUnbounded) {
  throw new Error("refusing to launch a REAL instance with no ttl and no costLimit …");
}

This is placed correctly — FanOut launches through this.client.launch (src/core/fanout.ts:230) and the GUI form through the same (src/ui/dashboard.ts:229), so sweep/queue/jobarray and the dashboard all inherit it. allowUnbounded is a per-call opt-in, which is a better shape than a flag string because a library caller has to name the risk in code. src/cli/commands.ts:201 duplicates the check only to produce a friendlier message before the throw. No complaint about any of that.

The actual divergence: which bounds count

bound Go accepts as sufficient spawn-ts accepts as sufficient
--ttl yes yes
--idle-timeout yes no
--cost-limit no (not consulted) yes

Both halves are backwards, and the cost-limit half is the one that matters:

costLimit alone is not a bound. It's a soft limit enforced by spored polling accumulated compute-seconds against spawn:cost-limit. The TTL is the hard backstop — src/core/types.ts:30 says so directly: "Always terminates on expiry — the hard cost backstop." If spored never starts (crash-loop, bad instance profile, failed bootstrap) nothing enforces a cost limit and the instance bills forever. That is exactly the #19 orphan failure mode src/core/orphans.ts exists to detect — and the guard currently treats a launch with only a cost limit as safe, so it creates the orphans that module then reports.

ttl-deadline, by contrast, is enforced independently of the instance: the ttl-reaper Lambda reads spawn:ttl-deadline from outside the box (lambda/ttl-reaper/main.go:688, "the authoritative, launch-anchored deadline"). A TTL survives spored being dead. A cost limit does not.

idleTimeoutMs is refused despite being a real bound. Go accepts it because spored stops the instance after inactivity. It's spored-dependent like the cost limit, but it's the bound Go itself chose as the auto-applied default, so refusing it while accepting the weaker signal is indefensible either way you rank them.

Fix

In SpawnClient.launch:

  • Accept idleTimeoutMs > 0 as a bound (matching Go).
  • Stop treating costLimit alone as sufficient — or, if it's kept, emit a stated warning that it is soft and spored-dependent, so the caller knows the launch has no external backstop. Silence here is the thing to avoid: a guard that passes must not imply a guarantee it isn't making.
  • Consider Go's acknowledgement step for the CLI override. allowUnbounded already forces a library caller to be explicit; --no-timeout in src/cli/commands.ts:203 does not ask for anything.

Worth stating in the code comment either way: refusing rather than defaulting is a deliberate divergence and the better choice for a browser (nothing launches, so nothing bills). It just shouldn't read as the same guard as Go's.

Part of the parity audit.

Activity

  1. added
    bug
    area: core
    cost-safety
    on Jul 31, 2026
  2. changed the title [-]The unbounded-launch guard lives in the CLI parser, so the GUI, FanOut (sweep/queue/array) and library callers bypass it[/-] [+]Unbounded-launch guard accepts costLimit (soft, spored-dependent) but refuses idleTimeout — inverted from Go[/+] on Jul 31, 2026
  3. scttfrdmn commented on Jul 31, 2026

    @scttfrdmn
    ContributorAuthor

    Part of #57 (spawn-ts vs spawn parity audit).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: corebugcost-safety

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions