feat(sessions): wire up the client flow for session creation response - #568
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughSession composition now gates pending vars and patches on the client side, updates verdict payload shapes and shared compose errors, refactors hook prompting and pending-item handling, and adds integration coverage for verdict composition, batching, and failure cases. ChangesSession composition gating
Sequence Diagram(s)sequenceDiagram
participant HandleResponse as "client::handler::handle_response"
participant GateVars as "gate_pending_vars"
participant Hooks as "PolicyHooks"
participant GatePatches as "gate_pending_patches"
participant Verdict as "ContributionVerdict"
HandleResponse->>GateVars: resolve pending vars and collect approved vars
GateVars->>Hooks: prompt undecidable vars
Hooks-->>GateVars: ItemDecision / updated policy
GateVars-->>HandleResponse: wire var verdicts + approved vars
HandleResponse->>GatePatches: expand patch sources with approved vars
GatePatches->>Hooks: prompt undecidable patch files
Hooks-->>GatePatches: ItemDecision / updated policy
GatePatches-->>HandleResponse: wire patch verdicts
HandleResponse-->>Verdict: assemble final verdict
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
crates/sessions/src/core/compose.rs (1)
461-478: 🩺 Stability & Availability | 🔵 Trivial | 💤 Low value
unreachable!on non-ResolutionFailureis correct today but brittle.
ResolvedVar::resolve_withcurrently only ever returnsVarError::ResolutionFailure, so the catch-all panic is unreachable in practice. However, this couplesfrom_wireto an implementation detail ofresolve_with; if a future change makes it return anotherVarErrorvariant, this becomes a runtime panic instead of a recoverable error. Consider folding any unexpected variant into a non-panickingComposeError(e.g.InvalidWireItem) instead.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@crates/sessions/src/core/compose.rs` around lines 461 - 478, The from_wire mapping in compose.rs relies on an unreachable! for non-ResolutionFailure VarError variants, which makes it brittle if ResolvedVar::resolve_with ever returns something else. Update the error handling in from_wire so the match on resolve_with maps known ResolutionFailure into ComposeError::VarResolution and converts any unexpected VarError variant into a recoverable ComposeError such as InvalidWireItem instead of panicking.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@crates/sessions/src/core/compose.rs`:
- Around line 461-478: The from_wire mapping in compose.rs relies on an
unreachable! for non-ResolutionFailure VarError variants, which makes it brittle
if ResolvedVar::resolve_with ever returns something else. Update the error
handling in from_wire so the match on resolve_with maps known ResolutionFailure
into ComposeError::VarResolution and converts any unexpected VarError variant
into a recoverable ComposeError such as InvalidWireItem instead of panicking.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 2011ec67-ef9f-4e3e-8dab-19dff4d06b2e
📒 Files selected for processing (8)
crates/sessions/docs/COMPOSITION.mdcrates/sessions/src/client/handler.rscrates/sessions/src/client/mod.rscrates/sessions/src/core/compose.rscrates/sessions/src/core/primitives.rscrates/sessions/src/wire/policy.rscrates/sessions/src/wire/request.rscrates/sessions/tests/client_flow2.rs
Phase 3 of session composition: client-side handler that turns the daemon's
ContributionResponseinto aContributionVerdict.client::handler::handle_response: resolves pending vars against theclient env, expands patch sources against the gated + same-batch vars,
runs
UserPolicy, and prompts viaPolicyHooksonly when the policycan't decide. Emits one wire verdict per pending id; lifecycle hooks
pass through.
WireVarVerdict/WirePatchVerdictnowcarry
name/host_pathon every variant; daemon correlates byid.SessionVaris a thin typestate wrapper overProvenancedVar; newPendingVar/PendingPatchFilebridge wire ↔ domain on theverdict-emitting side.
prompt_var_hook/prompt_patch_hookso Phase 1 and Phase 3 stop duplicating the abort/contract/install dance.
Summary by CodeRabbit