feat(sidecar): protocol 14 — the world event call forward (PLAN_REDESIGNS §14.3.1)
All checks were successful
PR Checks / rust-gates (pull_request) Successful in 5m49s

POST /world/call, a thin forward like /world/place: the body is stamped
`world.call` whatever it names, so the route cannot place, revert or zone
anything. What a call starts is kept, so nothing is remembered here; the
plugin keeps the call's key. The `world.event` frames (24 types, told apart by
`event`) ride the feed like any other event, and hello's `console` like any
other field. Still protocol 14 (D332); one new test, 71 pass.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01E14m6SuuY6i1vASFeGDBeY
This commit is contained in:
2026-10-15 00:39:00 -05:00
parent 5b2471b110
commit 4ad5cb0545
2 changed files with 31 additions and 0 deletions

View File

@@ -123,6 +123,8 @@ pub async fn serve(addr: &str, state: AppState) -> anyhow::Result<()> {
.route("/world/zone", post(world_zone))
.route("/world/place", post(world_place))
.route("/world/revert", post(world_revert))
// Protocol 14 (§20.5): one of the game's own world events, now. Kept, never reverted.
.route("/world/call", post(world_call))
// Protocol 10 (§29): who took part, what they may redeem, and a line in chat. The tally
// is counted and held by the plugin, the kit catalogue is Kits' own, and whether a chat
// line was already said is the plugin's memory. These move lines, like everything above.
@@ -554,6 +556,13 @@ async fn world_revert(State(st): State<AppState>, Json(body): Json<Value>) -> Re
forward_object(&st, body, "world.revert", "a revert").await
}
/// Run one of the game's own world events for a run (protocol 14): a patrol helicopter, a cargo
/// ship, an airdrop and the rest. `world.called` (`called`, and `repeat` for a key already seen)
/// or `world.error` with a reason. What it starts is kept, so nothing is remembered here.
async fn world_call(State(st): State<AppState>, Json(body): Json<Value>) -> Response {
forward_object(&st, body, "world.call", "a world event call").await
}
/// Start counting who takes part in a run. `tally.ok` or `tally.error` with a reason.
async fn tally_open(State(st): State<AppState>, Json(body): Json<Value>) -> Response {
forward_object(&st, body, "tally.open", "a tally").await
@@ -1270,6 +1279,22 @@ mod tests {
assert!(stamp(json!("76561198000000001"), "backpacks.read", "r-41").is_none());
}
/// Protocol 14, world events: a call is stamped `world.call` whatever its body names, so the
/// route cannot place, revert or zone anything, and its params pass through untouched.
#[test]
fn protocol_14_world_call_is_stamped() {
let body = json!({ "cmd": "world.revert", "reqId": "theirs", "runId": "9", "key": "9:2",
"event": "airdrop", "count": 3, "x": -412.0, "z": 1180.5 });
let stamped = stamp(body, "world.call", "r-50").expect("an object is stamped");
assert_eq!(stamped["cmd"], "world.call");
assert_eq!(stamped["reqId"], "r-50");
assert_eq!(stamped["event"], "airdrop");
assert_eq!(stamped["count"], 3);
assert_eq!(stamped["x"], -412.0);
assert!(stamp(json!("airdrop"), "world.call", "r-51").is_none());
}
/// Protocol 12: a title set is forwarded whole. The markup inside each `text` is the module's
/// and the plugin's business, so it must arrive byte for byte as the website composed it.
#[test]