Skip to content

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

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

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

Conversation

@sunrioa

@sunrioa sunrioa commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Consolidated into #6730.

已收敛至 #6730。

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

@liugddx liugddx left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code review of head fd69101c7. I read the code only: nothing was built or run, and I did not look into the red Windows/CLI checks mentioned above.

Summary: 7 inline findings, 1 × P1 and 6 × P2. The most important is the Recall scope split between discovery workers and the Bot (records.rs), which silently breaks discovery{record} and feedback linking once Recall is turned on after approval. Two of the P2s concern the new quote-only send path leaking into code this PR doesn't touch (external executors, the queue).

Stack note: #6730 (head eb3758d29) is built on 9d1ca95f3 and does not contain fd69101c7, so findings anchored here (e.g. the list_discovery_memory loop) do not exist at #6730 as it stands. The two PRs need to be merged/rebased together. Desktop-side findings are in the #6730 review.


针对头提交 fd69101c7 的代码评审。只读了代码:没有构建、没有运行,也没有排查上面提到的 Windows / CLI 红色检查。

摘要: 共 7 条行内意见,1 条 P1、6 条 P2。最重要的是 discovery worker 与 Bot 之间的 Recall scope 不一致(records.rs):批准之后再打开 Recall,discovery{record} 和反馈关联会静默失效。其中两条 P2 是新增的「只有引用的 send」流入了本 PR 没改的代码(外部执行器、队列)。

栈关系: #6730(头 eb3758d29)基于 9d1ca95f3,不包含 fd69101c7,所以这里的部分问题(如 list_discovery_memory 的循环)在 #6730 当前版本里并不存在。两个 PR 合入前需要一起合并 / rebase。桌面端的问题见 #6730 的评审。

boundary_revision: config.boundary_revision,
binding: config.binding,
};
scope(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P1] Use one Recall boundary for worker writes and Bot reads

Workers write under job_scope(job) (line 528), which keys the scope on job.recall, frozen at approval. The Bot reads here under scope(&target, self.settings.recall && self.tools.contains("Recall")), i.e. the live setting. discovery_authorized only rejects job.recall && !settings.recall, so a plan approved with Recall off keeps running after the user turns Recall on. Workers then write under (target, false) while the Bot reads under (target, true): SendUser/sleep with discovery{record} fail with discovery_record_unavailable, list returns nothing, and feedback cannot link, until the plan is approved again.

Suggest deriving the Bot scope from the same frozen value as the worker's, or treating a Recall flip as a boundary change that revokes authorization and requires re-approval. Please add an off→on test.


[P1] Worker 写入与 Bot 读取应使用同一个 Recall 边界

Worker 写入用的是 job_scope(job)(第 528 行),scope 取批准时冻结的 job.recall;Bot 在这里读取用的是实时的 self.settings.recall && self.tools.contains("Recall")。discovery_authorized 只拒绝 job.recall && !settings.recall,所以在 Recall 关闭时批准的计划,在用户之后打开 Recall 后仍会继续运行。此时 worker 写在 (target, false),Bot 读的是 (target, true):带 discovery{record} 的 SendUser/sleep 会报 discovery_record_unavailable,list 返回空,反馈也无法关联,直到重新批准计划。

建议让 Bot 的 scope 与 worker 使用同一个冻结值,或把 Recall 开关变化视为边界变化(撤销授权、要求重新批准)。请补一个「关→开」的测试。

}
let mut scope = None;
let mut records = Vec::new();
loop {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P2] Keep list_discovery_memory to one storage window per call

This loop keeps taking 32-position windows until it has four matches or reaches the start of history. A query or related that matches fewer than four records (related normally matches one to three) therefore scans every record in a single call. Each iteration re-takes the global scheduler gate and the Bot ordering lock, re-runs the access checks, does about 64 point reads, and re-serializes each candidate Entry. Nothing prunes records and plans run every 30 minutes by default, so N only grows.

This conflicts with AGENTS.md ("hot paths process only the data they need; avoid full scans") and with plugins/agent/native/README.md lines 161-163 (and the zh-CN twin), which still promise "at most 32 positions per call". Suggest one window per call that returns next_before (the single-window version before fd69101c7), and for related stop at the original record's sequence, since related records are always newer.


[P2] list_discovery_memory 每次调用只应处理一个存储窗口

