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
17 changes: 17 additions & 0 deletions docs/reference/protocols/quota-cli-hot-path-compaction-v0.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,23 @@ TypeScript 上下文 owner 同时约束 `quota context-read --initial-read`。
停止和结算不变;改变的只是起始视图,不是完整 capture 或显式读取。总成本比较须计入
后续索引补读及额外调用;初读字节减少本身不证明保留、理解或收益。

A prepared native turn with a matching settlement receipt can open a large
batch of suggested outcomes with their IDs, objectives, revisions, and exact
addresses. This applies when the complete suggested bodies exceed the native
first-read window and every suggested outcome has a verified supporting
address. Instead of claiming complete requirements inline, the opening
identifies those omitted outcome parent paths (the parent of each `/id` pointer)
and requires selecting every applicable complete outcome from the current
recovery capture before dependent work. A small batch retains its complete
opening bodies. Explicit initial reads and saved selection references retain
their own read plans.

原生 Turn 准备就绪后,若结算回执匹配、建议验收项的完整正文超过首读窗口,且各项
都有核验过的支撑地址,首读先提供各项目标、ID、版本和精确地址。该首读不再声称
已保留完整要求,而是标明省略的验收父路径(各 `/id` 指针的父路径),并要求在
依赖工作前沿当前恢复 capture 读取适用验收项的完整正文。小批量仍在首读展开完整
正文。显式初读和已保存的选择引用沿各自的读取计划运行。

## Ownership Boundary

