discovery.manager
napt.discovery.manager
Discovery pipeline orchestration.
This module owns the top-level discover_recipe
entry point used by napt discover. It loads the merged configuration,
picks a flow based on the recipe's discovery.strategy value, persists
state for the next run, and returns the public
DiscoverResult.
Two Flows
Two flows feed into the same orchestration:
- Version-first (api_github, api_json, web_scrape and any other registered DiscoveryStrategy): the strategy returns a RemoteVersion, and resolve_with_cache decides whether to skip the download (version unchanged + file present) or fetch fresh.
- url_download (handled by
run_url_download):
downloads the file with HTTP conditional headers (
ETag/Last-Modified) and extracts the version from the file's metadata. Not a registered strategy because it cannot determine the version without the file.
Both flows return a StrategyResult, which this module unwraps into state-cache fields and the public result.
discover_recipe
discover_recipe(
recipe_path: Path,
output_dir: Path | None = None,
state_file: Path | None = Path("state/versions.json"),
stateless: bool = False,
) -> DiscoverResult
Discovers the latest version of an app and resolves its installer.
Loads the recipe configuration, dispatches to the appropriate
discovery flow (version-first registered strategy or url_download),
persists the result to the state cache, and returns the public
discovery result.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
recipe_path
|
Path
|
Path to the recipe YAML file. Must exist and be readable. |
required |
output_dir
|
Path | None
|
Directory to download the installer into. When
omitted, falls back to |
None
|
state_file
|
Path | None
|
Path to the state file used for caching. Defaults
to |
Path('state/versions.json')
|
stateless
|
bool
|
When True, skips loading and saving state entirely. Forces every run to behave as if no prior cache existed. |
False
|
Returns:
| Type | Description |
|---|---|
DiscoverResult
|
Public discovery result containing the resolved version, |
DiscoverResult
|
file path, and SHA-256 hash. |
Raises:
| Type | Description |
|---|---|
ConfigError
|
On missing or invalid configuration, including
an unknown |
NetworkError
|
On download or version-extraction failures from either flow. |