Repository navigation
Description
SpawnClient.extend (src/core/client.ts:379) is missing the safety floor Go added, so extending an already-overdue instance can produce a deadline still in the past — the instance is reaped moments after the user asked to keep it. It also drops the spawn:ttl half of the tag pair and has no reload trigger.
1. The missing floor — a real failure, not a nicety
Go cmd/extend.go:126:
// Safety floor: never set a deadline earlier than the requested duration from
// now. A past/expired existing spawn:ttl-deadline (or a stale launch anchor)
// must not reap the instance the moment the user asks to extend it.
if floor := time.Now().Add(extendDuration); newDeadline.Before(floor) {
newDeadline = floor
}spawn-ts:
const deadline = i.ttlDeadlineMs + ms;Concrete failure: an instance whose deadline passed 2h ago (spored was down, or it's an orphan per src/core/orphans.ts — the exact #19 scenario that module exists for). The user runs extend 1h. New deadline = 1h ago. spawn extend reports success; the ttl-reaper (lambda/ttl-reaper/main.go:688, where spawn:ttl-deadline is "the authoritative, launch-anchored deadline") terminates it on its next pass. The user's rescue attempt is silently a no-op.
Note this is most likely to hit exactly when it matters most — the instance you're trying to save is by definition one that's overdue.
Both behaviours share the same anchoring rule, which spawn-ts gets right and should keep: extend adds to the current deadline, not to now, so TTL stays anchored to original launch across stop/wake cycles. The floor is a lower bound on top of that, not a replacement for it.
2. spawn:ttl is never updated
Go writes both tags — tags := map[string]string{"spawn:ttl": newTTL} plus spawn:ttl-deadline (extend.go:109, :132). spawn-ts writes only the deadline.
Mostly cosmetic, because the deadline is authoritative for both enforcers (reaper main.go:688; spored reads ttl-deadline at pkg/provider/ec2.go:478). But it isn't purely cosmetic in two places:
spawn extenditself readsinstance.TTLfor its no-deadline-tag fallback (extend.go:119), so a stalespawn:ttlfeeds a wrong answer on the next extend of an older instance.sporedsynthesizes a deadline fromanchor + config.TTLwhenTTLDeadlineis zero (pkg/agent/agent.go:140-147). spawn-ts always writes a deadline so this path isn't reached today, but the two tags disagreeing is a trap for anything that trustsspawn:ttl.
3. No reload trigger — and this one is portable
Go follows the tag write with triggerReload(instance) (extend.go:150), which SSHes sudo spored reload and degrades to a warning naming the manual command on failure. Without it, spored picks the change up on its next poll rather than immediately.
Go's transport is SSH, which a browser doesn't have. But SSM does, and it's CORS-open — preflighted live from Origin: https://spore.host:
OPTIONS https://ssm.us-east-1.amazonaws.com/ → HTTP 200
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: POST
Access-Control-Allow-Headers: *,Authorization,X-Amz-Date,X-Amz-Security-Token,X-Amz-Target,…
spawn-ts already talks SSM for the web terminal (src/ssm/session.ts:40). So SendCommand with AWS-RunShellScript is reachable and reload is tier B, not tier D. It must follow Go's degradation shape: a failed reload is a stated warning, never silent, and never a failed extend — the tag write already succeeded and is what actually matters.
Fix
- Clamp:
const deadline = Math.max(i.ttlDeadlineMs + ms, ctx.now() + ms)— with a test asserting the overdue case, since that's the whole point. - Write
spawn:ttlalongsidespawn:ttl-deadline, formatted with the existingformatDurationso it stays Go-parseable. - Optional reload via SSM
SendCommand, degrading to a warning that names the manual command.
Part of the parity audit.
Activity
scttfrdmn commentedon Jul 31, 2026
Part of #57 (spawn-ts vs spawn parity audit).
chore(release): 0.7.0, and make the release process repeatable (#69)