Skip to content
Open
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
10 changes: 10 additions & 0 deletions apps/presentation/dashboard/src/data/chat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -659,10 +659,20 @@ export async function readTodoRequest(goalId: string, todoId: string, signal: Ab
ok: z.literal(true), goal_id: z.string(), todo_id: z.string(), text: z.string(),
status: z.string(), archive_state: z.string(), updated_at: z.string().nullable(),
evidence: z.string().nullable().optional(), note: z.string().nullable().optional(),
stride_meta_goal: z.union([z.object({unavailable: z.literal(true)}), z.object({
decision_ref: z.string(), agent_id: z.string(), action: z.string(),
meta_goal: z.object({todo_id: z.string(), objective: z.string(), resolution_criterion: z.string(),
resolution: z.string().optional(), previous_decision_ref: z.string().optional()}),
next_probe: z.object({scope: z.string(), prediction: z.string(), adoption_criterion: z.string(),
cost_bound: z.string(), minimum_evidence: z.string()}),
evidence: z.array(z.object({evidence_ref: z.string(), summary: z.string().nullish()})),
})]).optional(),
review_basis: todoUpdateSourceBasisSchema.optional(),
source_access: z.object({namespace: z.string()}).optional(),
}).parse(await requestJson<unknown>(url, {signal}));
if (result.goal_id !== goalId || result.todo_id !== todoId) throw new Error("Task source changed");
if (result.stride_meta_goal && "meta_goal" in result.stride_meta_goal &&
result.stride_meta_goal.meta_goal.todo_id !== todoId) throw new Error("Meta-goal source changed");
if (expectedNamespace && result.source_access?.namespace !== expectedNamespace) throw new Error("Task source changed");
return result;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -548,6 +548,14 @@ const en = {
"drawer.requestLocalOnly": "This source provides a summary. Open its local workspace to read the full request.",
"drawer.requestUnidentified": "Showing the received text. This legacy Task has no authority id for a full request read.",
"drawer.requestRetry": "Retry full request",
"drawer.metaGoal": "Meta-goal",
"drawer.metaGoalCriterion": "Evidence needed to decide",
"drawer.metaGoalResolution": "Conclusion",
"drawer.metaGoalAction": "Decision action",
"drawer.metaGoalProbe": "Next probe",
"drawer.metaGoalEvidence": "Evidence for this decision",
"drawer.metaGoalEvidenceUnavailable": "Source evidence unavailable",
"drawer.metaGoalUnavailable": "The meta-goal could not be read.",
"drawer.taskManage": "Manage task",
"drawer.taskCompletionProof": "Original execution proof (optional)",
"drawer.taskCompletionProofHint": "For a task requiring an execution lease, paste the responsible Agent's original JSON with agent_id, task_lease_idempotency_key and task_lease_expected_version. This does not acquire a lease or change ownership. Review and confirm completion normally.",
Expand Down Expand Up @@ -2175,6 +2183,14 @@ const zhCN: Record<WorkspaceMessageKey, string> = {
"drawer.requestLocalOnly": "此来源提供摘要,请在它的本机工作区读取完整要求。",
"drawer.requestUnidentified": "显示已收到的正文。此旧版任务缺少原始 ID,无法另行读取完整要求。",
"drawer.requestRetry": "重试读取完整要求",
"drawer.metaGoal": "元目标",
"drawer.metaGoalCriterion": "作出选择所需的证据",
"drawer.metaGoalResolution": "结论",
"drawer.metaGoalAction": "元决策动作",
"drawer.metaGoalProbe": "下一探针",
"drawer.metaGoalEvidence": "本次决策的依据",
"drawer.metaGoalEvidenceUnavailable": "原始证据暂不可读",
"drawer.metaGoalUnavailable": "暂时无法读取元目标。",
"drawer.taskManage": "管理任务",
"drawer.taskCompletionProof": "原执行证明(可选)",
"drawer.taskCompletionProofHint": "需要执行租约的任务,可粘贴负责 Agent 提供的原 JSON:agent_id、task_lease_idempotency_key、task_lease_expected_version。这不会领取租约或改变归属;仍需检查并确认完成。",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ export function TaskRequest({todo, local, sourceNamespace, onSave, onRead}: {tod
}, [identity, local, retry, todo.goalId, sourceId, sourceNamespace, publishRead]);
const current = local && read?.identity === identity ? read : null;
const detail = current?.phase === "ready" ? current.detail : null;
const stride = detail?.stride_meta_goal;
const editable = local && onSave && todo.claimedBy && sourceId && detail?.review_basis
&& detail.archive_state === "active" && detail.status !== "done";
const draftLength = compactPythonTextLength(draft?.text ?? "");
Expand Down Expand Up @@ -87,6 +88,23 @@ export function TaskRequest({todo, local, sourceNamespace, onSave, onRead}: {tod
}
return <div className="personal-task-request">
{!draft ? <MarkdownText text={detail?.text ?? todo.requestText ?? todo.text} /> : null}
{stride && "meta_goal" in stride ? <details className="personal-task-meta-goal">
<summary>{t("drawer.metaGoal")}</summary>
<MarkdownText text={stride.meta_goal.objective}/>
<dl>
<dt>{t("drawer.metaGoalCriterion")}</dt><dd><MarkdownText text={stride.meta_goal.resolution_criterion}/></dd>
{stride.meta_goal.resolution ? <><dt>{t("drawer.metaGoalResolution")}</dt>
<dd><MarkdownText text={stride.meta_goal.resolution}/></dd></> : null}
<dt>{t("drawer.metaGoalAction")}</dt><dd><code>{stride.action}</code></dd>
<dt>{t("drawer.metaGoalProbe")}</dt><dd><MarkdownText text={stride.next_probe.scope}/></dd>
</dl>
{stride.evidence.length ? <><h4>{t("drawer.metaGoalEvidence")}</h4><ul>{stride.evidence.map(row =>
<li key={row.evidence_ref}><MarkdownText text={row.summary ?? t("drawer.metaGoalEvidenceUnavailable")}/>
<code>{row.evidence_ref}</code></li>)}</ul></> : null}
</details> : stride?.unavailable ? <div className="personal-proposal-explainer" role="alert">
<span>{t("drawer.metaGoalUnavailable")}</span>
<button className="personal-secondary-action" type="button" onClick={() => setRetry(value => value + 1)}>{t("drawer.requestRetry")}</button>
</div> : null}
{current?.phase !== "ready" ? <div className="personal-proposal-explainer" role={current?.phase === "error" ? "alert" : "status"}>
<span>{t(!local ? "drawer.requestLocalOnly" : !sourceId ? "drawer.requestUnidentified" : current?.phase === "error" ? "drawer.requestError" : "drawer.requestLoading")}</span>
{current?.phase === "error" ? <button className="personal-secondary-action" type="button" onClick={() => setRetry(value => value + 1)}>{t("drawer.requestRetry")}</button> : null}
Expand Down
42 changes: 42 additions & 0 deletions docs/reference/protocols/goal-vision-replan-contract-v0.md
Original file line number Diff line number Diff line change
Expand Up @@ -804,6 +804,48 @@ not improved model decisions or net efficiency.
任务缺失、关闭、改由他人认领或关联改变时旧页失效。未携带任务 ID 的全局页面保持
原契约;任务范围只改变证据相关性,不授予准入或强制选题。

### Todo meta-goal / Todo 内的元目标

An admitted Stride review can attach `agent_vision.stride_decision.meta_goal`
to one open Agent Todo it retains in `todo_delta`. If the Turn is bound to a
Todo, use that Todo's exact ID. The optional object contains `todo_id`,
`objective`, `resolution_criterion`, and `evidence_refs`. Start a question
with empty references. The enclosing Stride `action` and `next_probe` express
the chosen response and the first work slice.

An open meta-goal follows the Todo across ordinary Turns in
`work_context.stride_meta_goal`. In the next applicable Stride review, carry
the same objective and criterion with `previous_decision_ref` from
`todo_meta_goals`. Cite the exact references to subsequent work on that Todo
when changing the action or recording a `resolution`. The journal's append
order and the settled work identity qualify the references, including evidence
against a route. Omission preserves the last recorded question. A resolution
ends the question, and a later review can start another one on the same Todo.
All authored text and refs share the existing Vision budget.

Read the latest question, action, probe and cited evidence in the App's Task
Request details or with `loopx --format json todo list --goal-id <goal> --todo-id
<todo>`. The exact CLI read also provides recent eligible source refs under
`subsequent_evidence` for an open question. Use `loopx --format json history --goal-id <goal> --agent-id <agent>
--evidence-ref <ref>` to resolve the exact decision and each cited source row.
The references document which evidence the Agent cites for its choice.
Execution, Goal acceptance and gain follow their existing evidence contracts.

在已准入的 Stride 复盘中,Agent 可用 `agent_vision.stride_decision.meta_goal`
为 `todo_delta` 中保留的一项开放 Todo 声明元目标。如果 Turn 已绑定 Todo,使用该 Todo 的
精确 ID。首次写入 `todo_id`、`objective`、`resolution_criterion` 和空的 `evidence_refs`。
外层的 `action` 和 `next_probe` 表达所选元决策动作及首个工作切片。

普通工作 Turn 通过 `work_context.stride_meta_goal` 接续未决目标。复盘时从
`todo_meta_goals` 取得 `previous_decision_ref`,沿用原目标和证据条件。改变动作或写入
`resolution` 时,引用该 Todo 后续工作的精确证据。系统核对日志追加顺序和已结算工作身份,
并保留反证。省略字段则沿用上次记录。元目标收口后,可在后续复盘中为同一 Todo 提出新问题。
字段与引用计入已有 Vision 预算。

在 App 的任务要求详情或用 `todo list --todo-id` 回读元目标、动作、探针及证据,
用 `history --evidence-ref` 回读原决策和原证据。引用记录的是 Agent 作出选择所用的证据,
实际执行、Goal 验收和收益沿用各自的证据契约。

### Source-bound comparison selection

With Explore planning and `evidence_conditioned_v1` enabled, the existing
Expand Down
1 change: 1 addition & 0 deletions loopx/capabilities/native_chat/steward_turn.py
Original file line number Diff line number Diff line change
Expand Up @@ -1291,6 +1291,7 @@ def _read_stage(cmd_str: Any) -> dict[str, Any] | None:
"triggers": review_view.get("triggers"),
"recent_evidence": list(review_view.get("evidence") or [])[:12],
"decision_followthrough": review_view.get("decision_followthrough"),
**({"todo_meta_goals": review_view["todo_meta_goals"]} if "todo_meta_goals" in review_view else {}),
}
writeback_view = _read_stage(packet.get("writeback"))
if writeback_view is not None:
Expand Down
1 change: 1 addition & 0 deletions loopx/chat/todo_detail.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ def _todo_detail(self) -> None:
"text": item["text"], "status": item["status"],
"archive_state": item.get("archive_state", "active"),
"updated_at": item.get("updated_at"),
**({"stride_meta_goal": item["stride_meta_goal"]} if "stride_meta_goal" in item else {}),
**({"review_basis": basis} if basis is not None else {}),
})
except ValueError:
Expand Down
5 changes: 4 additions & 1 deletion loopx/control_plane/goals/vision_checkpoint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
type DeliveryOutcome,
} from "../work_items/delivery_outcome.ts";

import {normalizeStrideDecision, STRIDE_DECISION_SCHEMA, RECORDED_STRIDE_SCHEMA, STRIDE_PROBE_LIMITS, STRIDE_AXIS_NAMES, STRIDE_PLAN_LIMIT, STRIDE_REASON_LIMIT, STRIDE_REVIEW_LIMIT} from "../work_items/stride_policy.ts";
import {normalizeStrideDecision, STRIDE_DECISION_SCHEMA, RECORDED_STRIDE_SCHEMA, STRIDE_PROBE_LIMITS, STRIDE_META_GOAL_LIMITS, STRIDE_AXIS_NAMES, STRIDE_PLAN_LIMIT, STRIDE_REASON_LIMIT, STRIDE_REVIEW_LIMIT} from "../work_items/stride_policy.ts";
import lifecycle from "../goal_vision_lifecycle.json" with {type: "json"};

export const VISION_REFRESH_REQUEST_SCHEMA = "loopx_vision_refresh_request_v0";
Expand Down Expand Up @@ -836,6 +836,9 @@ function prepareVisionRefresh(request: VisionRefreshPrepareRequest): JsonObject
fieldLimits[`stride_decision.axes.${axis}.reason`] = STRIDE_REASON_LIMIT;
}
if (strideDecision.previous_review) fieldLimits["stride_decision.previous_review.lesson"] = STRIDE_REVIEW_LIMIT;
if (strideDecision.meta_goal) for (const [field, limit] of Object.entries(STRIDE_META_GOAL_LIMITS)) {
if (Object.hasOwn(strideDecision.meta_goal as JsonObject, field)) fieldLimits[`stride_decision.meta_goal.${field}`] = limit;
}
if (strideDecision.explore_review) fieldLimits["stride_decision.explore_review.reason"] = STRIDE_REVIEW_LIMIT;
}
fieldLimits["fallback_declarations"] = VISION_FALLBACK_DECLARATION_ENTRY_LIMIT;
Expand Down
4 changes: 3 additions & 1 deletion loopx/control_plane/quota/live_decision.py
Original file line number Diff line number Diff line change
Expand Up @@ -1148,11 +1148,13 @@ def observe_app_scheduler_state(readback: Mapping[str, Any]) -> None:
registry_path=registry_path,
runtime_root=runtime_root,
)
from ..work_items.context_readback import attach_work_context
from ..work_items.context_readback import attach_work_context, attach_stride_meta_goal_context

