feat(bap): bind lifecycle receipts to idempotency keys - #211
Conversation
📝 WalkthroughWalkthroughBAP 수명주기가 마지막 전환 증거를 보존하고 검증된 상태 복구를 지원합니다. 명령 영수증은 식별자와 단일 전환을 묶습니다. 재생은 최신 전환의 상태, 순서, 이벤트가 모두 일치할 때만 성공합니다. ChangesBAP 영수증 수명주기
Estimated code review effort: 4 (Complex) | ~60 minutes Merge Risk: ⚪ Minimal · up to This PR adds exact idempotent replay and lifecycle-recovery validation. The remaining issues are limited to documentation wording and changelog classification, which could briefly mislead maintainers or integrators but do not change runtime behavior; no actionable merge-blocking risk remains after normal review. Sequence Diagram(s)sequenceDiagram
participant Caller
participant BapTaskLifecycle
participant BapCommandReceipt
Caller->>BapTaskLifecycle: apply_or_replay 요청
BapTaskLifecycle->>BapCommandReceipt: 식별자와 전환 영수증 비교
alt 일치하는 영수증
BapCommandReceipt-->>Caller: 기존 영수증 반환
else 영수증 없음
BapTaskLifecycle->>BapTaskLifecycle: 전환 적용 및 마지막 전환 저장
BapTaskLifecycle-->>Caller: 새 명령 영수증 반환
end
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Full details: Docstring CoverageExplanation Docstring coverage is 80.39% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 51 functions across 7 files. (5 skipped: 5 unsupported.) ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Reconstruct the canonical idempotency branch on protected main 542ca1e while preserving the branch-owned BAP source, tests, API/TRD, architecture, and traceability changes. CHANGELOG overlap is reconciled in a following bounded commit.
|
Current-head governance audit:
|
Buyer-visible boundary
Bounded implementation of #200. Prerequisite #208 is merged, and this canonical branch has been non-destructively reconstructed directly onto current protected
mainwhile preserving the idempotency/recovery production boundary.main:542ca1e9c0a863595b8b6697790005d2471f5413;52a918577958a5701e1146c7eb8b62fe8f8ccd44;The BAP lifecycle owns an immutable in-memory command receipt binding a bounded caller-supplied tenant namespace, idempotency key, task identifier, lifecycle event, and accepted transition. Exact replay requires exact retry metadata and exact equality with the lifecycle's most recently accepted transition. Ambiguous, stale, foreign, divergent-history, or state-only restored snapshots fail closed without a second lifecycle mutation.
This branch exposes storage-neutral typed seams needed to reconstruct both sides of that replay identity from persisted primitive fields:
BapTaskTransition::restore(...)revalidates an accepted transition against the lifecycle state machine;BapTaskLifecycle::restore_with_transition(...)requires exact validated last-transition evidence for every non-created snapshot; andBapCommandReceipt::restore(...)revalidates bounded retry identifiers before reconstructing the immutable receipt. The persistence boundary remains responsible for integrity/authenticity of supplied evidence and for atomicity with any external side effect.Test-first repair lineage
The receipt/recovery contract covers exact retry, metadata conflicts, foreign lifecycle reuse, stale reuse after lifecycle advancement, same-state/different-sequence reuse, divergent histories, identifier validation, Debug redaction, state-only recovery refusing replay, transition reconstruction, transition-backed lifecycle restoration, and persisted receipt reconstruction.
A commercial recovery defect was reproduced test-first on this canonical branch: persisted transition/lifecycle state could be reconstructed through the public typed API, but a persisted
BapCommandReceiptcould not, so true cross-process replay was impossible. Test-only RED head794e532dd70c1f03416b87016ec8f10d565ee6ccfailed with the expected missing-API error; production repairdf89f56a7976447da76214c7d8300633d600639dadded the restore boundary while reusing fail-closed retry-identity validation. Historical RED/predecessor evidence remains lineage only.Subsequent current-head review findings corrected the API-contract scope and changelog classification. Two later Devin observations were verified against exact current head as informational rather than defects: transition evidence is internally validated at the private type-construction boundary before
restore_with_transition, and the explicit replay state/sequence checks are harmless fail-closed invariant checks. All current inline review threads are resolved; only addressed or verified-non-actionable threads were resolved.Exact-current verification
On unchanged exact head
52a918577958a5701e1146c7eb8b62fe8f8ccd44against protected main542ca1e9c0a863595b8b6697790005d2471f5413:33105052208: success;33105052160: success;33105052231: success;No predecessor-head check, scanner result, review, status, comment, synthetic merge, or model output transfers to this head or counts as independent approval. Same-head gates not actually present are not claimed.
Safety and truth boundary
This remains an in-memory lifecycle/idempotency primitive plus typed recovery-validation/reconstruction seams. It does not authenticate the caller or tenant, authorize an operation, persist receipts or transition evidence, authenticate persisted evidence, provide durable concurrent deduplication or locking, atomically couple receipt storage to browser/network side effects, or reconcile ambiguous external outcomes. A durable owner must persist receipt + exact transition evidence atomically at the appropriate production boundary, authenticate that evidence on restore, preserve policy/tenant/session authority, and reconcile uncertain side effects before commercial crash recovery can be claimed.
Prerequisite #208 is merged and the current branch is reconstructed and exact-head green. This PR is review-ready, but independent approval remains required before integration. Passing checks, comments, model output, and author activity are not approval. No workflow, secret, governance, release, tag, publish, approval, or merge mutation is included.