Archived
Mastra 化前置:loop 三修 —— 提交放行发真验收卡、事件只记不跑、轨迹喂回叙事面
勘察(两路 code-explorer)坐实 loop 范式三处真缺口,本轮先修(用户拍板), 与 Mastra 化解耦、按外科手术做(活动内 MVP 期高内聚不过度抽象): ① 提交放行走不到 released:submit/判齐只返回 submitted,task 层当 running 处理,任务原地重跑到预算耗尽(exhausted 而非 released)。 修:提交 = 发**验收卡**挂起等裁决(raiseAcceptance 唯一出口:发卡、立监听、 在途验收入状态信封 sys.loop_state.pending,迁移 0015);判齐重入不发第二张卡; 裁决 pass → finished released(选口随放行带回),reject → finished 不放行。 TurnOutcome 增 finished/released/selectedPorts,engines 接线透传。 ② onEvent 双拍:自跑一整拍后 deliver 的 tick 再跑一拍 —— 每次人卡回传多耗 一次不计 steps/activeMs 预算的模型决策。修:onEvent **只记不跑** (登记 occur / 收验收裁决入信封,存快照即返),推进统一归 tick,预算一个口径。 ③ Agent 每拍失忆:memory.window 定义了但零调用,任务自身轨迹从不喂回 prompt。 修:叙事面新增【本任务最近轨迹】段,窗口大小取活动声明的 manifest.declarations.harness.memoryWindow(活动侧唯一记忆配置,不再硬编码)。 测试:turn-runner-acceptance 八例;全量绿,五闸退出码过;loop CONTRACT.md 同步。 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KeDBx2PHLavbURXB8LJJ7m
This commit is contained in:
+10
-2
@@ -76,8 +76,11 @@ export type TurnOutcome = {
|
||||
readonly enabled: EnabledSet;
|
||||
readonly navigation: Navigation;
|
||||
readonly action?: AgentAction;
|
||||
readonly status: 'running' | 'awaiting' | 'submitted' | 'blocked';
|
||||
readonly status: 'running' | 'awaiting' | 'submitted' | 'finished' | 'blocked';
|
||||
readonly blockedReason?: string;
|
||||
/** 终局唯放行:finished 时带裁决 —— released=true 才算走完,选口随放行确认 */
|
||||
readonly released?: boolean;
|
||||
readonly selectedPorts?: Record<string, string>;
|
||||
};
|
||||
export type LoopEngineService = {
|
||||
/** 装载:XML 进语义引擎,说明书进 Agent 上下文;版本全部入信封 */
|
||||
@@ -88,11 +91,16 @@ export type LoopEngineService = {
|
||||
/** 跑一个回合:定位 → 择向 → 决断 → 行动 → 写数据 */
|
||||
runTurn(taskId: TaskId): Promise<TurnOutcome>;
|
||||
/** 事件驱动续跑:数据 / 时间 / 人 / 控制 */
|
||||
/**
|
||||
* 事件到达:**只记不跑**(登记 occur / 收验收裁决,存快照即返)。
|
||||
* 从前这里自跑一整拍、deliver 随后的 tick 又跑一拍 —— 每次人卡回传
|
||||
* 多耗一次不计 steps/activeMs 预算的模型决策。推进统一归 tick。
|
||||
*/
|
||||
onEvent(taskId: TaskId, event: {
|
||||
kind: 'data' | 'time' | 'human' | 'control';
|
||||
ref: string;
|
||||
payload: Record<string, unknown>;
|
||||
}): Promise<TurnOutcome>;
|
||||
}): Promise<void>;
|
||||
/** DMN 确定性求值 —— 能算的不问 LLM */
|
||||
decide(taskId: TaskId, decision: string): Promise<DecisionResult>;
|
||||
/** 驳回:相关计划项以新实例重新入场(迁移不是状态) */
|
||||
|
||||
+16
-1
@@ -10,11 +10,12 @@ export type Clock = {
|
||||
};
|
||||
/** 运行时实例状态 —— loop 的模型定位与就绪集(OS 09 三份持久状态之一) */
|
||||
export type LoopStateStore = {
|
||||
save(taskId: TaskId, model: LoopModel, parsed: CaseModel, runtime: CaseRuntime): Promise<void>;
|
||||
save(taskId: TaskId, model: LoopModel, parsed: CaseModel, runtime: CaseRuntime, pending?: PendingAcceptance | null): Promise<void>;
|
||||
load(taskId: TaskId): Promise<{
|
||||
model: LoopModel;
|
||||
parsed: CaseModel;
|
||||
runtime: CaseRuntime;
|
||||
pending?: PendingAcceptance;
|
||||
} | undefined>;
|
||||
};
|
||||
/** S-FEEL —— app 注入 `@sfeel`;引擎零 LLM */
|
||||
@@ -69,6 +70,15 @@ export type ToolGateway = {
|
||||
label: string;
|
||||
}): Promise<void>;
|
||||
};
|
||||
/**
|
||||
* 在途验收(提交放行的持久痕):卡发出即记,裁决到达再记 verdict ——
|
||||
* 判齐重入不再发第二张卡;恢复的那一拍据 verdict 定终局(released 与否)。
|
||||
*/
|
||||
export type PendingAcceptance = {
|
||||
readonly acceptanceCardId: string;
|
||||
readonly verdict?: 'pass' | 'reject';
|
||||
readonly selectedPorts?: Record<string, string>;
|
||||
};
|
||||
export type CardGateway = {
|
||||
issue(input: {
|
||||
taskId: TaskId;
|
||||
@@ -133,6 +143,11 @@ export type MemoryRecorder = {
|
||||
layer: string;
|
||||
statement: string;
|
||||
}>>;
|
||||
/** 本任务自己的最近轨迹(窗口大小由活动声明的 memoryWindow 定)—— 喂回叙事面,Agent 每拍不失忆 */
|
||||
window(taskId: TaskId): Promise<Array<{
|
||||
kind: string;
|
||||
title: string;
|
||||
}>>;
|
||||
};
|
||||
export type TaskContext = {
|
||||
of(taskId: TaskId): Promise<{
|
||||
|
||||
Reference in New Issue
Block a user