Skip to content

feat(toolchain): parallel installs with safe locking - #2758

Merged
Andriy Knysh (aknysh) merged 15 commits into
mainfrom
osterman/parallel-package-installs
Jul 17, 2026
Merged

Andriy Knysh (aknysh) merged 15 commits into
mainfrom
osterman/parallel-package-installs

Conversation

@osterman

@osterman Erik Osterman (Cloud Posse) (osterman) commented Jul 15, 2026 •

Copy link
Copy Markdown
Member

what

  • Install independent toolchain packages concurrently (default four), with parent-owned terminal rendering, lifecycle states, and byte-progress display.
  • Add context-aware cross-process and in-process reader/writer locks for assets, installs, latest markers, lockfiles, .tool-versions, and uninstall mutations.
  • Materialize legacy Cosign evidence locally, route it to compatible Cosign v2.6.1, serialize verifier execution, and retry only pre-verdict transport/process failures.
  • Restore full package IDs in uninstall results and keep automatic dependency installs on the configured toolchain path.

why

  • Parallel workers previously exposed shared verifier and mutable-file races; this keeps installs fast while preserving UI and data integrity.
  • OpenTofu releases still publish legacy certificate/signature evidence, and Cosign v3 both deprecates that path and intermittently rejects valid Rekor evidence.

references

  • N/A

Summary by CodeRabbit

  • New Features
    • Parallel, bounded toolchain installs with --max-concurrency/toolchain.max_concurrency (requires ≥ 1), plus enhanced batch progress and download progress reporting.
    • Improved Cosign verification for legacy certificate/signature option formats.
  • Bug Fixes
    • Safer concurrent installs/verifications via cross-process locking for caches, downloads, .tool-versions, and tool lockfiles; serialized trust repair and improved macOS retry classification.
    • More reliable batch failure reporting and clearer tool-spec messaging.
  • Documentation
    • Updated CLI/config docs, plus added a release blog post and roadmap entry.
  • Chores
    • Ignore local .tool-versions.lock files.

@atmos-pro

atmos-pro Bot commented Jul 15, 2026 •

Copy link
Copy Markdown
Contributor

Tip

Atmos Pro  

No affected stacks workflow was detected for this pull request.
If this is expected, no action is needed.
Learn More. Ask AI.

@github-actions github-actions Bot added the size/l Large size PR label Jul 15, 2026
@github-actions

Copy link
Copy Markdown

Dependency Review

✅ No vulnerabilities or license issues found.

Scanned Files

None

@osterman
Erik Osterman (Cloud Posse) (osterman) marked this pull request as ready for review July 16, 2026 00:12
@osterman Erik Osterman (Cloud Posse) (osterman) added the minor New features that do not break anything label Jul 16, 2026
@github-actions

github-actions Bot commented Jul 16, 2026 •

Copy link
Copy Markdown

Warning

Release Documentation Required

This PR is labeled minor or major and requires documentation updates:

  • Changelog entry - Add a blog post in website/blog/YYYY-MM-DD-feature-name.mdx
  • Roadmap update - Update website/src/data/roadmap.js with the new milestone

Alternatively: If this change doesn't require release documentation, remove the minor or major label.

@coderabbitai

coderabbitai Bot commented Jul 16, 2026 •

Copy link
Copy Markdown
Contributor

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
  • ✅ Review completed - (🔄 Check again to review again)
📝 Walkthrough

Walkthrough

The PR adds cross-process file locking, bounded concurrent toolchain installation with progress rendering, Cosign compatibility and retry handling, concurrency configuration, coordinated toolchain state updates, and related documentation and output changes.

Changes

Toolchain concurrency and verification

