Skip to content

feat(logging): adapt execution logging and shared contracts - #68

Merged
vistart merged 12 commits into
release/v1.0.0.dev17from
feature/logging-audit
Nov 10, 2026
Merged

vistart merged 12 commits into
release/v1.0.0.dev17from
feature/logging-audit

Conversation

@vistart

@vistart vistart commented Nov 10, 2026

Copy link
Copy Markdown
Contributor

Description

Aligns this backend with the core execution-logging contract introduced in rhosocial/python-activerecord#137.

  • execute_many accepts keyword-only options: ExecutionOptions | None and forwards it to the shared helpers; backends without overrides inherit the core implementation.
  • Single and batch executions use log_execution_start, log_batch_start, log_execution_summary, log_batch_summary and log_execution_error from core. Raw SQL/parameter logging and duplicate batch summaries are removed.
  • Sync and async backends share the canonical rhosocial.activerecord.backend.<type> logger.
  • Narrow backend log() overrides that dropped extra= are removed where present; CLI modules use the configured library logger.
  • INFO SQL and lifecycle chatter is downgraded to DEBUG; ERROR records logged immediately before a re-raise are downgraded to DEBUG, while swallowed recovery failures stay WARNING.
  • Adds the four shared-contract bridges: ordered-has-many, find-one-or-create, read-only models, keyless models.
  • Backend-specific test/schema gaps exposed by those contracts are fixed in this branch (for example orderable text columns and integrity-error normalization).

Depends on the core branch feature/logging-execution (PR rhosocial/python-activerecord#137); the temporary CI core reference points there.

No tracking issue.

Type of change

  • feat: A new feature
  • changed: A change in existing functionality
  • docs: Documentation only changes
  • test: Adding missing tests or correcting existing tests
  • perf: A code change that improves performance
  • chore: Changes to the build process or auxiliary tools and libraries
  • ci: Changes to our CI core reference
  • build: Changes that affect the build system or external dependencies
  • revert: Reverts a previous commit

Breaking Change

  • Yes, for end-users
  • Yes, for backend developers
  • No breaking changes

Impact on End-Users:

INFO output no longer contains raw SQL or parameter values; the backend now emits the core dml.* / dql.* / ddl.* / transaction.* summaries.

Impact on Backend Developers (Custom Implementations):

Custom overrides of execute_many, fetch_all or fetch_one must accept the new options / log_context keywords.

Applicable rhosocial-activerecord Version Range:

rhosocial-activerecord>=1.0.0.dev30,<2.0.0 once the core PR is released; CI currently tracks the core branch.

Related Repositories/Packages

Testing

  • I have added new tests to cover my changes.
  • I have updated existing tests to reflect my changes.
  • All existing tests pass in CI.
  • This change has been tested on the backend's CI matrix.

Test Plan:

pytest tests/rhosocial/activerecord_postgres_test/feature/relation/ordering/test_has_many_order_by.py
pytest tests/rhosocial/activerecord_postgres_test/feature/query/basic/test_find_one_or_create.py
pytest tests/rhosocial/activerecord_postgres_test/feature/basic/readonly/test_readonly_models.py
pytest tests/rhosocial/activerecord_postgres_test/feature/basic/nopk/test_keyless_models.py

Live runs against postgres_18 and postgres_9 / postgres_19beta4: 352 passed, including the execute_many regression.

Checklist

  • My code follows the project's code style guidelines.
  • I have performed a self-review of my own code.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have made corresponding changes to the documentation where needed.
  • My changes generate no new warnings.
  • I have added a changelog fragment (changelog.d/<issue_number>.<type>.md).
  • I have verified that my changes do not introduce SQL injection vulnerabilities.
  • I have checked for potential performance regressions.

Additional Notes

The changelog fragment is added after the PR number is known. The CI core reference will be switched to the next core release after PR rhosocial/python-activerecord#137 merges.

@vistart vistart self-assigned this Nov 10, 2026
@codecov

codecov Bot commented Nov 10, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 67.00000% with 33 lines in your changes missing coverage. Please review.
✅ Project coverage is 78.06%. Comparing base (19f6eb2) to head (87665e2).

Files with missing lines Patch % Lines
...ord/backend/impl/postgres/backend/async_backend.py 68.96% 9 Missing ⚠️
...iverecord/backend/impl/postgres/backend/backend.py 68.96% 9 Missing ⚠️
...activerecord/backend/impl/postgres/backend/sync.py 68.96% 9 Missing ⚠️
.../activerecord/backend/impl/postgres/transaction.py 33.33% 4 Missing ⚠️
...al/activerecord/backend/impl/postgres/cli/query.py 50.00% 2 Missing ⚠️

❌ Your patch check has failed because the patch coverage (67.00%) is below the target coverage (75.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
@@                   Coverage Diff                    @@
##           release/v1.0.0.dev17      #68      +/-   ##
========================================================
+ Coverage                 77.55%   78.06%   +0.50%     
========================================================
  Files                       360      360              
  Lines                     19335    19340       +5     
  Branches                   3173     3172       -1     
========================================================
+ Hits                      14995    15097     +102     
+ Misses                     3217     3110     -107     
- Partials                   1123     1133      +10     
Flag Coverage Δ
postgres-18 78.06% <67.00%> (+0.50%) ⬆️
python-3.14 78.06% <67.00%> (+0.50%) ⬆️
unittests 78.06% <67.00%> (+0.50%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@sonarqubecloud

Copy link
Copy Markdown

@vistart
vistart merged commit 576cbf6 into release/v1.0.0.dev17 Nov 10, 2026
16 of 17 checks passed
@vistart
vistart deleted the feature/logging-audit branch November 10, 2026 10:08
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