pub fn check_workstream_immutable(
existing: Option<WorkstreamId>,
explicit: Option<&str>,
method: &str,
) -> Result<(), RpcError>Expand description
Enforce DOC-48 §4.1’s binding immutability on a REUSED session (AC-1.3, issue #3298): “if a session with an existing workstream binding receives a task with a different workstream, the task is rejected.”
Why: task::protocol::task_run’s session_id (“sessionful”) path is the
one call site that can present a session already carrying a persisted
workstream_id alongside a fresh, possibly-conflicting workstream_id
param — mirrors the existing project mismatch guard right next to it
(task::protocol::task_run’s own docs) at the exact same layer.
What: explicit: None never rejects — ambient default-targeting (§4.2)
applies only to a session’s FIRST binding at creation, never re-applied
on reuse. explicit: Some(raw) — parses raw; Ok(()) if it restates
existing exactly (including existing: None restated by… it cannot
restate None, so any Some explicit id against an unbound session is
ALSO a mismatch, per the same authoritative-binding rule
task::protocol::task_run’s project check already applies); otherwise
Err(-32003 invalid_argument) naming both ids.
Test: protocol_tests::check_workstream_immutable_allows_none,
protocol_tests::check_workstream_immutable_allows_restating_same_id,
protocol_tests::check_workstream_immutable_rejects_mismatch,
protocol_tests::check_workstream_immutable_rejects_binding_an_unbound_session.