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
29 changes: 29 additions & 0 deletions docs/architecture/rfcs/monorepo-distribution-split-v0.md
Original file line number Diff line number Diff line change
Expand Up @@ -3995,3 +3995,32 @@ owners. A valid terminal request still loads the adapter, including when its
ordinary-Todo guard returns early. Complete workflow isolation, paired complete
costs, real-host adoption, R1/M3 and C1 writer/consumer cutover remain open.
These tests do not authorize C1 default promotion or establish model benefit.


### 2026-11-14 — Ordinary completion defers research implementations

`ResearchTerminalEvidenceHost.qualify` loads its research execution and
configuration implementations after its existing Todo applicability check.
A Todo without research or replan applicability signals can therefore persist
its completion evidence and replay its original receipt while either research
implementation is unavailable.
Research-qualified Todos still select the same policy and evidence owners;
module failures retain their error and commit no completion state or receipt.
The existing source checks, writer fence, qualification, CAS and cleanup apply.

Fresh-process fault cases cover both unavailable implementations on real File
and SQLite authority. Both retained baseline probes fail at the ordinary
completion; the candidate completes and independently reads back the result,
replays without a new effect and refuses repeated selected-research failures.
The available-module comparison passes the same 107 existing native cases;
the candidate additionally passes the failure-isolation case, for 108 total.
The real research CLI suite passes 11 cases. The same production delta and
fault cases pass with the exact C1 candidates #8266 (`b0b930bfb92a`) and #8484
(`b7e4e01cc423`), with 190 and 189 authority, context and recovery cases. An independently built Core wheel, installed alone, also passes the same File/SQLite fault paths with production module bytes equal to the source; this does not qualify an installed model Host or adoption.

This closes the evidenced ordinary-completion dependency failure using the
existing research guard, without duplicating the C1 work contract or its
producer/consumer pipeline. Research- or replan-associated Todos still enter the existing policy check and
load its implementations; a disabled policy does not remove that remaining
loading dependency. Complete D2/D5 closure, real-model Host/context continuity, progressive controls,
comparable complete cost, R1/M3 and C1 default cutover remain unqualified.
20 changes: 20 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 @@ -3113,3 +3113,23 @@ terminal lifecycle 请求选中它时加载。普通 coordination 不再加载
适配器,包括 ordinary Todo 的 guard 随后提前返回的情况。完整工作流隔离、
成对完整成本、真实 Host 采用、R1/M3 以及 C1 writer/consumer 切换仍开放。
这些测试不授权 C1 默认推广,也不证明模型收益。


### 2026-11-14 — 普通任务完成延后研究实现加载

`ResearchTerminalEvidenceHost.qualify` 在原有 Todo 适用性检查之后才加载研究执行与
配置实现。因此,即使任一研究实现不可用,没有研究或重规划适用性标记的 Todo 仍能持久化
完成证据并重放原回执。需要研究资格的 Todo 继续选中原策略和证据 owner;模块失败保留错误且不提交
完成状态或回执。原 source 检查、writer fence、资格判定、CAS 和清理继续执行。

新进程故障用例在真实 File 与 SQLite authority 上覆盖两个不可用实现。两个保留的
基线探针均在普通完成处失败;候选能够完成并独立回读结果,重放时不产生新效果,且
重复的已选中研究失败仍被拒绝。模块可用时,同一组原有 107 项 native 用例全部通过;
候选另通过故障隔离用例,共 108 项。真实研究 CLI 套件通过 11 项。同一 production
改动与故障用例和 C1 精确候选 #8266(`b0b930bfb92a`)、#8484(`b7e4e01cc423`)
组合后,分别通过 190 与 189 项 authority、上下文和恢复用例。独立构建并单独安装的 Core wheel 也通过同一 File/SQLite 故障路径,其 production 模块字节与源码一致;这不验证模型 Host 的安装或采用。

这项交付通过原研究 guard 修复已证明的普通完成依赖故障,复用 C1 的工作契约与
producer/consumer 管线。带研究或重规划标记的 Todo 仍进入原策略检查并加载其实现;策略禁用时也保留
这项待隔离的加载依赖。完整 D2/D5 闭包、真实模型
Host/上下文延续、渐进控制、可比完整成本、R1/M3 与 C1 默认切换仍未完成资格验证。
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ import {createInterface} from "node:readline";
import type {JsonObject} from "../effect_program.ts";
import type {TodoTerminalEvidenceGuard} from "../coordination/todo_terminal_lifecycle.ts";
import {requireJsonObject} from "../runtime_decode.ts";
import {normalizeResearchCompositionPolicy, qualifyResearchCompletion} from "./explore_research_execution.ts";
import {resolveExploreGoalConfiguration} from "./explore_configuration.ts";

export class ResearchTerminalEvidenceHost {
private child: ChildProcessWithoutNullStreams | null = null;
Expand All @@ -26,6 +24,8 @@ export class ResearchTerminalEvidenceHost {
&& context.todo.capability_binding_ref !== "explore:research-composition-v0"
&& !(Array.isArray(context.todo.explore_result_node_refs) && context.todo.explore_result_node_refs.length)
&& !context.todo.replan_obligation_id) return {required: false, allowed: true, evidence: null};
const {normalizeResearchCompositionPolicy, qualifyResearchCompletion} = await import("./explore_research_execution.ts");
const {resolveExploreGoalConfiguration} = await import("./explore_configuration.ts");
const source = requireJsonObject(this.source, "research registry source");
const bytes = await readFile(String(source.path));
if (createHash("sha256").update(bytes).digest("hex") !== source.sha256) {
Expand Down
96 changes: 96 additions & 0 deletions tests/control_plane_ts/effect_runtime_handler_loading.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,102 @@ test("coordination claims remain available without terminal research evidence",
assert.equal(child.status, 0, child.stderr);
});

test("ordinary completion stays available without research implementation modules", () => {
const entry = new URL("../../loopx/control_plane/effect_runtime_handlers.ts", import.meta.url).href;
const fixtures = new URL("./local_promotion_fixture.ts", import.meta.url).href;
const source = new URL("./shadow_file_fixture.ts", import.meta.url).href;
const storeModule = new URL("../../loopx/control_plane/coordination/file_authority_store.ts", import.meta.url).href;
const providerModule = new URL("../../loopx/control_plane/coordination/local_authority_provider.ts", import.meta.url).href;
for (const backend of ["file", "sqlite"]) {
for (const blockedModule of ["explore_research_execution.ts", "explore_configuration.ts"]) {
const script = `
import assert from "node:assert/strict";
import {registerHooks} from "node:module";
import {mkdtemp, rm, writeFile} from "node:fs/promises";
import {createHash} from "node:crypto";
import {tmpdir} from "node:os";
import {join} from "node:path";
let blockedLoads = 0;
registerHooks({load(url, context, nextLoad) {
if (url.endsWith("/capabilities/" + ${JSON.stringify(blockedModule)})) {
blockedLoads++;
throw new Error("research implementation unavailable");
}
return nextLoad(url, context);
}});
const {createEffectRuntimeHandlers, dispatchEffectRuntimeMethod} = await import(${JSON.stringify(entry)});
const {engageCanonicalRoute} = await import(${JSON.stringify(fixtures)});
const {projection, todo} = await import(${JSON.stringify(source)});
const {FileAuthorityStore} = await import(${JSON.stringify(storeModule)});
const root = await mkdtemp(join(tmpdir(), "coordination-ordinary-completion-"));
try {
let store;
if (${JSON.stringify(backend)} === "sqlite") {
const {selectLocalSqliteAuthority, openLocalAuthorityStore} = await import(${JSON.stringify(providerModule)});
await selectLocalSqliteAuthority(root, "goal-a", true);
store = await openLocalAuthorityStore(root, "goal-a");
} else {
store = new FileAuthorityStore(join(root, "authority", "file-v0"), "goal-a");
}
await engageCanonicalRoute(root);
const ordinary = {...todo(), claimed_by: "agent-a"};
const research = {...todo("todo_research"), claimed_by: "agent-a", action_kind: "joint_probe"};
assert.equal((await store.commitAuthority({expected_provider_revision: null,
operation_id: "seed", events: [], receipts: [],
next_projection: projection([ordinary, research], [], "soft_claim")})).status, "applied");
const registry = join(root, "registry.json");
await writeFile(registry, "{}");
const handlers = createEffectRuntimeHandlers({fingerprint: "loading-test", requestShutdown() {}});
const request = {
schema_version: "loopx_local_coordination_todo_terminal_lifecycle_request_v3",
registry_source: {path: registry, sha256: createHash("sha256").update("{}").digest("hex")},
runtime_root: root, goal_id: "goal-a", todo_id: "todo_one", role: "agent",
command: "complete", actor_agent_id: "agent-a", registered_agents: ["agent-a"],
lifecycle_grants: [], authority_reason: null, decision_outcome: null,
operation_identity: {kind: "explicit", operation_id: "ordinary-complete"},
lease_idempotency_key: null, lease_expected_version: null, allow_user_gate_auto_acquire: false,
requested_no_followup: true, requested_completion_turn_key: null,
requested_completion_identity_source: null, linked_successor_todo_ids: [], successor_intents: [],
note: null, evidence: "validated ordinary result", reason: null, clear_claim: false,
validation_declaration: null, validation_receipt: null, completion_policy_request: null,
observed_at: "2026-09-05T04:30:00Z", dry_run: false,
};
const completed = await dispatchEffectRuntimeMethod(handlers,
"coordination.local_authority.todo_terminal", request);
assert.equal(completed.status, "applied", JSON.stringify(completed));
const accepted = await store.loadAuthority();
assert.equal(accepted.status, "loaded");
const result = accepted.head.todos.find(row => row.todo_id === "todo_one");
assert.equal(result.status, "done");
assert.equal(result.done, true);
assert.equal(result.evidence, "validated ordinary result");
const receipt = await store.readReceipt("ordinary-complete");
assert.equal(receipt.status, "found");
assert.equal((await dispatchEffectRuntimeMethod(handlers,
"coordination.local_authority.todo_terminal", request)).status, "replayed");
assert.deepEqual(await store.loadAuthority(), accepted);
assert.deepEqual(await store.readReceipt("ordinary-complete"), receipt);
assert.equal(blockedLoads, 0);
const selected = {...request, todo_id: "todo_research",
operation_identity: {kind: "explicit", operation_id: "research-complete"}};
for (let attempt = 0; attempt < 2; attempt++) {
const failed = await dispatchEffectRuntimeMethod(handlers,
"coordination.local_authority.todo_terminal", selected);
assert.equal(failed.status, "failed");
assert.match(failed.reason, /research implementation unavailable/);
assert.deepEqual(await store.readReceipt("research-complete"), {status: "missing"});
assert.deepEqual(await store.loadAuthority(), accepted);
}
assert.equal((await dispatchEffectRuntimeMethod(handlers, "runtime.ping", {})).ready, true);
} finally {await rm(root, {recursive: true, force: true});}
`;
const child = spawnSync(process.execPath, ["--no-warnings", "--experimental-sqlite", "--experimental-strip-types",
"--input-type=module", "-e", script], {encoding: "utf8", timeout: 30_000});
assert.equal(child.status, 0, `${backend}/${blockedModule}: ${child.stderr}`);
}
}
});

test("runtime loads selected owners without importing unrelated methods", () => {
const entry = new URL("../../loopx/control_plane/effect_runtime_handlers.ts", import.meta.url).href;
// Observe a fresh process, not this test runner's already imported modules.
Expand Down
Loading