Skip to content

fix(scripts): stop-all 支援單一 pid 檔 - #217

Merged
monkey1sai merged 1 commit into
mainfrom
fix/stop-all-single-pid-count
Jun 16, 2026
Merged

monkey1sai merged 1 commit into
mainfrom
fix/stop-all-single-pid-count

Conversation

@monkey1sai

Copy link
Copy Markdown
Owner

Summary

  • 修正 stop-all.ps1 在 scripts/.run 只有一個 .pid 檔時,StrictMode 對 FileInfo.Count 的錯誤。
  • 新增 focused regression test,覆蓋單一 stale governance-service.pid 的 closeout 路徑。
  • 補 OpenSpec change stop-all-single-pid-cleanup,讓 PR review governance 可驗證 script 行為變更。

Validation

  • PowerShell parser check for scripts/stop-all.ps1 and scripts/tests/test-stop-all-single-pid.ps1
  • powershell -NoProfile -ExecutionPolicy Bypass -File scripts\tests\test-stop-all-single-pid.ps1
  • npx openspec validate stop-all-single-pid-cleanup --strict

Notes

Wrap stop-all pid-file enumeration in an array so StrictMode does not emit a Count error when exactly one pid file exists.

Validation: parser check; scripts/tests/test-stop-all-single-pid.ps1; npx openspec validate stop-all-single-pid-cleanup --strict.
Copilot AI review requested due to automatic review settings June 16, 2026 05:59
@coderabbitai

coderabbitai Bot commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

@monkey1sai, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 7 minutes and 57 seconds. Learn how PR review limits work.

Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file).

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: a23b3323-3a80-49c9-81b0-5b71ff870dfa

📥 Commits

Reviewing files that changed from the base of the PR and between 81a2bdd and f2bd843.

📒 Files selected for processing (6)
  • openspec/changes/stop-all-single-pid-cleanup/design.md
  • openspec/changes/stop-all-single-pid-cleanup/proposal.md
  • openspec/changes/stop-all-single-pid-cleanup/specs/one-click-deploy-hybrid/spec.md
  • openspec/changes/stop-all-single-pid-cleanup/tasks.md
  • scripts/stop-all.ps1
  • scripts/tests/test-stop-all-single-pid.ps1
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/stop-all-single-pid-count

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a Set-StrictMode bug in scripts/stop-all.ps1 where Get-ChildItem returns a scalar FileInfo (not an array) when scripts/.run/ contains exactly one .pid file, causing .Count to error. This was discovered during post-merge closeout of PR #215 which added governance-service to the deploy/stop lifecycle.

Changes:

  • Wraps the .pid file enumeration in @(...) to guarantee array semantics for zero, one, and many results.
  • Adds a focused regression test that creates a single stale governance-service.pid and verifies stop-all.ps1 exits cleanly without strict-mode errors.
  • Adds OpenSpec change artifacts (proposal.md, design.md, spec.md, tasks.md) documenting the fix rationale and verification.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
scripts/stop-all.ps1 Wraps Get-ChildItem in @(...) on line 121 to ensure array semantics under strict mode
scripts/tests/test-stop-all-single-pid.ps1 New regression test: creates one stale pid file, runs stop-all, asserts no strict-mode .Count error
openspec/changes/stop-all-single-pid-cleanup/proposal.md OpenSpec proposal documenting the bug origin and fix scope
openspec/changes/stop-all-single-pid-cleanup/design.md Design decision record for the @(...) wrapping approach
openspec/changes/stop-all-single-pid-cleanup/specs/one-click-deploy-hybrid/spec.md Spec delta: shutdown cleanup must handle 0/1/many pid files without strict-mode errors
openspec/changes/stop-all-single-pid-cleanup/tasks.md Task checklist tracking fix implementation and validation

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +12 to +18
function Assert-True {
param(
[Parameter(Mandatory = $true)] $Condition,
[Parameter(Mandatory = $true)][string] $Message
)
if (-not $Condition) { throw "ASSERT FAILED: $Message" }
}

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f2bd843119

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +21 to +24
Set-Content -LiteralPath $PidFile -Value '999999' -Encoding ASCII

try {
$output = & powershell -NoProfile -ExecutionPolicy Bypass -File $StopAll 2>&1 | Out-String

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Isolate the stop-all regression from live runs

When this test is run from a checkout that already has an active scripts\.run\governance-service.pid, it overwrites that PID with 999999 and then invokes the real stop-all.ps1 against the repo’s live .run directory and default ports. That can delete existing pid/log files and stop any workspace processes found by the fallback path, so running the focused regression during an active demo/deploy corrupts the session instead of being a safe test; use a temp sandbox/test run directory or add a test-only override for the run dir/ports before invoking the script.

Useful? React with 👍 / 👎.

Comment on lines +1 to +5
# one-click-deploy-hybrid — Spec Delta (stop-all-single-pid-cleanup)

## MODIFIED Requirements

### Requirement: Final Summary 可診斷性

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Merge this delta into the existing active change

This adds a second active OpenSpec delta for one-click-deploy-hybrid while openspec/changes/governance-service-deploy/specs/one-click-deploy-hybrid/spec.md is still active. openspec/AGENTS.md says MUST NOT 平行開兩個改同一 capability 的 active change, so this state violates the NoSuccessorWhilePredecessorOpen gate and leaves reviewers with concurrent deltas against the same capability; fold this cleanup into the existing active change or archive/close the predecessor first.

Useful? React with 👍 / 👎.


### Requirement: Final Summary 可診斷性

deploy and closeout scripts SHALL keep failure / recovery output diagnosable under strict mode. Shutdown cleanup MUST NOT emit strict-mode collection-shape errors when the runtime directory contains zero, one, or many `.pid` files.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Rewrite the OpenSpec prose in Traditional Chinese

The new active OpenSpec text is written in English, but openspec/AGENTS.md requires proposal/design/tasks/spec prose to be in Traditional Chinese while preserving only the parser-required headings. Leaving this delta in English makes the active change inconsistent with the repo’s OpenSpec contract, so translate the prose in the new change artifacts before merging.

Useful? React with 👍 / 👎.

Comment on lines +3 to +7
## MODIFIED Requirements

### Requirement: Final Summary 可診斷性

deploy and closeout scripts SHALL keep failure / recovery output diagnosable under strict mode. Shutdown cleanup MUST NOT emit strict-mode collection-shape errors when the runtime directory contains zero, one, or many `.pid` files.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve the existing Final Summary scenarios

Because this delta is under MODIFIED Requirements for the existing Final Summary 可診斷性 requirement, archiving it will replace that requirement’s current text and scenarios. The formal spec already contains the success, failure, build/probe, and null-safe PID/signature scenarios under this requirement, but this delta only keeps the new stop-all scenario, so it would erase the deployed deploy.ps1 Final Summary contract unless the full existing requirement is repeated with the new scenario added.

Useful? React with 👍 / 👎.

@github-actions

Copy link
Copy Markdown
Contributor

PR Review Agent Summary

Field Value
Status warning
Risk medium
PR 217
Head fix/stop-all-single-pid-count / f2bd8431194816b03fcd66ef745c91c03c4ce2e9
Base main / 81a2bdd166d0e059ae59a3002354ede4ababf8fd

Blockers

  • None

Warnings

  • [medium] GitNexus detect changes did not pass: warning.

Validation Commands

  • openspec validate stop-all-single-pid-cleanup
  • C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -NoProfile -ExecutionPolicy Bypass -File scripts/tests/test-pr-review-agent.ps1

Checks

  • passed openspec validate stop-all-single-pid-cleanup (openspec)
  • passed script-level PR review agent tests (scripts)

Human Review Notes

  • OpenSpec changes detected: stop-all-single-pid-cleanup
  • Optional AI adapter is not required by policy and was skipped.

@monkey1sai
monkey1sai merged commit 21d5fb6 into main Jun 16, 2026
3 checks passed
@monkey1sai
monkey1sai deleted the fix/stop-all-single-pid-count branch June 16, 2026 06:06
monkey1sai added a commit that referenced this pull request Jun 18, 2026
#229)

把 13 個產品碼已 merge 進 main 的 active change 歸檔為不可變快照,
並將其 spec delta 併入 canonical specs。對齊 #197 收斂規約。

歸檔(archive/<merge-date>-<id>,git 偵測為 R100 純改名、零內容漂移):
  a1-m1-closeout(#213) a2-version-diff-selector(#207) conv-coverage-report(#218/#220)
  conv-prioritize-retry(#221) conv-watch-toggle(#225) conversion-artifact-id-sanitize(#206)
  governance-service-deploy(#215) minio-fileserver-source(#204) minio-watch-auto-intake(#210)
  raise-claude-md-line-budget(#199) sessions-terminate(#226) stop-all-single-pid-cleanup(#217)
  test-deploy-rebuild-workflow(#198)

canonical 併入:
- 9 個新 capability(純 ADDED → 新建 spec):a1-m1-closeout、a2-version-diff-selector、
  conv-coverage-report、conv-prioritize-retry、conversion-control、conversion-artifact-id-sanitize、
  minio-fileserver-source、minio-watch-auto-intake、test-deploy-rebuild-workflow。
- review-session-request-lifecycle:append sessions-terminate 的 ADDED requirement
  「Operator 結束 session controlled action」(5 scenario),既有 7 requirement 不動。
- one-click-deploy-hybrid:併入 governance-service-deploy 與 stop-all-single-pid-cleanup
  兩 delta,採「合併不取代」保全既有更豐富內容。依 deploy.ps1 現況權威
  (4a=governance/4b=conversion/4c=Kit/4d=docker)調和 Phase 4 編號,並修正
  canonical 其他兩處陳舊的舊 3 段編號(Mode C 入口 scenario、退出碼 stage 清單補 4d)。
- agent-doc-context-budget:raise-claude-md-line-budget 的 130 行預算已於 #199 併入,
  本次為 archive-only。

驗證:
- 結構檢查無殘留 ## ADDED/MODIFIED header、每 requirement 皆有 scenario、
  43 archive 檔全 R100、git diff --cached --check 無 whitespace。
- 雙 agent 對抗驗證:完整性 PASS(無規範遺失);一致性初判 FAIL 抓到 2 處
  Phase 4 編號矛盾,已修正後複驗。
- 本機 openspec CLI 不可用(結構驗證代替);openspec validate --strict 由 CI pr-review-agent 執行。


Claude-Session: https://claude.ai/code/session_01JEyNWhEmb3x8oinY3B2v9V

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants