Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
3e2e337
fix(dsh): surface continuation admission failures in GoalBar
LIHUA919 Nov 11, 2026
f835932
fix(dsh): keep admitted turns across plugin-tree recomposition
LIHUA919 Nov 11, 2026
f64af35
fix(dsh): retry lost saved quota page responses
loopx-agent Nov 13, 2026
5cfe466
fix(dsh): clean up owned CLI process groups on timeout
loopx-agent Nov 13, 2026
7ac9377
fix(dsh): hold rejected automatic continuations
loopx-agent Nov 16, 2026
530d218
fix(dsh): keep approved user input in the current step
loopx-agent Nov 16, 2026
422f60a
Merge remote-tracking branch 'origin/main' into codex/dsh-prestep-rej…
loopx-agent Nov 16, 2026
f8d21bd
Show prior-Turn recovery waits in the DSH GoalBar
loopx-agent Nov 16, 2026
aeb57d1
Read an exact committed quota admission without starting a Turn
loopx-agent Nov 16, 2026
f402d5a
Resume a DSH Turn still awaiting its original Todo selection
loopx-agent Nov 16, 2026
a0667f2
Assert the pending selection marker on native admission
loopx-agent Nov 16, 2026
a2f6f9d
Integrate admitted-turn recomposition repair for DSH qualification
loopx-agent Nov 16, 2026
46b574c
Integrate rejected-continuation handling for DSH qualification
loopx-agent Nov 16, 2026
8d62929
Integrate recovery attention without reviving cancelled maintenance
loopx-agent Nov 16, 2026
2c57294
Integrate admission diagnostics with prior-Turn recovery projection
loopx-agent Nov 16, 2026
6de9b68
Integrate bounded DSH CLI transport recovery
loopx-agent Nov 16, 2026
5851c3c
Integrate current main for the DSH repair candidate
loopx-agent Nov 16, 2026
8888a8e
fix(dsh): complete continuation recovery and qualify beta.7 delivery
loopx-agent Nov 16, 2026
3a433dc
test(dsh): reject lifecycle writes with absent or malformed source fi…
loopx-agent Nov 16, 2026
71d232b
fix(dsh): preserve error hold after unrelated background completion
loopx-agent Nov 16, 2026
7f3b86b
test(dsh): clear recovered original selection before body transport f…
loopx-agent Nov 16, 2026
5087deb
Merge current main authority boundary into DSH integration
loopx-agent Nov 16, 2026
7308b4f
test(dsh): bind real SDK writeback to its producing workspace
loopx-agent Nov 16, 2026
b857fe9
test(dsh): isolate managed SDK qualification from machine credentials
loopx-agent Nov 16, 2026
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
8 changes: 8 additions & 0 deletions docs/quota-allocation.md
Original file line number Diff line number Diff line change
Expand Up @@ -1455,6 +1455,14 @@ markdown output and highlights `next_automatic_turn` when a goal is eligible.
If that value is `none`, the automation should skip delivery compute and follow
the displayed gate, evidence, or health reason.

`quota receipt --goal-id <goal-id> --agent-id <agent-id> --turn-instance-id <turn-id>`
reads the committed guard for that exact Turn. `heartbeat_receipt` is null when
the scoped receipt is missing. A guard that admitted an explicit work choice
before it was made carries `selection_required` and `settlement_binding_owed`.
After selection, the same lookup returns the committed settlement identity.
Hosts use this read-only lookup to reconcile a finished attempt with its
original guard, including when the current queue has changed.

`quota should-run` is the per-goal guard for heartbeat jobs. It returns a small
JSON or Markdown decision:

Expand Down
46 changes: 40 additions & 6 deletions examples/loopx-turn-dsh-real-e2e-smoke.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,11 @@
import sys
import tempfile
import threading
from collections.abc import Iterator
from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer
from pathlib import Path
from typing import Any
from unittest.mock import patch

REPO_ROOT = Path(__file__).resolve().parents[1]
sys.path.insert(0, str(REPO_ROOT))
Expand All @@ -38,10 +40,31 @@
ADAPTER = REPO_ROOT / "scripts" / "dsh_turn_host_adapter.py"


@contextlib.contextmanager
def _isolated_machine_profile(root: Path, endpoint: str) -> Iterator[None]:
"""Keep the real managed-host credential owner inside this local fixture."""
from loopx import paths
from loopx.control_plane.operator_provider import write_operator_provider

machine = root / "machine-owner"
with (
patch.object(paths, "DEFAULT_RUNTIME_ROOT", machine),
patch.object(paths, "LEGACY_RUNTIME_ROOT", root / "absent-legacy-machine"),
):
write_operator_provider(
runtime_root=machine,
api_key="dsh-real-e2e-mock-key",
base_url=endpoint,
)
yield


def _write_fixture(root: Path) -> tuple[Path, Path, Path, Path]:
project = root / "project"
runtime = root / "runtime"
workspace = root / "workspace"
# The native host and accountable writeback share the actual local Goal
# workspace; a separate sibling is not a producing-worktree receipt.
workspace = project
runtime.mkdir(parents=True)
workspace.mkdir(parents=True)
(workspace / "docs").mkdir()
Expand Down Expand Up @@ -113,6 +136,10 @@ def _write_fixture(root: Path) -> tuple[Path, Path, Path, Path]:
+ "\n",
encoding="utf-8",
)
from loopx.control_plane.testing.canary_harness import import_fixture_authority

for goal in json.loads(registry.read_text())["goals"]:
import_fixture_authority(registry, goal["id"], provider="sqlite")
return project, runtime, workspace, registry


Expand Down Expand Up @@ -276,6 +303,8 @@ def main() -> int:
{
"result_kind": "validated_progress",
"classification": "real_dsh_mock_llm",
"work_evidence": [f"artifact:{MARKER_NAME}"],
"validation_evidence": ["fixture:independent-marker-validator"],
"summary": "Real dsh runtime returned a typed result through the mock LLM.",
"recommended_action": "Review the real dsh e2e marker.",
"next_action": "Inspect the marker and replay idempotently.",
Expand Down Expand Up @@ -326,7 +355,10 @@ def log_message(self, _format: str, *args: object) -> None:
os.environ["DEEPSEEK_API_KEY"] = "dsh-real-e2e-mock-key"
for key in ("DSH_CWD", "DSH_HOME", "DSH_SESSION_ROOT"):
os.environ.pop(key, None)
with tempfile.TemporaryDirectory(prefix="loopx-turn-dsh-real-e2e-") as directory:
with (
tempfile.TemporaryDirectory(prefix="loopx-turn-dsh-real-e2e-") as directory,
_isolated_machine_profile(Path(directory), base_url),
):
root = Path(directory)
project, runtime, workspace, registry = _write_fixture(root)
session_root = root / "sessions"
Expand All @@ -344,7 +376,8 @@ def log_message(self, _format: str, *args: object) -> None:
host=args.host,
timeout_seconds=args.timeout_seconds,
)
exit_code, payload = _run_cli([*base, "--execute"])
with contextlib.chdir(workspace):
exit_code, payload = _run_cli([*base, "--execute"])

marker_valid = (
marker_path.is_file()
Expand All @@ -357,9 +390,10 @@ def log_message(self, _format: str, *args: object) -> None:
replay_base = list(base)
idx = replay_base.index("--turn-instance-id")
del replay_base[idx : idx + 2]
replay_exit_code, replay = _run_cli(
[*replay_base, "--resume-turn-key", turn_key, "--execute"]
)
with contextlib.chdir(workspace):
replay_exit_code, replay = _run_cli(
[*replay_base, "--resume-turn-key", turn_key, "--execute"]
)

summary = {
"schema_version": "loopx_turn_dsh_real_e2e_v1",
Expand Down
10 changes: 10 additions & 0 deletions loopx/cli_commands/quota.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ def _quota_goal_ref(
return exact_goal_ref(goal_id, goal_instance_id)
if args.quota_command not in {
"should-run",
"receipt",
"monitor-poll",
"scheduler-ack",
"scheduler-ack-current",
Expand Down Expand Up @@ -655,6 +656,15 @@ def handle_quota_command(
capture_directory: Path | None = None,
retained_action_selection_todo_id: str | None = None,
) -> int:
if args.quota_command == "receipt":
from .quota_receipt import read_quota_receipt, render_quota_receipt

payload = read_quota_receipt(
args, registry_path=registry_path, runtime_root_arg=runtime_root_arg,
goal_ref_resolver=lambda: _quota_goal_ref(args, registry_path=registry_path),
)
print_payload(payload, args.format, render_quota_receipt)
return 0 if payload["ok"] else 1
native_result = handle_native_context_command(args, print_payload=print_payload,
registry_path=registry_path, runtime_root_arg=runtime_root_arg)
if native_result is not None:
Expand Down
52 changes: 52 additions & 0 deletions loopx/cli_commands/quota_receipt.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
"""Read the original persisted guard without collecting live quota or writing."""

from __future__ import annotations

import argparse
from collections.abc import Callable, Mapping
import json
from pathlib import Path

from ..control_plane.quota.heartbeat_receipt import find_heartbeat_receipt, heartbeat_receipt_view
from ..history import load_registry
from ..paths import resolve_runtime_root, validate_goal_id_path_segment
from ..registry import find_registry_goal
from ..turn_identity import normalize_turn_instance_id


def read_quota_receipt(
args: argparse.Namespace,
*,
registry_path: Path,
runtime_root_arg: str | None,
goal_ref_resolver: Callable[[], Mapping[str, object] | None],
) -> dict[str, object]:
payload: dict[str, object] = {"ok": False, "schema_version": "quota_receipt_readback_v0"}
try:
if not (args.goal_id and args.agent_id and args.turn_instance_id):
raise ValueError("quota receipt requires --goal-id, --agent-id and --turn-instance-id")
goal_id = validate_goal_id_path_segment(args.goal_id)
turn_id = normalize_turn_instance_id(args.turn_instance_id)
assert turn_id is not None
registry = load_registry(registry_path)
if find_registry_goal(registry, goal_id) is None:
raise ValueError("quota receipt requires a registered Goal")
runtime_root = resolve_runtime_root(registry, runtime_root_arg, registry_path=registry_path)
event = find_heartbeat_receipt(
runtime_root, goal_id=goal_id, agent_id=args.agent_id, turn_instance_id=turn_id,
goal_ref=goal_ref_resolver(),
)
payload.update(
ok=True, goal_id=goal_id, agent_id=args.agent_id, turn_instance_id=turn_id,
heartbeat_receipt=(
heartbeat_receipt_view(event, turn_instance_id=turn_id, status="committed")
if event is not None else None
),
)
except (OSError, RuntimeError, ValueError) as exc:
payload["error"] = str(exc)
return payload


def render_quota_receipt(payload: dict[str, object]) -> str:
return json.dumps(payload, ensure_ascii=False, indent=2)
5 changes: 3 additions & 2 deletions loopx/cli_commands/quota_registration.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ def register_quota_command(
"status",
"plan",
"should-run",
"receipt",
"context-read",
"context-project",
"context-hook",
Expand All @@ -62,7 +63,7 @@ def register_quota_command(
"void-slot",
],
default="status",
help="Use status for all groups, plan for next-turn groups, should-run for one goal, context-read for bounded original-capture recovery without a guard, context-project to present an existing digest-bound quota capture with native full/delta and a full-read fallback, context-hook for opt-in native Codex lifecycle IO, context-config for native hook/recovery configuration without installation or trust changes, monitor-poll for no-spend quiet poll evidence, scheduler-ack for successful Codex App RRULE state, scheduler-fail-current to suppress a repeated failed host update pair, spend-slot for accounting, or void-slot for a non-destructive accounting correction.",
help="Use status for all groups, plan for next-turn groups, should-run for one goal, receipt to read one exact committed guard without admission, context-read for bounded original-capture recovery without a guard, context-project to present an existing digest-bound quota capture with native full/delta and a full-read fallback, context-hook for opt-in native Codex lifecycle IO, context-config for native hook/recovery configuration without installation or trust changes, monitor-poll for no-spend quiet poll evidence, scheduler-ack for successful Codex App RRULE state, scheduler-fail-current to suppress a repeated failed host update pair, spend-slot for accounting, or void-slot for a non-destructive accounting correction.",
)
quota_parser.add_argument("--decision-file", help="Original captured decision for read-only replan-view.")
quota_parser.add_argument("--outcome-ref", help="Exact captured acceptance outcome reference for replan-view.")
Expand Down Expand Up @@ -303,7 +304,7 @@ def register_quota_command(
quota_parser.add_argument(
"--turn-instance-id",
help=(
"Stable heartbeat settlement id for `quota should-run`, "
"Stable heartbeat settlement id for `quota should-run`, `quota receipt`, "
"`quota monitor-poll`, scheduler ACK/failure follow-ups, and "
"`quota spend-slot`. The guard persists one idempotent receipt; "
"reuse the same id through monitor writeback, scheduler handoff, "
Expand Down
2 changes: 2 additions & 0 deletions loopx/control_plane/quota/heartbeat_receipt.py
Original file line number Diff line number Diff line change
Expand Up @@ -663,6 +663,8 @@ def heartbeat_receipt_view(
# finished guard: the caller otherwise discovers the debt only when the
# closeout cannot settle the turn and the work stays unaccounted.
receipt["settlement_binding_owed"] = True
if details.get("selection_required") is True:
receipt["selection_required"] = True
semantic_replan_obligation_id = (
heartbeat_receipt_semantic_replan_obligation_id(event)
)
Expand Down
8 changes: 8 additions & 0 deletions loopx/control_plane/quota/settlement_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,14 @@ def quota_rollout_details(
details["semantic_replan_gap_id"] = capability_guard["gap_id"]
details["semantic_replan_frontier_revision"] = capability_guard["frontier_revision"]
cli_channel = interaction.get("cli_channel")
if (
isinstance(cli_channel, Mapping)
and cli_channel.get("selection_required") is True
and payload.get("ok") is True
and payload.get("should_run") is True
and not todo_id and not replan_obligation_id
):
details["selection_required"] = True
if isinstance(cli_channel, Mapping) and cli_channel.get("quota_spend_source"):
details["quota_spend_source"] = cli_channel["quota_spend_source"]
retained_todo_id = normalize_todo_id(retained_selection.get("retained_todo_id"))
Expand Down
Loading
Loading