这个 loop 会不断取 32 个位置的窗口,直到凑够 4 条匹配或翻到历史开头。当 query 或 related 匹配少于 4 条(related 通常只匹配 1~3 条)时,一次调用就会扫描全部记录。每轮都会重新获取全局调度 gate 和 Bot 排序锁、重跑访问检查、做约 64 次点读,并对每个候选 Entry 重新序列化。记录不会被清理,计划默认每 30 分钟运行一次,N 只会越来越大。

这违反 AGENTS.md 的「热路径只处理所需数据,避免全量扫描」,也与 plugins/agent/native/README.md 第 161-163 行(及中文版)仍写的「每次调用最多检查 32 个位置」不一致。建议每次只处理一个窗口并返回 next_before(即 fd69101c7 之前的单窗口实现);related 查询扫到原记录的序号为止即可,因为关联记录一定更新。

continue;
}
if let Some(query) = &query
&& !serde_json::to_string(&entry)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P2] Match query against the text fields, not the serialized Entry

serde_json::to_string(&entry)?.to_lowercase().contains(query) searches the whole JSON: field names, the kind tag, source ids and JSON escapes. A query such as investigation, content, source or kind matches almost every record, and short hex-like words can match digests. A query containing ", \ or a newline (e.g. He said "stop") never matches, because the stored JSON holds the escaped form.

Suggest matching against the same text fields that preview shows. Separately, related lookups have no cutoff below the original record's sequence (see the comment on list_discovery_memory).


[P2] query 应匹配文本字段,而不是序列化后的整条 Entry

serde_json::to_string(&entry)?.to_lowercase().contains(query) 搜索的是整段 JSON:字段名、kind 标签、来源 id 和 JSON 转义。像 investigation、content、source、kind 这样的查询几乎匹配所有记录,短的类十六进制词还可能命中摘要。含 "、\ 或换行的查询(如 He said "stop")永远匹配不到,因为存储的 JSON 里是转义后的形式。

建议只匹配 preview 展示的那些文本字段。另外,related 查询没有在原记录序号处截止(见 list_discovery_memory 那条评论)。

} else {
authorized?;
}
if let Phase::Delivering { notification, .. } = &job.phase

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P2] Settle an already-consumed Delivering report before converting the job to Stopping

The branch at 454-479 rewrites job.phase to Stopping whenever the plan is paused, disabled, or no longer authorized, so this if let Phase::Delivering check can only match when none of those hold. Scenario: the report is enqueued with "DiscoveryMemory record: X" and Delivering is saved; settle_discovery fails, returns OutcomeUnknown, or the process restarts; the idle Bot consumes the report, so it is no longer retractable; before the retry the plan is paused or a permission/Recall boundary changes. The retry sees Stopping, never reaches admit_notification, and outcome_mutations returns nothing for Stopping (records.rs), so the slot settles Blocked and no investigation record is written. Later discovery{record:X} fails with discovery_record_unavailable, and the finding is missing from shared memory.

I found this by reading; I have not reproduced it, and the tests keep the Bot busy so they don't reach it. Suggest checking "report already admitted/consumed" first. That is a fact about a delivery that already happened, not a new admission, so it does not weaken the authorization re-check for reports that can still be retracted.


[P2] 应先结算「已被消费」的 Delivering 报告,再把 job 转成 Stopping

454-479 行的分支在计划被暂停、被禁用或授权失效时会把 job.phase 改成 Stopping,所以这里的 if let Phase::Delivering 只会在这些条件都不成立时才可能命中。场景:报告带着「DiscoveryMemory record: X」入队并保存了 Delivering;settle_discovery 失败、返回 OutcomeUnknown 或进程重启;空闲的 Bot 消费了这条报告,不再可撤回;重试前计划被暂停,或权限 / Recall 边界变了。重试时看到的是 Stopping,不会走到 admit_notification,而 outcome_mutations 对 Stopping 返回空(records.rs),于是该槽位结算为 Blocked,调查记录没有写入。之后 discovery{record:X} 会报 discovery_record_unavailable,这条发现在共享记忆里缺失。

这是读代码得出的结论,尚未复现;现有测试都让 Bot 保持忙碌,覆盖不到这个路径。建议先判断「报告是否已被接纳 / 消费」。这是已发生投递的事实,不是新的接纳,所以不会削弱对「仍可撤回的报告」做授权复核的约束。

Comment thread plugins/agent/native/src/owner/send.rs Outdated
Err(CaptureError::Other(error)) => return Err(error),
};
let mut message: MessageInput = text.into();
message.quotes = (!quotes.is_empty()).then_some(quotes);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P2] Reject or fold in quotes for external executors

send now accepts quotes for every backend and stores them here, but external executors build the prompt from content.text only (attachments.rs:89: Materials { message: content.text.clone(), .. }). The native path (references::text) and the ACP driver (driver.rs:329) do fold quotes in; nothing under native/src/executor does. A send with quotes to a Codex/Claude/agy session (reachable via the SessionSend schema or the SDK) therefore drops the quote while history still shows it, and a quote-only message reaches the executor as an empty prompt. The README says external executors "retain their existing rich-input restrictions", but nothing rejects quotes.

The desktop UI only quotes Bot replies, so this needs a Bot session on an external executor or an API caller. Suggest rejecting quotes for external backends in send with a clear error, or folding them into Materials.message.


[P2] 外部执行器应拒绝 quotes,或把引用并入 prompt

send 现在对所有后端都接受 quotes 并在这里存下来,但外部执行器只用 content.text 拼 prompt(attachments.rs:89:Materials { message: content.text.clone(), .. })。原生路径(references::text)和 ACP 驱动(driver.rs:329)会把引用并入,native/src/executor 下没有任何地方处理。因此向 Codex / Claude / agy 会话发送带 quotes 的 send(可通过 SessionSend schema 或 SDK 触发),引用会被丢掉而历史里仍显示它;只有引用的消息到执行器时是空 prompt。README 写的是外部执行器「保留原有的富输入限制」,但没有任何地方拒绝引用。

桌面 UI 只能引用 Bot 的回复,所以触发需要「外部执行器上的 Bot 会话」或 API 调用方。建议在 send 里对外部后端明确报错拒绝 quotes,或把引用并入 Materials.message。

Comment thread plugins/agent/native/src/owner/send.rs Outdated
if text.trim().is_empty() && attachments.is_empty() {
if quotes.len() > 16
|| quotes.iter().any(|q| q.text.trim().is_empty())
|| (text.trim().is_empty() && attachments.is_empty() && quotes.is_empty())

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P2] A quote-only message is now valid, but the queue paths still treat content as text + attachments

