Help us shape the future of Go! Take the 2026 Go Developer Survey

dataprofile

package
v0.55.9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 2, 2026 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package dataprofile is the data protection profile of a subject: residency, retention and locality (kombify workspace public StackKits standards/DATA-ARCHITECTURE.md section 5, D-2026-10-21-12). It is edition-neutral; the SaaS header transport lives in edgeauth (profile.go), the self-hosted Full Local profile comes from the boot environment.

Every unknown, missing or malformed value is an error: a profile that cannot be resolved denies, it never falls back to Standard.

Index

Constants

View Source
const (
	ResidencyGlobal Residency = "global"
	ResidencyEU     Residency = "eu"

	RetentionStandard Retention = "standard"
	RetentionZero     Retention = "zero"

	LocalityHosted Locality = "hosted"
	LocalityLocal  Locality = "local"

	ScopeAccount      Scope = "account"
	ScopeOrganization Scope = "organization"
	ScopeWorkspace    Scope = "workspace"
	ScopeSession      Scope = "session"
	ScopeEdition      Scope = "edition"
)
View Source
const (
	ReasonUnresolvable        = "data_profile_unresolvable"
	ReasonCapabilityDenied    = "data_profile_capability_denied"
	ReasonProcessorIneligible = "data_profile_processor_ineligible"
)

Reason codes of the denial envelope.

View Source
const BootEnvVar = "KOMBIFY_DATA_PROFILE"

BootEnvVar selects the Full Local profile of the self-hosted edition.

View Source
const FullLocal = "full-local"

FullLocal is the only accepted value of BootEnvVar.

View Source
const ReasonFullLocal = "data_profile_full_local"

ReasonFullLocal names a Full Local refusal in logs, gates and denial envelopes.

View Source
const Version = 1

Version is the wire version of the encoded profile.

Variables

This section is empty.

Functions

func CapabilityDenial

func CapabilityDenial(requestID, capability, providerID string, p Profile) denial.Envelope

CapabilityDenial is the envelope for a capability the profile does not allow, for example a non-EU model under EU residency.

func GuardTransport

func GuardTransport(t *http.Transport)

GuardTransport binds t to the homelab: connections go through GuardDial and proxies are dropped. Use it for a transport a client creates for itself.

func IsDenied

func IsDenied(err error) bool

IsDenied reports whether err is a Full Local refusal. Besides a *DeniedError it recognizes the refusal of a public nameserver by LocalResolver, which the Go resolver reports as a *net.DNSError with the cause flattened to text: the error counts only if its text is exactly the text of this guard's own denial for the nameserver the error names. That is the machine reason the guard itself produced, not a reading of arbitrary error text, so an ordinary lookup failure (not found, timeout, a public server in a Standard process) is never classified as a refusal, and there is no shared state between lookups.

func LocalAddr

func LocalAddr(addr netip.Addr) bool

LocalAddr reports whether addr stays inside the homelab: loopback, private (RFC 1918, RFC 4193) or link-local, except the listed provider metadata endpoints. The shared address space 100.64.0.0/10 (RFC 6598) is not included: it is assigned to provider carrier networks, not to a homelab, and no standard admits it. An IPv4-mapped IPv6 address is judged as its IPv4 address and an IPv6 zone is ignored, so fd00:ec2::254%eth0 is the metadata endpoint fd00:ec2::254 and not a distinct, accepted address.

func LocalDestinationPolicy

func LocalDestinationPolicy() (prefixes []netip.Prefix, excluded []netip.Addr)

LocalDestinationPolicy returns the homelab destination policy that LocalAddr enforces: prefixes are the accepted address ranges and excluded are the individual addresses inside them that are refused (the listed provider metadata endpoints). An address is local when a prefix contains it and excluded does not list it; a consumer must compare in the same normal form as LocalAddr, that is IPv4-mapped IPv6 addresses unmapped to IPv4 and the IPv6 zone dropped. The slices are copies, so a caller may modify them freely.

func LocalResolver

func LocalResolver() *net.Resolver

