Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions docs/architecture/rfcs/monorepo-distribution-split-v0.md
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,29 @@ retained core capability (D2).
recovery semantics from the unified controller/executor design. Required
reads and source completeness remain binding.

A Worker launched by a built-in Host receives task requirements, scoped
authority, and the original read route. Todo-authoring CLI templates and the
ordinary delivery mode's quota spend instructions stay with the outer executor
in the complete captured contract, while standard Worker disposition conditions
for owner-only blockers and one-segment execution are delivered through checked
prompt guidance (custom rules and non-ordinary modes keep original rule text). Work, repair, and stop conditions remain
available to the Worker. Unconfigured memory recall and empty pre-turn
observations expose their current scoped status in this view. Their full
receipts stay in the original capture, with observations, failures, required
reads and unfamiliar data still delivered when present.

Work context carries the selected task, scoped User Todos and their read
provenance. For both registered Todo read formats, the field dictionary stays
with the canonical Todo reader. Existing captures remain available under
their original digests.

An ordinary admitted task presents its work, scope and validation to the Worker.
Matching ready lease preparations stay with launch and settlement. Unready,
inconsistent and unfamiliar preparations remain visible.
Operators read release readiness and completed-work maintenance through
quota/status or the original capture. Task context omits these maintenance
directions.

Context reuse must be invalidated by relevant source/requirement revisions,
session generation changes, compaction or lost acknowledgements. A smaller
packet cannot be treated as proof the executor has the prior context. Recover
Expand Down
16 changes: 16 additions & 0 deletions docs/architecture/rfcs/monorepo-distribution-split-v0.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,22 @@ capability 包直接采用现有 `extension.toml` 契约,不做扩展。唯一
4. **提供上下文:** 为所选工作和 executor 渲染现有受治理工作契约,复用统一 Controller/Executor
设计的首次完整、后续差量与恢复语义。Required reads 和来源完整性仍有约束力。

内置 Host 启动的 Worker 收到任务要求、权限范围和原始依据的读取路径。Todo 写入命令模板
和普通执行模式的扣额说明留在外层执行器持有的完整 capture 中,标准工作段与所有者阻塞时
的 Worker 报告及独立继续要求则经由已校验来源投影保留给 Worker(自定义规则及非普通模式
保留原规则原文)。Worker 仍能读取工作、
修复和停止条件。未配置的记忆召回和没有结果的启动前观察只向 Worker 提供带作用域的
当前状态,完整回执留在原始 capture 中。有实际结果、失败、必读材料或未知字段时,
Worker 仍会收到对应内容。

工作上下文携带选中的任务、作用域内的 User Todo 和读取依据。两种已登记的 Todo 读取
格式都把字段表留在 canonical Todo 读取入口。已有 capture 仍可按原摘要读取。

普通任务准入后,Worker 收到当前任务、范围与验证要求。完全一致的就绪租约记录留在
启动和结算入口,未就绪、有差异或格式未知的记录仍在任务视图中可见。
操作方通过 quota/status 或原始 capture 读取发布资格和已完成工作的维护提醒。
任务上下文省略这些维护指令。

相关来源/要求版本变化、Session generation 变化、compaction 或 ACK 丢失时,必须使上下文复用失效。
不能因为 packet 更小,就认为 executor 已掌握前文。连续性未知时走所属契约的恢复路径。
Capability 指令仅在适用时提供;authority 不能从 prompt 文字推导。
Expand Down
56 changes: 55 additions & 1 deletion docs/reference/protocols/loopx-turn-v0.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,40 @@ the effect projection, scheduler/automation execution data and
`interaction_contract.cli_channel` remain with the outer executor. The model
view resolves existing replan authoring and Explore guidance references before
hiding their outer owner, preserving the original scalar values and text.
Operators can read release readiness and completed Todo archive warnings in
quota/status and the original capture. The built-in Worker view omits these
maintenance directions.
Recognized unconfigured recall keeps its Goal, Agent and disabled status.
Known empty pre-turn observations keep their hook, capability and status.
The full readbacks stay with the executor. Available context, failed
observations, required reads and extended readbacks reach the Worker intact.
Work-context delivery keeps scoped Todo records, their provider revision and
record digest. The canonical Todo reader supplies the field dictionary for
both registered read formats. Unknown formats retain their supplied metadata.
For ordinary admitted work, matching recognized ready lease preparations stay
with the launcher and settlement reader. The Worker retains the admitted task,
scope, required reads and validation conditions. Unready, differing and
extended preparations stay in the task view.
When admitted `steering_audit_then_one_step` carries the standard mixed
accounting clause, that clause stays with the executor and the TypeScript
source check enables the built-in work-segment guidance in the Worker prompt:
check direction, then choose the largest coherent work segment it can reliably
complete and verify given its capabilities, budget, admitted task, scope and
execution profile (`one_step` is a work segment, not a single operation, and a
Todo groups related steps toward one verifiable outcome). Unrecognized policy
text stays in the task view untouched without substituting that guidance,
because it can carry additional constraints.
When admitted ordinary work carries the standard owner-only blocker rule in
`todo_write_hint`, command templates and queue section headings remain with the
outer executor while the TypeScript source check enables the Todo rules owner's
Worker disposition requirements in the prompt: report verified owner-only
blockers for `user_gate` even when noted in Next Action (non-blocking requests
belong in `user_action`), split mixed work and isolate the smallest blocked Todo,
give the owner the exact action and verification check, and continue runnable
independent work or identify a useful independent successor from Goal acceptance
before yielding. Custom `todo_write_hint.rule` text and non-ordinary turns
retain the original `rule` in `task_context` (still isolating CLI templates and
section headers) without substituting the built-in guidance.
The model receives the original `source_decision_hash`, reader references and
`source_schema_version`; that hash commits the original source, not the task
view. Inline task context does not require a filesystem read of a private
Expand All @@ -120,7 +154,27 @@ reader when needed.
范围、执行要求和未知新增信息。来源绑定、effect projection、scheduler/automation
执行数据及 `interaction_contract.cli_channel` 留在外层执行器。
来源中指向外层 owner 的 replan 编写和 Explore 指导引用在隐藏该 owner 前展开,
保留原始标量和文本。模型仍收到原始
保留原始标量和文本。操作方在 quota/status 和原始 capture 中读取发布资格和已完成
Todo 归档提醒。内置 Worker 视图省略这两条维护指令。能识别的未配置召回保留
Goal、Agent 和停用状态。已知的空观察
保留钩子、能力和状态。完整回执留在外层执行器。有可用上下文、观察失败、必需读取
或扩展回执时,Worker 仍收到完整内容。工作上下文保留作用域内的 Todo、读取版本和记录摘要。
两种已登记格式的字段表由 canonical Todo 读取入口提供,未知格式保留其元数据。
普通任务准入后,完全一致且可识别的就绪租约记录留在启动和结算入口。Worker 保留已准入
任务、范围、必需读取与验证条件。未就绪、有差异或带扩展字段的记录继续交付给 Worker。
当获准执行的 `steering_audit_then_one_step` 携带标准混合扣额条款时,该条款
留在执行器,由 TypeScript 来源校验开启内置提示中的工作段指导:先核对方向,再按
自身能力、预算、已准入任务、范围和执行要求,选择能可靠完成并验证的最大连贯工作段
(`one_step` 指一个工作段而非单次操作,同一可验证结果的相关操作归在一个 Todo)。
无法识别的策略原文继续完整交付给 Worker 且不以该指导替代,因为它可能带有额外约束。
当普通任务准入后的 `todo_write_hint` 携带标准所有者阻塞处置规则时,写入命令
模板与队列标题留在外层执行器,TypeScript 来源校验通过 Todo 规则 owner 在内置
Worker 提示中保留阻塞报告与继续工作的必要条件:确认属于所有者的阻塞时立即作为
`user_gate` 报告(即使已在 Next Action 记述;非阻塞请求归入 `user_action`),拆分混合工作并
隔离最小受阻 Todo,向所有者提供具体动作与验真检查,并在交还前继续独立可做的工作或从
Goal acceptance 中识别独立后继;自定义 `todo_write_hint.rule` 文本及非普通模式保留原
`rule`(同时继续隔离命令模板与标题)而不以内置提示替代。
模型仍收到原始
`source_decision_hash`、reader 引用和 `source_schema_version`;该 hash 绑定原始
来源,不绑定任务视图。已内联的任务上下文不要求 sandbox 读取不可访问的私有 capture,
缺少必需证据仍暂停依赖该证据的工作。此呈现不是 adapter 请求,也不授予权限、结算或
Expand Down
36 changes: 28 additions & 8 deletions loopx/control_plane/capability_hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,10 @@ const TURN_START_RESULT_FIELDS = new Set([
"provider_payload_returned",
"error_code",
]);
const TURN_START_OBSERVATION_FLAGS = [
"agent_read_required", "external_reads_performed", "external_writes_performed",
"local_private_state_mutated", "private_content_returned", "provider_payload_returned",
];
const POST_WRITEBACK_REGISTRATION_FIELDS = new Set([
"schema_version",
"hook_id",
Expand Down Expand Up @@ -560,14 +564,7 @@ export function validateTurnStartHookInvocation(input: {
if (observationCount < 0 || observationCount > 10_000) {
throw new Error("turn-start hook observation_count is invalid");
}
for (const field of [
"agent_read_required",
"external_reads_performed",
"external_writes_performed",
"local_private_state_mutated",
"private_content_returned",
"provider_payload_returned",
]) {
for (const field of TURN_START_OBSERVATION_FLAGS) {
const uncertainEffect = result[field] === null &&
["failed", "partial", "unavailable"].includes(status) &&
["external_reads_performed", "local_private_state_mutated"].includes(field);
Expand Down Expand Up @@ -665,6 +662,29 @@ export function projectTurnStartUnavailableContext(value: unknown): JsonObject |
};
}

/** Keep current empty/not-applicable observations visible without their effect receipts. */
export function projectEmptyTurnStartObservations(value: unknown): JsonObject | null {
const dispatch = jsonObject(value);
if (!dispatch || Object.keys(dispatch).length !== 7 ||
dispatch.schema_version !== "loopx_turn_start_capability_hook_dispatch_v1" ||
dispatch.phase !== "turn_start" || !Array.isArray(dispatch.results) ||
dispatch.registered_count !== dispatch.results.length || dispatch.invoked_count !== dispatch.results.length ||
!Array.isArray(dispatch.required_reads) || dispatch.required_reads.length !== 0 ||
!Array.isArray(dispatch.failures) || dispatch.failures.length !== 0) return null;
const results: JsonObject[] = [];
for (const raw of dispatch.results) {
const row = jsonObject(raw);
if (!row || Object.keys(row).length !== TURN_START_RESULT_FIELDS.size ||
row.schema_version !== TURN_START_HOOK_RESULT_SCHEMA_VERSION || row.phase !== "turn_start" ||
typeof row.hook_id !== "string" || typeof row.capability_id !== "string" ||
(row.status !== "empty" && row.status !== "not_applicable") ||
row.observation_count !== 0 || row.error_code !== null ||
!TURN_START_OBSERVATION_FLAGS.every(flag => row[flag] === false)) return null;
results.push({hook_id: row.hook_id, capability_id: row.capability_id, status: row.status});
}
return {results};
}

export function validatePostWritebackHookRegistration(
value: unknown,
): JsonObject & {
Expand Down
3 changes: 2 additions & 1 deletion loopx/control_plane/quota/context_delivery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ export function compactTodoContextSource(content: JsonObject): JsonObject {
}
const authority = jsonObject(content.authority_read);
const model = jsonObject(authority?.todo_read_model);
if (model?.schema_version === COORDINATION_STATE_CONTRACT.todo_read_record.schema_version
if (model && (model.schema_version === COORDINATION_STATE_CONTRACT.todo_read_record.schema_version
|| model.schema_version === COORDINATION_STATE_CONTRACT.todo_domain_record.schema_version)
&& Array.isArray(model.contract_fields)
&& model.contract_fields.every(field => typeof field === "string")) {
const {contract_fields: _dictionary, ...metadata} = model;
Expand Down
Loading
Loading