fix(code-runtime): settle Python provider contracts

This commit is contained in:
Tianyi Cui
2026-08-31 15:50:45 +08:00
parent 8e9d5467b0
commit 7f84a825c9
33 changed files with 1145 additions and 223 deletions
+6 -2
View File
@@ -52,7 +52,11 @@ interface CodeRunResult {
* rendered string; a failed or value-less run leaves this absent.
*/
value?: CodeJsonValue
/** Text the program emitted, in order, bounded only as part of the outer result. */
/**
* Captured text. Each source channel preserves emission order; interleaving
* across independent channels is backend-dependent. Bounded only as part of
* the outer result.
*/
logs: string[]
/** Present iff the run failed; see {@link CodeRunFailure} for the taxonomy. */
error?: CodeRunFailure
@@ -131,7 +135,7 @@ type CodeBindingFunction = (args: unknown) => Promise<CodeJsonValue>
## 捕获的输出与失败分类体系
日志是按发出顺序排列的纯字符串。运行时捕获程序的 console 与流输出,但通道和 console 方法的元数据不属于 seam,因为 Consumer 只渲染文本。实现会对序列化后的外层日志数组,以及完成值或失败消息的组合载荷设置上限;固定的结果封装语法与 Consumer 展示空白不计入这份可变载荷计量。超限会显式失败,而不会在值中插入替代内容。
日志是纯字符串。每个来源通道保留自身的发出顺序;由于通道元数据不属于 seam,相互独立的通道如何交错由后端决定。运行时捕获程序的 console 与流输出,Consumer 只渲染文本。实现会对序列化后的外层日志数组,以及完成值或失败消息的组合载荷设置上限;固定的结果封装语法与 Consumer 展示空白不计入这份可变载荷计量。超限会显式失败,而不会在值中插入替代内容。
失败类型是**正交的结果,独立报告**(见 [defensive-patterns](../defensive-patterns.zh.md)):预算耗尽不是异常,中止不是超时,基底崩溃(如 OOM)也不是二者中的任何一个: