Skip to content

Refactor mini_sim_db toward local-first sync workflow - #10

Merged
hyharry merged 1 commit into
masterfrom
feat/local-sync-model
Apr 10, 2026
Merged

Refactor mini_sim_db toward local-first sync workflow#10
hyharry merged 1 commit into
masterfrom
feat/local-sync-model

Conversation

@hyharry

@hyharry hyharry commented Apr 10, 2026

Copy link
Copy Markdown
Owner

Summary

  • pivot mini_sim_db from client/server-first toward a local-first + later-sync workflow
  • move REST transport into an optional remote_api/ module
  • add explicit sync export/import/status workflow on top of the SQLite backend

What changed

  • move REST client/server implementation into remote_api/
  • keep compatibility wrappers in sim_db_client.py and sim_db_server.py
  • add local-first sync artifact export/import flow using job_id + updated_at
  • add sync status visibility for pending/synced items
  • keep the initial reconcile policy simple and explicit

Sync model

  • artifact format: mini_sim_db_sync_v1 JSON file
  • merge key: job_id
  • reconcile policy:
    • newer updated_at wins
    • equal timestamps are skipped as unchanged
    • local newer stays local and is reported as conflict
    • case-name collision with different job_id is reported as conflict

Verification

  • python3 -m unittest -v
  • all tests passed locally

Notes

This PR intentionally builds on the SQLite storage PR that is already merged. The remote API remains available, but it is now treated as an optional transport layer rather than the primary architecture.

@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: 882f8abcaa

ℹ️ 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 thread remote_api/client.py
Comment on lines +246 to +247
if fields:
upd_cases(self.local_db_path, {case: fields})

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 Update local timestamp on fallback writes

When SimDbClient applies an update locally (for dual-write or offline fallback), it forwards user fields directly to upd_cases without setting updated_at. In the new sync workflow, pending detection relies on last_synced_updated_at < updated_at, so any local-only update that does not include a newer timestamp can be permanently omitted from sync-export after an initial sync. This is reproducible with a transport failure path: export once, run client.update(...) offline, then sync_status still reports zero pending even though fields changed.

Useful? React with 👍 / 👎.

@hyharry
hyharry merged commit 339582d into master Apr 10, 2026
8 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.

1 participant