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/16 01:18:41 UTC

(maka) 22/29: feat(host): expose read-only deployment status and bounded diagnostics

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

commit c9d1eff8a6c24544189c8203cb75b7145f0b9d19
Author: Wang <m4...@gmail.com>
AuthorDate: Tue Sep 15 22:12:31 2026 +0800

    feat(host): expose read-only deployment status and bounded diagnostics
    
    Generated-by: OpenAI Codex
---
 crates/cli/Cargo.toml                        |   2 +-
 crates/cli/src/args.rs                       |  42 ++----
 crates/cli/src/deployment.rs                 |  18 ++-
 crates/cli/src/deployment/entry.rs           |  48 ++++++
 crates/cli/src/deployment/logs.rs            | 218 +++++++++++++++++++++++++++
 crates/cli/src/deployment/query.rs           | 182 ++++++++++++++++++++++
 crates/cli/src/deployment/service.rs         |  18 ++-
 crates/cli/src/deployment/service/linux.rs   |  38 +++++
 crates/cli/src/deployment/service/macos.rs   |  45 +++++-
 crates/cli/src/deployment/service/status.rs  |  69 +++++++++
 crates/cli/src/deployment/service/windows.rs |  34 ++++-
 crates/cli/src/deployment/updates.rs         |   2 +-
 crates/cli/src/main.rs                       |   6 +-
 crates/cli/src/serve.rs                      |  11 +-
 crates/cli/src/windows.rs                    |  70 +++++++++
 crates/cli/tests/integration/deployment.rs   |  94 ++++++++++--
 crates/protocol/src/handshake.rs             |   2 +-
 docs/rust-runtime.md                         |   7 +
 docs/rust-runtime.zh-CN.md                   |   5 +
 19 files changed, 844 insertions(+), 67 deletions(-)

diff --git a/crates/cli/Cargo.toml b/crates/cli/Cargo.toml
index 420cadd88e..1899c46650 100644
--- a/crates/cli/Cargo.toml
+++ b/crates/cli/Cargo.toml
@@ -62,4 +62,4 @@ libc.workspace = true
 
 [target.'cfg(windows)'.dependencies]
 windows = { version = "0.62.2", features = ["Win32_Foundation", "Win32_System_Com", "Win32_System_TaskScheduler", "Win32_System_Variant", "Win32_System_Ole"] }
-windows-sys = { version = "0.61.2", features = ["Win32_Foundation", "Win32_Security", "Win32_System_JobObjects", "Win32_System_Threading"] }
+windows-sys = { version = "0.61.2", features = ["Win32_Foundation", "Win32_Security", "Win32_Storage_FileSystem", "Win32_System_Console", "Win32_System_JobObjects", "Win32_System_Threading"] }
diff --git a/crates/cli/src/args.rs b/crates/cli/src/args.rs
index 9b7f51445c..c3a46e826d 100644
--- a/crates/cli/src/args.rs
+++ b/crates/cli/src/args.rs
@@ -63,8 +63,10 @@ enum HostCommand {
     Restart(crate::deployment::Control),
     /// Revoke startup and unregister its service, retaining State Root data.
     Uninstall(crate::deployment::Control),
-    /// Query the existing Host without opening its State Root for writing.
-    Status(Root),
+    /// Observe a Host or managed deployment without starting or changing it.
+    Status(crate::deployment::Status),
+    /// Read a bounded tail of supervised Host diagnostics without starting it.
+    Logs(crate::deployment::Logs),
     /// Retire the exact current Host, preserving work at safe step boundaries.
     Retire {
         #[command(flatten)]
@@ -79,7 +81,7 @@ enum HostCommand {
     Candidate(candidate::Candidate),
     /// Run only the currently admitted supervised deployment.
     #[command(hide = true)]
-    ServiceRun(Root),
+    ServiceRun(crate::deployment::ServiceRun),
     /// Serve a native State Root over a private local endpoint.
     Serve {
         #[command(flatten)]
@@ -102,25 +104,6 @@ struct Log {
 }
 
 impl Cli {
-    pub(super) async fn run_service(self) -> Result<(), HostError> {
-        match self.command {
-            Command::Host(HostCommand::Serve {
-                root,
-                websocket: None,
-            }) => {
-                #[cfg(windows)]
-                crate::windows::own_process_tree()?;
-                serve::run(&root.root, None, true).await
-            }
-            Command::Host(HostCommand::Serve { .. }) => {
-                Err("service listener belongs to deployment configuration".into())
-            }
-            // The installed artifact also remains a usable captured-stdio
-            // operator for SSH/WSL; the interactive console command is maka.
-            command => Self { command }.run().await,
-        }
-    }
-
     pub(super) fn error_exit_code(&self) -> u8 {
         if matches!(self.command, Command::Host(HostCommand::Candidate(_))) {
             70
@@ -151,20 +134,13 @@ impl Cli {
                 Ok(())
             }
             Command::Host(HostCommand::Serve { root, websocket }) => {
-                serve::run(&root.root, websocket, false).await
-            }
-            Command::Host(HostCommand::ServiceRun(root)) => {
                 #[cfg(windows)]
                 crate::windows::own_process_tree()?;
-                serve::run(&root.root, None, true).await
-            }
-            Command::Host(HostCommand::Status(root)) => {
-                let mut client = crate::host_client::HostClient::connect(&root.root, None).await?;
-                let status = client.status().await?;
-                drop(client);
-                println!("{}", serde_json::to_string(&status)?);
-                Ok(())
+                serve::run(&root.root, websocket, None).await
             }
+            Command::Host(HostCommand::ServiceRun(args)) => args.run().await,
+            Command::Host(HostCommand::Status(args)) => args.run().await,
+            Command::Host(HostCommand::Logs(args)) => args.run().await,
             Command::Host(HostCommand::Retire {
                 root,
                 expected_host_epoch,
diff --git a/crates/cli/src/deployment.rs b/crates/cli/src/deployment.rs
index ac550c9fcb..7e4a9146e2 100644
--- a/crates/cli/src/deployment.rs
+++ b/crates/cli/src/deployment.rs
@@ -19,13 +19,19 @@
 
 mod activation;
 mod control;
+mod entry;
+mod logs;
 mod package;
+mod query;
 mod service;
 mod store;
 mod update;
 mod updates;
 pub(super) use activation::Activate;
 pub(super) use control::{Control, ControlAction};
+pub(super) use entry::ServiceRun;
+pub(super) use logs::Logs;
+pub(super) use query::Status;
 pub(super) use update::Update;
 
 use clap::{Args, ValueEnum};
@@ -120,8 +126,16 @@ impl Deployment {
     }
 
     fn validate(&self, root: &RootLocation, directory: &Path) -> Result<(), HostError> {
-        if self.root_id != root.root_id()
-            || self.root_path != root.canonical_path()
+        self.validate_record(directory)?;
+        if self.root_id != root.root_id() || self.root_path != root.canonical_path() {
+            return Err("deployment does not match its native root".into());
+        }
+        Ok(())
+    }
+
+    fn validate_record(&self, directory: &Path) -> Result<(), HostError> {
+        if self.root_id.parse::<RootId>().is_err()
+            || !self.root_path.is_absolute()
             || !(1..=9_007_199_254_740_991).contains(&self.config_revision)
             || self.sha256.len() != 64
             || !self
diff --git a/crates/cli/src/deployment/entry.rs b/crates/cli/src/deployment/entry.rs
new file mode 100644
index 0000000000..41f88bca37
--- /dev/null
+++ b/crates/cli/src/deployment/entry.rs
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use super::{RootId, directory, store};
+use clap::Args;
+use maka_runtime_host::server::HostError;
+
+#[derive(Args)]
+pub(crate) struct ServiceRun {
+    #[arg(long)]
+    root_id: RootId,
+}
+
+impl ServiceRun {
+    pub async fn run(self) -> Result<(), HostError> {
+        let directory = directory(&self.root_id.0)?;
+        #[cfg(windows)]
+        {
+            crate::windows::service_stderr(&directory)?;
+            crate::windows::own_process_tree()?;
+        }
+        let store::Installation::Installed(deployment) = store::read(&directory).await? else {
+            return Err("service deployment is absent or incomplete".into());
+        };
+        if deployment.root_id != self.root_id.0 {
+            return Err("service deployment root identity differs".into());
+        }
+        // This read only locates Root. Admission is repeated after acquiring the
+        // actual writer lease, so a waiting process cannot reuse an old grant.
+        crate::serve::run(&deployment.root_path, None, Some(&self.root_id.0)).await
+    }
+}
diff --git a/crates/cli/src/deployment/logs.rs b/crates/cli/src/deployment/logs.rs
new file mode 100644
index 0000000000..80a7a88ae0
--- /dev/null
+++ b/crates/cli/src/deployment/logs.rs
@@ -0,0 +1,218 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use super::{Deployment, Mode, RootId, directory, store};
+use clap::Args;
+use maka_runtime_host::server::HostError;
+use serde::Serialize;
+
+const LIMIT: usize = 48 * 1024;
+
+#[derive(Args)]
+pub(crate) struct Logs {
+    #[arg(long)]
+    root_id: RootId,
+}
+
+#[derive(Serialize)]
+#[serde(
+    tag = "kind",
+    rename_all = "snake_case",
+    rename_all_fields = "camelCase"
+)]
+enum Output {
+    NotCaptured,
+    Tail {
+        source: Source,
+        text: String,
+        byte_truncated: bool,
+    },
+}
+
+#[derive(Serialize)]
+#[serde(
+    tag = "kind",
+    rename_all = "snake_case",
+    rename_all_fields = "camelCase"
+)]
+enum Source {
+    #[cfg(target_os = "linux")]
+    Journal { entry_limit: usize },
+    #[cfg(any(target_os = "macos", windows))]
+    Stderr,
+}
+
+impl Logs {
+    pub async fn run(self) -> Result<(), HostError> {
+        let directory = directory(&self.root_id.0)?;
+        let store::Installation::Installed(deployment) = store::read(&directory).await? else {
+            return Err("State Root has no installed deployment".into());
+        };
+        if deployment.root_id != self.root_id.0 {
+            return Err("deployment root identity differs".into());
+        }
+        deployment.validate_record(&directory)?;
+        let output = if deployment.mode == Mode::OnDemand {
+            Output::NotCaptured
+        } else {
+            read(&deployment).await?
+        };
+        println!("{}", serde_json::to_string(&output)?);
+        Ok(())
+    }
+}
+
+#[cfg(any(target_os = "macos", windows))]
+async fn read(deployment: &Deployment) -> Result<Output, HostError> {
+    let directory = directory(&deployment.root_id)?;
+    tokio::task::spawn_blocking(move || {
+        use std::io::{Read, Seek, SeekFrom};
+        let path = directory.join("host.stderr.log");
+        #[cfg(target_os = "macos")]
+        let opened = {
+            use std::os::unix::fs::OpenOptionsExt;
+            std::fs::OpenOptions::new()
+                .read(true)
+                .custom_flags(libc::O_NOFOLLOW | libc::O_NONBLOCK)
+                .open(&path)
+        };
+        #[cfg(windows)]
+        let opened = maka_event_log::root::windows::open_nofollow(&path, false);
+        let mut file = match opened {
+            Ok(file) => file,
+            Err(error) if error.kind() == std::io::ErrorKind::NotFound => {
+                return Ok(Output::NotCaptured);
+            }
+            Err(error) => return Err(error.into()),
+        };
+        let metadata = file.metadata()?;
+        if !metadata.is_file() {
+            return Err("service log is not a regular file".into());
+        }
+        #[cfg(target_os = "macos")]
+        {
+            use std::os::unix::fs::MetadataExt;
+            if metadata.uid() != unsafe { libc::geteuid() }
+                || metadata.mode() & 0o077 != 0
+                || metadata.nlink() != 1
+            {
+                return Err("service log is not private and singly linked".into());
+            }
+        }
+        #[cfg(windows)]
+        {
+            use maka_event_log::root::windows::{file_identity, validate_private};
+            validate_private(&file)?;
+            if file_identity(&file)?.links != 1 {
+                return Err("service log is not singly linked".into());
+            }
+        }
+        // Freeze the end offset; an active writer must not make this a follow.
+        let start = metadata.len().saturating_sub(LIMIT as u64);
+        file.seek(SeekFrom::Start(start))?;
+        let mut bytes = Vec::with_capacity(LIMIT);
+        file.take(metadata.len() - start).read_to_end(&mut bytes)?;
+        Ok(Output::Tail {
+            source: Source::Stderr,
+            text: String::from_utf8_lossy(&bytes).into_owned(),
+            byte_truncated: start != 0,
+        })
+    })
+    .await?
+}
+
+#[cfg(target_os = "linux")]
+async fn read(deployment: &Deployment) -> Result<Output, HostError> {
+    use std::{process::Stdio, time::Duration};
+    const ENTRIES: usize = 200;
+    let mut child = tokio::process::Command::new("journalctl")
+        .args([
+            "--user",
+            "--no-pager",
+            "--quiet",
+            "--all",
+            "--output=short-iso-precise",
+        ])
+        .arg(format!(
+            "--user-unit=org.apache.maka.host.{}.service",
+            deployment.root_id
+        ))
+        .arg(format!("--lines={ENTRIES}"))
+        .stdin(Stdio::null())
+        .stdout(Stdio::piped())
+        .stderr(Stdio::piped())
+        .kill_on_drop(true)
+        .spawn()?;
+    let stdout = child.stdout.take().ok_or("journal stdout unavailable")?;
+    let stderr = child.stderr.take().ok_or("journal stderr unavailable")?;
+    let result = tokio::time::timeout(Duration::from_secs(10), async {
+        tokio::try_join!(tail(stdout, LIMIT), tail(stderr, 2048), child.wait())
+    })
+    .await;
+    let (stdout, stderr, status) = match result {
+        Ok(Ok(output)) => output,
+        result => {
+            // Reap the query even on timeout or pipe failure; no pager is spawned.
+            let _ = child.kill().await;
+            return Err(match result {
+                Err(error) => error.into(),
+                Ok(Err(error)) => error.into(),
+                Ok(Ok(_)) => unreachable!(),
+            });
+        }
+    };
+    if !status.success() {
+        return Err(format!(
+            "journal query failed ({status}): {}",
+            String::from_utf8_lossy(&stderr.0)
+        )
+        .into());
+    }
+    Ok(Output::Tail {
+        source: Source::Journal {
+            entry_limit: ENTRIES,
+        },
+        text: String::from_utf8_lossy(&stdout.0).into_owned(),
+        byte_truncated: stdout.1,
+    })
+}
+
+#[cfg(target_os = "linux")]
+async fn tail(
+    mut input: impl tokio::io::AsyncRead + Unpin,
+    limit: usize,
+) -> std::io::Result<(Vec<u8>, bool)> {
+    use tokio::io::AsyncReadExt;
+    let mut bytes = std::collections::VecDeque::with_capacity(limit);
+    let mut buffer = [0; 8192];
+    let mut truncated = false;
+    loop {
+        let read = input.read(&mut buffer).await?;
+        if read == 0 {
+            break;
+        }
+        let overflow = (bytes.len() + read).saturating_sub(limit);
+        if overflow != 0 {
+            truncated = true;
+            bytes.drain(..overflow.min(bytes.len()));
+        }
+        bytes.extend(&buffer[read.saturating_sub(limit)..read]);
+    }
+    Ok((bytes.into(), truncated))
+}
diff --git a/crates/cli/src/deployment/query.rs b/crates/cli/src/deployment/query.rs
new file mode 100644
index 0000000000..b82ef74c77
--- /dev/null
+++ b/crates/cli/src/deployment/query.rs
@@ -0,0 +1,182 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use super::{Admission, Deployment, RootId, directory, service, store, updates};
+use crate::host_client::{HostClient, LiveHost};
+use clap::Args;
+use maka_protocol::handshake::Lifecycle;
+use maka_runtime_host::server::HostError;
+use serde::{Deserialize, Serialize};
+use sqlx::{Connection, SqliteConnection, sqlite::SqliteConnectOptions};
+use std::path::{Path, PathBuf};
+
+#[derive(Args)]
+#[group(required = true, multiple = false)]
+pub(crate) struct Status {
+    #[arg(long, value_name = "DIRECTORY")]
+    root: Option<PathBuf>,
+    #[arg(long)]
+    root_id: Option<RootId>,
+}
+
+#[derive(Serialize)]
+#[serde(
+    tag = "kind",
+    rename_all = "snake_case",
+    rename_all_fields = "camelCase"
+)]
+enum Observation {
+    NotInstalled,
+    Incomplete,
+    Installed(Box<Installed>),
+}
+
+#[derive(Serialize)]
+#[serde(rename_all = "camelCase")]
+struct Installed {
+    deployment: Deployment,
+    pending_update: Option<Deployment>,
+    supervisor: service::Observation,
+    host: HostObservation,
+}
+
+#[derive(Serialize)]
+#[serde(tag = "kind", rename_all = "snake_case")]
+enum HostObservation {
+    Connected {
+        identity: LiveHost,
+        activity: Activity,
+    },
+    Unavailable {
+        message: String,
+    },
+    NotAdmitted,
+}
+
+#[derive(Serialize, Deserialize)]
+#[serde(rename_all = "camelCase")]
+struct Activity {
+    state: Lifecycle,
+    connections: usize,
+    active_operations: usize,
+    active_residencies: usize,
+}
+
+impl Status {
+    pub async fn run(self) -> Result<(), HostError> {
+        if let Some(root) = self.root {
+            let mut client = HostClient::connect(&root, None).await?;
+            println!("{}", serde_json::to_string(&client.status().await?)?);
+            return Ok(());
+        }
+        let id = self.root_id.ok_or("missing State Root target")?;
+        let observation = observe(&id).await?;
+        println!("{}", serde_json::to_string(&observation)?);
+        Ok(())
+    }
+}
+
+async fn observe(id: &RootId) -> Result<Observation, HostError> {
+    let directory = match directory(&id.0) {
+        Ok(directory) => directory,
+        Err(error)
+            if error
+                .downcast_ref::<std::io::Error>()
+                .is_some_and(|error| error.kind() == std::io::ErrorKind::NotFound) =>
+        {
+            return Ok(Observation::NotInstalled);
+        }
+        Err(error) => return Err(error),
+    };
+    let observation = match store::read(&directory).await? {
+        store::Installation::Missing => Observation::NotInstalled,
+        store::Installation::Incomplete => Observation::Incomplete,
+        store::Installation::Installed(deployment) => {
+            if deployment.root_id != id.0 {
+                return Err("deployment root identity differs".into());
+            }
+            deployment.validate_record(&directory)?;
+            let pending_update = pending(&directory, &deployment).await?;
+            let (supervisor, host) = tokio::join!(
+                service::observe(deployment.clone()),
+                observe_host(&deployment),
+            );
+            // Only configuration is bracketed. OS and Host observations can
+            // differ in time, including a restart that keeps this revision.
+            match store::read(&directory).await? {
+                store::Installation::Installed(after) if after == deployment => {}
+                _ => return Err("deployment changed during observation; query again".into()),
+            }
+            Observation::Installed(Box::new(Installed {
+                deployment,
+                pending_update,
+                supervisor,
+                host,
+            }))
+        }
+    };
+    Ok(observation)
+}
+
+async fn observe_host(deployment: &Deployment) -> HostObservation {
+    if deployment.admission == Admission::Revoked {
+        return HostObservation::NotAdmitted;
+    }
+    let result = async {
+        let mut client =
+            HostClient::connect(&deployment.root_path, Some(&deployment.generation())).await?;
+        let identity = client.live_host(deployment.websocket.port()).await?;
+        let activity = serde_json::from_value(client.status().await?)?;
+        Ok::<_, HostError>(HostObservation::Connected { identity, activity })
+    }
+    .await;
+    result.unwrap_or_else(|error| HostObservation::Unavailable {
+        message: error.to_string().chars().take(2048).collect(),
+    })
+}
+
+async fn pending(directory: &Path, current: &Deployment) -> Result<Option<Deployment>, HostError> {
+    // Earlier installed operators have only the Active table. Observation must
+    // not run migrations or create a pending table on their behalf.
+    let mut connection = SqliteConnection::connect_with(
+        &SqliteConnectOptions::new()
+            .filename(directory.join("deployment.sqlite"))
+            .read_only(true),
+    )
+    .await?;
+    let result = async {
+        let exists: bool = sqlx::query_scalar(
+            "SELECT EXISTS(SELECT 1 FROM sqlite_schema WHERE type='table' AND name='deployment_update')",
+        ).fetch_one(&mut connection).await?;
+        if !exists { return Ok(None) }
+        let value: Option<String> = sqlx::query_scalar(
+            "SELECT CASE WHEN length(CAST(target AS BLOB)) <= 65536 THEN target ELSE '' END FROM deployment_update WHERE singleton = 1",
+        ).fetch_optional(&mut connection).await?;
+        let target = value.map(|value| serde_json::from_str::<Deployment>(&value)).transpose()?;
+        if let Some(target) = &target {
+            target.validate_record(directory)?;
+            updates::validate_target(current, target)?;
+        }
+        Ok::<_, HostError>(target)
+    }.await;
+    let closed = connection.close().await;
+    let target = result?;
+    closed?;
+    Ok(target)
+}
diff --git a/crates/cli/src/deployment/service.rs b/crates/cli/src/deployment/service.rs
index 1de2614b8c..8d1f194f84 100644
--- a/crates/cli/src/deployment/service.rs
+++ b/crates/cli/src/deployment/service.rs
@@ -22,6 +22,10 @@ use maka_event_log::root::{FileLease, RootOwner};
 use maka_runtime_host::server::HostError;
 use std::sync::Arc;
 
+mod status;
+use status::State;
+pub(super) use status::{Observation, observe};
+
 #[cfg(target_os = "linux")]
 mod linux;
 #[cfg(target_os = "linux")]
@@ -109,14 +113,16 @@ fn arguments(deployment: &Deployment) -> Result<[&str; 5], HostError> {
         .executable
         .to_str()
         .ok_or("service executable must be UTF-8")?;
-    let root = deployment
-        .root_path
-        .to_str()
-        .ok_or("service root must be UTF-8")?;
-    if executable.chars().chain(root.chars()).any(char::is_control) {
+    if executable.chars().any(char::is_control) {
         return Err("service paths cannot contain control characters".into());
     }
-    Ok([executable, "host", "service-run", "--root", root])
+    Ok([
+        executable,
+        "host",
+        "service-run",
+        "--root-id",
+        &deployment.root_id,
+    ])
 }
 
 fn label(deployment: &Deployment) -> String {
diff --git a/crates/cli/src/deployment/service/linux.rs b/crates/cli/src/deployment/service/linux.rs
index 314840bcff..1a3ff594b0 100644
--- a/crates/cli/src/deployment/service/linux.rs
+++ b/crates/cli/src/deployment/service/linux.rs
@@ -128,6 +128,44 @@ impl Service {
         checked(command("systemctl", &["--user", "start", &self.unit])?)?;
         Ok(())
     }
+
+    pub fn observe(&self) -> Result<super::Observation, HostError> {
+        use super::{Observation, State};
+        let output = checked(command(
+            "systemctl",
+            &[
+                "--user",
+                "show",
+                "--property=LoadState,ActiveState,UnitFileState,MainPID,ExecMainStatus",
+                &self.unit,
+            ],
+        )?)?;
+        let fields: std::collections::BTreeMap<_, _> = output
+            .lines()
+            .filter_map(|line| line.split_once('='))
+            .collect();
+        let field = |key| fields.get(key).copied().ok_or("incomplete systemd status");
+        if field("LoadState")? == "not-found" {
+            return Ok(Observation::Missing);
+        }
+        let state = match field("ActiveState")? {
+            "active" | "reloading" => State::Running,
+            "activating" => State::Starting,
+            "deactivating" => State::Stopping,
+            "inactive" => State::Stopped,
+            "failed" => State::Failed,
+            _ => return Err("unrecognized systemd activity state".into()),
+        };
+        Ok(Observation::Present {
+            state,
+            enabled: Some(matches!(
+                field("UnitFileState")?,
+                "enabled" | "enabled-runtime"
+            )),
+            pid: std::num::NonZeroU32::new(field("MainPID")?.parse()?),
+            last_result: Some(field("ExecMainStatus")?.parse()?),
+        })
+    }
 }
 
 fn quote(value: &str) -> String {
diff --git a/crates/cli/src/deployment/service/macos.rs b/crates/cli/src/deployment/service/macos.rs
index 0265e5fa19..60f564ffe7 100644
--- a/crates/cli/src/deployment/service/macos.rs
+++ b/crates/cli/src/deployment/service/macos.rs
@@ -33,6 +33,7 @@ pub(super) struct Service {
 
 struct Instance {
     pid: Option<libc::pid_t>,
+    last_result: i64,
 }
 
 impl Service {
@@ -81,12 +82,17 @@ impl Service {
         Ok(())
     }
 
-    pub fn stop(&self) -> Result<(), HostError> {
+    fn require_domain(&self) -> Result<(), HostError> {
         if self.in_user_domain(&["managername"])?.trim() != "Aqua"
             || self.in_user_domain(&["manageruid"])?.trim() != self.uid
         {
             return Err("the account GUI launchd domain is unavailable".into());
         }
+        Ok(())
+    }
+
+    pub fn stop(&self) -> Result<(), HostError> {
+        self.require_domain()?;
         // Unlike print's diagnostic format, list's three columns are documented.
         if let Some(instance) = self.instance()? {
             // Root is held, so even a racing automatic launch cannot execute work.
@@ -131,7 +137,10 @@ impl Service {
                             .ok_or("invalid launchd service PID")?,
                     ),
                 };
-                return Ok(Some(Instance { pid }));
+                return Ok(Some(Instance {
+                    pid,
+                    last_result: columns[1].parse()?,
+                }));
             }
         }
         Ok(None)
@@ -142,6 +151,38 @@ impl Service {
         checked(command("/bin/launchctl", &["kickstart", &self.target])?)?;
         Ok(())
     }
+
+    pub fn observe(&self) -> Result<super::Observation, HostError> {
+        use super::{Observation, State};
+        self.require_domain()?;
+        if let Some(instance) = self.instance()? {
+            return Ok(Observation::Present {
+                state: if instance.pid.is_some() {
+                    State::Running
+                } else if instance.last_result == 0 {
+                    State::Stopped
+                } else {
+                    State::Failed
+                },
+                enabled: None,
+                pid: instance
+                    .pid
+                    .and_then(|pid| std::num::NonZeroU32::new(pid as u32)),
+                last_result: Some(instance.last_result),
+            });
+        }
+        match self.path.symlink_metadata() {
+            Ok(metadata) if metadata.is_file() => Ok(Observation::Present {
+                state: State::Stopped,
+                enabled: None,
+                pid: None,
+                last_result: None,
+            }),
+            Err(error) if error.kind() == std::io::ErrorKind::NotFound => Ok(Observation::Missing),
+            Err(error) => Err(error.into()),
+            Ok(_) => Err("service definition is not a regular file".into()),
+        }
+    }
 }
 
 fn process_exists(pid: libc::pid_t) -> bool {
diff --git a/crates/cli/src/deployment/service/status.rs b/crates/cli/src/deployment/service/status.rs
new file mode 100644
index 0000000000..870911b360
--- /dev/null
+++ b/crates/cli/src/deployment/service/status.rs
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use super::{Deployment, HostError, platform};
+use serde::Serialize;
+use std::num::NonZeroU32;
+
+#[derive(Serialize)]
+#[serde(tag = "kind", rename_all = "snake_case")]
+pub(crate) enum Observation {
+    OnDemand,
+    Missing,
+    Present {
+        state: State,
+        enabled: Option<bool>,
+        pid: Option<NonZeroU32>,
+        #[serde(rename = "lastResult")]
+        last_result: Option<i64>,
+    },
+    Unavailable {
+        message: String,
+    },
+}
+
+#[derive(Serialize)]
+#[serde(rename_all = "snake_case")]
+pub(crate) enum State {
+    Stopped,
+    #[cfg(any(target_os = "linux", windows))]
+    Starting,
+    Running,
+    #[cfg(target_os = "linux")]
+    Stopping,
+    #[cfg(unix)]
+    Failed,
+}
+
+pub(crate) async fn observe(deployment: Deployment) -> Observation {
+    if deployment.mode == super::super::Mode::OnDemand {
+        return Observation::OnDemand;
+    }
+    let result =
+        tokio::task::spawn_blocking(move || platform::Service::new(&deployment)?.observe())
+            .await
+            .map_err(HostError::from)
+            .and_then(|result| result);
+    match result {
+        Ok(observed) => observed,
+        Err(error) => Observation::Unavailable {
+            message: error.to_string().chars().take(2048).collect(),
+        },
+    }
+}
diff --git a/crates/cli/src/deployment/service/windows.rs b/crates/cli/src/deployment/service/windows.rs
index 72d28fd62d..7075a4c235 100644
--- a/crates/cli/src/deployment/service/windows.rs
+++ b/crates/cli/src/deployment/service/windows.rs
@@ -29,7 +29,8 @@ use windows::{
             },
             TaskScheduler::{
                 IRegisteredTask, ITaskFolder, ITaskService, TASK_CREATE_OR_UPDATE,
-                TASK_LOGON_INTERACTIVE_TOKEN, TASK_STATE_DISABLED, TaskScheduler,
+                TASK_LOGON_INTERACTIVE_TOKEN, TASK_STATE_DISABLED, TASK_STATE_QUEUED,
+                TASK_STATE_READY, TASK_STATE_RUNNING, TaskScheduler,
             },
             Variant::VARIANT,
         },
@@ -170,6 +171,37 @@ impl Service {
         Ok(())
     }
 
+    pub fn observe(&self) -> Result<super::Observation, HostError> {
+        use super::{Observation, State};
+        let Some(task) = self.task()? else {
+            return Ok(Observation::Missing);
+        };
+        // SAFETY: observation stays on this object's COM apartment thread.
+        unsafe {
+            let last_result = if task.LastRunTime()? > 0.0 {
+                Some(i64::from(task.LastTaskResult()?))
+            } else {
+                None
+            };
+            let state = match task.State()? {
+                TASK_STATE_RUNNING => State::Running,
+                TASK_STATE_QUEUED => State::Starting,
+                // LastTaskResult also contains successful scheduler statuses
+                // such as user termination; it is not a process exit code.
+                TASK_STATE_READY | TASK_STATE_DISABLED => State::Stopped,
+                _ => return Err("unrecognized scheduled task state".into()),
+            };
+            Ok(Observation::Present {
+                state,
+                enabled: Some(task.Enabled()?.as_bool()),
+                // Task engine PID is not the Host PID; only the live handshake
+                // and diagnostics identify the actual execution owner.
+                pid: None,
+                last_result,
+            })
+        }
+    }
+
     fn task(&self) -> Result<Option<IRegisteredTask>, HostError> {
         // SAFETY: retrieval and ownership validation share this COM apartment.
         unsafe {
diff --git a/crates/cli/src/deployment/updates.rs b/crates/cli/src/deployment/updates.rs
index e5f767a852..9c93a1bf91 100644
--- a/crates/cli/src/deployment/updates.rs
+++ b/crates/cli/src/deployment/updates.rs
@@ -107,7 +107,7 @@ pub(super) async fn commit(
     Ok(())
 }
 
-fn validate_target(current: &Deployment, target: &Deployment) -> Result<(), StoreError> {
+pub(super) fn validate_target(current: &Deployment, target: &Deployment) -> Result<(), StoreError> {
     let mut expected = target.clone();
     expected.executable = current.executable.clone();
     expected.sha256 = current.sha256.clone();
diff --git a/crates/cli/src/main.rs b/crates/cli/src/main.rs
index 080f6c3b13..d50ec1fc8b 100644
--- a/crates/cli/src/main.rs
+++ b/crates/cli/src/main.rs
@@ -33,11 +33,7 @@ mod windows;
 async fn main() -> std::process::ExitCode {
     let cli = args::Cli::parse();
     let error_exit = cli.error_exit_code();
-    let result = if env!("CARGO_BIN_NAME") == "maka-service" {
-        cli.run_service().await
-    } else {
-        cli.run().await
-    };
+    let result = cli.run().await;
     if let Err(error) = result {
         eprintln!("{error}");
         // Let Tokio wait for accepted blocking work to finish before the OS
diff --git a/crates/cli/src/serve.rs b/crates/cli/src/serve.rs
index 2c65284f8a..c6f543174b 100644
--- a/crates/cli/src/serve.rs
+++ b/crates/cli/src/serve.rs
@@ -24,7 +24,7 @@ use tokio_util::sync::CancellationToken;
 pub(super) async fn run(
     path: &Path,
     websocket: Option<std::net::SocketAddr>,
-    require_managed: bool,
+    expected_root: Option<&str>,
 ) -> Result<(), maka_runtime_host::server::HostError> {
     use maka_event_log::root::{ROOT_MARKER, RootNamespaces, RootOwner};
     use maka_runtime_host::server::{Host, websocket::WebSocketListener};
@@ -35,7 +35,7 @@ pub(super) async fn run(
             match RootOwner::open(path, &namespaces) {
                 Ok(owner) => break owner,
                 Err(error)
-                    if require_managed
+                    if expected_root.is_some()
                         && error.kind() == std::io::ErrorKind::WouldBlock
                         && tokio::time::Instant::now() < deadline =>
                 {
@@ -46,13 +46,16 @@ pub(super) async fn run(
                 Err(error) => return Err(error.into()),
             }
         }
-    } else if !require_managed {
+    } else if expected_root.is_none() {
         RootOwner::create(path, &namespaces)?
     } else {
         return Err("service State Root must already be installed".into());
     };
+    if expected_root.is_some_and(|expected| expected != owner.root_id()) {
+        return Err("service State Root identity changed".into());
+    }
     let deployment = crate::deployment::admit(&owner, crate::deployment::Mode::Supervised).await?;
-    if require_managed && deployment.is_none() {
+    if expected_root.is_some() && deployment.is_none() {
         return Err("service State Root must have a supervised deployment".into());
     }
     let websocket = match deployment
diff --git a/crates/cli/src/windows.rs b/crates/cli/src/windows.rs
index fd64ccb6d6..fc668ddbab 100644
--- a/crates/cli/src/windows.rs
+++ b/crates/cli/src/windows.rs
@@ -37,6 +37,76 @@ use windows_sys::Win32::System::{
 // the Host exits, terminating descendants without killing the Host during Drop.
 static OWNER: OnceLock<io::Result<OwnedHandle>> = OnceLock::new();
 
+// SetStdHandle borrows the file handle. Retain it until process exit, including
+// final error reporting and Tokio's shutdown of accepted blocking work.
+static SERVICE_STDERR: OnceLock<io::Result<std::fs::File>> = OnceLock::new();
+
+pub(super) fn service_stderr(directory: &std::path::Path) -> io::Result<()> {
+    SERVICE_STDERR
+        .get_or_init(|| open_service_stderr(directory))
+        .as_ref()
+        .map(|_| ())
+        .map_err(|error| io::Error::new(error.kind(), error.to_string()))
+}
+
+fn open_service_stderr(directory: &std::path::Path) -> io::Result<std::fs::File> {
+    use maka_event_log::root::windows::{
+        PrivateSecurity, file_identity, open_nofollow, validate_private,
+    };
+    use std::os::windows::{ffi::OsStrExt, fs::MetadataExt};
+    use windows_sys::Win32::{
+        Foundation::{GENERIC_READ, INVALID_HANDLE_VALUE},
+        Storage::FileSystem::{
+            CreateFileW, FILE_APPEND_DATA, FILE_ATTRIBUTE_REPARSE_POINT,
+            FILE_FLAG_OPEN_REPARSE_POINT, FILE_SHARE_DELETE, FILE_SHARE_READ, FILE_SHARE_WRITE,
+            OPEN_ALWAYS,
+        },
+        System::Console::{STD_ERROR_HANDLE, SetStdHandle},
+    };
+
+    let parent = open_nofollow(directory, false)?;
+    validate_private(&parent)?;
+    if !parent.metadata()?.is_dir() {
+        return Err(io::Error::other("service deployment is not a directory"));
+    }
+    let path = directory.join("host.stderr.log");
+    let name: Vec<_> = path.as_os_str().encode_wide().chain(Some(0)).collect();
+    let security = PrivateSecurity::current_account()?;
+    // SAFETY: name and private descriptor live through the call. Append-only
+    // writes preserve concurrent startup diagnostics without following reparse points.
+    let handle = unsafe {
+        CreateFileW(
+            name.as_ptr(),
+            GENERIC_READ | FILE_APPEND_DATA,
+            FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
+            &security.attributes(),
+            OPEN_ALWAYS,
+            FILE_FLAG_OPEN_REPARSE_POINT,
+            ptr::null_mut(),
+        )
+    };
+    if handle == INVALID_HANDLE_VALUE {
+        return Err(io::Error::last_os_error());
+    }
+    // SAFETY: CreateFileW returned one owned file handle.
+    let file = unsafe { std::fs::File::from_raw_handle(handle) };
+    let metadata = file.metadata()?;
+    if !metadata.is_file()
+        || metadata.file_attributes() & FILE_ATTRIBUTE_REPARSE_POINT != 0
+        || file_identity(&file)?.links != 1
+    {
+        return Err(io::Error::other(
+            "service log is not a regular, singly linked file",
+        ));
+    }
+    validate_private(&file)?;
+    // SAFETY: SERVICE_STDERR owns the returned file until the process exits.
+    if unsafe { SetStdHandle(STD_ERROR_HANDLE, file.as_raw_handle()) } == 0 {
+        return Err(io::Error::last_os_error());
+    }
+    Ok(file)
+}
+
 pub(super) fn own_process_tree() -> io::Result<()> {
     OWNER
         .get_or_init(create)
diff --git a/crates/cli/tests/integration/deployment.rs b/crates/cli/tests/integration/deployment.rs
index 0dd0292660..49c2cee458 100644
--- a/crates/cli/tests/integration/deployment.rs
+++ b/crates/cli/tests/integration/deployment.rs
@@ -35,6 +35,16 @@ fn managed_installation_pins_code_before_migration_and_preserves_live_authority(
     let namespaces = RootNamespaces::for_current_account().unwrap();
     for mode in ["on-demand", "supervised"] {
         let mut fixture = CandidateFixture::new(temporary.path().join(mode));
+        let query_id = fixture.root_id.clone();
+        let query = |action: &str| {
+            let output = Command::new(env!("CARGO_BIN_EXE_maka"))
+                .args(["host", action, "--root-id", &query_id])
+                .output()
+                .unwrap();
+            assert!(output.status.success(), "{output:?}");
+            serde_json::from_slice::<Value>(&output.stdout).unwrap()
+        };
+        assert_eq!(query("status")["kind"], "not_installed");
         let mut install = Command::new(env!("CARGO_BIN_EXE_maka"));
         install
             .args(["host", "install", "--root"])
@@ -63,23 +73,50 @@ fn managed_installation_pins_code_before_migration_and_preserves_live_authority(
         let executable = installed["executable"].as_str().unwrap();
         assert_eq!(installed["rootId"], fixture.root_id);
         assert_eq!(installed["configRevision"], 1);
+        let owner = RootOwner::open(&fixture.root, &namespaces).unwrap();
+        let observed = query("status");
+        assert_eq!(observed["deployment"], installed);
+        assert_eq!(observed["host"]["kind"], "unavailable");
+        assert!(observed["pendingUpdate"].is_null());
+        if mode == "on-demand" {
+            assert_eq!(observed["supervisor"]["kind"], "on_demand");
+            assert_eq!(query("logs")["kind"], "not_captured");
+        }
+        #[cfg(any(target_os = "macos", windows))]
+        if mode == "supervised" {
+            let path = directory.join("host.stderr.log");
+            #[cfg(windows)]
+            let mut file = maka_event_log::root::windows::create_private_file(&path).unwrap();
+            #[cfg(target_os = "macos")]
+            let mut file = {
+                use std::os::unix::fs::OpenOptionsExt;
+                std::fs::OpenOptions::new()
+                    .write(true)
+                    .create_new(true)
+                    .mode(0o600)
+                    .open(&path)
+                    .unwrap()
+            };
+            let contents = "old diagnostics\n".repeat(8192) + "latest failure\n";
+            file.write_all(contents.as_bytes()).unwrap();
+            drop(file);
+            let log = query("logs");
+            assert_eq!(log["source"]["kind"], "stderr");
+            assert_eq!(log["byteTruncated"], true);
+            assert_eq!(log["text"], contents[contents.len() - 48 * 1024..]);
+            assert_eq!(std::fs::read_to_string(path).unwrap(), contents);
+        }
+        assert!(!fixture.root.join("runtime-rust.sqlite").exists());
+        drop(owner);
 
         let launch_root = fixture.root.clone();
         let launch_root_id = fixture.root_id.clone();
         let command = |executable: &str, candidate: bool| {
             let mut command = Command::new(executable);
-            command
-                .args([
-                    "host",
-                    if candidate {
-                        "candidate"
-                    } else {
-                        "service-run"
-                    },
-                    "--root",
-                ])
-                .arg(&launch_root);
             if candidate {
+                command
+                    .args(["host", "candidate", "--root"])
+                    .arg(&launch_root);
                 command.args([
                     "--expected-root-id",
                     &launch_root_id,
@@ -89,6 +126,8 @@ fn managed_installation_pins_code_before_migration_and_preserves_live_authority(
                     "--initial-connection-timeout-ms",
                     "300000",
                 ]);
+            } else {
+                command.args(["host", "service-run", "--root-id", &launch_root_id]);
             }
             command
         };
@@ -105,6 +144,28 @@ fn managed_installation_pins_code_before_migration_and_preserves_live_authority(
             !wrong_mode.status.success(),
             "launch mode bypassed deployment policy"
         );
+        #[cfg(windows)]
+        if !candidate {
+            let log = directory.join("host.stderr.log");
+            let before = std::fs::read(&log).unwrap();
+            let marker = fixture.root.join(maka_event_log::root::ROOT_MARKER);
+            let backup = fixture.root.join("marker.backup");
+            std::fs::rename(&marker, &backup).unwrap();
+            let failed = command(executable, false).output();
+            std::fs::rename(&backup, &marker).unwrap();
+            let failed = failed.unwrap();
+            assert!(!failed.status.success());
+            let after = std::fs::read(log).unwrap();
+            assert!(
+                after.starts_with(&before),
+                "startup overwrote previous diagnostics"
+            );
+            assert!(
+                String::from_utf8_lossy(&after[before.len()..])
+                    .contains("service State Root must already be installed"),
+                "early failure was lost before main reported it"
+            );
+        }
         assert!(
             !fixture.root.join("runtime-rust.sqlite").exists(),
             "admission must precede migrations"
@@ -172,6 +233,14 @@ fn managed_installation_pins_code_before_migration_and_preserves_live_authority(
         assert_eq!(connected["hostEpoch"], registration["hostEpoch"]);
         assert_eq!(connected["pid"], registration["pid"]);
         assert_eq!(connected["endpoint"]["port"], address.port());
+        let observed = query("status");
+        assert_eq!(observed["host"]["kind"], "connected");
+        assert_eq!(
+            observed["host"]["identity"]["hostEpoch"],
+            registration["hostEpoch"]
+        );
+        assert_eq!(observed["host"]["identity"]["pid"], registration["pid"]);
+        assert_eq!(observed["host"]["activity"]["state"], "ready");
         assert!(RootOwner::open(&fixture.root, &namespaces).is_err());
         let retired = Command::new(env!("CARGO_BIN_EXE_maka"))
             .args(["host", "retire", "--root"])
@@ -269,6 +338,9 @@ fn managed_installation_pins_code_before_migration_and_preserves_live_authority(
         assert_eq!(uninstalled["deployment"]["admission"], "revoked");
         assert_eq!(uninstalled["deployment"]["configRevision"], 2);
         assert_eq!(uninstalled["cleanup"]["kind"], "complete");
+        let observed = query("status");
+        assert_eq!(observed["deployment"], uninstalled["deployment"]);
+        assert_eq!(observed["host"]["kind"], "not_admitted");
         let repeated = control("uninstall").output().unwrap();
         assert!(repeated.status.success(), "{repeated:?}");
         assert_eq!(
diff --git a/crates/protocol/src/handshake.rs b/crates/protocol/src/handshake.rs
index 09c99d07e2..918d998706 100644
--- a/crates/protocol/src/handshake.rs
+++ b/crates/protocol/src/handshake.rs
@@ -124,7 +124,7 @@ impl ClientHello {
     }
 }
 
-#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize)]
+#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, serde::Deserialize)]
 #[serde(rename_all = "snake_case")]
 pub enum Lifecycle {
     Starting,
diff --git a/docs/rust-runtime.md b/docs/rust-runtime.md
index ef866ac4c8..4f283189f1 100644
--- a/docs/rust-runtime.md
+++ b/docs/rust-runtime.md
@@ -84,6 +84,13 @@ the service; it retains Root data, packages and a deployment tombstone. Retry th
 same uninstall if `cleanup.kind` is `pending`. Explicit installation grants a new
 deployment identity after the old service has been removed.
 
+`host status --root-id <rootId>` reads the deployment, pending update, OS service
+and live Host independently; it never starts or repairs them. An unavailable Host
+is not proof that its process stopped. `host logs --root-id <rootId>` returns up to
+48 KiB of supervised diagnostics, with `byteTruncated` marking omitted bytes.
+Linux selects the latest 200 journal entries; macOS/Windows read stderr. These are
+diagnostics, not execution history. On-demand stderr is not captured.
+
 The `maka` command also provides `host candidate` for Desktop-owned startup,
 `code --log <file>` for a JavaScript cell read from stdin, and
 `inspect --log <file>` for committed execution facts.
diff --git a/docs/rust-runtime.zh-CN.md b/docs/rust-runtime.zh-CN.md
index 2853a2cecd..54e677ee82 100644
--- a/docs/rust-runtime.zh-CN.md
+++ b/docs/rust-runtime.zh-CN.md
@@ -69,6 +69,11 @@ Windows 托管服务使用同目录的 `maka-service.exe`,它是同一 Host 
 停止和重启保留待更新目标。卸载先撤销启动资格,再注销服务;Root 数据、代码包及部署撤销记录均保留。
 若 `cleanup.kind` 为 `pending`,重试相同卸载命令;显式安装会在旧服务清理完成后授予新的部署身份。
 
+`host status --root-id <rootId>` 分别读取部署、待更新目标、OS 服务及活体 Host,不启动或修复它们;
+Host 不可连接不代表进程已停止。`host logs --root-id <rootId>` 返回最多 48 KiB 的托管诊断尾部,
+`byteTruncated` 标明省略的字节。Linux 选择最近 200 条 journal 记录;macOS/Windows 读取 stderr。
+这些是诊断信息,不是执行历史;按需 Host 不捕获 stderr。
+
 `maka` 命令还提供 Desktop 启动用的 `host candidate`、从 stdin 读取 JavaScript cell 的
 `code --log <file>`,以及查看已提交执行事实的 `inspect --log <file>`。
 


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org