@@ -1745,6 +1745,11 @@ export const plantGatheredNearEmptyWall = ( |
1745 | 1745 | * reporting cannot wall a provider forever. */ |
1746 | 1746 | const gatheredProviderQuota = new Map<string, QuotaGateState>() |
1747 | 1747 |
|
| 1748 | +// Promoting model-shaped evidence is derived from a Location's declaration. |
| 1749 | +// Neither another Location nor removal of that declaration may inherit it. |
| 1750 | +const gatheredProviderKey = (target: Model.Ref, location?: string) => |
| 1751 | + JSON.stringify([location ?? "", wallScope(target.providerID, location), target.providerID]) |
| 1752 | + |
1748 | 1753 | /** Feeds one target's gathered reading into the provider gate when the reading |
1749 | 1754 | * is the provider-wide shape (fork #2479): exactly one entry for the provider |
1750 | 1755 | * and no per-model reading for this target — the shape `gatheredQuotaWall`'s |
@@ -1834,8 +1839,8 @@ export const observeGatheredProviderWall = ( |
1834 | 1839 | stale: false, |
1835 | 1840 | } |
1836 | 1841 | if (!QuotaSnapshot.isKnownFull(snapshot, now, threshold)) return false |
1837 | | - const previous = gatheredProviderQuota.get(target.providerID) |
1838 | | - gatheredProviderQuota.set(target.providerID, { snapshot, target, gated: true }) |
| 1842 | + const previous = gatheredProviderQuota.get(gatheredProviderKey(target, location)) |
| 1843 | + gatheredProviderQuota.set(gatheredProviderKey(target, location), { snapshot, target, gated: true }) |
1839 | 1844 | if (!previous?.gated) |
1840 | 1845 | logHealth( |
1841 | 1846 | target, |
@@ -1872,9 +1877,9 @@ export const observeGatheredProviderWall = ( |
1872 | 1877 | observedAt: entry.measuredAt, |
1873 | 1878 | stale: false, |
1874 | 1879 | } |
1875 | | - const previous = gatheredProviderQuota.get(target.providerID) |
| 1880 | + const previous = gatheredProviderQuota.get(gatheredProviderKey(target, location)) |
1876 | 1881 | if (QuotaSnapshot.isKnownFull(snapshot, now, currentConstants(location).quotaGate.balanceDeadThreshold)) { |
1877 | | - gatheredProviderQuota.set(target.providerID, { snapshot, target, gated: true }) |
| 1882 | + gatheredProviderQuota.set(gatheredProviderKey(target, location), { snapshot, target, gated: true }) |
1878 | 1883 | if (!previous?.gated) |
1879 | 1884 | logHealth( |
1880 | 1885 | target, |
@@ -1888,7 +1893,7 @@ export const observeGatheredProviderWall = ( |
1888 | 1893 | // a percent-less window is missing evidence, not headroom (the plant's own |
1889 | 1894 | // lift rule, at provider scope). |
1890 | 1895 | if (!complete || !previous) return false |
1891 | | - gatheredProviderQuota.delete(target.providerID) |
| 1896 | + gatheredProviderQuota.delete(gatheredProviderKey(target, location)) |
1892 | 1897 | if (previous.gated) logHealth(target, "quota-readmitted", `provider:${target.providerID} (gathered)`) |
1893 | 1898 | return true |
1894 | 1899 | } |
@@ -3672,16 +3677,15 @@ export const providerQuotaBlocked = ( |
3672 | 3677 | // Sibling-evidence narrowing (code#13693 Slice F): a target serving after |
3673 | 3678 | // the fed snapshot was observed is not blocked by the provider-scope fed |
3674 | 3679 | // gate; the gathered gate below is still judged on its own evidence time. |
3675 | | - if (scope === "provider" || scope === "account" || !state || !providerScopeNarrowed(target, state.snapshot.observedAt)) |
3676 | | - return fed |
| 3680 | + if (!state || !providerScopeNarrowed(target, state.snapshot.observedAt)) return fed |
3677 | 3681 | } |
3678 | 3682 | // The gathered snapshot's provider-wide wall (fork #2479): a provider no |
3679 | 3683 | // plan-derived feed carries can still stand walled on the gatherer's own |
3680 | 3684 | // reading. Judged with the same known-full rule, and with staleness |
3681 | 3685 | // recomputed from the reading's own observation time — the root-start |
3682 | 3686 | // gate's discipline — so the record lapses when the gatherer stops |
3683 | 3687 | // reporting instead of holding on a derivation-time freshness stamp. |
3684 | | - const gathered = scope === "per-model" ? undefined : gatheredProviderQuota.get(target.providerID) |
| 3688 | + const gathered = scope === "per-model" ? undefined : gatheredProviderQuota.get(gatheredProviderKey(target, location)) |
3685 | 3689 | if (gathered) { |
3686 | 3690 | if ( |
3687 | 3691 | QuotaSnapshot.isKnownFull( |
@@ -3777,7 +3781,7 @@ export const providerRootStartBlocked = ( |
3777 | 3781 | // session waves kept dealing walled legs of this shape as last resorts. |
3778 | 3782 | const gathered = wallScope(target.providerID, location) === "per-model" |
3779 | 3783 | ? undefined |
3780 | | - : gatheredProviderQuota.get(target.providerID) |
| 3784 | + : gatheredProviderQuota.get(gatheredProviderKey(target, location)) |
3781 | 3785 | if (gathered && QuotaSnapshot.blocksRootStart(judgedSnapshot(gathered.snapshot, now), now, gate.rootStartMaxPct)) |
3782 | 3786 | return { until: gathered.snapshot.resetAt } |
3783 | 3787 | return undefined |
|