Skip to content

Commit c7ea859

Browse files
authored
Retire proven exited claims before integration admission (#2406)
Written-by: Codex Fixes #2375 on `delivery/ai-centric-development-service`. Add configure-authorized `attempt.reconcile-exit` over existing pool serialization and Effects. Verify exact Session/worker/allocation exit and unresolved responsibility, commit retirement and fence the old generation before a fresh integration snapshot. Preserve drafts, input/PR semantics, stop cancellation and Agent choice; expose specific checkpoint blockers to Chief. Includes long-term memory, dated decision, architecture, operations, complete API inventory/OpenAPI, generated patches and red/green regressions. Tests cover failed/no-op persistence inside the pool, repeat requests, native/SDK/Chief proof, mismatched allocations, pending results/writes, cancellation and generation races. Validation: full root verify4,941/0 at4239a9a9; final head `7c487e01d9acd9e11b3dcbd5767692369437376e` changes only the strengthened regression and its generated mirror, five selected regressions/coverage pass. Nine API/docs tests pass. Exact-head CI running. Production source unchanged from full verify. New retirement paths have measured line coverage, not 100% branch coverage; optional runtime/error branches are not exhaustive. Actual DSH eight runtime cases passed; actual Docker SDK-to-retirement/live recovery remain unclaimed. Pairing correctness/security/conventions: no unresolved blockers. No deployment/live configuration/credentials changed. Owner-authorized delivery basic CI scope; no independent Verifier PASS claimed.
1 parent 5382e13 commit c7ea859

27 files changed

Lines changed: 707 additions & 70 deletions

‎.github/scripts/backend-docs.test.mjs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ test('public API tables enumerate the actual complete command/query contracts',
1919
const commandText = api.split('## v1命令')[1].split('## Execution')[0]
2020
assert.deepEqual(rows(queryText), [...queries].sort())
2121
assert.deepEqual(rows(commandText), operations.filter(name => !queries.includes(name)).sort())
22-
assert.equal(queries.length, 29); assert.equal(rows(commandText).length, 34)
23-
for (const name of ['README.md', 'README.zh.md']) assert.match(read(name), /29查询\/34命令/)
22+
assert.equal(queries.length, 29); assert.equal(rows(commandText).length, 35)
23+
for (const name of ['README.md', 'README.zh.md']) assert.match(read(name), /29查询\/35命令/)
2424
})
2525

2626
test('quickstart JSON, shell syntax and local documentation links stay usable', () => {

‎PROJECT.md‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# FlyBot — Project State
22

3+
4+
#2375 adds explicit exit-proven claim retirement through existing pools/Effects; preserve drafts, pending results and unknown writes. No cancellation or automatic routing.
5+
36
The single page that says what this project is, who decides what, and what automation must never
47
do. Operational rules live in [AGENTS.md](AGENTS.md) and [CONTRIBUTING.md](CONTRIBUTING.md);
58
architecture lives in [docs/architecture.md](docs/architecture.md) and

‎README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ HTTP 入口为 `POST /api/bot`、事件为 `GET /api/project-events`,
8181

8282
| 需要 | 文档 |
8383
| --- | --- |
84-
| 对象、权限、全部29查询/34命令、原生接口、幂等与SSE | [API参考](docs/development-service-api.md) |
84+
| 对象、权限、全部29查询/35命令、原生接口、幂等与SSE | [API参考](docs/development-service-api.md) |
8585
| Chief/角色/Task/Handoff、咨询、个人代理、安全与值守、状态与上下文 | [协作指南](docs/development-service-guide.md) |
8686
| 数据目录、账号平台、模型/SDK/仓库、停止重启、备份升级、排障 | [部署运维](docs/backend-operations.md) |
8787
| 个人Chief、多Bot、群聊、公共Bot、原版安装与桌面功能 | [原版FlyBot](README.native.zh.md) · [English](README.native.md) |

‎README.zh.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ HTTP 入口为 `POST /api/bot`、事件为 `GET /api/project-events`,
8181

8282
| 需要 | 文档 |
8383
| --- | --- |
84-
| 对象、权限、全部29查询/34命令、原生接口、幂等与SSE | [API参考](docs/development-service-api.md) |
84+
| 对象、权限、全部29查询/35命令、原生接口、幂等与SSE | [API参考](docs/development-service-api.md) |
8585
| Chief/角色/Task/Handoff、咨询、个人代理、安全与值守、状态与上下文 | [协作指南](docs/development-service-guide.md) |
8686
| 数据目录、账号平台、模型/SDK/仓库、停止重启、备份升级、排障 | [部署运维](docs/backend-operations.md) |
8787
| 个人Chief、多Bot、群聊、公共Bot、原版安装与桌面功能 | [原版FlyBot](README.native.zh.md) · [English](README.native.md) |

‎ROADMAP.md‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# FlyBot — Roadmap
22

3+
4+
#2375: retire proven exited responsibility before fresh integration admission; source/isolated tests remain separate from live recovery.
5+
36
## Resource authentication reliability — 2026-11-04
47

58
#2398: existing profile binding, correct SDK auth feedback and same-profile setup;

‎changelog.d/2375.fixed.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Add explicit, durable retirement of exit-proven execution claims before fresh integration admission, preserving drafts and rejecting stale or unresolved execution.

‎core/src/host/project-chief-control.js‎

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎core/src/host/project-delivery.js‎

Lines changed: 47 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -456,15 +456,52 @@ export function createProjectDelivery(rt, { publisher, releaseProvider, roleArti
456456
if (attempt.protocol !== 'project-handoff/v1') throw reject('Integration input admission requires Project Bot pools')
457457
return { attempt, task }
458458
}
459-
function integrationReleased(attempt, permit) {
460-
if (permit?.[childPermit]) { childInputs.assertProof(attempt.taskId, permit.proof.claim, permit.proof); return }
459+
function integrationBlockers(attempt, permit, retiringClaim) {
461460
const chief = row => row?.kind === 'chief-control' && row.projectId === attempt.projectId
462-
const claim = taskOf(attempt.taskId)?.collaboration?.claim
463-
const ownChiefRun = permit?.[chiefInputPermit]
464-
// Old released Chief turns never owned this workspace. The current Chief
465-
// claim and any unreleased Project Chief still require exact exit proof.
466-
const currentWorker = row => !(ownChiefRun && row.role === 'chief' && row.chiefRunId === ownChiefRun) && (row.attemptId === attempt.id || row.projectId === attempt.projectId && row.chiefRunId && (row.status !== 'released' || row.chiefRunId === claim?.chiefRunId))
467-
if (claim?.status === 'active' && !(ownChiefRun && claim.chiefRunId === ownChiefRun && claim.botId === `${attempt.projectId}:chief`) || Object.values(state.projectExecutions ?? {}).some(row => chief(row) && row.status === 'running' && row.id !== ownChiefRun) || Object.values(state.projectResourceLeases ?? {}).some(row => (row.attemptId === attempt.id || chief(state.projectExecutions?.[row.attemptId])) && row.status !== 'released') || Object.values(state.projectHarnessWorkers ?? {}).some(row => currentWorker(row) && !confirmedWorkerExit(state, row)) || Object.values(state.bots ?? {}).some(row => row.ephemeral && row.attemptId === attempt.id)) throw reject('Integration input is waiting for confirmed execution exit')
461+
const claim = taskOf(attempt.taskId)?.collaboration?.claim, ownChiefRun = permit?.[chiefInputPermit]
462+
const blockers = []
463+
if (claim?.status === 'active' && claim !== retiringClaim && !(ownChiefRun && claim.chiefRunId === ownChiefRun && claim.botId === `${attempt.projectId}:chief`)) blockers.push({ kind: 'claim-active', claimId: claim.id, action: 'attempt.reconcile-exit after result and exit reconciliation' })
464+
if (claim?.retirement && !rt.projectEffects?.intentCommitted(claim.retirement.effect)) blockers.push({ kind: 'claim-retirement-uncommitted', claimId: claim.id })
465+
for (const row of Object.values(state.projectExecutions ?? {})) if (chief(row) && row.status === 'running' && row.id !== ownChiefRun) blockers.push({ kind: 'chief-running', runId: row.id })
466+
for (const row of Object.values(state.projectResourceLeases ?? {})) if ((row.attemptId === attempt.id || chief(state.projectExecutions?.[row.attemptId])) && (row.status !== 'released' || row.preparation && row.preparation.exitConfirmed === false)) blockers.push({ kind: row.preparation?.exitConfirmed === false ? 'preparation-exit-unknown' : 'lease-not-released', leaseId: row.id })
467+
// Old released Chief turns never owned this workspace. Unknown current workers stay held.
468+
for (const row of Object.values(state.projectHarnessWorkers ?? {})) {
469+
const relevant = !(ownChiefRun && row.role === 'chief' && row.chiefRunId === ownChiefRun) && (row.attemptId === attempt.id || row.projectId === attempt.projectId && row.chiefRunId && (row.status !== 'released' || row.chiefRunId === claim?.chiefRunId))
470+
if (relevant && !confirmedWorkerExit(state, row)) blockers.push({ kind: 'worker-exit-unknown', workerId: row.id })
471+
}
472+
for (const row of Object.values(state.bots ?? {})) if (row.ephemeral && row.attemptId === attempt.id) blockers.push({ kind: 'native-worker-present', workerId: row.id })
473+
return blockers
474+
}
475+
function integrationReleased(attempt, permit, retiringClaim) {
476+
if (permit?.[childPermit]) { childInputs.assertProof(attempt.taskId, permit.proof.claim, permit.proof); return }
477+
const blockers = integrationBlockers(attempt, permit, retiringClaim)
478+
if (blockers.length) throw Object.assign(reject(`Integration input is waiting for confirmed execution exit: ${blockers.map(row => row.kind).join(', ')}`), { details: { kind: 'execution-checkpoint', attemptId: attempt.id, blockers } })
479+
}
480+
async function reconcileExit(body, actor) {
481+
const { attempt, task } = integrationAttempt(body, actor)
482+
if (!['running', 'interrupted', 'failed'].includes(attempt.status) || attempt.cancelRequested || ['accepted', 'cancelled'].includes(task.status)) throw reject('Exit retirement cannot revive a cancelled or completed Attempt')
483+
return rt.projectPools.retireExited(task.id, body, actor, async (currentTask, claim) => {
484+
await rt.projectDelegations?.background(actor.memberId)
485+
if (claim.attemptId !== attempt.id || claim.taskId !== task.id || claim.projectId !== task.projectId || task.deliveryAttemptId !== attempt.id) throw reject('Execution retirement requires the exact current Task/Attempt claim')
486+
const worker = ownEntry(state.projectHarnessWorkers ?? {}, claim.workerId), native = ownEntry(state.projectNativeWorkers ?? {}, claim.workerId)
487+
let proof
488+
if (claim.chiefRunId) {
489+
const run = ownEntry(state.projectExecutions ?? {}, claim.chiefRunId)
490+
if (!run || run.projectId !== task.projectId || run.status === 'running' || !await rt.projectChiefControl.exitConfirmed(run)) throw reject('Chief retirement is waiting for confirmed execution exit')
491+
proof = { chiefRunId: run.id, invocation: run.invocation, exitProof: run.exitProof ?? run.recovery?.proof ?? null }
492+
} else {
493+
const record = worker ?? native, lease = record && ownEntry(state.projectResourceLeases ?? {}, record.leaseId)
494+
if (!record || record.id !== claim.workerId || record.projectId !== task.projectId || record.taskId !== task.id || record.attemptId !== attempt.id || ![attempt.roleSessions?.[record.role], ...(attempt.roleSessionHistory ?? [])].some(session => session?.id === record.sessionKey && session.poolClaimId === claim.id && session.generation === claim.generation) || !executionExitConfirmed(rt, record.id)) throw reject('Claim retirement is waiting for matching confirmed execution exit')
495+
if (worker && (!lease || lease.status !== 'released' || lease.projectId !== record.projectId || lease.attemptId !== record.attemptId || lease.role !== record.role || lease.resourceId !== record.resourceId || lease.generation !== record.generation || lease.worker?.handle !== record.id || worker.releaseProof?.workerId !== record.id && worker.releaseProof?.kind !== 'systemd-prior-invocation-exited' || lease.releaseProof?.kind !== record.releaseProof?.kind || lease.releaseProof?.generation !== record.releaseProof?.generation || lease.releaseProof?.at !== record.releaseProof?.at)) throw reject('Claim retirement exit proof does not match its allocation')
496+
if (worker?.resultHash && !claim.decision || claim.inputCorrection?.status === 'pending') throw reject('Reconcile the pending worker result or input correction before retiring its responsibility')
497+
proof = { workerId: record.id, leaseId: record.leaseId, generation: record.generation, releaseProof: record.releaseProof }
498+
}
499+
if (Object.values(state.projectEffects ?? {}).some(row => row.taskId === task.id && row.payload?.attemptId === attempt.id && ['pending', 'running', 'failed'].includes(row.status) && ['github.candidate', 'github.publish', 'github.review', 'github.merge'].includes(row.kind))) throw reject('Reconcile pending external writes before retiring execution responsibility')
500+
integrationReleased(attempt, undefined, claim)
501+
rt.requireProjectAccess(actor, task.projectId, 'configure', task)
502+
if (task.deliveryAttemptId !== attempt.id || attempt.cancelRequested) throw reject('Execution retirement Attempt changed during validation')
503+
return proof
504+
})
468505
}
469506
async function integrationSnapshot(attempt) {
470507
const workspace = workspaceFor(attempt, 'developer')
@@ -546,7 +583,7 @@ export function createProjectDelivery(rt, { publisher, releaseProvider, roleArti
546583
if (!attempt || attempt.taskId !== task.id || attempt.projectId !== task.projectId) return null
547584
try {
548585
const project = projectOf(task.projectId, attempt)
549-
return { baseSha: attempt.baseSha ?? null, checkoutSha: attempt.candidateSha ?? attempt.seedSha ?? attempt.baseSha ?? null,
586+
return { executionCheckpoint: { generation: task.collaboration?.generation ?? 0, claimId: task.collaboration?.claim?.id ?? null, blockers: integrationBlockers(attempt) }, baseSha: attempt.baseSha ?? null, checkoutSha: attempt.candidateSha ?? attempt.seedSha ?? attempt.baseSha ?? null,
550587
availableInputs: await approvedRepositoryInputs(project), snapshot: await integrationSnapshot(attempt),
551588
preparationFailure: attempt.preparationFailures?.at(-1) ?? null,
552589
materialization: workspaceFor(attempt, 'developer')?.materialization ?? null, verificationRecovery: { attemptStatus: attempt.status, sealedCandidate: Boolean(attempt.candidateSha && attempt.evidence.implementation?.sha === attempt.candidateSha), testsPassedForCandidate: Boolean(attempt.evidence.tests?.passed && attempt.evidence.tests.sha === attempt.candidateSha), requires: ['current requirements and repository binding', 'clean sealed candidate', 'all old allocation exits confirmed', 'normal Task-role context admission'], reviewerRequires: 'matching passing host test command and immutable log' } }
@@ -920,6 +957,7 @@ export function createProjectDelivery(rt, { publisher, releaseProvider, roleArti
920957
integrationReleased(attempt)
921958
return { attemptId: attempt.id, generation: task.collaboration?.generation ?? 0, inputs: structuredClone(attempt.integrationInputs ?? []), availableInputs: await approvedRepositoryInputs(projectOf(task.projectId, attempt)), materialization: workspaceFor(attempt, 'developer')?.materialization ?? null, snapshot: await integrationSnapshot(attempt) }
922959
}
960+
if (endpoint === 'project-attempt-reconcile-exit') return reconcileExit(body, actor)
923961
if (endpoint === 'project-attempt-integration-bind') return serialAttempt(body.attemptId, () => bindIntegrations(body, actor))
924962
if (endpoint === 'project-task-run') return serial(() => start(body, actor))
925963
if (endpoint === 'project-task-reject') return serialAttempt(body.attemptId, async () => {

‎core/src/host/project-development-service.js‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const operations = Object.freeze({
2222
'handoff.get': 'project-handoff-get', 'handoff.list': 'project-handoff-list',
2323
'task.propose': 'task-create', 'task.change.request': 'project-task-change-request', 'task.run': 'project-task-run', 'task.detail': 'project-task-detail',
2424
'task.accept': 'project-task-accept', 'task.reject': 'project-task-reject',
25-
'attempt.stop': 'project-attempt-stop', 'attempt.cleanup': 'project-attempt-cleanup',
25+
'attempt.reconcile-exit': 'project-attempt-reconcile-exit', 'attempt.stop': 'project-attempt-stop', 'attempt.cleanup': 'project-attempt-cleanup',
2626
'attempt.integration-state': 'project-attempt-integration-state', 'attempt.integration-bind': 'project-attempt-integration-bind',
2727
'release.request': 'project-release-request', 'release.reconcile': 'project-release-reconcile', 'release.status': 'project-release-status',
2828
'attempt.publication-retry': 'project-attempt-publication-retry', 'attempt.log': 'project-attempt-log',
@@ -110,7 +110,7 @@ export function taskView(state, task, { activity = {}, roleCatalog, isIntentComm
110110

111111
export function createDevelopmentService(rt) {
112112
const receipts = rt.projectEffects ? createCommandReceipts(rt) : null
113-
const management = new Set(['github.connection.configure', 'release.request', 'release.reconcile', 'role.decide', 'attempt.stop', 'attempt.cleanup', 'queue.retry', 'chief.inspect', 'chief.configure', 'schedule.configure', 'effect.retry', 'attempt.integration-bind', 'attempt.publication-retry', 'source.subscribe', 'source.disable', 'source.poll'])
113+
const management = new Set(['github.connection.configure', 'release.request', 'release.reconcile', 'role.decide', 'attempt.stop', 'attempt.cleanup', 'queue.retry', 'chief.inspect', 'chief.configure', 'schedule.configure', 'effect.retry', 'attempt.reconcile-exit', 'attempt.integration-bind', 'attempt.publication-retry', 'source.subscribe', 'source.disable', 'source.poll'])
114114
const readCommand = new Set(['inbox.claim', 'inbox.renew', 'inbox.complete', 'inbox.fail', 'inbox.connection.configure', 'agent.mode', 'consultation.ask', 'consultation.reply'])
115115
const actionFor = name => ['task.propose', 'proposal.publish', 'comment.publish'].includes(name) ? 'create' : management.has(name) ? 'configure' : readCommand.has(name) ? 'read' : name === 'task.accept' || name === 'task.reject' ? 'accept' : 'task-write'
116116

0 commit comments

Comments
 (0)