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
23 changes: 23 additions & 0 deletions docs/architecture/rfcs/monorepo-distribution-split-v0.md
Original file line number Diff line number Diff line change
Expand Up @@ -4234,3 +4234,26 @@ File/SQLite negative cases guard this boundary without changing valid activation
progressive controls, comparable complete costs, full V1–V5/V10, R1/M3 and
C1 cutover remain unqualified. Preserve original requirements and earlier
negative evidence; run full original-goal regression before completion.

### 2026-11-15 — Native Tasks consume existing owner Goal checks

- **Gap:** a managed Native Task refused to execute with owner-configured Goal
acceptance alone, requiring a duplicate Task argv declaration.
- **Delta:** the existing canonical Task validation plan now serves Native and
Delegation. Native reads current Goal scope and private Task declarations from
their existing owners, runs cumulative Goal and required Task checks, and
rechecks definition, work, claim, lifecycle and checker assets before and after
validation. Required declarations, applicable unbound/stale checks and changed
sources cannot fall back to a weaker check. Task argv keeps typed-result stdin
and the existing Turn receipt; legacy non-argv declarations retain refusal.
- **Evidence:** the Goal-only refusal is reproduced on the prior Native consumer.
Shared TypeScript behavior matches the immutable baseline in 54 compatibility
vectors. Real isolated Chat/Core/canonical tests cover Goal-only and combined
execution, HTTP readback/replay, independent failures, corrupt declarations,
source changes before and after checks, and unrelated progress observations.
- **Boundary:** this removes duplicate validation setup for already configured
Goal checks on V2/V4/R1. It does not install a trusted checker for a new natural
language Goal, authorize model/browser commands, or complete automatic first
Task adoption. Full V1–V5/V10, native-model/context retention, D2/D5 closure,
progressive controls, comparable complete costs, R1/M3 and C1 cutover remain
unqualified; preserve original acceptance and full-goal regression gates.
18 changes: 18 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 @@ -3288,3 +3288,21 @@ R1/M3、C1 切换和原目标回归仍未完成资格验证。
原 Task、选定 D2/D5 闭包、原生 App/模型与 compaction 保留、渐进控制、
可比完整成本、完整 V1–V5/V10、R1/M3 和 C1 切换仍未通过资格验证。原要求
与此前负面证据保留;完成目标前仍需完整原目标回归。

### 2026-11-15 — Native Task 消费既有 owner Goal 检查

- **缺口:**managed Native Task 即使有 owner 配置的 Goal 验收,也会拒绝执行,
要求重复声明 Task argv 校验器。
- **增量:**既有 canonical Task 验证计划由 Native 和 Delegation 共用。Native
从既有 owner 读取当前 Goal 范围和私有 Task 声明,累加执行 Goal 与必需 Task
检查;验证前后复核定义、工作、认领、生命周期和检查器资产。必需声明缺失、
适用但未绑定或过期的检查,以及来源变化,都不能降级为更弱的检查。Task argv
保留 typed-result stdin 和既有 Turn receipt;旧非 argv 声明继续拒绝。
- **证据:**原 Native 消费路径已复现 Goal-only 拒绝;共享 TypeScript 在 54 组
兼容向量上与不可变基线一致。真实隔离 Chat/Core/canonical 测试覆盖 Goal-only
与组合执行、HTTP 读回与重放、独立检查失败、声明损坏、检查前后来源变更和
无关进展观察。
- **边界:**本次消除 V2/V4/R1 中既有 Goal 检查的重复配置,不为新的自然语言
Goal 安装可信检查器,不授权模型或 browser 命令,也不完成首个 Task 自动采用。
完整 V1–V5/V10、原生模型与 context 保留、D2/D5 闭包、渐进控制、可比完整成本、
R1/M3 和 C1 切换仍未通过资格验证;原验收与完整目标回归门继续保留。
92 changes: 70 additions & 22 deletions loopx/capabilities/native_chat/steward_managed_mode.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ def health(self, binding_id: str) -> dict[str, Any]:


class ManagedTaskValidationUnavailable(ValueError):
"""A native selection has no usable caller-declared independent validator."""
"""A native selection has no usable owner-declared independent validator."""


