Skip to content

[P1][Planning] Use ContextGraph and Map Service views for conflict-aware fan-out #687

Description

@wesleysimplicio

Objective

Use Mapper ContextGraph evidence and the existing Map Service (#497) to schedule batch tasks safely: independent tasks may fan out, overlapping tasks are ordered or isolated, and worktrees consume one canonical map plus incremental overlays.

This issue is a runner/client integration slice. It must reuse #497 and its protocol rather than rebuilding the Map Service.

Implementation steps

  1. Add a client adapter that requests a canonical/effective map view from the existing Map Service and records explicit fallback when unavailable.
  2. Resolve each task envelope to files, symbols, tests and graph neighborhoods.
  3. Derive a deterministic task conflict graph from overlapping mutation targets, shared symbols, reverse dependencies and test/resource contention.
  4. Separate hard dependencies from soft conflict risk with reason codes and confidence.
  5. Build deterministic execution waves; cycles and ambiguous high-risk conflicts fail closed.
  6. Allocate worktrees only after a compatible map view and mutation authority are bound.
  7. Each worktree receives the canonical snapshot handle plus its own dirty overlay; no independent full remap by default.
  8. Invalidate/replan affected nodes after overlay/source drift without restarting safe independent tasks.
  9. Release/pin map handles correctly through success, failure, cancellation and crash recovery.
  10. Record cache hit, overlay size, graph reason codes, wave selection and fallback/degraded state.
  11. Keep a standalone fallback for environments without Hub/Map Service, marked unsupported or degraded honestly.
  12. Benchmark N tasks/N worktrees against independent full remaps using the same workload.

Acceptance criteria

  • Disjoint task graph nodes execute in the same wave when capacity permits.
  • Tasks sharing a mutation target never execute concurrently.
  • Reverse-dependent/high-risk graph conflicts are ordered or explicitly blocked with reason codes.
  • Every worktree view binds canonical snapshot + overlay + config/schema identity.
  • Equivalent requests reuse the same canonical snapshot handle.
  • Source/overlay drift invalidates only affected tasks where safe.
  • Crash/cancel releases leases and map handles without deleting a snapshot still in use.
  • Map Service unavailable follows the documented standalone fallback and never pretends a cache hit.
  • Unit, integration, system, crash/recovery and concurrency tests pass.
  • Coverage for touched code meets the repository gate.
  • Benchmark reports wall time, CPU, RSS, I/O, cache hits and remap count; unobservable values are null with reason.
  • No scheduler/process ownership is duplicated outside the Loop Hub/Runtime boundaries.

Dependencies

Out of scope

  • Reimplementing the Mapper canonical store.
  • Moving process ownership from Runtime to Loop.
  • Treating heuristic graph edges as proof without confidence/reason metadata.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    Status
    Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions