Skip to content

Add repository interface experiment with SQLite regex filtering#36

Merged
eviltester merged 11 commits into
masterfrom
codex/repository-interface-experiment
Jul 6, 2026
Merged

Add repository interface experiment with SQLite regex filtering#36
eviltester merged 11 commits into
masterfrom
codex/repository-interface-experiment

Conversation

@eviltester

Copy link
Copy Markdown
Owner

Summary

  • add the repository provider experiment with SQLite-backed repository modes
  • route repository reads/writes through the repository surface for the migrated paths
  • add standalone SQLite todo manager app support
  • push supported SQLite filters/sorts into SQL
  • add conservative regex-to-LIKE conversion for SQLite ~= filters
  • register a Java-backed SQLite REGEXP function for regex filters that cannot safely convert to LIKE
  • deprecate legacy SimpleQuery as an ERInstanceData-backed compatibility path

Validation

mvn -pl ercoremodel -am "-Dtest=SqliteRegexToLikeConverterTest,ThingRepositoryContractTest" -DfailIfNoTests=false test
mvn -pl ercoremodel,thingifier,challenger -am "-Dtest=SqliteRegexToLikeConverterTest,ThingRepositoryContractTest,QueryFiltersStringTest,QueryFiltersIntegerTest,TodoManagerQueryEngineTest,RelationshipApiSqliteRepositoryTest,DefaultGuiHtmlPagesRepositoryTest,ChallengeApiModelRepositoryTest" -DfailIfNoTests=false test
mvn test

All validation passed locally.

Issues

Copilot AI review requested due to automatic review settings July 6, 2026 17:21

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@eviltester eviltester merged commit c5b5ef7 into master Jul 6, 2026
2 checks passed

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: fdce182760

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +493 to +497
private void loadExistingData() {
for (EntityDefinition entity : schema.getEntityDefinitions()) {
loadEntityRows(entity);
restoreCountersFor(entity);
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Restore counters before repository writes

For file-backed SQLite repositories, counters are restored only from loadExistingData(), which is only reached when the deprecated compatibility snapshot is requested. If the app restarts and handles normal repository-backed writes before any getInstanceData() call, countersFor() still starts auto-increment fields at their default value, so the next created row reuses ids that already exist in SQLite; with the current persistence path this can overwrite an existing row, and even without that it would make the first create after restart fail. Initialize or lazily restore the counters before writes/counter access, not only when hydrating the snapshot.

Useful? React with 👍 / 👎.

Comment on lines +853 to +854
String sql = "INSERT OR REPLACE INTO " + table(entity) +
" (" + names + ") VALUES (" + placeholders + ")";

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Do not replace rows on unique conflicts

Using SQLite INSERT OR REPLACE here turns any primary-key or unique-field conflict into a delete-and-insert of the existing row. In a file-backed repo after restart, or whenever the in-memory uniqueness check has not hydrated the conflicting row, creating/updating an instance with a duplicate unique value silently removes the old instance instead of returning the existing validation/constraint error, leaving stale relationship rows and losing user data.

Useful? React with 👍 / 👎.

Comment on lines +91 to +95
public void deleteRepository(final String databaseKey) {
ThingRepository repository = repositories.remove(databaseKey);
if (repository != null) {
repository.close();
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Remove file-backed database files when deleting repositories

In sqlite-file mode this only removes the repository from the provider and closes the connection; the <databaseKey>.sqlite file remains on disk. Any flow that deletes a logical database and later recreates the same key, such as expired challenger/session cleanup followed by restoring or reusing that id, reopens the old file and exposes the stale data that deletion was expected to discard.

Useful? React with 👍 / 👎.

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