You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maka.apache.org by wy...@apache.org on 2026/09/23 02:31:00 UTC
(maka) branch feat/runtime-host-rust updated: fix(session): publish draft retention after independent work admission
This is an automated email from the ASF dual-hosted git repository.
M4n5ter pushed a commit to branch feat/runtime-host-rust
in repository https://gitbox.apache.org/repos/asf/maka.git
The following commit(s) were added to refs/heads/feat/runtime-host-rust by this push:
new 564cbc94b1 fix(session): publish draft retention after independent work admission
564cbc94b1 is described below
commit 564cbc94b1926c75a829b1084086063fc77be442
Author: Wang <m4...@gmail.com>
AuthorDate: Wed Sep 23 10:30:54 2026 +0800
fix(session): publish draft retention after independent work admission
Generated-by: Codex
---
crates/runtime-host/src/execution.rs | 7 +++
crates/runtime-host/src/execution/plugins.rs | 4 +-
.../runtime-host/src/execution/plugins/effects.rs | 9 +++
crates/runtime-host/src/execution/plugins/root.rs | 12 ++--
.../runtime-host/src/plugins/terminal/resource.rs | 4 +-
.../runtime-host/src/server/resources/mutation.rs | 8 ++-
.../tests/integration/session_history.rs | 64 +++++++++++++++++++---
docs/rust-parity.md | 2 +-
docs/rust-parity.zh-CN.md | 2 +-
9 files changed, 93 insertions(+), 19 deletions(-)
diff --git a/crates/runtime-host/src/execution.rs b/crates/runtime-host/src/execution.rs
index 037573c066..34af02224d 100644
--- a/crates/runtime-host/src/execution.rs
+++ b/crates/runtime-host/src/execution.rs
@@ -150,6 +150,13 @@ impl Executions {
pub(crate) fn active_count(&self) -> usize {
self.active.lock().unwrap().len()
}
+
+ /// Notification failure cannot discard an already accepted operation.
+ pub(crate) async fn publish_session_change(&self, session: &str) {
+ if self.catalog.publish_session(session).await.is_err() {
+ self.begin_drain();
+ }
+ }
pub(crate) fn accepting(&self) -> bool {
!self.shutdown.is_cancelled()
&& *self
diff --git a/crates/runtime-host/src/execution/plugins.rs b/crates/runtime-host/src/execution/plugins.rs
index 75af79eebb..6cc1f6e15f 100644
--- a/crates/runtime-host/src/execution/plugins.rs
+++ b/crates/runtime-host/src/execution/plugins.rs
@@ -99,7 +99,9 @@ impl Executions {
&self,
session: &str,
) -> Result<(), StoreError> {
- self.log.retain_session(session).await
+ self.log.retain_session(session).await?;
+ self.publish_session_change(session).await;
+ Ok(())
}
pub(crate) async fn admit_plugin_process(
diff --git a/crates/runtime-host/src/execution/plugins/effects.rs b/crates/runtime-host/src/execution/plugins/effects.rs
index f0a32ee038..22c1569581 100644
--- a/crates/runtime-host/src/execution/plugins/effects.rs
+++ b/crates/runtime-host/src/execution/plugins/effects.rs
@@ -155,6 +155,12 @@ impl Executions {
.await
.map_err(ToolError::from)?;
let _admitted = owner.admit().map_err(failed)?;
+ let session = match &boundary {
+ maka_plugins::authorization::Boundary::Session { boundary, .. } => {
+ Some(boundary.session_id.clone())
+ }
+ _ => None,
+ };
let request = Request {
source: call.identity.clone(),
owner: owner.identity().map_err(failed)?,
@@ -165,6 +171,9 @@ impl Executions {
self.begin_drain();
ToolError::Persistence(error.to_string())
})?;
+ if let Some(session) = session {
+ self.publish_session_change(&session).await;
+ }
drop(gate);
let result = if cancellation.is_cancelled() {
Err(failed("cancelled before effect"))
diff --git a/crates/runtime-host/src/execution/plugins/root.rs b/crates/runtime-host/src/execution/plugins/root.rs
index 565792d71a..ee4b22458a 100644
--- a/crates/runtime-host/src/execution/plugins/root.rs
+++ b/crates/runtime-host/src/execution/plugins/root.rs
@@ -247,9 +247,7 @@ impl BoundCommands {
let result = match result {
Ok(maka_event_log::sessions::AbandonRevision::Abandoned) => {
grants.lock().unwrap().remove(&id);
- if worker.catalog.publish_session(&id).await.is_err() {
- worker.begin_drain();
- }
+ worker.publish_session_change(&id).await;
Ok(RevisionDisposition::Abandoned)
}
Ok(maka_event_log::sessions::AbandonRevision::Retained) => {
@@ -454,8 +452,12 @@ impl BoundCommands {
} else {
worker.log.create_plugin_session(&origin, &expected, now()?).await.map_err(storage)?
};
- if worker.catalog.publish_session(&id).await.is_err() {
- worker.begin_drain();
+ let changed = std::iter::once(id.as_str())
+ .chain(history.as_ref().map(|seed| seed.input.session_id.as_str()))
+ .chain(approval.source.as_ref().map(|source| source.session_id.as_str()))
+ .collect::<std::collections::BTreeSet<_>>();
+ for session in changed {
+ worker.publish_session_change(session).await;
}
record
}
diff --git a/crates/runtime-host/src/plugins/terminal/resource.rs b/crates/runtime-host/src/plugins/terminal/resource.rs
index 96c5928ed9..40bf0c286a 100644
--- a/crates/runtime-host/src/plugins/terminal/resource.rs
+++ b/crates/runtime-host/src/plugins/terminal/resource.rs
@@ -164,7 +164,9 @@ impl Worker {
.shells
.start_pty(record, prepared.command, self.input.size)
.map_err(super::failed)?;
- handle.clone().ready().await.map_err(super::failed)?;
+ let ready = handle.clone().ready().await;
+ self.host.publish_session_change(session).await;
+ ready.map_err(super::failed)?;
drop(prepared.gate);
Ok(handle)
}
diff --git a/crates/runtime-host/src/server/resources/mutation.rs b/crates/runtime-host/src/server/resources/mutation.rs
index 7ca64b9a3c..5fb577d784 100644
--- a/crates/runtime-host/src/server/resources/mutation.rs
+++ b/crates/runtime-host/src/server/resources/mutation.rs
@@ -118,7 +118,7 @@ pub(super) async fn start(host: &Host, input: ResourceStartInput) -> Result<Outc
let size = TerminalSize::new(80, 24).unwrap();
let record = ShellRun {
id: uuid::Uuid::new_v4().to_string(),
- session_id: input.session_id,
+ session_id: input.session_id.clone(),
source_run_id: None,
source_turn_id: input.launch_id.clone(),
source_tool_call_id: input.launch_id,
@@ -162,7 +162,11 @@ pub(super) async fn start(host: &Host, input: ResourceStartInput) -> Result<Outc
Err(ShellError::Rejected(message)) => return Ok(failure(Code::OperationConflict, message)),
Err(error) => return Ok(fault(host, error)),
};
- match handle.ready().await {
+ let ready = handle.ready().await;
+ host.executions
+ .publish_session_change(&input.session_id)
+ .await;
+ match ready {
Ok(record) => match projected((*record).clone()) {
Ok(result) => Ok(result),
Err(error) => {
diff --git a/crates/runtime-host/tests/integration/session_history.rs b/crates/runtime-host/tests/integration/session_history.rs
index 98047298b1..6adf97e17c 100644
--- a/crates/runtime-host/tests/integration/session_history.rs
+++ b/crates/runtime-host/tests/integration/session_history.rs
@@ -17,7 +17,8 @@
* under the License.
*/
-use maka_event_log::{EventLog, sessions::SessionCopyResult};
+use super::support::{client_probe::ClientFixture, peer::Peer};
+use maka_event_log::sessions::SessionCopyResult;
use maka_protocol::session::{RevisionState, SandboxMode, WorkspaceProjection, WorkspaceTarget};
use maka_runtime::{
event::{EventWrite, Fact, Invocation, InvocationInput, InvocationOutcome, RuntimeEvent},
@@ -32,17 +33,16 @@ use serde_json::json;
#[tokio::test]
async fn catalog_revisions_preserve_branch_origin_without_inheriting_execution_status() {
- let directory = tempfile::tempdir().unwrap();
- let path = directory.path().join("history.sqlite");
- let cwd = directory.path().to_string_lossy().into_owned();
+ let fixture = ClientFixture::new("maka-revision-catalog-");
+ let cwd = fixture.workspace.to_string_lossy().into_owned();
let configuration = PreparedSession::new(serde_json::from_value(json!({
"sessionId":"source", "workspace":{"kind":"host_path","path":cwd}, "executorId":"fixture"
})).unwrap()).unwrap().bind(
WorkspaceProjection { target: WorkspaceTarget::HostPath { path: cwd.clone() }, host_cwd: cwd },
SessionTarget::Executor { executor_id: "fixture".to_owned().try_into().unwrap(), settings: Default::default() },
- SandboxMode::ReadOnly,
+ SandboxMode::DangerFullAccess,
);
- let log = EventLog::open(&path).await.unwrap();
+ let log = fixture.log().await;
log.create_session("source", "source", &configuration, 1)
.await
.unwrap();
@@ -149,9 +149,57 @@ async fn catalog_revisions_preserve_branch_origin_without_inheriting_execution_s
assert!(projected.revision_state.is_none());
}
}
- log.retain_session("revision").await.unwrap();
log.close().await.unwrap();
- let log = EventLog::open(&path).await.unwrap();
+ let host = maka_runtime_host::server::Host::open(fixture.owner())
+ .await
+ .unwrap();
+ #[cfg(unix)]
+ let endpoint = fixture.workspace.parent().unwrap().join("revision.sock");
+ #[cfg(windows)]
+ let endpoint =
+ std::path::PathBuf::from(format!(r"\\.\pipe\maka-revision-{}", uuid::Uuid::new_v4()));
+ let stop = tokio_util::sync::CancellationToken::new();
+ let _cleanup = stop.clone().drop_guard();
+ let server = tokio::spawn(
+ maka_runtime_host::server::local::LocalListener::bind(&endpoint)
+ .unwrap()
+ .serve(host.clone(), stop.clone()),
+ );
+ // A catalog-only observer must hear retention even without a canonical
+ // invocation or a Session/PTY subscription driving its connection loop.
+ let mut observer = Peer::new(host.clone(), "revision-catalog").await;
+ let mut operator = Peer::new(host.clone(), "revision-shell").await;
+ let started = operator
+ .rpc(
+ "runtime.resource.start",
+ json!({
+ "sessionId":"revision", "launchId":"draft-shell", "command":"exit 0"
+ }),
+ )
+ .await;
+ assert_eq!(started["ok"], true, "{started}");
+ loop {
+ let notice = observer.frame().await;
+ if notice["kind"] == "session.catalog.changed" && notice["sessionId"] == "revision" {
+ break;
+ }
+ }
+ let catalog = observer
+ .rpc(
+ "session.catalog.query",
+ json!({"kind":"get", "sessionId":"revision"}),
+ )
+ .await;
+ assert_eq!(
+ catalog["result"]["session"]["revisionState"], "committed",
+ "{catalog}"
+ );
+ observer.close().await;
+ operator.close().await;
+ stop.cancel();
+ server.await.unwrap().unwrap();
+ drop(host);
+ let log = fixture.log().await;
let projection = catalog_projection(
log.get_session::<SessionConfiguration>("revision")
.await
diff --git a/docs/rust-parity.md b/docs/rust-parity.md
index 55101f7c6b..be25d722b6 100644
--- a/docs/rust-parity.md
+++ b/docs/rust-parity.md
@@ -91,7 +91,7 @@ implementations; wire adapters may retain existing client vocabulary.
| External agents | Setup start/query/cancel; execution adapters, configuration, auth, conversation identity, adapter-specific attachments/interactions/resume/fork. | **Plugin + Host.** Implement concrete CLI/ACP adapters as Executor plugins over owned processes/HTTP. Generic Executor support is not a shipped adapter. Host owns authorization, cancellation and canonical external-event recording. |
| Usage / Pricing | Usage queries, revision-consistent screens/activity pages, pricing query/mutate and valuation. | **Plugin + Host.** Reports, price policy and rebuildable projections may be an Insights domain; Host records usage independently of plugin availability and provides consistent reads. Missing usage must not become zero. |
| Background health | BackgroundTaskHealth process and endpoint checks. | **Plugin + Host.** Health interpretation and Tool in a plugin; Host exposes authorized resource observations and bounded probes. A stored PID is not resource ownership. |
-| Session lineage | Public Rust/JS history copying, revision abandonment, original input reads and durable recovery exist. Native Client routes, catalog retention notices and Desktop editing remain. Regeneration is removed; edits use revision and resend. | **Host.** One transactional lineage and workspace authority; plugins may request changes through commands, not reproduce them in private storage. |
+| Session lineage | Public Rust/JS history copying, revision abandonment, original input reads, retention notices and durable recovery exist. Native Client routes and Desktop editing remain. Regeneration is removed; edits use revision and resend. | **Host.** One transactional lineage and workspace authority; plugins may request changes through commands, not reproduce them in private storage. |
| Session lifecycle | Removal/preview and shared Session queries. | **Host.** Coordinate references, running work, attachments, owned worktrees, grants and cleanup. Shared queries depend on real collaboration authorization. |
| Session transfer | Bundle export/import and unified external catalog/source/import for Codex, Claude Code and OpenCode. | **Plugin + Host.** Source parsing/discovery can be adapters; Host owns bounded canonical import, identities, artifacts, provenance and atomic publication. Native bundle format remains a Host contract. Never import source event bytes as trusted execution authority. |
| Runtime policy | Shell/external-agent consumers and ordinary named tool profiles. | **Split.** Shell launch policy and capability ceilings stay in Host. External-agent settings belong to their domain. Profiles contribute definitions; Host applies the intersection at admission and per-step capture. Storing settings alone is insufficient. |
diff --git a/docs/rust-parity.zh-CN.md b/docs/rust-parity.zh-CN.md
index 12aba60faa..e2694ad7a0 100644
--- a/docs/rust-parity.zh-CN.md
+++ b/docs/rust-parity.zh-CN.md
@@ -81,7 +81,7 @@ runtime 契约不能反向依赖插件实现,协议适配层可以保留现有
| 外部 agent | setup start/query/cancel;具体执行适配、配置、鉴权、对话身份,以及附件/交互/resume/fork。 | **插件 + Host。** CLI/ACP 适配作为 Executor 插件,使用受管理进程/HTTP。已有 Executor 框架不等于已有具体 adapter。Host 负责授权、取消和外部事件落盘。 |
| Usage/Pricing | Usage 查询、一致版本视图及活动分页,Pricing 查询/修改和估价。 | **插件 + Host。** 报表、价格策略和可重建投影可归 Insights 领域;Host 不依赖插件存活来记录用量,并提供一致快照。缺失用量不能视为零。 |
| 后台健康 | BackgroundTaskHealth 的进程和端点检查。 | **插件 + Host。** 插件解释健康状态并提供工具;Host 提供授权资源观察和有界探测。保存 PID 不等于拥有进程。 |
-| Session 谱系 | 公共 Rust/JS 历史复制、修订放弃、原始输入读取及持久恢复已有。原生 Client 路由、保留状态通知及 Desktop 编辑仍待接入。已移除 regenerate,修改请求使用编辑重发。 | **Host。** 谱系及工作区只有一个事务权威;插件可以请求命令,不能在私有存储中重做。 |
+| Session 谱系 | 公共 Rust/JS 历史复制、修订放弃、原始输入读取、保留状态通知及持久恢复已有。原生 Client 路由及 Desktop 编辑仍待接入。已移除 regenerate,修改请求使用编辑重发。 | **Host。** 谱系及工作区只有一个事务权威;插件可以请求命令,不能在私有存储中重做。 |
| Session 生命周期 | 删除/预览、shared 查询。 | **Host。** 协调引用、运行中工作、附件、托管 worktree、授权及清理。shared 查询依赖真实协作授权。 |
| Session 迁入迁出 | bundle 导入/导出;Codex、Claude Code、OpenCode 的统一外部 catalog/source/import。 | **插件 + Host。** 来源解析/发现可以作为 adapter;Host 拥有有界规范导入、身份、附件、来源记录和原子发布。原生 bundle 格式仍是 Host 合同,不能把外部事件字节直接作为可信执行权威。 |
| Runtime policy | shell/external-agent 消费,普通 named tool profiles。 | **拆分。** shell 启动策略和能力上限留在 Host;外部 agent 设置由对应领域消费。Profile 提供定义,Host 在准入和每步捕获时取能力交集。只保存设置不算完成。 |
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org