Skip to content

[refactor] Unify strict-mode policy across remote dependency fetchers in fetchAllRemoteDependenciesWithOptions #79392

Done

Description

@github-actions

Summary

Sampled semantic refactoring analysis for 2026-11-20. Slices: pkg/cli 326/646 and pkg/workflow 326/701.

Reviewed: 3 files and 14 functions from the analysis packet. Two functions were truncated (fetchFrontmatterImportsRecursive, fetchAndSaveRemoteIncludesWithOptions) and were not used as evidence. This is a sampled analysis, not coverage of the full packages or repository.

The strict flag governs only three of the six remote dependency fetchers in fetchAllRemoteDependenciesWithOptions. The other three return an error in non-strict mode too, which skips the steps after them.

Proposed refactoring

  1. Behavior-preserving extraction: replace the six hand-written if err := ... blocks in pkg/cli/includes.go (lines 793-854) with an ordered table of steps, each with a label, a run function, and explicit policy fields (for example fatalWhenStrict, fatalAlways, warnAlways). One helper iterates the table, keeping the current step order and early return.
  2. Policy decision, separate change: decide whether dispatch, call-workflow and resource failures should respect strict, and whether non-strict callers should continue past them. This changes behavior, so it should not be bundled with the extraction.
Observed policy per fetcher (pkg/cli/includes.go:790-856)
Step Lines Strict Non-strict
Includes 793-807 returns error verbose-only warning, continues
Frontmatter imports 812-819 returns error verbose-only warning, continues
Runtime imports 822-830 returns error unconditional warning (826), continues
Dispatch workflows 833-838 returns error returns error (837), skips later steps
Call-workflow workers 841-846 returns error returns error (845), skips later steps
Resources 849-854 returns error returns error (853)

Dispatch step as written:

if err := fetchAndSaveRemoteDispatchWorkflows(ctx, content, spec, targetDir, verbose, force, tracker); err != nil {
    if verbose {
        fmt.Fprintln(os.Stderr, console.FormatWarningMessage(fmt.Sprintf("Failed to fetch dispatch workflow dependencies: %v", err)))
    }
    return fmt.Errorf("failed to fetch dispatch workflow dependencies: %w", err)
}

Observed consequences:

  • In non-strict mode, a failing dispatch fetch returns before the call-workflow and resource fetchers run.
  • The frontmatter fetcher receives the strict argument (line 812). The runtime, dispatch, call-workflow and resource fetchers do not, so the policy lives in each call site rather than in a shared rule.
  • The non-strict runtime-import warning (line 826) is not gated by verbose; the other non-strict warnings are.
Preservation risks
  • User-visible error prefixes differ per step and must stay verbatim.
  • A uniform helper would silently change the runtime-import warning unless its policy field preserves the unconditional print.
  • The always-fatal steps print a verbose warning and then return the error. A helper that prints and returns could double-report if the caller also prints.
  • Non-strict mode must stop at the always-fatal steps, not continue past them.
  • Callers of fetchAllRemoteDependencies and fetchAllRemoteDependenciesStrict were not in the packet, so whether they treat a non-strict error as fatal is unverified.
  • No tests were run, and tests that match these strings or the step order were not checked.

Verification before refactoring

Add table-driven tests that pin, for each of the six steps, the strict and non-strict outcome, the returned error, and whether later steps run. Run them before and after the extraction.

References:

Generated by 🔧 Semantic Function Refactoring · claude · routed: haiku55 xhigh · ~3 AIC · ⌖ ~1 AIC · ⊞ 4.1K · ◷

  • expires on Nov 21, 2026, 6:28 PM UTC-08:00

Activity

  1. github-actions commented on Nov 20, 2026

    @github-actions
    ContributorAuthor

    🍪 Issue Monster selected this for Copilot

    I've identified this issue as a good candidate for automated resolution and requested assignment to the Copilot coding agent.

    If assignment succeeds, Copilot will analyze the issue and create a pull request with the fix.

    Om nom nom! 🍪

    🍪 Om nom nom by Issue Monster · pi · gpt50 · ~1 AIC · ⌖ ~1 AIC · ⊞ 11.5K · ◷

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions