Skip to content

OPS-REF-002A: split PostgreSQL source-family stable ID and SQL builders#650

Merged
ktalpay merged 1 commit into
developfrom
codex/extract-stable-id-and-sql-builders
Jun 2, 2026
Merged

OPS-REF-002A: split PostgreSQL source-family stable ID and SQL builders#650
ktalpay merged 1 commit into
developfrom
codex/extract-stable-id-and-sql-builders

Conversation

@ktalpay

@ktalpay ktalpay commented Jun 2, 2026

Copy link
Copy Markdown
Owner

Motivation

  • The PostgreSQL source-family repository owned multiple unrelated responsibilities making further refactors harder.
  • The goal is a narrow extraction of stable UUID generation and master/detail SQL builders while preserving existing behavior.
  • Keep parameter mapping, transaction helpers, source-document upsert, ingestion-run upsert, and error redaction in place for follow-up refactors.

Description

  • Added src/carbonfactor_parser/persistence/postgresql_source_family_ids.py which exposes source_document_uuid(record), ingestion_run_uuid(record), master_uuid(source_family, master_id), and detail_uuid(source_family, detail_id) and preserves the original uuid.uuid5 JSON tuple payload behavior.
  • Added src/carbonfactor_parser/persistence/postgresql_source_family_sql.py which exposes master_insert_sql(source_family) and detail_insert_sql(source_family) and preserves table names, column order, JSONB casts, conflict targets, and RETURNING clauses.
  • Updated src/carbonfactor_parser/persistence/postgresql_source_family_repository.py to call the new helpers (SQL builders and stable ID helpers) and to continue owning parameter mapping and execution logic.
  • Extended tests/test_postgresql_source_family_repository.py with focused compatibility tests for stable UUID helpers, ingestion-run fallback determinism, and master/detail SQL shape and kept existing repository tests unchanged.

Testing

  • Ran python -m pytest tests/test_postgresql_source_family_repository.py which completed with 15 passed, 1 skipped.
  • Ran python -m pytest tests/test_configured_cycle_runner.py tests/test_ingestion_run_history_mapping.py tests/test_ingestion_run_history_repository.py tests/test_ingestion_run_history_reader.py which completed with 50 passed.
  • Ran the full test suite with python -m pytest which completed with 2156 passed, 8 skipped.
  • Ran linting with python -m ruff check src/carbonfactor_parser/persistence/postgresql_source_family_repository.py src/carbonfactor_parser/persistence/postgresql_source_family_ids.py src/carbonfactor_parser/persistence/postgresql_source_family_sql.py tests/test_postgresql_source_family_repository.py which passed, and git diff --check which reported no issues.

Codex Task

@ktalpay
ktalpay merged commit 0ff6d93 into develop Jun 2, 2026
2 checks passed
@ktalpay
ktalpay deleted the codex/extract-stable-id-and-sql-builders branch June 2, 2026 13:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant