Skip to content

Chore/legacy cleanup - #61

Merged
JSChronicles merged 8 commits into
mainfrom
chore/legacy_cleanup
Jul 27, 2026
Merged

Chore/legacy cleanup#61
JSChronicles merged 8 commits into
mainfrom
chore/legacy_cleanup

Conversation

@JSChronicles

Copy link
Copy Markdown
Owner

Description

Refactors Anvil’s target pipeline around a provider-owned contract. Providers now control target validation, filtering, preparation, and execution-target resolution, while the shared runner focuses on orchestration and scheduling.

This also removes the legacy ConfigBranch abstraction, standardizes result payloads on target/targets, strengthens task and processor validation, and caches component discovery for substantially faster repeated listings.

Key changes

  • Extended the provider contract with:
    • resolve_target_filters
    • prepare_target
    • provider-owned validation
    • explicit preparation state and scheduler admission keys
  • Migrated AWS account, organization, authentication, and session modules under anvil.providers.aws.
  • Updated AWS, Azure, GCP, and GitHub providers to own their target modes, options, filters, region semantics, and execution preparation.
  • Simplified schema v2 so provider names, modes, and options can be supplied by discovered providers instead of being hard-coded in the shared JSON schema.
  • Removed ConfigBranch throughout descriptors, CLI handling, validation, execution, processors, and result serialization.
  • Removed the task invocation shim and invoke tasks directly through TaskCallContext.
  • Standardized execution output on target and targets.
  • Enriched results and queries with:
    • provider information
    • entity metadata
    • recorded task actions
  • Centralized keyword-only callable validation for tasks and processors.
  • Added task and processor documentation validation for detailed CLI listings.
  • Added provider-scoped duplicate and ambiguity detection for tasks.
  • Isolated mutable task and processor invocation inputs using fresh metadata and context snapshots.
  • Split universal and provider-specific task discovery so universal tasks are scanned only once.
  • Added process-local caching for provider, processor, and task discovery, including centralized cache invalidation.
  • Tightened GitHub REST task typing with protocol-based client abstractions and safer response normalization.
  • Added ty configuration for optional SDK imports and structurally typed test doubles.
  • Updated README guidance, runtime-contract documentation, schemas, processors, CLI behavior, and tests for the revised contracts.

Performance

Warm component-listing calls improve from roughly:

  • Providers: 1.8 ms0.0003 ms
  • Processors: 1.8 ms0.0007 ms
  • Tasks: 1.9 ms0.009 ms

Breaking changes

  • ConfigBranch and branch-specific result handling have been removed.
  • Result payloads now consistently use target and targets.
  • Provider implementations must support the expanded provider contract.
  • resolve_execution_targets now accepts provider preparation data.
  • Task resolution requires an explicit provider name.
  • Task and processor run() functions must use supported keyword-only parameters and provide documentation compatible with detailed CLI listings.
  • AWS-specific runtime modules now live under anvil.providers.aws.
  • Provider-specific target constraints are validated at runtime by the provider rather than encoded in the shared target schema.

Checklist

  • Python format, lint, and tests (ruff and pytest) were successful.
  • Pre-commit hooks passed locally.
  • Documentation updated if needed.
  • Unit tests added or updated.

Shift target mode/option/filter validation out of shared descriptors into provider implementations, and extend the provider contract with `resolve_target_filters` and `prepare_target` for provider-owned preflight state and scheduling keys.

This also unifies runner auth/preparation/execution flow around provider APIs, migrates AWS account/auth/session modules under `providers/aws`, and updates loaders to use shared component descriptors.

Results were enriched with provider/entity metadata and task action output, and schemas/tests were updated to reflect provider-owned target semantics.
- Extract `validate_keyword_only_invocation` into `_components.py` and reuse it for both task and processor signature validation, replacing duplicated inspection logic

- Replace `task_validation_errors(resolved)` with `task_validation_errors(descriptors)` so validation loads callables from descriptors directly; add `task_catalog_ambiguity_errors` for provider-scoped duplicate detection

- Split `_provider_task_discovery` into `_universal_task_catalog` and `_provider_specific_task_catalog` caches so universal tasks are discovered once across all providers

- `ProcessorRunContext` now snapshots mutable inputs in `__post_init__`, derives `target_result` and `target_result_path` as properties, and validates target-selection invariants

- `TaskCallContext.to_kwargs()` returns a fresh metadata copy; add `keyword_names()` classmethod

- `run_processors` passes a `replace(context)` snapshot and a fresh metadata dict to each processor invocation

- Remove `ConfigBranch` dependency from `ProcessorRunContext`, `html_report`, `sarif_report`, and related call sites

- Drop `kind` field from `PackageComponentSource`; add `provider` parameter to `source_from_entry_point`

- Add docstring validation for processors and expand test coverage for isolation, ambiguity, and context invariants
Simplifies the config and execution model to schema v2 `targets` only by removing `ConfigBranch` from descriptors, results, runner, CLI, providers, and validators.

Result payloads now consistently use `target`/`targets`, branch-specific guards and label mapping were removed, and task execution now calls `task.run(**context.to_kwargs())` directly (deleting the task invocation shim).

The provider contract was tightened to require a `preparation` parameter on `resolve_execution_targets`, and tests were updated accordingly (including renaming org-validation tests to target-validation).
Allow `entity_metadata` in result field selection so result queries can include that data.

Also align target validation messaging and tests with the newer entity-region terminology, and clean up the validate command test stub to match the current provider interface.
Adds `tool.ty` configuration to support optional SDK imports and to relax strict type rules in tests, then updates GitHub provider/task code with Protocol-based client/requester typing and safer mapping normalization for REST results. Also improves local typing in benchmark/test helpers and renames the auth test file to remove the space in its filename.
- Cached completed provider and processor catalogs with lru_cache(maxsize=1).

- Added centralized cache-clearing functions that invalidate both cache layers.

- Updated plugin/import-safety tests to clear snapshots explicitly.

-Added five regression tests covering single scans, refresh after clearing, and repeated task listing.

Measured warm-call improvement:
Provider listing: ~1.8 ms → ~0.0003 ms
Processor listing: ~1.8 ms → ~0.0007 ms
Task listing: ~1.9 ms → ~0.009 ms
@JSChronicles
JSChronicles merged commit 7d191be into main Jul 27, 2026
8 checks passed
@JSChronicles
JSChronicles deleted the chore/legacy_cleanup branch July 27, 2026 04:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant