Skip to content

refactor: unify per-key reporter ids behind OperationId#6025

Merged
baszalmstra merged 2 commits intoprefix-dev:mainfrom
baszalmstra:refactor/operation-id-reporters
May 6, 2026
Merged

refactor: unify per-key reporter ids behind OperationId#6025
baszalmstra merged 2 commits intoprefix-dev:mainfrom
baszalmstra:refactor/operation-id-reporters

Conversation

@baszalmstra
Copy link
Copy Markdown
Contributor

@baszalmstra baszalmstra commented May 6, 2026

Description

Current the Reporter trait creates a coupling between computations in the command dispatcher crate. It bundles different reports and uses ReporterContext which also couples different computations together.

Adds a pixi_compute_reporters crate with OperationId, OperationRegistry, a task-local for the active id, and a SpawnHook that propagates it across compute spawns. The registry records each id's parent at allocation time, so reporter implementations walk ancestry via parent_of() / ancestors() without the dispatcher exposing a context type.

Replaces the Reporter trait + 8 per-key id types with a single OperationId. Per-key reporter traits in pixi_command_dispatcher now return OperationId; on_started / on_finished take OperationId.

Groundwork for splitting pixi_command_dispatcher into per-key crates: each per-key crate now needs only pixi_compute_engine and pixi_compute_reporters for parent tracking, not the dispatcher.

Folded in: drop ClearReporter (CLI sites hold their own Arc<TopLevelProgress> and call on_clear() directly); fold the rattler install factory into PixiInstallReporter and InstantiateBackendReporter; push TopLevelProgress construction up to CLI entry points (Workspace::update_lock_file and get_update_lock_file_and_prefix(es) take Option<Arc<TopLevelProgress>>); pixi_global::Project holds its progress in a paired OnceCell.

How Has This Been Tested?

  • cargo test -p pixi_command_dispatcher --test integration: 36 passed.
  • simple_test with slow_integration_tests and a fresh PIXI_CACHE_DIR: produces the expected nested event tree (including the conda solve nested under Instantiate backend). Snapshot regenerated for the new shared id numbering.

AI Disclosure

  • This PR contains AI-generated content.
    • I have tested any AI-generated content in my PR.
    • I take responsibility for any AI-generated content in my PR.

Tools: Claude Code

Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added sufficient tests to cover my changes.

@baszalmstra baszalmstra changed the title refactor(reporters): unify per-key reporter ids behind OperationId refactor: unify per-key reporter ids behind OperationId May 6, 2026
@baszalmstra baszalmstra force-pushed the refactor/operation-id-reporters branch 4 times, most recently from 758a067 to dd1aeb1 Compare May 6, 2026 17:31
Generic OperationId + OperationRegistry + task-local + spawn hook
shared across pixi reporter implementations. The registry records
each id's parent (read from the task-local at allocation time) so
reporter implementations can walk ancestry via parent_of() /
ancestors() without exposing a context type.
Replace the umbrella Reporter trait + 8 per-key id types with a single
OperationId allocated by reporter implementations from a shared
OperationRegistry. The registry records each id's parent (read from a
task-local at allocation time) so reporter implementations can walk
ancestry via parent_of() / ancestors() without the dispatcher exposing
any context type.

The new pixi_compute_reporters crate hosts OperationId, OperationRegistry,
the task-local + scope helper, and the SpawnHook that propagates the
active id across compute spawns. Per-key reporter traits in
pixi_command_dispatcher now return OperationId; their on_started /
on_finished take OperationId.

Other changes folded in:
- Drop the umbrella Reporter trait; per-key reporters are registered
  separately on the dispatcher builder.
- Drop ClearReporter; CLI sites hold their own Arc<TopLevelProgress> and
  call on_clear() directly.
- Fold the rattler install reporter factory into PixiInstallReporter +
  InstantiateBackendReporter (each gains create_install_reporter()).
- Push TopLevelProgress construction up to CLI entry points;
  Workspace::update_lock_file and get_update_lock_file_and_prefix(es)
  take Option<Arc<TopLevelProgress>>.
- pixi_global::Project carries its own progress in a paired OnceCell.
- Test EventReporter allocates via the registry; ContextSnapshot is
  gone, EventTree walks parents through registry.parent_of().
- Regenerate simple_test snapshot for the new (shared) id numbering.
@baszalmstra baszalmstra force-pushed the refactor/operation-id-reporters branch from dd1aeb1 to d06b2e9 Compare May 6, 2026 17:50
@baszalmstra baszalmstra requested a review from hunger May 6, 2026 18:09
Copy link
Copy Markdown
Contributor

@hunger hunger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I want this.

@baszalmstra baszalmstra merged commit 82f1672 into prefix-dev:main May 6, 2026
38 checks passed
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