GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(core): isolate declared gathered gates by location · developing-today-forks/opencode@080b96f

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • packages/core
    • src
      • model-route.ts
    • test
      • model-routes-wall-scope.test.ts
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎packages/core/src/model-route.ts‎

Copy file name to clipboardExpand all lines: packages/core/src/model-route.ts
+13-9Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1745,6 +1745,11 @@ export const plantGatheredNearEmptyWall = (
17451745
* reporting cannot wall a provider forever. */
17461746
const gatheredProviderQuota = new Map<string, QuotaGateState>()
17471747

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+
17481753
/** Feeds one target's gathered reading into the provider gate when the reading
17491754
* is the provider-wide shape (fork #2479): exactly one entry for the provider
17501755
* and no per-model reading for this target — the shape `gatheredQuotaWall`'s
@@ -1834,8 +1839,8 @@ export const observeGatheredProviderWall = (
18341839
stale: false,
18351840
}
18361841
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 })
18391844
if (!previous?.gated)
18401845
logHealth(
18411846
target,
@@ -1872,9 +1877,9 @@ export const observeGatheredProviderWall = (
18721877
observedAt: entry.measuredAt,
18731878
stale: false,
18741879
}
1875-
const previous = gatheredProviderQuota.get(target.providerID)
1880+
const previous = gatheredProviderQuota.get(gatheredProviderKey(target, location))
18761881
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 })
18781883
if (!previous?.gated)
18791884
logHealth(
18801885
target,
@@ -1888,7 +1893,7 @@ export const observeGatheredProviderWall = (
18881893
// a percent-less window is missing evidence, not headroom (the plant's own
18891894
// lift rule, at provider scope).
18901895
if (!complete || !previous) return false
1891-
gatheredProviderQuota.delete(target.providerID)
1896+
gatheredProviderQuota.delete(gatheredProviderKey(target, location))
18921897
if (previous.gated) logHealth(target, "quota-readmitted", `provider:${target.providerID} (gathered)`)
18931898
return true
18941899
}
@@ -3672,16 +3677,15 @@ export const providerQuotaBlocked = (
36723677
// Sibling-evidence narrowing (code#13693 Slice F): a target serving after
36733678
// the fed snapshot was observed is not blocked by the provider-scope fed
36743679
// 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
36773681
}
36783682
// The gathered snapshot's provider-wide wall (fork #2479): a provider no
36793683
// plan-derived feed carries can still stand walled on the gatherer's own
36803684
// reading. Judged with the same known-full rule, and with staleness
36813685
// recomputed from the reading's own observation time — the root-start
36823686
// gate's discipline — so the record lapses when the gatherer stops
36833687
// 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))
36853689
if (gathered) {
36863690
if (
36873691
QuotaSnapshot.isKnownFull(
@@ -3777,7 +3781,7 @@ export const providerRootStartBlocked = (
37773781
// session waves kept dealing walled legs of this shape as last resorts.
37783782
const gathered = wallScope(target.providerID, location) === "per-model"
37793783
? undefined
3780-
: gatheredProviderQuota.get(target.providerID)
3784+
: gatheredProviderQuota.get(gatheredProviderKey(target, location))
37813785
if (gathered && QuotaSnapshot.blocksRootStart(judgedSnapshot(gathered.snapshot, now), now, gate.rootStartMaxPct))
37823786
return { until: gathered.snapshot.resetAt }
37833787
return undefined
Collapse file

‎packages/core/test/model-routes-wall-scope.test.ts‎

Copy file name to clipboardExpand all lines: packages/core/test/model-routes-wall-scope.test.ts
+24Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,30 @@ describe("declared wall scope (code#13790)", () => {
6363
}
6464
})
6565

66+
test("promoted model evidence stays local and disappears when its declaration is removed", () => {
67+
ModelRoute.resetHealth()
68+
const entries = [document("provider")]
69+
const off = ModelRoute.onWallScope((id) => ConfigModelRoutesPlugin.configuredWallScope(entries, id), "/scope")
70+
const leaf = ModelRoute.ref({ providerID: "scoped", model: "full" })
71+
const now = 910_000_000
72+
const resetAt = now + 86_400_000
73+
const readings = [{ providerID: "scoped", measuredAt: now, windows: [], models: {
74+
full: [{ name: "weekly", usedPercent: 100, resetAt, measuredAt: now }],
75+
} }]
76+
try {
77+
expect(ModelRoute.observeGatheredProviderWall(leaf, readings, now, "/scope")).toBe(true)
78+
expect(ModelRoute.providerQuotaBlocked(leaf, now + 1, "/scope")).toEqual({ until: resetAt })
79+
expect(ModelRoute.providerQuotaBlocked(leaf, now + 1, "/other")).toBeUndefined()
80+
expect(ModelRoute.providerRootStartBlocked(leaf, now + 1, "/other")).toBeUndefined()
81+
entries.length = 0
82+
expect(ModelRoute.providerQuotaBlocked(leaf, now + 1, "/scope")).toBeUndefined()
83+
expect(ModelRoute.providerRootStartBlocked(leaf, now + 1, "/scope")).toBeUndefined()
84+
} finally {
85+
off()
86+
ModelRoute.resetHealth()
87+
}
88+
})
89+
6690
test.each([undefined, "provider", "account"] as const)("%s scope judges model-shaped evidence", (scope) => {
6791
ModelRoute.resetHealth()
6892
const off = ModelRoute.onWallScope((id) => ConfigModelRoutesPlugin.configuredWallScope([document(scope)], id), "/scope")

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.