Skip to content

design-15 S3: sing-box sidecar annotation + bounded inspect enrichment#5

Merged
lr00rl merged 4 commits into
mainfrom
feat/singbox-sidecar-line-uuid
Jul 22, 2026
Merged

design-15 S3: sing-box sidecar annotation + bounded inspect enrichment#5
lr00rl merged 4 commits into
mainfrom
feat/singbox-sidecar-line-uuid

Conversation

@lr00rl

@lr00rl lr00rl commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

Summary

design-15 S3 agent slice:

  • Sidecar annotation: reads /etc/sing-box/lattice-metadata.json (env override LATTICE_SINGBOX_META), joins by inbound tag, fills LineUUID + DownstreamLineUUID on every reported SingBoxNode. Missing file / corrupt JSON / legacy v1 flat sidecar all degrade quietly — discovery never fails on a read-only annotation. Applies to both the primary list path and the runtime-config fallback.
  • Bounded inspect enrichment: closes the known primary-path gap — per line, sb --json inspect <name> backfills outbound tag/type, line_id, node_uuid, and user roster (cap 64 calls/cycle, per-call timeout, first-call-failure detects older sb and stops). Fill-only-empty; config join still resolves outbound server/port.
  • lattice-agent flag/env: -singbox-meta / LATTICE_SINGBOX_META; README updated.
  • Pins lattice-sdk@60c69bd (draft PR lattice-sdk#7).

Verification

  • gofmt/go vet clean; go test ./... all ok
  • New tests cover: sidecar missing/corrupt/v1/v2 (contract fixtures in testdata), tag join hit/miss, inspect mapping, inspect-failure fallback, call cap

Refs LatticeNet/lattice#2, LatticeNet/lattice-sdk#7, LatticeNet/lattice-server#13.

Discovery now annotates each reported line with the control-plane
line_uuid and declared downstream_line_uuid from the v2 sidecar
(/etc/sing-box/lattice-metadata.json, LATTICE_SINGBOX_META override),
joined by inbound tag; missing/corrupt/legacy-v1 sidecars degrade
quietly and never fail discovery.

The primary list path is also enriched per line via bounded
`sb --json inspect <name>` calls (cap 64, per-call timeout,
first-call-failure detection for older sb builds), filling outbound
tag/type, line_id, node_uuid, and the user roster the plain list omits.
Fill-only-empty in both enrichers; existing config join keeps resolving
outbound server/port.

Pins lattice-sdk @60c69bd (draft PR lattice-sdk#7).
lr00rl added 3 commits July 22, 2026 04:59
The workspace checkout forced SDK main over the pseudo-version pinned for sidecar line identity, producing compile failures unrelated to the branch. Letting Go resolve go.mod keeps the tested dependency identical to the shipped one.

Constraint: The sidecar branch consumes an SDK commit not yet present on SDK main

Rejected: Always checkout SDK main | masks the pinned dependency and breaks coordinated prerelease work

Confidence: high

Scope-risk: narrow

Directive: Keep agent CI aligned with go.mod unless an explicit integration matrix is introduced

Tested: GOWORK=off go mod verify; go vet ./...; go test -race -cover ./...; YAML parse; git diff --check
The module-root gosec invocation surfaced a different legacy finding set even though the SDK resolution change was the only intended behavior. Restore the previously green repository-prefixed scan target.

Constraint: The sidecar PR must fix SDK selection without redefining the existing gosec baseline

Confidence: high

Scope-risk: narrow

Tested: Workflow diff review; prior successful main CI gosec evidence
Treat the Design 15 sidecar as an atomic identity document: distinguish absence from read failure, reject invalid v2 annotations as a unit, and cap aggregate inspect latency with bounded concurrency. Build CI and prerelease artifacts against the exact SDK pinned in go.mod.

Constraint: Discovery must not delay the task loop beyond a short aggregate budget.

Rejected: Serial per-line eight-second inspection | it can starve task polling for minutes.

Confidence: high

Scope-risk: moderate

Reversibility: clean

Directive: Keep invalid sidecars fail-closed and release builds on the declared SDK pin.

Tested: go test ./...; go vet ./...; release workflow checker; targeted singboxdiscover race tests

Not-tested: HK filesystem permission failure, covered by unit seams and deferred to canary
@lr00rl
lr00rl marked this pull request as ready for review July 22, 2026 12:59
@lr00rl
lr00rl merged commit 22528d9 into main Jul 22, 2026
1 check passed
@lr00rl
lr00rl deleted the feat/singbox-sidecar-line-uuid branch July 22, 2026 12:59
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