niceeval 0.14.3-canary.52 → 0.14.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/INDEX.md +13 -6
- package/dist/agents/sdk-streams.cjs +6 -1
- package/dist/agents/sdk-streams.cjs.map +1 -1
- package/dist/agents/sdk-streams.d.cts +3 -2
- package/dist/agents/sdk-streams.d.mts +3 -2
- package/dist/agents/sdk-streams.d.ts +3 -2
- package/dist/agents/ui-message-stream.cjs +3 -1
- package/dist/agents/ui-message-stream.cjs.map +1 -1
- package/dist/experiment/host/cli/debug-protocol.cjs +257 -0
- package/dist/experiment/host/cli/debug-protocol.cjs.map +1 -0
- package/dist/experiment/host/cli/debug-protocol.d.cts +13 -0
- package/dist/experiment/host/cli/debug-protocol.d.mts +13 -0
- package/dist/experiment/host/cli/debug-protocol.d.ts +13 -0
- package/dist/experiment/host/cli/debug-protocol.js +8 -0
- package/dist/experiment/host/cli/debug-protocol.js.map +1 -0
- package/dist/experiment/host/cli/session-protocol.cjs +78 -0
- package/dist/experiment/host/cli/session-protocol.cjs.map +1 -0
- package/dist/experiment/host/cli/session-protocol.d.cts +10 -0
- package/dist/experiment/host/cli/session-protocol.d.mts +10 -0
- package/dist/experiment/host/cli/session-protocol.d.ts +10 -0
- package/dist/experiment/host/cli/session-protocol.js +12 -0
- package/dist/experiment/host/cli/session-protocol.js.map +1 -0
- package/dist/experiment/host/index.cjs +9 -1
- package/dist/experiment/host/index.cjs.map +1 -1
- package/dist/experiment/host/index.d.cts +2 -0
- package/dist/experiment/host/index.d.mts +2 -0
- package/dist/experiment/host/index.d.ts +2 -0
- package/dist/experiment/host/index.js +28 -16
- package/dist/experiment/host/index.mjs +28 -16
- package/dist/run/cli/contribution.cjs +5 -5
- package/dist/run/cli/contribution.cjs.map +1 -1
- package/dist/run/host/index.cjs +14 -3
- package/dist/run/host/index.cjs.map +1 -1
- package/dist/run/host/index.d.cts +2 -2
- package/dist/run/host/index.d.mts +2 -2
- package/dist/run/host/index.d.ts +2 -2
- package/dist/run/host/lifecycle-adapter.cjs +12 -12
- package/dist/run/host/lifecycle-adapter.cjs.map +1 -1
- package/dist/run/host/runtime.cjs +22 -22
- package/dist/run/host/runtime.cjs.map +1 -1
- package/dist/run/host/runtime.d.cts +11 -2
- package/dist/run/host/runtime.d.mts +11 -2
- package/dist/run/host/runtime.d.ts +11 -2
- package/dist/run/host/runtime.js +2 -2
- package/dist/run/host/types.cjs.map +1 -1
- package/dist/run/host/types.d.cts +4 -5
- package/dist/run/host/types.d.mts +4 -5
- package/dist/run/host/types.d.ts +4 -5
- package/dist/runner/assert-first-bridge.cjs +78 -3
- package/dist/runner/assert-first-bridge.cjs.map +1 -1
- package/dist/runner/assert-first-bridge.d.cts +11 -1
- package/dist/runner/assert-first-bridge.d.mts +11 -1
- package/dist/runner/assert-first-bridge.d.ts +11 -1
- package/dist/runner/attempt.cjs +77 -67
- package/dist/runner/attempt.cjs.map +1 -1
- package/dist/sandbox/backend.cjs.map +1 -1
- package/dist/sandbox/backend.d.cts +2 -2
- package/dist/sandbox/backend.d.mts +2 -2
- package/dist/sandbox/backend.d.ts +2 -2
- package/dist/sandbox/incus/ledger.cjs +34 -1
- package/dist/sandbox/incus/ledger.cjs.map +1 -1
- package/dist/sandbox/index.cjs.map +1 -1
- package/dist/sandbox/index.d.cts +1 -0
- package/dist/sandbox/index.d.mts +1 -0
- package/dist/sandbox/index.d.ts +1 -0
- package/dist/sandbox/layer.cjs.map +1 -1
- package/dist/sandbox/layer.d.cts +3 -3
- package/dist/sandbox/layer.d.mts +3 -3
- package/dist/sandbox/layer.d.ts +3 -3
- package/dist/sandbox/runtime.cjs.map +1 -1
- package/dist/sandbox/types.cjs.map +1 -1
- package/dist/sandbox/types.d.cts +2 -0
- package/dist/sandbox/types.d.mts +2 -0
- package/dist/sandbox/types.d.ts +2 -0
- package/dist/show/render.cjs +1 -0
- package/dist/show/render.cjs.map +1 -1
- package/dist/terminal/blocks.cjs +3 -5
- package/dist/terminal/blocks.cjs.map +1 -1
- package/dist/view/app-dist/.vite/manifest.json +3 -76
- package/dist/view/app-dist/assets/index-C6GQwHEF.js +63 -0
- package/dist/view/app-dist/assets/{quality-cost-scatter-B5wDa_F1.js → quality-cost-scatter-CSiMLelf.js} +5 -5
- package/dist/view/app-dist/index.html +1 -2
- package/dist/view/server.cjs +4 -3
- package/dist/view/server.cjs.map +1 -1
- package/docs-site/zh/README.md +2 -2
- package/docs-site/zh/tutorials/agent-feedback-loop.mdx +8 -5
- package/docs-site/zh/tutorials/agent-onboarding.mdx +5 -3
- package/package.json +1 -1
- package/dist/view/app-dist/assets/AttemptDialog-76dX1VQq.js +0 -41
- package/dist/view/app-dist/assets/AttemptRoute-DRHVh2JA.js +0 -4
- package/dist/view/app-dist/assets/ResultsPage-9CSI8dvZ.js +0 -2
- package/dist/view/app-dist/assets/RunPage-BUF0REv7.js +0 -1
- package/dist/view/app-dist/assets/TableContentView-_Sbg5wDr.js +0 -3
- package/dist/view/app-dist/assets/index-BGr_6pGY.js +0 -19
- package/dist/view/app-dist/assets/jsx-runtime-BnHLaUks.js +0 -1
- package/dist/view/app-dist/assets/useSuspenseQuery-D3W8Uy33.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assert-first-bridge.js","sourceRoot":"","sources":["assert-first-bridge.ts"],"names":[],"mappings":";;AAmGA,oEA0JC;AA7PD;;;;;GAKG;AACH,mCAAqE;AAErE,iDAAqE;AAoCrE,kEAAkE;AAClE,SAAS,aAAa;IAClB,IAAI,OAAgC,CAAC;IACrC,IAAI,MAAiC,CAAC;IACtC,MAAM,OAAO,GAAG,IAAI,OAAO,CAAQ,CAAC,cAAc,EAAE,aAAa,EAAE,EAAE;QACjE,OAAO,GAAG,cAAc,CAAC;QACzB,MAAM,GAAG,aAAa,CAAC;IAC3B,CAAC,CAAC,CAAC;IACH,uEAAuE;IACvE,6EAA6E;IAC7E,KAAK,OAAO,CAAC,KAAK,CAAC,GA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,uEAAuE;QACvE,uEAAuE;QACvE,6DAA6D;QAC7D,KAAK,CAAC,CAAC,eAAM,CAAC,YAAY,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,mBAAmB,CAAC,aAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,cAAK,CAAC,iBAAiB,CAAC,IAAI,CAAC,KAAK,CAAC;YAChH,CAAC,CAAC,IAAI,sCAA6B,CAAC,qBAAqB,CAAC;YAC1D,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC;QACtB,OAAO,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IACjC,CAAC,CAAC,CAAC;AACP,CAAC","sourcesContent":["/**\n * The Promise-shaped parts of the existing Attempt body (agent setup, sandbox\n * work, trace collection) need a narrow hand-off to the Effect-owned authoring\n * runtime. The bridge is a scoped Effect resource: the Queue worker is the\n * only executor, and public Promise values are only facade adapters.\n */\nimport { Cause, Deferred, Effect, Exit, Queue, Scope } from \"effect\";\nimport type { AssertionStopError, AssertionSealOptions, AssertionsRuntime, SealedAttemptAssertions, } from \"../assertions/api.ts\";\nimport { AssertionAuthoringClosedError } from \"../assertions/api.ts\";\nimport type { AgentWorkspaceDiff } from \"../assertions/workspace-diff.ts\";\nexport type AttemptAuthorCompletion = {\n readonly _tag: \"succeeded\";\n} | {\n readonly _tag: \"stopped\";\n} | {\n readonly _tag: \"failed\";\n readonly error: unknown;\n} | {\n readonly _tag: \"defect\";\n readonly cause: unknown;\n};\nexport interface AssertionSealRequest {\n readonly runtime: AssertionsRuntime<\"pass\" | \"score\">;\n readonly options: AssertionSealOptions;\n /** Frozen post-run evidence shared by evaluators and the Record adapter. */\n readonly workspaceDiff?: AgentWorkspaceDiff;\n}\ntype AttemptEffectRequestKind = \"assertion\" | \"operation\";\n/**\n * A request from the Promise-shaped Attempt body into its owning Effect Scope.\n * The resolver pair is deliberately the sole native-Promise state: it adapts\n * the public callback facade after the owner fiber has classified an Exit.\n */\ninterface AttemptEffectRequest {\n readonly kind: AttemptEffectRequestKind;\n readonly effect: Effect.Effect<unknown, unknown, never>;\n readonly resolve: (value: unknown) => void;\n readonly reject: (error: unknown) => void;\n}\ninterface PromiseFacade<Value> {\n readonly promise: Promise<Value>;\n readonly resolve: (value: Value) => void;\n readonly reject: (error: unknown) => void;\n}\n/** This is a facade adapter, not a bridge lifecycle primitive. */\nfunction promiseFacade<Value>(): PromiseFacade<Value> {\n let resolve!: (value: Value) => void;\n let reject!: (error: unknown) => void;\n const promise = new Promise<Value>((resolvePromise, rejectPromise) => {\n resolve = resolvePromise;\n reject = rejectPromise;\n });\n // A detached author continuation may intentionally observe its failure\n // later. Keep Node from treating the named lifecycle rejection as unhandled.\n void promise.catch(() => undefined);\n return { promise, resolve, reject };\n}\nexport interface AssertFirstAttemptBridge<Context> {\n /** The Promise body submits Context completion through the owner Queue. */\n offerContext(context: Context): Effect.Effect<void>;\n failBeforeContext(error: unknown): Effect.Effect<void>;\n awaitContext(): Effect.Effect<Context, unknown>;\n completeAuthor(completion: AttemptAuthorCompletion): Effect.Effect<void>;\n awaitAuthor(): Effect.Effect<AttemptAuthorCompletion, unknown>;\n requestAssertion<Value>(effect: Effect.Effect<Value, AssertionStopError, never>): Promise<Value>;\n /** Executes an internal body operation in the existing Attempt Effect Scope. */\n requestEffect<Value, Error>(effect: Effect.Effect<Value, Error, never>): Promise<Value>;\n /** Rejects only `orStop()` barriers after authoring has closed. */\n closeAssertionRequests(error: unknown): Effect.Effect<void>;\n /** Rejects every queued / in-flight bridge request during Scope release. */\n closeEffectRequests(error: unknown): Effect.Effect<void>;\n requestSeal(request: AssertionSealRequest): Effect.Effect<SealedAttemptAssertions, unknown>;\n awaitSealRequest(): Effect.Effect<AssertionSealRequest, unknown>;\n completeSeal(sealed: SealedAttemptAssertions): Effect.Effect<void>;\n failSeal(error: unknown): Effect.Effect<void>;\n}\nfunction completeRequest(request: AttemptEffectRequest, exit: Exit.Exit<unknown, unknown>, failureOverride?: unknown): Effect.Effect<void> {\n return Effect.sync(() => {\n if (failureOverride !== undefined) {\n request.reject(failureOverride);\n }\n else if (Exit.isSuccess(exit)) {\n request.resolve(exit.value);\n }\n else {\n // This is the sole Effect → Promise conversion. Until this boundary the\n // full Cause remains in the owner Effect tree.\n request.reject(failureOverride ?? Cause.squash(exit.cause));\n }\n });\n}\nfunction exactlyOnce(completed: Effect.Effect<boolean>, message: string): Effect.Effect<void> {\n return completed.pipe(Effect.flatMap((accepted) => accepted ? Effect.void : Effect.die(new Error(message))), Effect.asVoid);\n}\n/**\n * Creates exactly one scoped bridge for one Attempt. No method starts a\n * runtime: public Promise methods only offer work, and the scoped worker\n * performs every Effect, response, interruption and finalization transition.\n */\nexport function makeAssertFirstAttemptBridge<Context>(): Effect.Effect<AssertFirstAttemptBridge<Context>, never, import(\"effect\").Scope.Scope> {\n return Effect.gen(function* () {\n const context = yield* Deferred.make<Context, unknown>();\n const author = yield* Deferred.make<AttemptAuthorCompletion, unknown>();\n const sealRequest = yield* Deferred.make<AssertionSealRequest, unknown>();\n const sealed = yield* Deferred.make<SealedAttemptAssertions, unknown>();\n const assertionRequestsClosed = yield* Deferred.make<never, unknown>();\n const effectRequestsClosed = yield* Deferred.make<never, unknown>();\n const requests = yield* Queue.unbounded<AttemptEffectRequest>();\n // Each taken request runs independently in this child Scope. The dispatcher\n // must never await a control barrier such as awaitAuthor(), otherwise an\n // author assertion queued behind it cannot make the barrier complete.\n const requestScope = yield* Scope.make();\n let terminalError: unknown | undefined;\n let assertionCloseError: unknown | undefined;\n const closeReason = (): unknown => terminalError ?? new AssertionAuthoringClosedError(\"attempt-sealed\");\n const closeEffectRequests = (error: unknown): Effect.Effect<void> => Effect.suspend(() => {\n // This synchronous guard is intentionally the first close transition.\n // Promise callers can run between later queue operations, so they must\n // see a terminal outcome before any draining or shutdown can yield.\n if (terminalError !== undefined)\n return Effect.void;\n terminalError = error;\n return Deferred.fail(effectRequestsClosed, error).pipe(Effect.flatMap((firstClose) => {\n if (!firstClose)\n return Effect.void;\n return Effect.gen(function* () {\n // Wake every owner-side Deferred before removing pending work. The\n // worker races in-flight requests against this same close signal.\n yield* Deferred.fail(context, error);\n yield* Deferred.fail(author, error);\n yield* Deferred.fail(sealRequest, error);\n yield* Deferred.fail(sealed, error);\n yield* Deferred.fail(assertionRequestsClosed, error);\n // `terminalError` is already visible before this close. Every\n // in-flight child therefore settles its Promise facade by the\n // onExit path with the named terminal reason.\n yield* Scope.close(requestScope, Exit.fail(error));\n const pending = yield* Queue.clear(requests);\n yield* Effect.forEach(pending, (request) => completeRequest(request, Exit.fail(error)), { discard: true });\n yield* Queue.shutdown(requests);\n });\n }));\n });\n const awaitClose = (kind: AttemptEffectRequestKind) => Effect.raceFirst(Deferred.await(effectRequestsClosed), kind === \"assertion\" ? Deferred.await(assertionRequestsClosed) : Effect.never).pipe(Effect.exit);\n const runRequest = (request: AttemptEffectRequest): Effect.Effect<void> => {\n const closureError = (): unknown | undefined => terminalError ?? (request.kind === \"assertion\" ? assertionCloseError : undefined);\n return Effect.raceFirst(request.effect.pipe(Effect.exit), awaitClose(request.kind)).pipe(Effect.flatMap((exit) => completeRequest(request, exit, closureError())), \n // Scope interruption can arrive while the Queue worker is running the\n // race. This finalizer is the in-flight counterpart to Queue.takeAll:\n // it settles the sole Promise facade even when the worker itself is\n // interrupted before its normal response continuation runs.\n Effect.onExit((workerExit) => Exit.isFailure(workerExit)\n ? completeRequest(request, Exit.failCause(workerExit.cause), closureError())\n : Effect.void));\n };\n const worker = Effect.forever(Queue.take(requests).pipe(Effect.flatMap((request) => Effect.forkIn(runRequest(request), requestScope).pipe(Effect.asVoid)))).pipe(Effect.catchCause((cause) => Cause.hasInterruptsOnly(cause)\n ? Effect.void\n : closeEffectRequests(Cause.squash(cause))));\n yield* Effect.forkScoped(worker);\n const enqueue = <Value, Error>(effect: Effect.Effect<Value, Error, never>, kind: AttemptEffectRequestKind): Promise<Value> => {\n const facade = promiseFacade<Value>();\n if (terminalError !== undefined) {\n facade.reject(terminalError);\n return facade.promise;\n }\n if (kind === \"assertion\" && assertionCloseError !== undefined) {\n facade.reject(assertionCloseError);\n return facade.promise;\n }\n const request: AttemptEffectRequest = {\n kind,\n effect,\n resolve: facade.resolve as (value: unknown) => void,\n reject: facade.reject,\n };\n if (!Queue.offerUnsafe(requests, request)) {\n // Once the Queue is shut down there is no owner fiber left to consume\n // this facade. Return its named terminal outcome without a second\n // lifecycle implementation.\n facade.reject(closeReason());\n }\n return facade.promise;\n };\n const bridge: AssertFirstAttemptBridge<Context> = {\n offerContext(value) {\n return exactlyOnce(Deferred.succeed(context, value), \"Assert-first Context was offered twice\");\n },\n failBeforeContext(error) {\n return Deferred.fail(context, error).pipe(Effect.asVoid);\n },\n awaitContext() {\n return Deferred.await(context);\n },\n completeAuthor(completion) {\n return exactlyOnce(Deferred.succeed(author, completion), \"Assert-first author completion was delivered twice\");\n },\n awaitAuthor() {\n return Deferred.await(author);\n },\n requestAssertion(effect) {\n return enqueue(effect, \"assertion\");\n },\n requestEffect(effect) {\n return enqueue(effect, \"operation\");\n },\n closeAssertionRequests(error) {\n return Effect.suspend(() => {\n if (assertionCloseError !== undefined)\n return Effect.void;\n assertionCloseError = error;\n return Deferred.fail(assertionRequestsClosed, error).pipe(Effect.flatMap((firstClose) => {\n if (!firstClose)\n return Effect.void;\n return Effect.gen(function* () {\n const pending = yield* Queue.clear(requests);\n yield* Effect.forEach(pending, (request) => request.kind === \"assertion\"\n ? completeRequest(request, Exit.fail(error))\n : Queue.offer(requests, request).pipe(Effect.asVoid), { discard: true });\n });\n }));\n });\n },\n closeEffectRequests,\n requestSeal(request) {\n return Effect.gen(function* () {\n const firstRequest = yield* Deferred.succeed(sealRequest, request);\n if (!firstRequest) {\n const prior = yield* Deferred.await(sealRequest);\n if (prior.runtime !== request.runtime) {\n return yield* Effect.die(new Error(\"Assert-first Attempt requested a second runtime seal\"));\n }\n }\n return yield* Deferred.await(sealed);\n });\n },\n awaitSealRequest() {\n return Deferred.await(sealRequest);\n },\n completeSeal(value) {\n return exactlyOnce(Deferred.succeed(sealed, value), \"Assert-first Attempt seal was completed twice\");\n },\n failSeal(error) {\n return Deferred.fail(sealed, error).pipe(Effect.asVoid);\n },\n };\n // This fallback is intentionally after the worker is scoped. Attempt's\n // more specific finalizer runs first and supplies timeout/interruption\n // detail; this one closes any exceptional construction path.\n yield* Effect.addFinalizer((exit) => closeEffectRequests(Exit.isFailure(exit) && Cause.hasInterruptsOnly(exit.cause)\n ? new AssertionAuthoringClosedError(\"attempt-interrupted\")\n : closeReason()));\n return Object.freeze(bridge);\n });\n}\n"]}
|
|
1
|
+
{"version":3,"file":"assert-first-bridge.js","sourceRoot":"","sources":["assert-first-bridge.ts"],"names":[],"mappings":";;AA8GA,oEAoOC;AAlVD;;;;;GAKG;AACH,mCAAqE;AAErE,iDAAqE;AAErE,6DAA0D;AAmC1D,kEAAkE;AAClE,SAAS,aAAa;IAClB,IAAI,OAAgC,CAAC;IACrC,IAAI,MAAiC,CAAC;IACtC,MAAM,OAAO,GAAG,IAAI,OAAO,CAAQ,CAAC,cAAc,EAAE,aAAa,EAAE,EAAE;QACjE,OAAO,GAAG,cAAc,CAAC;QACzB,MAAM,GAAG,aAAa,CAAC;IAC3B,CAAC,CAAC,CAAC;IACH,uEAAuE;IACvE,6EAA6E;IAC7E,KAAK,OAAO,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;IACpC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC;AACxC,CAAC;AA8BD,SAAS,eAAe,CAAC,OAA6B,EAAE,IAAiC,EAAE,eAAyB;IAChH,OAAO,eAAM,CAAC,IAAI,CAAC,GAAG,EAAE;QACpB,IAAI,eAAe,KAAK,SAAS,EAAE,CAAC;YAChC,OAAO,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC;QACpC,CAAC;aACI,IAAI,aAAI,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC;YAC5B,OAAO,CAAC,O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AC,KAAK,CAAC;gBACtE,CAAC,CAAC,IAAI,sCAA6B,CAAC,qBAAqB,CAAC;gBAC1D,CAAC,CAAC,WAAW,EAAE,CAAC;YACpB,OAAO,mBAAmB,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,eAAM,CAAC,OAAO,CAAC,oBAAoB,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;QAC1F,CAAC,CAAC,CAAC;QACH,OAAO,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IACjC,CAAC,CAAC,CAAC;AACP,CAAC","sourcesContent":["/**\n * The Promise-shaped parts of the existing Attempt body (agent setup, sandbox\n * work, trace collection) need a narrow hand-off to the Effect-owned authoring\n * runtime. The bridge is a scoped Effect resource: the Queue worker is the\n * only executor, and public Promise values are only facade adapters.\n */\nimport { Cause, Deferred, Effect, Exit, Queue, Scope } from \"effect\";\nimport type { AssertionStopError, AssertionSealOptions, AssertionsRuntime, SealedAttemptAssertions, } from \"../assertions/api.ts\";\nimport { AssertionAuthoringClosedError } from \"../assertions/api.ts\";\nimport type { AgentWorkspaceDiff } from \"../assertions/workspace-diff.ts\";\nimport { withCleanupTimeout } from \"./cleanup-timeout.ts\";\nexport type AttemptAuthorCompletion = {\n readonly _tag: \"succeeded\";\n} | {\n readonly _tag: \"stopped\";\n} | {\n readonly _tag: \"failed\";\n readonly error: unknown;\n} | {\n readonly _tag: \"defect\";\n readonly cause: unknown;\n};\nexport interface AssertionSealRequest {\n readonly runtime: AssertionsRuntime<\"pass\" | \"score\">;\n readonly options: AssertionSealOptions;\n /** Frozen post-run evidence shared by evaluators and the Record adapter. */\n readonly workspaceDiff?: AgentWorkspaceDiff;\n}\ntype AttemptEffectRequestKind = \"assertion\" | \"operation\";\n/**\n * A request from the Promise-shaped Attempt body into its owning Effect Scope.\n * The resolver pair is deliberately the sole native-Promise state: it adapts\n * the public callback facade after the owner fiber has classified an Exit.\n */\ninterface AttemptEffectRequest {\n readonly kind: AttemptEffectRequestKind;\n readonly effect: Effect.Effect<unknown, unknown, never>;\n readonly resolve: (value: unknown) => void;\n readonly reject: (error: unknown) => void;\n}\ninterface PromiseFacade<Value> {\n readonly promise: Promise<Value>;\n readonly resolve: (value: Value) => void;\n readonly reject: (error: unknown) => void;\n}\n/** This is a facade adapter, not a bridge lifecycle primitive. */\nfunction promiseFacade<Value>(): PromiseFacade<Value> {\n let resolve!: (value: Value) => void;\n let reject!: (error: unknown) => void;\n const promise = new Promise<Value>((resolvePromise, rejectPromise) => {\n resolve = resolvePromise;\n reject = rejectPromise;\n });\n // A detached author continuation may intentionally observe its failure\n // later. Keep Node from treating the named lifecycle rejection as unhandled.\n void promise.catch(() => undefined);\n return { promise, resolve, reject };\n}\nexport interface AssertFirstAttemptBridge<Context> {\n /** The Promise body submits Context completion through the owner Queue. */\n offerContext(context: Context): Effect.Effect<void>;\n failBeforeContext(error: unknown): Effect.Effect<void>;\n awaitContext(): Effect.Effect<Context, unknown>;\n completeAuthor(completion: AttemptAuthorCompletion): Effect.Effect<void>;\n awaitAuthor(): Effect.Effect<AttemptAuthorCompletion, unknown>;\n requestAssertion<Value>(effect: Effect.Effect<Value, AssertionStopError, never>): Promise<Value>;\n /** Executes an internal body operation in the existing Attempt Effect Scope. */\n requestEffect<Value, Error>(effect: Effect.Effect<Value, Error, never>): Promise<Value>;\n /** Marks that the Promise body has entered and therefore owes its ordered cleanup. */\n expectCleanup(): void;\n /** Atomically enters cleanup unless the owner has already abandoned the body. */\n beginCleanup(): boolean;\n /** Executes teardown after the forward authoring bridge has closed. */\n requestCleanup<Value, Error>(effect: Effect.Effect<Value, Error, never>): Promise<Value>;\n /** Completes the Promise body's cleanup obligation after its final teardown. */\n completeCleanup(): void;\n /** Waits for an expected Promise cleanup without accepting forward work. */\n awaitCleanup(): Effect.Effect<void>;\n /** Rejects only `orStop()` barriers after authoring has closed. */\n closeAssertionRequests(error: unknown): Effect.Effect<void>;\n /** Rejects every queued / in-flight forward request during Scope release. */\n closeEffectRequests(error: unknown): Effect.Effect<void>;\n requestSeal(request: AssertionSealRequest): Effect.Effect<SealedAttemptAssertions, unknown>;\n awaitSealRequest(): Effect.Effect<AssertionSealRequest, unknown>;\n completeSeal(sealed: SealedAttemptAssertions): Effect.Effect<void>;\n failSeal(error: unknown): Effect.Effect<void>;\n}\nfunction completeRequest(request: AttemptEffectRequest, exit: Exit.Exit<unknown, unknown>, failureOverride?: unknown): Effect.Effect<void> {\n return Effect.sync(() => {\n if (failureOverride !== undefined) {\n request.reject(failureOverride);\n }\n else if (Exit.isSuccess(exit)) {\n request.resolve(exit.value);\n }\n else {\n // This is the sole Effect → Promise conversion. Until this boundary the\n // full Cause remains in the owner Effect tree.\n request.reject(failureOverride ?? Cause.squash(exit.cause));\n }\n });\n}\nfunction exactlyOnce(completed: Effect.Effect<boolean>, message: string): Effect.Effect<void> {\n return completed.pipe(Effect.flatMap((accepted) => accepted ? Effect.void : Effect.die(new Error(message))), Effect.asVoid);\n}\n/**\n * Creates exactly one scoped bridge for one Attempt. No method starts a\n * runtime: public Promise methods only offer work, and the scoped worker\n * performs every Effect, response, interruption and finalization transition.\n */\nexport function makeAssertFirstAttemptBridge<Context>(): Effect.Effect<AssertFirstAttemptBridge<Context>, never, import(\"effect\").Scope.Scope> {\n return Effect.gen(function* () {\n const context = yield* Deferred.make<Context, unknown>();\n const author = yield* Deferred.make<AttemptAuthorCompletion, unknown>();\n const sealRequest = yield* Deferred.make<AssertionSealRequest, unknown>();\n const sealed = yield* Deferred.make<SealedAttemptAssertions, unknown>();\n const assertionRequestsClosed = yield* Deferred.make<never, unknown>();\n const effectRequestsClosed = yield* Deferred.make<never, unknown>();\n const requests = yield* Queue.unbounded<AttemptEffectRequest>();\n // Each taken request runs independently in this child Scope. The dispatcher\n // must never await a control barrier such as awaitAuthor(), otherwise an\n // author assertion queued behind it cannot make the barrier complete.\n const requestScope = yield* Scope.make();\n const cleanupCompleted = yield* Deferred.make<void>();\n const cleanupRequests = yield* Queue.unbounded<AttemptEffectRequest>();\n const cleanupRequestScope = yield* Scope.make();\n let terminalError: unknown | undefined;\n let assertionCloseError: unknown | undefined;\n let cleanupExpected = false;\n let cleanupStarted = false;\n let cleanupTerminalError: unknown | undefined;\n const closeReason = (): unknown => terminalError ?? new AssertionAuthoringClosedError(\"attempt-sealed\");\n const closeEffectRequests = (error: unknown): Effect.Effect<void> => Effect.suspend(() => {\n // This synchronous guard is intentionally the first close transition.\n // Promise callers can run between later queue operations, so they must\n // see a terminal outcome before any draining or shutdown can yield.\n if (terminalError !== undefined)\n return Effect.void;\n terminalError = error;\n return Deferred.fail(effectRequestsClosed, error).pipe(Effect.flatMap((firstClose) => {\n if (!firstClose)\n return Effect.void;\n return Effect.gen(function* () {\n // Wake every owner-side Deferred before removing pending work. The\n // worker races in-flight requests against this same close signal.\n yield* Deferred.fail(context, error);\n yield* Deferred.fail(author, error);\n yield* Deferred.fail(sealRequest, error);\n yield* Deferred.fail(sealed, error);\n yield* Deferred.fail(assertionRequestsClosed, error);\n // `terminalError` is already visible before this close. Every\n // in-flight child therefore settles its Promise facade by the\n // onExit path with the named terminal reason.\n yield* Scope.close(requestScope, Exit.fail(error));\n const pending = yield* Queue.clear(requests);\n yield* Effect.forEach(pending, (request) => completeRequest(request, Exit.fail(error)), { discard: true });\n yield* Queue.shutdown(requests);\n });\n }));\n });\n const awaitClose = (kind: AttemptEffectRequestKind) => Effect.raceFirst(Deferred.await(effectRequestsClosed), kind === \"assertion\" ? Deferred.await(assertionRequestsClosed) : Effect.never).pipe(Effect.exit);\n const closeCleanupRequestsNow = (error: unknown): Effect.Effect<void> => {\n if (cleanupTerminalError !== undefined)\n return Effect.void;\n cleanupTerminalError = error;\n return Effect.gen(function* () {\n yield* Scope.close(cleanupRequestScope, Exit.fail(error));\n const pending = yield* Queue.clear(cleanupRequests);\n yield* Effect.forEach(pending, (request) => completeRequest(request, Exit.fail(error)), { discard: true });\n yield* Queue.shutdown(cleanupRequests);\n });\n };\n const closeCleanupRequests = (error: unknown): Effect.Effect<void> => Effect.suspend(() => closeCleanupRequestsNow(error));\n const runRequest = (request: AttemptEffectRequest): Effect.Effect<void> => {\n const closureError = (): unknown | undefined => terminalError ?? (request.kind === \"assertion\" ? assertionCloseError : undefined);\n return Effect.raceFirst(request.effect.pipe(Effect.exit), awaitClose(request.kind)).pipe(Effect.flatMap((exit) => completeRequest(request, exit, closureError())), \n // Scope interruption can arrive while the Queue worker is running the\n // race. This finalizer is the in-flight counterpart to Queue.takeAll:\n // it settles the sole Promise facade even when the worker itself is\n // interrupted before its normal response continuation runs.\n Effect.onExit((workerExit) => Exit.isFailure(workerExit)\n ? completeRequest(request, Exit.failCause(workerExit.cause), closureError())\n : Effect.void));\n };\n const worker = Effect.forever(Queue.take(requests).pipe(Effect.flatMap((request) => Effect.forkIn(runRequest(request), requestScope).pipe(Effect.asVoid)))).pipe(Effect.catchCause((cause) => Cause.hasInterruptsOnly(cause)\n ? Effect.void\n : closeEffectRequests(Cause.squash(cause))));\n yield* Effect.forkScoped(worker);\n const cleanupWorker = Effect.forever(Queue.take(cleanupRequests).pipe(Effect.flatMap((request) => Effect.forkIn(request.effect.pipe(Effect.exit, Effect.flatMap((exit) => completeRequest(request, exit, cleanupTerminalError)), Effect.onExit((workerExit) => Exit.isFailure(workerExit)\n ? completeRequest(request, Exit.failCause(workerExit.cause), cleanupTerminalError)\n : Effect.void)), cleanupRequestScope).pipe(Effect.asVoid)))).pipe(Effect.catchCause((cause) => Cause.hasInterruptsOnly(cause)\n ? Effect.void\n : closeCleanupRequests(Cause.squash(cause))));\n yield* Effect.forkScoped(cleanupWorker);\n const enqueue = <Value, Error>(effect: Effect.Effect<Value, Error, never>, kind: AttemptEffectRequestKind): Promise<Value> => {\n const facade = promiseFacade<Value>();\n if (terminalError !== undefined) {\n facade.reject(terminalError);\n return facade.promise;\n }\n if (kind === \"assertion\" && assertionCloseError !== undefined) {\n facade.reject(assertionCloseError);\n return facade.promise;\n }\n const request: AttemptEffectRequest = {\n kind,\n effect,\n resolve: facade.resolve as (value: unknown) => void,\n reject: facade.reject,\n };\n if (!Queue.offerUnsafe(requests, request)) {\n // Once the Queue is shut down there is no owner fiber left to consume\n // this facade. Return its named terminal outcome without a second\n // lifecycle implementation.\n facade.reject(closeReason());\n }\n return facade.promise;\n };\n const enqueueCleanup = <Value, Error>(effect: Effect.Effect<Value, Error, never>): Promise<Value> => {\n const facade = promiseFacade<Value>();\n if (cleanupTerminalError !== undefined) {\n facade.reject(cleanupTerminalError);\n return facade.promise;\n }\n const request: AttemptEffectRequest = {\n kind: \"operation\",\n effect,\n resolve: facade.resolve as (value: unknown) => void,\n reject: facade.reject,\n };\n if (!Queue.offerUnsafe(cleanupRequests, request)) {\n facade.reject(cleanupTerminalError ?? new AssertionAuthoringClosedError(\"attempt-sealed\"));\n }\n return facade.promise;\n };\n const bridge: AssertFirstAttemptBridge<Context> = {\n offerContext(value) {\n return exactlyOnce(Deferred.succeed(context, value), \"Assert-first Context was offered twice\");\n },\n failBeforeContext(error) {\n return Deferred.fail(context, error).pipe(Effect.asVoid);\n },\n awaitContext() {\n return Deferred.await(context);\n },\n completeAuthor(completion) {\n return exactlyOnce(Deferred.succeed(author, completion), \"Assert-first author completion was delivered twice\");\n },\n awaitAuthor() {\n return Deferred.await(author);\n },\n requestAssertion(effect) {\n return enqueue(effect, \"assertion\");\n },\n requestEffect(effect) {\n return enqueue(effect, \"operation\");\n },\n expectCleanup() {\n cleanupExpected = true;\n },\n beginCleanup() {\n if (cleanupTerminalError !== undefined || cleanupStarted)\n return false;\n cleanupStarted = true;\n return true;\n },\n requestCleanup(effect) {\n return enqueueCleanup(effect);\n },\n completeCleanup() {\n // The Promise body's outer finally must acknowledge completion even\n // when a dispatcher has failed. This does not submit another request.\n Deferred.doneUnsafe(cleanupCompleted, Effect.void);\n },\n awaitCleanup() {\n return Effect.suspend(() => {\n const close = () => closeCleanupRequestsNow(closeReason());\n if (!cleanupExpected)\n return close();\n return withCleanupTimeout(Deferred.await(cleanupCompleted).pipe(Effect.interruptible)).pipe(Effect.catchTag(\"CleanupTimeoutError\", () => Effect.suspend(() => \n // Each started callback has its own deadline. The join may only\n // abandon a body that has not entered cleanup. Both this decision\n // and closeCleanupRequests' terminal guard run before yielding,\n // so a late finally cannot race resource release.\n cleanupStarted ? Deferred.await(cleanupCompleted) : close())));\n });\n },\n closeAssertionRequests(error) {\n return Effect.suspend(() => {\n if (assertionCloseError !== undefined)\n return Effect.void;\n assertionCloseError = error;\n return Deferred.fail(assertionRequestsClosed, error).pipe(Effect.flatMap((firstClose) => {\n if (!firstClose)\n return Effect.void;\n return Effect.gen(function* () {\n const pending = yield* Queue.clear(requests);\n yield* Effect.forEach(pending, (request) => request.kind === \"assertion\"\n ? completeRequest(request, Exit.fail(error))\n : Queue.offer(requests, request).pipe(Effect.asVoid), { discard: true });\n });\n }));\n });\n },\n closeEffectRequests,\n requestSeal(request) {\n return Effect.gen(function* () {\n const firstRequest = yield* Deferred.succeed(sealRequest, request);\n if (!firstRequest) {\n const prior = yield* Deferred.await(sealRequest);\n if (prior.runtime !== request.runtime) {\n return yield* Effect.die(new Error(\"Assert-first Attempt requested a second runtime seal\"));\n }\n }\n return yield* Deferred.await(sealed);\n });\n },\n awaitSealRequest() {\n return Deferred.await(sealRequest);\n },\n completeSeal(value) {\n return exactlyOnce(Deferred.succeed(sealed, value), \"Assert-first Attempt seal was completed twice\");\n },\n failSeal(error) {\n return Deferred.fail(sealed, error).pipe(Effect.asVoid);\n },\n };\n // This fallback is intentionally after the worker is scoped. Attempt's\n // more specific finalizer runs first and supplies timeout/interruption\n // detail; this one closes any exceptional construction path.\n yield* Effect.addFinalizer((exit) => {\n const reason = Exit.isFailure(exit) && Cause.hasInterruptsOnly(exit.cause)\n ? new AssertionAuthoringClosedError(\"attempt-interrupted\")\n : closeReason();\n return closeEffectRequests(reason).pipe(Effect.andThen(closeCleanupRequests(reason)));\n });\n return Object.freeze(bridge);\n });\n}\n"]}
|
|
@@ -34,9 +34,19 @@ export interface AssertFirstAttemptBridge<Context> {
|
|
|
34
34
|
requestAssertion<Value>(effect: Effect.Effect<Value, AssertionStopError, never>): Promise<Value>;
|
|
35
35
|
/** Executes an internal body operation in the existing Attempt Effect Scope. */
|
|
36
36
|
requestEffect<Value, Error>(effect: Effect.Effect<Value, Error, never>): Promise<Value>;
|
|
37
|
+
/** Marks that the Promise body has entered and therefore owes its ordered cleanup. */
|
|
38
|
+
expectCleanup(): void;
|
|
39
|
+
/** Atomically enters cleanup unless the owner has already abandoned the body. */
|
|
40
|
+
beginCleanup(): boolean;
|
|
41
|
+
/** Executes teardown after the forward authoring bridge has closed. */
|
|
42
|
+
requestCleanup<Value, Error>(effect: Effect.Effect<Value, Error, never>): Promise<Value>;
|
|
43
|
+
/** Completes the Promise body's cleanup obligation after its final teardown. */
|
|
44
|
+
completeCleanup(): void;
|
|
45
|
+
/** Waits for an expected Promise cleanup without accepting forward work. */
|
|
46
|
+
awaitCleanup(): Effect.Effect<void>;
|
|
37
47
|
/** Rejects only `orStop()` barriers after authoring has closed. */
|
|
38
48
|
closeAssertionRequests(error: unknown): Effect.Effect<void>;
|
|
39
|
-
/** Rejects every queued / in-flight
|
|
49
|
+
/** Rejects every queued / in-flight forward request during Scope release. */
|
|
40
50
|
closeEffectRequests(error: unknown): Effect.Effect<void>;
|
|
41
51
|
requestSeal(request: AssertionSealRequest): Effect.Effect<SealedAttemptAssertions, unknown>;
|
|
42
52
|
awaitSealRequest(): Effect.Effect<AssertionSealRequest, unknown>;
|
|
@@ -34,9 +34,19 @@ export interface AssertFirstAttemptBridge<Context> {
|
|
|
34
34
|
requestAssertion<Value>(effect: Effect.Effect<Value, AssertionStopError, never>): Promise<Value>;
|
|
35
35
|
/** Executes an internal body operation in the existing Attempt Effect Scope. */
|
|
36
36
|
requestEffect<Value, Error>(effect: Effect.Effect<Value, Error, never>): Promise<Value>;
|
|
37
|
+
/** Marks that the Promise body has entered and therefore owes its ordered cleanup. */
|
|
38
|
+
expectCleanup(): void;
|
|
39
|
+
/** Atomically enters cleanup unless the owner has already abandoned the body. */
|
|
40
|
+
beginCleanup(): boolean;
|
|
41
|
+
/** Executes teardown after the forward authoring bridge has closed. */
|
|
42
|
+
requestCleanup<Value, Error>(effect: Effect.Effect<Value, Error, never>): Promise<Value>;
|
|
43
|
+
/** Completes the Promise body's cleanup obligation after its final teardown. */
|
|
44
|
+
completeCleanup(): void;
|
|
45
|
+
/** Waits for an expected Promise cleanup without accepting forward work. */
|
|
46
|
+
awaitCleanup(): Effect.Effect<void>;
|
|
37
47
|
/** Rejects only `orStop()` barriers after authoring has closed. */
|
|
38
48
|
closeAssertionRequests(error: unknown): Effect.Effect<void>;
|
|
39
|
-
/** Rejects every queued / in-flight
|
|
49
|
+
/** Rejects every queued / in-flight forward request during Scope release. */
|
|
40
50
|
closeEffectRequests(error: unknown): Effect.Effect<void>;
|
|
41
51
|
requestSeal(request: AssertionSealRequest): Effect.Effect<SealedAttemptAssertions, unknown>;
|
|
42
52
|
awaitSealRequest(): Effect.Effect<AssertionSealRequest, unknown>;
|
|
@@ -34,9 +34,19 @@ export interface AssertFirstAttemptBridge<Context> {
|
|
|
34
34
|
requestAssertion<Value>(effect: Effect.Effect<Value, AssertionStopError, never>): Promise<Value>;
|
|
35
35
|
/** Executes an internal body operation in the existing Attempt Effect Scope. */
|
|
36
36
|
requestEffect<Value, Error>(effect: Effect.Effect<Value, Error, never>): Promise<Value>;
|
|
37
|
+
/** Marks that the Promise body has entered and therefore owes its ordered cleanup. */
|
|
38
|
+
expectCleanup(): void;
|
|
39
|
+
/** Atomically enters cleanup unless the owner has already abandoned the body. */
|
|
40
|
+
beginCleanup(): boolean;
|
|
41
|
+
/** Executes teardown after the forward authoring bridge has closed. */
|
|
42
|
+
requestCleanup<Value, Error>(effect: Effect.Effect<Value, Error, never>): Promise<Value>;
|
|
43
|
+
/** Completes the Promise body's cleanup obligation after its final teardown. */
|
|
44
|
+
completeCleanup(): void;
|
|
45
|
+
/** Waits for an expected Promise cleanup without accepting forward work. */
|
|
46
|
+
awaitCleanup(): Effect.Effect<void>;
|
|
37
47
|
/** Rejects only `orStop()` barriers after authoring has closed. */
|
|
38
48
|
closeAssertionRequests(error: unknown): Effect.Effect<void>;
|
|
39
|
-
/** Rejects every queued / in-flight
|
|
49
|
+
/** Rejects every queued / in-flight forward request during Scope release. */
|
|
40
50
|
closeEffectRequests(error: unknown): Effect.Effect<void>;
|
|
41
51
|
requestSeal(request: AssertionSealRequest): Effect.Effect<SealedAttemptAssertions, unknown>;
|
|
42
52
|
awaitSealRequest(): Effect.Effect<AssertionSealRequest, unknown>;
|
package/dist/runner/attempt.cjs
CHANGED
|
@@ -804,13 +804,6 @@ ${recentLogs.map((l) => ` · ${l}`).join("\n")}`;
|
|
|
804
804
|
// but cannot mask the owning Attempt's terminal cause.
|
|
805
805
|
effect_1.Effect.catchCause(() => effect_1.Effect.void));
|
|
806
806
|
}));
|
|
807
|
-
// Close outstanding bridge promises before the interruption seal. This
|
|
808
|
-
// makes a detached author continuation fail by name while preserving the
|
|
809
|
-
// already declared entries for the finalizer's declaration-order seal.
|
|
810
|
-
yield* effect_1.Effect.addFinalizer((exit) => effect_1.Effect.suspend(() => {
|
|
811
|
-
const interrupted = timedOut || (effect_1.Exit.isFailure(exit) && effect_1.Cause.hasInterruptsOnly(exit.cause));
|
|
812
|
-
return assertFirst.closeEffectRequests(new api_ts_1.AssertionAuthoringClosedError(interrupted ? "attempt-interrupted" : "attempt-sealed"));
|
|
813
|
-
}));
|
|
814
807
|
// Scope 的 LIFO 让作者 cleanup 在 agent teardown 后、Provider Case finalizer 前执行。
|
|
815
808
|
// Cleanup must not fork back into this already-closing Attempt Scope, so it uses the resource
|
|
816
809
|
// facade captured above while retaining the same physical Sandbox and provider release owner.
|
|
@@ -856,6 +849,18 @@ ${recentLogs.map((l) => ` · ${l}`).join("\n")}`;
|
|
|
856
849
|
yield* effect_1.Effect.addFinalizer(() => (0, cleanup_timeout_ts_1.cleanupCallback)((cleanupSignal) => attemptResources.releaseAll(cleanupSignal)).pipe(effect_1.Effect.catch((error) => effect_1.Effect.sync(() => {
|
|
857
850
|
reportAttemptResourceReleaseFailure(error);
|
|
858
851
|
}))));
|
|
852
|
+
// Register the cleanup join after every outer resource finalizer, then
|
|
853
|
+
// register the forward close last. Scope LIFO therefore first rejects
|
|
854
|
+
// outstanding Promise work, then lets the body finish Agent teardown →
|
|
855
|
+
// managed Attempt release → Eval Plugin teardown, and only afterwards
|
|
856
|
+
// releases the enclosing Sandbox / Provider owners. The join abandons
|
|
857
|
+
// only a body that never enters cleanup; each cleanup callback owns its
|
|
858
|
+
// deadline without sharing an aggregate deadline with later callbacks.
|
|
859
|
+
yield* effect_1.Effect.addFinalizer(() => assertFirst.awaitCleanup());
|
|
860
|
+
yield* effect_1.Effect.addFinalizer((exit) => effect_1.Effect.suspend(() => {
|
|
861
|
+
const interrupted = timedOut || (effect_1.Exit.isFailure(exit) && effect_1.Cause.hasInterruptsOnly(exit.cause));
|
|
862
|
+
return assertFirst.closeEffectRequests(new api_ts_1.AssertionAuthoringClosedError(interrupted ? "attempt-interrupted" : "attempt-sealed"));
|
|
863
|
+
}));
|
|
859
864
|
// The legacy setup/diff body remains Promise-shaped, while OTLP waits,
|
|
860
865
|
// author execution, and sealing run in this Attempt's Effect scope. No
|
|
861
866
|
// nested runtime is introduced.
|
|
@@ -1455,6 +1460,10 @@ async function executeSandboxAction(data, sandbox, managedProcess, signal, progr
|
|
|
1455
1460
|
// attempt 的固定段(上传→基线→setup→驱动 agent→采 diff→脚本→评分→判定)。
|
|
1456
1461
|
// 资源已由 runAttemptEffect 的 Sample 持有;这里只在 finally 跑 agent 自己的 cleanup/teardown。
|
|
1457
1462
|
async function runAttemptBody(a, config, t0, base, res, parentSignal) {
|
|
1463
|
+
// Mark the cleanup obligation only once the Promise body has actually
|
|
1464
|
+
// entered. An interruption before tryPromise invokes this body must not make
|
|
1465
|
+
// Scope shutdown wait for cleanup that can never start.
|
|
1466
|
+
res.assertFirst.expectCleanup();
|
|
1458
1467
|
const { evalDef, run, attempt } = a;
|
|
1459
1468
|
const { sandbox: rawSandbox, materializedCase, sourceRegistry, sourceCapture, receiver, telemetry, otel, signal, log, enterPhase, getPhase, setSendActive, recorder, feedback, diagnostics, commands, sensitiveValues, observabilityRuntime, concurrencySlot, declareFailure, onEnvironmentIncomplete, isDeadlineTimedOut, layerCleanups, registerEvidence, registerLedger, retainFileChangesCapture, assertFirst, registerAssertions, prepareCoordinator, preparedSetupPrefix, } = res;
|
|
1460
1469
|
const usesSandbox = run.agent.kind === "sandbox";
|
|
@@ -2491,73 +2500,74 @@ async function runAttemptBody(a, config, t0, base, res, parentSignal) {
|
|
|
2491
2500
|
// 闭集声明一致:agent.teardown → sandbox.cleanup;各段可独立标 failed。
|
|
2492
2501
|
// 沙箱 stop / 接收器 close 不在这里 —— 由 runAttemptEffect 的 Sample 在本函数返回后回收,
|
|
2493
2502
|
// 并经 finalizer 计成 sandbox.stop。没有对应 teardown/cleanup 的段直接跳过,不产生空阶段。
|
|
2494
|
-
if (
|
|
2495
|
-
|
|
2496
|
-
|
|
2497
|
-
|
|
2498
|
-
|
|
2499
|
-
|
|
2500
|
-
|
|
2501
|
-
|
|
2502
|
-
|
|
2503
|
-
|
|
2504
|
-
|
|
2505
|
-
|
|
2506
|
-
|
|
2507
|
-
|
|
2508
|
-
|
|
2503
|
+
if (assertFirst.beginCleanup()) {
|
|
2504
|
+
try {
|
|
2505
|
+
if (agentSetupReached && run.agent.teardown) {
|
|
2506
|
+
enterPhase("agent.teardown");
|
|
2507
|
+
await recorder
|
|
2508
|
+
.measureClosing("agent.teardown", async () => {
|
|
2509
|
+
try {
|
|
2510
|
+
// 先按 kind 收窄 Agent 联合,再取 teardown —— 否则可选属性访问会把
|
|
2511
|
+
// AgentTeardown | DirectAgentTeardown 混成无法调用的签名。
|
|
2512
|
+
if (run.agent.kind === "sandbox") {
|
|
2513
|
+
const teardown = run.agent.teardown;
|
|
2514
|
+
if (teardown) {
|
|
2515
|
+
const context = { ...sandboxAttemptCtx, signal };
|
|
2516
|
+
const native = (0, effect_runtime_ts_1.agentTeardownEffect)(run.agent, sandbox, context);
|
|
2517
|
+
await assertFirst.requestCleanup((0, cleanup_timeout_ts_1.withCleanupTimeout)(native === undefined
|
|
2518
|
+
? (0, callback_context_ts_1.withAgentCallbackContext)(context, (callbackContext) => (0, effect_runtime_ts_1.authorCallbackEffect)(() => teardown(sandbox, callbackContext)), { inheritAttemptSignal: false })
|
|
2519
|
+
: (0, callback_context_ts_1.withAgentCallbackContext)(context, (callbackContext) => (0, effect_runtime_ts_1.agentTeardownEffect)(run.agent, sandbox, callbackContext), { inheritAttemptSignal: false })));
|
|
2520
|
+
}
|
|
2521
|
+
}
|
|
2522
|
+
else {
|
|
2523
|
+
const teardown = run.agent.teardown;
|
|
2524
|
+
if (teardown) {
|
|
2525
|
+
const context = { ...attemptCtx, signal };
|
|
2526
|
+
const native = (0, effect_runtime_ts_1.agentTeardownEffect)(run.agent, sandbox, context);
|
|
2527
|
+
await assertFirst.requestCleanup((0, cleanup_timeout_ts_1.withCleanupTimeout)(native === undefined
|
|
2528
|
+
? (0, callback_context_ts_1.withAgentCallbackContext)(context, (callbackContext) => (0, effect_runtime_ts_1.authorCallbackEffect)(() => teardown(callbackContext)), { inheritAttemptSignal: false })
|
|
2529
|
+
: (0, callback_context_ts_1.withAgentCallbackContext)(context, (callbackContext) => (0, effect_runtime_ts_1.agentTeardownEffect)(run.agent, sandbox, callbackContext), { inheritAttemptSignal: false })));
|
|
2530
|
+
}
|
|
2531
|
+
}
|
|
2509
2532
|
}
|
|
2510
|
-
|
|
2511
|
-
|
|
2512
|
-
|
|
2513
|
-
|
|
2514
|
-
const context = { ...attemptCtx, signal };
|
|
2515
|
-
const native = (0, effect_runtime_ts_1.agentTeardownEffect)(run.agent, sandbox, context);
|
|
2516
|
-
await assertFirst.requestEffect((0, cleanup_timeout_ts_1.withCleanupTimeout)(native === undefined
|
|
2517
|
-
? (0, callback_context_ts_1.withAgentCallbackContext)(context, (callbackContext) => (0, effect_runtime_ts_1.authorCallbackEffect)(() => teardown(callbackContext)), { inheritAttemptSignal: false })
|
|
2518
|
-
: (0, callback_context_ts_1.withAgentCallbackContext)(context, (callbackContext) => (0, effect_runtime_ts_1.agentTeardownEffect)(run.agent, sandbox, callbackContext), { inheritAttemptSignal: false })));
|
|
2533
|
+
catch (e) {
|
|
2534
|
+
declareFailure("agent.teardown", e);
|
|
2535
|
+
diagnostics.push(teardownDiagnostic("agent.teardown", e));
|
|
2536
|
+
throw e;
|
|
2519
2537
|
}
|
|
2520
|
-
}
|
|
2538
|
+
})
|
|
2539
|
+
.catch(() => { });
|
|
2521
2540
|
}
|
|
2522
|
-
|
|
2523
|
-
|
|
2524
|
-
|
|
2525
|
-
|
|
2541
|
+
try {
|
|
2542
|
+
await assertFirst.requestCleanup((0, cleanup_timeout_ts_1.cleanupCallback)((cleanupSignal) => attemptResources.releaseAll(cleanupSignal)));
|
|
2543
|
+
}
|
|
2544
|
+
catch (error) {
|
|
2545
|
+
reportAttemptResourceReleaseFailure(error);
|
|
2546
|
+
}
|
|
2547
|
+
for (const lifecycle of evalPluginLifecycles.slice(0, activatedEvalPlugins).reverse()) {
|
|
2548
|
+
if (lifecycle.teardown === undefined)
|
|
2549
|
+
continue;
|
|
2550
|
+
try {
|
|
2551
|
+
await assertFirst.requestCleanup((0, cleanup_timeout_ts_1.cleanupCallback)((signal) => lifecycle.teardown({
|
|
2552
|
+
...evalPluginContext,
|
|
2553
|
+
signal,
|
|
2554
|
+
})));
|
|
2555
|
+
}
|
|
2556
|
+
catch (error) {
|
|
2557
|
+
feedback.diagnostic({
|
|
2558
|
+
code: "plugin-lifecycle-teardown-failed",
|
|
2559
|
+
level: "warning",
|
|
2560
|
+
message: error instanceof Error ? error.message : String(error),
|
|
2561
|
+
});
|
|
2562
|
+
}
|
|
2526
2563
|
}
|
|
2527
|
-
})
|
|
2528
|
-
.catch(() => { });
|
|
2529
|
-
}
|
|
2530
|
-
try {
|
|
2531
|
-
await assertFirst.requestEffect((0, cleanup_timeout_ts_1.cleanupCallback)((cleanupSignal) => attemptResources.releaseAll(cleanupSignal)));
|
|
2532
|
-
}
|
|
2533
|
-
catch (error) {
|
|
2534
|
-
// An interrupted body can resume its Promise finally only after the
|
|
2535
|
-
// Effect bridge has closed. The Scope finalizer above still performs the
|
|
2536
|
-
// release; this named closure is therefore lifecycle control, not a
|
|
2537
|
-
// second teardown failure.
|
|
2538
|
-
if (!(error instanceof api_ts_1.AssertionAuthoringClosedError && error.reason === "attempt-interrupted")) {
|
|
2539
|
-
reportAttemptResourceReleaseFailure(error);
|
|
2540
|
-
}
|
|
2541
|
-
}
|
|
2542
|
-
for (const lifecycle of evalPluginLifecycles.slice(0, activatedEvalPlugins).reverse()) {
|
|
2543
|
-
if (lifecycle.teardown === undefined)
|
|
2544
|
-
continue;
|
|
2545
|
-
try {
|
|
2546
|
-
await assertFirst.requestEffect((0, cleanup_timeout_ts_1.cleanupCallback)((signal) => lifecycle.teardown({
|
|
2547
|
-
...evalPluginContext,
|
|
2548
|
-
signal,
|
|
2549
|
-
})));
|
|
2550
2564
|
}
|
|
2551
|
-
|
|
2552
|
-
|
|
2553
|
-
code: "plugin-lifecycle-teardown-failed",
|
|
2554
|
-
level: "warning",
|
|
2555
|
-
message: error instanceof Error ? error.message : String(error),
|
|
2556
|
-
});
|
|
2565
|
+
finally {
|
|
2566
|
+
assertFirst.completeCleanup();
|
|
2557
2567
|
}
|
|
2558
2568
|
}
|
|
2559
|
-
// Agent teardown
|
|
2560
|
-
//
|
|
2569
|
+
// Agent / Eval Plugin teardown 留在 Promise author 边界的同一 ordered cleanup;
|
|
2570
|
+
// 作者 Sandbox cleanup / Provider Case 仍由外层 Effect Scope finalizer 接管。
|
|
2561
2571
|
}
|
|
2562
2572
|
}
|
|
2563
2573
|
/** 把一次 teardown / cleanup 失败折成一条 `DiagnosticRecord`(warning,不改判定)。message 取一层
|