Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
90 changes: 90 additions & 0 deletions desktop/VALIDATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -2676,3 +2676,93 @@ installed-platform acceptance remain separate requirements.
连接模式均通过。原生协议模块和业务断言保持不变;本机验收将 Server 启动就绪等待设为 60 秒,
不代表默认启动预算通过,也不构成启动性能承诺。该记录不替代安装后 GUI、原生凭据持久化、
Windows/macOS、数据库升级、签名或正式发行验收。

## Task stop reason contract protocol qualification

`sqlite-task-stop-reason-0b434770-v1` qualifies all twelve Desktop protocol operations against
Server source `0b43477001e3453a79b310b40fc3e3e7e648c2a6`. Its OpenAPI contract adds the optional
Task Outcome stop reason; the Desktop operation set and runtime behavior are unchanged.

- Normalized OpenAPI SHA-256: `34cc6572321296c6d67d2a8ca1dffd93d8ebb187a54af8f6dcdb5cd489a0926c`.
- Wheel: `powercontext-1.5.1.dev129+g0b4347700-py3-none-any.whl`.
- Wheel SHA-256: `f572a91a6796d645c6545eaaa8278a2c4b1598b83fa8392df754e187277ab490`.
- Native debug probe SHA-256: `584859ac181e7abe9d6fc84e69c9d8993446837788c630280c0780744fd4f023`.

All 738 packaged runtime files match the recorded Git source byte for byte, with no missing or
extra runtime files. The wheel was built from the clean Server commit before Desktop generation
and qualification changes. The native probe was built from that commit with the regenerated
Desktop contract and new bundled profile present as working-tree changes, using the product
Cargo lock and Rust 1.95.0, without `ci-fixtures`.

On 2026-11-10, macOS 26.5.1 ARM64 and Python 3.13.15 passed all four modes in the unchanged
`desktop/tests/real_server.py`: anonymous loopback, static Bearer, HTTPS with explicit CA/base
path, and enforced Provider access. Each case reports `bundled product records` qualification
through the ordinary product ConnectionManager. Checks cover discovery, Scope selection,
statistics, Memory save/search/exact revision reads, committed writes with lost responses
without replay, and independent Server survival after client exit. Provider mode also checks
Principal changes, same-identity revocation, scoped authorization, and 51 same-title Scopes.
Statistics usage is controlled fixture input, not an external model-provider execution claim.

The source verification, exact wheel, native build log, probe identity and real-Server report
are retained under ignored `desktop/.artifacts/issue-2544/`. Historical qualification records
retain their exact source, contract, artifact identities and operation sets. This run qualifies
the observed local SQLite protocol, not installed WebView behavior, native credential persistence,
other operating systems, external databases, production deployment, or release acceptance.
The Desktop probe exercises its existing operations; the new stop reason's recording and
readback are covered by the separate Work/HTTP SQLite tests, not by a Desktop UI flow.

Reproduce against the recorded Server source and artifact:

```sh
pnpm --dir desktop generate
cargo build --locked --manifest-path desktop/src-tauri/Cargo.toml --example server_probe
# The harness requires exactly this wheel under desktop/.artifacts/server-wheel/.
uv run --no-sync python desktop/tests/real_server.py \
--product-qualification sqlite-task-stop-reason-0b434770-v1
cargo test --locked --manifest-path desktop/src-tauri/Cargo.toml \
--test session bundled_product_qualification_covers_every_desktop_operation
```

## Task stop reason merged contract protocol qualification

`sqlite-task-stop-reason-4cb70619-v1` qualifies all thirteen bundled Desktop protocol operations
against Server source `4cb7061913f5484c3b848551c1d570e59bab846f`, including connection identity.

- Normalized OpenAPI SHA-256: `e1ff2e3ad1d6a09a9288c4c66e111a54c4979026e29806ff70543988b8e29220`.
- Wheel: `powercontext-1.5.2.dev5+g4cb706191-py3-none-any.whl`.
- Wheel SHA-256: `e4c0d3f7549fe28abfd09669c3dc53ded66d79a4711b1e89da93611717b64a76`.
- Native debug probe SHA-256: `6685c55fac1cacf45292757767283851f242b2cdfbfe6f4a16d73795ad150844`.

All 750 packaged runtime files match the clean recorded Git source byte for byte, with no missing,
extra or changed runtime files. The wheel uses its actual VCS development version. The native probe
was built with the product Cargo lock and Rust 1.95.0, without `ci-fixtures`. Its working tree contained
the added bundled profile; no runtime implementation or harness assertion was substituted.

On 2026-11-10, macOS 26.5.1 ARM64 and Python 3.13.15 passed all four modes of the unchanged
`desktop/tests/real_server.py`: anonymous loopback, static Bearer, HTTPS with explicit CA/base path,
and enforced Provider access. The ordinary product ConnectionManager selected the bundled profile.
Checks cover discovery and connection identity, exact Scope selection, statistics, Memory save/search/
exact revision reads, committed writes with lost responses without replay, independent Server survival,
Principal changes, same-identity revocation, scoped authorization and 51 same-title Scopes.
Statistics usage is controlled fixture input, not an external model-provider execution claim.

The exact wheel, source verification, native build log, probe identity and real-Server report are retained
under ignored `desktop/.artifacts/issue-2544-merged/`. Historical profiles retain their original identities,
operation sets and evidence. The complete contract gate passes 67 tests; the focused stop-reason Work/HTTP
suite passes 23 tests. Desktop generation, TypeScript checking and native bundled-operation coverage pass.
This record qualifies local SQLite protocol behavior, not installed WebView behavior, native credential
persistence, other operating systems, external databases, production deployment or release acceptance.
Stop-reason recording and readback use the Work/HTTP tests; Desktop has no outcome UI flow.

Reproduce using the recorded wheel and the client containing this bundled profile:

