Skip to content

refactor: use an outbox for lifecycle artifact deletion - #1683

Merged
ferhatelmas merged 2 commits into
masterfrom
ferhat/lc-outbox
Nov 9, 2026
Merged

ferhatelmas merged 2 commits into
masterfrom
ferhat/lc-outbox

Conversation

@ferhatelmas

@ferhatelmas ferhatelmas commented Nov 9, 2026 •

Copy link
Copy Markdown
Member

What kind of change does this PR introduce?

Refactor

What is the current behavior?

The lifecycle worker deletes eligible metadata and stores an in-flight batch in the bucket continuation. It records physical deletion outcomes in that journal and advances the cursor after cleanup completes. Pending artifacts can later be moved to the abandoned artifact table for retry.

What is the new behavior?

The worker deletes eligible metadata, writes the corresponding physical keys to the outbox and advances the cursor in one transaction. Physical deletion happens afterward; unresolved keys remain in the outbox for retry. The continuation holds only the cursor and counters.

Additional context

Related to #1627

@ferhatelmas
ferhatelmas requested a review from a team as a code owner November 9, 2026 14:49
Copilot AI balanced review requested due to automatic review settings November 9, 2026 14:49

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

Signed-off-by: Ferhat Elmas <elmas.ferhat@gmail.com>

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I reviewed this PR and didn't find any bugs. It redesigns how lifecycle deletes backend artifacts, and a mistake there could leak or wrongly delete stored data, so a human look is still worthwhile.

What was reviewed:

  • armLifecycleAttempt in pg.ts: the metadata delete, the outbox insert and the cursor/claim update run in one transaction, and the renumbered SQL parameters match the values arrays.
  • I searched for remaining callers of the removed methods (commitLifecycleAttempt, revalidateLifecycleRecoveryAttempt, inFlightOnly, LifecycleClaimedState) and found none.
  • The outbox table and its attempted_at index already exist in migration 0079, so no new migration is needed.
  • decodeLifecycleContinuation now rejects any continuation that still has a batch. I ruled this out as a bug on the assumption that the old journal format never reached production. A human should confirm that, because a bucket saved mid-batch would fail to decode on every claim.
Extended reasoning...

The change rewrites the lifecycle metadata-deletion path in src/storage/database/pg.ts, continuation.ts and the lifecycle schemas. The in-flight journal kept in the continuation is replaced with outbox rows in storage.lifecycle_abandoned_artifacts, with about 1,300 net lines removed. It doesn't touch auth or injection: the queries are fully parameterized and run as the service role. It does control when stored objects get permanently deleted. I deferred because the change is large and changes the design of data-deletion code, and because its safety depends on deployment history (whether any old-format continuation was ever persisted), which the code alone can't settle.

This review covers commit cd7ec36, which is no longer the latest commit on this pull request; later commits are not covered by it.

@coveralls

coveralls commented Nov 9, 2026 •

Copy link
Copy Markdown

Coverage Report for CI Build 42643103949

Coverage decreased (-0.09%) to 87.475%

Details

  • Coverage decreased (-0.09%) from the base build.
  • Patch coverage: 21 of 21 lines across 3 files are fully covered (100%).
  • 1 coverage regression across 1 file.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

1 previously-covered line in 1 file lost coverage.

File Lines Losing Coverage Coverage
src/storage/lifecycle/continuation.ts 1 93.59%

Coverage Stats

Coverage Status
Relevant Lines: 15890
Covered Lines: 14342
Line Coverage: 90.26%
Relevant Branches: 10074
Covered Branches: 8370
Branch Coverage: 83.09%
Branches in Coverage %: Yes
Coverage Strength: 1298.12 hits per line

💛 - Coveralls

Signed-off-by: Ferhat Elmas <elmas.ferhat@gmail.com>
@ferhatelmas
ferhatelmas merged commit dd568db into master Nov 9, 2026
34 of 36 checks passed
@ferhatelmas
ferhatelmas deleted the ferhat/lc-outbox branch November 9, 2026 17:42
ferhatelmas added a commit that referenced this pull request Nov 10, 2026
## What kind of change does this PR introduce?

feat

## What is the current behavior?

#1627 and #1683 added the database operations and outbox needed for
noncurrent lifecycle deletion but executor to run was missing.

## What is the new behavior?

Add a bucket executor that evaluates archived versions, deletes eligible
metadata in bounded batches and removes the corresponding backend
artifacts.
Failed artifact deletions remain in the outbox for retry. 

## Additional context

Scheduling the executor and retry helper is a next separate change.

Signed-off-by: Ferhat Elmas <elmas.ferhat@gmail.com>
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.

4 participants