Skip to content

Split createMainAction into focused orchestration modules - #11599

Merged
lpcox merged 3 commits into
mainfrom
copilot/refactoring-split-createmainaction
Nov 14, 2026
Merged

lpcox merged 3 commits into
mainfrom
copilot/refactoring-split-createmainaction

Conversation

@lpcox

@lpcox lpcox commented Nov 14, 2026 •

Copy link
Copy Markdown
Collaborator

createMainAction mixes command assembly, runtime wiring, and exit handling in a security-sensitive lifecycle. This refactor reduces the handler from 505 to 234 lines while retaining its export and startup/cleanup ordering.

  • Command assembly: Extract reflect validation and single-/multi-argument handling, preserving container-side shell expansion.
  • Runtime wiring: Extract backend adaptation, harness dependencies, command tracking, diagnostics, and signal callbacks.
  • Exit handling: Extract exit markers, startup diagnostic decisions, fatal cleanup, and routing exit-code propagation.
  • Lifecycle ownership: Keep mutable state in the handler; callbacks read the shared context so runtime fallback cannot leave stale backend or cleanup references.

@lpcox lpcox changed the title [WIP] Refactor createMainAction into focused modules Split createMainAction into focused orchestration modules Nov 14, 2026
@lpcox
lpcox marked this pull request as ready for review November 14, 2026 19:52
Copilot AI adaptive review requested due to automatic review settings November 14, 2026 19:52

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.

🟡 Changes recommended

The enclave conformance workflow omits the new main-action directory and test files, allowing changes to preflight gating and exit markers to bypass its checks.

1 open issue
What changed in this PR

Refactors AWF’s main CLI action into focused modules for #11594, retaining the createMainAction export and keeping mutable lifecycle state in the handler.

Changes:

  • Extracts command assembly, runtime wiring, signal callbacks, and exit handling.
  • Adds focused tests for command quoting, runtime selection, diagnostics, cleanup ordering, and exit-code propagation.
File Description
src/​commands/​main-action/​external-runtime-wiring.ts Builds workflow dependencies and registers state-aware signal callbacks.
src/​commands/​main-action/​external-runtime-wiring.test.ts Tests runtime selection, diagnostics, preflight checks, and fallback callbacks.
src/​commands/​main-action/​exit-handling.ts Centralizes exit markers, fatal cleanup, and routing exit codes.
src/​commands/​main-action/​exit-handling.test.ts Tests cleanup ordering, capture handling, and exit-code propagation.
src/​commands/​main-action/​agent-command.ts Extracts reflect validation and shell-preserving command assembly.
src/​commands/​main-action/​agent-command.test.ts Tests quoting, expansion preservation, and invalid inputs.
src/​commands/​main-action.ts Composes the helpers while retaining lifecycle ownership.

Review effort: Max (dynamic)

Comment on lines +134 to +135
prepareEnclaves: config.enclaves?.enabled
&& externalRuntimeBackend?.runtime === 'cloud-hypervisor'
@lpcox

lpcox commented Nov 14, 2026

Copy link
Copy Markdown
Collaborator Author

@copilot address all review feedback

Copilot AI commented Nov 14, 2026

Copy link
Copy Markdown
Contributor

@copilot address all review feedback

Added the nested main-action path filter and both requested Jest test paths in commit a74fbbc.

@github-actions

Copy link
Copy Markdown
Contributor

✅ Copilot review passed with no inline comments.

@lpcox Add the ready-for-aw label to this PR to trigger agentic CI smoke tests.

@lpcox
lpcox merged commit b4ff8df into main Nov 14, 2026
44 of 46 checks passed
@lpcox
lpcox deleted the copilot/refactoring-split-createmainaction branch November 14, 2026 20:49
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.

[Refactoring] Split createMainAction in src/commands/main-action.ts into focused modules

3 participants