attach_work_context(payload, registry_path=registry_path, runtime_root=runtime_root,
hook_dispatch=turn_start_hook_dispatch, context_navigation=context_navigation,
inline_goal_source=inline_goal_source)
attach_stride_meta_goal_context(payload, status_payload=decision_status_payload,
registry_goal=registered_goal, runtime_root=runtime_root)
return payload


Expand Down
3 changes: 3 additions & 0 deletions loopx/control_plane/quota/progressive_context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1046,6 +1046,9 @@ function initialContextReadGroups(context: JsonObject, decisionFields: readonly
if (!attentionSources.length) include(...requiredReadsPath);
const work = ["interaction_contract", "agent_channel", "work_context"];
include(...work, "instruction");
if (normalWork && object(channel?.work_context)?.stride_meta_goal) {
include(...work, "stride_meta_goal");
}
if (deferredReentry) {
// Surface the owner's reopen and same-Turn guard before the long read.
for (const field of admissionFields) include("interaction_contract", "cli_channel", field);
Expand Down
1 change: 1 addition & 0 deletions loopx/control_plane/quota/turn_envelope.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1027,6 +1027,7 @@ function projectReplanView(request: JsonObject, payload: JsonObject, sourceHash:
...(acceptanceIndex ? {acceptance_index: acceptanceIndex} : {}),
triggers: obligation.triggers,
decision_followthrough: Object.keys(follow).length ? follow : null,
...(Array.isArray(context.todo_meta_goals) ? {todo_meta_goals: context.todo_meta_goals} : {}),
planning_horizon: payload.planning_horizon == null ? null : horizon,
action_portfolio: payload.action_portfolio ?? null,
...(context.explore_basis ? {capabilities: {explore: retain({
Expand Down
5 changes: 5 additions & 0 deletions loopx/control_plane/runtime/run_context_retention.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ def goal_semantic_history_from_runs(
"""

from ..work_items.recommendation_source_io import recommendation_run_decision
from ..work_items.replan_context_codec import recorded_stride_meta_goal

contexts: dict[str, dict[str, Any]] = {}
resolved_agent_vision: set[str] = set()
Expand Down Expand Up @@ -164,6 +165,8 @@ def goal_semantic_history_from_runs(
if index in qualification.active_turn_retries:
active_blocked_retry_runs.append(run)
context = contexts.setdefault(agent_id, {"agent_id": agent_id})
if "has_stride_meta_goal" not in context and recorded_stride_meta_goal(run) is not None:
context["has_stride_meta_goal"] = True

if ("latest_lane_step_run" not in context and run.get("agent_id") == agent_id
and recommendation_run_decision(run) is not None):
Expand Down Expand Up @@ -275,6 +278,8 @@ def compact_goal_semantic_history(
if not agent_id:
continue
context: dict[str, Any] = {"agent_id": agent_id}
if raw_context.get("has_stride_meta_goal") is True:
context["has_stride_meta_goal"] = True
retired_at = str(raw_context.get("vision_retired_at") or "").strip()
if retired_at:
context["vision_retired_at"] = retired_at
Expand Down
1 change: 1 addition & 0 deletions loopx/control_plane/stride_decision_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"actions": ["grow", "switch", "verify"],
"axis_plan_limit": 120,
"probe_field_limits": {"scope": 120, "prediction": 120, "adoption_criterion": 120, "cost_bound": 100, "minimum_evidence": 120},
"meta_goal_field_limits": {"objective": 144, "resolution_criterion": 144, "resolution": 120},
"axis_reason_limit": 96,
"review_text_limit": 120,
"review_reference_limit": 3,
Expand Down
15 changes: 15 additions & 0 deletions loopx/control_plane/todos/list_readback.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,4 +118,19 @@ def list_goal_todos(
from .goal_todo_projection import observe_todo_acceptance
payload = observe_todo_acceptance(payload, result["canonical_acceptance"],
registry_path=source_registry, goal_id=goal_id)
item = payload.get("todo")
if normalized_todo_id and isinstance(item, dict) and item.get("role") == "agent":
from ..work_items.replan_context_codec import read_todo_stride_meta_goal

instance = goal.get("goal_instance_id")
try:
meta_goal = read_todo_stride_meta_goal(

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P2] 未使用元目标的 Todo 也会扫描历史并显示元目标故障。在明确设置 Stride off、从未保存元目标的真实 Todo 上,旧版精确读取只返回正常详情。当前头和主干整合预演都为每次详情读取解析整份日志。在 File 和 SQLite 上,一条无关的残缺 UTF-8 日志尾随 40,000 条普通记录时,两者都返回 stride_meta_goal.unavailable=true。原 Todo 和日志内容保持原样,CLI 与 Task Request 的额外告警来自新加的读路径。 把已存在元目标的事实交给有作用域的读回所有者。没有元目标的 Todo 保持原详情,即使无关历史不可读。已保存的历史在显式关闭后仍应可查,按 Todo 与 GoalRef 查找其来源。

runtime_root=runtime_root, goal_id=goal_id, todo_id=normalized_todo_id,
agent_id=normalized_agent_id, include_evidence=True,
goal_ref={"goal_id": goal_id, "goal_instance_id": instance} if instance else None,
)
except (ValueError, OSError, RuntimeError):
meta_goal = {"unavailable": True}
if meta_goal is not None:
payload["todo"] = {**item, "stride_meta_goal": meta_goal}
return payload
36 changes: 36 additions & 0 deletions loopx/control_plane/work_items/context_readback.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,42 @@ def _user_context(
"todos": inventory["todos"]}


def attach_stride_meta_goal_context(
payload: dict[str, Any], *, status_payload: dict[str, Any],
registry_goal: dict[str, Any] | None, runtime_root: Path,
) -> None:
if registry_goal is None or not payload.get("should_run") or not payload.get("normal_delivery_allowed"):
return
selected = payload.get("selected_todo")
agent = (payload.get("agent_identity") or {}).get("agent_id")
goal_id = payload.get("goal_id")
channel = (payload.get("interaction_contract") or {}).get("agent_channel") or {}
context = channel.get("work_context")
if not agent or not goal_id or not isinstance(context, dict) or not isinstance(selected, dict):
return
todo_id = selected.get("todo_id")
if not isinstance(todo_id, str) or not any(
lane.get("agent_id") == agent and lane.get("has_stride_meta_goal") is True
for goal in (status_payload.get("run_history") or {}).get("goals", []) if goal.get("id") == goal_id
for lane in (goal.get("semantic_history") or {}).get("agents", [])
):
return
from ...capabilities.todo_replan_cadence.machine_defaults import resolve_todo_replan_cadence_goal

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P2] 准确头 quick premerge 的可维护性检查出现两条新增失败。普通工作上下文从控制面反向导入能力配置,qualify_replan_writeback 又超出决策函数预算。旧分叉基线及主干对照均为零未审项。 在现有配额或能力组装层解析策略,向工作上下文传入明确值。把元目标写回校验交给现有领域校验边界,再复跑标准 premerge。

from .replan_context_codec import read_todo_stride_meta_goal

profile = resolve_todo_replan_cadence_goal(registry_goal, runtime_root).get("execution_profile") or {}
if profile.get("stride_strategy", "off") == "off":
return
try:
record = read_todo_stride_meta_goal(runtime_root=runtime_root, goal_id=goal_id,
todo_id=todo_id, agent_id=agent, goal_ref=payload.get("goal_ref"))
except (ValueError, OSError, RuntimeError):
context["stride_meta_goal"] = {"unavailable": True}
return
if record is not None and not record["meta_goal"].get("resolution"):
context["stride_meta_goal"] = record


def attach_work_context(payload: dict[str, Any], *, registry_path: Path,
runtime_root: Path, hook_dispatch: dict[str, Any] | None,
context_navigation: bool = False,
Expand Down
Loading
Loading