Skip to content

#337: Type PackUpdater update results so failures surface a non-zero exit#349

Merged
bguidolim merged 3 commits into
mainfrom
bruno/337-typed-update-result
May 28, 2026
Merged

#337: Type PackUpdater update results so failures surface a non-zero exit#349
bguidolim merged 3 commits into
mainfrom
bruno/337-typed-update-result

Conversation

@bguidolim
Copy link
Copy Markdown
Collaborator

Summary

mcs pack update, mcs sync --update, and mcs update always exited zero — even when every pack failed with a transport error — because every non-success outcome was flattened into one opaque "skipped" string. CI and the --all-projects fan-out had no failure signal, and a user declining a trust prompt looked identical to a crash. This distinguishes the outcomes so genuine failures surface a non-zero exit while an expected trust-decline stays zero.

Changes

  • A hard failure (failed fetch, broken local checkout, invalid fetched manifest, or internal error) now exits non-zero when running non-interactively (CI), or when every attempted pack failed. Declining a trust prompt is not a failure and exits zero, re-prompting on the next run. Partial outages still re-apply the packs that succeeded before the failure is signalled.

Test plan

  • swift test passes locally
  • swiftformat --lint . and swiftlint pass without violations
  • Run mcs pack update <pack> and decline the trust prompt → expect exit code 0 and a non-scary notice.
  • Point a pack's checkout at an unreachable remote, then mcs update --global < /dev/null → expect a non-zero exit.
  • Run mcs update against healthy packs → expect exit 0 and packs re-applied.
Checklist for engine changes
  • Integration tests updated for new features (LifecycleIntegrationTests or DoctorRunnerIntegrationTests)

…exit

- Replace the single skipped(String) outcome with typed cases (fetch failure, broken checkout, invalid manifest, trust-declined, internal error)
- Pack-update commands now exit non-zero when non-interactive (CI) or when every attempted pack failed; a trust-decline stays zero-exit
- Centralize the exit-code decision so all three update callers stay in contract
Copy link
Copy Markdown

Copilot AI left a comment

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 refines pack update outcomes so commands can distinguish expected trust declines from hard update failures and return non-zero exits when appropriate.

Changes:

  • Replaces opaque skipped results with typed PackUpdater.UpdateResult failure/success cases.
  • Adds shared non-zero exit policy and applies it across pack update flows.
  • Adds unit coverage for result classification, trust decline, invalid manifests, and non-interactive lockfile update failure.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
Sources/mcs/Sync/PackUpdater.swift Introduces typed update results, hard-failure classification, and shared exit policy.
Sources/mcs/Sync/LockfileOperations.swift Tracks attempted/failed packs and throws non-zero exit failures for update failures.
Sources/mcs/Commands/UpdateCommand.swift Carries failed/skipped update state through reapply and delays failure signalling.
Sources/mcs/Commands/PackCommand.swift Applies typed update results and non-zero exit policy to mcs pack update.
Tests/MCSTests/PackUpdaterTests.swift Updates and expands PackUpdater result tests.
Tests/MCSTests/LockfileOperationsTests.swift Adds non-interactive failure exit coverage for updatePacks().

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

Comment thread Sources/mcs/Sync/PackUpdater.swift
Comment thread Sources/mcs/Sync/LockfileOperations.swift
bguidolim added 2 commits May 29, 2026 00:32
- Fold .localCheckoutBroken into .fetchFailed (a broken checkout already surfaces as fetchFailed since update() reads HEAD first)
- Reword .internalError reason to "could not verify pack scripts" (avoid mis-attributing user-environment errors to bugs)
- Add shouldExitNonZero truth-table test; document deprecated sync --update pre-sync throw
- Add exit-status notes to docs/cli.md: hard failures exit non-zero in CI or when all packs fail; trust-declines stay zero
@bguidolim bguidolim merged commit 13672d0 into main May 28, 2026
4 checks passed
@bguidolim bguidolim deleted the bruno/337-typed-update-result branch May 28, 2026 22:40
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