design-15 S7a: read-only sing-box stats collector (ADR-004)#6
Merged
Conversation
ADR-004 slice: the new singbox-stats collector queries the core's experimental V2Ray Stats API over loopback gRPC (LATTICE_SINGBOX_STATS_API, off by default) with substring patterns and never resets counters — the server keeps monotonic successive-snapshot diffing. stats.proto is the upstream definition byte-identical except go_package, with generation pinned to development time and a regen note in singboxstats/README.md. Counter names flow through unchanged (design-15 §5 u_<hash> users); the server reverses them into (user, line) pairs. Collector config joins the single-source exclusivity validation and the collector-health error reporting exactly like the xray-cli source.
Report the configured stats endpoint in runtime telemetry, pin the vendored protocol to a verified upstream commit, and publish this slice only as an alpha artifact built against the SDK declared in go.mod. Constraint: The sing-box experimental API is loopback-only and its wire contract is vendored. Rejected: Test only against generated local stubs | that cannot detect drift from upstream sing-box. Confidence: high Scope-risk: moderate Reversibility: clean Directive: Run check-singbox-stats-proto.sh before changing the vendored proto pin. Tested: go test ./...; go vet ./...; release workflow checker; upstream proto byte comparison; proxyusage race tests Not-tested: Live gRPC query against HK sing-box, deferred to canary
lr00rl
force-pushed
the
feat/design-15-singbox-stats
branch
from
July 22, 2026 13:03
aee9c33 to
d75b6ca
Compare
lr00rl
marked this pull request as ready for review
July 22, 2026 13:27
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
singbox-statscollector: read-onlyQueryStats(substringuser>>>, neverreset) against the core's experimental V2Ray Stats API over loopback gRPC (LATTICE_SINGBOX_STATS_API, off by default). Server keeps monotonic diffing exactly like the xray-cli source.internal/proxyusage/singboxstats/stats.protois the upstream definition (byte-identical service/messages, onlygo_packageadjusted) + generated code, regen pinned to development time (README with the one-liner). New deps:google.golang.org/grpc+protobuf(pure Go, per ADR-004, design-15: line_uuid, per-line users, chain recognition, Sub-Store integration lattice#2).u_<hash>) for server-side reversal into (user, line).Verification
gofmt/go vetclean;go test ./...all ok (-count=1)Refs LatticeNet/lattice#2 (ADR-004), #5.