SPEC-084-A: Demand-Driven Sourcing Dedup

Implements ADR-084. Amends SPEC-067-A / the ADR-069 launcher arm. Mirrors the dispatch dedup of SPEC-064-A / SPEC-071-A.

What changed

swarm/sourcing.sh’s --if-pool-empty gate now also skips when a chore(sourcing) PR is already open, so concurrent sourcers (or one sourcer across UNSORRY_SOURCING_WAIT ticks before its PR merges) no longer both open a replenishment PR.

New functions (swarm/sourcing.sh)

Gate wiring

In run_cycle’s per-cycle --if-pool-empty block: compute open_n; if open_n == 0, set pr_open=$(sourcing_pr_in_flight) (else leave 0, no gh call); then case "$(sourcing_gate_decision "$open_n" "$pr_open")"have-work/in-flight log + break; source logs and proceeds to the sourcing cycle.

Unchanged

Acceptance criteria / tests

swarm/sourcing.sh --self-test (hermetic) — test_sourcing_gate_decision asserts:

(sourcing_pr_in_flight is the thin network wrapper; its best-effort degradation is by construction — no network in the self-test.)

Out of scope