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
7 changes: 7 additions & 0 deletions docs/guides/context-delivery.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,13 @@ same registered source in the current session and epoch. The current source
revision and Turn controls still appear. A change to the narrative or its
source, an incomplete read, or compaction restores the current text.

For ready work on the same registered route and Todo, the native first read can
reference an exact write-scope list that the session already received in full.
The rest of the current boundary, including guards and stops, still appears.
If unsure about a path, select `/goal_boundary/write_scope` from the current
recovery reader. Changes to the list or route, incomplete reads and compaction
restore the current list.

### Read and recover the right object

Use the path, digest and command returned by the current response. A native
Expand Down
5 changes: 5 additions & 0 deletions docs/guides/context-delivery.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,11 @@ Full 表示完整保存视图可用,不要求判断任何问题前先遍历所
首读仍交付当前来源修订和 Turn 控制条件。正文或来源变化、读取不完整或发生压缩时,
读者恢复当前正文。

同一注册路由和 Todo 的工作已就绪时,原生首读可以引用会话此前完整收到的同一份写入
范围列表。当前边界的其他部分仍会显示,包括防护和停止条件。不确定某个路径是否在
范围内时,通过当前恢复读取命令选择 `/goal_boundary/write_scope`。列表或路由变化、
读取不完整或发生压缩时,会恢复当前完整列表。

### 读对对象,再恢复

使用当前响应返回的路径、摘要与命令。原生响应的 `recovery` 指向当前完整必要视图;
Expand Down
11 changes: 11 additions & 0 deletions docs/reference/required-work-context.md
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,12 @@ immutable capture.
original digest-bound capture in the wake prompt. Recovery reuses the saved
decision and its original receipt.

The native `quota should-run` navigation may also link two reads when a ready
decision has a large write scope. Read `first_read_command` for the decision,
stop conditions and required reads. If `remaining_read_command` is present,
follow it and its cursor before work, even when the opening reports EOF. It
starts with the complete current write scope and uses the same capture.

中文:对于已保存的 benchmark 准入结果,唤醒正文直接给出首读命令。一次调用即可
取得首屏,已知字段可改用多个 `--select`。首读默认最多 12,000 个 UTF-8 字节,含导航。
已知工具直出与历史保留上限时,可用 `--max-page-output-bytes` 指定匹配的字节预算,最高
Expand All @@ -317,6 +323,11 @@ decision and its original receipt.
`navigation.first_read_command` 可重读首屏,其他字段沿
`navigation.recovery.command` 读取。结果丢失时,用唤醒正文中的原文件及摘要恢复,复用原决策和回执。

原生 `quota should-run` 的已就绪决策含较长的写入范围时,导航也可能给出两段读取。
先用 `first_read_command` 取得决策、停止条件和必读项。如果给出
`remaining_read_command`,即使首段已到 EOF,也要在开工前沿该命令及其游标读完。
续读从完整的当前写入范围开始,两段绑定同一份捕获。

When the existing acceptance owner supplies complete `outcome_context`
navigation matching this capture's Goal, Agent, selected Todo, outcome revision
and provider revision, the initial read expands its suggested outcomes in full
Expand Down
11 changes: 9 additions & 2 deletions loopx/cli_commands/quota_capture.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
native_context_page_budget,
)
from .quota_context_reader import (
_bounded_initial_read,
_capture_selection_transport_template,
bind_capture_selection_transport as bind_capture_selection_transport,
_saved_context_read_page,
Expand Down Expand Up @@ -108,17 +109,19 @@ def native_context_capture_view(projected: dict[str, Any], directory: Path, *,
field_index = None
initial_read_pointers = None
initial_read_reference = None
initial_read_size = 0
# A stateless attached page uses the ordinary verified selector below.
# 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:
nonlocal initial_read_pointers, initial_read_reference
nonlocal initial_read_pointers, initial_read_reference, initial_read_size
selections = plan["selections"]
initial_read_pointers = [item["pointer"] for item in selections]
try:
initial_read_reference, _ = write_initial_context_read_reference(Path(current["path"]), current["sha256"],
initial_read_reference, content = write_initial_context_read_reference(Path(current["path"]), current["sha256"],
current_document, selections)
initial_read_size = len(content)
except OSError:
# Read-only capture roots keep the existing initial recipe;
# metadata is optional and never a read/authority receipt.
Expand Down Expand Up @@ -195,6 +198,10 @@ def view(kind: str, ref: dict[str, Any], body: bytes) -> dict[str, Any]:
result["first_read_command"] = context_capture_read_command(Path(current["path"]), current["sha256"],
reference_file=first, page_bytes=first_page_bytes,
max_page_output_bytes=first_output_bytes, reader_argv=reader_argv)
elif (not page_attached and initial_read_plan and initial_read_plan.get("prefer_linked_opening") is True

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

[P2] 已读其他字段时仍须保留完整首段

同一会话只完整读取 Goal 正文,然后改动 290 条写入范围的末项。已有正文观测会先选择普通 observed reader,跳过这里的分段。在实际 File/SQLite 入口,新的 ready 首读都是 12,000 字节截断页,缺选定 Todo、回执身份、租约状态、停止条件与父级批准条件。请在当前范围仍需交付且会遮住控制条件时保留分段,并同时复验已完整观察范围的暖读和同一捕获续段。

and initial_read_size > first_page_bytes):
result = _bounded_initial_read(result, initial_read_plan, page_bytes=first_page_bytes,
output_bytes=first_output_bytes, reader_argv=reader_argv, attach_page=False) or result
return result


Expand Down
21 changes: 15 additions & 6 deletions loopx/cli_commands/quota_context_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,8 @@ def reference(value: dict[str, Any], *, navigation: bool = False) -> dict[str, s
result["first_read_command"] = context_capture_read_command(Path(recovery["path"]), recovery["sha256"],
page_bytes=first_page_bytes, max_page_output_bytes=first_output_bytes, initial_read=True,
reference_file=Path(result["recovery"]["reference_file"]), reader_argv=reader_argv)
if "remaining_read_command" in view:
result["remaining_read_command"] = view["remaining_read_command"]
result["instruction"] += (" Append --select '<pointer>' or --list to recovery.command for current fields. "
"Reader references keep complete digests locally; the CLI checks them on every page. "
"A reference or digest grants no authority or freshness.")
Expand Down Expand Up @@ -582,8 +584,9 @@ def _native_context_read_bytes(reference: dict[str, Any], raw: bytes, *,
offset = page["next_offset"]


def _bounded_initial_page(navigation: dict[str, Any], plan: dict[str, Any], *,
page_bytes: int, output_bytes: int, reader_argv: list[str]) -> dict[str, Any] | None:
def _bounded_initial_read(navigation: dict[str, Any], plan: dict[str, Any], *,
page_bytes: int, output_bytes: int, reader_argv: list[str] | None,
attach_page: bool = True) -> dict[str, Any] | None:
"""Try the typed opening and keep the remainder pinned to the same capture."""
if "opening" not in plan or "first_read_command" not in navigation:
return None
Expand All @@ -599,14 +602,20 @@ def command(reference: Path) -> str:
return context_capture_read_command(path, digest, page_bytes=page_bytes,
max_page_output_bytes=output_bytes, reference_file=reference, reader_argv=reader_argv)

guidance = ("This opening covers the decision and read obligations. Before work, read its content, "
"then follow remaining_read_command and its cursor through the rest of the initial selection. "
"Both views pin the same capture.")
navigation = {**navigation, "first_read_command": command(opening), "remaining_read_command": command(remaining),
"instruction": ("This opening covers the decision and read obligations. Before work, read its content, "
"then follow remaining_read_command and its cursor through the rest of the initial selection. "
+ navigation["instruction"])}
"instruction": (guidance + " " + navigation["instruction"] if attach_page
else navigation["instruction"] + " " + guidance)}
page = _capture_page(path, content, digest, offset=0, size=len(content), output_limit=None,
instruction=False, select=[], reference_file=opening, reader_argv=reader_argv)
# An opening is useful only as a complete, independently readable
# page. Keep the ordinary cursor when even the opening cannot fit.
if not attach_page:
navigation["first_read_reference"] = str(opening)
return (navigation if len(_native_output_bytes(page)) <= output_bytes
and len(_native_output_bytes(navigation)) <= min(output_bytes, 7900) else None)
page["read_instruction"] = (
"EOF ends the opening. Before work, read its content and follow navigation.remaining_read_command "
"and its next_command cursor through the remaining initial context. Both views pin the same capture. "
Expand All @@ -633,7 +642,7 @@ def _saved_context_read_page(args: argparse.Namespace, navigation: dict[str, Any
if page["ok"]:
if (pinned and initial_read_plan and output_limit is not None and not page["eof"]
and "previously_delivered_fields" not in page
and (opening := _bounded_initial_page(navigation, initial_read_plan,
and (opening := _bounded_initial_read(navigation, initial_read_plan,
page_bytes=args.page_bytes if args.page_bytes is not None else output_limit,
output_bytes=output_limit, reader_argv=reader_argv)) is not None):
return opening
Expand Down
Loading
Loading