Skip to content

fix: restore simple Windows installer command - #2541

Merged
yohamta0 merged 13 commits into
mainfrom
agent/restore-simple-windows-installer-command
Aug 9, 2026
Merged

fix: restore simple Windows installer command#2541
yohamta0 merged 13 commits into
mainfrom
agent/restore-simple-windows-installer-command

Conversation

@yohamta0

@yohamta0 yohamta0 commented Aug 8, 2026

Copy link
Copy Markdown
Member

Summary

  • isolate the PowerShell installer from caller variables while preserving the simple irm ... | iex command
  • perform real PowerShell and CMD install, version, uninstall, and cleanup checks in Windows CI
  • make heartbeat deadline reporting consistent and replace transport-racy timeout tests with deterministic context tests

Root cause

Invoke-Expression evaluates downloaded code in the caller's scope. The installer's top-level parameter metadata could therefore collide with an existing caller variable such as $Service. Renaming that parameter would only move the collision risk.

The installer now creates its own child scope and forwards direct script arguments with @args. Its source remains ASCII-safe so Windows PowerShell can execute both a downloaded file and the direct irm ... | iex pipeline.

Testing

  • GOCACHE=/private/tmp/dagu6-go-cache GOLANGCI_LINT_CACHE=/private/tmp/dagu6-golangci-cache make check
  • GOCACHE=/private/tmp/dagu6-go-cache go test -race ./internal/service/coordinator -count=10
  • Windows CI downloads this PR's exact installer revision with the no-argument irm ... | iex pipeline, installs Dagu, runs dagu.exe version, uninstalls it, and verifies cleanup
  • Windows CI performs the same lifecycle checks through installer.cmd

Closes #2530

Summary by CodeRabbit

  • Bug Fixes

    • Improved timeout and cancellation error reporting for service heartbeats.
    • Enhanced installer behavior in redirected or noninteractive environments.
    • Replaced installer status symbols with broadly compatible text characters.
    • Improved Windows process-record listing during temporary file-sharing conflicts.
  • Installation

    • Windows PowerShell installation now runs more reliably without affecting the calling session.
    • Expanded Windows installer validation, including installation, version checks, cleanup, and uninstall options.
    • Added comprehensive command-line installer checks for installation and removal.

@coderabbitai

coderabbitai Bot commented Aug 8, 2026

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: c5f3a108-7358-4155-abfd-647bb714d43d

📥 Commits

Reviewing files that changed from the base of the PR and between fe96a59 and a704281.

📒 Files selected for processing (1)
  • internal/persis/file/proc/store_windows_test.go
🚧 Files skipped from review as they are similar to previous changes (1)
  • internal/persis/file/proc/store_windows_test.go

📝 Walkthrough

Walkthrough

The Windows installer now runs in an isolated PowerShell script block. Windows CI performs real PowerShell and CMD installation checks. Coordinator heartbeats preserve cancellation and deadline errors. Proc-store filesystem access uses shared utilities.

Changes

Windows installer validation

Layer / File(s) Summary
Installer script-block isolation
scripts/installer.ps1
The installer runs in an invoked script block, forwards arguments through @args, treats redirected input as noninteractive, and uses ASCII status prefixes.
PowerShell invocation and lifecycle validation
README.md, .github/workflows/ci.yaml
The README uses direct Invoke-Expression execution. CI checks variable isolation, performs installation and version checks, cleans up, validates invalid uninstall flags, and increases the timeout to 10 minutes.
CMD installer lifecycle validation
.github/workflows/ci.yaml
The CMD test performs installation, version verification, uninstallation, and cleanup checks.

Coordinator heartbeat timeout handling

Layer / File(s) Summary
Heartbeat context error normalization
internal/service/coordinator/client.go
Heartbeat discovery, failover, and final failure paths return active cancellation or deadline errors when the request context has ended.
Heartbeat timeout test coverage
internal/service/coordinator/client_test.go
Tests cover configured timeouts, caller deadlines during discovery, failover exhaustion, cancellation, and context-aware service-member lookup callbacks.

Proc-store filesystem access

Layer / File(s) Summary
Shared filesystem utility adoption
internal/persis/file/proc/store.go
Proc-store directory traversal and file metadata access use fileutil operations.
Windows sharing-violation coverage
internal/persis/file/proc/store_windows_test.go
A Windows-only test verifies retry behavior after a transient directory sharing violation.

Estimated code review effort: 4 (Complex) | ~60 minutes

Sequence Diagram(s)

sequenceDiagram
  participant CI as Windows CI
  participant Installer as installer.ps1
  participant System as Installed system
  CI->>Installer: Invoke downloaded installer expression
  Installer->>System: Install executable
  CI->>System: Check executable version
  CI->>Installer: Run cleanup and invalid-flag checks
Loading
sequenceDiagram
  participant Heartbeat as Coordinator heartbeat
  participant Monitor as Service monitor
  participant RPC as Coordinator heartbeat RPC
  Heartbeat->>Monitor: Discover service members
  Monitor-->>Heartbeat: Return members or context error
  Heartbeat->>RPC: Send heartbeat with request context
  RPC-->>Heartbeat: Return heartbeat result
  Heartbeat-->>Heartbeat: Normalize cancellation or deadline error
Loading

Possibly related PRs

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Out of Scope Changes check ⚠️ Warning Heartbeat coordinator changes and proc-store Windows tests are unrelated to the linked Windows installer issue #2530. Move the coordinator and proc-store changes to separate pull requests, or link issues that explicitly require those changes.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the primary change: restoring the simple Windows installer command.
Description check ✅ Passed The description includes the summary, root cause, testing details, and issue reference, but omits the template checklist and Changes heading.
Linked Issues check ✅ Passed The PR restores the documented irm ... | iex installation flow and adds Windows lifecycle tests, directly addressing issue #2530.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch agent/restore-simple-windows-installer-command

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.

@yohamta0
yohamta0 marked this pull request as ready for review August 8, 2026 17:20

@coderabbitai coderabbitai 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.

Actionable comments posted: 1

🧹 Nitpick comments (1)
scripts/installer.ps1 (1)

6-7: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Verify that all invocation paths preserve the same isolation contract.

The wrapper isolates local parameters, but the installer also uses $Script: state. The implementation and test must prove that string-based invocations cannot modify caller script state.

  • scripts/installer.ps1#L6-L7: verify the non-file staging decision before $Script: state is initialized.
  • scripts/installer.ps1#L1257-L1257: verify @args forwarding and preserve the original error and exit behavior.
  • .github/workflows/ci.yaml#L366-L374: assert $script:Service and $script:DaguHome, in addition to local $Service.
🤖 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 `@scripts/installer.ps1` around lines 6 - 7, Preserve installer isolation for
every invocation path: in scripts/installer.ps1 lines 6-7, determine non-file
staging before initializing any $Script: state; at line 1257, forward arguments
through `@args` while preserving the existing error and exit behavior; in
.github/workflows/ci.yaml lines 366-374, extend the test assertions to verify
$script:Service and $script:DaguHome alongside local $Service.
🤖 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.

Inline comments:
In `@scripts/installer.ps1`:
- Around line 6-7: Save scripts/installer.ps1 as UTF-8 with BOM, preserving its
existing content and encoding all non-ASCII characters correctly. Use make
addlicense or the repository’s established license workflow to apply the
required BOM.

---

Nitpick comments:
In `@scripts/installer.ps1`:
- Around line 6-7: Preserve installer isolation for every invocation path: in
scripts/installer.ps1 lines 6-7, determine non-file staging before initializing
any $Script: state; at line 1257, forward arguments through `@args` while
preserving the existing error and exit behavior; in .github/workflows/ci.yaml
lines 366-374, extend the test assertions to verify $script:Service and
$script:DaguHome alongside local $Service.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: d7d82d9d-91e1-4682-bb7c-2e7f4928681d

📥 Commits

Reviewing files that changed from the base of the PR and between 4588800 and 393f0ce.

📒 Files selected for processing (3)
  • .github/workflows/ci.yaml
  • README.md
  • scripts/installer.ps1

Comment thread scripts/installer.ps1
@yohamta0

yohamta0 commented Aug 8, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 8, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai 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.

Actionable comments posted: 1

🤖 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.

Inline comments:
In @.github/workflows/ci.yaml:
- Around line 365-366: Update the installerUrl construction in the
test-windows-installer workflow to use
github.event.pull_request.head.repo.full_name for pull request runs, while
retaining GITHUB_REPOSITORY for non-PR runs. Keep installerRef aligned with the
corresponding head commit so the raw URL resolves to the correct repository and
revision.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: ae1dc96e-77ee-4e0f-8433-aab185ac36e6

📥 Commits

Reviewing files that changed from the base of the PR and between 393f0ce and 23e3f8c.

📒 Files selected for processing (2)
  • .github/workflows/ci.yaml
  • scripts/installer.ps1
🚧 Files skipped from review as they are similar to previous changes (1)
  • scripts/installer.ps1

Comment thread .github/workflows/ci.yaml Outdated
@yohamta0

yohamta0 commented Aug 8, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 8, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@yohamta0

yohamta0 commented Aug 8, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 8, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai 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.

🧹 Nitpick comments (1)
internal/service/coordinator/client_test.go (1)

1257-1258: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add direct-call and retry-exhaustion coverage.

The RPC mock now returns an immediate gRPC error, and both timeout tests block service-member discovery. The changed tests therefore do not exercise heartbeatContextError after attemptCall at Line 866 or after retry exhaustion at Lines 888-901. Add deterministic tests that block the mock heartbeat on ctx.Done(), with one coordinator and with multiple coordinators. Add a cancellation case if no existing test covers context.Canceled.

Also applies to: 1343-1348, 1374-1379

🤖 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 `@internal/service/coordinator/client_test.go` around lines 1257 - 1258, Extend
the heartbeat timeout tests around heartbeatContextError and attemptCall to
block the mock heartbeat until ctx.Done(), rather than returning an immediate
gRPC error. Add deterministic coverage with one coordinator for the direct-call
path and multiple coordinators for retry exhaustion, ensuring discovery is
blocked as required; also add a context.Canceled case if no existing test covers
it.
🤖 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 `@internal/service/coordinator/client_test.go`:
- Around line 1257-1258: Extend the heartbeat timeout tests around
heartbeatContextError and attemptCall to block the mock heartbeat until
ctx.Done(), rather than returning an immediate gRPC error. Add deterministic
coverage with one coordinator for the direct-call path and multiple coordinators
for retry exhaustion, ensuring discovery is blocked as required; also add a
context.Canceled case if no existing test covers it.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 57cc6333-8e2f-4b61-bdc0-0f05e2e67722

📥 Commits

Reviewing files that changed from the base of the PR and between bdb0577 and 5568a0c.

📒 Files selected for processing (2)
  • internal/service/coordinator/client.go
  • internal/service/coordinator/client_test.go

@yohamta0

yohamta0 commented Aug 8, 2026

Copy link
Copy Markdown
Member Author

Addressed the latest CodeRabbit nitpick in 5919d1f: added deterministic single-coordinator timeout, multi-coordinator exhaustion, and caller-cancellation coverage. @coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 8, 2026

Copy link
Copy Markdown

@yohamta0 I will review the updates in 5919d1f85.

✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai 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.

Actionable comments posted: 1

🤖 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.

Inline comments:
In `@internal/service/coordinator/client_test.go`:
- Around line 1403-1429: Update
TestClientHeartbeatReturnsDeadlineAfterFailoverExhaustion to count heartbeat
invocations across both mock coordinators, using shared tracking in mockCoord or
the heartbeat handlers. After client.Heartbeat returns, assert the total count
is two while retaining the context.DeadlineExceeded assertion; do not assert
coordinator call order because Heartbeat shuffles members.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 4c7cbf4e-33a7-4a2c-9d7f-2bab0a574b86

📥 Commits

Reviewing files that changed from the base of the PR and between 5568a0c and 5919d1f.

📒 Files selected for processing (1)
  • internal/service/coordinator/client_test.go

Comment thread internal/service/coordinator/client_test.go
@yohamta0

yohamta0 commented Aug 8, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 8, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@yohamta0

yohamta0 commented Aug 8, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 8, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai 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.

Actionable comments posted: 1

🤖 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.

Inline comments:
In `@internal/persis/file/proc/store_windows_test.go`:
- Around line 43-53: Ensure the handle created in this test is closed exactly
once: replace the independent t.Cleanup and release-goroutine closes with
synchronized ownership using sync.Once, or transfer cleanup ownership to the
goroutine after successful release. Update the CloseHandle calls around the
existing released channel so both paths cannot close the same handle
independently.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: cc09f9fd-5a6c-4846-819b-60e9a1797984

📥 Commits

Reviewing files that changed from the base of the PR and between 2186192 and fe96a59.

📒 Files selected for processing (2)
  • internal/persis/file/proc/store.go
  • internal/persis/file/proc/store_windows_test.go

Comment thread internal/persis/file/proc/store_windows_test.go Outdated
@yohamta0

yohamta0 commented Aug 8, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 8, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@yohamta0
yohamta0 merged commit 9f57a01 into main Aug 9, 2026
12 checks passed
@yohamta0
yohamta0 deleted the agent/restore-simple-windows-installer-command branch August 9, 2026 01:33
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.

bug: Windows installer broke

1 participant