def managed_session_identity(controller: Any, *, goal_id: str, agent_id: str, workspace: Path,
Expand Down Expand Up @@ -434,19 +434,40 @@ def submit(self, session_id: str, *, agent_id: str, operation_id: str,
return accepted.turn, accepted.created

def _validation_source(self, request: dict[str, Any], todo_id: str) -> dict[str, Any]:
from ...control_plane.todos.list_readback import list_goal_todos
readback = list_goal_todos(registry_path=self.controller.registry_path, goal_id=request["actor"]["goal_id"],
todo_id=todo_id, role="agent", runtime_root_arg=str(self.controller.coordination_runtime_root))
rows = [readback["todo"]] if readback.get("todo") else []
if len(rows) != 1 or rows[0].get("completion_validation_required") is not True:
from ...control_plane.effect_runtime import effect_runtime_result
from ...control_plane.goals.acceptance import inspect_goal_acceptance, validation_effect_files_current
from ...control_plane.todos.completion_validation import resolve_private_completion_validation_declaration
from ...materials import goal_state_path
actor = request["actor"]
workspace = Path(actor["workspace_path"])
basis = inspect_goal_acceptance(registry_path=self.controller.registry_path,
runtime_root=str(self.controller.coordination_runtime_root), goal_id=actor["goal_id"],
agent_id=actor["agent_id"], todo_id=todo_id, validation_workspace_path=workspace)
todo = basis.get("todo")
goal = load_goal_from_registry(self.controller.registry_path, actor["goal_id"])
if not isinstance(todo, dict) or goal is None:
raise ManagedTaskValidationUnavailable("the selected task's canonical validation source is unavailable")
declaration = resolve_private_completion_validation_declaration(canonical_todo=todo,
state_file=goal_state_path(goal), runtime_root=self.controller.coordination_runtime_root,
registry_path=self.controller.registry_path, goal_id=actor["goal_id"], todo_id=todo_id,
role=todo.get("role"), persist_if_resolved=False)
# Only the existing owner can resolve acceptance to explicit null.
# Applicable unbound/stale checks and failed reads must never fall back.
plan = effect_runtime_result("goal.task.validation_plan", {
"todo_id": todo_id, "basis": basis, "declaration": declaration})
if plan["state"] != "ready":
raise ManagedTaskValidationUnavailable("the selected task needs its existing independent argv validation declaration")
return rows[0]
if not validation_effect_files_current(effects=plan["effects"],
registry_path=self.controller.registry_path, goal_id=actor["goal_id"],
validation_workspace_path=workspace):
raise ManagedTaskValidationUnavailable("the selected task's declared verifier files changed or are unavailable")
return {**todo, "plan": plan}

def prepare_validation(self, request: dict[str, Any], native_request: dict[str, Any], *,
_checked_work_identity: dict[str, str] | None = None) -> None:
from ...control_plane.turn_driver.driver import selected_turn_todo, turn_host_lineage
from ...control_plane.turn_driver.command_validation import build_loopx_turn_command_validator
from ...control_plane.todos.completion_validation_store import read_completion_validation_declaration
from ...control_plane.goals.acceptance import run_goal_acceptance_validation_effect
# Dispatch can reuse its just-checked identity within this invocation;
# direct callers still check the complete source through the same owner.
if "work_contract" in native_request:
Expand All @@ -460,20 +481,47 @@ def prepare_validation(self, request: dict[str, Any], native_request: dict[str,
self.validation_basis = self._validation_source(request, selected["todo_id"])
if re.fullmatch(r"cadence_[a-f0-9]{64}", self.validation_basis.get("target_key") or "") and request.get("work_kind") != "scheduled_task":
raise ValueError("the original calendar Task must execute through its scheduled Session admission")
declaration = read_completion_validation_declaration(runtime_root=self.controller.coordination_runtime_root,
goal_id=request["actor"]["goal_id"], todo_id=selected["todo_id"],
expected_digest=self.validation_basis["completion_validation_sha256"])
if not declaration or not declaration.get("validation_command_argv"):
raise ManagedTaskValidationUnavailable("the selected task requires its existing argv validation declaration")
self.task_validator = build_loopx_turn_command_validator(declaration["validation_command_argv"],
project=Path(request["actor"]["workspace_path"]), timeout_seconds=declaration.get("validation_timeout_seconds") or 20)
actor = request["actor"]
workspace = Path(actor["workspace_path"])
validators = []
for effect in self.validation_basis["plan"]["effects"]:
if "criterion_id" not in effect:
if not effect.get("validation_argv"):
raise ManagedTaskValidationUnavailable("the selected task requires its existing argv validation declaration")
# Preserve raw typed model-result JSON on the command's stdin,
# plus its existing receipt and optional reflection attestation.
validators.append(build_loopx_turn_command_validator(effect["validation_argv"],
project=workspace, timeout_seconds=effect["validation_timeout_seconds"] or 20))
else:
def goal_check(_plan, _result, effect=effect):
receipt = run_goal_acceptance_validation_effect(effect=effect,
registry_path=self.controller.registry_path, goal_id=actor["goal_id"],
validation_workspace_path=workspace)
return {"status": "passed" if receipt["passed"] else "failed",
"validator_kind": "command", "summary": receipt.get("summary") or
("independent Goal acceptance check passed" if receipt["passed"] else
"independent Goal acceptance check failed"),
"exit_code": receipt["exit_code"],
**({"recovery_kind": "repair_required"} if not receipt["passed"] else {})}
validators.append(goal_check)

def validate_checks(plan, result):
receipts = [check(plan, result) for check in validators]
if len(receipts) == 1:
return receipts[0]
failed = next((row for row in receipts if row["status"] != "passed"), None)
# Keep the existing receipt contract and the caller's optional
# reflection attestation. Every required check has executed.
return failed or {**receipts[-1], "summary": f"{len(receipts)} independent task checks passed"}

self.task_validator = validate_checks

def validator(self, request: dict[str, Any], *, turn_id: str):
"""Resolve only the native selection's immutable, caller-declared argv.
"""Execute the current owner-resolved Goal and required Todo checks.

No browser or model argument may install a host validation command.
The captured canonical digest and fresh source must agree before and
after the existing command validator reads the task's real artifact.
Definition, work, claim and lifecycle must agree before and after the
existing validators read the task's real artifact.
"""
from ...control_plane.turn_driver.driver import (
COMPLETE_TURN_PLAN_SCHEMA_VERSION, selected_turn_todo, turn_host_lineage,
Expand All @@ -486,15 +534,15 @@ def validate(plan, result):
selected = (turn_host_lineage(plan) if "work_contract" in plan or plan.get("schema_version") == COMPLETE_TURN_PLAN_SCHEMA_VERSION
else selected_turn_todo(plan.get("turn_envelope") or {}))
basis = self.validation_basis
if not basis or not self.task_validator or basis["todo_id"] != selected["todo_id"]:
if not basis or not self.task_validator or basis["plan"]["todo_id"] != selected["todo_id"]:
raise ValueError("the original task validation source was not captured before model work")

def current():
self.admit(request, turn=self.store.load_turn(actor["session_id"], turn_id))
fresh = self._validation_source(request, selected["todo_id"])
if any(fresh.get(key) != basis.get(key) for key in
("completion_validation_sha256", "completion_validation_revision")):
raise ValueError("the selected task's validation declaration changed")
if (fresh["plan"]["task_basis_sha256"] != basis["plan"]["task_basis_sha256"]
or fresh["plan"]["observation"]["basis_sha256"] != basis["plan"]["observation"]["basis_sha256"]):
raise ValueError("the selected task's validation source or work changed")

current()
receipt = self.task_validator(plan, result)
Expand Down
72 changes: 21 additions & 51 deletions loopx/control_plane/collaboration/delegation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {executionRequestSubject, type JsonObject} from "../effect_program.ts";
import {requireInteger, requireJsonObject, requireStringArray} from "../runtime_decode.ts";
import {EffectRuntimeRequestError} from "../effect_runtime_errors.ts";
import {canonicalAuthoritySha256} from "../coordination/authority_store_codec.ts";
import {acceptanceValidationEffects, goalAcceptanceTodoDigest, type AcceptanceCompletionRequirements} from "../goals/acceptance_contract.ts";
import {canonicalTaskValidationPlan} from "../goals/task_validation_plan.ts";
import {normalizeTodoCompletionValidationDeclaration} from "../todos/completion_validation_declaration.ts";
import {readTurnSelectionRejection, turnSelectionRejectionState} from "../turn_driver/selection_rejection.ts";
import { BARE_SHA256_PATTERN } from "../content_digest.ts";
Expand Down Expand Up @@ -43,57 +43,27 @@ export function delegationValidationPlan(params: JsonObject): JsonObject {
observation: {source: "request_validation", basis_sha256: canonicalAuthoritySha256({binding, effects}),
check_count: effects.length, pinned_file_count: 0}};
}
const basis = requireJsonObject(params.basis, "canonical validation basis");
const todo = requireJsonObject(basis.todo, "canonical delegation Todo");
requireThat(basis.status === "loaded" && text(basis.provider_revision)
&& todo.todo_id === binding.todo_id, "delegation requires a current matching canonical Todo");
requireThat(Object.hasOwn(basis, "completion_requirements"), "canonical acceptance scope required");
const requirements = basis.completion_requirements === null ? null
: requireJsonObject(basis.completion_requirements, "canonical acceptance requirements");
if (requirements !== null) requireThat(requirements.todo_id === todo.todo_id
&& Array.isArray(requirements.criteria) && requirements.criteria.length > 0,
"delegation requires matching owner acceptance criteria");
const unavailable = (reason: string) => ({todo_id: todo.todo_id, state: "unbound",
source: null, reason, effects: [], canonical_done: false});
const effects: JsonObject[] = requirements === null ? []
: acceptanceValidationEffects(requirements as AcceptanceCompletionRequirements, todo)
.map(row => ({...requireJsonObject(row.effect, "acceptance validation effect"), criterion_id: row.criterion_id}));
if (todo.completion_validation_required === true) {
if (params.declaration === null) return unavailable("completion_validation_declaration_unavailable");
const declaration = requireJsonObject(params.declaration, "private validation declaration");
const normalized = normalizeTodoCompletionValidationDeclaration(declaration, {
strict_fields: true, require_command: true, require_canonical_input: true,
});
if (!normalized.ok || canonicalAuthoritySha256(declaration) !== todo.completion_validation_sha256)
return unavailable("completion_validation_declaration_mismatch");
effects.push({kind: "caller_validation", validation_command: normalized.value.validation_command,
validation_argv: normalized.value.validation_command_argv,
validation_label: normalized.value.validation_label,
validation_timeout_seconds: normalized.value.validation_timeout_seconds,
validation_declaration_sha256: todo.completion_validation_sha256,
task_repository: todo.task_repository ?? null});
} else {
requireThat(params.declaration === null && todo.completion_validation_sha256 == null,
"Todo without canonical validation authority cannot supply a declaration");
if (requirements === null) return unavailable("independent_delegation_validation_required");
let plan: JsonObject;
try {
plan = canonicalTaskValidationPlan({todo_id: binding.todo_id,
basis: params.basis, declaration: params.declaration});
} catch (error) {
if (!(error instanceof EffectRuntimeRequestError)) throw error;
// Retain the established delegation diagnostics at this compatibility entry.
const message = error.message === "canonical task Todo must be an object"
? "canonical delegation Todo must be an object"
: error.message === "canonical task requires a current matching canonical Todo"
? "delegation requires a current matching canonical Todo"
: error.message === "canonical task requires matching owner acceptance criteria"
? "delegation requires matching owner acceptance criteria" : null;
if (message === null) throw error;
throw new EffectRuntimeRequestError(message, error.code, error.details);
}
const source = requirements === null ? "todo_validation" : "goal_acceptance";
// Definition identity, not a stored success or independent-verifier receipt.
// Host validation must pass before exposing this path-free current observation.
const observation = {source,
basis_sha256: canonicalAuthoritySha256({todo_id: todo.todo_id, requirements, effects}),
check_count: effects.length,
pinned_file_count: effects.reduce((count, effect) => count
+ (Array.isArray(effect.validation_files) ? effect.validation_files.length : 0), 0),
...currentOracleChecks(basis, effects)};
// Reuse the acceptance owner's work classification. Scheduling/progress
// metadata and unrelated provider commits are not a new task declaration;
// current claim/lifecycle still fence this particular validation attempt.
const task_basis_sha256 = canonicalAuthoritySha256({work: goalAcceptanceTodoDigest(todo),
claimed_by: todo.claimed_by ?? null, role: todo.role ?? null,
status: todo.status, done: todo.done, archive_state: todo.archive_state ?? null});
return {todo_id: todo.todo_id, state: "ready", source, observation, task_basis_sha256,
effects, canonical_done: todo.done === true && todo.status === "done"};
if (plan.reason === "no_declaration")
return {...plan, reason: "independent_delegation_validation_required"};
if (plan.state !== "ready") return plan;
return {...plan, observation: {...requireJsonObject(plan.observation, "current validation observation"),
...currentOracleChecks(requireJsonObject(params.basis, "canonical validation basis"), plan.effects as JsonObject[])}};
}

/** Consume only the acceptance owner's current exact-source observation. */
Expand Down
Loading
Loading