Skip to content

feat: add taxonomy database background updater - #411

Merged
codeZe-us merged 3 commits into
Toolbox-Lab:mainfrom
akinboyewaSamson:feat/taxonomy-auto-update
Aug 24, 2026
Merged

feat: add taxonomy database background updater#411
codeZe-us merged 3 commits into
Toolbox-Lab:mainfrom
akinboyewaSamson:feat/taxonomy-auto-update

Conversation

@akinboyewaSamson

Copy link
Copy Markdown

Description

This PR implements an automated, non-blocking background mechanism in the CLI to keep the taxonomy database up to date. It ensures users have the latest error definitions and diagnostic insights without interrupting their workflow, while also respecting offline mode preferences.

How It Was Done

-Updater Module (updater.rs): Created a new module in grat-core that uses reqwest to ping the remote repository for the latest taxonomy version.

  • Caching Mechanism: Utilized the directories crate for cross-platform paths and cached a 24-hour timestamp (~/.cache/grat/taxonomy_update.json) to prevent spamming the remote server on every invocation.
  • Atomic Replacements: When a newer version is downloaded, it is written to a temporary .tmp file and atomically renamed to ~/.local/share/grat/taxonomy/database.toml to prevent database corruption during reads.
  • Loader Adjustments: Introduced TaxonomyDatabase::load_latest() to prioritize loading the downloaded file before falling back to the embedded data/*.toml files.
  • CLI Integration: Added a global --offline flag to explicitly disable network requests and spawned the update task concurrently in crates/cli/src/main.rs.

Issues Encountered (If Any)

  • Assumed the fallback structure for the database would remain intact by appending the downloaded file loading as the primary check and only executing load_embedded() if no updated file exists or if it fails to parse.
  • Refactored away from chrono to rely solely on standard library SystemTime in updater.rs to maintain a clean dependency tree in grat-core.

Related Issue

Closes #407

How It Was Tested

  • Code built and checked using cargo check and cargo build.
  • Manually verified that the --offline flag is respected and prevents background network requests.
  • Validated atomic renaming logic and tested that TaxonomyDatabase::load_latest() seamlessly cascades from the cache to the fallback without breaking existing tests.

Screenshots / Video (If Applicable)

N/A - This is a background implementation with no UI changes.

@coderabbitai

coderabbitai Bot commented Aug 23, 2026

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 10bfcc2d-0fef-4e77-b584-d2c808268d7b


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.

@codeZe-us

Copy link
Copy Markdown
Contributor

@akinboyewaSamson Fix the CI issue

@codeZe-us
codeZe-us self-requested a review August 24, 2026 12:09
@codeZe-us

Copy link
Copy Markdown
Contributor

PR reviewed

@codeZe-us
codeZe-us merged commit 0748c71 into Toolbox-Lab:main Aug 24, 2026
3 checks passed
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.

Implement AutoUpdate for Taxonomy Database

3 participants