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
38 changes: 25 additions & 13 deletions docs/quota-allocation.md
Original file line number Diff line number Diff line change
Expand Up @@ -814,23 +814,35 @@ loopx --format json quota should-run \
--available-capability benchmark_runner
```

A live `quota should-run` or executing `turn run-once` automatically remembers,
through the admitted turn-start capability hook, these five runtime observations
for the registered Agent on this host:
A live `quota should-run`, executing `turn run-once`, committed `refresh-state` /
`quota spend-slot` / `quota monitor-poll` settlement, or verified live external
capability execution (such as Goal-bound `pr-review` or `issue-fix pr-lifecycle --fetch-metadata`)
automatically remembers these five runtime observations for the registered Agent
on this host:
`network`, `benchmark_runner`, `external_evidence_poll`, `worker_bridge`, and
`cli_bridge`. Later decisions, including `quota spend-slot` and `monitor-poll`
rechecks, read that Agent's observations without repeating flags. Goal/project
`available_capabilities` declarations are inherited dynamically; Agent observations
never write back into Goal configuration or propagate to peer Agents.
`cli_bridge`. In addition, when the host is not in a network-disabled sandbox
(`CODEX_SANDBOX_NETWORK_DISABLED=1` / `LOOPX_OFFLINE=1`) and local GitHub CLI
polling readiness (`gh` + configured auth/token) is detected, LoopX probes
`external_evidence_poll` automatically by default (`probed`) so fresh Goals and
Agents observe upstream PR/evidence dependencies out of the box without manual
`agent-capabilities --execute` or `--available-capability` ceremony. Later
decisions, including `heartbeat-prompt` pre-quota projection, `quota spend-slot`,
and `monitor-poll` rechecks, read that Agent's effective availability without
repeating flags. Goal/project `available_capabilities` declarations are
inherited dynamically; Agent observations never write back into Goal configuration
or propagate to peer Agents.
The hook declares only its Agent-private write scope, returns no private payload,
and fails in isolation; quota selection itself performs no provider or memory write.

The scope is the resolved runtime root, registry path, Goal id and registered
Agent id. Separate hosts/runtimes or registries do not inherit these observations.
A reused Agent id in the same scope refers to the same runtime declaration;
use distinct Agent identities for environments with different tools. Observations
are caller declarations, not independently verified probe receipts. They persist
until corrected or forgotten; omission of a flag does not revoke them.
The scope is the resolved runtime root, canonical project `source_registry` path
(unifying synced `registry.global.json` mirrors with the project's `.loopx/registry.json`),
Goal id and registered Agent id. Separate hosts/runtimes or unrelated registries do
not inherit these observations. A reused Agent id in the same scope refers to the
same runtime declaration; use distinct Agent identities for environments with
different tools. Explicit negative observations (`--unavailable-capability`)
override both Goal inheritance and automatic host probes (`probed`), and are
preserved across passive task-facing executions until explicitly cleared or replaced.
Explicit and verified observations persist until corrected or forgotten. A forget masks the old mirror value on subsequent reads. Local readiness probes apply to the current invocation. A network-disabled host suppresses PR polling even with an earlier positive observation.

```bash
# Read current Agent observations and inherited/effective declarations.
Expand Down
23 changes: 12 additions & 11 deletions docs/reference/todo-continuation-readback.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,14 @@ requirements, claims, leases or Goal acceptance. Deferred ready work still needs
its normal lifecycle transition.

The existing typed capability owner resolves `external_evidence_poll` from the
current Goal declaration, remembered host observations and invocation facts;
remembered revocation defeats inherited permission. No per-command flag is
required when the owner already supplies permission. Shell/filesystem access,
Todo requirements and explicit prequota invocation do not grant network access.
current Goal declaration, automatic local host readiness probes (`probed`: `gh`
CLI + configured auth outside network-disabled sandboxes), remembered host
observations and invocation facts; remembered revocation (`--unavailable-capability`)
defeats both inherited permission and automatic host probes. No per-command flag is
required on equipped hosts. Shell/filesystem access alone and Todo requirements
do not grant network access on offline/unconfigured sandboxes.
Unavailable permission sources return a failure without contacting GitHub.
Remove all inherited grants or record the capability as unavailable to stop
future automatic reads; previously verified merge facts remain usable.
Set `LOOPX_AUTO_CAPABILITY_PROBE=0` to disable local discovery. A network-disabled host suppresses PR observation even with a remembered or explicit declaration. Previously verified merge facts remain usable.

