Versionless devshard stats endpoints#1453
Open
a-kuprin wants to merge 2 commits into
Open
Conversation
Public GET diffs/stats no longer CreateSession; only owner-signed chat binds. Join proxy rewrites legacy versioned obs URLs internally; versiond serves versionless paths via PG sessions.version (fan-out fallback).
O(1) stats detail + negative cache, nginx obs rate limits, numeric primary version sort, single GetEscrow on owner bind, healthz not rewritten to versiond, and visible PG lookup fan-out errors.
x0152
approved these changes
Jul 17, 2026
x0152
left a comment
Collaborator
There was a problem hiding this comment.
non-blocking: lookupBoundVersionActiveSession appears to be intended to return only active sessions, but it currently does not
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
POST …/chat/completions./devshard/sessions|stats|metrics), with join-proxy internal rewrites so legacy/devshard/{version}/…scrapers keep working unchanged.sessions.versionwhen available (fan-out fallback for SQLite / PG errors).devshard_obsrate limits, numeric primary-version sort, visible PG-lookup fan-out errors, clarified/healthzvs/metrics.Motivation
Escrow create is version-agnostic. Version was bound on first
CreateSession, and observability GETs (diffs/mempool/signatures/ stats detail) went throughgetOrCreate. Dashboards that hardcode/devshard/v2/sessions/{id}/diffscould lock an escrow tov2before the creator’s firstv3chat, after which the creator hitsErrSessionVersionConflict.Design notes
Stop the bleed (
devshardd). Split resolve paths:SessionServerExisting— recover only, neverCreateSessionBindOwnerChat— verify owner signature before bind; reuse fetched escrow for create (singleGetEscrow)Unbound obs / host protocol → 404. Chat-only bind.
Join proxy. Internal
rewrite … last(not public 308) from versioned obs URLs onto versionless paths. Protocol POSTs andpayloadsstay versioned. Public obs usesdevshard_obsrate zone (DEVSHARD_OBS_RATE_LIMIT_RPSdefault 10, burst 20); chat/gossip/payloads stay exempt.versiond + paths. Versionless obs without a version prefix. Session-scoped / stats-detail: PG lookup of
sessions.version→ correct child; unbound → 404; no PG → fan-out. Process-level/metricsand/stats/shardslist pin to newest child by numeric/dotted compare (v10>v2,v0.2.11>v0.2.9). PG lookup errors fan out with a rate-limited warn +LookupFanoutErrorscounter (not silent).Health vs metrics.
/devshard/healthzis versiond supervisor (mux)./devshard/{version}/healthzreaches that child (not rewritten)./devshard/metricspins newest child.Stats detail.
GET /stats/shards/{id}uses O(1)GetSessionMeta+ short negative cache (~10s, cap 4096); warn only on cache insert.Test plan
go test ./server/ ./cmd/devshardd/session/ ./transport/— unbound obs/gossip no bind; owner chat binds; non-owner does not; first bind singleGetEscrowgo test ./internal/proxy/(versioned) — versionless routing, numeric primary, lookup, fan-out + lookup-error countergo test . -run Versionless(devshard paths helpers)Location; unbound → 404; owner chat then binds chosen versiondevshard_obsrate limit; chat stays exempt/devshard/healthz= versiond;/devshard/{v}/healthz= childConfig / ops
PGHOST/DATABASE_URLVERSIOND_DISABLE_SESSION_LOOKUPDEVSHARD_OBS_RATE_LIMIT_RPSDEVSHARD_OBS_BURSTPreferred monitor URLs:
/devshard/sessions/{id}/diffs,/devshard/stats/shards/{id}(legacy versioned diffs/stats/metrics still work via rewrite). Child health:/devshard/{version}/healthz.