Skip to content

feat(assistant): retain bounded discovery records and feedback - #6728

Open
sunrioa wants to merge 33 commits into
apache:rust-previewfrom
sunrioa:codex/feat-rust-discovery-records
Open

sunrioa wants to merge 33 commits into
apache:rust-previewfrom
sunrioa:codex/feat-rust-discovery-records

Conversation

@sunrioa

@sunrioa sunrioa commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

Summary

Refs #6716. Depends on #6724.

Fresh discovery Sessions avoid accumulating the entire investigation history, but they also need a way to recover previous progress, corrections and notification decisions. Otherwise, later investigations can repeat work or overlook user feedback.

Add DiscoveryMemory using the existing scheduler KV store. Investigations retain their outcomes and checkpoints, while the Bot can link corrections, notification decisions and user feedback to the original investigation.

  • Give each new worker up to three short record previews, with explicit truncation and references for reading the complete material. Queries support text filtering, related records and pagination, including continuation after an empty filtered page.
  • Commit investigation records together with settlement. Preserve unfinished checkpoints after failed execution, and discard checkpoints from cancelled investigations.
  • Allow SendUser and sleep to record a discovery decision in the same call. Notification records require an actual outbox message; retries reuse its identity.
  • Link feedback to an actual user message, retaining access to its original text and quotes. Add optional quotes to send, including quote-only and steering input, and update the generated SDK contracts.
  • Scope shared records to the Bot’s source boundary. Changed workspace permissions or revoked Recall access cannot be bypassed through discovery memory.

The investigating worker still submits findings directly to the Bot, which decides whether to call SendUser. This adds no separate judgement Session.

This implements the shared-record and feedback portion of A2/A3 in #6716. Event-triggered discovery remains follow-up work.

Verification

Local macOS verification using Rust 1.98.0 and Node 26.13.0.

Check Result
Agent Native, Agent API, Agent Facts and Scheduler library suites 467 passed, 0 failed; four existing manual/opt-in tests skipped
Final discovery-record regression rerun 7 passed
Generated SDK schemas and SDK/product TypeScript checks Passed
Rust formatting, Biome, ASF headers and whitespace checks Passed
Dependency-license policy and generated inventory Passed
Clippy Passed with three existing warnings in unchanged files

Integration tests use the real Host and local model fixtures. Coverage includes fresh-Session continuation, restart recovery, complete decision reasons, paginated quoted feedback, steering, cancellation, failed-investigation progress, permission and Recall revocation, and notification retry deduplication.

The final publication-retry adjustment was covered by the focused seven-test rerun. Windows validation, desktop E2E and live-provider evaluation were not performed.

AI use

  • No generative tool made a substantive contribution
  • Generative tooling made a substantive contribution

Tool(s) and scope: OpenAI Codex assisted with implementation, regression tests, local verification and this description. The implementation commit includes a Generated-by: OpenAI Codex trailer.

Checklist

  • Tests cover the change and fail without it
  • Format, typecheck and the affected suites pass locally

Does this PR entail a change in behavior?

  • Yes — described under Summary above
  • No
简体中文

概述

关联 #6716,依赖 #6724。

每轮新建调查 Session 可以避免持续累积完整调查历史,但也需要恢复此前进度、修正和通知决策的途径,否则后续调查可能重复工作,或忽略用户反馈。

通过现有调度器 KV 存储增加 DiscoveryMemory。调查保存结果与进度检查点,Bot 可以将修正、通知决策和用户反馈关联到原始调查。

  • 每个新 worker 最多携带三条简短记录预览,明确标记截断,并提供完整内容的读取入口。查询支持文本筛选、关联记录和分页;筛选结果为空时,也会保留后续读取入口。
  • 调查记录与结算一起提交。执行失败时保留未完成的调查进度,取消调查时舍弃暂存进度。
  • SendUser 和 sleep 可以在同一次调用中记录发现处理决策。通知记录必须关联实际存在的 outbox 消息,重试复用原消息身份。
  • 反馈关联到真实用户消息,并保留原文和引用的读取入口。为 send 增加可选 quotes 字段,支持只有引用的消息及 steering 输入,同步更新生成的 SDK 契约。
  • 共享记录受 Bot 的来源权限边界约束。工作区权限变化或 Recall 授权撤销后,不能通过调查记忆绕过限制。

调查 worker 仍直接将发现提交给 Bot,由 Bot 决定是否调用 SendUser,没有增加独立的判断 Session。

本次实现 #6716 中 A2/A3 的共享记录与反馈部分。事件触发的快速发现留在后续阶段。

验证

本地使用 macOS、Rust 1.98.0 和 Node 26.13.0 验证。

检查 结果
Agent Native、Agent API、Agent Facts 和 Scheduler 库套件 467 项通过、0 项失败;四项既有手工/需显式启用的测试跳过
最终共享记录定向回归复跑 7 项通过
生成的 SDK Schema、SDK/产品 TypeScript 检查 通过
Rust 格式、Biome、ASF 文件头及空白检查 通过
依赖许可证策略与生成清单 通过
Clippy 通过;未修改文件中保留三条既有告警

集成测试使用真实 Host 和本地模型夹具,覆盖新 Session 接续、重启恢复、完整决策理由、引用反馈分页、steering、取消、失败调查进度、权限和 Recall 撤销,以及通知重试去重。

最后的发送重试调整通过七项定向测试复验。尚未执行 Windows 验证、桌面 E2E 或真实供应商评估。

AI 使用说明

OpenAI Codex 协助完成实现、回归测试、本地验证及本说明起草。实现提交包含 Generated-by: OpenAI Codex 标记。

检查清单

  • 测试覆盖本次改动,缺少相应实现时无法通过
  • 格式、类型检查和受影响套件在本地通过

本 PR 存在行为变化,已在概述中说明。

Add opt-in discovery schedules using fresh read-only worker Sessions and
explicit report or no_report settlement through the existing Bot path.
Preserve original execution identities across restart and Host handoff.

Refs: apache#6716
Generated-by: OpenAI Codex
Keep cancellation durable across resume and service disablement, and
settle only the original investigation Turn. Recheck report authority
at admission and restrict Recall to the enabled built-in implementation.
Preserve uncertain result writes and allow approved inactive plans to resume.

Generated-by: OpenAI Codex
Share scoped investigation outcomes and checkpoints across fresh workers using
the existing scheduler store. Keep complete reasons and source references
available through bounded queries and explicit continuation.

Link corrections and feedback to the original investigation and immutable
user input, including quoted and steered messages. Record notification
decisions in SendUser or sleep without an extra model step, retaining outbox
identity and uncertain-write semantics.

Generated-by: OpenAI Codex
@liugddx

liugddx commented Nov 10, 2026

Copy link
Copy Markdown
Member

Blocking CI issue on the current head (c230b1b98cf9ac9c8e4bf4fec332e8ffec7a84df):

  • native-windows fails terminal::desktop_new_session::desktop_file_gestures_preserve_drafts_and_stage_an_image (observed Null instead of the expected draft).
  • root-tests cli slice 2 times out in terminal::keyboard::editor_copy_and_undo_precede_interrupt_and_ctrl_c_requires_confirming_the_current_run after about 72 seconds.

These failures are in existing desktop/keyboard paths, so it is not yet clear whether they are regressions from this PR or flaky/environment failures. Please rerun and document the diagnosis (or provide a justified waiver); until the required checks are green, this PR remains blocked from merge.

@liugddx

liugddx commented Nov 10, 2026

Copy link
Copy Markdown
Member

Code-level review follow-up:

I traced the DiscoveryMemory write path (records.rs memory_append/discovery_memory) and the discovery settlement path (discovery.rs settle_discovery). The record, active-job deletion, completion marker, and outcome record are assembled into one storage batch with a head CAS, and decision writes use deterministic receipt keys. I did not find a confirmed P0/P1/P2 correctness defect in these paths.

The merge-relevant gap is coverage of the failure cases around that design. Please add or point to tests for:

  • an OutcomeUnknown after the batch commits, followed by scheduler restart/retry;
  • concurrent DiscoveryMemory append attempts and head-revision conflict recovery;
  • Bot notification admission succeeding but the subsequent Notified decision receipt being uncertain;
  • scope changes (permissions/binding/Recall boundary) between the worker's investigation and Bot feedback/notification.

The current red Windows/CLI checks remain a separate merge blocker.

@github-actions github-actions Bot added the effort/XXL Over 2500 readable lines label Nov 10, 2026
Exercise committed but unacknowledged settlement, uncertain notification receipts, concurrent memory writes, and project relocation with real storage and a test-only fault seam.

Generated-by: OpenAI Codex
Reconcile discovery jobs, feedback and bounded records with the durable Run and queue contracts introduced by apache#6713. Port the Host regressions to the current fixture and preserve unknown-effect cleanup semantics.

Generated-by: OpenAI Codex
Sync rust-preview through apache#6740, retaining its archive and WebSocket recovery fixes. Handle scheduler revision conflicts and wait for original Run cleanup in the discovery fixtures.

