Working scratch documents for the Blueprints v1 implementation: * BLUEPRINTS-CHECKLIST.md: enumerates every spec requirement that must be true before v1 is done, so progress is auditable. * BLUEPRINTS-NOTES.md: read-only reconnaissance of the existing OSS systems that Blueprints touches (CheckTag, CLI structure, set validation, ipnlocal/prefs, tailcfg types, clientmetric). Captured before any production change to avoid re-reading the same files later. * BLUEPRINTS-FOLLOWUPS.md: deferred-to-v2 list, primed from the spec. Anything tempting that surfaces during the build gets appended here instead of expanding scope. Updates #cleanup Signed-off-by: Kabir Sikand <[email protected]>
6.0 KiB
Blueprints v1 — OSS Reconnaissance Notes (tailscale/tailscale)
Read-only snapshot of the existing system, taken on branch kabir/blueprints-v1 at HEAD 894ff5d8e (main). Working notes — not user-facing docs.
1. Tag parsing and validation
File: tailcfg/tailcfg.go:704-741
Key: CheckTag(tag string) error validates a single ACL tag. Rules today:
- Must have
tag:prefix (line 723, viastrings.CutPrefix). - Tag name after the prefix must be non-empty (line 728).
- Must start with a letter (line 730).
- Body must be alphanumerics and dashes only (lines 734-737).
- The forward slash
/is rejected by the existing character set.
Hostinfo.CheckRequestTags() (line ~749) iterates RequestTags and calls CheckTag on each.
Slot for tag:bp//<id>: narrow exception inside CheckTag — if the remainder after tag: starts with bp//, strip exactly that prefix and validate the rest as a normal tag name. This keeps the / rejection intact for every other namespace.
2. tagOwners validation
Not in OSS — corp's control/policy/policy_parse.go:674 is where tagOwners gets validated against grants. OSS only validates tag format.
No OSS-side changes needed for the tagOwners exemption.
3. CLI structure (cmd/tailscale/cli/)
cli.go:252-340—newRootCmd()wires up subcommands. NewjoinCmdregistered alongsideupCmd,setCmd,logoutCmdin theSubcommandsslice (lines 273-309).up.go:47-251—upCmd+newUpFlagSet()flag declaration. Template forjoinCmd.set.go:32-129—setCmd+newSetFlagSet().runSet():131is where blueprint-locked-field rejection slots in.logout.go:1-45—logoutCmd. Template forleaveCmdif implemented as a separate command, or extend it to detect blueprint-bound state.down.go:1-65— pattern for short verb commands.
All subcommands use *ffcli.Command with a flag set and a run function.
4. tailscale set flag validation
runSet() in set.go:131 builds a MaskedPrefs from flags, fetches current Status (line 136), then calls localClient.EditPrefs().
No existing precedent for "reject this set based on node state." The check needs to happen after the MaskedPrefs is built and before EditPrefs is called: if the locally-stored "brought up via join" bit is set AND any locked field is in the mask, return the verbatim spec error and increment blueprint_set_rejected.
5. ipn/ipnlocal/ node state and prefs
ipn/prefs.go:58-250+—Prefsstruct. New field needed:BlueprintID string(or aBlueprintBindingsub-struct) to record both the binding and the "was-this-join" bit.ipn/ipnlocal/local.go:5948—applyPrefsToHostinfoLocked(). Today:AdvertiseTags→Hostinfo.RequestTags,AdvertiseRoutes→Hostinfo.RoutableIPs. When blueprint-bound, the projected tags/routes come from the control plane via MapResponse and should NOT be written back toHostinfofrom prefs (they live inNode.BlueprintConfigalready).
6. tailcfg types
Nodetailcfg.go:348-535— addBlueprintID stringandBlueprintConfig *BlueprintConfig(new type) here per the decision to put binding on top-level fields, not inCapMap.Hostinfo:845-900+— likely no changes; blueprint binding is server-to-client, and the prefs change inPrefs.BlueprintIDis enough to let the server identify a join-mode node on registration.MapResponse:1968-2177— no new top-level field needed; everything goes onNode.NodeCapMap:2451-2463— alternate path we chose not to take.- Capability version comments
:50-188— bump for the new fields. Node.Equal():2359-2399— must includeBlueprintIDandBlueprintConfig.
7. clientmetric conventions
util/clientmetric/clientmetric.go:1-481.NewCounter(name),NewGauge(name). Globally registered, names must be unique.- Pattern: module-level
vardeclarations. Naming: package-prefixed snake_case (e.g.localbackend_metric_name).
clientmetric does NOT support labels. The spec's blueprint_join_attempts_total{result} becomes four separate counters: blueprint_join_success, blueprint_join_failure_not_found, blueprint_join_failure_scope_mismatch, blueprint_join_failure_auth. Document in BLUEPRINTS.md.
8. ipn/ipnstate/
ipnstate.go:31-150+—Statusstruct hasSelf *PeerStatus. AddBlueprintID stringtoPeerStatussotailscale statuscan surface "bound to bp:".
9. App-connector / advertise-routes / advertise-tags precedent
types/appctype/appconnector.go:1-113—AppConnectorConfigandAppConnectorAttrtypes. App-connector config arrives viaNode.CapMap. Useful shape precedent but we're not usingCapMapfor blueprint binding (decision: top-level fields).ipn/ipnlocal/local.go:5948-6023—applyPrefsToHostinfoLocked(). Current pattern: user prefs → Hostinfo → MapRequest → control returns Node config → client applies.- Blueprint pattern inverts this: control sends
Node.BlueprintConfig→ client applies WITHOUT mutatingPrefs.Prefs.BlueprintIDrecords the binding; everything else flows top-down.
Known unknowns
- Storing the OAuth secret locally. After
tailscale jointhe secret should NOT persist on disk (one-shot exchange). Confirm the existing auth-key path discards the secret after the auth-key trade. - Status surface details. Does
tailscale statusJSON output need a separate field, or just the binding inPeerStatus? tailscale leavevstailscale logout. Spec saysleave. Decide: new command, or alias forlogoutwith blueprint-aware behavior. Leaning toward a thinleaveCmdthat calls into the same backend path aslogoutbut with a different telemetry tag.- Local persistence of "was-this-join" bit.
Prefsis persisted to disk; adding the field there is the natural home. Confirm Prefs serialization round-trip preserves it. - Every tag-parsing callsite.
CheckTagis the main one; need to grep forstrings.Contains(..., "tag:"), regex matches on^tag:, etc. Will surface during Phase 1.