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

anonymouspostgres

package module
v0.0.0-...-789096f Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2026 License: MIT Imports: 44 Imported by: 0

README

PostgreSQL anonymous lifecycle

Primary storage and same-Work lifecycle effects for public anonymous signin, recovery, self-deletion and the selected permanent-target password upgrade. The native services compose authenticated public dependencies; the upgrade profile and its limitations are documented below. HTTP/reference composition and broader anonymous lifecycle profiles remain unfinished, so this is not a delivered complete M09.

The adapter owns anonymous metadata, original expiry and lifecycle versions. Kernel identities/placeholders remain kernel-owned; session records remain session-owned. No independent transaction, command journal, identity store or bearer storage is introduced. Constructors borrow an already migrated primary pool and perform no IO; callers close it after operations finish.

Install the kernel anonymous-placeholder history, this module's forward schema and the selected session issuance suffix through the existing migration runner. Stage creation only in the exact closed anonymous participant's original Work, then repeat current lifecycle checks in its final commit phase. Structural reads and recovery correlation do not authenticate a browser, renew original expiry or grant permission to erase legally retained data.

NewSessionService composes those real primary owners and the existing anonymous-only session validator. Configure the lifecycle schema, session schema, directory/policy/audience profile and bounded session validation explicitly. Get returns session.AnonymousGetResult, not verified-user authentication. Every read checks current lifecycle/status, all kernel and policy epochs and session/family state. Its original evidence expires within 20 seconds of the first lookup and never outlives anonymous expiry; copies and later owner reads cannot renew it. This factory performs no issuance, cache fallback or activity update. This reader does not perform permanent-account upgrade; that operation requires the explicit native composition below.

See anonymous policy, changelog and security.

Public anonymous signin

NewSigninService composes the actual kernel, anonymous lifecycle, session, durable risk and audit/outbox owners. It accepts an already issued primary pre-auth transaction/cookie through anonymous.SigninRequest; caller and network/device/origin metadata require trusted ingress. Supply an admitted system display-name attribute, explicit unprivileged namespace/audience, stable configuration identity and independently purposed keys. No caller-selected user or application domain store is accepted.

Install kernel request-key preparation and admission-preparation history, directory and anonymous-placeholder history, authorization authority, this module's schema, session issuance/anonymous/pre-auth/pre-auth-issuance and CSRF histories plus the actual audit/outbox histories. Installing only the base session schema correctly rejects genuine CSRF-bearing issuance.

Signin atomically consumes the original flow and creates the kernel identity, reserved placeholder, anonymous lifecycle and session. Only an acknowledged new commit reveals bearer/CSRF once. Persist its credential-free Recovery scope before attempting recovery. Same-key retry and fresh-service RecoverSignin return historical outcomes without generating or disclosing another token. Changed intent conflicts; recovery still requires original-cookie possession and current disclosure policy. Unknown is not rollback. The resulting guest is read only through the anonymous session service, not verified-user admission.

Authenticated anonymous self-deletion

NewDeletionService composes the real anonymous reader and concrete kernel, session, risk, authorization, audit and outbox owners. Supply a bounded pure identity.PolicyEvaluator retention decision, registered reasons/origins, retained session lookup/CSRF keys, explicit protected-counter configuration and configuration identity. The runtime input cannot select a target or cleanup policy; cleanup is the original subject's stored policy. No permanent password or application-supplied domain store is needed.

Append kernel AnonymousDisposalMigrationSource after anonymous creation and legal-hold/status histories, session AnonymousDisposalMigrationSource after its installed anonymous issuance history, and this module's DisposalMigrationSource after subjects. Install the existing native risk protected-counter history in its selected schema. Keep every installed predecessor byte/version unchanged and allocate suffix versions permanently.

The selected retention profile accepts explicit Allow only. Legal holds, deferred retention, policy failure and changed hold generation deny before erasure; no callback executes while SQL locks are held. Delete and anonymize remove kernel attributes/profile and terminalize the user distinctly; retain preserves payload but still permanently withdraws authentication. Minimal opaque identity/lifecycle/command tombstones remain for non-resurrection, legal audit and ambiguous-outcome recovery. This is not a claim of physical row erasure or full-platform privacy cleanup. Extra contacts or credentials deny self-disposal.

