Skip to content

fix(access): commit the approval result owner with the approval - #2993

Open
ctxloop wants to merge 1 commit into
oceanbase:masterfrom
ctxloop:fix/approval-owner-migration-race
Open

ctxloop wants to merge 1 commit into
oceanbase:masterfrom
ctxloop:fix/approval-owner-migration-race

Conversation

@ctxloop

@ctxloop ctxloop commented Dec 3, 2026

Copy link
Copy Markdown
Contributor

Which issue or RFC does this PR close?

Refs #2456 (6).

Rationale for this change

When Access is enforced and an approval publishes a new Artifact (target is None), approval commits first and writes the Artifact's owner afterward, outside both the approval transaction and the owner recovery outbox.

If POST /v1/access/ownership/apply runs in that window, ownership migration claims the Artifact with the migration Principal. The approval then fails with 409 artifact-owner, and the migration Principal remains the owner.

What changes are included in this PR?

  • Add an on_commit hook to ReviewService.approve and ScopedReviewApplication.approve for Experience, Skill (including Dream derive_skill), and Profile Candidates. Target-revising Dream families and tag Candidates do not run it.
  • Write the new Artifact's owner inside the approval transaction on a same-database store, or stage a recovery intent in the outbox on an external store.
  • Flush staged owner writes after approval commits, while keeping the post-commit fallback for ownerless results committed while Access was disabled.
  • Add regression tests in tests/e2e/test_access_ownership_migration.py for failed owner writes, online migration racing approval (Experience and Profile, local and external stores), and ownerless approval retry.

Are there any user-facing changes?

Yes. If writing the new Artifact's owner fails during enforced approval (target is None):

  • Same-database store: approval rolls back and returns 503 (the Candidate stays pending). Before, approval committed an ownerless Artifact.
  • External store: approval commits with a pending recovery intent and returns 503; migration reports owner-recovery-pending instead of claiming it, and retrying approval delivers the owner and returns 200.

Public APIs and persisted formats do not change.

How was this change tested?

  • New and updated regression tests in tests/e2e/test_access_ownership_migration.py.
  • uv run pytest tests/e2e/test_access_ownership_migration.py -q -n 4: 50 passed.
  • uv run pytest tests/e2e/test_candidate_review.py -q -n 4: 2 passed, 1 skipped.
  • uv run ruff check, uv run ruff format --check, and uv run ty check passed on all modified files.

Tests use local SQLite single-database and two-database external Access store configurations. No live external Access backend acceptance is claimed.

AI usage statement

I used Claude Code (Claude Opus 5.5), Gemini 4 Neon, and Codex (GPT-6.1-sol) to write, rebase, and audit this change. I selected the approach and examined the diff and tests.

Writing a new result Artifact's owner after approval committed let online
ownership migration claim it first and fail the approval with 409. Write the
owner (or stage its recovery intent for external stores) in the approval
transaction instead.

Refs oceanbase#2456 (6)

This branch has not been deployed

No deployments
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