Skip to content

Commit 0c5652b

Browse files
cocolordTRAE CLI
andauthored
Defer terminal research evidence until coordination closeout (#8738)
Signed-off-by: lusendong.6789 <lusendong.6789@bytedance.com> Co-authored-by: TRAE CLI <traecli@bytedance.com>
1 parent 0ef43fd commit 0c5652b

4 files changed

Lines changed: 131 additions & 1 deletion

File tree

‎docs/architecture/rfcs/monorepo-distribution-split-v0.md‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3971,3 +3971,27 @@ R1/M3, real-host compaction/thread retention, progressive control, comparable
39713971
complete costs, Standard/workspace delivery and original-Goal regression remain
39723972
open. No default activation, host upgrade, release or frozen-budget change is
39733973
implied by these protocol fixtures.
3974+
3975+
### 2026-11-14 — Coordination loads terminal evidence on its selected route
3976+
3977+
The local-authority runtime defers `ResearchTerminalEvidenceHost` until a valid
3978+
terminal lifecycle request selects it. Ordinary coordination no longer loads
3979+
that adapter and its research implementation dependencies. The existing typed
3980+
terminal owner, registry witness, research qualification, writer locks and
3981+
resource cleanup remain responsible for completion; no competing work schema
3982+
or execution pipeline is introduced.
3983+
3984+
A fresh-process fault injection makes the terminal adapter unavailable. The
3985+
ordinary claim persists and replays its original receipt, malformed claims
3986+
leave state unchanged, and a selected terminal request fails without a new
3987+
receipt or state mutation. The retained base fails this same ordinary-claim
3988+
probe. The source authority/terminal suite passes 93 cases. Applying the same
3989+
patch to the exact C1 candidates in #8266 (`b15c443ee64d`) and #8484
3990+
(`b7e4e01cc423`) passes 188 and 193 authority, context and recovery cases
3991+
respectively; the latter also covers real SQLite admission.
3992+
3993+
This is a loading and failure-isolation prerequisite, aligned with C1's existing
3994+
owners. A valid terminal request still loads the adapter, including when its
3995+
ordinary-Todo guard returns early. Complete workflow isolation, paired complete
3996+
costs, real-host adoption, R1/M3 and C1 writer/consumer cutover remain open.
3997+
These tests do not authorize C1 default promotion or establish model benefit.

‎docs/architecture/rfcs/monorepo-distribution-split-v0.zh-CN.md‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3093,3 +3093,23 @@ PR #8707(`d695b40f633742fb0a5e1cb6b970a56c46dba5e9`,合入提交
30933093
compaction/线程保留、渐进控制、可比完整成本、Standard/workspace 交付和
30943094
原 Goal 回归仍开放。协议 fixture 不表示默认激活、Host 升级、发行或冻结预算
30953095
发生变化。
3096+
3097+
### 2026-11-14 — Coordination 在选定终结路径加载证据适配器
3098+
3099+
local-authority runtime 将 `ResearchTerminalEvidenceHost` 延后到合法的
3100+
terminal lifecycle 请求选中它时加载。普通 coordination 不再加载该适配器
3101+
及其研究实现依赖。完成操作仍由现有 typed terminal owner、registry witness、
3102+
研究资格检查、writer lock 和资源清理负责;没有新增竞争的工作 schema 或
3103+
执行流水线。
3104+
3105+
新进程故障注入使 terminal 适配器不可用:普通 claim 仍落盘并重放原回执,
3106+
非法 claim 保持状态不变,选中的 terminal 请求则明确失败,不产生新回执或
3107+
状态变更。保留的基线在同一普通 claim 探针上失败。源码 authority/terminal
3108+
整组 93 项通过。同一补丁应用到 C1 的精确候选 #8266(`b15c443ee64d`)和
3109+
#8484(`b7e4e01cc423`)后,authority、context 与 recovery 分别有 188 和
3110+
193 项通过;后者还覆盖真实 SQLite admission。
3111+
3112+
这只是对齐 C1 现有 owner 的加载和故障隔离前提。合法 terminal 请求仍会加载
3113+
适配器,包括 ordinary Todo 的 guard 随后提前返回的情况。完整工作流隔离、
3114+
成对完整成本、真实 Host 采用、R1/M3 以及 C1 writer/consumer 切换仍开放。
3115+
这些测试不授权 C1 默认推广,也不证明模型收益。

‎loopx/control_plane/coordination/local_authority_runtime.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import {verifyReentrySettlement} from "./todo_terminal_reentry.ts";
33
import {readPromotionReceipt, commitPromotionAndReadBack} from './promotion_receipt.ts';
44
import {reviewedPromotionPlan, promotionPlanDigest, decodeReviewedPromotionOperation, REVIEWED_PROMOTION_OPERATION_RESULT_SCHEMA} from './reviewed_promotion_plan.ts';
55
import {registryAuthoritySourceCheck} from "./authority_source.ts";
6-
import {ResearchTerminalEvidenceHost} from "../capabilities/explore_research_terminal.ts";
76
import {decodeTaskLeaseProof} from "./task_lease_proof.ts";
87
import type {ClaimWorkspaceObserver} from "./claim_execution.ts";
98
import {LeaseWorktreeObservationError, observeLeaseWorktree} from "../work_items/task_lease_workspace.ts";
@@ -1363,6 +1362,7 @@ export async function terminalLifecycleLocalCoordinationTodo(
13631362
requireAuthorityStoreId(todoId, "linked successor Todo id"));
13641363
const successorIntents = input.successor_intents.map((intent, index) =>
13651364
requireJsonObject(intent, `successor_intents[${index}]`));
1365+
const {ResearchTerminalEvidenceHost} = await import("../capabilities/explore_research_terminal.ts");
13661366
return await withCanonicalWriter(root, goalId, input.dry_run === true, async () => {
13671367
const store = await openRuntimeStore(root, goalId, dependencies);
13681368
sourceAuthority = sourceAuthorityFor(store);

‎tests/control_plane_ts/effect_runtime_handler_loading.test.ts‎

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,92 @@ import assert from "node:assert/strict";
22
import {spawnSync} from "node:child_process";
33
import test from "node:test";
44

5+
test("coordination claims remain available without terminal research evidence", () => {
6+
const entry = new URL("../../loopx/control_plane/effect_runtime_handlers.ts", import.meta.url).href;
7+
const fixtures = new URL("./local_promotion_fixture.ts", import.meta.url).href;
8+
const source = new URL("./shadow_file_fixture.ts", import.meta.url).href;
9+
const storeModule = new URL("../../loopx/control_plane/coordination/file_authority_store.ts", import.meta.url).href;
10+
const script = `
11+
import assert from "node:assert/strict";
12+
import {registerHooks} from "node:module";
13+
import {mkdtemp, rm, writeFile} from "node:fs/promises";
14+
import {createHash} from "node:crypto";
15+
import {tmpdir} from "node:os";
16+
import {join} from "node:path";
17+
let terminalLoads = 0;
18+
registerHooks({load(url, context, nextLoad) {
19+
if (url.endsWith("/capabilities/explore_research_terminal.ts")) {
20+
terminalLoads++;
21+
throw new Error("terminal research evidence unavailable");
22+
}
23+
return nextLoad(url, context);
24+
}});
25+
const {createEffectRuntimeHandlers, dispatchEffectRuntimeMethod} = await import(${JSON.stringify(entry)});
26+
const {engageCanonicalRoute} = await import(${JSON.stringify(fixtures)});
27+
const {projection, todo} = await import(${JSON.stringify(source)});
28+
const {FileAuthorityStore} = await import(${JSON.stringify(storeModule)});
29+
const root = await mkdtemp(join(tmpdir(), "coordination-selected-loading-"));
30+
try {
31+
await engageCanonicalRoute(root);
32+
const store = new FileAuthorityStore(join(root, "authority", "file-v0"), "goal-a");
33+
assert.equal((await store.commitAuthority({expected_provider_revision: null,
34+
operation_id: "seed", events: [], receipts: [],
35+
next_projection: projection([todo()], [], "soft_claim")})).status, "applied");
36+
const handlers = createEffectRuntimeHandlers({fingerprint: "loading-test", requestShutdown() {}});
37+
const request = {schema_version: "loopx_local_coordination_todo_claim_request_v0",
38+
runtime_root: root, goal_id: "goal-a", todo_id: "todo_one", role: "agent",
39+
claimed_by: "agent-a", actor_agent_id: "agent-a", registered_agents: ["agent-a"],
40+
operation_id: "claim", observed_at: "2026-09-05T04:30:00Z", dry_run: false};
41+
const applied = await dispatchEffectRuntimeMethod(handlers,
42+
"coordination.local_authority.todo_claim", request);
43+
assert.equal(applied.status, "applied", JSON.stringify(applied));
44+
const claimed = await store.loadAuthority();
45+
assert.equal(claimed.status, "loaded");
46+
assert.equal(claimed.head.todos[0].claimed_by, "agent-a");
47+
const receipt = await store.readReceipt("claim");
48+
assert.equal(receipt.status, "found");
49+
assert.equal((await dispatchEffectRuntimeMethod(handlers,
50+
"coordination.local_authority.todo_claim", request)).status, "replayed");
51+
assert.deepEqual(await store.loadAuthority(), claimed);
52+
assert.deepEqual(await store.readReceipt("claim"), receipt);
53+
const invalid = await dispatchEffectRuntimeMethod(handlers,
54+
"coordination.local_authority.todo_claim", {...request, operation_id: "invalid", dry_run: "true"});
55+
assert.equal(invalid.reason_code, "invalid_local_coordination_todo_claim_request");
56+
assert.deepEqual(await store.readReceipt("invalid"), {status: "missing"});
57+
assert.deepEqual(await store.loadAuthority(), claimed);
58+
assert.equal(terminalLoads, 0);
59+
const registry = join(root, "registry.json");
60+
await writeFile(registry, "{}");
61+
const terminalRequest = {
62+
schema_version: "loopx_local_coordination_todo_terminal_lifecycle_request_v3",
63+
registry_source: {path: registry, sha256: createHash("sha256").update("{}").digest("hex")},
64+
runtime_root: root, goal_id: "goal-a", todo_id: "todo_one", role: "agent",
65+
command: "complete", actor_agent_id: "agent-a", registered_agents: ["agent-a"],
66+
lifecycle_grants: [], authority_reason: null, decision_outcome: null,
67+
operation_identity: {kind: "explicit", operation_id: "terminal"},
68+
lease_idempotency_key: null, lease_expected_version: null, allow_user_gate_auto_acquire: false,
69+
requested_no_followup: true, requested_completion_turn_key: null,
70+
requested_completion_identity_source: null, linked_successor_todo_ids: [], successor_intents: [],
71+
note: null, evidence: null, reason: null, clear_claim: false,
72+
validation_declaration: null, validation_receipt: null, completion_policy_request: null,
73+
observed_at: "2026-09-05T04:30:00Z", dry_run: false,
74+
};
75+
for (let attempt = 0; attempt < 2; attempt++) {
76+
const failed = await dispatchEffectRuntimeMethod(handlers,
77+
"coordination.local_authority.todo_terminal", terminalRequest);
78+
assert.equal(failed.status, "failed");
79+
assert.match(failed.reason, /terminal research evidence unavailable/);
80+
assert.deepEqual(await store.readReceipt("terminal"), {status: "missing"});
81+
assert.deepEqual(await store.loadAuthority(), claimed);
82+
}
83+
assert.equal((await dispatchEffectRuntimeMethod(handlers, "runtime.ping", {})).ready, true);
84+
} finally {await rm(root, {recursive: true, force: true});}
85+
`;
86+
const child = spawnSync(process.execPath, ["--no-warnings", "--experimental-strip-types",
87+
"--input-type=module", "-e", script], {encoding: "utf8", timeout: 30_000});
88+
assert.equal(child.status, 0, child.stderr);
89+
});
90+
591
test("runtime loads selected owners without importing unrelated methods", () => {
692
const entry = new URL("../../loopx/control_plane/effect_runtime_handlers.ts", import.meta.url).href;
793
// Observe a fresh process, not this test runner's already imported modules.

0 commit comments

Comments
 (0)