```sh
pnpm --dir desktop generate:check
cargo build --locked --manifest-path desktop/src-tauri/Cargo.toml --example server_probe
uv run --no-sync python desktop/tests/real_server.py \
--product-qualification sqlite-task-stop-reason-4cb70619-v1 \
--wheel desktop/.artifacts/issue-2544-merged/server-wheel/powercontext-1.5.2.dev5+g4cb706191-py3-none-any.whl
cargo test --locked --manifest-path desktop/src-tauri/Cargo.toml \
--test session bundled_product_qualification_covers_every_desktop_operation
make contract-test
```
43 changes: 43 additions & 0 deletions desktop/src-tauri/src/connections/compatibility.json
Original file line number Diff line number Diff line change
Expand Up @@ -1268,5 +1268,48 @@
"search_memory"
],
"evidence": "desktop/VALIDATION.md#server-bcc0d93a-v151-protocol-qualification"
},
{
"id": "sqlite-task-stop-reason-0b434770-v1",
"serverCommit": "0b43477001e3453a79b310b40fc3e3e7e648c2a6",
"contractSha256": "34cc6572321296c6d67d2a8ca1dffd93d8ebb187a54af8f6dcdb5cd489a0926c",
"artifactSha256": "f572a91a6796d645c6545eaaa8278a2c4b1598b83fa8392df754e187277ab490",
"operations": [
"get_access_principal",
"get_artifact_revision",
"get_capabilities",
"get_default_scope",
"get_liveness",
"get_readiness",
"get_scope",
"get_server_info",
"get_stats",
"list_scopes",
"remember_memory",
"search_memory"
],
"evidence": "desktop/VALIDATION.md#task-stop-reason-contract-protocol-qualification"
},
{
"id": "sqlite-task-stop-reason-4cb70619-v1",
"serverCommit": "4cb7061913f5484c3b848551c1d570e59bab846f",
"contractSha256": "e1ff2e3ad1d6a09a9288c4c66e111a54c4979026e29806ff70543988b8e29220",
"artifactSha256": "e4c0d3f7549fe28abfd09669c3dc53ded66d79a4711b1e89da93611717b64a76",
"operations": [
"get_access_principal",
"get_artifact_revision",
"get_capabilities",
"get_connection_identity",
"get_default_scope",
"get_liveness",
"get_readiness",
"get_scope",
"get_server_info",
"get_stats",
"list_scopes",
"remember_memory",
"search_memory"
],
"evidence": "desktop/VALIDATION.md#task-stop-reason-merged-contract-protocol-qualification"
}
]
2 changes: 1 addition & 1 deletion desktop/src-tauri/src/transport/operations.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"contractSha256": "93b733bda25ab4db0e883f63a2571334c7c1dfb3af68a18b330384fd344c2d4c",
"contractSha256": "e1ff2e3ad1d6a09a9288c4c66e111a54c4979026e29806ff70543988b8e29220",
"operations": {
"get_liveness": {
"method": "GET",
Expand Down
13 changes: 13 additions & 0 deletions desktop/ui/src/generated/api.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3937,6 +3937,17 @@ export interface components {
basis: components["schemas"]["WorkClaimBasis"];
evidence: components["schemas"]["HandoffCitation"][];
};
/** @enum {string} */
TaskStopReasonKind: "safety" | "authorization" | "capability" | "missing_evidence" | "scope";
/** @description A caller-recorded judgement about why continuing would have been wrong. It grants no permission, approval, or retry budget and is not success or failure evidence. */
TaskStopReason: {
kind: components["schemas"]["TaskStopReasonKind"];
/** @description The circumstance under which continuing would have been wrong; must be trimmed. */
condition: string;
basis: components["schemas"]["WorkClaimBasis"];
/** @description Use [] with declared. verified requires exact previously returned same-scope citations. */
evidence: components["schemas"]["HandoffCitation"][];
};
TaskOutcome: {
/** @enum {string} */
schema: "powercontext.task-outcome.v1";
Expand All @@ -3946,6 +3957,8 @@ export interface components {
status: components["schemas"]["TaskOutcomeStatus"];
summary: string;
handoff_receipt_ref?: components["schemas"]["SourceReference"];
/** @description Optional deliberate-stop reason, accepted only with blocked or cancelled status. */
stop_reason?: components["schemas"]["TaskStopReason"];
observations: components["schemas"]["WorkClaim"][];
checks: components["schemas"]["TaskCheck"][];
produced_artifacts: components["schemas"]["ArtifactReference"][];
Expand Down
2 changes: 1 addition & 1 deletion desktop/ui/src/generated/operations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/

// Generated from openapi/powercontext.yaml. Do not edit.
export const contractSha256 = "93b733bda25ab4db0e883f63a2571334c7c1dfb3af68a18b330384fd344c2d4c";
export const contractSha256 = "e1ff2e3ad1d6a09a9288c4c66e111a54c4979026e29806ff70543988b8e29220";
export const operations = {
"get_liveness": {
"method": "GET",
Expand Down
13 changes: 13 additions & 0 deletions docs/en/docs/develop/interfaces.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,19 @@ unlinked Outcome in the same scope does not cover it. The operation stores a `ta
Experience incubation can inspect, but does not generate or approve an Experience by itself. Integrations call it only
at a real completion or interruption boundary, not solely because a prompt, Stop event, or Session ended.

For `blocked` or `cancelled`, an optional `stop_reason` records why continuing would have been wrong. Its `kind` is
`safety`, `authorization`, `capability`, `missing_evidence`, or `scope`; `condition` is nonblank, trimmed text.
Like claims, its `basis` is `declared` with empty `evidence`, or `verified` with exact same-scope citations
(at most 31). Other outcome statuses reject a reason. Omitting it preserves the existing stored representation
and content digest, including for older `blocked` outcomes; historical records gain no inferred reason.
Read the structured reason from the outcome Source's `content` through `get_source`. The continuity projection
counts it as an outcome with its original status and does not expose the reason or classify it as success or
failure. The reason itself is excluded from recurrence failure evidence and `avoided` derivation; existing
observation and check rules still apply. It records a judgement without establishing that stopping was correct,
granting permission, approval, or a retry budget, or ensuring that another agent will honour it.
OpenClaw's `powercontext_task_outcome` and Pi's `pc_task_outcome` expose the same optional field and forward it
to the Server, which owns status and evidence validation.

Claims and checks are either `declared` with no evidence or `verified` with exact same-scope citations. A readable
citation proves identity and availability, not freshness. Current instructions, live workspace state, capabilities,
and authorization still take precedence over all Work and Handoff records.
Expand Down
11 changes: 11 additions & 0 deletions docs/zh/docs/develop/interfaces.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,17 @@ create_work_contract
Outcome 不会覆盖它。该 operation 保存现有 Experience 孵化可读取的 `task-outcome` Source,但不会自行生成或批准
Experience。Integration 只应在真实完成或中断边界调用它,不能仅因 Prompt、Stop 或 Session 结束而调用。

`blocked` 或 `cancelled` 可以用可选的 `stop_reason` 记录继续执行会有问题的原因。`kind` 只能是 `safety`、
`authorization`、`capability`、`missing_evidence` 或 `scope`;`condition` 必须是非空且首尾无空白的文字。
与 Claim 一样,`basis` 为 `declared` 时 `evidence` 必须为空,为 `verified` 时必须有同 scope 的精确 citation,
最多 31 条。其他 outcome 状态不接受原因。省略此字段会保留现有存储表示和内容摘要哈希,也适用于旧的 `blocked`
outcome;历史记录不会被推断或补写原因。通过 `get_source` 读取 outcome Source 的 `content` 即可取得结构化原因。
Continuity 投影按原状态将其计为一条 outcome,不展示原因,也不将其分类为成功或失败。原因本身不进入 recurrence
失败证据或 `avoided` 推导;已有 observation 和 check 规则继续适用。它只记录判断,不能证明停止是正确的,
不能授予权限、批准或重试预算,也不保证后续 Agent 会遵循该原因。
OpenClaw 的 `powercontext_task_outcome` 和 Pi 的 `pc_task_outcome` 均暴露同一可选字段并透传至 Server,
状态和证据规则由 Server 统一校验。

Claim 和 check 要么是没有 evidence 的 `declared`,要么是拥有同 scope 精确 citation 的 `verified`。Citation 可读只证明
身份和可用性,不证明事实仍然新鲜。当前指令、实时 workspace、能力和授权始终优先于 Work 与 Handoff 记录。

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,57 @@ describe("PowerContext work tools", () => {
});
});

it.each([
["safety", "blocked", "declared"],
["authorization", "blocked", "verified"],
["capability", "cancelled", "verified"],
["missing_evidence", "blocked", "verified"],
["scope", "cancelled", "declared"],
])("exposes and forwards a %s stop reason unchanged", async (kind, status, basis) => {
const { deps, requests } = fixture();
const tool = createTaskOutcomeTool(context, deps)!;
const reason = {
kind,
condition: "继续执行需要先确认前提条件。",
basis,
evidence: basis === "declared" ? [] : [
{ kind: "source", source_ref: { name: "content", source_id: "evidence-1" } },
{ kind: "artifact", artifact_ref: { family: "handoff", artifact_id: "h-1", revision: 2 } },
],
};
const outcome = {
schema: "powercontext.task-outcome.v1",
trust: "untrusted_observation",
objective: "Attempt an action.",
status,
summary: "The caller deliberately stopped.",
observations: [{ text: "The caller reported stopping.", basis: "declared", evidence: [] }],
checks: [],
produced_artifacts: [],
remaining_work: [],
};
const params = { source_id: "outcome-1", outcome: { ...outcome, stop_reason: reason } };

expect(tool.parameters.properties.outcome.properties.stop_reason).toBeDefined();
expect(Value.Check(tool.parameters, params)).toBe(true);
expect(Value.Check(tool.parameters, { outcome })).toBe(true);
expect(Value.Check(tool.parameters, { outcome: { ...outcome, stop_reason: null } })).toBe(true);
for (const invalid of [
{ ...reason, kind: "refused" },
{ ...reason, condition: " " },
{ ...reason, evidence: Array(32).fill({ kind: "source", source_ref: { name: "content", source_id: "evidence-1" } }) },
]) {
expect(Value.Check(tool.parameters, { outcome: { ...outcome, stop_reason: invalid } })).toBe(false);
}

await tool.execute("call-stop", params);

expect(requests.find(({ path }) => path === "/v1/work/outcomes/record")).toEqual({
path: "/v1/work/outcomes/record",
body: { scope_id: "scope-1", ...params },
});
});

it("treats nullable handoff inputs as omitted optional fields", async () => {
const { deps, requests } = fixture();
const revision = { family: "handoff", artifact_id: "h-1", revision: 1 };
Expand Down
15 changes: 14 additions & 1 deletion integrations/openclaw/plugins/memory-powercontext/src/work.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,18 @@ const taskCheck = Type.Object({
basis: Type.Union([Type.Literal("declared"), Type.Literal("verified")]),
evidence: Type.Array(handoffCitation, { maxItems: 32 }),
}, { additionalProperties: false });
const taskStopReason = Type.Object({
kind: Type.Union([
Type.Literal("safety"),
Type.Literal("authorization"),
Type.Literal("capability"),
Type.Literal("missing_evidence"),
Type.Literal("scope"),
]),
condition: Type.String({ minLength: 1, maxLength: 8192, pattern: ".*\\S.*", description: "The circumstance under which continuing would have been wrong; must be trimmed." }),
basis: Type.Union([Type.Literal("declared"), Type.Literal("verified")]),
evidence: Type.Array(handoffCitation, { maxItems: 31, description: "Use [] with declared. verified requires exact previously returned same-scope citations." }),
}, { additionalProperties: false });
const taskOutcome = Type.Object({
schema: Type.Literal("powercontext.task-outcome.v1"),
trust: Type.Literal("untrusted_observation"),
Expand All @@ -113,6 +125,7 @@ const taskOutcome = Type.Object({
]),
summary: workText,
handoff_receipt_ref: Type.Optional(Type.Union([sourceReference, Type.Null()])),
stop_reason: Type.Optional(Type.Union([taskStopReason, Type.Null()], { description: "Optional deliberate-stop reason, accepted only with blocked or cancelled status. Records a judgement without granting permission, approval, or retry budget." })),
observations: Type.Array(workClaim, { minItems: 1, maxItems: 64 }),
checks: Type.Array(taskCheck, { maxItems: 64 }),
produced_artifacts: Type.Array(artifactReference, { maxItems: 32 }),
Expand Down Expand Up @@ -448,7 +461,7 @@ export function createTaskOutcomeTool(ctx: OpenClawPluginToolContext, deps: Tool
name: POWERCONTEXT_TASK_OUTCOME_TOOL,
label: "Record Task Outcome",
description:
"Record the exact outcome, checks, produced artifacts, and remaining work at a completion or interruption boundary. Provide schema powercontext.task-outcome.v1, trust untrusted_observation, objective, status, summary, at least one observation, and all result arrays.",
"Record the exact outcome, checks, produced artifacts, and remaining work at a completion or interruption boundary. Provide schema powercontext.task-outcome.v1, trust untrusted_observation, objective, status, summary, at least one observation, and all result arrays. For blocked or cancelled, optionally record stop_reason with kind, condition, basis, and evidence; declared requires [], verified requires exact same-scope citations. A reason grants no authority.",
parameters: Type.Object({
outcome: taskOutcome,
source_id: Type.Optional(Type.String({ minLength: 1, maxLength: 256 })),
Expand Down
Loading
Loading