feat: accept a staged update in the app
The host has staged a downloaded, signature-checked update since step 4, but the only way to apply it was `wanderbooks update` at a terminal, and nothing in the viewer or on an agent's first call said one waited. The owner's accept is the name plan 8.0.3 allocated for it: the lease socket gains `Intent::ApplyUpdate`, and the host installs the staged copy from a thread and lets its existing watch for a replaced program (host.rs INVARIANT 7) restart onto it once no call runs, so the books stay open and every holder's session carries on. With no host running there is no call to cut off, so the viewer applies it itself. The viewer reads `<root>/updates/staged/meta.json` every few seconds and shows a standing notice with "Update now"; Books gains "Check for updates" (which looks at the feed at once, whatever the daily look last did) and "Update to X". `books.start` gains the allocated `update_waiting` field and a next step telling the agent to tell the human; no tool can accept. `apply_staged` waits up to five seconds for the update lock: running the new tests showed the host's own look can hold it for a moment after it writes `meta.json`, and the owner's accept should wait that out rather than answer "nothing waits". Tests: `books_start_says_an_update_waits` and `the_owner_accepts_a_staged_update_in_the_app` in `crates/ledger-cli/tests/update.rs` (a bridge writes all through the restart, each account in the chart exactly once); `the_menu_checks_for_updates_and_a_waiting_update_shows_a_notice_that_accepts` and `books_outside_a_data_root_have_no_update_notice` in `crates/ledger-gui/tests/update_notice.rs`.
This commit is contained in:
1 parent
812d6f203e
commit
53a233d687
10 files changed
+693
-11
No files matched your search
@@ -16,7 +16,8 @@
|
||||
//! 1. A connection's first line is one Ask; a Hold keeps the
|
||||
//! connection (the lease lasts until it closes), anything else is
|
||||
//! answered once and the connection closed.
|
||||
//! 2. Exactly two intents exist: close and consent_format_upgrade; any
|
||||
//! 2. Exactly three intents exist: close, consent_format_upgrade and
|
||||
//! apply_update; any
|
||||
//! other request is refused.
|
||||
//! 3. consent_format_upgrade carries the owner passphrase; without one
|
||||
//! it is refused before anything is done. With one, the host hands it
|
||||
@@ -106,7 +107,7 @@ pub enum Ask {
|
||||
Intent(Intent),
|
||||
}
|
||||
|
||||
/// The owner's intents: exactly these two (INVARIANT 2).
|
||||
/// The owner's intents: exactly these three (INVARIANT 2).
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "snake_case", deny_unknown_fields)]
|
||||
pub enum Intent {
|
||||
@@ -120,6 +121,10 @@ pub enum Intent {
|
||||
#[serde(default)]
|
||||
passphrase: Option<ledger_mcp::admin::Passphrase>,
|
||||
},
|
||||
/// Accept the update the host has staged (P11a step 4): the host
|
||||
/// installs it, and restarts onto it once no call is running, the
|
||||
/// books staying open to every holder across it.
|
||||
ApplyUpdate,
|
||||
}
|
||||
|
||||
impl Intent {
|
||||
@@ -258,9 +263,10 @@ mod tests {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn exactly_two_intents_are_understood() {
|
||||
fn exactly_three_intents_are_understood() {
|
||||
for intent in [
|
||||
json!("close"),
|
||||
json!("apply_update"),
|
||||
json!({"consent_format_upgrade": {"book": "acme", "passphrase": "x"}}),
|
||||
] {
|
||||
let h = parse(json!({"proto": 1, "intent": intent})).unwrap();
|
||||
|
||||
Reference in new issue
Block a user