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
15 changes: 13 additions & 2 deletions docs/reference/protocols/decision-context-architecture-v0.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@ Status: experimental contract
## Position

Decision Context is a built-in, default-off, goal-scoped LoopX capability. It
runs above LoopX Core, consumes Core truth, and does not enter
`loopx/control_plane/` or alter todo, gate, quota, or authority semantics.
runs above LoopX Core, consumes Core truth, and does not alter Core todo, gate,
quota eligibility, or authority semantics; its optional host-local turn-start
hook binding uses the TypeScript capability-hook owner seam under
`loopx/control_plane/capabilities/decision_context_hook.ts` without moving
domain scoring, source adapters, or decision recommendations into Core.

```mermaid
flowchart TD
Expand Down Expand Up @@ -267,6 +270,14 @@ registering a private adapter in the public package. Activation projects only
private. Missing or mismatched runtime providers fail open without advancing a
cursor.

Host-local turn-start integration (`decision_context.turn_context`) follows the
same default-off and read-only boundary: an explicit CAS-managed binding under
`<runtime-root>/decision-context/agent-bindings/` opts one registered
`(goal_id, agent_id)` into a public-safe `decision_context_hook_view_v1`
observation on `quota should-run` and `turn run-once`, omitting private
locators, cursors, and source bodies while leaving review settlement and cursor
commits untouched.

### P1: first dogfood

Use one private, redacted decision-assistant scenario. Let a domain adapter map
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
## 定位

Decision Context 是 LoopX 内置、默认关闭、goal-scoped 的高层决策 capability。
它运行在 LoopX Core 之上,消费 Core truth,但不进入
`loopx/control_plane/`,也不改变 todo、gate、quota、authority 的语义。
它运行在 LoopX Core 之上,消费 Core truth,不改变 Core 的 todo、gate、quota 准入或
authority 语义;其可选本机回合起始钩子绑定遵循 TypeScript 控制面迁移契约,落在
`loopx/control_plane/capabilities/decision_context_hook.ts` 能力钩子边界内,不把领域打分、信源适配器或决策建议下沉进 Core。

```mermaid
flowchart TD
Expand Down Expand Up @@ -277,6 +278,11 @@ checkpoint 路径,而不必把私有 adapter 注册进公开包。activation
`runtime-bound`;adapter 名称、配置、locator、payload 和 cursor 均留在私有边界。
provider 缺失或身份不匹配时 fail open,且不会推进 cursor。

本机轮次启动钩子(`decision_context.turn_context`)同样遵守默认关闭与只读边界:只有通过
`<runtime-root>/decision-context/agent-bindings/` 下的事务型 CAS 绑定显式接入单个已注册
`(goal_id, agent_id)` 后,`quota should-run` 与 `turn run-once` 才会交付公开安全的
`decision_context_hook_view_v1` 新鲜度/变更摘要,不暴露私有路径、游标与正文,也不触发审阅结算或游标提交。

### P1:首个 dogfood

- 在一个私有、脱敏的决策助手场景,由领域 adapter 把新事实映射到稳定私有论点;
Expand Down
36 changes: 36 additions & 0 deletions loopx/capabilities/decision_context/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ change touches.
| `capture.py` | Opt-in source-reference capture and `capture-status` |
| `capture_recovery.py` | Reference-preserving capture diagnosis and recovery |
| `extension_provider.py` | Advisory context provider delivered by an extension (`decision_context_advisory_provider_v0`) |
| `turn_start_hook.py` | Opt-in host-local Agent turn-start hook binding and public-safe freshness/change view |
| `architecture.py` | `architecture` readback of the capability contract |
| `catalog_entry.py` | Capability catalog record |
| `cli.py` | Every `loopx decision-context` subcommand and its rendering |
Expand Down Expand Up @@ -547,6 +548,41 @@ pointing at a deleted checkout), when the last tick failed, when the spool is
gone, or when a recorded source is stale or failing. Remove the record of a
deliberately retired host.

### Opt-in Host-Local Turn-Start Hook Binding

Decision Context remains **default off** on `quota should-run` and `turn run-once`.
Untouched runtimes and unbound Agents make zero provider or RPC calls. An operator
can explicitly bind a registered `(goal_id, agent_id)` lane to an existing private
profile through the transactional host-local binding store under
`<runtime-root>/decision-context/agent-bindings/`:

```bash
loopx decision-context hook read \
--goal-id <goal-id> --agent-id <agent-id> --format json

loopx decision-context hook bind \
--goal-id <goal-id> --agent-id <agent-id> \
--profile <private-profile.json> \
[--cursor-state <reviewed-cursors.json>] \
[--spool <private-capture.sqlite>] \
[--mode prepare_evidence|source_manifest|capture_status] \
--expected-revision none --operation-id bind-ops-v1 \
--execute --format json
```

Once bound, `quota should-run` and `turn run-once` invoke the read-only
`decision_context.turn_context` hook (`capability_id=decision-context`) and deliver
a public-safe `decision_context_hook_view_v1` summary (`changed_source_ids`,
`alerted_source_ids`, `uncovered_p0_source_ids`, `freshness_counts`, advisory
recall health, and bounded follow-up commands) into `work_context.sources`.
Private file paths, cursors, and source bodies never enter the hook receipt or
turn packet, and turn-start observations never commit cursors. While bound,
read-only CLI commands (`inspect-profile`, `source-manifest`, `prepare-evidence`,
`recall-context`, `capture-status`) can omit `--profile` (and `--cursor-state` /
`--spool`) to resolve the bound private locators in-process. Use `hook unbind`
with the current `--expected-revision` to retire the binding and invalidate
cached turn assumptions.

## Relationship To Other Capabilities

| Capability | Primary question | Relationship |
Expand Down
31 changes: 31 additions & 0 deletions loopx/capabilities/decision_context/README.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ exact-read 完整度和未覆盖的 P0 source 投影为公开安全的回执。`
| `capture.py` | opt-in 的 source-reference capture 与 `capture-status` |
| `capture_recovery.py` | 保留引用的 capture 诊断与恢复 |
| `extension_provider.py` | 由扩展交付的 advisory context provider(`decision_context_advisory_provider_v0`) |
| `turn_start_hook.py` | 显式启用的本机 Agent turn-start 钩子绑定与公开安全的新鲜度/变更视图 |
| `architecture.py` | 能力合同的 `architecture` 读回 |
| `catalog_entry.py` | 能力 catalog 记录 |
| `cli.py` | 所有 `loopx decision-context` 子命令及其渲染 |
Expand Down Expand Up @@ -455,6 +456,36 @@ provider 读取失败会更新 `last_checked_at` 并累加 `failure_streak`,
已删除的 checkout)、最后一次 tick 失败、spool 丢失,或记录中的来源陈旧/持续失败时告警。
主动退役的 host 需删除其记录。

### 显式绑定本机 Turn-Start Hook

`quota should-run` 与 `turn run-once` 上的 Decision Context 钩子**默认关闭**:未绑定时不做任何
provider 或 RPC 调用。操作者可通过 `<runtime-root>/decision-context/agent-bindings/`
下的事务型本机绑定存储,为已注册的 `(goal_id, agent_id)` 显式绑定既有私有 profile:

```bash
loopx decision-context hook read \
--goal-id <goal-id> --agent-id <agent-id> --format json

loopx decision-context hook bind \
--goal-id <goal-id> --agent-id <agent-id> \
--profile <private-profile.json> \
[--cursor-state <reviewed-cursors.json>] \
[--spool <private-capture.sqlite>] \
[--mode prepare_evidence|source_manifest|capture_status] \
--expected-revision none --operation-id bind-ops-v1 \
--execute --format json
```

绑定生效后,`quota should-run` 与 `turn run-once` 会执行只读的
`decision_context.turn_context` 钩子(`capability_id=decision-context`),向
`work_context.sources` 注入公开安全的 `decision_context_hook_view_v1` 视图(包含
`changed_source_ids`、`alerted_source_ids`、`uncovered_p0_source_ids`、
`freshness_counts`、advisory recall 状态及有界后续命令)。私有路径、游标与信源正文
绝不进入钩子回执或轮次数据包,且轮次启动观察绝不推进审阅游标。绑定处于激活态时,只读 CLI
(`inspect-profile`、`source-manifest`、`prepare-evidence`、`recall-context`、
`capture-status`)可省略 `--profile`(及 `--cursor-state` / `--spool`)并在进程内解析已绑定私有路径。
停用时用当前 `--expected-revision` 执行 `hook unbind` 退役绑定并使旧缓存失效。

## 与其他能力的关系

| 能力 | 核心问题 | 与 Decision Context 的关系 |
Expand Down
Loading
Loading