feat(ptc): present provider execution guidance in logged program schema

This commit is contained in:
Tianyi Cui committed 2026-09-12 15:03:02 +08:00
1 parent c6b959783a
commit 2a08bf6ab9
17 files changed
+36 -15

No files matched your search

@@ -2,5 +2,5 @@
# side as of the last confirmed-consistent state. Both languages carry equal authority;
# after editing either side, bring the other along and re-record with:
# pnpm run verify-translation-pairing --write packages/code-runtime/code-runtime/README.md
README.md: ede55ec882cc8d51f0457800d6c79c31145882c4
README.zh.md: 938ccd0dcfa37dbc237f8f8b016763053b4e0ea2
README.md: 162d875966b0225b629a722986757035e30082e9
README.zh.md: 9f794d1c65b165e302e1d2349dc169bd672d00c3
@@ -70,6 +70,8 @@ The package is the Service Definition role of the code-execution capability seam
The readonly `timeout` descriptor exposes `{ defaultMs, maxMs }` for a provider supporting per-call overrides; `undefined` means that the consumer must omit the field. It reports presentation values, while `resolve` remains the validation and clamping authority.
`executionInstructions` supplies provider-owned usage guidance, or an empty string when none is needed. Consumers can include it in their program presentation without identifying the provider from its language or isolation descriptor; PTC includes it in the logged `run_code` schema.
`resolve(request)` owns supported option validation and deployment defaulting. `run(spec)` executes the complete inputs and resolves program outcomes after cleanup. Language and substrate descriptors guide presentation; `sandboxMode` indicates whether the consumer can pass a resolved file policy. Neither descriptors nor a successful program result substitute for the backend's reported enforcement facts.
The exhaustive semantics live in the [code runtime subsystem reference](../../../docs/subsystems/code-runtime.md); the exact signatures are in [`src/index.ts`](src/index.ts).
@@ -70,6 +70,8 @@ binding-global 与 error-class 名称是语言可移植的:必须匹配 `[A-Za
只读 `timeout` 描述符为支持逐次覆盖的提供方公开 `{ defaultMs, maxMs }`;`undefined` 表示消费方必须省略该字段。它报告呈现值,验证与截断仍由 `resolve` 负责。
`executionInstructions` 提供由运行时拥有的使用说明;不需要说明时返回空字符串。消费方可将其纳入程序呈现,无需根据语言或隔离描述符识别提供方;PTC 将它纳入已记录的 `run_code` schema。
`resolve(request)` 负责支持选项的验证与部署默认值。`run(spec)` 执行完整输入,并在清理后返回程序结果。语言和执行基底描述符指导呈现;`sandboxMode` 表示消费方能否传入已解析文件策略。描述符与程序成功结果都不能代替后端报告的强制能力事实。
穷尽式语义见[代码运行时子系统参考](../../../docs/subsystems/code-runtime.zh.md);确切签名见 [`src/index.ts`](src/index.ts)。
@@ -121,6 +121,9 @@ export abstract class CodeRuntime extends Service {
*/
abstract readonly isolation: string
/** Provider-owned program usage guidance for consumers to present alongside the source language. */
get executionInstructions(): string { return '' }
/** Deployment file-policy mode, or undefined for a provider without confinement support. */
get sandboxMode(): SandboxMode | undefined { return undefined }