move hive-sh4re's paused_marker() composition into hive-agent
This commit is contained in:
parent
aa14339be7
commit
2024848251
5 changed files with 32 additions and 25 deletions
|
|
@ -243,7 +243,7 @@ and inbox messages queue unacked until it's removed (see
|
|||
|
||||
Unusually, it's read and written from **both** sides of the harness
|
||||
bind-mount, and that's the whole design: the harness stats it
|
||||
in-container via `hive_sh4re::paths::paused_marker`, while hive-c0re
|
||||
in-container via `hive_agent::paths::paused_marker`, while hive-c0re
|
||||
stats it on the host (`Coordinator::is_paused`) to populate the
|
||||
`paused` field on the agent card, and creates/removes it
|
||||
(`Coordinator::set_paused`) for `hivectl agent <name> pause|resume` and the
|
||||
|
|
|
|||
|
|
@ -686,7 +686,7 @@ async fn serve_loop<S: Surface>(
|
|||
// need to be: hive-c0re skips the stop-checkpoint handshake for
|
||||
// a paused agent, because this check sits at the top of the loop
|
||||
// and so a paused agent provably has no turn in flight.
|
||||
if hive_sh4re::paths::paused_marker().exists() {
|
||||
if paths::paused_marker().exists() {
|
||||
if !was_paused {
|
||||
tracing::info!("pause marker present — parking the turn loop");
|
||||
bus.emit(LiveEvent::Note {
|
||||
|
|
@ -827,7 +827,7 @@ fn apply_todo_wake_checked(checked: Option<bool>, todo_miss_streak: &mut u32, bu
|
|||
consecutive todo wakes — an operator needs to resume this agent"
|
||||
),
|
||||
});
|
||||
if let Err(e) = std::fs::write(hive_sh4re::paths::paused_marker(), "") {
|
||||
if let Err(e) = std::fs::write(paths::paused_marker(), "") {
|
||||
tracing::warn!(error = ?e, "failed to write pause marker");
|
||||
}
|
||||
// Fresh slate for whenever this agent gets resumed — see
|
||||
|
|
|
|||
|
|
@ -90,6 +90,29 @@ pub fn config_dir() -> PathBuf {
|
|||
PathBuf::from("/run/hive-config")
|
||||
}
|
||||
|
||||
/// Marker file whose presence means "this agent is paused": the harness
|
||||
/// keeps serving its web UI and MCP daemons but drives no turns, so
|
||||
/// inbox messages queue up unacked until it's removed.
|
||||
///
|
||||
/// It lives in the harness dir rather than `state/` because `state/` is
|
||||
/// the agent's own scratch space — this is harness control state. The
|
||||
/// harness dir is bind-mounted from the host, so the marker is the
|
||||
/// single source of truth for both sides: the harness stats it to gate
|
||||
/// the turn loop, and hive-c0re stats it to render the paused
|
||||
/// indicator and creates/removes it for `hivectl pause|resume`. Being a
|
||||
/// plain file, it survives container restarts — pause is sticky by
|
||||
/// construction, and works even when the harness isn't running.
|
||||
/// The filename constant is shared via `hive_sh4re::paths::PAUSED_MARKER_FILE`
|
||||
/// (itself re-exported from `hive-priv-sock`, the actual writer on the host
|
||||
/// side) so this resolver and hive-c0re's host-side one
|
||||
/// (`Coordinator::agent_paused_marker`) cannot drift apart — only the
|
||||
/// call-site-specific composition lived in the shared crate for no reason,
|
||||
/// since hive-agent is the only in-container caller.
|
||||
#[must_use]
|
||||
pub fn paused_marker() -> PathBuf {
|
||||
harness_dir().join(hive_sh4re::paths::PAUSED_MARKER_FILE)
|
||||
}
|
||||
|
||||
/// Claude credentials directory for the current agent. `$HOME/.claude`
|
||||
/// matches what the `claude` CLI reads at runtime — the harness sees
|
||||
/// the same `$HOME` set by the per-service systemd `environment`
|
||||
|
|
|
|||
|
|
@ -1557,7 +1557,7 @@ impl Coordinator {
|
|||
}
|
||||
|
||||
/// Host-side path of the pause marker — the same file the harness
|
||||
/// resolves in-container via `hive_sh4re::paths::paused_marker`,
|
||||
/// resolves in-container via `hive_agent::paths::paused_marker`,
|
||||
/// reached through the harness bind-mount. Its presence means the
|
||||
/// agent's turn loop is parked: the harness still serves its web UI
|
||||
/// and MCP daemons, but drives no turns, so inbox messages queue up
|
||||
|
|
|
|||
|
|
@ -33,25 +33,9 @@ pub fn harness_dir() -> PathBuf {
|
|||
/// `hive-priv-sock`, which owns the definition because hive-priv (root) is
|
||||
/// the component that actually creates and unlinks the marker — hive-c0re
|
||||
/// runs unprivileged and cannot write to the agent-owned harness dir — and
|
||||
/// hive-priv deliberately does not depend on this crate. Shared so the
|
||||
/// in-container resolver below, hive-c0re's host-side one (which builds the
|
||||
/// same path from `/var/lib/hyperhive/agents/{name}/harness`) and the
|
||||
/// privileged writer cannot drift apart.
|
||||
/// hive-priv deliberately does not depend on this crate. Shared so
|
||||
/// hive-agent's in-container resolver (`hive_agent::paths::paused_marker`),
|
||||
/// hive-c0re's host-side one (which builds the same path from
|
||||
/// `/var/lib/hyperhive/agents/{name}/harness`) and the privileged writer
|
||||
/// cannot drift apart.
|
||||
pub use hive_priv_sock::PAUSED_MARKER_FILE;
|
||||
|
||||
/// Marker file whose presence means "this agent is paused": the harness
|
||||
/// keeps serving its web UI and MCP daemons but drives no turns, so
|
||||
/// inbox messages queue up unacked until it's removed.
|
||||
///
|
||||
/// It lives in the harness dir rather than `state/` because `state/` is
|
||||
/// the agent's own scratch space — this is harness control state. The
|
||||
/// harness dir is bind-mounted from the host, so the marker is the
|
||||
/// single source of truth for both sides: the harness stats it to gate
|
||||
/// the turn loop, and hive-c0re stats it to render the paused
|
||||
/// indicator and creates/removes it for `hivectl pause|resume`. Being a
|
||||
/// plain file, it survives container restarts — pause is sticky by
|
||||
/// construction, and works even when the harness isn't running.
|
||||
#[must_use]
|
||||
pub fn paused_marker() -> PathBuf {
|
||||
harness_dir().join(PAUSED_MARKER_FILE)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue