Skip to content

Conversation

@seefeldb
Copy link
Contributor

@seefeldb seefeldb commented Sep 5, 2025

Summary by cubic

Make all write operations resilient by using runtime.editWithRetry across core packages to prevent lost writes during conflicts. Also make Runner.setup/Runtime.setup async to support retryable transactions.

  • Refactors

    • Replaced direct tx.commit calls with runtime.editWithRetry in: background-charm-service (status/enable/disable updates), charm (manager, iterate, controller), runner (runner, runtime), shell (default recipe), toolshed Google OAuth utils; cleaned up json-utils to avoid no-op tx.
    • CharmManager: consolidated add logic, moved trash/unpin flows to retryable edits, and tightened boolean returns based on actual changes.
    • Runner/Runtime: setup now wraps internal edits in retries when no external tx is provided; start flow and syncing behavior preserved.
  • Migration

    • Runner.setup and Runtime.setup now return Promise<Cell>. Update call sites to await these methods.

@seefeldb seefeldb requested review from Copilot and ubik2 September 5, 2025 22:11
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This pull request adds retry mechanisms for write commits in core packages to improve reliability when updating cell data. The changes replace direct transaction commits with editWithRetry() calls, which automatically handle transaction conflicts and retry operations when necessary.

  • Replaces manual transaction management with editWithRetry() wrapper
  • Updates method signatures to return Promises where retry logic is added
  • Adds comments explaining retry behavior in specific contexts

Reviewed Changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
packages/toolshed/routes/integrations/google-oauth/google-oauth.utils.ts Replaces manual commits with retry logic for OAuth token persistence
packages/shell/src/lib/iframe-ctx.ts Adds comment explaining why iframe writes don't use retries
packages/shell/src/lib/default-recipe.ts Converts default recipe creation to use retry mechanism
packages/runner/src/runtime.ts Updates setup method signatures to return Promises
packages/runner/src/runner.ts Implements retry logic in setup and run methods
packages/runner/src/cell.ts Adds comment about sink callback retry behavior
packages/runner/src/builder/json-utils.ts Simplifies cell retrieval by removing unnecessary transaction
packages/charm/src/ops/charm-controller.ts Adds retry logic for charm property updates
packages/charm/src/manager.ts Converts charm management operations to use retries
packages/charm/src/iterate.ts Adds retry for charm lineage updates
packages/background-charm-service/src/utils.ts Converts background charm operations to use retries
packages/background-charm-service/src/space-manager.ts Adds retry logic for charm status updates
Comments suppressed due to low confidence (1)

packages/charm/src/manager.ts:1

  • The function returns early with return false inside the retry callback, but editWithRetry expects the callback to either succeed or throw an error for retry logic to work properly. These early returns will be interpreted as successful operations.
import {

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

18 issues found across 12 files

React with 👍 or 👎 to teach cubic. You can also tag @cubic-dev-ai to give feedback, ask questions, or re-run the review.

@seefeldb seefeldb force-pushed the fix/add-commit-retry branch from cda57e8 to 25d77ef Compare September 8, 2025 17:55
@seefeldb seefeldb merged commit 690ad6b into main Sep 8, 2025
7 checks passed
@seefeldb seefeldb deleted the fix/add-commit-retry branch September 8, 2025 18:57
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.

2 participants