memoryd: the Honcho worker sends conclusions, their deletions and fleet notes
Co-Authored-By: ornith-1.5-35b-a3b <agent@wntrmute.dev>
This commit is contained in:
@@ -127,6 +127,7 @@ pub struct Clients {
|
||||
untrusted: Client,
|
||||
fleet: Client,
|
||||
agent: String,
|
||||
owner: String,
|
||||
ensured: HashSet<(Workspace, Ensured)>,
|
||||
}
|
||||
|
||||
@@ -233,6 +234,7 @@ impl Clients {
|
||||
)?,
|
||||
fleet: client(&config.url, &config.fleet, fleet_key.as_ref(), timeouts)?,
|
||||
agent: config.agent.clone(),
|
||||
owner: config.owner.clone(),
|
||||
ensured: HashSet::new(),
|
||||
};
|
||||
Ok((clients, warnings))
|
||||
@@ -307,6 +309,36 @@ impl Clients {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Make sure memory session `name` (a Boxmaker session's `<id>_memory`) exists in
|
||||
/// `workspace`, after the workspace, the agent's peer and the owner's. It holds conclusions,
|
||||
/// no messages, so neither peer observes (M5c spec, section 4).
|
||||
pub fn ensure_memory_session(
|
||||
&mut self,
|
||||
workspace: Workspace,
|
||||
name: &str,
|
||||
) -> Result<(), HonchoError> {
|
||||
self.ensure_workspace(workspace)?;
|
||||
let (agent, owner) = (self.agent.clone(), self.owner.clone());
|
||||
self.ensure_peer(workspace, &agent)?;
|
||||
self.ensure_peer(workspace, &owner)?;
|
||||
let key = (workspace, Ensured::Session(name.to_string()));
|
||||
if self.ensured.contains(&key) {
|
||||
return Ok(());
|
||||
}
|
||||
let unobserved = || {
|
||||
SessionPeerConfig::new()
|
||||
.observe_me(false)
|
||||
.observe_others(false)
|
||||
};
|
||||
let mut peers = HashMap::new();
|
||||
peers.insert(agent, unobserved());
|
||||
peers.insert(owner, unobserved());
|
||||
let create = SessionCreate::new(name).with_peers(peers);
|
||||
created(self.client(workspace).session(&create))?;
|
||||
self.ensured.insert(key);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Delete conclusion `id` in `workspace`. Gone already (404) counts as done.
|
||||
pub fn delete_conclusion(&self, workspace: Workspace, id: &str) -> Result<(), HonchoError> {
|
||||
match self.client(workspace).delete_conclusion(id) {
|
||||
|
||||
Reference in New Issue
Block a user