diff --git a/docs/architecture/rfcs/monorepo-distribution-split-v0.md b/docs/architecture/rfcs/monorepo-distribution-split-v0.md index 1fbca97cbe..96b3cc3a99 100644 --- a/docs/architecture/rfcs/monorepo-distribution-split-v0.md +++ b/docs/architecture/rfcs/monorepo-distribution-split-v0.md @@ -3971,3 +3971,27 @@ R1/M3, real-host compaction/thread retention, progressive control, comparable complete costs, Standard/workspace delivery and original-Goal regression remain open. No default activation, host upgrade, release or frozen-budget change is implied by these protocol fixtures. + +### 2026-11-14 — Coordination loads terminal evidence on its selected route + +The local-authority runtime defers `ResearchTerminalEvidenceHost` until a valid +terminal lifecycle request selects it. Ordinary coordination no longer loads +that adapter and its research implementation dependencies. The existing typed +terminal owner, registry witness, research qualification, writer locks and +resource cleanup remain responsible for completion; no competing work schema +or execution pipeline is introduced. + +A fresh-process fault injection makes the terminal adapter unavailable. The +ordinary claim persists and replays its original receipt, malformed claims +leave state unchanged, and a selected terminal request fails without a new +receipt or state mutation. The retained base fails this same ordinary-claim +probe. The source authority/terminal suite passes 93 cases. Applying the same +patch to the exact C1 candidates in #8266 (`b15c443ee64d`) and #8484 +(`b7e4e01cc423`) passes 188 and 193 authority, context and recovery cases +respectively; the latter also covers real SQLite admission. + +This is a loading and failure-isolation prerequisite, aligned with C1's existing +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. diff --git a/docs/architecture/rfcs/monorepo-distribution-split-v0.zh-CN.md b/docs/architecture/rfcs/monorepo-distribution-split-v0.zh-CN.md index f76b5bd547..d621d18086 100644 --- a/docs/architecture/rfcs/monorepo-distribution-split-v0.zh-CN.md +++ b/docs/architecture/rfcs/monorepo-distribution-split-v0.zh-CN.md @@ -3093,3 +3093,23 @@ PR #8707(`d695b40f633742fb0a5e1cb6b970a56c46dba5e9`,合入提交 compaction/线程保留、渐进控制、可比完整成本、Standard/workspace 交付和 原 Goal 回归仍开放。协议 fixture 不表示默认激活、Host 升级、发行或冻结预算 发生变化。 + +### 2026-11-14 — Coordination 在选定终结路径加载证据适配器 + +local-authority runtime 将 `ResearchTerminalEvidenceHost` 延后到合法的 +terminal lifecycle 请求选中它时加载。普通 coordination 不再加载该适配器 +及其研究实现依赖。完成操作仍由现有 typed terminal owner、registry witness、 +研究资格检查、writer lock 和资源清理负责;没有新增竞争的工作 schema 或 +执行流水线。 + +新进程故障注入使 terminal 适配器不可用:普通 claim 仍落盘并重放原回执, +非法 claim 保持状态不变,选中的 terminal 请求则明确失败,不产生新回执或 +状态变更。保留的基线在同一普通 claim 探针上失败。源码 authority/terminal +整组 93 项通过。同一补丁应用到 C1 的精确候选 #8266(`b15c443ee64d`)和 +#8484(`b7e4e01cc423`)后,authority、context 与 recovery 分别有 188 和 +193 项通过;后者还覆盖真实 SQLite admission。 + +这只是对齐 C1 现有 owner 的加载和故障隔离前提。合法 terminal 请求仍会加载 +适配器,包括 ordinary Todo 的 guard 随后提前返回的情况。完整工作流隔离、 +成对完整成本、真实 Host 采用、R1/M3 以及 C1 writer/consumer 切换仍开放。 +这些测试不授权 C1 默认推广,也不证明模型收益。 diff --git a/loopx/control_plane/coordination/local_authority_runtime.ts b/loopx/control_plane/coordination/local_authority_runtime.ts index 4d4de11614..17c50ec26e 100644 --- a/loopx/control_plane/coordination/local_authority_runtime.ts +++ b/loopx/control_plane/coordination/local_authority_runtime.ts @@ -3,7 +3,6 @@ import {verifyReentrySettlement} from "./todo_terminal_reentry.ts"; import {readPromotionReceipt, commitPromotionAndReadBack} from './promotion_receipt.ts'; import {reviewedPromotionPlan, promotionPlanDigest, decodeReviewedPromotionOperation, REVIEWED_PROMOTION_OPERATION_RESULT_SCHEMA} from './reviewed_promotion_plan.ts'; import {registryAuthoritySourceCheck} from "./authority_source.ts"; -import {ResearchTerminalEvidenceHost} from "../capabilities/explore_research_terminal.ts"; import {decodeTaskLeaseProof} from "./task_lease_proof.ts"; import type {ClaimWorkspaceObserver} from "./claim_execution.ts"; import {LeaseWorktreeObservationError, observeLeaseWorktree} from "../work_items/task_lease_workspace.ts"; @@ -1363,6 +1362,7 @@ export async function terminalLifecycleLocalCoordinationTodo( requireAuthorityStoreId(todoId, "linked successor Todo id")); const successorIntents = input.successor_intents.map((intent, index) => requireJsonObject(intent, `successor_intents[${index}]`)); + const {ResearchTerminalEvidenceHost} = await import("../capabilities/explore_research_terminal.ts"); return await withCanonicalWriter(root, goalId, input.dry_run === true, async () => { const store = await openRuntimeStore(root, goalId, dependencies); sourceAuthority = sourceAuthorityFor(store); diff --git a/tests/control_plane_ts/effect_runtime_handler_loading.test.ts b/tests/control_plane_ts/effect_runtime_handler_loading.test.ts index fedcb8b572..1b435abb31 100644 --- a/tests/control_plane_ts/effect_runtime_handler_loading.test.ts +++ b/tests/control_plane_ts/effect_runtime_handler_loading.test.ts @@ -2,6 +2,92 @@ import assert from "node:assert/strict"; import {spawnSync} from "node:child_process"; import test from "node:test"; +test("coordination claims remain available without terminal research evidence", () => { + 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 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 terminalLoads = 0; + registerHooks({load(url, context, nextLoad) { + if (url.endsWith("/capabilities/explore_research_terminal.ts")) { + terminalLoads++; + throw new Error("terminal research evidence 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-selected-loading-")); + try { + await engageCanonicalRoute(root); + const store = new FileAuthorityStore(join(root, "authority", "file-v0"), "goal-a"); + assert.equal((await store.commitAuthority({expected_provider_revision: null, + operation_id: "seed", events: [], receipts: [], + next_projection: projection([todo()], [], "soft_claim")})).status, "applied"); + const handlers = createEffectRuntimeHandlers({fingerprint: "loading-test", requestShutdown() {}}); + const request = {schema_version: "loopx_local_coordination_todo_claim_request_v0", + runtime_root: root, goal_id: "goal-a", todo_id: "todo_one", role: "agent", + claimed_by: "agent-a", actor_agent_id: "agent-a", registered_agents: ["agent-a"], + operation_id: "claim", observed_at: "2026-09-05T04:30:00Z", dry_run: false}; + const applied = await dispatchEffectRuntimeMethod(handlers, + "coordination.local_authority.todo_claim", request); + assert.equal(applied.status, "applied", JSON.stringify(applied)); + const claimed = await store.loadAuthority(); + assert.equal(claimed.status, "loaded"); + assert.equal(claimed.head.todos[0].claimed_by, "agent-a"); + const receipt = await store.readReceipt("claim"); + assert.equal(receipt.status, "found"); + assert.equal((await dispatchEffectRuntimeMethod(handlers, + "coordination.local_authority.todo_claim", request)).status, "replayed"); + assert.deepEqual(await store.loadAuthority(), claimed); + assert.deepEqual(await store.readReceipt("claim"), receipt); + const invalid = await dispatchEffectRuntimeMethod(handlers, + "coordination.local_authority.todo_claim", {...request, operation_id: "invalid", dry_run: "true"}); + assert.equal(invalid.reason_code, "invalid_local_coordination_todo_claim_request"); + assert.deepEqual(await store.readReceipt("invalid"), {status: "missing"}); + assert.deepEqual(await store.loadAuthority(), claimed); + assert.equal(terminalLoads, 0); + const registry = join(root, "registry.json"); + await writeFile(registry, "{}"); + const terminalRequest = { + 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: "terminal"}, + 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: null, 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, + }; + for (let attempt = 0; attempt < 2; attempt++) { + const failed = await dispatchEffectRuntimeMethod(handlers, + "coordination.local_authority.todo_terminal", terminalRequest); + assert.equal(failed.status, "failed"); + assert.match(failed.reason, /terminal research evidence unavailable/); + assert.deepEqual(await store.readReceipt("terminal"), {status: "missing"}); + assert.deepEqual(await store.loadAuthority(), claimed); + } + 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-strip-types", + "--input-type=module", "-e", script], {encoding: "utf8", timeout: 30_000}); + assert.equal(child.status, 0, 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.