LocalResolver returns a resolver that only asks homelab nameservers, so a lookup cannot reach a public DNS server. It forces the Go resolver, whose nameserver dial is the only hook for this check. A refused nameserver makes the lookup fail with a *net.DNSError that IsDenied recognizes.

func UnresolvableDenial

func UnresolvableDenial(requestID string) denial.Envelope

UnresolvableDenial is the envelope for a request whose profile is missing or invalid.

func WithProfile

func WithProfile(ctx context.Context, p Profile) context.Context

WithProfile stores a verified profile for downstream handlers.

Types

type DeniedError

type DeniedError struct {
	Host string
}

DeniedError is the error of a connection Full Local refused.

func (*DeniedError) Error

func (e *DeniedError) Error() string

type DialFunc

type DialFunc = func(ctx context.Context, network, address string) (net.Conn, error)

DialFunc is the signature of net.Dialer.DialContext. It is an alias so named dial types of other packages (for example pgconn.DialFunc) convert implicitly.

func GuardDial

func GuardDial(next DialFunc) DialFunc

GuardDial wraps next (a plain net.Dialer when nil) so that it only connects to homelab addresses. See the file comment for the rules, including what the connection returned by next must report as its peer.

type Locality

type Locality string

Locality is the loc axis.

type Profile

type Profile struct {
	V     int       `json:"v"`
	Res   Residency `json:"res"`
	Ret   Retention `json:"ret"`
	Loc   Locality  `json:"loc"`
	Scope Scope     `json:"scope"`
	Rev   int64     `json:"rev"`
	TS    int64     `json:"ts"`
}

Profile is one resolved data protection profile. Rev is the revision of the stored record (0 for Standard without a record); TS is the unix second it was resolved.

func Decode

func Decode(encoded string) (Profile, error)

Decode parses an encoded profile strictly: unknown fields, non-canonical encodings and out-of-vocabulary values fail.

func FromBoot

func FromBoot(e edition.Edition, value string) (Profile, error)

FromBoot returns the edition profile of a self-hosted installation. Unset means hosted Standard; "full-local" is accepted only with selfhost-oss.

func FromBootEnv

func FromBootEnv() (Profile, error)

FromBootEnv reads BootEnvVar and the resolved edition.

func FromContext

func FromContext(ctx context.Context) (Profile, bool)

FromContext returns the verified profile. A missing profile is reported, never replaced by Standard.

func Meet

func Meet(profiles ...Profile) (Profile, error)

Meet returns the strictest value per axis: eu over global, zero over standard, local over hosted. Scope, revision and timestamp come from the strictest contributor in that order of axes, else from the first profile. Meet of nothing is an error, never Standard.

func Standard

func Standard() Profile

Standard is the profile of a subject without a stored record.

func (Profile) Canonical

func (p Profile) Canonical() (string, error)

Canonical is the canonical JSON of p with a fixed key order; it is the signed form shared with the TypeScript twin.

func (Profile) Describe

func (p Profile) Describe() string

Describe names the active options in plain words.

func (Profile) EU

func (p Profile) EU() bool

EU reports whether content and its processing must stay in the EU.

func (Profile) Encode

func (p Profile) Encode() (string, error)

Encode returns the base64url (unpadded) canonical JSON carried in headers and job payloads.

func (Profile) EnforceEgress

func (p Profile) EnforceEgress() error

EnforceEgress binds http.DefaultTransport and net.DefaultResolver to the homelab when p is Full Local, and changes nothing for any other valid profile; an invalid profile is an error, never a no-op. Call it once at boot, before any client or telemetry is created. The shared transport is changed in place, so it stays an *http.Transport that can be cloned and clients that captured it earlier are guarded as well. Clients with a transport, dialer or resolver of their own need GuardTransport or GuardDial.

func (Profile) Local

func (p Profile) Local() bool

Local reports whether nothing may leave the homelab.

func (Profile) Validate

func (p Profile) Validate() error

Validate fails on any value outside the vocabulary.

func (Profile) Zero

func (p Profile) Zero() bool

Zero reports whether processing content must not be written durably.

type Residency

type Residency string

Residency is the res axis.

type Retention

type Retention string

Retention is the ret axis.

type Scope

type Scope string

Scope names where a profile value was set.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL