refactor(subagent): scope the setup transaction to the creation callback

The setup validation and commit moved into the callback, so the outer
definite-assignment slot and its type import are no longer needed; declare
the transaction as a callback-local const.
This commit is contained in:
Tianyi Cui
2026-08-02 12:55:10 +08:00
parent e55d3e96d9
commit daf9554804

View File

@@ -42,7 +42,6 @@ import type { ContinuableCreateRequest, ContinuableCreateSpec, SubagentStartRequ
import type { ActivationObserver } from './lifecycle.ts'
import { SubagentError } from './error.ts'
import type SubagentActivationSetupRegistry from './activation-setup-registry.ts'
import type { ActivationSetupTransaction } from './activation-setup-registry.ts'
/** Attribution for a model coordinator's follow-up to one of its children. */
export interface CoordinatorMessageSource {
@@ -800,10 +799,9 @@ export class SubagentContinuationManager {
// `AgentRegistry.enter()` is the authoritative collision boundary for an id
// some other owner holds — a duplicate would reject there with rollback.
inputs.signal.throwIfAborted()
let setupTransaction!: ActivationSetupTransaction
const setup = (childCtx: Context): void => {
applyChildComposition(childCtx, inputs.composition)
setupTransaction = this.setupRegistry.apply(childCtx)
const setupTransaction = this.setupRegistry.apply(childCtx)
// Validate and freeze the batch inside the creation callback, before the
// factory can publish the session: a revoked contribution must reject
// the create/resume call pre-publication, so no persisted session is