Delete commits kernel state, anonymous lifecycle, every anonymous session and family, and required audit/outbox in one Work. Protected attempt counters retain their existing reservation/replay semantics: a later disposal rollback does not refund the attempt or charge replay again. Original expiry and the earliest <=20-second admission deadline are rechecked without renewal. Required late-owner failure rolls back disposal and its audit/outbox. An ambiguous commit returns Unknown; save its full query and call RecoverDeletion with the original credential/CSRF and exact ingress. Recovery authenticates original encrypted input even after self-revocation, reconciles the existing owners and returns metadata only. It never issues credentials or authorizes live access. Calls remain bounded and no background jobs, private ledger or cache are introduced.

Permanent-target upgrade

NewUpgradeService composes the existing owners through UpgradeConfig: Guest supplies actual anonymous/session/kernel/risk/retention configuration; Primary is the password adapter's action-primary source for identity.anonymous.upgrade and ProofAudience; Target selects the real permanent password-session profile. Supply both retained CSRF key sets, the session issuer and the actual capability issuer/preparation configuration. Guest and permanent namespaces may differ, but tenant/global/audience/storage ownership must agree. The constructor performs no migration or network work.

Install the selected kernel AnonymousUpgradeDisposalMigrationSource, password AnonymousUpgradeReauthenticationMigrationSource, the existing MFA factor- authority history, session AnonymousUpgradeMigrationSource and this module's UpgradeMigrationSource, plus the actual capability issuance/one-use and protected-risk-counter histories. Append these to their documented predecessors without rewriting installed steps.

Call password verification for the selected upgrade action, then submit that fresh target proof, both original cookie credentials and CSRF synchronizers, the actual anonymous subject in a typed anonymous.MergePlan, matching remember policy, trusted ingress and one idempotency key to Upgrade. This finite profile preserves an existing permanent target, including canonical ULIDs and historical authentication. It transfers no application resources. Only no-conflict or profile.display_name/KeepTarget plans are supported; resource-transfer, other conflict decisions and enrolled/unknown MFA fail closed.

The first durable command issues the real one-use capability. The second consumes that original grant and target proof atomically with anonymous disposal, all guest-session/family revocations, the new permanent session and required audit/outbox effects. Original evidence expires within 20 seconds of the first authoritative read, or the earlier proof/guest deadline; waits and retries never renew it. Acknowledged new completion alone reveals the new cookie/CSRF once.

Persist both credential-free queries in UpgradeResult. Unknown is not rollback: RecoverUpgrade requires those exact queries, both original credentials/CSRF and original ingress. It reconciles the original commands without reexecution, new grants, fresh authentication or credential redelivery. Successful same-key replay is likewise metadata-only, including after the original grant expires. Retain original lookup/CSRF, request/envelope and capability verification keys for their respective recovery lifetimes. Keep Guest.IntentKey stable for retained requests; independent transport-key rotation does not change original intent.

Abandoned-guest maintenance

NewCleanupService(pool, CleanupConfig, keys) composes actual kernel, anonymous, session, audit and outbox owners. The fixed configured service actor must be authorized for identity.anonymous.expire: selection uses resource identity.anonymous/expired, and each subject uses identity.anonymous/<user>. The coordinator's request-admission and query policies remain required. Expired guest cookies never provide maintenance authority.

Supply installed repository/session schemas, global authority, bounded clock, current authorization/retention policy, original request/envelope keys, configuration identity and maximum batch (1..1000). Policy callbacks execute outside transactions. Current hold/directory/lifecycle/session generations and the original at-most-20-second evidence window are fenced before commit. Unavailable policy stops the batch; legal hold or validated retention deferral preserves the guest and allows explicit cursor progress. Stored delete, anonymize and retain remain distinct: retain keeps payload but withdraws guest authentication. No permanent upgrade target or application data is erased.

Append kernel AnonymousExpiryDisposalMigrationSource, session AnonymousExpiryMigrationSource and anonymous ExpiryMigrationSource after their selected disposal histories. If upgrade is installed, append its histories first and set session Upgrade: true. Preserve predecessor versions/checksums; the expiry suffix accepts populated historical upgrade records.

Generate one random RunID and call CleanupExpired with tenant, bounded Limit and optional exact returned Next cursor. Selection seeks over the existing active-expiry index using authoritative database time. LagKnown identifies a successful tenant-wide remaining-backlog observation, including held rows; RemainingLag saturates at 8760 hours. Selection holds no locks across callbacks. This is an explicit call, not a scheduler or HTTP API.

Each attempted guest owns an independently atomic original random command: the batch is not an atomic/idempotent batch receipt. Save each nonempty CleanupItem.Recovery; unknown/in-progress stops selection and requires RecoverCleanup before advancing. Exact CleanupSubject input (tenant/user/ RunID) retains original retry custody; retry it after uncertain request-key admission. Terminal retry/recovery performs no new disposal and cannot renew authority. A later run starts from zero to revisit held rows. See the native maintenance contract and external-package cleanup_service_integration_test.go consumer examples.

