From fa29e175f66c3421460c32320926096240f6f8d0 Mon Sep 17 00:00:00 2001 From: "lusendong.6789" Date: Thu, 19 Nov 2026 18:22:38 +0800 Subject: [PATCH] fix(explore): retain execution feedback in product readers Signed-off-by: lusendong.6789 Co-authored-by: TRAE CLI --- .../execution-feedback-browser-smoke.mjs | 84 +++++ apps/presentation/dashboard/src/data/chat.ts | 2 + .../fixtures/execution-feedback-readback.json | 331 ++++++++++++++++++ .../goal-explore-results.tsx | 3 +- .../goal-research-history.tsx | 16 +- .../work-yardstick-readback.tsx | 21 ++ ...hanism-convergence-and-learning-loop-v0.md | 14 + ...-convergence-and-learning-loop-v0.zh-CN.md | 9 + .../research-history-backend.py | 3 +- .../research-history.mjs | 4 +- .../presentation/explore_record_values.py | 31 +- tests/test_chat_explore_results.py | 71 ++++ 12 files changed, 569 insertions(+), 20 deletions(-) create mode 100644 apps/presentation/dashboard/smoke/execution-feedback-browser-smoke.mjs create mode 100644 apps/presentation/dashboard/src/data/fixtures/execution-feedback-readback.json diff --git a/apps/presentation/dashboard/smoke/execution-feedback-browser-smoke.mjs b/apps/presentation/dashboard/smoke/execution-feedback-browser-smoke.mjs new file mode 100644 index 0000000000..825d84b190 --- /dev/null +++ b/apps/presentation/dashboard/smoke/execution-feedback-browser-smoke.mjs @@ -0,0 +1,84 @@ +// The same native Explore records cross HTTP, client decoding and both readers. +// Fault injection changes only transport; source state and authority stay intact. +import assert from "node:assert/strict"; +import {mkdir} from "node:fs/promises"; +import {resolve} from "node:path"; +import {startHistoryOwner} from "../../../../examples/personal-workspace-browser/research-history.mjs"; +import {launchBrowser, loadPlaywright} from "../../../../examples/dashboard-browser-smoke-support.mjs"; + +const root = resolve(import.meta.dirname, "../../../.."); +const output = resolve(root, ".local/feedback-qualification"); +await mkdir(output, {recursive: true}); +const missing = process.env.LOOPX_FEEDBACK_EXPECT_MISSING === "1"; +const browser = await launchBrowser(loadPlaywright().chromium); +try { + for (const provider of ["file", "sqlite"]) { + const owner = await startHistoryOwner(resolve(root, "apps/presentation/dashboard/src/data/fixtures/execution-feedback-readback.json"), + {provider, assetsDir: process.env.LOOPX_FEEDBACK_ASSETS}); + const page = await browser.newPage({viewport: {width: 1280, height: 900}, locale: "zh-CN"}); + let corrupt = false; + try { + await page.addInitScript(() => localStorage.setItem("loopx-pw-locale", "zh-CN")); + await page.route("**/api/chat/explore-results?*", async route => { + if (!corrupt || new URL(route.request().url()).searchParams.get("view") !== "findings") return route.continue(); + const response = await route.fetch(), packet = await response.json(); + const changed = packet.items.find(item => item.execution_observation); + changed.execution_observation.result_candidate_sha256 = "b".repeat(64); + return route.fulfill({response, json: packet}); + }); + const url = new URL("/chat/", owner.base); + url.search = new URLSearchParams({goalId: "feedback-readback", view: "research", research_goal: "feedback-readback", + research_reading: "history", research_node: "method-choice", research_finding: "result-11"}); + await page.goto(url.href); + const saved = page.locator(".research-saved-evidence"); + await saved.locator(":scope > summary").click(); + const evidence = saved.locator(".goal-explore-results"); + const reader = evidence.locator(".goal-team-result-reader"); + await reader.waitFor(); + const observation = reader.locator("details").filter({has: page.locator("summary", {hasText: "实际执行与资源观测"})}); + if (missing) { + assert.equal(await observation.count(), 0, "Baseline saved findings discarded execution observations"); + await reader.scrollIntoViewIfNeeded(); + await page.screenshot({path: resolve(output, `before-${provider}-desktop.png`), animations: "disabled"}); + continue; + } + assert.equal(await observation.count(), 1); + assert.equal(await observation.getAttribute("open"), null, "Execution detail stays on demand"); + await observation.locator(":scope > summary").click(); + const text = await observation.innerText(); + assert.match(text, /broad-search → targeted-check/); + assert.match(text, /counterexample ruled out/); + assert.match(text, /12\.5 \/ 60/); + assert.match(text, /未测量/); + assert.match(text, /input-v1/); + assert.match(text, /artifact:negative-result/); + assert.match(text, /不等于方法有效/); + await observation.scrollIntoViewIfNeeded(); + await observation.screenshot({path: resolve(output, `after-${provider}-detail.png`), animations: "disabled"}); + await page.screenshot({path: resolve(output, `after-${provider}-desktop.png`), animations: "disabled"}); + await page.setViewportSize({width: 390, height: 844}); + await observation.scrollIntoViewIfNeeded(); + assert(await page.evaluate(() => document.documentElement.scrollWidth <= innerWidth + 1), "Narrow reader has no horizontal overflow"); + await page.screenshot({path: resolve(output, `after-${provider}-mobile.png`), animations: "disabled"}); + await evidence.getByRole("combobox", {name: "选择结论"}).selectOption("result-0"); + assert.equal(await observation.count(), 0, "Missing observation adds no invented execution block"); + await evidence.getByRole("combobox", {name: "选择结论"}).selectOption("result-11"); + corrupt = true; + await evidence.getByRole("button", {name: "刷新证据"}).click(); + await evidence.getByRole("alert").waitFor(); + assert.equal(await reader.count(), 0, "Wrong-candidate evidence cannot leave old facts visible"); + corrupt = false; + await evidence.getByRole("button", {name: "刷新证据"}).click(); + await reader.waitFor(); + assert.equal(await observation.count(), 1, "Valid source recovers in place"); + const history = page.locator(".research-history-detail"); + const historicObservation = history.locator("details").filter({has: page.locator("summary", {hasText: "实际执行与资源观测"})}); + await historicObservation.first().locator(":scope > summary").click(); + assert.match(await historicObservation.first().innerText(), /broad-search → targeted-check/, "Append-only history shares the same reader"); + const readback = await (await fetch(`${owner.base}/fixture/readback`)).json(); + assert.equal(readback.source_unchanged, true); + assert.equal(readback.mutation_attempts, 0); + console.log(`${provider}: HTTP -> saved/history reader, missing/rejected/recovery, desktop/narrow PASS`); + } finally {await page.close(); await owner.close();} + } +} finally {await browser.close();} diff --git a/apps/presentation/dashboard/src/data/chat.ts b/apps/presentation/dashboard/src/data/chat.ts index c3db5a2c22..a9b90ca17f 100644 --- a/apps/presentation/dashboard/src/data/chat.ts +++ b/apps/presentation/dashboard/src/data/chat.ts @@ -1,3 +1,4 @@ +import {normalizeExploreExecutionObservation} from "../../../../../loopx/control_plane/capabilities/explore_execution_observation.js"; import {normalizeWorkYardstickCapture} from "../../../../../loopx/control_plane/work_items/yardstick_decision.js"; import {sourceReadApiUrl} from "./local-status-query"; import type {OracleEvidence} from "./goal-acceptance-observation"; @@ -3353,6 +3354,7 @@ const exploreResultPageSchema = z.object({ evidence_refs: z.array(z.string()), last_updated_at: z.string(), measurements: z.unknown().transform(value => normalizeExploreMeasurements(value)).optional(), measurement_error: z.string().optional(), + execution_observation: z.unknown().transform(observation => normalizeExploreExecutionObservation({observation})).optional(), work_yardstick: z.unknown().transform(capture => normalizeWorkYardstickCapture({capture})).optional(), linked_todos_available: z.boolean().optional(), linked_todos: z.array(z.object({ diff --git a/apps/presentation/dashboard/src/data/fixtures/execution-feedback-readback.json b/apps/presentation/dashboard/src/data/fixtures/execution-feedback-readback.json new file mode 100644 index 0000000000..74e2c7121f --- /dev/null +++ b/apps/presentation/dashboard/src/data/fixtures/execution-feedback-readback.json @@ -0,0 +1,331 @@ +{ + "goal_id": "feedback-readback", + "display_name": "Method feedback", + "events": [ + { + "schema_version": "loopx_explore_result_event_v0", + "goal_id": "feedback-readback", + "event_kind": "node", + "recorded_at": "2026-01-01T00:00:00Z", + "title": "Compare a method and its actual execution", + "boundary": { + "raw_task_text_recorded": false, + "raw_logs_recorded": false, + "raw_trajectory_recorded": false, + "raw_session_transcript_recorded": false, + "credential_values_recorded": false, + "absolute_paths_recorded": false + }, + "summary": "Read the recorded method, deviation and result; acceptance stays independent.", + "result_id": "method-choice", + "node_kind": "area", + "status": "open", + "event_id": "8b0bf5d2d23f9d6f" + }, + { + "schema_version": "loopx_explore_result_event_v0", + "goal_id": "feedback-readback", + "event_kind": "finding", + "recorded_at": "2026-01-01T00:01:00Z", + "title": "Observation 0", + "boundary": { + "raw_task_text_recorded": false, + "raw_logs_recorded": false, + "raw_trajectory_recorded": false, + "raw_session_transcript_recorded": false, + "credential_values_recorded": false, + "absolute_paths_recorded": false + }, + "summary": "A negative result remains negative. The same long scope boundary remains readable. The same long scope boundary remains readable. The same long scope boundary remains readable. The same long scope boundary remains readable. The same long scope boundary remains readable. The same long scope boundary remains readable. The same long scope boundary remains readable. The same long scope boundary remains readable.", + "agent_id": "reader-agent", + "evidence_refs": [ + "artifact:negative-result" + ], + "result_id": "result-0", + "node_id": "method-choice", + "status": "refuted", + "event_id": "fe63a49692bf13ca" + }, + { + "schema_version": "loopx_explore_result_event_v0", + "goal_id": "feedback-readback", + "event_kind": "finding", + "recorded_at": "2026-01-01T00:02:00Z", + "title": "Observation 1", + "boundary": { + "raw_task_text_recorded": false, + "raw_logs_recorded": false, + "raw_trajectory_recorded": false, + "raw_session_transcript_recorded": false, + "credential_values_recorded": false, + "absolute_paths_recorded": false + }, + "summary": "A negative result remains negative. The same long scope boundary remains readable. The same long scope boundary remains readable. The same long scope boundary remains readable. The same long scope boundary remains readable. The same long scope boundary remains readable. The same long scope boundary remains readable. The same long scope boundary remains readable. The same long scope boundary remains readable.", + "agent_id": "reader-agent", + "evidence_refs": [ + "artifact:negative-result" + ], + "result_id": "result-1", + "node_id": "method-choice", + "status": "refuted", + "event_id": "4a83ea109c7241d1" + }, + { + "schema_version": "loopx_explore_result_event_v0", + "goal_id": "feedback-readback", + "event_kind": "finding", + "recorded_at": "2026-01-01T00:03:00Z", + "title": "Observation 2", + "boundary": { + "raw_task_text_recorded": false, + "raw_logs_recorded": false, + "raw_trajectory_recorded": false, + "raw_session_transcript_recorded": false, + "credential_values_recorded": false, + "absolute_paths_recorded": false + }, + "summary": "A negative result remains negative. The same long scope boundary remains readable. The same long scope boundary remains readable. The same long scope boundary remains readable. The same long scope boundary remains readable. The same long scope boundary remains readable. The same long scope boundary remains readable. The same long scope boundary remains readable. The same long scope boundary remains readable.", + "agent_id": "reader-agent", + "evidence_refs": [ + "artifact:negative-result" + ], + "result_id": "result-2", + "node_id": "method-choice", + "status": "refuted", + "event_id": "28ab31ca7421ba95" + }, + { + "schema_version": "loopx_explore_result_event_v0", + "goal_id": "feedback-readback", + "event_kind": "finding", + "recorded_at": "2026-01-01T00:04:00Z", + "title": "Observation 3", + "boundary": { + "raw_task_text_recorded": false, + "raw_logs_recorded": false, + "raw_trajectory_recorded": false, + "raw_session_transcript_recorded": false, + "credential_values_recorded": false, + "absolute_paths_recorded": false + }, + "summary": "A negative result remains negative. The same long scope boundary remains readable. The same long scope boundary remains readable. The same long scope boundary remains readable. The same long scope boundary remains readable. The same long scope boundary remains readable. The same long scope boundary remains readable. The same long scope boundary remains readable. The same long scope boundary remains readable.", + "agent_id": "reader-agent", + "evidence_refs": [ + "artifact:negative-result" + ], + "result_id": "result-3", + "node_id": "method-choice", + "status": "refuted", + "event_id": "42dd1e21cfdfd704" + }, + { + "schema_version": "loopx_explore_result_event_v0", + "goal_id": "feedback-readback", + "event_kind": "finding", + "recorded_at": "2026-01-01T00:05:00Z", + "title": "Observation 4", + "boundary": { + "raw_task_text_recorded": false, + "raw_logs_recorded": false, + "raw_trajectory_recorded": false, + "raw_session_transcript_recorded": false, + "credential_values_recorded": false, + "absolute_paths_recorded": false + }, + "summary": "A negative result remains negative. The same long scope boundary remains readable. The same long scope boundary remains readable. The same long scope boundary remains readable. The same long scope boundary remains readable. The same long scope boundary remains readable. The same long scope boundary remains readable. The same long scope boundary remains readable. The same long scope boundary remains readable.", + "agent_id": "reader-agent", + "evidence_refs": [ + "artifact:negative-result" + ], + "result_id": "result-4", + "node_id": "method-choice", + "status": "refuted", + "event_id": "f6e4e52febefe975" + }, + { + "schema_version": "loopx_explore_result_event_v0", + "goal_id": "feedback-readback", + "event_kind": "finding", + "recorded_at": "2026-01-01T00:06:00Z", + "title": "Observation 5", + "boundary": { + "raw_task_text_recorded": false, + "raw_logs_recorded": false, + "raw_trajectory_recorded": false, + "raw_session_transcript_recorded": false, + "credential_values_recorded": false, + "absolute_paths_recorded": false + }, + "summary": "A negative result remains negative. The same long scope boundary remains readable. The same long scope boundary remains readable. The same long scope boundary remains readable. The same long scope boundary remains readable. The same long scope boundary remains readable. The same long scope boundary remains readable. The same long scope boundary remains readable. The same long scope boundary remains readable.", + "agent_id": "reader-agent", + "evidence_refs": [ + "artifact:negative-result" + ], + "result_id": "result-5", + "node_id": "method-choice", + "status": "refuted", + "event_id": "437d3b06c356a3e4" + }, + { + "schema_version": "loopx_explore_result_event_v0", + "goal_id": "feedback-readback", + "event_kind": "finding", + "recorded_at": "2026-01-01T00:07:00Z", + "title": "Observation 6", + "boundary": { + "raw_task_text_recorded": false, + "raw_logs_recorded": false, + "raw_trajectory_recorded": false, + "raw_session_transcript_recorded": false, + "credential_values_recorded": false, + "absolute_paths_recorded": false + }, + "summary": "A negative result remains negative. The same long scope boundary remains readable. The same long scope boundary remains readable. The same long scope boundary remains readable. The same long scope boundary remains readable. The same long scope boundary remains readable. The same long scope boundary remains readable. The same long scope boundary remains readable. The same long scope boundary remains readable.", + "agent_id": "reader-agent", + "evidence_refs": [ + "artifact:negative-result" + ], + "result_id": "result-6", + "node_id": "method-choice", + "status": "refuted", + "event_id": "e351ef2cb007f74e" + }, + { + "schema_version": "loopx_explore_result_event_v0", + "goal_id": "feedback-readback", + "event_kind": "finding", + "recorded_at": "2026-01-01T00:08:00Z", + "title": "Observation 7", + "boundary": { + "raw_task_text_recorded": false, + "raw_logs_recorded": false, + "raw_trajectory_recorded": false, + "raw_session_transcript_recorded": false, + "credential_values_recorded": false, + "absolute_paths_recorded": false + }, + "summary": "A negative result remains negative. The same long scope boundary remains readable. The same long scope boundary remains readable. The same long scope boundary remains readable. The same long scope boundary remains readable. The same long scope boundary remains readable. The same long scope boundary remains readable. The same long scope boundary remains readable. The same long scope boundary remains readable.", + "agent_id": "reader-agent", + "evidence_refs": [ + "artifact:negative-result" + ], + "result_id": "result-7", + "node_id": "method-choice", + "status": "refuted", + "event_id": "8517c1d3e3b15aea" + }, + { + "schema_version": "loopx_explore_result_event_v0", + "goal_id": "feedback-readback", + "event_kind": "finding", + "recorded_at": "2026-01-01T00:09:00Z", + "title": "Observation 8", + "boundary": { + "raw_task_text_recorded": false, + "raw_logs_recorded": false, + "raw_trajectory_recorded": false, + "raw_session_transcript_recorded": false, + "credential_values_recorded": false, + "absolute_paths_recorded": false + }, + "summary": "A negative result remains negative. The same long scope boundary remains readable. The same long scope boundary remains readable. The same long scope boundary remains readable. The same long scope boundary remains readable. The same long scope boundary remains readable. The same long scope boundary remains readable. The same long scope boundary remains readable. The same long scope boundary remains readable.", + "agent_id": "reader-agent", + "evidence_refs": [ + "artifact:negative-result" + ], + "result_id": "result-8", + "node_id": "method-choice", + "status": "refuted", + "event_id": "bf7613aaa94c7698" + }, + { + "schema_version": "loopx_explore_result_event_v0", + "goal_id": "feedback-readback", + "event_kind": "finding", + "recorded_at": "2026-01-01T00:10:00Z", + "title": "Observation 9", + "boundary": { + "raw_task_text_recorded": false, + "raw_logs_recorded": false, + "raw_trajectory_recorded": false, + "raw_session_transcript_recorded": false, + "credential_values_recorded": false, + "absolute_paths_recorded": false + }, + "summary": "A negative result remains negative. The same long scope boundary remains readable. The same long scope boundary remains readable. The same long scope boundary remains readable. The same long scope boundary remains readable. The same long scope boundary remains readable. The same long scope boundary remains readable. The same long scope boundary remains readable. The same long scope boundary remains readable.", + "agent_id": "reader-agent", + "evidence_refs": [ + "artifact:negative-result" + ], + "result_id": "result-9", + "node_id": "method-choice", + "status": "refuted", + "event_id": "e2e4af3af1a5b077" + }, + { + "schema_version": "loopx_explore_result_event_v0", + "goal_id": "feedback-readback", + "event_kind": "finding", + "recorded_at": "2026-01-01T00:11:00Z", + "title": "Observation 10", + "boundary": { + "raw_task_text_recorded": false, + "raw_logs_recorded": false, + "raw_trajectory_recorded": false, + "raw_session_transcript_recorded": false, + "credential_values_recorded": false, + "absolute_paths_recorded": false + }, + "summary": "A negative result remains negative. The same long scope boundary remains readable. The same long scope boundary remains readable. The same long scope boundary remains readable. The same long scope boundary remains readable. The same long scope boundary remains readable. The same long scope boundary remains readable. The same long scope boundary remains readable. The same long scope boundary remains readable.", + "agent_id": "reader-agent", + "evidence_refs": [ + "artifact:negative-result" + ], + "result_id": "result-10", + "node_id": "method-choice", + "status": "refuted", + "event_id": "9025be02e1a9ab01" + }, + { + "schema_version": "loopx_explore_result_event_v0", + "goal_id": "feedback-readback", + "event_kind": "finding", + "recorded_at": "2026-01-01T00:12:00Z", + "title": "Recorded method change", + "boundary": { + "raw_task_text_recorded": false, + "raw_logs_recorded": false, + "raw_trajectory_recorded": false, + "raw_session_transcript_recorded": false, + "credential_values_recorded": false, + "absolute_paths_recorded": false + }, + "summary": "A negative result remains negative. The same long scope boundary remains readable. The same long scope boundary remains readable. The same long scope boundary remains readable. The same long scope boundary remains readable. The same long scope boundary remains readable. The same long scope boundary remains readable. The same long scope boundary remains readable. The same long scope boundary remains readable.", + "agent_id": "reader-agent", + "evidence_refs": [ + "artifact:negative-result" + ], + "result_id": "result-11", + "node_id": "method-choice", + "status": "refuted", + "execution_observation": { + "candidate_sha256": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "change_reason": "The counterexample ruled out the planned search.", + "elapsed_seconds": 12.5, + "evidence_refs": [ + "artifact:negative-result" + ], + "executed_method_id": "targeted-check", + "input_revision": "input-v1", + "limit_seconds": 60, + "planned_method_id": "broad-search", + "result_candidate_sha256": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "result_ref": "artifact:negative-result", + "schema_version": "explore_execution_observation_v0", + "search_iterations": null, + "stop_reason": null + }, + "event_id": "686464f745c278cf" + } + ] +} diff --git a/apps/presentation/dashboard/src/features/personal-workspace/goal-explore-results.tsx b/apps/presentation/dashboard/src/features/personal-workspace/goal-explore-results.tsx index f0ba8725ff..6efb434937 100644 --- a/apps/presentation/dashboard/src/features/personal-workspace/goal-explore-results.tsx +++ b/apps/presentation/dashboard/src/features/personal-workspace/goal-explore-results.tsx @@ -1,4 +1,4 @@ -import {WorkYardstickReadback} from "./work-yardstick-readback"; +import {ExecutionObservationReadback, WorkYardstickReadback} from "./work-yardstick-readback"; import {exploreFindingCopy} from "./explore-finding-copy"; import {useEffect, useRef, useState} from "react"; import {AlertTriangle, ChevronRight, RefreshCw} from "lucide-react"; @@ -128,6 +128,7 @@ export function GoalExploreResults({goalId, originalGoalId = goalId, zh, active
    {sections.decision![key].map((text, index) =>
  • {text}
  • )}
: null)} : null} :

{selected.summary}

} + {selected.execution_observation ? : null} {selected.work_yardstick ? : null}
{zh ? "来源与范围" : "Sources and scope"}
{zh ? "记录时间" : "Recorded at"}
diff --git a/apps/presentation/dashboard/src/features/personal-workspace/goal-research-history.tsx b/apps/presentation/dashboard/src/features/personal-workspace/goal-research-history.tsx index 7bb83d289b..598424f17b 100644 --- a/apps/presentation/dashboard/src/features/personal-workspace/goal-research-history.tsx +++ b/apps/presentation/dashboard/src/features/personal-workspace/goal-research-history.tsx @@ -1,4 +1,4 @@ -import {WorkYardstickReadback} from "./work-yardstick-readback"; +import {ExecutionObservationReadback, WorkYardstickReadback} from "./work-yardstick-readback"; import {GoalSourceStrategies, useGoalStrategyLocation} from "./goal-source-strategies"; import {exploreFindingCopy} from "./explore-finding-copy"; import {AlertCircle, ArrowLeft, ArrowRight, Circle, CircleHelp, FlaskConical, GitBranch, RefreshCw, Search} from "lucide-react"; @@ -181,19 +181,7 @@ export function GoalResearchHistory({goalId, originalGoalId = goalId, preferHist
:

{finding.summary}

; }; const findingBody = (finding: ExploreHistoryEvent) => { - const execution = finding.execution_observation; - const measured = (value: unknown) => value === null ? (zh ? "未测量" : "Not measured") : String(value); - return <>{finding.measurements ? : null}{findingNarrative(finding)}{finding.work_yardstick ? : null}{execution ?
{zh ? "实际执行与资源观测" : "Execution and resource observations"}

{zh ? "来源记录的执行观测;不等于方法有效或当前候选已通过验收。" : "Source-recorded execution observations; not proof of method benefit or current-candidate acceptance."}

-
-
{zh ? "计划方法 → 实际方法" : "Planned → executed method"}
{String(execution.planned_method_id)} → {String(execution.executed_method_id)}
- {execution.change_reason ? <>
{zh ? "改向原因" : "Reason for change"}
{String(execution.change_reason)}
: null} -
{zh ? "运行秒数 / 上限秒数" : "Elapsed / limit seconds"}
{measured(execution.elapsed_seconds)} / {measured(execution.limit_seconds)}
-
{zh ? "搜索次数" : "Search iterations"}
{measured(execution.search_iterations)}
-
{zh ? "结束原因" : "Termination reason"}
{measured(execution.stop_reason)}
-
{zh ? "执行候选 SHA-256" : "Executed candidate SHA-256"}
{String(execution.candidate_sha256)}
- {execution.result_ref ? <>
{zh ? "该候选的结果引用" : "Result for this candidate"}
{String(execution.result_ref)}
: null} -
-
: null}; + return <>{finding.measurements ? : null}{findingNarrative(finding)}{finding.work_yardstick ? : null}{finding.execution_observation ? : null}; }; const findingMeta = (finding: ExploreHistoryEvent) => {timeLabel(finding.recorded_at)} · {stateLabel(finding.status)}{finding.confidence !== null ? ` · ${zh ? "来源自报置信度" : "Source-reported confidence"} ${finding.confidence}` : ""}; const findingElement = (finding: ExploreHistoryEvent) => { diff --git a/apps/presentation/dashboard/src/features/personal-workspace/work-yardstick-readback.tsx b/apps/presentation/dashboard/src/features/personal-workspace/work-yardstick-readback.tsx index 017cc0b494..aa5108cd6c 100644 --- a/apps/presentation/dashboard/src/features/personal-workspace/work-yardstick-readback.tsx +++ b/apps/presentation/dashboard/src/features/personal-workspace/work-yardstick-readback.tsx @@ -22,3 +22,24 @@ export function WorkYardstickReadback({capture, zh}: {capture: WorkYardstickCapt

{zh ? "这是记录者的研究判断;代理有效性与成果验收仍需独立证据。" : "This records the author's research decision; proxy fidelity and outcome acceptance still require independent evidence."}

; } + +/** Both current findings and append-only history read the same recorded facts. */ +export function ExecutionObservationReadback({observation, zh}: { + observation: import("../../../../../../loopx/control_plane/runtime_decode.js").JsonObject; zh: boolean; +}) { + const measured = (value: unknown) => value === null ? (zh ? "未测量" : "Not measured") : String(value); + return
+ {zh ? "实际执行与资源观测" : "Execution and resource observations"} +
+
{zh ? "计划方法 → 实际方法" : "Planned → executed method"}
{String(observation.planned_method_id)} → {String(observation.executed_method_id)}
+ {observation.change_reason ? <>
{zh ? "改向原因" : "Reason for change"}
{String(observation.change_reason)}
: null} +
{zh ? "运行秒数 / 上限秒数" : "Elapsed / limit seconds"}
{measured(observation.elapsed_seconds)} / {measured(observation.limit_seconds)}
+
{zh ? "搜索次数" : "Search iterations"}
{measured(observation.search_iterations)}
+
{zh ? "结束原因" : "Termination reason"}
{measured(observation.stop_reason)}
+
{zh ? "输入版本" : "Input revision"}
{String(observation.input_revision)}
+
{zh ? "执行候选 SHA-256" : "Executed candidate SHA-256"}
{String(observation.candidate_sha256)}
+ {observation.result_ref ? <>
{zh ? "该候选的结果引用" : "Result for this candidate"}
{String(observation.result_ref)}
: null} +
+

{zh ? "来源记录的执行观测;不等于方法有效或当前候选已通过验收。" : "Source-recorded execution observations; not proof of method benefit or current-candidate acceptance."}

+
; +} diff --git a/docs/architecture/rfcs/mechanism-convergence-and-learning-loop-v0.md b/docs/architecture/rfcs/mechanism-convergence-and-learning-loop-v0.md index cecec7e793..407a5e0d06 100644 --- a/docs/architecture/rfcs/mechanism-convergence-and-learning-loop-v0.md +++ b/docs/architecture/rfcs/mechanism-convergence-and-learning-loop-v0.md @@ -335,6 +335,20 @@ read-only quota observation. It admits no ordinary host Turn. These service checks therefore do not qualify an ordinary PostgreSQL feedback Turn or justify adding another execution profile to this slice. +**Source checkpoint: product execution-observation readback (2026-11-19).** Saved +findings reuse Explore's execution-observation codec and retain the planned and +actual methods, deviation reason, candidate revision, costs and result reference. +The findings and history readers share one expandable view; the existing Lark +finding Summary presents the same recorded facts, keeping missing measurements +unknown. Findings without observations retain their existing display and +projection. Wrong-candidate result references are rejected, failed reads withhold +old contents, and valid sources recover in place. Isolated File/SQLite HTTP and +packaged desktop/narrow-browser checks qualify these paths without source-state +or execution-authority mutations. This delivers product transport and readback, +not model adoption or method benefit. Execution convergence, cross-task adoption, +prediction calibration and matched-budget outcomes remain open. Formal evaluation +does not block independent implementation or migration. + The first task needs an actual feedback or method-choice requirement. Reuse complete existing paths; real consumers must demonstrate gaps before repairing them rather than manufacturing a failure for the example. Experiments, training and procedural publication retain original authority. This document allocates neither another lane's quota nor a prescribed PR count. ## 12. Consequential choices to confirm diff --git a/docs/architecture/rfcs/mechanism-convergence-and-learning-loop-v0.zh-CN.md b/docs/architecture/rfcs/mechanism-convergence-and-learning-loop-v0.zh-CN.md index 500f003c4b..41f4423fa9 100644 --- a/docs/architecture/rfcs/mechanism-convergence-and-learning-loop-v0.zh-CN.md +++ b/docs/architecture/rfcs/mechanism-convergence-and-learning-loop-v0.zh-CN.md @@ -316,6 +316,15 @@ soft claim/hard lease 及历史反馈仅作上下文:保留独立验证的成 host Turn。因此这些服务检查不能取得普通 PostgreSQL 反馈 Turn 资格, 也不构成本切片新增执行 profile 的理由。 +**源码 checkpoint:产品执行观察读回(2026-11-19)。** 已保存结论现在复用 +Explore 的执行观察 codec,保留原方法、实际方法、改向原因、候选版本、成本和 +结果引用。结论页与历史页复用同一展开式读回;现有 Lark finding Summary 同步 +展示这些源事实,缺失测量保持未知。没有执行观察的结论保持原展示与投影,错误 +候选结果关联被拒绝,失效读取不能留下旧内容,有效来源可在原页面重试。 +隔离 File/SQLite HTTP 和打包浏览器检查覆盖这些路径及桌面/窄屏,读回不改变源 +状态或执行权限。这只交付产品传输与读回,不证明模型采用或方法收益;执行融合、 +跨任务采用、预测校准与可比预算结果仍开放。正式评测不阻塞独立的实现和迁移。 + 首个任务须确有反馈或方法选择需求。已有链完整时直接复用;有缺口时由真实消费者证明并修复,不为配合示例制造失败。运行实验、训练模型和发布过程各沿原权限,本文不占用其他 lane 配额或预设 PR 数。 ## 12. 待确认的关键选择 diff --git a/examples/personal-workspace-browser/research-history-backend.py b/examples/personal-workspace-browser/research-history-backend.py index 2e5cfac03b..c5b9daac45 100644 --- a/examples/personal-workspace-browser/research-history-backend.py +++ b/examples/personal-workspace-browser/research-history-backend.py @@ -48,6 +48,7 @@ def materialize_analysis(source_root: Path, analysis: dict) -> Path: def main(): parser = argparse.ArgumentParser(description=__doc__) parser.add_argument("--port", type=int, default=0) + parser.add_argument("--provider", choices=("file", "sqlite"), default="sqlite") parser.add_argument("--assets-dir", type=Path, help="Frozen packaged UI for before/after inspection.") parser.add_argument("--fixture", type=Path, action="append", help="Captured-event wrapper; repeat for independently selectable Goals.") @@ -92,7 +93,7 @@ def main(): log.parent.mkdir(parents=True) log.write_bytes("".join(json.dumps(event, ensure_ascii=False) + "\n" for event in capture["events"]).encode("utf-8")) initialize_canonical_authority(runtime, captured_goal, build_todo_runtime_shadow_projection( - goal_id=captured_goal, todos=capture.get("todos", []), handoff_mode="soft_claim"), state_path=state, provider="sqlite") + goal_id=captured_goal, todos=capture.get("todos", []), handoff_mode="soft_claim"), state_path=state, provider=args.provider) original.update({path: path.read_bytes() for path in (state, log)}) registry = root / "registry.json" registry.write_text(json.dumps({"schema_version": 1, "common_runtime_root": str(runtime), "goals": goals})) diff --git a/examples/personal-workspace-browser/research-history.mjs b/examples/personal-workspace-browser/research-history.mjs index 5a1d21abf3..bb1fb78a6d 100644 --- a/examples/personal-workspace-browser/research-history.mjs +++ b/examples/personal-workspace-browser/research-history.mjs @@ -94,11 +94,11 @@ function comparisonReadback() { return snapshot; } -export async function startHistoryOwner(fixture, {workspaceDirectory = false} = {}) { +export async function startHistoryOwner(fixture, {workspaceDirectory = false, provider = "sqlite", assetsDir} = {}) { const fixtures = Array.isArray(fixture) ? fixture : fixture ? [fixture] : []; const backendCommand = testPythonCommand(` import runpy -sys.argv = ${JSON.stringify(["examples/personal-workspace-browser/research-history-backend.py", ...fixtures.flatMap(path => ["--fixture", path]), ...(workspaceDirectory ? ["--workspace-directory"] : [])])} +sys.argv = ${JSON.stringify(["examples/personal-workspace-browser/research-history-backend.py", ...fixtures.flatMap(path => ["--fixture", path]), "--provider", provider, ...(assetsDir ? ["--assets-dir", assetsDir] : []), ...(workspaceDirectory ? ["--workspace-directory"] : [])])} runpy.run_path(sys.argv[0], run_name="__main__") `); const child = spawn(backendCommand.command, backendCommand.args, diff --git a/loopx/extensions/lark/presentation/explore_record_values.py b/loopx/extensions/lark/presentation/explore_record_values.py index f6577a2f3e..66be419650 100644 --- a/loopx/extensions/lark/presentation/explore_record_values.py +++ b/loopx/extensions/lark/presentation/explore_record_values.py @@ -63,7 +63,7 @@ def _finding_summary(finding: Mapping[str, Any]) -> str: summary = str(finding.get("summary") or "") capture = finding.get("work_yardstick") if not isinstance(capture, Mapping): - return summary + return "\n".join(part for part in (summary, _execution_summary(finding)) if part) # Projection only: the canonical event/typed owner has validated this # declaration. A Lark row does not upgrade it to acceptance or authority. decision = capture["decision"] @@ -78,7 +78,34 @@ def _finding_summary(finding: Mapping[str, Any]) -> str: if decision["counterevidence_refs"]: details.append("Proxy counterevidence: " + ", ".join(decision["counterevidence_refs"])) details.append("Recorded research decision; fidelity and acceptance remain independently assessed.") - return "\n".join([summary, *details]) + recorded = "\n".join([summary, *details]) + execution = _execution_summary(finding) + return recorded + ("\n" + execution if execution else "") + + +def _execution_summary(finding: Mapping[str, Any]) -> str: + observation = finding.get("execution_observation") + if not isinstance(observation, Mapping): + return "" + # These source facts were validated by Explore. Missing quantities remain + # unknown; the projection neither certifies adoption nor assesses utility. + def measured(field: str) -> str: + value = observation[field] + return "not measured" if value is None else str(value) + details = [ + f"Planned -> executed method: {observation['planned_method_id']} -> {observation['executed_method_id']}", + f"Elapsed / limit seconds: {measured('elapsed_seconds')} / {measured('limit_seconds')}", + f"Search iterations: {measured('search_iterations')}", + f"Termination reason: {measured('stop_reason')}", + f"Input revision: {observation['input_revision']}", + f"Executed candidate SHA-256: {observation['candidate_sha256']}", + ] + if observation.get("change_reason"): + details.append(f"Reason for change: {observation['change_reason']}") + if observation.get("result_ref"): + details.append(f"Result for this candidate: {observation['result_ref']}") + details.append("Source-recorded execution; method benefit and acceptance remain independently assessed.") + return "\n".join(details) def _finding_record_values(finding: Mapping[str, Any], *, goal_id: str, source_id: str) -> dict[str, Any]: diff --git a/tests/test_chat_explore_results.py b/tests/test_chat_explore_results.py index e77ed30250..6472f52c75 100644 --- a/tests/test_chat_explore_results.py +++ b/tests/test_chat_explore_results.py @@ -301,3 +301,74 @@ def observe(operation, params): server.shutdown() worker.join(timeout=5) server.server_close() + + +@pytest.mark.parametrize("provider", ["file", "sqlite"]) +def test_execution_feedback_survives_http_and_lark_readback_after_disable(tmp_path, monkeypatch, provider): + """Recorded method deviations remain visible without certifying benefit.""" + from tests.control_plane.canonical_authority_fixture import initialize_canonical_authority, isolate_sqlite_runtime + from loopx.control_plane.coordination.runtime_shadow import build_todo_runtime_shadow_projection + from loopx.extensions.lark.presentation.explore_record_values import _finding_record_values + + isolate_sqlite_runtime(tmp_path, monkeypatch) + state = tmp_path / "active.md" + state.write_text("# Read-only feedback\n") + runtime = tmp_path / "runtime" + registry = tmp_path / "registry.json" + registry.write_text(json.dumps({"common_runtime_root": str(runtime), "goals": [ + {"id": "feedback", "repo": str(tmp_path), "state_file": state.name}, + ]})) + initialize_canonical_authority(runtime, "feedback", build_todo_runtime_shadow_projection( + goal_id="feedback", todos=[], handoff_mode="soft_claim"), state_path=state, provider=provider) + observation = { + "schema_version": "explore_execution_observation_v0", "candidate_sha256": "a" * 64, + "input_revision": "input-v1", "planned_method_id": "broad-search", + "executed_method_id": "targeted-check", "change_reason": "A counterexample ruled out broad search.", + "elapsed_seconds": 12.5, "limit_seconds": 60, "search_iterations": None, "stop_reason": None, + "evidence_refs": ["artifact:negative-result"], "result_ref": "artifact:negative-result", + "result_candidate_sha256": "a" * 64, + } + log = explore_result_log_path(runtime, "feedback") + append_explore_result_event(log, build_explore_node_event( + goal_id="feedback", node_id="choice", title="Method choice")) + for finding_id, observed in (("plain", None), ("changed", observation)): + append_explore_result_event(log, build_explore_finding_event( + goal_id="feedback", node_id="choice", finding_id=finding_id, + title="Recorded negative result", summary="No measured improvement.", status="refuted", + execution_observation=observed, evidence_refs=["artifact:negative-result"])) + from loopx.control_plane.effect_runtime import EffectRuntimeRejected + with pytest.raises(EffectRuntimeRejected, match="executed candidate"): + build_explore_finding_event(goal_id="feedback", node_id="choice", finding_id="bad", + title="Wrong candidate", execution_observation={**observation, "result_candidate_sha256": "b" * 64}) + before = {path: path.read_bytes() for path in (log, state, registry)} + server = ChatHTTPServer(("127.0.0.1", 0), ChatRequestHandler) + server.registry_path, server.runtime_root_override, server.verbose = registry, None, False + worker = threading.Thread(target=server.serve_forever, daemon=True) + worker.start() + try: + # Explore is never activated: already saved evidence remains readable. + with urlopen(f"http://127.0.0.1:{server.server_port}/api/chat/explore-results?goal_id=feedback&view=findings") as response: + page = json.load(response) + changed = next(row for row in page["items"] if row["finding_id"] == "changed") + plain = next(row for row in page["items"] if row["finding_id"] == "plain") + assert changed["execution_observation"] == observation + assert changed["status"] == "refuted" + assert "execution_observation" not in plain + for row in (plain, changed): + lark = _finding_record_values(row, goal_id="feedback", source_id="fixture") + assert lark["Status"] == "refuted" + assert lark["LoopX Result ID"] == row["finding_id"] + if row is plain: + assert lark["Summary"] == "No measured improvement." + else: + assert "broad-search -> targeted-check" in lark["Summary"] + assert "12.5 / 60" in lark["Summary"] + assert "Search iterations: not measured" in lark["Summary"] + assert "Termination reason: not measured" in lark["Summary"] + assert "artifact:negative-result" in lark["Summary"] + assert "independently assessed" in lark["Summary"] + assert all(path.read_bytes() == contents for path, contents in before.items()) + finally: + server.shutdown() + worker.join(timeout=5) + server.server_close()