Skip to content

Clean up package pins when deposits roll back - #121

Closed
LIghtJUNction wants to merge 1 commit into
mainfrom
codex/fix-vulnerability-in-package-deposit-process
Closed

LIghtJUNction wants to merge 1 commit into
mainfrom
codex/fix-vulnerability-in-package-deposit-process

Conversation

@LIghtJUNction

Copy link
Copy Markdown
Contributor

Motivation

  • Prevent external content pins from accumulating when store.package_deposit durably pins blobs before the enclosing metadata transaction commits, which allows repeated failed deposits to exhaust storage.

Description

  • Add a rollback-compensation hook on_rollback to the MetadataSession contract so handlers can register async cleanup work to run when a transaction or savepoint rolls back (src/msg/core/contracts.py).
  • Implement rollback compensation bookkeeping and execution in SqliteSession by tracking rollback_effects, exposing on_rollback, and running compensations on rollback and nested savepoint aborts (src/msg/storage/sqlite.py).
  • Mirror nested savepoint rollback compensation and post-commit cleanup invocation in the Postgres transaction wrapper so PostgreSQL-backed sessions also run compensations on rollback (src/msg/storage/postgres.py).
  • Register an idempotent unpin callback immediately before creating durable pins in store.package_deposit so the content store is unpinned if the metadata transaction aborts (src/msg/plugins/store.py).
  • Add a regression test test_failed_deposit_projection_removes_external_pins that replays an invalid-projection deposit and asserts no new pins or package rows accumulate, and extend the test request helper to allow exercising return_fields (tests/test_store_foundation.py, tests/test_service.py).

Testing

  • Ran a focused transaction rollback unit test via PYTHONPATH=src uv run --python 3.14 --no-project --with pytest --with pytest-asyncio pytest -q -c /dev/null --confcutdir=/tmp /tmp/test_rollback_effects.py, which passed and verified nested rollback-effect ordering.
  • Ran a bytecode/compile check via uv run --python 3.14 --no-project -m compileall -q src/msg tests/test_service.py tests/test_store_foundation.py, which succeeded.
  • Ran repository checks (git diff --check) which reported no issues.
  • Attempted to run pytest -q tests/test_store_foundation.py to exercise database-backed tests; collection and one independent test passed but five PostgreSQL-backed tests could not initialize in this environment because initdb (PostgreSQL) is not available.

Codex Task

Copilot AI lite review requested due to automatic review settings September 28, 2026 11:41

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 28, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
🔒 Security Review ✅ Completed 2026-09-28T11:46:56.469142Z c2e3205 PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@LIghtJUNction

Copy link
Copy Markdown
Contributor Author

Superseded by merged #142 (edf0d55). This branch targets the pre-integration tree and would duplicate or conflict with the security repairs already on main.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants