Skip to content

refactor(build): lean awsEc2Mac compute provider - #363

Merged
YosefHayim merged 1 commit into
mainfrom
refactor/build/providers-aws-mac
Aug 7, 2026
Merged

refactor(build): lean awsEc2Mac compute provider#363
YosefHayim merged 1 commit into
mainfrom
refactor/build/providers-aws-mac

Conversation

@YosefHayim

@YosefHayim YosefHayim commented Aug 6, 2026

Copy link
Copy Markdown
Owner

User description

Summary

Deslop src/providers/compute/awsEc2Mac.ts (~764) for wave-2 feature #349 without changing allocate / status / teardown / doctor behavior.

  • Extract multi-caller SDK seam awsEc2MacClient.ts (failure channel, lazy load, client factory, requireAws)
  • Export pure helpers for public address, instance type, AMI architecture/newest pick, quota detection, live host counting, release error detail, Xcode bootstrap marker
  • Lift post-host provisioning into provisionAllocatedHost under one release-on-failure catch
  • Deduplicate instance-type defaults across allocate + doctor
  • Colocated Vitest for pure helpers and requireAws (no live AWS)
  • Regenerate docs badges for the new test count

Gate

pnpm typecheck && pnpm lint && pnpm lint:style && pnpm docs:check && pnpm test && pnpm build

All green.

Test plan

  • pnpm typecheck
  • pnpm lint / pnpm lint:style
  • pnpm docs:check
  • pnpm test (includes src/providers/compute/awsEc2Mac.test.ts)
  • pnpm build
  • Orchestrator audit (do not merge)

Fixes #349


CodeAnt-AI Description

Refactor AWS EC2 Mac provisioning while preserving allocation behavior

What Changed

  • Failed EC2 Mac provisioning now consistently releases the allocated Dedicated Host to prevent unnecessary billing
  • AWS setup, error handling, AMI selection, host status, quota detection, and Xcode checks are covered by focused automated tests
  • Cloud doctor and provisioning use the same instance-type defaults and host-counting rules
  • Documentation now reports 2,081 passing tests

Impact

✅ Fewer billable hosts left after failed provisioning
✅ Clearer AWS quota and release errors
✅ Safer EC2 Mac status and AMI selection

💡 Usage Guide

Checking Your Pull Request

Every time you make a pull request, our system automatically looks through it. We check for security issues, mistakes in how you're setting up your infrastructure, and common code problems. We do this to make sure your changes are solid and won't cause any trouble later.

Talking to CodeAnt AI

Got a question or need a hand with something in your pull request? You can easily get in touch with CodeAnt AI right here. Just type the following in a comment on your pull request, and replace "Your question here" with whatever you want to ask:

@codeant-ai ask: Your question here

This lets you have a chat with CodeAnt AI about your pull request, making it easier to understand and improve your code.

Example

@codeant-ai ask: Can you suggest a safer alternative to storing this secret?

Preserve Org Learnings with CodeAnt

You can record team preferences so CodeAnt AI applies them in future reviews. Reply directly to the specific CodeAnt AI suggestion (in the same thread) and replace "Your feedback here" with your input:

@codeant-ai: Your feedback here

This helps CodeAnt AI learn and adapt to your team's coding style and standards.

Example

@codeant-ai: Do not flag unused imports.

Retrigger review

Ask CodeAnt AI to review the PR again, by typing:

@codeant-ai: review

Check Your Repository Health

To analyze the health of your code repository, visit our dashboard at https://app.codeant.ai. This tool helps you identify potential issues and areas for improvement in your codebase, ensuring your repository maintains high standards of code health.


Summary by cubic

Refactors the AWS EC2 Mac compute provider into a leaner, testable module with no behavior changes across allocate/status/teardown/doctor. Aligns with Linear #349 by extracting AWS client plumbing and pure helpers to improve maintainability and test coverage.

  • Refactors

    • Added awsEc2MacClient.ts with a typed failure channel, lazy loading for @aws-sdk/client-ec2 and @aws-sdk/credential-providers, a client factory, requireAws, and sendAwsRequest.
    • Lifted post-host provisioning into provisionAllocatedHost; exposed helpers for AMI catalog selection (datedMacImages/newestImageId), instance-type→arch mapping, quota detection, public address and host release state, release error details, and Xcode bootstrap checks; shared DEFAULT_INSTANCE_TYPE and host-counting between doctor and provisioning.
  • Tests

    • Added awsEc2Mac.test.ts for helpers plus awsFailure/requireAws (no live AWS); docs badges updated, test count now 2081.

Written for commit 574586e. Summary will update on new commits.

Review in cubic

@YosefHayim YosefHayim added the domain:build Pipeline, distribution, build providers label Aug 6, 2026
@changeset-bot

changeset-bot Bot commented Aug 6, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 574586e

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@codeant-ai

codeant-ai Bot commented Aug 6, 2026

Copy link
Copy Markdown

🤖 CodeAnt AI — Review Status

Status Commit Started (UTC) Finished (UTC)
✅ Reviewed your PR 61046ab Aug 06, 2026 · 23:41 23:44

@codeant-ai

codeant-ai Bot commented Aug 6, 2026

Copy link
Copy Markdown

Thanks for using CodeAnt! 🎉

We're free for open-source projects. if you're enjoying it, help us grow by sharing.

Share on X ·
Reddit ·
LinkedIn

@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@YosefHayim, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 54 minutes

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

How can I continue?

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.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 9b65d7ec-6d0b-40dc-b06b-ded0f627948f

📥 Commits

Reviewing files that changed from the base of the PR and between 8c1e951 and 574586e.

📒 Files selected for processing (3)
  • src/providers/compute/awsEc2Mac.test.ts
  • src/providers/compute/awsEc2Mac.ts
  • src/providers/compute/awsEc2MacClient.ts

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.

@codeant-ai codeant-ai Bot added the size:L This PR changes 100-499 lines, ignoring generated files label Aug 6, 2026
@qodo-code-review

Copy link
Copy Markdown

PR Summary by Qodo

Refactor AWS EC2 Mac compute provider into client seam + pure helpers

✨ Enhancement 🧪 Tests 📝 Documentation 🕐 40+ Minutes

Grey Divider

AI Description

• Extract AWS SDK client/failure plumbing into a dedicated module for reuse and testing.
• Split EC2 Mac provider logic into exported pure helpers and a single host-provision flow.
• Add unit tests for helpers and update docs/test-count badges.
Diagram

graph TD
  A["src/providers/compute/awsEc2Mac.ts"] --> B["src/providers/compute/awsEc2MacClient.ts"] --> C{{"AWS SDK / EC2"}}
  A --> D["src/providers/compute/awsEc2Mac.test.ts"]
  E["Docs/test counts"] --> F["README*.md + docs/*.md"]
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Create a shared AWS client utility for all AWS-backed providers
  • ➕ Avoids duplicating client/failure/optional-dep logic across future AWS providers
  • ➕ Centralizes AWS optional dependency behavior and error shaping
  • ➖ Requires designing a more generic interface (risk of over-abstraction)
  • ➖ May be premature if EC2 Mac remains the only AWS provider
2. Keep helpers internal (non-exported) and test via provider integration seams
  • ➕ Smaller public surface area; less API to maintain
  • ➕ Tests remain aligned to observable provider behavior
  • ➖ Harder to unit-test edge cases without heavier mocking
  • ➖ Encourages broader integration tests that may accidentally require AWS

Recommendation: The chosen approach (dedicated awsEc2MacClient seam + exported pure helpers) is a pragmatic refactor that improves testability and isolates optional AWS SDK concerns without changing provider semantics. If additional AWS compute providers are planned, consider evolving awsEc2MacClient into a shared AWS utility module; otherwise, keeping it scoped to EC2 Mac is appropriate.

Files changed (14) +432 / -186

Refactor (2) +264 / -175
awsEc2Mac.tsLean EC2 Mac provider via helper exports and provisioning extraction +183/-175

