Documentation
¶
Overview ¶
Copyright 2026 Sneat.co
Copyright 2026 Sneat.co ¶
Copyright 2026 Sneat.co ¶
Copyright 2026 Sneat.co ¶
Copyright 2026 Sneat.co ¶
Package host4datatug holds the host adapters DataTug's checkout and project routes share across hosts: the verified-caller authenticators, the verified first-sign-in bootstrap, the personal-account and owner ports, the project contact and usage-actor ports and the reviewed plan settings. They bind the DataTug domain's narrow ports to Sneat Core, so a library cannot import a service repository and every host imports the same implementation.
Copyright 2026 Sneat.co ¶
Copyright 2026 Sneat.co ¶
Copyright 2026 Sneat.co ¶
Copyright 2026 Sneat.co ¶
Copyright 2026 Sneat.co ¶
Copyright 2026 Sneat.co
Index ¶
- Constants
- func BearerValue(value string) (string, bool)
- func BusinessUsageActors() businessUsageActors
- func CloudProjectLifecycle() facade4datatug.CloudProjectLifecycleOptions
- func CloudProjectSpaces() cloudProjectSpaces
- func NewActiveAccountChecker(db dal.DB, ...) (func(context.Context, string) error, error)
- func NewInfrastructureRootMonitor(db dal.DB, observer bool, ...) (*infrastructureroots.Monitor, bool, error)
- func NewWatchIdentityReader(readUser func(context.Context, string) (*sneatauth.AuthUserInfo, error)) (facade4datatug.WatchIdentityReader, error)
- func PersonalAccountForCheckout(ctx context.Context, db dal.DB, userID string, ...) (facade4datatug.PersonalAccount, error)
- func PersonalDirectory(db dal.DB) facade4datatug.PersonalAccountDirectory
- func PersonalOwner() facade4datatug.PersonalPlanOwnerPort
- func PlanConfiguration() facade4datatug.PlanConfigReader
- func ProjectAccountOwner(db dal.DB) projectAccountOwner
- func ProjectContacts() projectContacts
- func ProjectInvites(db dal.DB) facade4datatug.CloudProjectInvitePort
- func ProjectRelationshipMutationPolicies(db dal.DB, businessReader facade4datatug.BusinessSharedProjectOptions) (*facade4linkage.RelationshipMutationPolicies, error)
- func ReadPersonalAccountInTransaction(ctx context.Context, tx dal.ReadTransaction, userID string) (facade4datatug.PersonalAccount, error)
- func RootSpaceLifecycle() contract4spaceus.RootSpaceLifecycleAuthority
- func VerifiedPersonalBootstrap(ctx context.Context, actor string) (facade4auth.VerifiedPersonalBootstrap, error)
- func WithRemoteClient(next http.Handler) http.Handler
- type BusinessCheckoutCaller
- type InfrastructureRootMonitorConfig
- type PlanSettings
- type VerifiedCaller
Constants ¶
const InfrastructureRootMonitorConfigEnv = "DB_SCHEMA_MONITOR_CONFIG_B64"
InfrastructureRootMonitorConfigEnv names the environment variable holding the standard-base64 InfrastructureRootMonitorConfig JSON. It is not a credential.
const InvitedFriendTitle = "Invited friend"
InvitedFriendTitle names the Space contact create_invite writes before the friend joins; the claim fills in the friend's own name.
const PlanSettingsEnv = "DATATUG_PERSONAL_PLAN_SETTINGS_JSON"
The reviewed deployment configuration is versioned and must supply every allowance and model choice. An absent or malformed value closes plan reads and new paid effects; it never invents an allowance.
const ProjectJoinInviteGate = "datatug.project_join"
ProjectJoinInviteGate gates every invite into a dedicated project Space: create_cloud_project stamps it on the Space (SpaceDbo.InviteGate), invitus stamps it on every invite minted there by any route, and Sneat's generic accept_personal_invite refuses those with 403 invite_gated. A friend joins only through join_project, which checks their plan first and claims with AllowGate (founder 2026-10-29: "Gate the invites").
Variables ¶
This section is empty.
Functions ¶
func BearerValue ¶
BearerValue extracts the token of a well-formed "Bearer <token>" header value.
func BusinessUsageActors ¶
func BusinessUsageActors() businessUsageActors
BusinessUsageActors binds activity attribution to the verified request context preserved by DAL transaction callbacks.
func CloudProjectLifecycle ¶ added in v0.60.6
func CloudProjectLifecycle() facade4datatug.CloudProjectLifecycleOptions
CloudProjectLifecycle binds delete_project's ports for Space-backed cloud projects to Core: invitus revokes the dedicated Space's pending invites (facade4invitus.NewSpaceInvites), contactus' remove_space_member removes its other members (facade4contactus.RemoveSpaceMember), and Core's delete_space removes the emptied Space (facade4spaceus.DeleteSpace). The host passes it to SharedProjectService.ConfigureCloudProjectLifecycle.
func CloudProjectSpaces ¶ added in v0.60.6
func CloudProjectSpaces() cloudProjectSpaces
CloudProjectSpaces binds create_cloud_project's Space port to Core's facade4spaceus.CreateSpaceTxWorker. RegisterSpace is resumable but not atomic, so the worker runs inside DataTug's own create transaction. The Space type comes from DataTug's Space registration profile.
func NewActiveAccountChecker ¶
func NewActiveAccountChecker(db dal.DB, readUser func(context.Context, string) (*sneatauth.AuthUserInfo, error)) (func(context.Context, string) error, error)
NewActiveAccountChecker requires an explicitly initialized Firebase Admin user reader. It reads existing users only; it never bootstraps a Space or entitlement. Firebase verification is a preflight (including retries), never atomic with Firestore. Native fence callbacks reuse only their exact trusted owner reader; ordinary callers read the configured database in their own read transaction.
func NewInfrastructureRootMonitor ¶
func NewInfrastructureRootMonitor(db dal.DB, observer bool, listRoots func(context.Context, string, string) ([]string, error)) (*infrastructureroots.Monitor, bool, error)
NewInfrastructureRootMonitor is shared by the scanner host and independent freshness host. Missing config disables it. No account or bot state is created.
func NewWatchIdentityReader ¶
func NewWatchIdentityReader(readUser func(context.Context, string) (*sneatauth.AuthUserInfo, error)) (facade4datatug.WatchIdentityReader, error)
NewWatchIdentityReader never bootstraps accounts. Native status, personal account ownership and verified recipient evidence are reread in the caller's transaction; Firebase status is an additional bounded provider preflight.
func PersonalAccountForCheckout ¶
func PersonalAccountForCheckout(ctx context.Context, db dal.DB, userID string, bootstrap *facade4auth.VerifiedPersonalBootstrap) (facade4datatug.PersonalAccount, error)
PersonalAccountForCheckout uses only an auth-account already verified by Firebase Admin for the signed-in buyer. The core resolver performs its own fresh provider match before creating a missing user.
func PersonalDirectory ¶
func PersonalDirectory(db dal.DB) facade4datatug.PersonalAccountDirectory
PersonalDirectory binds the released personal-space authority to DataTug's account port. A missing user is deliberately refused until the host has a verified auth-account and request-client bootstrap seam.
func PersonalOwner ¶
func PersonalOwner() facade4datatug.PersonalPlanOwnerPort
PersonalOwner verifies current ownership inside the caller's transaction.
func PlanConfiguration ¶
func PlanConfiguration() facade4datatug.PlanConfigReader
func ProjectAccountOwner ¶
ProjectAccountOwner keeps Paymentus's current owner fence in the same DataTug admission transaction. Checkout's wider writer adapter stays checkout-owned.
func ProjectContacts ¶
func ProjectContacts() projectContacts
ProjectContacts binds DataTug's project-contact ports to current Contactus records. The DataTug service owns the assignment and reciprocal writes.
func ProjectInvites ¶ added in v0.60.6
func ProjectInvites(db dal.DB) facade4datatug.CloudProjectInvitePort
ProjectInvites binds DataTug's cloud-project invite port to the contactus create_member and remove_space_member and the invitus personal-invite facades, called in-process.
func ProjectRelationshipMutationPolicies ¶
func ProjectRelationshipMutationPolicies(db dal.DB, businessReader facade4datatug.BusinessSharedProjectOptions) (*facade4linkage.RelationshipMutationPolicies, error)
ProjectRelationshipMutationPolicies builds the trusted server registry for both directions of Core Linkage's reciprocal project/contact mutations. Protection is declared before configuration is read, so any later startup failure leaves generic mutations fail-closed.
Any host that serves Core's /linkage/update_item_relationships endpoint MUST bind this registry to it (see WithLinkageMutationPolicies). Without it a DataTug project's roles fall back to Core's unprotected path.
func ReadPersonalAccountInTransaction ¶ added in v0.60.6
func ReadPersonalAccountInTransaction(ctx context.Context, tx dal.ReadTransaction, userID string) (facade4datatug.PersonalAccount, error)
ReadPersonalAccountInTransaction reads the user's one existing personal space through tx and verifies it as Core's resolver does. It never creates a user or a space: a user without one holds no personal plan (ErrPersonalAccountUnavailable). A storage failure is returned as is.
func RootSpaceLifecycle ¶ added in v0.63.0
func RootSpaceLifecycle() contract4spaceus.RootSpaceLifecycleAuthority
RootSpaceLifecycle returns Core's typed native root Space lifecycle authority. DataTug product code consumes the contract; epoch minting and archive/restore status policy stay in Core.
func VerifiedPersonalBootstrap ¶
func VerifiedPersonalBootstrap(ctx context.Context, actor string) (facade4auth.VerifiedPersonalBootstrap, error)
VerifiedPersonalBootstrap admits only a single Firebase Admin verified provider account and the actual request-derived client information.
Types ¶
type BusinessCheckoutCaller ¶
type BusinessCheckoutCaller struct{}
BusinessCheckoutCaller verifies the same DataTug product, audience and current OAuth grant as the Pro caller, without requiring a project-write scope for a Space purchase.
func (BusinessCheckoutCaller) AuthenticateCheckout ¶
func (BusinessCheckoutCaller) AuthenticateCheckout(ctx context.Context, bearer string) (subscriptions.BuyerIdentity, error)
type InfrastructureRootMonitorConfig ¶
type InfrastructureRootMonitorConfig struct {
RegistryDigest string `json:"registryDigest"`
CatalogArtifact []byte `json:"catalogArtifact"`
CatalogDigest string `json:"catalogDigest"`
CatalogRevision string `json:"catalogRevision"`
OperatorUserID string `json:"operatorUserID"`
TelegramChatID int64 `json:"telegramChatID"`
TelegramBotID int64 `json:"telegramBotID"`
}
InfrastructureRootMonitorConfig is supplied by operator deployment only. CatalogArtifact is standard-base64 JSON bytes in the outer JSON object.
type PlanSettings ¶
type PlanSettings struct {
Version string `json:"version"`
ProjectGuestsKnown bool `json:"projectGuestsKnown"`
Config facade4datatug.PlanConfig `json:"config"`
}
func ReadPlanSettings ¶
func ReadPlanSettings() (PlanSettings, error)
type VerifiedCaller ¶
type VerifiedCaller struct{}
VerifiedCaller uses the host's Firebase signature and active OAuth-grant verification. The route-specific policy is bound before each verification; a caller-supplied site, body product or account never broadens it.
func (VerifiedCaller) AuthenticateCheckout ¶
func (VerifiedCaller) AuthenticateCheckout(ctx context.Context, bearer string) (subscriptions.BuyerIdentity, error)