Skip to content

Allow help targets for manifests with build-only Jinja helpers #574

Description

@leynos

Problem

netsuke help targets rejects manifests containing Jinja helpers that are not
part of its restricted query surface, even when those helpers occur only in a
recipe that target discovery does not need to execute.

For example, Catnap could select its test runner declaratively at manifest
compile time:

- name: test
  description: Run tests with cargo-nextest or Cargo
  command: >-
    RUSTFLAGS='-D warnings'
    cargo {% if command_available("cargo-nextest") %}nextest run{% else %}test{% endif %}
    --all-targets --all-features

The manifest is valid for a normal build, but netsuke help targets fails
because its restricted renderer rejects command_available(). The equivalent
two-action form using opposing when: command_available(...) expressions has
the same discovery problem.

Catnap therefore has to defer selection to a runtime shell conditional:

https://github.com/leynos/catnap/blob/de453cb63aa030844ef08e1c60d4981b6d25d949/Netsukefile#L18-L23

That workaround is more verbose, less declarative, and unnecessarily couples
a portable manifest decision to shell syntax.

Requirement

netsuke help targets should be able to list action and target metadata when
build-only fields use Jinja helpers that are unavailable in query mode. Target
discovery must not fail merely because a recipe contains
command_available(), env(), or another normal-build helper.

A suitable implementation might avoid rendering recipe-only fields during
metadata discovery. Conditional actions whose when expression uses such a
helper also need a defined discovery policy, such as listing them as
conditional, but the command should not fail wholesale.

Acceptance criteria

  • netsuke help targets succeeds for an action whose command contains the
    inline command_available() example above.
  • Define and test discovery behaviour for when expressions that use
    build-only helpers.
  • Human-readable and JSON target-help output continue to include descriptions.
  • Target discovery does not execute recipes or create build outputs.
  • Helpers that are intentionally unavailable in query mode are not executed
    merely to render recipe fields.
  • Normal build, generate, and manifest-rendering semantics remain
    unchanged.

Related to #551.

Metadata

Metadata

Assignees

No one assigned

    Labels

    RoadmapbugSomething isn't workingenhancementNew feature or requesttestingTest coverage, test infrastructure, and verification tooling work.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions