Skip to content

design-15: user names + v2 sidecar regeneration (sb meta) - #2

Merged
lr00rl merged 3 commits into
mainfrom
feat/design-15-user-meta
Jul 22, 2026
Merged

design-15: user names + v2 sidecar regeneration (sb meta)#2
lr00rl merged 3 commits into
mainfrom
feat/design-15-user-meta

Conversation

@lr00rl

@lr00rl lr00rl commented Jul 20, 2026

Copy link
Copy Markdown
Owner

Summary

design-15 D3 companion slice for the Lattice per-line user write path (LatticeNet/lattice-server#14):

  • sb user add|del: every protocol's derived user object now carries name (the design-15 §5 u_<sha256(user|line_uuid)[:16]>) — the single join key for sing-box auth metadata, auth_user route rules, and user>>><name>>>>traffic>>> stats. Matching also keys on name, so credential rotation stays idempotent.
  • sb meta: regenerates /etc/sing-box/lattice-metadata.json in lattice.singbox-metadata.v2 shape — preserves existing v2 line_uuid / v1 lines{}.line_id per conf file (v1 id adopted as v2 line_uuid), mints fresh uuids only for identity-less lines, preserves declared chain blocks, keeps v1 .node/.lines keys for older readers, and fails loud when node id is unknown. The Lattice server remains the authoritative writer; this is the on-box fallback/repair path.
  • help documents user/meta.

Verification

  • tests/design-15-user-meta.sh (new, the repo's first harness): 22 assertions, all pass locally (bash extraction harness — user-obj name per protocol, name-keyed match, fresh/upgrade/idempotent/chain-preserving meta regeneration, missing-node-id failure)
  • bash -n clean on core.sh/help.sh

Stacked on #1. Refs LatticeNet/lattice#2, LatticeNet/lattice-server#14.

lr00rl added 3 commits July 22, 2026 06:06
sb user add/del payloads now carry a per-user name (the design-15 §5
derived u_<hash>) in every protocol's user object, and add/del matching
also keys on name, so renamed credentials stay idempotent. name is the
join key sing-box uses for auth metadata, auth_user route rules, and
per-user stats counters.

New `sb meta` command regenerates the sidecar in
lattice.singbox-metadata.v2 shape: existing v2 line_uuid or v1
lines{}.line_id identity is preserved per conf file (v1 line_id is
adopted as the v2 line_uuid), fresh uuids only for lines with no
identity; the v1 .node/.lines keys are kept alongside so pre-v2 readers
keep working. It is the on-box fallback writer — the Lattice server
stays the authoritative one.

tests/design-15-user-meta.sh is the repo's first test harness: it
extracts the functions under test and asserts user-obj name handling,
name-keyed matching, meta regeneration, v1 upgrade, idempotent rerun,
chain preservation, and the missing-node-id failure (22 assertions).
design-15 §8 / ADR-004: toggles experimental.v2ray_api in config.json
through the same atomic jq + check + rollback pattern as sb user,
restricted to loopback listens (a stats API must never bind a routable
address) with port validation, then restarts the core. This is what the
agent's singbox-stats collector dials (LATTICE_SINGBOX_STATS_API).
Make the sb Design 15 commands resolve configuration files and users by exact identity, reject ambiguous legacy matches and traversal, preserve validated sidecar extensions, enforce literal loopback stats listeners, and surface restart failures instead of reporting partial success.

Constraint: Existing unambiguous legacy user selectors remain supported during migration.

Rejected: Match name or any credential field | shared credentials can delete unrelated users.

Confidence: high

Scope-risk: moderate

Reversibility: clean

Directive: Never turn restart failure or invalid sidecar input into ok=true.

Tested: bash -n src/core.sh tests/design-15-user-meta.sh; design-15-user-meta.sh 41/41; git diff --check

Not-tested: Full 233boy installer harness on HK, deferred to canary
@lr00rl
lr00rl force-pushed the feat/design-15-user-meta branch from 04f3b1c to ebfcdbc Compare July 22, 2026 13:07
@lr00rl
lr00rl changed the base branch from fix/lattice-metadata-sidecar to main July 22, 2026 13:07
@lr00rl
lr00rl marked this pull request as ready for review July 22, 2026 13:08
@lr00rl
lr00rl merged commit 2a144c0 into main 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