Skip to content

fix(model): count only providers holding a Public provide key#5

Open
Ryanmello07 wants to merge 2 commits into
beta/self-contained-envfrom
feat/provider-count-provide-mode
Open

fix(model): count only providers holding a Public provide key#5
Ryanmello07 wants to merge 2 commits into
beta/self-contained-envfrom
feat/provider-count-provide-mode

Conversation

@Ryanmello07

Copy link
Copy Markdown
Owner

Filters provider counting to clients holding provide_mode=3. Observed on beta: 39 US providers advertised, 2 reachable.

Both UpdateClientLocations and UpdateClientScores are filtered, since GetProviderLocations also gates on loadLocationStables (populated by UpdateClientScores) — filtering only the first leaves the symptom in place.

Two existing beta tests (TestUpdateClientLocationsCountsClientsWithoutReliabilityScores, TestUpdateClientScoresCountsClientsWithoutReliabilityScores) connected a client with no provide key at all; they now set a Public key explicitly, since the reliability-score join is what they are testing.

🤖 Generated with Claude Code

https://claude.ai/code/session_01QtgqtCmKJRXdsQ5ktiqwkg

Ryanmello07 and others added 2 commits July 26, 2026 06:26
A provider without a provide_mode=3 key cannot accept a contract from a
client outside its own network, so counting it advertises supply nobody
can reach. On beta this reported 39 US providers when 2 were reachable.

Filters both UpdateClientLocations and UpdateClientScores: GetProviderLocations
gates on loadLocationStables as well, so fixing only the first leaves the
symptom in place.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QtgqtCmKJRXdsQ5ktiqwkg
…e score filter

Review follow-ups to "count only providers holding a Public provide key".

1. The location *group* source query in UpdateClientScores was still bare
   `connected = true AND valid = true`. It fills locationGroupClientScores ->
   the clientScoreLocationGroup* redis keys -> loadClientScores ->
   FindProviders2 whenever a spec carries a LocationGroupId, so a user
   selecting a promoted group (e.g. "Strong Privacy Laws") still received
   providers that cannot accept their contract, and CreateContract rejected
   them with NoPermission. Same EXISTS predicate as the other two queries.

2. The UpdateClientScores filter had no test of its own -- every existing
   test that reaches it gives all its clients a Public key, so deleting the
   clause broke nothing. Two new tests set up connected+valid providers that
   are identical except for the Public provide key:
   - TestUpdateClientScoresCountsOnlyPublicProviders covers the per-location
     query through loadLocationStables (the gate GetProviderLocations uses)
     and loadClientScores.
   - TestUpdateClientScoresGroupCountsOnlyPublicProviders covers the group
     query through the group cache.
   Both were verified to fail with their respective EXISTS clause removed.

3. The SQL comments claimed the destination "must hold a key for exactly
   that mode". That is not an invariant the code holds:
   resolveNonCompanionProvideMode lets a Stream-only destination settle a
   cross-network contract as a companion stream. Reworded to state the
   intent -- a companion-only destination is a return path, not general
   provider supply, so excluding it from provider counts is deliberate.
   No SQL change.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QtgqtCmKJRXdsQ5ktiqwkg
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.

1 participant