feat(store): JobsRepo CRUD over ix_jobs + integration fixtures #20

Merged
goldstein merged 1 commit from feat/jobs-repo into main 2026-04-18 09:43:29 +00:00
Owner

JobsRepo covers the full job-lifecycle surface: insert_pending (idempotent), claim_next_pending (FOR UPDATE SKIP LOCKED), get, get_by_correlation, mark_done, mark_error, update_callback_status, sweep_orphans.

Integration fixtures skip cleanly without a DB; with a DB, Alembic runs in a subprocess to sidestep pytest-asyncio loop collisions. 15 integration tests pass locally against postgres:16.

Chunk 3 Task 3.3. Forgejo Actions trigger is flaky; local verification is the gate (uv run pytest tests/unit + IX_TEST_DATABASE_URL=... uv run pytest tests/integration both green).

JobsRepo covers the full job-lifecycle surface: insert_pending (idempotent), claim_next_pending (FOR UPDATE SKIP LOCKED), get, get_by_correlation, mark_done, mark_error, update_callback_status, sweep_orphans. Integration fixtures skip cleanly without a DB; with a DB, Alembic runs in a subprocess to sidestep pytest-asyncio loop collisions. 15 integration tests pass locally against postgres:16. Chunk 3 Task 3.3. Forgejo Actions trigger is flaky; local verification is the gate (`uv run pytest tests/unit` + `IX_TEST_DATABASE_URL=... uv run pytest tests/integration` both green).
goldstein added 1 commit 2026-04-18 09:43:23 +00:00
feat(store): JobsRepo CRUD over ix_jobs + integration fixtures (spec §4)
All checks were successful
tests / test (push) Successful in 1m10s
tests / test (pull_request) Successful in 1m10s
141153ffa7
JobsRepo covers the full job-lifecycle surface:

- insert_pending: idempotent on (client_id, request_id) via ON CONFLICT
  DO NOTHING + re-select; assigns a 16-hex ix_id.
- claim_next_pending: FOR UPDATE SKIP LOCKED so concurrent workers never
  double-dispatch a row.
- get / get_by_correlation: hydrates JSONB back through Pydantic.
- mark_done: done iff response.error is None, else error.
- mark_error: explicit convenience wrapper.
- update_callback_status: delivered | failed (no status transition).
- sweep_orphans: time-based rescue of stuck running rows; attempts++.

Integration fixtures (tests/integration/conftest.py):
- Skip cleanly when neither IX_TEST_DATABASE_URL nor IX_POSTGRES_URL is
  set (unit suite stays runnable on a bare laptop).
- Alembic upgrade/downgrade runs in a subprocess so its internal
  asyncio.run() doesn't collide with pytest-asyncio's loop.
- Per-test engine + truncate so loops never cross and tests start clean.

15 integration tests against a live postgres:16, including SKIP LOCKED
concurrency + orphan sweep.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
goldstein merged commit 04a415a191 into main 2026-04-18 09:43:29 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: goldstein/infoxtractor#20
No description provided.