Fresh executing `quota should-run` and `turn run-once --execute` compose the
same registered hook before collecting the governing decision. Compatibility
Expand Down Expand Up @@ -100,11 +101,11 @@ single-flight,并发调用只读回观察进行中,不重复请求。仓库
仍保留原展示边界,重启不需要重复远端读取或改写合并时间。离开 open 列表、关闭未合并或
provider 失败不能解除等待。观察不修改 Todo 状态、要求、认领、lease 或 Goal 验收;
已满足条件的 deferred Todo 仍走正常生命周期转换。
既有 typed capability owner 从当前 Goal 声明、已记住的宿主观察和本次参数解析
`external_evidence_poll`;宿主记录的撤销优先于继承授权。owner 已提供权限时,不必给
每条命令手工补 flag。filesystem/shell、Todo 要求与显式调用 prequota 都不授予网络
权限。权限来源不可用时只返回失败,不联系 GitHub。移除所有继承授权或记录能力不可用,
即可停止后续自动读取;已验证合并事实保留。
既有 typed capability owner 从当前 Goal 声明、默认本机能力自动探测(`probed`:非离线沙箱下检测到
`gh` CLI 与认证凭据时自动开启)、已记住的宿主观察和本次参数解析
`external_evidence_poll`;宿主记录的撤销(`--unavailable-capability`)同时优先于继承授权和自动探测。
本机工具就绪时无需手工传参或预先写入记忆。离线沙箱中仅凭 filesystem/shell 或 Todo 要求不会授予网络
权限。权限来源不可用时只返回失败,不联系 GitHub。设置 `LOOPX_AUTO_CAPABILITY_PROBE=0` 可关闭本地探测。宿主禁网时,即使存在历史或显式能力声明也会停止 PR 观察;已验证的合并事实仍然可用。

执行性的 `quota should-run` 与新的 `turn run-once --execute` 在 governing decision
前组合相同注册 hook;兼容 `heartbeat-prequota` 也调用它。full/thin heartbeat 在宿主
Expand Down
24 changes: 18 additions & 6 deletions loopx/capabilities/external_research/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,20 @@ JSON 与默认 Markdown 输出分别报告文件读取、JSON 解析和根对象
便于调用者修正输入。

```bash
loopx external-evidence discover \
--connector-registry \
# Default zero-flag auto-detection: probes local methods (public-github,
# public-source-reader, gh-cli, ego-browser) + default connector inventory.
loopx external-evidence discover --format json

# Default zero-flag planning with pinned GitHub source refs (auto-probes public-github):
loopx external-evidence plan \
--objective "Compare current behavior" \
--user-activity "Choose an implementation" \
--decision "Whether to adopt it" \
--evidence-kind current_behavior \
--source https://github.com/OWNER/REPO/blob/FULL_COMMIT_SHA/README.md \
--format json

# Explicit custom provider inventory override remains supported:
loopx external-evidence plan \
--objective "Compare current behavior" \
--user-activity "Choose an implementation" \
Expand Down Expand Up @@ -294,15 +304,17 @@ ledger. It requires the active research question to match the plan objective.
Retries for the same admission are idempotent. Wrong questions, unrelated existing
sources and exhausted source budgets remain blockers; partial projection stays
retained until every admitted source is actually read back with matching lineage.
Omit `--execute` for read-only projection; omit `--public-github` to avoid the
provider readiness probe. There is no persistent provider enablement to uninstall.
Omit `--execute` for read-only projection; pass `--no-auto-detect` (or an
explicit `--provider-inventory-json` without `--public-github`) to disable automatic
provider readiness probing. There is no persistent provider enablement to uninstall.
Original sources remain available on partial, empty and failed results.

`execute --execute` 只授权读取来源;`readback --execute` 只把已明确采纳的紧凑证据
写入现有研究账本,且要求研究问题与 plan objective 相同。同一 admission 可幂等重试;
问题不匹配、已有不相关来源或预算耗尽仍为 blocker。部分下游投影保持 retained,
直至全部已采纳来源以匹配 lineage 实际回读。省略 `--execute` 可只读回读;省略
`--public-github` 不探测该 provider。没有持久开关需要卸载。部分、空或失败证据
直至全部已采纳来源以匹配 lineage 实际回读。省略 `--execute` 可只读回读;传入
`--no-auto-detect`(或不带 `--public-github` 的显式 `--provider-inventory-json`)
可关闭默认 provider 就绪探测。没有持久开关需要卸载。部分、空或失败证据
保留原始来源退路;字面匹配不证明语义结论或证据完整性。

Real qualification (anonymous network reads, disposable synthetic ledger):
Expand Down
98 changes: 77 additions & 21 deletions loopx/capabilities/external_research/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from ..connector_registry.core import load_connector_registry
from ...extensions.public_github_research import execute_public_github, inspect_provider
from .projection import readback, render_readback, validate_receipt
from .provider_probe import probe_local_evidence_providers


PrintPayload = Callable[
Expand Down Expand Up @@ -39,7 +40,7 @@ def _load_object(path_text: str, *, label: str) -> dict[str, Any]:
return value


def _load_receipt(path_text: str) -> dict:
def _load_receipt(path_text: str) -> dict[str, Any]:
value = _load_object(path_text, label="external evidence receipt")
receipt = value.get("receipt", value)
if not isinstance(receipt, dict):
Expand Down Expand Up @@ -148,6 +149,13 @@ def register_external_evidence_commands(
help="Path to a JSON object with a providers array; not inline JSON.",
)
discover.add_argument("--connector-registry", nargs="?", const="")
discover.add_argument(
"--no-auto-detect",
dest="auto_detect",
action="store_false",
default=True,
help="Disable default host evidence method and connector auto-detection.",
)
add_subcommand_format(discover)

plan = actions.add_parser(
Expand All @@ -167,6 +175,13 @@ def register_external_evidence_commands(
plan.add_argument("--search-term", action="append", default=[])
plan.add_argument("--connector-registry", nargs="?", const="")
plan.add_argument("--preferred-provider-id")
plan.add_argument(
"--no-auto-detect",
dest="auto_detect",
action="store_false",
default=True,
help="Disable default host evidence provider auto-detection when --provider-inventory-json is omitted.",
)
add_subcommand_format(plan)

execute = actions.add_parser("execute", help="Execute the exact public GitHub plan without admitting evidence.")
Expand Down Expand Up @@ -218,34 +233,75 @@ def handle_external_evidence_command(
return None
try:
if args.external_evidence_action == "discover":
providers = _merge_providers(
_connector_inventory(args.connector_registry),
[]
if args.provider_inventory_json is None
else _provider_inventory(
_load_object(
args.provider_inventory_json,
label="external evidence provider inventory",
auto_detect = (
getattr(args, "auto_detect", True)
and args.provider_inventory_json is None
and args.connector_registry is None
)
connector_arg = "" if auto_detect else args.connector_registry
observed_providers = (
probe_local_evidence_providers(for_plan=False)
if auto_detect
else (
[]
if args.provider_inventory_json is None
else _provider_inventory(
_load_object(
args.provider_inventory_json,
label="external evidence provider inventory",
)
)
),
)
)
providers = _merge_providers(
_connector_inventory(connector_arg),
observed_providers,
)
payload = effect_runtime_result(
"external_evidence.discover",
{"providers": providers},
)
elif args.external_evidence_action == "plan":
if not args.provider_inventory_json and not getattr(args, "public_github", False):
sources = list(getattr(args, "source", []) or [])
explicit_public_github = bool(getattr(args, "public_github", False))
auto_detect = (
getattr(args, "auto_detect", True)
and not args.provider_inventory_json
and not explicit_public_github
)
if not args.provider_inventory_json and not explicit_public_github and not auto_detect:
raise ValueError("plan requires provider inventory or explicit --public-github")
inventory = _load_object(args.provider_inventory_json,
label="external evidence provider inventory") if args.provider_inventory_json else {"providers": []}
if getattr(args, "public_github", False):
if len(getattr(args, "source", [])) > 8:
if explicit_public_github and len(sources) > 8:
raise ValueError("public GitHub plan allows at most eight sources")
if auto_detect:
if len(sources) > 8:
raise ValueError("public GitHub plan allows at most eight sources")
inventory["providers"] = _merge_providers(_provider_inventory(inventory), [inspect_provider(getattr(args, "source", []))])
providers = _merge_providers(
_connector_inventory(args.connector_registry),
_provider_inventory(inventory),
)
connector_arg = "" if args.connector_registry is None else args.connector_registry
providers = _merge_providers(
_connector_inventory(connector_arg),
probe_local_evidence_providers(
source_refs=sources,
for_plan=True,
),
)
else:
inventory = (
_load_object(
args.provider_inventory_json,
label="external evidence provider inventory",
)
if args.provider_inventory_json
else {"providers": []}
)
if explicit_public_github:
inventory["providers"] = _merge_providers(
_provider_inventory(inventory),
[inspect_provider(sources)],
)
providers = _merge_providers(
_connector_inventory(args.connector_registry),
_provider_inventory(inventory),
)
payload = effect_runtime_result(
"external_evidence.plan",
{
Expand All @@ -255,7 +311,7 @@ def handle_external_evidence_command(
"decision": args.decision,
"evidence_kinds": args.evidence_kind,
"constraints": args.constraint,
**({"source_refs": getattr(args, "source", [])} if getattr(args, "source", []) else {}),
**({"source_refs": sources} if sources else {}),
**({"search_terms": getattr(args, "search_term", [])} if getattr(args, "search_term", []) else {}),
},
"providers": providers,
Expand Down
Loading
Loading