Module state exposed before initial Lua load and store writes are applied #47

Closed
opened 2026-10-14 20:51:21 +08:00 by Breadway · 4 comments
Owner

How found: reproduced by running unmodified origin/main at e4ddf6c under 32 CPU busy loops with eight concurrent ipc_integration binaries. 7/8 suite runs failed: 2 module_with_no_manifest_keeps_full_access_but_is_flagged_ungated at the store field check, 7 rules_toml_malformed_rule_surfaces_doctor_visible_error at bread.rules present, plus one rules_toml_absent_is_a_no_op. Confidence: high. Exact causal paths: (1) Lua module_store_set directly inserts a fabricated ModuleStatus { status: Loaded, ungated: false } when on_load sets its first store value; load_module only queues final status after on_load returns. Thus a real client polling modules.list/state.get can see a loaded module with an empty/partial store and wrong ungated flag. (2) the IPC socket accepts ping/state requests before initial Lua loading finishes, and status updates are async state-engine commands; tests treat ping as ready. bread.rules can be absent from health/modules during initial load. Fix under review introduces private staging for store writes merged with final status and an explicit startup.ready IPC barrier over Lua completion plus FIFO state-engine acknowledgement. Regression exercises store staging/merge deterministically; IPC status tests wait on readiness instead of weakening assertions. Not duplicate of BREAD-30 (module-host child startup timeout), BREAD-42 (hyprland bridge), or BREAD-43 (SIGTERM bind cleanup). PR44 module_host_bridge.rs is untouched because it is not causative.

How found: reproduced by running unmodified origin/main at e4ddf6c under 32 CPU busy loops with eight concurrent ipc_integration binaries. 7/8 suite runs failed: 2 `module_with_no_manifest_keeps_full_access_but_is_flagged_ungated` at the store field check, 7 `rules_toml_malformed_rule_surfaces_doctor_visible_error` at `bread.rules present`, plus one `rules_toml_absent_is_a_no_op`. Confidence: high. Exact causal paths: (1) Lua module_store_set directly inserts a fabricated `ModuleStatus { status: Loaded, ungated: false }` when on_load sets its first store value; `load_module` only queues final status after on_load returns. Thus a real client polling modules.list/state.get can see a loaded module with an empty/partial store and wrong ungated flag. (2) the IPC socket accepts ping/state requests before initial Lua loading finishes, and status updates are async state-engine commands; tests treat ping as ready. `bread.rules` can be absent from health/modules during initial load. Fix under review introduces private staging for store writes merged with final status and an explicit `startup.ready` IPC barrier over Lua completion plus FIFO state-engine acknowledgement. Regression exercises store staging/merge deterministically; IPC status tests wait on readiness instead of weakening assertions. Not duplicate of BREAD-30 (module-host child startup timeout), BREAD-42 (hyprland bridge), or BREAD-43 (SIGTERM bind cleanup). PR44 `module_host_bridge.rs` is untouched because it is not causative.
Author
Owner

Independent review: changes_requested at a7056d1714, despite exact-head CI success (run152/internal2521). Full criterion mapping and precise requests: #48 (comment) . R1 high: mod.rs:3130-3143 store.get ignores newly staged on_load writes. Independently rebuilt old base e4ddf6c loads identical module successfully (x41/y42); rebuilt head fails read-after-write assertion at startup and reload. R2 mod.rs:207-243 discards all FIFO barrier errors and still acknowledges startup.ready; propagate Result, test channel closure/dropped ack, clarify attempted-vs-healthy semantics. All locked workspace tests/clippy/fmt/docs pass; five fresh loaded IPC suites43/43 each. Staging/publication and clear acknowledgement source/unit checks pass but do not cover R1/R2. No merge/done or BREAD-28 status change. Durable evidence ~/.config/breadboard/reviews/BREAD-48-a7056d1/. Required reviewer action is todo for coordinator rework, overriding requested review placement for an accepted head.

Independent review: changes_requested at a7056d17148c542019b6818332e538603675925c, despite exact-head CI success (run152/internal2521). Full criterion mapping and precise requests: https://git.breadway.dev/Breadway/bread/pulls/48#issuecomment-4989 . R1 high: mod.rs:3130-3143 store.get ignores newly staged on_load writes. Independently rebuilt old base e4ddf6c loads identical module successfully (x41/y42); rebuilt head fails read-after-write assertion at startup and reload. R2 mod.rs:207-243 discards all FIFO barrier errors and still acknowledges startup.ready; propagate Result, test channel closure/dropped ack, clarify attempted-vs-healthy semantics. All locked workspace tests/clippy/fmt/docs pass; five fresh loaded IPC suites43/43 each. Staging/publication and clear acknowledgement source/unit checks pass but do not cover R1/R2. No merge/done or BREAD-28 status change. Durable evidence ~/.config/breadboard/reviews/BREAD-48-a7056d1/. Required reviewer action is todo for coordinator rework, overriding requested review placement for an accepted head.
Author
Owner

Independent re-review PASS at repaired exact head f37efff325; integrated merge d7add44b20 verified tree-identical. Persisted full criteria/evidence to PR comment #48 (comment). Exact-head CI run154 success and integrated run156 success, independent workspace tests/clippy/fmt/docs pass, actual startup/reload Lua store probe and barrier error tests pass. BREAD-48 remains in review for coordinator post-merge verification; BREAD-28 untouched.

Independent re-review PASS at repaired exact head f37efff32516294f41112b0e74fa142d60196599; integrated merge d7add44b204b7ce4a3648d5e98f32475ee705512 verified tree-identical. Persisted full criteria/evidence to PR comment https://git.breadway.dev/Breadway/bread/pulls/48#issuecomment-5124. Exact-head CI run154 success and integrated run156 success, independent workspace tests/clippy/fmt/docs pass, actual startup/reload Lua store probe and barrier error tests pass. BREAD-48 remains in review for coordinator post-merge verification; BREAD-28 untouched.
Breadway reopened this issue 2026-10-15 14:52:00 +08:00
Author
Owner

Post-merge sync had prematurely marked this card done before coordinator behavior verification. Independent PASS is now persisted at PR comment5124/card comment2300; exact integration tree confirmed and CI green. Restored card to review per workflow. Coordinator must verify behavior on merge d7add44 before done. BREAD-28 remains unchanged.

Post-merge sync had prematurely marked this card done before coordinator behavior verification. Independent PASS is now persisted at PR comment5124/card comment2300; exact integration tree confirmed and CI green. Restored card to review per workflow. Coordinator must verify behavior on merge d7add44 before done. BREAD-28 remains unchanged.
Author
Owner

Coordinator integrated verification on merge d7add44b20: clean detached worktree cargo test --locked -p breadd --test ipc_integration in_process_module_store_supports_read_your_writes_on_startup_and_reload passed (startup+reload). Independent repaired-head pass PR48 comment5124 verifies same tree, negative ack tests, full locked checks and integrated run156 success. Full acceptance now backed; this is not retroactive waiver of the premature merge.

Coordinator integrated verification on merge d7add44b204b7ce4a3648d5e98f32475ee705512: clean detached worktree cargo test --locked -p breadd --test ipc_integration in_process_module_store_supports_read_your_writes_on_startup_and_reload passed (startup+reload). Independent repaired-head pass PR48 comment5124 verifies same tree, negative ack tests, full locked checks and integrated run156 success. Full acceptance now backed; this is not retroactive waiver of the premature merge.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Breadway/bread#47
No description provided.