Lean EC2 Mac provider via helper exports and provisioning extraction

• Refactors the provider to use a new awsEc2MacClient seam for optional SDK loading, EC2 client creation, and request failure shaping. Extracts pure helper functions (instance type, AMI picking, host counting/state checks, quota detection, release error detail, Xcode marker) and consolidates post-host provisioning into provisionAllocatedHost, while keeping allocate/status/teardown/doctor semantics consistent.

src/providers/compute/awsEc2Mac.ts

awsEc2MacClient.tsIntroduce AWS EC2 client seam for lazy loading and failure mapping +81/-0

Introduce AWS EC2 client seam for lazy loading and failure mapping

• Adds a focused module that encapsulates optional dependency loading for @aws-sdk/client-ec2 and credential providers, builds the EC2 client, wraps SDK calls in an Effect failure channel, and enforces presence of the aws config block for allocations.

src/providers/compute/awsEc2MacClient.ts

Tests (1) +157 / -0
awsEc2Mac.test.tsAdd unit tests for EC2 Mac helper functions +157/-0

Add unit tests for EC2 Mac helper functions

• Introduces Vitest coverage for extracted pure helpers (address selection, instance type defaults, AMI selection, quota detection, host state handling, Xcode bootstrap marker). Also tests the awsFailure tagging and requireAws validation path without contacting AWS.

src/providers/compute/awsEc2Mac.test.ts

Documentation (11) +11 / -11
README.de.mdUpdate test-count badge +1/-1

Update test-count badge

• Bumps the README badge from 2064 to 2081 passing tests to reflect the new Vitest suite size.

README.de.md

README.es.mdUpdate test-count badge +1/-1

Update test-count badge

• Bumps the README badge from 2064 to 2081 passing tests to reflect the new Vitest suite size.

README.es.md

README.fr.mdUpdate test-count badge +1/-1

Update test-count badge

• Bumps the README badge from 2064 to 2081 passing tests to reflect the new Vitest suite size.

README.fr.md

README.ja.mdUpdate test-count badge +1/-1

Update test-count badge

• Bumps the README badge from 2064 to 2081 passing tests to reflect the new Vitest suite size.

README.ja.md

README.ko.mdUpdate test-count badge +1/-1

Update test-count badge

• Bumps the README badge from 2064 to 2081 passing tests to reflect the new Vitest suite size.

README.ko.md

README.mdUpdate test-count badge +1/-1

Update test-count badge

• Bumps the README badge from 2064 to 2081 passing tests to reflect the new Vitest suite size.

README.md

README.pt-BR.mdUpdate test-count badge +1/-1

Update test-count badge

• Bumps the README badge from 2064 to 2081 passing tests to reflect the new Vitest suite size.

README.pt-BR.md

README.ru.mdUpdate test-count badge +1/-1

Update test-count badge

• Bumps the README badge from 2064 to 2081 passing tests to reflect the new Vitest suite size.

README.ru.md

README.zh-CN.mdUpdate test-count badge +1/-1

Update test-count badge

• Bumps the README badge from 2064 to 2081 passing tests to reflect the new Vitest suite size.

README.zh-CN.md

commands.mdRefresh generated docs test count +1/-1

Refresh generated docs test count

• Updates the command reference header to reflect 2081 tests guarding the CLI surface area.

docs/commands.md

llms.txtRefresh listed test count +1/-1

Refresh listed test count

• Updates the LLM-facing command summary text to reflect the new 2081 test count.

llms.txt