Expired-subject owner composition

ExpiryFields/ExpirySubject preserve the exact stored lifecycle in the closed service-expiry command; neither is authorization or current-expiry evidence. StageExpiredDisposal requires actual same-Work kernel disposal and authoritative database-time expiry. RequireExpiredDisposal repeats the original terminal state/time fence; RecoverExpiredDisposal reads retained command evidence, never infers success from a missing subject. Install ExpiryMigrationSource after disposal history without changing any predecessor SQL. Stored delete becomes StateExpired; anonymize/retain keep their distinct classifications. The native maintenance workflow must still provide service authorization, current retention/legal-hold policy, complete session effects and audit/outbox. These owner entry points are not a public cleanup service or HTTP route.

Documentation

Overview

Package anonymouspostgres owns primary anonymous lifecycle metadata inside identity's existing coordinator. Kernel and session state keep their owners.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreationFields

func CreationFields(subject anonymous.AnonymousSubject) ([]identity.FeatureField, error)

CreationFields freezes the complete anonymous-owned initial lifecycle before command fingerprinting. Kernel/session fields remain separately owner-mapped. The result contains no bearer or credential and grants no current authority.

func CreationSubject

func CreationSubject(command identity.Command) (anonymous.AnonymousSubject, error)

CreationSubject reconstructs only this owner's original lifecycle projection from the exact closed anonymous command. Missing/extra/foreign fields deny; independent namespaces remain their owners' responsibility. It performs no IO and cannot authenticate a browser, authorize creation or renew expiry.

func DeletionFields

func DeletionFields(subject anonymous.AnonymousSubject) ([]identity.FeatureField, error)

DeletionFields freezes this owner's original lifecycle before fingerprinting. It neither authorizes disposal nor selects retention or kernel/session state.

func ExpiryFields

func ExpiryFields(subject anonymous.AnonymousSubject) ([]identity.FeatureField, error)

ExpiryFields freezes the original lifecycle for the exact service-expiry command. Mapping grants neither maintenance authority nor expiry, retention, kernel or session evidence. The returned fields are caller-owned.

func ExpirySubject

func ExpirySubject(c identity.Command) (anonymous.AnonymousSubject, error)

ExpirySubject reconstructs only the complete original lifecycle in an exact service-expiry command. This pure projection performs no IO, authentication, expiry check or authorization. It cannot convert browser custody into service authority; current owners must fence the command in the coordinator's Work.

func NewSessionService

NewSessionService composes the actual lifecycle, kernel, session and policy primary owners with the existing anonymous-only core validator. Construction has no IO and owns no pool, goroutine, cache, transaction or token. The caller closes its pool only after calls finish. Reads are concurrent-safe, never create a credential reference and return only unprivileged anonymous custody; existing verified-user session APIs remain closed to this method.

func UpgradeFields

func UpgradeFields(p anonymous.MergePlan) ([]identity.FeatureField, error)

UpgradeFields commits the bounded original source, permanent target and canonical typed merge plan before command fingerprinting. It carries no credential or resource payload and grants no authentication/transfer authority. The native owner must retain the complete plan in encrypted preparation; unsupported resource transfers still deny before mutation.

func ValidateUpgradePlan

func ValidateUpgradePlan(command identity.Command, plan anonymous.MergePlan) error

ValidateUpgradePlan checks exact native command/typed plan agreement without IO, a clock, permission, proof consumption or mutation. Target UserID/ActorID remain distinct from the guest RecordID. Other owner namespaces are untouched.

Types

type CleanupConfig

type CleanupConfig struct {
	Repository                Config
	Sessions                  sessionpg.Config
	GlobalAuthorityID         string
	ActorID                   identity.ActorID
	ConfigurationID, PolicyID string
	MaximumBatch              uint32
	Clock                     clock.Clock
	Retention                 *identity.PolicyEvaluator
	RetentionPolicyVersion    uint64
	RequestKeys               kernel.RequestKeyConfig
	Coordinator               kernel.CoordinatorConfig
	IntentKey                 [32]byte
	ActiveEnvelopeKeyID       string
}

CleanupConfig selects trusted maintenance, not browser authentication. ActorID is fixed by composition; the configured current authorization engine must allow selection on identity.anonymous/expired and individual disposal on identity.anonymous/<user>, in addition to the coordinator's admission/query scopes. Retention runs outside SQL; holds and deferred decisions stay pending. MaximumBatch is 1..1000. ConfigurationID versions callback semantics. Install selected kernel/session/anonymous disposal+expiry and existing request-key preparation histories. Construction never installs or migrates.

func (CleanupConfig) Format

func (CleanupConfig) Format(f fmt.State, _ rune)

func (CleanupConfig) MarshalJSON

func (CleanupConfig) MarshalJSON() ([]byte, error)

func (CleanupConfig) MarshalText

func (CleanupConfig) MarshalText() ([]byte, error)

type CleanupCursor

type CleanupCursor struct {
	ExpiresAt time.Time
	UserID    identity.UserID
}

CleanupCursor is an exclusive indexed seek position, not eligibility or authorization. Eligibility always uses fresh authoritative database time. Advance past deferred subjects using Next, then start a later run from zero to revisit them. Preserve the exact returned expiry and user tie-breaker.

type CleanupItem

type CleanupItem struct {
	UserID     identity.UserID
	Outcome    identity.CommitOutcome
	Recovery   identity.RecoveryQuery
	Replayed   bool
	RetryAfter time.Duration
	Error      error
}

CleanupItem is historical per-subject metadata, never authentication. Error is populated by batch execution for a deferred or interrupted item. Unknown and InProgress require original recovery, not an invented success/rollback.

func (CleanupItem) Format

func (CleanupItem) Format(f fmt.State, _ rune)

func (CleanupItem) MarshalJSON

func (CleanupItem) MarshalJSON() ([]byte, error)

type CleanupRequest

type CleanupRequest struct {
	TenantID identity.TenantID
	RunID    identity.CommandID
	Limit    uint32
	After    *CleanupCursor
}

CleanupRequest selects one bounded tenant page. Generate RunID once and keep it across interruption/retry: each selected subject gets an original random command through the existing immutable request-key owner. A batch is NOT one atomic/idempotent receipt: repeating selection can include other still-active expired subjects. Individual results and CleanupSubject retain exact retries. No caller-supplied timestamp, actor, cleanup policy or guest credential exists.

type CleanupResult

type CleanupResult struct {
	Items        []CleanupItem
	Next         *CleanupCursor
	ObservedAt   time.Time
	RemainingLag time.Duration
	LagKnown     bool
}

CleanupResult preserves completed/attempted items even when a later item fails. Next follows the last attempted subject; reconcile unknown work before advancing. LagKnown alone makes RemainingLag meaningful: it observes the tenant's complete active backlog, including held/contended subjects, at ObservedAt and saturates at 8760 hours. It is not a future-empty guarantee.

func (CleanupResult) Format

func (CleanupResult) Format(f fmt.State, _ rune)

func (CleanupResult) MarshalJSON

func (CleanupResult) MarshalJSON() ([]byte, error)

type CleanupService

type CleanupService struct {
	// contains filtered or unexported fields
}

CleanupService owns bounded explicit maintenance, not a scheduler, background goroutine, pool or second transaction/recovery engine. Immutable composition supports concurrent calls; keep borrowed pool, policies, clock and keys alive.

func NewCleanupService

func NewCleanupService(pool *database.Pool, c CleanupConfig, keys *keyring.Provider) (*CleanupService, error)

NewCleanupService freezes native owners without IO, callbacks or entropy. Expired credentials are never accepted as maintenance authority. Stored retain/anonymize/delete policy and original hold/authority versions survive preparation; every actual owner rechecks them in the same final transaction.

func (*CleanupService) CleanupExpired

func (s *CleanupService) CleanupExpired(ctx context.Context, r CleanupRequest) (out CleanupResult, err error)

CleanupExpired selects at most Limit indexed expired subjects, then executes their independently atomic owner commands. Selection holds no locks across callbacks: original version/expiry/hold fences arbitrate upgrade/deletion races. It stops on unknown/unavailable/cancellation, preserving attempted original queries; policy-denied items remain pending and do not starve later pages when the caller advances Next. No automatic retry or scheduler runs.

func (*CleanupService) CleanupSubject

func (s *CleanupService) CleanupSubject(ctx context.Context, r CleanupSubjectRequest) (out CleanupItem, err error)

CleanupSubject expires one exact subject with original per-run retry custody. Preparation/callbacks occur outside SQL; the existing coordinator alone owns reservation, commit, failure and reconciliation. A terminal retry does not reread a now-disposed subject, renew its deadline or perform disposal twice.

func (*CleanupService) Format

func (*CleanupService) Format(f fmt.State, _ rune)

func (*CleanupService) MarshalJSON

func (*CleanupService) MarshalJSON() ([]byte, error)

