fix(orchestration): bind E2 campaign approval identity - #167
Merged
mirror29 merged 5 commits intoSep 1, 2026
Merged
Conversation
This was referenced Aug 31, 2026
mirror29
marked this pull request as ready for review
September 1, 2026 07:27
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 this PR does / 这个 PR 做了什么
修复 E2 事件演化 campaign 的经济授权身份断链:
evolver.run_event_campaign不再走自动allow+ 独立randomUUID(),而是复用 trusted approval 路径,并把一次显式 owner 审批绑定到一个有界的 E2 五代 campaign。审批产生的 durable operation ID 继续绑定 signed
event_campaigngrant,并作为 EvolverIdempotency-Key使用。campaign 内部五代执行保持自动,不增加逐代审批。This PR also closes the retry/durability issues identified during maintainer and Codex review:
/startresponse is recoverable without starting the same campaign twice;0045permitsevolver.run_event_campaignin the shared approval-operation ledger.This remains a maintainer-aligned authorization-boundary fix. No public issue was opened because the repository security policy directs permission/authorization bypass reports to private channels.
Problem
At the stacked base, E1 and E2 used different economic authorization models.
E1:
permission ask → explicit trusted approval → durable operation ID → request/LLM-bound grant → Idempotency-Key → runE2 before this PR:
permission allow → getAutomaticEventCampaignContext() → randomUUID() → grant → Idempotency-Key → campaignAn E2 campaign can perform cost-bearing proposer calls across a fixed five-generation run, so creating the economic operation identity independently of owner approval breaks the authorization/provenance chain.
Two additional retry/durability gaps were identified during review:
/startcommitted but its response was lost, whole-tool retry could hitCAMPAIGN_STATE_CONFLICT;Invariant
One explicit owner approval authorizes one bounded E2 campaign.
approval → operation ID → signed event_campaign grant → Idempotency-Key → campaignAfter approval:
Implementation
evolver.run_event_campaignfromallowtoaskin both permission representations.eventSnapshotId, optionalsourceRunId, complete campaignconfig, and the frozen non-secret LLM snapshot.APPROVAL_OPERATION_ID_KEYingetApprovedEventCampaignContext().randomUUID().event_campaignEd25519 grant.Idempotency-Key.draftcampaign returns that campaign without another/start;CAMPAIGN_STATE_CONFLICTis reconciled through owner-scoped GET;draft.DELETE ... RETURNING;0045_e2_campaign_approval_operations.pyto expand the approval-ledgertool_nameconstraint for E2.Security model
The normal path fails closed at two layers:
The signed grant binds owner, approved operation ID,
grant_purpose=event_campaign, LLM config identity, and canonical campaign request digest. Evolver requires grantoperation_idto match the backendIdempotency-Key.Existing
(owner_account_id, idempotency_key)uniqueness prevents a second economic campaign under the same operation.The recovery entitlement is separately bounded: exactly one matching retry within two minutes, atomically consumed across restart/concurrency. This preserves durable recovery without turning one explicit approval into a reusable long-lived capability.
Non-goals
This PR does not address:
Scope / 涉及范围
packages/orchestrationinfra/migrations/versions/0045_e2_campaign_approval_operations.pyfixcodex/evolution-task27)Acceptance criteria
evolver.run_event_campaignrequires explicit approval.Idempotency-Key./startresponse recovery does not issue a second start after the campaign advanced.draft.evolver.run_event_campaignafter migration0045.Tests / 验证
Validated on final contribution SHA
e1ec52ec48c3c6889c7faac0b8393bf1ec06f4bb:0045scripts/check-consistency.sh: passedFork CI run on the exact final head:
33384343793— success.A validation-only fork PR was used to run exact repository CI and was closed without merging:
TheBayoumi/inalpha#1.Codex review
Codex reviewed the contribution iteratively and identified three P1 issues during development:
evolver.run_event_campaign;All three were fixed and regression-tested.
Final Codex review on
e1ec52ec48:No actionable P0/P1/P2 findings remain in the final Codex pass.
Reproducibility
mirror29/inalphab75928d57fbeb7c978ccd33b84812921ca65408aTheBayoumi:fix/e2-campaign-authorizatione1ec52ec48c3c6889c7faac0b8393bf1ec06f4bbmirror29:codex/evolution-task27Commits:
89d586c161297a49c65ff59512a5e31079e9562c—fix(orchestration): 绑定 E2 campaign 审批操作身份e1d10d9623885f4d458c67ddb138187dc40e8c8b—fix(orchestration): 使 E2 campaign 启动重试幂等e2196c5dedd01ffce43ac125018a5b1c1bdc1ed3—fix(orchestration): 收紧 E2 campaign 补偿重试28eaea0ec3f57ba397115d7e163649bcb2bbca18—fix(orchestration): 封闭 E2 审批并发与持久化约束e1ec52ec48c3c6889c7faac0b8393bf1ec06f4bb—test(orchestration): 校正 E2 并发重试声明Current upstream gate
PR #167 remains Draft because the upstream fork workflow is still
action_required. The implementation, fork CI, migration verification, and final Codex review are complete; the remaining external gate is maintainer approval/run of the upstream workflow.