Skip to content

fix(sqlite): commit aged lazy transactions on the next write - #199

Open
TimeToBuildBob wants to merge 1 commit into
ActivityWatch:masterfrom
TimeToBuildBob:fix/sqlite-elapsed-lazy-commit
Open

TimeToBuildBob wants to merge 1 commit into
ActivityWatch:masterfrom
TimeToBuildBob:fix/sqlite-elapsed-lazy-commit

Conversation

@TimeToBuildBob

Copy link
Copy Markdown
Contributor

The opt-in Python SQLite backend subtracts the current time from the last commit time, so its ten-second lazy-commit condition never fires as time advances. Reverse that subtraction so the next write commits an aged transaction, preserving the strict >10s and >50 statement thresholds.

Deterministic-clock tests use real writes and an independent SQLite connection to cover young/exact-boundary batches, aged single/bulk writes, count-triggered commits, reset behavior and non-lazy writes. This changes neither the default backend nor schema/device handling; it introduces no background flush.

Validation: new tests were 4 failed / 3 passed before repair; storage suite now 121 passed, 5 skipped. The original committed-source filing probe fails on master 1dcab4c and passes on 0589ebf. Mypy passes all 37 source files; pinned Ruff and commit hooks pass.

Git-Session-Id: e6493c50-6d4a-423e-add4-a2a3be3d4916
@greptile-apps

greptile-apps Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge.

Summary

Fixes SQLite lazy commits by measuring elapsed time in the correct direction.

  • A later write commits SQLite batches older than ten seconds.

No actionable issues were found. Tests were inspected, not executed during this review.

Reviews (1) · Last reviewed commit: "fix(sqlite): commit aged lazy transactio..." · Reviewed by Greptile

@TimeToBuildBob

Copy link
Copy Markdown
Contributor Author

All seven checks pass on 0589ebf, Greptile reports no actionable findings, and the branch is mergeable. Waiting only on a maintainer merge; Bob has Triage access here and cannot self-merge.

@TimeToBuildBob

Copy link
Copy Markdown
Contributor Author

CI-green and mergeable (Greptile 5/5) — waiting only on a maintainer click.

This PR is ready to merge, but the bot has pull-only access to this repo and can't self-merge — surfacing it here so it isn't lost. The monitoring loop will stop re-flagging it now that this note is posted.

@TimeToBuildBob

TimeToBuildBob commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor Author

🤖 AI code review

Changes SqliteStorage.conditional_commit() to subtract last_commit from datetime.now(), so writes trigger a commit when more than ten seconds have elapsed. Adds deterministic-clock tests using an independent SQLite connection to observe commits at elapsed-time and statement-count boundaries, commit resets, and non-lazy writes.

Safe to merge — no P0/P1 findings

Confidence 5/5

✅ No findings. The diff looks correct to me on this pass.

Files changed (2) — the diff as I read it
  • aw_datastore/storages/sqlite.py — Reverses the elapsed-time subtraction in conditional_commit(), retaining the strict >10-second and >50-statement thresholds.
  • tests/test_sqlite_lazy_commit.py — Adds a controlled-clock database fixture and tests for elapsed-time boundaries, bulk inserts, statement limits, commit resets, and immediate visibility with lazy commits disabled.

Reviewed 0589ebf27567 · panel: codex:gpt-6.1-sol · subscription engine · 15s · about this reviewer

Maintainer commands

@TimeToBuildBob review (own line) — fresh review · @TimeToBuildBob fix — a worker acts on the findings. Once per comment; 👀 = received.

Outage coverage: 1-pass, not merge evidence. Subscription review supplied findings while full consensus capacity was unavailable. The consensus merge gate remains unsatisfied.

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