Layer / File(s) Summary
Shared file-locking foundation
pkg/filelock/*, pkg/cache/filelock.go
Adds shared/exclusive cross-process locking, context-aware acquisition, cache lock handling, and concurrency tests.
Toolchain state and installer lock integration
pkg/toolchain/tool_versions.go, pkg/toolchain/filemanager/*, pkg/toolchain/installer/*
Serializes tool-version, lockfile, installation, uninstall, and latest-version filesystem transactions.
Bounded installation and progress flow
cmd/toolchain/install.go, pkg/schema/schema.go, pkg/toolchain/install.go, pkg/toolchain/installer/download.go
Adds max-concurrency configuration, concurrent batch workers, event-driven rendering, download progress callbacks, and failure propagation.
Verifier compatibility and sidecar handling
pkg/toolchain/installer/installer.go, pkg/toolchain/verification/*
Handles legacy Cosign arguments, serializes trust repair, downloads option sidecars, and retries additional macOS transport failures.
Configuration, development setup, and output documentation
cmd/toolchain/toolchain.go, .atmos.d/dev.yaml, .gitignore, pkg/toolchain/uninstall.go, website/docs/*, website/blog/*, website/src/data/roadmap.js
Refines configuration precedence, documents parallel installs, pins development tools, ignores tool-version lockfiles, updates the roadmap, and formats uninstall tool specifications with backticks.

Estimated code review effort: 5 (Critical) | ~120 minutes

Sequence Diagram(s)

sequenceDiagram
  participant CLI
  participant InstallCommand
  participant BatchWorkers
  participant Installer
  participant Renderer
  CLI->>InstallCommand: provide max concurrency
  InstallCommand->>BatchWorkers: start bounded tool installs
  BatchWorkers->>Installer: install and report download progress
  Installer-->>Renderer: emit progress and result events
  Renderer-->>CLI: render install status and summary
Loading
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 28.57% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: parallel toolchain installs with safer locking.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch osterman/parallel-package-installs

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.

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

Actionable comments posted: 12

🧹 Nitpick comments (1)
pkg/toolchain/install_test.go (1)

30-41: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Refactor to use a table-driven test.

As per coding guidelines, use table-driven tests for testing multiple scenarios in Go.

♻️ Proposed refactor
-func TestRightAlignInstallProgress(t *testing.T) {
-	t.Run("shows downloaded and total bytes at the terminal edge", func(t *testing.T) {
-		line := rightAlignInstallProgress("⣾ Installing owner/[email protected]", 85*1024*1024, 100*1024*1024, 80)
-		assert.True(t, strings.HasSuffix(line, "85.0 MB/100.0 MB"))
-		assert.Equal(t, 80, lipgloss.Width(line))
-	})
-
-	t.Run("does not wrap a narrow terminal", func(t *testing.T) {
-		left := "⣾ Installing owner/[email protected]"
-		assert.Equal(t, left, rightAlignInstallProgress(left, 85*1024*1024, 100*1024*1024, len(left)))
-	})
-}
+func TestRightAlignInstallProgress(t *testing.T) {
+	tests := []struct {
+		name       string
+		left       string
+		downloaded int64
+		total      int64
+		width      int
+		verify     func(t *testing.T, line string)
+	}{
+		{
+			name:       "shows downloaded and total bytes at the terminal edge",
+			left:       "⣾ Installing owner/[email protected]",
+			downloaded: 85 * 1024 * 1024,
+			total:      100 * 1024 * 1024,
+			width:      80,
+			verify: func(t *testing.T, line string) {
+				assert.True(t, strings.HasSuffix(line, "85.0 MB/100.0 MB"))
+				assert.Equal(t, 80, lipgloss.Width(line))
+			},
+		},
+		{
+			name:       "does not wrap a narrow terminal",
+			left:       "⣾ Installing owner/[email protected]",
+			downloaded: 85 * 1024 * 1024,
+			total:      100 * 1024 * 1024,
+			width:      len("⣾ Installing owner/[email protected]"),
+			verify: func(t *testing.T, line string) {
+				assert.Equal(t, "⣾ Installing owner/[email protected]", line)
+			},
+		},
+	}
+
+	for _, tt := range tests {
+		t.Run(tt.name, func(t *testing.T) {
+			line := rightAlignInstallProgress(tt.left, tt.downloaded, tt.total, tt.width)
+			tt.verify(t, 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 `@pkg/toolchain/install_test.go` around lines 30 - 41, Refactor
TestRightAlignInstallProgress into a table-driven test with named cases for the
terminal-edge and narrow-terminal scenarios. Store each case’s input and
expected output, then iterate with t.Run while preserving the existing suffix,
width, and unchanged-line assertions.

Source: Coding guidelines

🤖 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 `@cmd/toolchain/install.go`:
- Around line 40-43: Add the ATMOS_TOOLCHAIN_MAX_CONCURRENCY
environment-variable mapping alongside the existing registrations in the install
command, associating it with the max-concurrency flag/config key so environment
values participate in the established flag/env/config precedence.

In `@cmd/toolchain/toolchain.go`:
- Around line 147-155: Remove bindToolchainEnvironment and its invocation,
avoiding direct viper.BindEnv usage. In PersistentPreRunE, use os.LookupEnv for
ATMOS_TOOL_VERSIONS and ATMOS_TOOLCHAIN_PATH alongside the corresponding flag
Changed checks before copying viper values into atmosCfg.Toolchain; add the os
import and preserve the existing initialization behavior.

In `@pkg/filelock/filelock_test.go`:
- Around line 20-27: The file-lock tests discard errors from asynchronous
WithExclusive/WithShared calls and helper processes, allowing channel waits to
hang indefinitely. Update the affected test goroutines and helper-process
handling to send failures through buffered error channels, and replace unbounded
waits on held/release signals with bounded select-based waits that fail loudly
on errors or timeouts; preserve successful callback synchronization.

In `@pkg/toolchain/install.go`:
- Around line 338-347: Update the concurrent installation branch around
InstallSingleTool and the direct installer.Install call by extracting a shared
lifecycle helper that accepts the worker-configured Installer. Have the helper
perform the same latest-version resolution and handleInstallSuccess processing
as InstallSingleTool, while retaining the configured progress callback; route
both sequential and concurrent paths through this helper.
- Around line 684-686: Update startBatchInstallWorkers so progress callbacks do
not block downloads on terminal rendering: coalesce progress events by tool,
retaining only the latest state, and make intermediate event delivery
non-blocking or throttled. Have the existing ticker render the coalesced latest
progress for all active tools rather than redrawing on every received event,
while preserving completion and error event handling.

In `@pkg/toolchain/installer/installer.go`:
- Around line 946-948: In the uninstall flow around versionDir and filelock.New,
create the parent directory with os.MkdirAll(filepath.Dir(versionDir),
defaultMkdirPermissions) before opening the lock, handling any resulting error
consistently with Install. Preserve the existing lock and FindBinaryPath
behavior afterward.

In `@pkg/toolchain/installer/lockfile_update.go`:
- Around line 39-40: Update the directory-creation error handling in the
installer lockfile update method to wrap the static ErrLockfileIO domain error
while preserving the underlying MkdirAll error as contextual wrapping. Keep the
existing directory context and ensure callers can classify this failure
consistently with the load/save paths.

In `@pkg/toolchain/tool_versions_test.go`:
- Line 19: Replace require.NoError with assert.NoError in the background
goroutines at pkg/toolchain/tool_versions_test.go:19-19 and
pkg/toolchain/installer/lockfile_update_test.go:28-28, preserving the existing
error checks while avoiding FailNow from concurrent test goroutines.

In `@pkg/toolchain/tool_versions.go`:
- Around line 59-64: The public LoadToolVersions path in
pkg/toolchain/tool_versions.go must acquire a shared lock, while exclusive
transactions should call an unlocked loader to avoid recursive locking; update
the relevant load/save helpers accordingly. In
pkg/toolchain/installer/version.go, update ReadLatestFile to acquire
latestFilePath+".lock" in shared mode, or replace the write flow with atomic
replacement. Apply the corresponding change at both identified sites.

In `@pkg/toolchain/verification/signature_test.go`:
- Around line 100-102: Update both signature verification tests around the
existing runner.calls assertions to store the test asset path in an AssetPath
variable and assert that runner.calls[0].args[len(runner.calls[0].args)-1]
equals AssetPath. Retain the existing argument and sidecar assertions while
adding this final positional-argument check in both tests.

In `@pkg/toolchain/verification/signature.go`:
- Around line 115-117: Update the error handling after
downloadCosignOptionSidecars in the verification flow to pass failures through
the same signature-policy branch used by downloadCosignSidecars, rather than
returning immediately. Preserve optional-verification skip recording and ensure
required verification applies the ErrSignatureRequired wrapper.
- Around line 149-152: Update Verifier.downloadCosignOptionSidecars to proceed
whenever any supported remote Cosign sidecar option is present, including
standalone --certificate, --signature, --key, --bundle, and mixed local/remote
combinations, instead of requiring hasRemoteCertificateSignaturePair(args).
Ensure all such remote options are localized through the existing Atmos download
and retry handling.

---

Nitpick comments:
In `@pkg/toolchain/install_test.go`:
- Around line 30-41: Refactor TestRightAlignInstallProgress into a table-driven
test with named cases for the terminal-edge and narrow-terminal scenarios. Store
each case’s input and expected output, then iterate with t.Run while preserving
the existing suffix, width, and unchanged-line assertions.
🪄 Autofix (Beta)

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: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 29370ded-bce8-4cbe-8333-09a564d7fc19

📥 Commits

Reviewing files that changed from the base of the PR and between 6b3b0ef and f73c2e3.

📒 Files selected for processing (32)
  • .atmos.d/dev.yaml
  • .gitignore
  • cmd/toolchain/install.go
  • cmd/toolchain/toolchain.go
  • pkg/cache/file_cache.go
  • pkg/cache/filelock.go
  • pkg/cache/filelock_unix.go
  • pkg/cache/filelock_windows.go
  • pkg/filelock/filelock.go
  • pkg/filelock/filelock_test.go
  • pkg/schema/schema.go
  • pkg/toolchain/filemanager/lockfile.go
  • pkg/toolchain/install.go
  • pkg/toolchain/install_test.go
  • pkg/toolchain/installer/download.go
  • pkg/toolchain/installer/download_test.go
  • pkg/toolchain/installer/installer.go
  • pkg/toolchain/installer/lockfile_update.go
  • pkg/toolchain/installer/lockfile_update_test.go
  • pkg/toolchain/installer/verifier_command_test.go
  • pkg/toolchain/installer/version.go
  • pkg/toolchain/remove.go
  • pkg/toolchain/tool_versions.go
  • pkg/toolchain/tool_versions_test.go
  • pkg/toolchain/types.go
  • pkg/toolchain/uninstall.go
  • pkg/toolchain/uninstall_test.go
  • pkg/toolchain/verification/checksum_test.go
  • pkg/toolchain/verification/signature.go
  • pkg/toolchain/verification/signature_rekor.go
  • pkg/toolchain/verification/signature_rekor_test.go
  • pkg/toolchain/verification/signature_test.go
💤 Files with no reviewable changes (2)
  • pkg/cache/filelock_unix.go
  • pkg/cache/filelock_windows.go

Comment thread cmd/toolchain/install.go Resolved
Comment thread cmd/toolchain/toolchain.go Resolved
Comment thread pkg/filelock/filelock_test.go Resolved
Comment thread pkg/toolchain/install.go Resolved
Comment thread pkg/toolchain/install.go Resolved
Comment thread pkg/toolchain/tool_versions_test.go Resolved
Comment thread pkg/toolchain/tool_versions.go Resolved
Comment thread pkg/toolchain/verification/signature.go Resolved
Comment thread pkg/toolchain/verification/signature.go Resolved
coderabbitai[bot]
coderabbitai Bot previously approved these changes Jul 16, 2026
@mergify

mergify Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

💥 This pull request now has conflicts. Could you fix it Erik Osterman (Cloud Posse) (@osterman)? 🙏

@mergify mergify Bot added the conflict This PR has conflicts label Jul 16, 2026
…kage-installs

# Conflicts:
#	.atmos.d/dev.yaml
@mergify

mergify Bot commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Important

Cloud Posse Engineering Team Review Required

This pull request modifies files that require Cloud Posse's review. Please be patient, and a core maintainer will review your changes.

To expedite this process, reach out to us on Slack in the #pr-reviews channel.

@codecov

codecov Bot commented Jul 17, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 75.94554% with 159 lines in your changes missing coverage. Please review.
✅ Project coverage is 81.89%. Comparing base (c04641e) to head (f9aa981).

Files with missing lines Patch % Lines
pkg/toolchain/install.go 55.82% 77 Missing and 14 partials ⚠️
cmd/toolchain/install.go 50.00% 13 Missing ⚠️
pkg/toolchain/installer/installer.go 83.95% 7 Missing and 6 partials ⚠️
pkg/toolchain/installer/version.go 56.52% 6 Missing and 4 partials ⚠️
pkg/toolchain/filemanager/lockfile.go 86.53% 4 Missing and 3 partials ⚠️
cmd/toolchain/toolchain.go 0.00% 6 Missing ⚠️
pkg/toolchain/installer/lockfile_update.go 75.00% 3 Missing and 3 partials ⚠️
pkg/filelock/filelock.go 93.97% 4 Missing and 1 partial ⚠️
pkg/toolchain/installer/download.go 95.00% 1 Missing and 1 partial ⚠️
pkg/toolchain/tool_versions.go 94.73% 1 Missing and 1 partial ⚠️
... and 2 more

❌ Your patch check has failed because the patch coverage (75.94%) is below the target coverage (85.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff            @@
##             main    #2758    +/-   ##
========================================
  Coverage   81.88%   81.89%            
========================================
  Files        1720     1721     +1     
  Lines      162234   162657   +423     
========================================
+ Hits       132853   133209   +356     
- Misses      22114    22165    +51     
- Partials     7267     7283    +16     
Flag Coverage Δ
unittests 81.89% <75.94%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
pkg/cache/file_cache.go 86.61% <ø> (ø)
pkg/cache/filelock.go 100.00% <100.00%> (ø)
pkg/schema/schema.go 86.42% <ø> (ø)
pkg/toolchain/remove.go 100.00% <100.00%> (+9.52%) ⬆️
pkg/toolchain/remove_helpers.go 100.00% <100.00%> (ø)
pkg/toolchain/types.go 94.23% <100.00%> (+0.35%) ⬆️
pkg/toolchain/verification/signature_rekor.go 89.74% <ø> (ø)
pkg/toolchain/installer/download.go 87.50% <95.00%> (+1.37%) ⬆️
pkg/toolchain/tool_versions.go 90.60% <94.73%> (-0.02%) ⬇️
pkg/toolchain/uninstall.go 70.08% <71.42%> (ø)
... and 9 more

... and 10 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@aknysh
Andriy Knysh (aknysh) merged commit 580f5c0 into main Jul 17, 2026
87 checks passed
@aknysh
Andriy Knysh (aknysh) deleted the osterman/parallel-package-installs branch July 17, 2026 01:04
@atmos-pro

atmos-pro Bot commented Jul 17, 2026 •

Copy link
Copy Markdown
Contributor

Tip

Atmos Pro  

No affected stacks workflow was detected for this pull request.
If this is expected, no action is needed.
Learn More. Ask AI.

@mergify mergify Bot removed the needs-cloudposse Needs Cloud Posse assistance label Jul 17, 2026
@github-actions

Copy link
Copy Markdown

These changes were released in v1.223.1-rc.1.

This branch was successfully deployed

1 active deployment
preview — f9aa981c Deployed Jul 17, 2026 by github-actions[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

minor New features that do not break anything size/l Large size PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants