Skip to content

Feature/SQLite persistence#20

Closed
JGsouzaa wants to merge 5 commits intobrunoerg:mainfrom
JGsouzaa:feature/SQLite_persistence
Closed

Feature/SQLite persistence#20
JGsouzaa wants to merge 5 commits intobrunoerg:mainfrom
JGsouzaa:feature/SQLite_persistence

Conversation

@JGsouzaa
Copy link

SQLite feature developed based on #11

*Development Summary:


[sqlite.rs file (NEW FILE)]:

Implemented the following functions:

  • check_db
  • _createdb
  • _check_schema
  • _fill_projects_table
  • _check_initial_row
  • store_run
  • store_mutants
  • check_mutation_folder
  • get_files_from_folder
  • get_file_diff
  • get_hash_from_diff
  • update_status_mutant
  • update_command_to_test_mutant
  • update_mutants_table

Implemented the following tests:

  • test_db_creation_and_seed
  • test_store_run_creates_row
  • test_store_mutants_inserts_rows
  • test_update_status_mutant
  • test_update_command_mutant

[main.rs file (MODIFICATIONS)]:

Implemented the following logic:

  • Added mod sqlite.rs
  • Optional SQLite flag for mutation + handler
  • Optional SQLite flag for analyze with --run_id + handler

[lib.rs file (MODIFICATIONS)]:

  • sqlite.rs module

[git_changes.rs file (MODIFICATIONS)]:

  • get_commit_hash function implementation

[error.rs file (MODIFICATIONS)]:

  • Added Sqlite and MissingDbPath errors

[analyze.rs file (MODIFICATIONS)]:

  • Adapted run_analysis signature to get db_path and run_id
  • Added update_status_mutant and update_command_to_test_mutant on current logic
  • Changed find_mutation_folders visibility to public so it can be called from the sqlite.rs module

[Cargo.toml file (MODIFICATIONS)]:

  • Added rusqlite and sha2 dependencies

*Additional comments:

  • strategy, config_json from the current execution config -> NOT IMPLEMENTED

  • The database schema follows the issue documentation entirely, with only one exception on table mutant that was inserted an additional column called file_name to query on analyze section

  • Apart from the code tests, the following functional tests were performed manually:

    • (mutate) -> --sqlite flag optional, normal behavior {OK}

    • (mutate --sqlite ) -> Creates/open "db/mutation.db" and uses it {OK}

    • (mutate --sqlite results.db) -> Creates/open "db/results.db" and uses it {OK}

    • (mutate --sqlite ...) -> Verify INSERT OR IGNORE INTO projects (name, repository_url) VALUES ('Bitcoin Core', 'https://github.com/bitcoin/bitcoin'); {OK}

    • (mutate --sqlite...) -> General behavior: Open DB (create if missing) Ensure projects seed (bitcoin core), create run, insert mutants {OK}

    • (analyze --sqlite) -> Asks for run_id {OK}

    • (analyze --sqlite <db_file> <run_id> ) -> Record standard commands {OK}

    • (analyze <without file (-f ...)> --sqlite <run_id> ...) -> Record only for run_id, behave like analyze normally {OK}


*Further implementations suggestion:

  • Modify logic when grabbing file extensions (current supports only for .cpp, .h and .py files)
  • Implement help options for flag --sqlite
  • Insert one more table column on table runs indicating the total number of mutants generated
  • Explore options for compress the data on column "diff" on table "mutants" if diffs become hard to store and read
  • Implement a folder called bcore-mutation on the project that it's running to hold "db" and "mutants" folders apart from original project

@JGsouzaa JGsouzaa force-pushed the feature/SQLite_persistence branch 3 times, most recently from eb2257d to a255f22 Compare December 27, 2025 10:39
@brunoerg
Copy link
Owner

Please, you should better organize your commits by squashing some of them.

js and others added 5 commits January 13, 2026 16:58
Added Path to flag

Added get_commit_hash function

refactored into functions

implemented error handling for rusqlite errors

mod for sqlite
added hash for diffs

sha2 dependency

filepath functionality

sqlite storing mutants into db

bug fix in folder_path for sqlite
implemented update_status_mutant, change to snake case in variable, adition of a file_name colunm on mutants table

implemented update command_to_test_mutant

fix fullpath bug without -f flag on analysis

--run_id necessary for --sqlite flag
Error handling for unwrap() parts

MissingDbPath handler for MutationError enum
updated readme with Storage and Update storage functions

bug fix on analyze without --sqlite and --runid flags
@JGsouzaa JGsouzaa force-pushed the feature/SQLite_persistence branch from a255f22 to c02ed02 Compare January 13, 2026 20:06
@JGsouzaa
Copy link
Author

Please, you should better organize your commits by squashing some of them.

Thanks for the suggestion. I’ve done the squash as recommended. If you have any further tips on how to better organize the commits, I’d be happy to hear them.

Copy link
Owner

@brunoerg brunoerg left a comment

Choose a reason for hiding this comment

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

I think the approach went to a wrong direction. The idea of having sqlite persistence is not relaying on muts-* folder anymore. When generating the mutants and storing them, you don't need the muts-* folder, you could do it in the source code. Again, the idea is not having these folders anymore.

Also, some points we could take in consideration - here or in a follow-up:

  1. The README says --run_id but the correct one is --runid.
  2. Analysis should run only for the "pending" mutants. Imagine a scenario where the power went out right in the middle of the analysis, and you'd like to resume it. Therefore, you would need to run the analysis for the mutants that haven't been analyzed yet, not for all of them.
  3. It would be great if we had a new command, something like "report" that would generate the .json file (the result as we have now) based on unkilled mutants from a specified run_id or (even better) from a date range.
  4. Would be great to print the run id after running mutate. This way I know the run id to then run the analysis. Without it, I would have to check the database by myself.

@brunoerg
Copy link
Owner

brunoerg commented Feb 2, 2026

Also, it needs rebase.

@brunoerg
Copy link
Owner

brunoerg commented Mar 3, 2026

Closing in favor of #35.

@brunoerg brunoerg closed this Mar 3, 2026
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