fix(managed-agent): renumber session-close migration to V32 (#13223)

Main carries both V31__workspace_recovery_bundle from #13138 and
V31__workspace_session_close from the merged #13135, so Flyway aborts at
startup with 'Found more than one migration with version 31' and every
managed-agent-server migration (and the deployments running them) fails.
Renumber the close migration to V32 with its SQL bytes unchanged and
update the close design doc in both languages to record the sequence.

The merged close flow also completes lifecycle operations only while the
claim lease is fresh in database time. The recovery-bundle tests added
by #13138 complete a leased DELETE whose fixture row has no lease_until,
which production never produces, so give the fixture a far-future lease.
This commit is contained in:
Shaojin Wen authored and GitHub committed 2026-10-02 12:23:26 +00:00
1 parent 9478f28731
commit b3dda468f2
4 files changed
+5 -4

No files matched your search

@@ -38,7 +38,7 @@ Before binding retirement, require no active logical Session, no unsettled execu
## Implementation areas
Managed Agent lifecycle service/store/coordinator, capabilities and canonical OpenAPI/generated WebShell types; Runtime Broker repositories/service/provider and schema; Hosted Harness admission; collocated tests. The close migration is V31, following main's V28 Hook admission index, V29 backfill, and V30 tool-output retention migrations. Its SQL bytes are unchanged. Public and WebShell capabilities retain both upstream Artifact reads and optional close support. No new lifecycle orchestrator or broad core refactor is introduced. Align lifecycle contracts with [#12867](https://github.com/QwenLM/qwen-code/issues/12867) and Harness recovery with [#12740](https://github.com/QwenLM/qwen-code/issues/12740).
Managed Agent lifecycle service/store/coordinator, capabilities and canonical OpenAPI/generated WebShell types; Runtime Broker repositories/service/provider and schema; Hosted Harness admission; collocated tests. The close migration is V32, following main's V28 Hook admission index, V29 backfill, V30 tool-output retention, and V31 workspace recovery bundle migrations. Its SQL bytes are unchanged. Public and WebShell capabilities retain both upstream Artifact reads and optional close support. No new lifecycle orchestrator or broad core refactor is introduced. Align lifecycle contracts with [#12867](https://github.com/QwenLM/qwen-code/issues/12867) and Harness recovery with [#12740](https://github.com/QwenLM/qwen-code/issues/12740).
## Validation and acceptance
@@ -38,7 +38,7 @@ binding 退休前必须确认:无活跃逻辑 Session、无未结算 execution
## 实现区域
Managed Agent lifecycle service/store/coordinator、capabilities、权威 OpenAPI 与生成的 WebShell 类型;Runtime Broker repository/service/provider 与 schema;Hosted Harness 准入和同目录测试。close 迁移使用 V31,接在主干 V28 Hook admission 索引、V29 回填及 V30 工具输出保留迁移之后,SQL 字节不变。public 和 WebShell capability 同时保留上游 Artifact 读取与可选 close 支持。不新增 lifecycle orchestrator 或大范围核心重构。与 [#12867](https://github.com/QwenLM/qwen-code/issues/12867) 对齐生命周期契约,与 [#12740](https://github.com/QwenLM/qwen-code/issues/12740) 对齐 Harness 恢复。
Managed Agent lifecycle service/store/coordinator、capabilities、权威 OpenAPI 与生成的 WebShell 类型;Runtime Broker repository/service/provider 与 schema;Hosted Harness 准入和同目录测试。close 迁移使用 V32,接在主干 V28 Hook admission 索引、V29 回填、V30 工具输出保留及 V31 workspace recovery bundle 迁移之后,SQL 字节不变。public 和 WebShell capability 同时保留上游 Artifact 读取与可选 close 支持。不新增 lifecycle orchestrator 或大范围核心重构。与 [#12867](https://github.com/QwenLM/qwen-code/issues/12867) 对齐生命周期契约,与 [#12740](https://github.com/QwenLM/qwen-code/issues/12740) 对齐 Harness 恢复。
## 验证与验收
@@ -428,9 +428,10 @@ class WorkspaceRecoveryStoreTest {
jdbc.update("UPDATE managed_agent_session SET status = 'DELETING' WHERE session_id = ?", session);
jdbc.update("INSERT INTO managed_agent_operation (tenant_id, session_id, operation_id, operation_kind,"
+ " actor_digest, idempotency_key, request_digest, state, admission_stage, delivery_state,"
+ " session_status_before, lease_owner, claim_generation, available_at, created_at, updated_at)"
+ " session_status_before, lease_owner, lease_until, claim_generation, available_at, created_at,"
+ " updated_at)"
+ " VALUES ('tenant', ?, ?, 'DELETE', '', 'delete', 'digest', 'RUNNING', 'JAVA_DURABLE',"
+ " 'LEASED', 'ACTIVE', 'worker', 1, 0, 0, 0)", session, operation);
+ " 'LEASED', 'ACTIVE', 'worker', 32503680000000, 1, 0, 0, 0)", session, operation);
jdbc.update("UPDATE qwen_managed_session_journal_head SET latest_checkpoint_resource_id = 'retained' WHERE session_id = ?", session);
assertThat(new TransactionTemplate(manager).<Boolean>execute(status ->
sessions.completeOperation("tenant", session, operation, "worker", 1, false))).isTrue();