feat(kiloclaw): add multi-row-all-destroyed collapse and bulk apply paths#2571
feat(kiloclaw): add multi-row-all-destroyed collapse and bulk apply paths#2571jeanduplessis wants to merge 1 commit intomainfrom
Conversation
…aths Adds a third remediation mode to the subscription alignment script for users whose personalCurrentSubscriptionWhere matches >1 rows AND none point at a live instance, which fails the resolver guard. The mode collapses the ambiguous rows into one tail row by chaining older rows to newer ones via transferred_to_subscription_id. Also introduces an opt-in --bulk flag on apply-missing-personal and apply-multi-row-all-destroyed for chunked bulk writes (250-row tx chunks with per-user fallback on chunk failure), batches the apply-changelog-baseline path into 500-row chunks, and adds progress logging to long-running apply paths.
| after_state: serializeKiloClawSubscriptionSnapshot(row), | ||
| })) | ||
| ); | ||
| insertedFromCurrent += currentStateRows.length; |
There was a problem hiding this comment.
WARNING: This counter can over-report successful backfills after a chunk rollback
insertedFromCurrent is mutated before the transaction commits. If the later mutationStateRows insert throws, the whole chunk rolls back but this JS counter stays incremented, so the results table can claim rows were backfilled when none of them committed. Returning the per-chunk counts from db.transaction(...) and accumulating them after it resolves would keep operator output in sync with the database.
| const next = joinedRows[index + 1]?.subscription; | ||
| if (!source || !next) continue; | ||
| if (source.transferred_to_subscription_id !== null) continue; | ||
| if (existingPredecessorTargets.has(next.id)) continue; |
There was a problem hiding this comment.
WARNING: Skipping a claimed successor can leave the user still ambiguous
If next.id already has a predecessor from an older partial chain, this continue drops the current source row from the collapse plan entirely. A history like D->B, A, B, C then only writes B->C, leaving both A and C current and resolveCurrentPersonalSubscriptionRow still throwing afterward. These cases need to be surfaced as manual review / skipped-not-collapsible instead of being counted as a successful collapse.
Code Review SummaryStatus: 2 Issues Found | Recommendation: Address before merge Overview
Issue Details (click to expand)WARNING
Other Observations (not in diff)None. Files Reviewed (1 files)
Fix these issues in Kilo Cloud Reviewed by gpt-5.4-20260305 · 815,632 tokens |
Summary
Retroactive PR for changes made to the script to update the database.