Skip to content

ci: self-heal empty oclif command tree before NUTs @W-24530265@ - #514

Open
nico-pappagianis wants to merge 1 commit into
mainfrom
nico/nuts-preflight-heal-command-tree
Open

nico-pappagianis wants to merge 1 commit into
mainfrom
nico/nuts-preflight-heal-command-tree

Conversation

@nico-pappagianis

Copy link
Copy Markdown
Collaborator

Problem

The `tests` workflow NUTs on ubuntu intermittently fail with every `agent:*` subcommand reporting `command ... not found` (oclif exit 2), cascading into secondary assertion errors. It reproduces across all 3 retry attempts and is not caused by the PR under test — it's a build/cache flake.

Root cause: the shared reusable workflow (`salesforcecli/github-workflows/.github/workflows/nut.yml`) runs `yarn compile` then `yarn oclif manifest` once, before a `nick-fields/retry` block that re-runs only the NUT command. `yarn compile` is wireit-cached and, on the Actions runner, restores `lib/` from the GitHub Actions cache instead of running tsc. When that per-job restore is incomplete, `lib/commands` is empty at manifest time, so `oclif manifest` silently writes a zero-command manifest (it still prints "wrote manifest", no error). Every `agent:*` NUT then 404s at command-resolution time — and because the retry block never rebuilds, all attempts fail identically.

Fix

Add `scripts/verify-commands.mjs` and run it (as `nuts:preflight`) at the front of each `test:nuts:*` script — i.e. inside the retried command, which is the only thing plugin-agent controls in the retry loop.

  • Healthy case (common): verify the manifest has >0 commands and `lib/commands` is non-empty — a sub-second no-op, so the fast cached build is preserved.
  • Empty command tree: force an un-cached `WIREIT_CACHE=none yarn compile`, regenerate the manifest, and re-verify. The next retry attempt then runs against a correct `lib/`, turning a silent 404 into either a heal or a loud build failure (exit 1).

This lives entirely in plugin-agent (no change to the shared `github-workflows` repo) and keeps the cache speedup for the ~95% of jobs that restore correctly.

Validation (local)

  • Heal path (manifest genuinely missing): detected 0 commands → clean rebuild → 41 commands → exit 0.
  • Healthy path: 0.07s no-op.
  • `scripts/` is outside the eslint globs; lint/commitlint pre-commit hooks pass.

Notes / follow-ups

  • Heals between retry attempts, not inside a running mocha process — fine here, since the whole suite 404s together when `lib/` is bad.
  • Symptom-level fix (don't trust an incomplete cache restore); the underlying wireit GitHub-cache partial-restore race is worth a separate investigation.
  • Draft: hasn't run against CI yet.

On CI the shared nut.yml workflow runs `yarn compile` + `yarn oclif manifest`
once, before a retry block that only re-runs the NUT command. `yarn compile` is
wireit-cached and restores `lib/` from the GitHub Actions cache rather than
running tsc; when that restore is incomplete, `lib/commands` is empty at manifest
time and `oclif manifest` silently writes a zero-command manifest. Every `agent:*`
NUT then fails `command ... not found` (exit 2), and since the retry block never
rebuilds, all attempts fail identically.

Add scripts/verify-commands.mjs and run it (as `nuts:preflight`) at the front of
each `test:nuts:*` script, inside the retried command. Healthy case: a sub-second
no-op, so the fast cached build is preserved. Empty command tree: force an
un-cached `WIREIT_CACHE=none yarn compile`, regenerate the manifest, and
re-verify, so the next retry attempt runs against a correct lib/ — turning a
silent 404 into either a heal or a loud build failure.
@github-actions

github-actions Bot commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

This PR lacks any commits of the 'fix' or 'feat' type, and therefore will not trigger a release. To silence all further warnings, react to this warning comment (or any other) with the 👀 emoji.

NOTE: If your repo uses squash commits, make sure to add the appropriate conventional commit prefix (e.g., 'fix:', 'feat:', 'chore:', etc) in the squash commit message.

@nico-pappagianis nico-pappagianis changed the title ci: self-heal empty oclif command tree before NUTs ci: self-heal empty oclif command tree before NUTs @W-24530265@ Nov 6, 2026
@nico-pappagianis
nico-pappagianis marked this pull request as ready for review November 6, 2026 23:52
@nico-pappagianis
nico-pappagianis requested a review from a team as a code owner November 6, 2026 23:52
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