fix(kiloclaw): compute orphan volume grace period in SQL#3431
Open
St0rmz1 wants to merge 1 commit into
Open
Conversation
Contributor
Code Review SummaryStatus: No Issues Found | Recommendation: Merge Executive SummaryThe PR correctly moves the orphan-volume grace period check from runtime JS Files Reviewed (4 files)
Notes:
Fix these issues in Kilo Cloud Reviewed by claude-4.6-sonnet-20260217 · 427,449 tokens Review guidance: REVIEW.md from base branch |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The admin orphan volume cleanup tool rejected volumes that were well past
the 7 day grace period, reporting that the instance was "destroyed too
recently". A destroyed instance over 60 days old was still refused.
The destroy path measured the grace period in JavaScript: it read the
stored
destroyed_attimestamp and passed it to theDateconstructor.That value arrives as Postgres native timestamp text rather than ISO
8601, and the
Dateconstructor handles that text inconsistently acrossthe Vercel and Cloudflare runtimes the two destroy gates run in, so the
elapsed time came out wrong and the grace gate misfired.
Both destroy gates now compute the grace decision entirely in Postgres:
destroyOrphanVolumeprocedure and the kiloclaw workerorphan-volume-destroyroute each select agrace_period_elapsedboolean, derived from
max(destroyed_at)across the (user, sandbox)versus the grace window.
falseor a null result (no destroyed row, already ruled out by thepreceding gate) both fail closed.
Grace is still measured from the latest destruction of the sandbox, so a
reprovisioned sandbox whose shared volume was re-destroyed recently is
still held. The change is limited to the orphan volume destroy path; no
other procedure or route is affected.
Verification
from the admin tool and confirmed it now succeeds instead of being
rejected as too recent.
rejected at the grace gate.
Visual Changes
N/A. This PR changes server query logic and test coverage only. There
are no UI changes.
Reviewer Notes
Focus areas:
grace_period_elapsedSQL expression: `extract(epoch from (now()milliseconds. Confirm the boundary matches the previous JavaScript
comparison.
trueas not elapsed, so a null result fails closed.boundary, the reprovisioned sandbox case, and a long destroyed
instance stored as Postgres native timestamp text. The worker test
mocks the database, so it consumes the precomputed flag directly; the
SQL itself is exercised end to end by the web router test.