fix(deploy): thaw shadow before final stop - #57
Conversation
📝 WalkthroughWalkthroughThe shadow gate now thaws the frozen Rust unit and verifies ChangesShadow gate lifecycle
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
deployment/aliyun/test-polymarket-raw-ops-control-plane.sh (1)
1247-1263: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueEnhance grep robustness and remove redundant condition.
Consider these minor adjustments for consistency and test robustness:
- Add
|| trueto thefinal_stop_lineassignment. Ifset -eandpipefailare active, a missing stop command will abruptly terminate the script, hiding your customshadow final freeze/snapshot/kill/thaw/stop sequence is unsafediagnostic.- Add
| tail -1to thethawed_state_lineassignment for consistency with other variables and to prevent multiple matches from breaking the integer validation.- Remove the redundant
&& $kill_line -lt $final_stop_linecondition, as it is mathematically guaranteed by the preceding less-than checks.♻️ Proposed refactor
-thawed_state_line=$(grep -n '^shadow_thawed_state=.*FreezerState' "$GATE" \ - | cut -d: -f1 || true) -final_stop_line=$(grep -n '^systemctl stop "$shadow_unit"$' "$GATE" | tail -1 | cut -d: -f1) +thawed_state_line=$(grep -n '^shadow_thawed_state=.*FreezerState' "$GATE" \ + | tail -1 | cut -d: -f1 || true) +final_stop_line=$(grep -n '^systemctl stop "$shadow_unit"$' "$GATE" | tail -1 | cut -d: -f1 || true) [[ $freeze_line =~ ^[1-9][0-9]*$ \ && $freezer_state_line =~ ^[1-9][0-9]*$ \ && $final_memory_line =~ ^[1-9][0-9]*$ \ && $kill_line =~ ^[1-9][0-9]*$ \ && $final_thaw_line =~ ^[1-9][0-9]*$ \ && $thawed_state_line =~ ^[1-9][0-9]*$ \ && $final_stop_line =~ ^[1-9][0-9]*$ \ && $freeze_line -lt $freezer_state_line \ && $freezer_state_line -lt $final_memory_line \ && $final_memory_line -lt $kill_line \ && $kill_line -lt $final_thaw_line \ && $final_thaw_line -lt $thawed_state_line \ - && $thawed_state_line -lt $final_stop_line \ - && $kill_line -lt $final_stop_line ]] || { + && $thawed_state_line -lt $final_stop_line ]] || {🤖 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 `@deployment/aliyun/test-polymarket-raw-ops-control-plane.sh` around lines 1247 - 1263, Harden the sequence-line extraction and simplify its validation: update the final_stop_line pipeline to tolerate missing matches with || true, make thawed_state_line select only the last matching line via tail -1, and remove the redundant kill_line -lt final_stop_line check from the compound condition.
🤖 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 `@deployment/aliyun/test-polymarket-raw-ops-control-plane.sh`:
- Around line 1247-1263: Harden the sequence-line extraction and simplify its
validation: update the final_stop_line pipeline to tolerate missing matches with
|| true, make thawed_state_line select only the last matching line via tail -1,
and remove the redundant kill_line -lt final_stop_line check from the compound
condition.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 8e477fff-4a79-4fc3-bdbc-a6881ddf2488
📒 Files selected for processing (2)
deployment/aliyun/polymarket-raw-ops-shadow-gate.shdeployment/aliyun/test-polymarket-raw-ops-control-plane.sh
Fixes the failed Polymarket Rust shadow gate finalization.
The gate froze the shadow unit for its final memory snapshot, queued SIGTERM, then attempted
systemctl stopwhile the unit was still frozen. Systemd correctly rejected that operation.The fixed fail-closed sequence is: freeze → verify frozen → snapshot → SIGTERM → thaw → verify running → stop. The existing control-plane contract now asserts the final thaw transition and ordering.
Validation:
bash deployment/aliyun/test-polymarket-raw-ops-control-plane.sh,bash -n, ShellCheck,git diff --check.Summary by CodeRabbit
Bug Fixes
Tests