const securityGroupId = yield* ensureSecurityGroup(ec2, client, vpcId);
let goldenAmiId: string | null | undefined = awsConfiguration.amiId;
if (goldenAmiId === undefined) {
goldenAmiId = yield* provideComputeServices(getAwsGoldenAmiId());

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Suggestion: Concurrent allocations can both read a null cached AMI, independently create and snapshot golden images, and then race when persisting the result. This wastes a second Dedicated Host and leaves the shared cache dependent on whichever write wins. Reserve or lock golden-image creation before provisioning, or recheck the cache atomically before snapshotting. [race condition]

Severity Level: Major ⚠️
- ⚠️ Parallel first builds duplicate Dedicated Host costs.
- ⚠️ Multiple golden AMI snapshots are created unnecessarily.
- ⚠️ Cache contents depend on write completion order.

Fix in Cursor Fix in VSCode Claude

(Use Cmd/Ctrl + Click for best experience)

Prompt for AI Agent 🤖
This is a comment left during a code review.

**Path:** src/providers/compute/awsEc2Mac.ts
**Line:** 268:268
**Comment:**
	*Race Condition: Concurrent allocations can both read a null cached AMI, independently create and snapshot golden images, and then race when persisting the result. This wastes a second Dedicated Host and leaves the shared cache dependent on whichever write wins. Reserve or lock golden-image creation before provisioning, or recheck the cache atomically before snapshotting.

Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix
👍 | 👎

): Effect.Effect<void, AwsComputeFailure> =>
Effect.gen(function* () {
const deadline = Date.now() + 5 * 60 * 1000;
const deadline = Date.now() + TERMINATE_TIMEOUT_MS;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Suggestion: The five-minute deadline causes waitForTerminated to complete successfully even when the instance is still not terminated. Teardown then proceeds to ReleaseHosts, which AWS can reject while the instance is stopping, and the caller does not clear the live-host state because teardown failed. Timeout must be reported as a failure and should not be treated as confirmation that the host is safe to release. [logic error]

Severity Level: Major ⚠️
- ❌ Teardown may attempt release before instance termination.
- ⚠️ AWS release errors leave cloud state uncleared.
- ⚠️ Users must retry cleanup for slow terminations.

Fix in Cursor Fix in VSCode Claude

(Use Cmd/Ctrl + Click for best experience)

Prompt for AI Agent 🤖
This is a comment left during a code review.

**Path:** src/providers/compute/awsEc2Mac.ts
**Line:** 755:755
**Comment:**
	*Logic Error: The five-minute deadline causes `waitForTerminated` to complete successfully even when the instance is still not terminated. Teardown then proceeds to `ReleaseHosts`, which AWS can reject while the instance is stopping, and the caller does not clear the live-host state because teardown failed. Timeout must be reported as a failure and should not be treated as confirmation that the host is safe to release.

Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix
👍 | 👎

Comment on lines +44 to +45
try: () => import('@aws-sdk/client-ec2'),
catch: (cause) => awsFailure('load the EC2 SDK', cause),

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Suggestion: The dynamic import failure is wrapped in a plain AwsComputeFailure object before reaching requireOptional. requireOptional only checks Error.message or String(cause) for module-resolution text, so the tagged object stringifies as an object and the missing-package case will not produce the documented INSTALL_HINT. Let the original import error reach requireOptional, or preserve its message in the optional-dependency detection path. [api mismatch]

Severity Level: Major ⚠️
- ⚠️ Missing AWS SDK produces a non-actionable error.
- ⚠️ AWS allocation setup lacks the documented install hint.
- ⚠️ `cloud doctor` cannot guide dependency installation.

Fix in Cursor Fix in VSCode Claude

(Use Cmd/Ctrl + Click for best experience)

Prompt for AI Agent 🤖
This is a comment left during a code review.

**Path:** src/providers/compute/awsEc2MacClient.ts
**Line:** 44:45
**Comment:**
	*Api Mismatch: The dynamic import failure is wrapped in a plain `AwsComputeFailure` object before reaching `requireOptional`. `requireOptional` only checks `Error.message` or `String(cause)` for module-resolution text, so the tagged object stringifies as an object and the missing-package case will not produce the documented `INSTALL_HINT`. Let the original import error reach `requireOptional`, or preserve its message in the optional-dependency detection path.

Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix
👍 | 👎

@qodo-code-review

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (2) 📜 Skill insights (0)

Grey Divider


Action required

1. awsEc2MacClient missing test file 📘 Rule violation ▣ Testability
Description
src/providers/compute/awsEc2MacClient.ts introduces new provider logic but there is no co-located
src/providers/compute/awsEc2MacClient.test.ts. This violates the requirement that each new logic
file has a same-directory *.test.ts, which reduces confidence in refactors and regression safety.
Code

src/providers/compute/awsEc2MacClient.ts[R1-4]

+import { Data, Effect } from 'effect';
+import { errorMessage } from '@core/services/errorMessage.js';
+import { requireOptional } from '@core/services/optionalDep.js';
+import type { AllocateRequest, AwsConfig } from '@core/types/remote.js';
Evidence
The checklist requires a co-located *.test.ts file for each new logic file (PR Compliance ID
1028645). The PR adds the new logic module src/providers/compute/awsEc2MacClient.ts, but there is
no corresponding awsEc2MacClient.test.ts alongside it; tests currently live in awsEc2Mac.test.ts
and import awsFailure/requireAws from awsEc2MacClient.js instead.

Rule 1028645: New logic files must have a co-located test file
src/providers/compute/awsEc2MacClient.ts[1-81]
src/providers/compute/awsEc2Mac.test.ts[1-17]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`src/providers/compute/awsEc2MacClient.ts` is a new logic-bearing module but it does not have a corresponding co-located test file `src/providers/compute/awsEc2MacClient.test.ts`.

## Issue Context
The compliance rule requires a co-located test file for each new logic file. While some of the functions are currently tested via `awsEc2Mac.test.ts`, the rule requires a dedicated sibling `*.test.ts` for the new module.

## Fix Focus Areas
- src/providers/compute/awsEc2MacClient.ts[1-81]
- src/providers/compute/awsEc2Mac.test.ts[1-20]
- src/providers/compute/awsEc2MacClient.test.ts[1-200]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools



Remediation recommended

2. Unprefixed reportProgress() messages 📘 Rule violation ◔ Observability
Description
New reportProgress(...) status messages do not start with the required standardized prefixes
(e.g., [RUN] ). This makes human-readable effect logging inconsistent and harder to grep/parse.
Code

src/providers/compute/awsEc2Mac.ts[277]

+    reportProgress('Launching the EC2 Mac instance...');
Evidence
PR Compliance ID 2513456 requires human-readable status/effect logs to begin with one of the
standardized prefixes. The newly introduced/refactored `reportProgress('Launching the EC2 Mac
instance...')` and the subsequent first-run progress message are emitted without any of the allowed
prefixes.

Rule 2513456: Standardize human-readable effect logging prefixes and keep JSON logs undecorated
src/providers/compute/awsEc2Mac.ts[277-290]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`reportProgress(...)` messages added/moved in the refactor are human-facing status logs but they do not use the required standardized prefixes ("[RUN] ", "[OK] ", "[WARN] ", "[ERROR] ", "[SKIP] ").

## Issue Context
The logging standard requires consistent prefixing for human-readable logs/status reporting.

## Fix Focus Areas
- src/providers/compute/awsEc2Mac.ts[277-290]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

Context used
✅ Compliance rules (platform): 47 rules

To customize comments, go to the Qodo configuration screen, or learn more in the docs.

Qodo Logo

Comment on lines +1 to +4
import { Data, Effect } from 'effect';
import { errorMessage } from '@core/services/errorMessage.js';
import { requireOptional } from '@core/services/optionalDep.js';
import type { AllocateRequest, AwsConfig } from '@core/types/remote.js';

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Action required

1. awsec2macclient missing test file 📘 Rule violation ▣ Testability

src/providers/compute/awsEc2MacClient.ts introduces new provider logic but there is no co-located
src/providers/compute/awsEc2MacClient.test.ts. This violates the requirement that each new logic
file has a same-directory *.test.ts, which reduces confidence in refactors and regression safety.
Agent Prompt
## Issue description
`src/providers/compute/awsEc2MacClient.ts` is a new logic-bearing module but it does not have a corresponding co-located test file `src/providers/compute/awsEc2MacClient.test.ts`.

## Issue Context
The compliance rule requires a co-located test file for each new logic file. While some of the functions are currently tested via `awsEc2Mac.test.ts`, the rule requires a dedicated sibling `*.test.ts` for the new module.

## Fix Focus Areas
- src/providers/compute/awsEc2MacClient.ts[1-81]
- src/providers/compute/awsEc2Mac.test.ts[1-20]
- src/providers/compute/awsEc2MacClient.test.ts[1-200]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

} else {
imageId = goldenAmiId;
}
reportProgress('Launching the EC2 Mac instance...');

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Remediation recommended

2. Unprefixed reportprogress() messages 📘 Rule violation ◔ Observability

New reportProgress(...) status messages do not start with the required standardized prefixes
(e.g., [RUN] ). This makes human-readable effect logging inconsistent and harder to grep/parse.
Agent Prompt
## Issue description
`reportProgress(...)` messages added/moved in the refactor are human-facing status logs but they do not use the required standardized prefixes ("[RUN] ", "[OK] ", "[WARN] ", "[ERROR] ", "[SKIP] ").

## Issue Context
The logging standard requires consistent prefixing for human-readable logs/status reporting.

## Fix Focus Areas
- src/providers/compute/awsEc2Mac.ts[277-290]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

@cubic-dev-ai cubic-dev-ai 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.

1 issue found across 14 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="src/providers/compute/awsEc2MacClient.ts">

<violation number="1" location="src/providers/compute/awsEc2MacClient.ts:45">
P2: Missing AWS SDKs surface a raw module-not-found error instead of the actionable `pnpm add ...` hint because the import rejection is wrapped as `AwsComputeFailure` before `requireOptional` can classify it. Keep the import rejection recognizable to `requireOptional`, then wrap only non-missing loader failures afterward; apply the same ordering to both loaders.</violation>
</file>

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

requireOptional('AWS EC2 Mac builds', INSTALL_HINT, () =>
Effect.tryPromise({
try: () => import('@aws-sdk/client-ec2'),
catch: (cause) => awsFailure('load the EC2 SDK', cause),

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: Missing AWS SDKs surface a raw module-not-found error instead of the actionable pnpm add ... hint because the import rejection is wrapped as AwsComputeFailure before requireOptional can classify it. Keep the import rejection recognizable to requireOptional, then wrap only non-missing loader failures afterward; apply the same ordering to both loaders.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/providers/compute/awsEc2MacClient.ts, line 45:

<comment>Missing AWS SDKs surface a raw module-not-found error instead of the actionable `pnpm add ...` hint because the import rejection is wrapped as `AwsComputeFailure` before `requireOptional` can classify it. Keep the import rejection recognizable to `requireOptional`, then wrap only non-missing loader failures afterward; apply the same ordering to both loaders.</comment>

<file context>
@@ -0,0 +1,81 @@
+  requireOptional('AWS EC2 Mac builds', INSTALL_HINT, () =>
+    Effect.tryPromise({
+      try: () => import('@aws-sdk/client-ec2'),
+      catch: (cause) => awsFailure('load the EC2 SDK', cause),
+    }),
+  );
</file context>

@YosefHayim
YosefHayim force-pushed the refactor/build/providers-aws-mac branch from 61046ab to b9fbe2b Compare August 7, 2026 10:46
Deslop the EC2 Mac host without changing allocate/status/teardown/doctor
semantics: extract shared SDK client/failure plumbing, pure helpers for
AMI selection, quota detection, address/host state, and release errors,
lift post-host provision into one catch-all path, and cover the helpers
with colocated Vitest (no live AWS).

Fixes #349
@YosefHayim
YosefHayim force-pushed the refactor/build/providers-aws-mac branch from b9fbe2b to 574586e Compare August 7, 2026 10:48
@YosefHayim
YosefHayim merged commit 9cfd610 into main Aug 7, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

domain:build Pipeline, distribution, build providers size:L This PR changes 100-499 lines, ignoring generated files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

refactor(build): lean awsEc2Mac compute provider

1 participant