Repository navigation
feat(work): record structured task stop reasons - #2580
Conversation
| maxItems: 32 | ||
| items: | ||
| $ref: "#/components/schemas/HandoffCitation" | ||
| TaskStopReasonKind: |
There was a problem hiding this comment.
[P1] 新增 OpenAPI schema 后 Desktop 契约身份失效,contract-test 在这个 head 上是红的
openapi/powercontext.yaml 新增了 TaskStopReason/TaskStopReasonKind,并给 TaskOutcome 加了 stop_reason,文件摘要随之从 de74d806343998ba… 变为 34cc6572321296c6…(sha256(openapi 字节,CRLF→LF))。本 PR 没有改 desktop/ui/src/generated/operations.ts 与 desktop/src-tauri/src/transport/operations.json,两者仍写 de74d806343998ba…。
后果(实测,非推断):
- exact head 镜像内
pytest tests/test_desktop_contract.py tests/builtin/test_task_stop_reason.py tests/builtin/runtime/test_task_stop_reason.py→2 failed, 22 passed,两处失败都是Stale Desktop contract identity ... run 'pnpm --dir desktop generate'。 - CI job 129775659065(
CI preflight):make contract-test→2 failed, 65 passed,make: *** [Makefile:168: contract-test] Error 1,退出码 2。 - 该 head 的 check-run 目前是 1 success / 3 failure / 34 skipped:preflight 失败后其余 suite 全部 skip,因此
stop_reason的写入、回读与续跑在所有 CI 套件上都没有验收证据。我能给出的行为证据只有本地 sqlite(tests/builtin/*/test_task_stop_reason.py、tests/e2e/test_runtime_server.py -k stop_reason,24 项通过,其中 4 个非blocked/cancelled状态返回 422 且GET该 source 为 404,即未落盘)。
建议的处理顺序:
- 先
pnpm --dir desktop generate,把两个 manifest 的contractSha256更新为 head 摘要。这步是机械的,能立刻消掉这两个失败。 - 再补一个
contractSha256等于新摘要的desktop/src-tauri/src/connections/compatibility.jsonprofile,否则test_bundled_desktop_contract_has_a_qualified_business_profile会接替变红。这才是正文 HOLD 指的是 macOS 资格记录(可参考 fix(api): declare 409 for artifact replacement #2553 的sqlite-artifact-conflict-8dc98e49-v1+desktop/VALIDATION.md条目做法)。
在 1、2 完成前 preflight 保持红,这个 PR 无法进入合并判定。正文把它记录为"等维护者指示"不改变门禁状态,也不产生验收证据。
补充核对(通过,无需处理):TaskOutcomeStatus 与 WorkClaimBasis 两个枚举与 merge-base 69b2d7e2 逐字一致;stop_reason 没有进入 avoided 推导(builtin/artifacts/experience/recurrence.py::avoided_refs 只读 observations 与 checks),与文档表述一致;builtin/runtime/application.py::_outcome_evidence 把 stop_reason.evidence 纳入引用可用性校验,verified 的 citation 确实会被验证,declared 带 evidence 会被 pydantic 校验拒绝。
There was a problem hiding this comment.
已在 head 61f8213c 复核,这个问题不再成立:
openapi/powercontext.yaml归一化(CRLF→LF)后 SHA-256 =e1ff2e3ad1d6a09a9288c4c66e111a54c4979026e29806ff70543988b8e29220;desktop/src-tauri/src/transport/operations.json的contractSha256同为e1ff2e3a…;desktop/src-tauri/src/connections/compatibility.json新增条目sqlite-task-stop-reason-4cb70619-v1的contractSha256也是e1ff2e3a…。
三处一致,说明本 head 的契约身份已登记并自洽,之前「新 schema 未登记导致 contract-test 红」的前提消失。
仍待确认:commits/61f8213c/check-runs 只返回 7 个 check run(另有 1 项 tests (3.11, unit) in_progress,其余 desktop 相关 job 尚未产生),因此 desktop 契约 job 在这条提交上的最终结论无法判定,本次不据此给出合并结论。
hidb4ai
left a comment
There was a problem hiding this comment.
Reviewed c786e47606d65484ea06b8eb343e248539b0d229. I found no new correctness blocker in the stop-reason implementation. The Desktop contract identity/qualification mismatch reported earlier is fixed at this head.
Merge readiness is still blocked by CI:
- OpenDAL package fails on
pydantic-discarded-extra-argumentatintegrations/opendal/src/powercontext_connector_opendal/source.py:160. The same diagnostic occurs on basecc752d8a; it is outside this PR's changes. - OceanBase harness acceptance has replay evidence showing
ImportError: cannot import name 'text_block' from 'acp'before workload execution. SQLite harness acceptance is also red. These failures do not establish a defect in stop-reason persistence, but the CI gate still needs to pass before merging.
There are no new database tables, migrations, HTTP paths, or operation IDs. However, TaskStopReason, TaskStopReasonKind, and TaskOutcome.stop_reason extend the public SDK/HTTP/MCP/tool contracts, so this review remains COMMENT under the requested no-new-public-interfaces approval condition.
hireview001
left a comment
There was a problem hiding this comment.
- Resolve merge conflicts with the target branch.
- CI failed: CI result (failure).
- CI failed: dsh-package (failure).
- CI failed: Main (failure). Failed steps: dsh-package / Test built plugin in the real DSH runtime; CI result / Require successful selected checks.
hireview001
left a comment
There was a problem hiding this comment.
- Resolve merge conflicts with the target branch.
Resolve the conflict with the standalone seekdb maintenance identity (oceanbase#2585) and the 30 other commits that landed since the previous merge, including the processing status projection (oceanbase#2568) and the structured task stop reasons (oceanbase#2580). - `release/upgrade-support.json`: keep the rationale sentence added upstream for the seekdb maintenance identity, append the sentence about this branch's code-organization changes, and recompute the persistence digest after formatting. The generated table and index DDL for all 76 tables is identical to master on the SQLite and MySQL dialects. Follow the moves and removals into code that arrived with the merge: - `tests/builtin/runtime/test_context_reuse.py` imports access control from `powercontext.builtin.authz`. - The `scheduler_path` argument is dropped from the new calls in `test_artifact_merge_experience.py` and `test_dashboard.py`. - The startup-deadline test in `test_real_experience_skill_harness.py` stops passing a scheduler database path to `_start_server` and `_start_configured_server`, which no longer take one. It passed the path positionally, so a search for the `scheduler_path=` keyword could not find it. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Which issue or RFC does this PR close?
Closes #2544. Tracking: #2542.
Rationale for this change
A deliberately interrupted attempt can already use
blockedorcancelled, but its reason can only be recorded as prose. Add a typed, optionalstop_reasonso a caller can recover the recorded judgement from the outcome Source without parsing its summary.What changes are included in this PR?
TaskStopReasonwith a closedkind(safety,authorization,capability,missing_evidence,scope), a nonblank trimmedcondition,basis, and at most 31 exact citations.blockedandcancelled. Require evidence forverified; reject evidence fordeclared. Resolve supplied citations through the existing same-scope evidence validation before writing.powercontext_task_outcomeand Pi'spc_task_outcome, with bounded reason schemas and guidance on status, evidence, and authority. Forward the complete reason to the Server without duplicating its domain validators.blockedrecords. No stored-record migration or inferred reasons.0b434770, preserving every historical qualification record.TaskOutcomeStatusandWorkContinuityEventStatusare textually unchanged againsted8902b2.WorkContinuityEventandbuiltin/work/continuity.pyare unchanged. The OpenAPITaskOutcome.requiredlist andadditionalProperties: falseare unchanged.Are there any user-facing changes?
HTTP, MCP tool schemas derived from the public contract, Python client requests, and the OpenClaw/Pi outcome tools can carry the optional reason. The exact outcome Source remains the supported read path. The record preserves a judgement; it does not establish that stopping was correct, grant permission, approval, or retry budget, or guarantee that another agent will honour it.
Non-blocking capability boundaries:
source_idviaget_source, or caller-side scanning.continuity()does not expose the reason, andListSourcesRequesthas no kind/status filter. Server-side discovery of previous stops by class is not delivered here; it remains the read-surface question in [Tracking] repeated-trial work-continuity gaps — research registry (case: three-session stereotaxic task) #2542 finding G.avoidedderivation. Existing observation/check rules still apply: a verified observation with exact evidence under ablockedoutcome can still qualify as failure evidence, and qualifying check results retain their existing behavior. This PR does not exempt the entire outcome from recurrence processing. Continuity parses the new field but emits only the existing status and counts the record as an outcome, without a success/failure classification. Experience incubation can inspect the captured Source content; this PR adds no reason-based policy, ledger item, statistics counter, or retry path.How was this change tested?
blocked/cancelledrecording and readbacked8902b2; OpenAPI required list and closed-object rule unchangedmake api-generate;scripts/generate_api.py --check;scripts/generate_js_operations.py --checkmake contract-test, including Desktop identity and qualified business profile checkssqlite-task-stop-reason-0b434770-v1; native profile-coverage test, generator check, and typecheckCommands and results:
The new host-tool tests validate the published schemas and requests against stubbed HTTP responses; Pi also uses its native argument validator. They do not establish a live host → real Server → persistence workflow for the new field.
Desktop qualification uses the ordinary native product ConnectionManager against the exact built Server wheel in anonymous loopback, static Bearer, HTTPS with explicit CA/base path, and enforced Provider modes. All four modes passed. The new record binds the Server commit, normalized OpenAPI digest, wheel digest, and twelve-operation set; source verification confirms all 738 packaged runtime files match
0b434770byte for byte.desktop/VALIDATION.mdrecords the native probe identity and environment. This verifies local SQLite protocol compatibility, not installed UI, native credential persistence, other operating systems, external databases, or release readiness.AI usage statement
OpenAI Codex (GPT-6) assisted with implementation, tests, bilingual documentation, and local validation. Review and acceptance remain with the maintainers.