func (*CleanupService) RecoverCleanup

func (s *CleanupService) RecoverCleanup(ctx context.Context, q identity.RecoveryQuery) (out CleanupItem, err error)

RecoverCleanup reconciles the original command under current service query policy. It restores authenticated input, never live guest authentication or retention admission; missing/corrupt history never establishes rollback.

type CleanupSubjectRequest

type CleanupSubjectRequest struct {
	TenantID identity.TenantID
	UserID   identity.UserID
	RunID    identity.CommandID
}

CleanupSubjectRequest names a maintenance target and stable run correlation. It grants no authority and cannot dispose a permanent/unexpired/terminal user. Retry the same input after uncertain request-key admission; after a command exists, save its Recovery query. New policy/admission needs a new RunID.

type Config

type Config struct {
	Schema          string
	MaximumDuration time.Duration
}

Config selects an installed dedicated schema and positive primary IO budget of at most one minute. The caller owns pool lifetime and all migration IO.

type DeletionConfig

type DeletionConfig struct {
	Repository                Config
	Sessions                  sessionpg.Config
	Profile                   sessionpg.AnonymousAdmissionConfig
	Validation                session.ServiceConfig
	CSRFKeys                  []session.CSRFKey
	Origins, Reasons          []string
	ConfigurationID, PolicyID string
	Retention                 *identity.PolicyEvaluator
	RetentionPolicyVersion    uint64
	RequestKeys               kernel.RequestKeyConfig
	Coordinator               kernel.CoordinatorConfig
	Risk                      riskpg.Config
	IntentKey                 [32]byte
	ActiveEnvelopeKeyID       string
}

DeletionConfig selects authenticated self-disposal of an existing native anonymous user. No signin/password implementation is required at construction. Install kernel/anonymous/session disposal and request-key preparation histories, the actual protected risk-counter history, authorization, audit and outbox. Retention is a bounded pure policy callback evaluated outside SQL; this profile accepts explicit Allow only, and denies legal holds or deferred erasure rather than ignoring them. Cleanup comes from the stored subject, never the request. ConfigurationID must change when callback semantics change. Borrow all owner pools/keys/clocks until calls finish; no background work is created.

func (DeletionConfig) Format

func (DeletionConfig) Format(f fmt.State, _ rune)

func (DeletionConfig) MarshalJSON

func (DeletionConfig) MarshalJSON() ([]byte, error)

func (DeletionConfig) MarshalText

func (DeletionConfig) MarshalText() ([]byte, error)

type DeletionService

type DeletionService struct {
	// contains filtered or unexported fields
}

DeletionService composes real primary owners under the existing coordinator. It owns neither a transaction/replay ledger nor session/token authority. Immutable composition is concurrency-safe, with one private phase per call.

func NewDeletionService

func NewDeletionService(pool *database.Pool, c DeletionConfig, keys *keyring.Provider) (*DeletionService, error)

NewDeletionService freezes explicit trusted native composition without IO, migration, policy callbacks, entropy or session generation. It accepts no application-provided store, transaction engine or identity assertion.

func (*DeletionService) Delete

Delete binds the actual anonymous bearer/CSRF and original retry intent. Only a new command can enter live admission. Exact terminal retries return metadata, never reactivate a user, reevaluate retention or revoke twice.

func (*DeletionService) DeletionRateSource

func (s *DeletionService) DeletionRateSource(ctx context.Context, r anonymous.DeletionRequest) (user identity.UserID, err error)

DeletionRateSource authenticates original anonymous credential and CSRF possession before returning its rate subject. Retained revoked sessions select only the same historical retry scope, never active authority. Delete independently admits live state for new work and original-command policy for replay. No command, retention callback, risk effect or mutation occurs here. The value is internal routing metadata, not public identity disclosure or a reusable proof. Borrowed dependencies retain their bounded concurrent owners.

func (*DeletionService) Format

func (*DeletionService) Format(f fmt.State, _ rune)

func (*DeletionService) MarshalJSON

func (*DeletionService) MarshalJSON() ([]byte, error)

func (*DeletionService) RecoverDeletion

RecoverDeletion authenticates original encrypted input plus original bearer/ CSRF possession, even after self-revocation or session payload cleanup. It only asks the existing coordinator to reconcile retained owner evidence. No live permission, retention reevaluation, issuance or reexecution occurs.

type DisposalMigrationSource

type DisposalMigrationSource struct {
	Schema  string
	Version migrations.Version
}

DisposalMigrationSource appends retained anonymous-owned self-deletion evidence after subject/kernel histories; schema/version are permanent explicit installation inputs. Existing creation SQL remains byte-for-byte unchanged.

func (DisposalMigrationSource) Load

Load performs no IO and enables no endpoint. The existing runner owns the forward-only installation; invalid scope/order at installation fails closed.

type ExpiryMigrationSource

type ExpiryMigrationSource struct {
	Schema  string
	Version migrations.Version
}

ExpiryMigrationSource appends service-expiry support to the installed anonymous disposal journal. Existing creation/deletion/upgrade SQL and rows are unchanged. Expired delete is distinct from requested self-deletion; anonymize and retain preserve their stored-policy terminal classifications. Allocate Version after selected predecessors; no destructive downgrade exists.

func (ExpiryMigrationSource) Load

Load returns one forward-only suffix without IO or capability activation. Wrong/missing predecessor constraints fail when the existing runner installs the suffix. Nil contexts, invalid schema/version and cancellation deny.

type MigrationSource

type MigrationSource struct {
	Schema  string
	Version migrations.Version
}

MigrationSource installs this dedicated owner after the actual kernel's anonymous-placeholder history. Version is a permanent unused allocation; callers use the existing migration runner's explicit history namespace. It enables no endpoint and has no destructive downgrade or automatic bootstrap.

func (MigrationSource) Load

Load returns one independently owned forward migration without IO. Kernel reference failures are fatal; no IF EXISTS fallback adopts another history.

type Repository

type Repository struct {
	// contains filtered or unexported fields
}

Repository owns only anonymous lifecycle metadata. It borrows a PRIMARY pool, opens no transaction and has no goroutines or mutable global state. Read is concurrent-safe; borrowed Work and command custody remain serial-use.

func NewRepository

func NewRepository(pool *database.Pool, c Config) (*Repository, error)

NewRepository freezes explicit configuration without IO or state creation. This is neither an anonymous signin service nor session authority.

func (*Repository) Format

func (*Repository) Format(f fmt.State, _ rune)

func (*Repository) MarshalJSON

func (*Repository) MarshalJSON() ([]byte, error)

func (*Repository) MarshalText

func (*Repository) MarshalText() ([]byte, error)

func (*Repository) Read

Read returns an exact primary lifecycle projection, preserving terminal states and original expiry/version. No credential is accepted and no positive lease is issued. A session consumer must check all owners under its original bounded read window; absence cannot prove noncommit or authorize recreation.

func (*Repository) RecoverCreation

RecoverCreation inspects this participant's retained original creation correlation only. It grants no access, restores no bearer and performs no mutation. Missing metadata describes this participant, never proves overall rollback: the existing coordinator must reconcile every enlisted owner.

func (*Repository) RecoverDisposal

RecoverDisposal reads retained original metadata, never infers a successful deletion from absence or mutable user/session status. Only the sole existing coordinator can reconcile this participant with kernel/session/audit/outbox.

func (*Repository) RecoverExpiredDisposal

RecoverExpiredDisposal votes only from retained original expiry-command evidence. Missing lifecycle rows do not prove success, and recovery grants no current access or right to re-execute. The existing coordinator reconciles this vote with kernel, sessions and required audit/outbox effects.

func (*Repository) RecoverUpgrade

RecoverUpgrade reads the exact retained source/target/typed-plan correlation only under the original coordinator's recovery invocation. It does not infer commitment from an absent guest row, authenticate a target or return a bearer. The caller must reconcile kernel, capability, password, session and required effects; mismatched or missing evidence cannot independently prove success.

func (*Repository) RequireCreation

func (r *Repository) RequireCreation(ctx context.Context, w kernel.Work, owner kernel.FeatureExecutionContributor, command identity.Command) error

RequireCreation repeats exact original lifecycle and expiry under share lock in the same owner's final read-only invocation. It neither writes nor renews time. Caller must also repeat kernel/session/current-policy admission.

func (*Repository) RequireDisposal

RequireDisposal verifies this owner's exact terminal state and original lifetime during the final read-only same-Work fence; no time is renewed.

func (*Repository) RequireExpiredDisposal

func (r *Repository) RequireExpiredDisposal(ctx context.Context, w kernel.Work, p kernel.FeatureExecutionContributor, c identity.Command) error

RequireExpiredDisposal repeats the exact terminal lifecycle and original database-time expiry in the same final Work fence. It cannot renew expiry or replace current kernel, service, retention or session-owner checks.

func (*Repository) RequireUpgrade

RequireUpgrade repeats this owner's exact upgraded lifecycle, original merge decision and expiry under the same Work after all downstream effects. It is read-only and does not infer target authentication or extend validity.

func (*Repository) StageCreation

func (r *Repository) StageCreation(ctx context.Context, w kernel.Work, owner kernel.FeatureExecutionContributor, command identity.Command) error

StageCreation writes only anonymous metadata after actual kernel creation in the exact native participant's original Work. Risk and session effects remain required owner phases. No independent transaction or identity/session writes occur here. Every error must abort Work; success is provisional, not issuance.

func (*Repository) StageDisposal

StageDisposal terminalizes only this owner's exact active subject after the actual kernel's disposal in the same Work. Minimal lifecycle/command linkage is retained for non-resurrection and ambiguity recovery; no personal fields, credentials, bearer or application merge payloads are duplicated here. Every error must abort the complete command, including session effects.

func (*Repository) StageExpiredDisposal

StageExpiredDisposal terminalizes the exact database-time-expired active subject after actual kernel disposal in the same service-expiry Work. Stored cleanup is preserved; delete becomes expired, anonymize and retain keep their distinct terminal states. Upgrade/version races deny, never erase a target.

func (*Repository) StageUpgrade

StageUpgrade writes only anonymous lifecycle and bounded merge metadata after the actual kernel's guest disposal and provisional one-use consumption in the same exact native Work. It never writes target identity, credentials, bearer or application data. Missing/changed source loses the optimistic race. Errors abort every owner; success is provisional until the coordinator commits.

type SessionServiceConfig

type SessionServiceConfig struct {
	Repository Config
	Sessions   sessionpg.Config
	Profile    sessionpg.AnonymousAdmissionConfig
	Validation session.ServiceConfig
}

SessionServiceConfig explicitly selects anonymous lifecycle and session schemas on one borrowed PRIMARY pool. Both owner IO budgets must fit within Validation.MaximumDuration. Directory, anonymous kernel/lifecycle, session issuance and guest-policy histories must already be installed. Validation's clock and retained lookup keys keep the session owner's existing semantics. Applications supply configuration, not domain stores or authority readers.

func (SessionServiceConfig) Format

func (SessionServiceConfig) Format(f fmt.State, _ rune)

func (SessionServiceConfig) MarshalJSON

func (SessionServiceConfig) MarshalJSON() ([]byte, error)

func (SessionServiceConfig) MarshalText

func (SessionServiceConfig) MarshalText() ([]byte, error)

type SigninConfig

type SigninConfig struct {
	Repository                                  Config
	Sessions                                    sessionpg.Config
	Profile                                     sessionpg.AnonymousAdmissionConfig
	Policy                                      anonymous.Policy
	ConfigurationID, PolicyID, DisplayNameField string
	Fields                                      *identity.AttributeProcessor
	FieldSchema                                 identity.AttributeSchema
	FlowKeys                                    []session.DigestKey
	Origins, CallbackURLs                       []string
	RequestKeys                                 kernel.RequestKeyConfig
	IntentKey                                   [32]byte
	ActiveEnvelopeKeyID                         string
	Risk                                        risk.AuthenticationAdmissionCustodyConfig
	Coordinator                                 kernel.CoordinatorConfig
	Issuer                                      session.IssuerConfig
	CSRF                                        session.CSRFKey
}

SigninConfig is immutable trusted composition. The selected DisplayNameField is admitted through Fields/FieldSchema as a system-created attribute, never a caller-selected contact. ConfigurationID versions callback semantics. The guest namespace/audience must be deliberately unprivileged. Separate request intent, lookup, flow, envelope and risk keys retain their owners/rotation. Install the kernel preparation/key, anonymous, directory, pre-auth, session issuance and CSRF, authorization, audit and outbox histories before enabling Signin. CSRFMigrationSource is required even in the base anonymous-only profile: its genuine issuer persists digest-only synchronizer state, not schema-1 rows.

func (SigninConfig) Format

func (SigninConfig) Format(f fmt.State, _ rune)

func (SigninConfig) MarshalJSON

func (SigninConfig) MarshalJSON() ([]byte, error)

func (SigninConfig) MarshalText

func (SigninConfig) MarshalText() ([]byte, error)

type SigninService

type SigninService struct {
	// contains filtered or unexported fields
}

SigninService composes concrete primary owners under the sole existing coordinator. It borrows the pool/local keyring and owns no transaction, goroutine, mutable request cache, sender or automatic retry. Every call has its own native phase. Keep borrowed dependencies alive until calls finish.

func NewSigninService

func NewSigninService(pool *database.Pool, c SigninConfig, keys *keyring.Provider) (*SigninService, error)

NewSigninService freezes explicit configuration without IO, callbacks, migrations or entropy. Applications supply configuration, not domain stores.

func (SigninService) Format

func (SigninService) Format(f fmt.State, _ rune)

func (SigninService) MarshalJSON

func (SigninService) MarshalJSON() ([]byte, error)

func (*SigninService) RecoverSignin

RecoverSignin authenticates original encrypted input and cookie before native disclosure/reconciliation. It performs no generation, external risk or retry.

func (*SigninService) Signin

Signin executes one original scoped request through native prepared-input and generation custody. Terminal retry/recovery cannot generate a second token.

func (*SigninService) SigninRateSource

func (s *SigninService) SigninRateSource(ctx context.Context, r anonymous.SigninRequest) (source string, err error)

SigninRateSource authenticates the original pre-auth possession and intent before returning its stable HTTP rate dimension. It reads only the primary original flow and performs no identity lookup, admission, command preparation, risk evaluation, entropy or mutation. The returned value is not an identifier supplied by the browser and must never be logged or treated as authority.

Retained consumed/expired flows keep this rate scope for keyed retries, not permission to create another guest. Signin independently enforces live flow admission for a new command; only its existing owner can recover old work. Calls are bounded, concurrency-safe and preserve redacted error identities.

type UpgradeConfig

type UpgradeConfig struct {
	Guest                 DeletionConfig
	Primary               *passwordpg.ActionPrimarySource
	Target                sessionpg.SessionServiceConfig
	TargetCSRFKeys        []session.CSRFKey
	ProofAudience         string
	Issuer                session.IssuerConfig
	CSRF                  session.CSRFKey
	Capability            capabilitypg.IssuerConfig
	CapabilityPreparation capabilitypg.IssuancePreparationConfig
}

UpgradeConfig composes the existing guest, password, capability and session owners. Guest supplies disposal/retention, primary stores, request-key custody and protected risk counters; it does not select deletion permission. Primary must select identity.anonymous.upgrade and ProofAudience. Target is the real single-factor password session profile. Both original cookies require CSRF. Capability and CapabilityPreparation must retain their keys for recovery. Install the corresponding forward histories before use. Constructors perform no IO, migration, entropy or provider work. Borrow pools/clocks until calls end.

func (UpgradeConfig) Format

func (UpgradeConfig) Format(f fmt.State, _ rune)

func (UpgradeConfig) MarshalJSON

func (UpgradeConfig) MarshalJSON() ([]byte, error)

func (UpgradeConfig) MarshalText

func (UpgradeConfig) MarshalText() ([]byte, error)

type UpgradeMigrationSource

type UpgradeMigrationSource struct {
	Schema  string
	Version migrations.Version
}

UpgradeMigrationSource adds this owner's retained source/target merge journal after existing anonymous history. Existing SQL and deletion evidence stay unchanged. This finite profile transfers no resources: the only nonempty explicit decision is preserving profile.display_name on the permanent target. Kernel, password, MFA, capability and session histories remain independently required before the native upgrade can be selected. No endpoint is enabled.

func (UpgradeMigrationSource) Load

Load returns one forward-only migration without IO. Version/schema are permanent explicit installation inputs; the existing runner owns ordering.

type UpgradeService

type UpgradeService struct {
	// contains filtered or unexported fields
}

UpgradeService owns native composition, not a second transaction, proof, session or replay engine. Immutable configuration permits concurrent calls; every call retains its own phase and reveal-once prospective session.

func NewUpgradeService

func NewUpgradeService(pool *database.Pool, c UpgradeConfig, keys *keyring.Provider) (*UpgradeService, error)

NewUpgradeService freezes explicit native owner composition. This finite profile preserves an existing permanent account, transferring no application resources or credentials. Unsupported merge decisions and enrolled MFA deny.

func (*UpgradeService) Format

func (*UpgradeService) Format(f fmt.State, _ rune)

func (*UpgradeService) MarshalJSON

func (*UpgradeService) MarshalJSON() ([]byte, error)

func (*UpgradeService) RecoverUpgrade

RecoverUpgrade authenticates both original cookies/CSRF and exact retained two-command scope. It reconciles existing owner evidence only: no current signin, new proof, grant generation, mutation or credential redelivery.

func (*UpgradeService) Upgrade

Upgrade commits original grant issuance first, then atomically consumes that grant and fresh target proof with all guest/session effects. Unknown retains both original correlations. Only a known newly committed final execution may reveal its invocation-local session; retries and recovery reveal no secrets.

Jump to

Keyboard shortcuts

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