Skip to content

design-15 S7b: reverse u_name stats into (line, user) accounting - #17

Closed
lr00rl wants to merge 2 commits into
feat/design-15-substore-integrationfrom
feat/design-15-usage-reversal
Closed

design-15 S7b: reverse u_name stats into (line, user) accounting#17
lr00rl wants to merge 2 commits into
feat/design-15-substore-integrationfrom
feat/design-15-usage-reversal

Conversation

@lr00rl

@lr00rl lr00rl commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Summary

design-15 §8 server slice (pairs with lattice-node-agent#6):

  • userLineNameIndex(): recomputes the §5 on-box names for every (migrated identity × enabled binding) and maps them to (line_hash_id, proxy_user_id).
  • foldUserLineUsage(): applyProxyUsageSnapshot folds matched u_<hash> counter keys into the proxy user's UserBytes total (normal monotonic diff advances it) and into line_user_bytes line buckets (3-D usage rows). Unmatched names degrade to ignored — never fabricated zero traffic.
  • Multi-line users sum into one total while each line keeps its own bucket.

Stacked on #16.

Verification

  • gofmt/go vet clean; go test ./... all ok (server pkg 21.4s)
  • New end-to-end tests: baseline→delta advances UsedBytes exactly; u_name folded away from raw keys; line bucket persisted; unknown u_ names ignored; two-line user sums correctly

Refs LatticeNet/lattice#2, #13#16, lattice-node-agent#6.

lr00rl added 2 commits July 21, 2026 04:11
design-15 §8 server slice: applyProxyUsageSnapshot now folds on-box
u_<sha256(user|line_uuid)[:16]> counter names back into (line_hash_id,
proxy user id) rows before eligibility checks and monotonic diffing.
The per-user total advances through the existing UserBytes path, the
line granularity persists in line_user_bytes, and names that match no
(bound, migrated) pair degrade to ignored — never zero-filled.

Counters from users on multiple lines sum into one proxy-user total
while each line keeps its own bucket, so the three-dimensional usage
read model (node, line, user) lights up without a contract change.
ADR-004: the vpn-core profiles settings model gains singbox_stats_api
(saved/reported/normalized with the same host:port validation as
proxy_usage_xray_api), AgentLaunchConfig persists it (lattice-sdk
f2a9b0e), and the generated reconfigure command exports
LATTICE_SINGBOX_STATS_API.
@lr00rl

lr00rl commented Jul 22, 2026

Copy link
Copy Markdown
Contributor Author

Superseded by #20, which rebased the complete remaining Design 15 stack onto alpha/v0.2.2 and passed go test, go vet, gosec, govulncheck, formatting, and Docker contract CI before merge as 86422a1.

@lr00rl lr00rl closed this Jul 22, 2026
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