This clause makes a message with text: "" and one quote valid to send and queue; the queue code was not updated (neither PR touches it):

  • queue() builds the preview from the text, then the first attachment name, then "" (controls.rs:79-88), so the MessagesDock row is blank; queue_message returns message: "" and has_attachments: false.
  • edit_queue Update rejects with InvalidEdit when message.trim().is_empty() and there are no attachments, without considering quotes (controls.rs:272). MessagesDock.tsx disables Save on the same condition, and queued quotes are not shown anywhere.
  • On the desktop side (feat(bot): add scheduled proactive discovery and quoted feedback #6730 head): the queue command is enabled by !!owner.draft().trim() || owner.attachments.files().length > 0 (SessionSurface.tsx:2881), so it is disabled for a quote-only draft while the Composer's "Add to queue" menu (via hasContent()) works; and the composer occupancy (Conversation.tsx:3385) ignores quotes, so next-message prediction runs for a quote-only draft and Composer.tsx then discards the result.

Suggest either giving the queue preview/edit/occupancy checks a quote-aware "has content" helper, or not allowing quote-only messages until those paths are updated.


[P2] 现在「只有引用」的消息合法,但队列路径仍只认「文字 + 附件」

这个条件让 text: "" 加一条引用的消息可以发送和入队;而队列代码没有同步更新(两个 PR 都没改它):

  • queue() 的预览依次取文字、第一个附件名、""(controls.rs:79-88),所以 MessagesDock 里这一行是空白的;queue_message 返回 message: "" 和 has_attachments: false。
  • edit_queue 的 Update 在 message.trim().is_empty() 且没有附件时返回 InvalidEdit,没有考虑引用(controls.rs:272)。MessagesDock.tsx 的 Save 用同样的条件禁用,排队中的引用在任何地方都不显示。
  • 桌面侧(feat(bot): add scheduled proactive discovery and quoted feedback #6730 头):queue 命令用 !!owner.draft().trim() || owner.attachments.files().length > 0 判断是否可用(SessionSurface.tsx:2881),所以只有引用的草稿时命令被禁用,而 Composer 的「加入队列」菜单(经 hasContent())却可用;输入框占用状态(Conversation.tsx:3385)也没算引用,因此只有引用的草稿仍会触发下一条消息预测,Composer.tsx 随后又丢弃结果。

建议给队列预览 / 编辑 / 占用判断提供一个能识别引用的「是否有内容」函数;或在这些路径更新前先不允许只有引用的消息。

Comment thread plugins/agent/state/src/queue/sql.rs Outdated
if !is_interactive(&entry.request, &source)
|| matches!(
source.message.origin,
Some(maka_agent_facts::message::MessageOrigin::BotWorker { .. })

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P2] Scope the Stop exemption to the discovery report, and cover it with a state-crate test

retract_interactive now skips every MessageOrigin::BotWorker entry. Its only caller is StopRun::execute, and BotWorker messages come from two places: the discovery report and the existing worker-finished wake (owner/bot/wake.rs:354). Neither sets a budget_basis, so both were interactive and Stop retracted them before this change. With the new condition, pressing Stop on the Bot's latest run while a worker-finished wake is pending leaves that wake in the queue; it then starts a new Bot Run with no user input, so Stop looks ignored. The discovery test asserts this survival for reports, so it is intended there, but the change for ordinary worker wakes is neither documented nor tested (stop_tests.rs has no BotWorker case). SessionCompletion is still retracted, so the treatment is also inconsistent.

Suggest scoping the exemption to the discovery report (or defining is_interactive explicitly for BotWorker) and adding a Stop test with a BotWorker entry.


[P2] Stop 的豁免应只针对调查报告,并在 state crate 里补测试

retract_interactive 现在会跳过所有 MessageOrigin::BotWorker 的条目。它唯一的调用方是 StopRun::execute,而 BotWorker 消息有两个来源:调查报告,以及已有的「worker 完成」唤醒消息(owner/bot/wake.rs:354)。两者都没有 budget_basis,所以此前都算交互式消息,Stop 会撤回它们。加了这个条件后,如果在「worker 完成」唤醒消息待处理时对 Bot 最新一次运行按 Stop,这条唤醒消息会留在队列里,随后在没有用户输入的情况下启动新的 Bot Run,Stop 看起来像没生效。调查报告的测试断言了这种「保留」,对报告而言是预期行为;但对普通 worker 唤醒的行为变化既没有文档也没有测试(stop_tests.rs 里没有 BotWorker 用例)。SessionCompletion 仍会被撤回,处理上也不一致。

建议把豁免限定在调查报告上(或为 BotWorker 明确定义 is_interactive),并补一个带 BotWorker 条目的 Stop 测试。

@M4n5ter

M4n5ter commented Nov 17, 2026

Copy link
Copy Markdown
Member

Consolidated review posted on #6730; please fold the stack there and close #6724 / #6728.

@Astro-Han Astro-Han left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: the new pause/resume regression test does not compile at f0d09f19fc910dec9dac5313a64a5502e59f7fd7. The two added f.send(...) calls omit the required quotes: Value argument. The original Windows job and macOS job both report E0061 at lines 1472 and 1491, preventing the workspace test build from completing. The helper at line 187 already required both arguments before this follow-up.

I fetched the jobs' actual merge commit 854e9b92aefeed0dc3598ba86f85b3899738b32c and verified that the complete fixture matches the raw PR head byte for byte. I inspected the six-file incremental diff, the existing helper and its call sites. A1 uses a one-argument helper, whereas this branch's helper also takes quotes; A3 already supplies an empty quote array at both adapted calls. This finding concerns this branch's test integration and does not establish a failure in the pause-ownership runtime behavior.

This is a scoped follow-up, not a complete review of the 44-file discovery-records change. I did not run Rust or native UI tests locally, or validate persistence, restart and source-authorization behavior end to end.


Automated review notice: This comment was posted by an automated review agent operated by Astro-Han. It is not an independent human review and does not replace one.

quiet(&f, &listener, &mut socket).await;
f.change(id, "approve").await;

f.send("Pause and then resume your discovery").await;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P2] Pass the quote argument in both added sends

Fixture::send in this branch takes (text: &str, quotes: Value) (line 187), but this new call and the one at line 1491 provide only the text. Both native CI jobs fail to compile the workspace test targets with E0061 at these lines. Pass an explicit empty quote array for these non-quote messages, preserving the pause/resume assertions.

sunrioa added a commit to sunrioa/maka that referenced this pull request Nov 17, 2026
…agement

Combine the changes from apache#6724, apache#6728, and apache#6730 on rust-preview. Keep the upstream session readers and share the escaped quote renderer.

Generated-by: Codex
@sunrioa sunrioa closed this Nov 17, 2026
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.

4 participants