mirror of
https://github.com/tailscale/tailscale.git
synced 2026-11-25 19:21:18 -08:00
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]>
7.9 KiB
7.9 KiB
Blueprints v1 — Implementation Checklist
Derived from /home/ubuntu/code/tmp/BLUEPRINTS-SPEC.md. Every line below is a thing that must be true before v1 is done.
Tag namespace (NEW)
tag:bp//<id>parses as a valid tag everywhere in the codebase. Note the double-slash.<id>validation matches the regular tag-name character set: letter-start, alphanumerics and dashes only.tag:bp//*is exempt from requiring atagOwnersentry. Control plane is the implicit owner.- Every existing call site that does substring/regex matching on
tag:strings is audited; tests added for each. - ACL grants can reference
tag:bp//fooas src or dst with semantics identical to a regular tag. - Round-trips through JSON/HuJSON serialization, MapResponse encoding, and policy storage.
ACL schema (blueprints block)
- New top-level
blueprintskey in the HuJSON policy file. - Each blueprint object supports v1 fields only:
description(required),tags,serves.apps,serves.ipsets,attrs. - v2-deferred fields explicitly rejected at parse time (or silently ignored, document the choice):
serves.services,serves.exitNode,serves.funnel,posture,prefs,includes. - Blueprint creation auto-generates the paired
tag:bp//<id>tag. - Blueprint deletion revokes the paired OAuth client.
- At least one example blueprint in
deploy/acls/test fixtures. - ACL-CI validates the example.
OAuth lifecycle
- Blueprint creation auto-generates a paired OAuth client.
- Paired client has
auth_keys.read+auth_keys.writescopes. - Paired client is pinned to mint keys only with
tag:bp//<id>. - Client secret is surfaced once at creation. Re-fetch is rotation, not display.
- Mint attempt for a tag the client is not scoped to fails with a clear error.
- Blueprint deletion revokes the paired client.
- Rotation is per-blueprint; touching one client does not affect others.
CLI (tailscale join / tailscale leave / tailscale set)
- New subcommand
tailscale join --blueprint=<id> --auth-key=<oauth-secret>. joinhas no--advertise-tags,--advertise-routes,--advertise-exit-node,--advertise-connectorflags.joinaccepts node-local flags:--hostname,--state-dir,--operator,--ssh.- Under the hood,
joinperforms the existing OAuth secret → auth key exchange; no new auth path. - Joining with a non-existent blueprint fails clearly.
- Joining with a secret that doesn't match the blueprint's paired client fails clearly.
- One bit ("was this node brought up via
join?") is persisted in local prefs / state. tailscale setrejects every locked-field set when the bit is set, with the EXACT spec error message:Error: this node is bound to bp:<id>. <Field> are managed by the blueprint. Edit the blueprint in the ACL to change what this node serves, or run 'tailscale leave' to detach.- Locked-field set covers:
advertise-tags,advertise-routes,advertise-exit-node,advertise-connector, serves, funnel,hostname,operator,ssh,accept-dns. tailscale leavedetaches the node, logs it out, and (server-side) deletes it.
Propagation
- Blueprint-bound nodes carry blueprint state in their
Node(top-level fields, per design decision). - Map response projects blueprint's
tags,serves.apps,serves.ipsets,attrsinto the bound node's MapResponse atomically. - Editing the blueprint in the ACL triggers reconvergence: all bound nodes receive new config on next map poll.
tailcfgcapability version is bumped to mark the new field set.- No new wire protocol — reuse the existing MapResponse mechanism.
Approval & ephemerality
- Blueprint joins follow the tailnet's existing device-approval settings. No new approval path.
- Blueprint-bound nodes are ephemeral;
tailscale leavedeletes them server-side. - Re-joining mints a fresh node; no local state is preserved.
Metrics
Server (corp, expvar)
gauge_blueprints_defined_total{tailnet_id}— gauge of defined blueprints.gauge_blueprint_oauth_clients_total{tailnet_id}— gauge of paired clients.counter_blueprint_join_attempts_total{tailnet_id,blueprint_id,result}—result ∈ {success, blueprint_not_found, scope_mismatch, auth_failed}.gauge_blueprint_bound_nodes{tailnet_id,blueprint_id}— currently-bound node count.histogram_blueprint_edit_propagation_seconds{tailnet_id}— ACL-save to last bound node receiving updated config.
Client (OSS, clientmetric)
blueprint_join_successcounter.blueprint_join_failurecounter.blueprint_set_rejectedcounter.blueprint_leavecounter.blueprint_boundgauge.
Admin HTTP API
GET /admin/api/blueprints— list blueprints with bound-node counts.GET /admin/api/blueprints/{id}— single blueprint detail + bound nodes.- Endpoint to reveal the paired client secret once (creation) and to rotate it.
- Permissioned by the same actor model as ACLs (
perm.ACLs.CanRead/WriteTailnet()).
Build variants
HasBlueprints()gate incontrol/controltags/controltags.goreturningIsSaaS.- All blueprint code paths gated on
HasBlueprints(). - Tests pass under all four CI matrix tags: saas, onprem, onprem_coral, compliance_us.
Tests
- Unit tests on every new function (table-driven where the repo uses table-driven).
- Integration test: define blueprint → mint key →
tailscale join→ bound node observes correct config → edit ACL → node reconverges →tailscale leavecleans up. - Negative tests:
tailscale set --advertise-routeson a bound node fails with the verbatim spec error.- OAuth client minting for an unscoped tag fails.
- Join with non-existent blueprint fails clearly.
- Join with mismatched secret fails clearly.
- Grant references
tag:bp//foobut no such blueprint: surfaces a warning/error (decide and test).
- Tag parser tests: round-trip
tag:bp//foothrough serialization, grant compilation, MapResponse encoding. - Coverage of new code ≥ 80% in both repos.
CI
- OSS:
./tool/go test ./...green. - OSS: staticcheck, vet, gofmt, depaware green per
.github/workflows/. - Corp:
./tool/go test ./...green across all build tags. - Corp:
make pr(staticcheck, test, depaware, gofmt, vet) green. - Corp: ACL-CI on
deploy/acls/green.
Docs
BLUEPRINTS.mdat root of each branch: scope (v1 in vs out), metrics paths, how to run the integration test locally, known limitations.BLUEPRINTS-NOTES.mdretained as scratch.BLUEPRINTS-FOLLOWUPS.mdlists every deferred item (composability, services, tsnet, versioning, partial overrides, per-deployment secrets, etc.).
Anti-scope-creep checks
- No
includesfield on blueprints (composability deferred). - Blueprints are NOT ACL destinations (
tag:bp//foois, but the blueprint object itself is not a grant target). - No services-auto-generating-blueprints code.
- No tsnet integration.
- No versioning, rollback, or pinning.
- No partial overrides.
- No per-deployment secrets.
Iterative loops (per the prompt)
- Loop 1: make it work. End-to-end MVS green with passing tests.
- Loop 2: make it right. Style consistency, error messages, metric verification.
- Loop 3: make it observable and ergonomic. Fresh-checkout integration test, metrics visible, full local CI re-run.
Done criteria
- Both branches pushed.
- Both branches show green local CI.
- ≥ 80% coverage of new code (numbers reported).
- Three loops visible in commit history.
- Metrics observable in the scrape path.
- End-to-end integration test passes.
- No scope creep beyond MVS (anything wanted-but-deferred is in FOLLOWUPS).
BLUEPRINTS.mdexists in both repos.