Successful JSON `refresh-state` output keeps the complete `explore_result` once.
Expand Down
2 changes: 1 addition & 1 deletion docs/reference/protocols/turn-envelope-v0.md
Original file line number Diff line number Diff line change
Expand Up @@ -599,7 +599,7 @@ diagnostic remain unchanged. This is an output qualification, not a full-cost SL
The benchmark heartbeat worker verifies a historical `turn_envelope` request
against the pinned CLI's v0 response before launching a model. Its read-only
preview and eligibility are recorded in the wake receipt. See the [runtime
guide](../../../benchmark/runtime/RUNTIME.md) for supported configurations.
guide](https://github.com/loopx-project/loopx/blob/main/benchmark/runtime/RUNTIME.md) for supported configurations.
Model cost, decision quality and long-run adoption require a separately pinned
experiment. A capture carries its original read and recovery scope.

Expand Down
12 changes: 7 additions & 5 deletions loopx/cli_commands/quota_capture.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,13 +111,14 @@ def native_context_capture_view(projected: dict[str, Any], directory: Path, *,
# Its recovery recipe does not require an extra root index to be planned.
stateless_first_read = progressive_enabled and page_attached and captured_recovery is not None

def pin_initial_selection(plan: dict[str, Any]) -> None:
def pin_initial_selection(plan: dict[str, Any], *, opening_context_instruction: str | None = None) -> None:
nonlocal initial_read_pointers, initial_read_reference, initial_read_content
selections = plan["selections"]
initial_read_pointers = [item["pointer"] for item in selections]
try:
initial_read_reference, initial_read_content = write_initial_context_read_reference(Path(current["path"]), current["sha256"],
current_document, selections)
initial_read_reference, initial_read_content = write_initial_context_read_reference(
Path(current["path"]), current["sha256"], current_document, selections,
opening_context_instruction=opening_context_instruction)
except OSError:
# Read-only capture roots keep the existing initial recipe;
# metadata is optional and never a read/authority receipt.
Expand Down Expand Up @@ -146,7 +147,7 @@ def pin_initial_selection(plan: dict[str, Any]) -> None:
try:
initial, plan = initial_read_plan["initial"], initial_read_plan["plan"]
if initial:
pin_initial_selection(plan)
pin_initial_selection(plan, opening_context_instruction=initial_read_plan.get("opening_context_instruction"))
else:
field_index = _context_index_fields(current_document, plan["selections"][0]["children"])
except (EffectRuntimeRemoteError, EffectRuntimeStartupError):
Expand Down Expand Up @@ -250,7 +251,8 @@ def project_native_quota_context(payload: dict[str, Any], args: argparse.Namespa
capture_directory=capture_directory, goal_id=decision_identity[0], agent_id=decision_identity[1],
surface=quota_context_surface(payload),
capture_id=capture_id, continuity_generation=getattr(args, "_context_delivery_generation", None),
progressive_enabled=progressive_enabled)
progressive_enabled=progressive_enabled,
max_page_output_bytes=getattr(args, "max_page_output_bytes", None))
recovery = prepared.delivery.get("recovery")
view = native_context_capture_view(prepared.delivery, capture_directory, context_directory=directory,
progressive_enabled=progressive_enabled, initial_read_plan=prepared.initial_read_plan,
Expand Down
19 changes: 15 additions & 4 deletions loopx/cli_commands/quota_context_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,11 +256,17 @@ def _validate_context_page_window(offset: int, size: int, output_limit: int | No


def _validate_pinned_selection(selection: dict[str, Any]) -> None:
if (set(selection) - {"present_goal_narrative"} != {"select", "initial_read", "list_fields", "list_depth", "sha256"}
if (set(selection) - {"present_goal_narrative", "opening_context_instruction"}
!= {"select", "initial_read", "list_fields", "list_depth", "sha256"}
or type(selection["initial_read"]) is not bool or type(selection["list_fields"]) is not bool
or ("present_goal_narrative" in selection and (
selection["present_goal_narrative"] is not True
or selection["list_fields"] or selection["initial_read"]))
or ("opening_context_instruction" in selection and (
not isinstance(selection["opening_context_instruction"], str)
or not selection["opening_context_instruction"]
or selection["list_fields"] or selection["initial_read"]
or "/context_details/instruction" not in (selection.get("select") or ())))
or not isinstance(selection["sha256"], str)
or BARE_SHA256_PATTERN.fullmatch(selection["sha256"]) is None):
raise ValueError("reader selection reference is incomplete or unsupported")
Expand Down Expand Up @@ -393,7 +399,9 @@ def read_context_capture(args: argparse.Namespace, *, presentation: dict[str, An
present_goal_narrative=(pinned_selection.get("present_goal_narrative") is True
if pinned_selection is not None else None),
selection_paths=reference.get("selection_paths") if pinned_selection is not None else None,
text_append=text_append)
text_append=text_append,
opening_context_instruction=(pinned_selection.get("opening_context_instruction")
if pinned_selection is not None else None))
except ContextSelectionDigestChanged as exc:
# A verified file digest only binds bytes. Preserve an explicit
# selection or listing, including a receipt-only diagnostic.
Expand Down Expand Up @@ -720,12 +728,15 @@ def _bounded_initial_read(navigation: dict[str, Any], plan: dict[str, Any], *,
digest = plan["capture"]["sha256"]
if ordinary_page and _contains_ordinary_opening(ordinary_page["content"], document, plan):
return None
opening, content = write_initial_context_read_reference(path, digest, document, plan["opening"]["selections"])
opening_instruction = plan.get("opening_context_instruction")
opening, content = write_initial_context_read_reference(path, digest, document, plan["opening"]["selections"],
opening_context_instruction=opening_instruction)
if len(content) > page_bytes or len(content) >= output_bytes:
return None
remaining = remaining_reference
if remaining is None:
remaining, _ = write_initial_context_read_reference(path, digest, document, plan["remaining"]["selections"])
remaining, _ = write_initial_context_read_reference(path, digest, document, plan["remaining"]["selections"],
opening_context_instruction=opening_instruction)

def command(reference: Path) -> str:
return context_capture_read_command(path, digest, page_bytes=page_bytes,
Expand Down
3 changes: 2 additions & 1 deletion loopx/cli_commands/quota_native_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,8 @@ def authority_refusal(error: Exception) -> dict[str, Any]:
goal_id=args.goal_id, agent_id=args.agent_id, surface="complete_turn" if complete else "quota_packet",
capture_id=args.capture_sha256,
continuity_generation=getattr(args, "_context_delivery_generation", None),
progressive_enabled=activation["progressive_enabled"], selection_command_args_template=transport,
progressive_enabled=activation["progressive_enabled"], max_page_output_bytes=caller_output_limit,
selection_command_args_template=transport,
captured_decision=captured_decision if activation["progressive_enabled"]
and (args.initial_read or "sha256" in captured_decision) else None,
hook_session=hook_session, saved_capture=True, publication_guard=publication_guard)
Expand Down
Loading
Loading