Repository navigation
feat(db): apply dormant MANUAL authorization atomically - #14
Merged
Merged
Conversation
Implement prerequisite P-B from accepted D02 authority and signed B1 proof with exact workflow, audit, source, claim and revision finality. Preserve REFUND and keep capture, P-C and runtime activation closed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What and why
P-A supplied the tagged proof envelope but no atomic MANUAL authorization application. Migration 0013 adds dormant SQL preparation, application and original-result recognition for MANUAL AUTHORIZE_SUCCESS, consuming genuine accepted D02 command/execution/complete original result and independent SDK-signed B1 proof.
A successful caller-owned READ COMMITTED transaction establishes the canonical AUTH root, tagged manifest/permit, SUCCEEDED attempt, AUTHORIZED payment, exactly one provider audit, application, exact receipt/source dispositions, scope revision and current-generation PROCESSED inbox together. Result
VERIFIED_NO_EFFECT/ reasonAUTHORIZE_SUCCESSrecognizes no capture, fee, journal, lot or capture child. Missing, contradictory, stale, unsupported or incomplete evidence refuses without partial application.P-B only. Contracts/enrollment remain empty by default; private NOLOGIN owners receive narrow rights, with no runtime LOGIN grants or activation. P-C, B2-A/B/C, automatic authorization, production routing/workers and financial posting are excluded. Existing REFUND behavior and historical financial policies remain intact.
Review guide
Read carefully — T2 Human Review Guide:
Also read the restricted AUTH fixture: the positive chain starts REQUIRES_AUTHORIZATION with zero recognized totals, accepts D02 in the same initial transaction, executes scripted SDK transport and independently signed receipts, then seals/binds separately. It does not seed successful authorization evidence.
The application spec covers genuine success, ownership/contradiction/stale-claim refusal, duplicate recognition, raw grants/forgeries, 11 omitted whole groups, savepoint/late rollback, deferred immediate validation and observed distinct-backend concurrency. The migration spec covers fresh/repeated/populated upgrade, complete catalog/data/ACL/owner rollback and DDL waiting.
Skim: journal append, current-chain count updates in existing harness/specs, explicit original0012 staging for P-A catalog assertions, and owning-document additions. Historical SQL/snapshots and original financial assertions are unchanged.
Least confident / later gates: production principal/session fencing and all-writer integration; P-C CAPTURE_PENDING and genuine post-capture historical recognition; live provider/broker behavior. No production-readiness claim.
Tests removed, weakened or newly explicitly skipped: none. New suites use the standard environment gate. Six historical F01 cases remain opt-in. Review-signal warnings identify two new
toBeDefined()error-presence checks in race tests; they are paired with observed lock waits and exact application/audit/revision/disposition or zero-application assertions, not replacements for old assertions. The refusal helper attempts prepare and apply, so prepare-only deferred rejection cannot mask invalid-evidence tests.Task size
T2 / HIGH_RISK. Invariants touched: original source/proof and merchant/account/currency ownership; canonical application uniqueness; claim/principal/revision ownership; exact immutable audit cardinality; restricted SQL capabilities; ordered locking; commit-time finality and complete rollback.
Transaction boundary: prepare and apply share one caller-owned READ COMMITTED transaction. Claims/failure CAS and source publication/sealing/binding commit separately. Authorization remains distinct from capture/ledger/settlement/payout; no accounting semantics, rounding or public API idempotency contract changes.
Checks
Local results are not hosted CI. The 13 published files are byte-identical to independently approved checkpoint
52dd2466…b69b1c9; authorized commit/rebase changes Git metadata and incorporates main's agent/workflow-only update.pnpm lintRUN_DB_TESTS=0 RUN_MIGRATION_TESTS=0 pnpm testpnpm buildthenpnpm typecheckpnpm test:verificationpnpm test:integration:dockerverifyIntegration({run})with Jest selectiontest/integration/(manual-authorization|shared-payment-proof-envelope)node scripts/check-migration-history.mjs origin/main HEADnode scripts/check-pr-review-signals.mjs origin/main HEADnode scripts/sync-agent-skills.mjs --check;node scripts/check-engineering-workflow.mjsgit diff --check origin/main...HEAD; approved-file SHA256/index/commit inventory checksRUN_F01_PENDING=1, disposable runner selectingsettlement-f01.pending.spec.tsF01 baseline retained: partial/full refunds and stale settlement candidates still produce the documented legacy discrepancies; funded dispute and cross-capture attribution expectations remain pending B2. This PR does not close F01/F04/F05/F06 or weaken those assertions.
Unverified boundaries
Node22 and PostgreSQL18 were not run locally; current local runtime is Node24 / PostgreSQL17.11. No real Stripe, RabbitMQ/Redis application integration, production migrations, principal fencing or runtime activation was exercised. Browser checks are n/a for this SQL-only change.
Exact P-C dependencies: human-accepted completed P-B AUTH root/history and exact effective-cause projection; separate protected first-intent/request/replay storage; an exclusive CAPTURE_INTENT alternative in the same permit while preserving APPLICATION; SQL-derived full/first-partial/final-partial child/outbox/accepted D02/audit/response/revision group; whole-group/replay/race tests and original AUTH recognition after CAPTURE_PENDING. Subsequent D02/B1 capture proof must reference the same original AUTH source. P-C must not lock the old AUTH inbox after scope. Genuine post-financial-capture history is B2-B's later gate; capture preparation/posting/recovery remain separately reviewed work.
Review
Engineering Workflow v1.1 task
r2-prerequisite-p-b-implementation: original checkpoint validated at HUMAN_APPROVAL; two correction rounds used, no budget reset. Fresh plan reviewer/root/p_b_plan_review_2approved. Original code reviewer/root/p_b_code_review_1reproduced three blocking P2s; all corrected and regressions retained: typed UUID audit owner identity, prior/exact terminal audit cardinality, required original-recognition lock prefix.Final accepted
/root/p_b_code_review_3: REVIEW_APPROVED, no P0/P1/acceptance-blocking P2; independently executed full1,122-pass Docker run on the approved P-B content. Interrupted plan/code attempts supplied no accepted approval. Original adverse reports remain unchanged.Claude Code's fresh
/security-reviewalso returned zero blocking findings on these exact SQL bytes. Its incorrect SELECT-only row-lock rationale was rejected using an actual PostgreSQL privilege probe; required narrow UPDATE grants were retained.Publication review of committed HEAD
8718d4cb9ef76d89e32baf49c145ca286f20fb19: REVIEW_APPROVED, fresh native read-only reviewer/root/p_b_pr_review, the local codex-review skill's permitted fallback after automatic approval review blocked the external CLI before execution. No blocking findings; independently inspected the complete diff, SQL/callers/tests, all 13 approved hashes and committed guards. Database results were inspected rather than rerun by this publication reviewer. Self-review uses ponytail-review; no source edits during shipping.Docs and temporary files
Updated
docs/database-design.mdanddocs/payment-lifecycle.mdfor durable contract/lock/privilege/history semantics. Consulted the approved three-stage P design, H01–H12/D01, B1 accounting section16 and R2-A/D02/B1/P-A records; no policy was reinterpreted.Only the approved13 source/doc files are committed. Original ignored workflow workspace remains sealed (12 state/plan/review/security/verification/handoff files) with ten historical failed/control/expected-failure runner evidence directories retained until disposition. Publication-only ignored workspace contains the PR draft, review brief/reports and compact verification/content-hash receipt; successful runners remove their own temporary outputs. No workflow artifacts, staged migration copies, logs, DB markers, dependencies, build outputs or databases are included in this PR. Keep task branch/worktree and evidence until merge/rejection; no merge, deployment, activation or P-C is authorized here.