Skip to content

fix: feature.json corruption on crash lose#532

Merged
Shironex merged 1 commit intov0.12.0rcfrom
feature/v0.12.0rc-1768605251997-8ufb
Jan 17, 2026
Merged

fix: feature.json corruption on crash lose#532
Shironex merged 1 commit intov0.12.0rcfrom
feature/v0.12.0rc-1768605251997-8ufb

Conversation

@Shironex
Copy link
Copy Markdown
Collaborator

- Introduced atomic write functionality for JSON files to ensure data integrity during writes.
- Added recovery mechanisms to read JSON files with fallback options for corrupted or missing files.
- Enhanced existing services to utilize atomic write and recovery features for improved reliability.
- Updated tests to cover new atomic writing and recovery scenarios, ensuring robust error handling and data consistency.
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jan 16, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @Shironex, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request implements a critical improvement to data integrity by introducing atomic file operations with backup and recovery capabilities for JSON files. Specifically targeting feature.json and settings files, these changes prevent data corruption that could occur during unexpected application termination. By writing to temporary files and then atomically renaming them, and by attempting to recover from temporary or backup files upon read failures, the system ensures that critical data remains consistent and accessible, even in crash scenarios.

Highlights

  • Introduced Atomic JSON Operations: A new utility module atomic-writer.ts has been added to @automaker/utils, providing functions for atomic JSON file writes (atomicWriteJson) and robust JSON file reads with automatic recovery from backups (readJsonWithRecovery).
  • Enhanced Data Integrity for Feature Files: All operations involving writing and reading feature.json files across various services (parse-and-create-features, auto-mode-service, feature-loader) now utilize the new atomic write and recovery mechanisms, significantly reducing the risk of data corruption due to crashes.
  • Improved Settings File Handling: The settings-service has been updated to use the new atomicWriteJson utility for saving configuration and credentials, replacing a local implementation and benefiting from the added backup and recovery features.
  • Comprehensive Test Coverage: New unit tests have been added for the atomic-writer utilities, ensuring the reliability and correctness of the atomic file operations and recovery logic.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a robust solution to prevent feature.json corruption by implementing atomic writes and reads with recovery capabilities. The new atomic-writer.ts utility is well-designed, providing atomic operations with backup and recovery from temporary files or backups, which significantly enhances data integrity. These changes have been consistently applied across various services, replacing direct file system access with the new safer utilities. The inclusion of a comprehensive test suite for the new atomic writer is also a great addition, ensuring the reliability of this critical component. The overall quality of the implementation is high. As a suggestion for future improvement, the private loadFeature method within AutoModeService could also be updated to use the new featureLoader.get() method to ensure all feature loading paths are protected against file corruption.

@Shironex Shironex merged commit 2f38ffe into v0.12.0rc Jan 17, 2026
7 checks passed
@Shironex Shironex deleted the feature/v0.12.0rc-1768605251997-8ufb branch January 17, 2026 00:00
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.

1 participant