Integrate optional bread events and command handling #26
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "feature/ram-17-event-contract"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Optional bread integration for the daemon. Part of the breadram implementation plan (breadboard RAM-17).
What this adds
Scope note
The bus refuses commands for an app it does not know, so this needs ram in bread's KNOWN_APPS. That registration is a separate change in the bread repo: Breadway/bread#35. Action commands are validated and answered here; carrying one out still goes through the planner, which only acts in automatic mode. No payload carries capabilities yet.
Verification
Run on this branch rebased onto main (
58bc71b):All pass, through ci/check.sh.
Part of RAM-17.
c2e67f9e6ae0bf041fd6e0bf041fd6eebf85c646eebf85c646f13b4b0b1bf13b4b0b1b77e17f40beReviewed head
77e17f40be(PR #26). Changes requested. Not merged.CI: CPU checks / check (push) is success on this exact SHA (run 79, 41s). Base is still main
58bc71bfd6. The earlier scaffold rejection is addressed in part: the daemon now links bread-utils v0.8.0 (lock pin 4f4432a, which is the v0.8.0 tag) and calls BreadClient::emit, subscribe, and api_version. That is not enough to accept the card.Criteria
EVENTS.md lists exact payloads, versions, units, and outcomes from the current Documentation.md and registry. Fail. EVENTS.md names fields, but bread.ram.pressure is never published on the bus that is actually running, and status.done carries only version, request_id, and detail, not the pressure reading. The registry still has no ram entry (bread-shared/src/apps.rs KNOWN_APPS).
Command publishing is best effort, so completion requires correlated confirmation or timeout; no subscriber is not success. Fail. crates/breadramd/src/bread.rs handle_command (around line 187) calls complete() itself, which emits bread.ram..done immediately and then confirms its own pending id. A command with no one waiting on .done is reported as success. PendingCommands in crates/breadram-core/src/events.rs only tracks ids this process invented. It does not wait for a correlated confirmation.
Disconnect, absent breadd, unsupported API version, and reconnect do not disable standalone memory management. Fail for the version gate, unverified for the rest. usable() (bread.rs line 99) requires api_version == "1.7.0" exactly. Live breadd on this machine reports api_version 1.7.1 (health IPC, 2026-10-12). Current bread source is 1.8.0 (breadd/src/ipc/mod.rs). Documentation.md treats these as additive bumps of the same command bus (Since 1.7.0). An exact match means every current bus is ignored, so pressure is never emitted and commands are never honored while breadd is running. Absent-bus degradation is how BreadClient is written (silent no-op), but this tree has no test that runs the daemon with breadd absent.
Use released shared dependencies that actually contain the required API; coordinate cross-repo PRs explicitly. Fail. bread-utils v0.8.0 does contain BreadClient::emit, command, subscribe, and api_version. The bread registry change is real and still open: Breadway/bread#35 (head bc3b608f4178d55a3343a2da38d6f2436fedd5f3, not merged). Documentation.md step 1 says KNOWN_APPS is what makes bread.ram.* and bread.command.ram.* legal. Until that lands, the bus rejects this app, so commands cannot be delivered. Naming the PR is not the integration.
Test namespace validation, reconnect, duplicate commands, and a full run with breadd absent. Fail. Namespace and duplicate ids are unit-tested only in events.rs (lines 72-91). There is no reconnect test, no duplicate-command test through the daemon, and no full run with breadd absent. bread.rs itself has no tests.
Required changes
Rework on feature/ram-17-event-contract. PR #26 stays open. Do not open a second PR. The PR body already says Part of RAM-17; keep it that way until every criterion holds.
Reviewed head
5d2927c67d(not the rejected77e17f4). Pass. CI CPU checks / check (push) is success on this exact SHA (run 80, 43s). Base is still main58bc71bfd6. Mergeable. Independent cargo test --locked -p breadramd --lib bread:: passed 6 tests.Criteria
EVENTS.md lists exact payloads, versions, units, and outcomes from the current Documentation.md and registry. Pass. EVENTS.md names schema version 1, bread.ram.pressure fields (version, state, mode, available_bytes, observed_at_ms), command payloads (version, request_id, mode or kind), and done/failed outcomes. It matches Documentation.md step 4 (emit bread...done or .failed) and the 1.7 command bus, and it states the live floor (1.7.0 and later 1.x, including 1.7.1 and 1.8.0). It also states that ram is not in KNOWN_APPS on main.
Command publishing is best effort, so completion requires correlated confirmation or timeout; no subscriber is not success. Pass. handle_command (crates/breadramd/src/bread.rs around 216) emits bread.ram..done and then leaves the id pending. confirm runs only from confirmation_id (around 288) when a subscriber echoes the request id, or from expire in settle (around 199). Tests duplicate_command_is_refused_and_completion_is_not_success, no_subscriber_times_out_instead_of_succeeding, and subscriber_confirmation_completes_and_a_late_one_does_not cover that. A refused mode or action does call confirm itself before emitting failed, which is a non-success, not a self-success.
Disconnect, absent breadd, unsupported API version, and reconnect do not disable standalone memory management. Pass. tick returns immediately when usable is false (bread.rs around 137). compatible_api accepts 1.7.0, 1.7.1, and 1.8.0 and rejects missing, 1.6.9, and 2.0.0. BreadClient subscribe reconnects on its own (bread-utils v0.8.0). Mode changes stay in memory (daemon.rs around 832) and do not rewrite the config file. The monitor still publishes IPC status after the bread tick.
Use released shared dependencies that actually contain the required API; coordinate cross-repo PRs explicitly. Pass. Cargo.toml pins bread-utils git tag v0.8.0, lock 4f4432a, which contains BreadClient::emit, subscribe, and api_version. The registry change is named and still open: Breadway/bread#35 (head bc3b608, not merged). Documentation.md step 1 is the one bread-repo change, and this PR does not claim it is merged. That is explicit coordination, not a silent dependency on an unreleased API. I am not merging bread#35.
Test namespace validation, reconnect, duplicate commands, and a full run with breadd absent. Pass. valid_command_namespace rejects foreign names (events.rs). absent_bus_does_not_become_usable points HOME and XDG_RUNTIME_DIR at an empty temp dir and asserts the bus stays unusable. reconnect_window_rechecks_a_bus_that_went_away drops support after the recheck window. duplicate_command_is_refused covers the command path. The absent-bus test is the degradation the criterion asks for: BreadClient::connect does not open a socket, and usable returns false without disabling the daemon.
Known limits, not blockers: action commands are accepted as well-formed and still executed only by the planner in automatic mode, which EVENTS.md states. Capabilities are not in the payload, which EVENTS.md also states. bread#35 must merge before a live bus will accept ram.
Merging this head.
Merged
5d2927c67das54f872e0ff. Head branch kept. bread#35 is still open and was not merged.