Generated-by: OpenAI Codex
Retain always-visible controls when rebuilding the authorized Run catalog, and calculate continuation replay evidence from the discovered tool subset. Keep replay signature validation and current tool authorization unchanged.

Exercise Bot controls with tool discovery enabled; the existing desktop continuation regression covers failed-Run continuation without duplicate input.

Generated-by: OpenAI Codex
sunrioa added a commit to sunrioa/maka that referenced this pull request Nov 10, 2026
Integrate apache#6728 and keep desktop discovery status, publication provenance and quoted feedback on the current Agent execution and queue contracts. Obsolete fixture coverage will be carried by the current Host and journal tests.

Generated-by: OpenAI Codex
Integrate the durable Agent execution API, retain the A1 read-only investigation scope, and retract revoked pending reports before recovery consumers start. Port behavior coverage to the current real Host harness.

Generated-by: OpenAI Codex
Preserve shared discovery records and feedback while synchronizing the current durable Agent runtime. Carry the recovered-report authorization checks and their real Host regressions into A2.

Generated-by: OpenAI Codex
Include the latest upstream UI changes and regenerate the dependency inventory after the upstream native graph changes.

Generated-by: OpenAI Codex
Carry the current rust-preview synchronization while retaining the recovered-report authority checks and shared-memory regression coverage.

Generated-by: OpenAI Codex
Finish each simulated model step before awaiting steering. Verify that Stop targets the current Run while an accepted followup executes once and the next draft stays intact. Keep the existing input, queue, and timeout checks.

Generated-by: OpenAI Codex
Sync current rust-preview while retaining the recovered-report authorization boundary. Box the new legacy-compaction projection at its entrypoint to bound the debug poll stack, and keep the notification recovery fixture pinned to its original busy Run.

Generated-by: OpenAI Codex
Carry the verified A1 recovery boundary, bounded projection stack, and existing desktop steering fixture correction into the shared-memory layer.

Generated-by: OpenAI Codex
Acquire the existing child handle before the five-second pipe-drain wait. This separates PowerShell fixture startup from drain timing and preserves cleanup when the wait fails; production process behavior and the drain bound are unchanged.

Generated-by: OpenAI Codex
The queue consumer uses try_lock for Goal admission, so an enqueue wake can be consumed while the producer still owns the gate. Notify after releasing it when the persisted schedule still has ready work; keep the existing authorization and ordering checks.

Generated-by: OpenAI Codex
Carry the shared Goal wake and Windows process fixture corrections without changing discovery permissions or memory semantics.

Generated-by: OpenAI Codex
Withdraw independent engine, Goal, Bot admission, inventory and platform-test repairs. Keep discovery recovery and authorization coverage, and narrow fixture cleanup to report delivery.

Generated-by: OpenAI Codex
Inherit the narrowed A1 scope and remove independent engine and continuation repairs. Preserve memory, feedback and uncertain-commit coverage, with discovery-only tool admission.

Generated-by: OpenAI Codex
Retain both discovery and upstream recovery endpoints in the model test fixture.

Generated-by: OpenAI Codex
Keep discovery target checks and upstream completion placement during background admission. Retain the Bot controls and discovery regression fixtures.

Generated-by: OpenAI Codex
Keep quote feedback and discovery permissions while retaining upstream completion placement and live Bot tool visibility. Regenerate the SDK from the merged runtime contracts.

Generated-by: OpenAI Codex
Sync rust-preview and keep Bot worker notifications out of the interactive Stop cut. The recovery fixture finishes its independent worker turn before restarting the Host so the original report is still verified exactly once.

Generated-by: OpenAI Codex
Read the investigation plan directly in restore and tool admission, and fold ordinary Session tool visibility into the existing approval test.

Generated-by: OpenAI Codex
Preserve quoted input alongside rust-preview interrupt handling and retain the project fixture needed for feedback scope.

Generated-by: OpenAI Codex
Keep Session ordering and record commits intact. Reuse the existing proposal fixture for tool visibility and keep the real concurrent append and settlement test in place of an artificial competing writer.

Generated-by: OpenAI Codex
Continue accepting the old receipt shape while avoiding a second durable copy of the worker report.

Generated-by: OpenAI Codex
Keep the memory append and settlement receipt in the same atomic write.

Generated-by: OpenAI Codex
@sunrioa
sunrioa marked this pull request as ready for review November 12, 2026 10:04

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

effort/XXL Over 2500 readable lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants