memory

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewRepositories

func NewRepositories() *store.Repositories

Types

type AgentRepo

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

func NewAgentRepo

func NewAgentRepo() *AgentRepo

func (*AgentRepo) Create

func (r *AgentRepo) Create(ctx context.Context, a *agent.Agent) error

func (*AgentRepo) GetByID

func (r *AgentRepo) GetByID(ctx context.Context, id string) (*agent.Agent, error)

func (*AgentRepo) List

func (r *AgentRepo) List(ctx context.Context) ([]*agent.Agent, error)

func (*AgentRepo) Update

func (r *AgentRepo) Update(ctx context.Context, a *agent.Agent) error

type ControlAuditRepo

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

ControlAuditRepo is a thread-safe in-memory implementation of controlaudit.Repository. It is intended for tests only.

func NewControlAuditRepo

func NewControlAuditRepo() *ControlAuditRepo

NewControlAuditRepo constructs an empty ControlAuditRepo.

func (*ControlAuditRepo) Append

Append appends an audit record. A defensive copy is stored so callers cannot mutate the record after appending.

func (*ControlAuditRepo) List

List returns records matching the filter in descending occurred_at order. A zero-value filter returns all records up to the effective limit.

type EnvelopeRepo

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

func NewEnvelopeRepo

func NewEnvelopeRepo() *EnvelopeRepo

func (*EnvelopeRepo) Create

func (r *EnvelopeRepo) Create(ctx context.Context, e *envelope.Envelope) error

func (*EnvelopeRepo) GetByID

func (r *EnvelopeRepo) GetByID(ctx context.Context, id string) (*envelope.Envelope, error)

func (*EnvelopeRepo) GetByRequestID

func (r *EnvelopeRepo) GetByRequestID(ctx context.Context, requestID string) (*envelope.Envelope, error)

GetByRequestID looks up by request_id only (legacy compatibility)

func (*EnvelopeRepo) GetByRequestScope

func (r *EnvelopeRepo) GetByRequestScope(ctx context.Context, requestSource, requestID string) (*envelope.Envelope, error)

GetByRequestScope looks up by (request_source, request_id) - preferred for schema v2.1

func (*EnvelopeRepo) List

func (r *EnvelopeRepo) List(ctx context.Context) ([]*envelope.Envelope, error)

func (*EnvelopeRepo) ListByState

func (r *EnvelopeRepo) ListByState(ctx context.Context, state envelope.EnvelopeState) ([]*envelope.Envelope, error)

ListByState returns all envelopes in the given lifecycle state. An empty state returns all envelopes.

func (*EnvelopeRepo) Update

func (r *EnvelopeRepo) Update(ctx context.Context, e *envelope.Envelope) error

type GrantRepo

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

func NewGrantRepo

func NewGrantRepo() *GrantRepo

func (*GrantRepo) Create

func (*GrantRepo) FindActiveByAgentAndProfile

func (r *GrantRepo) FindActiveByAgentAndProfile(ctx context.Context, agentID, profileID string) (*authority.AuthorityGrant, error)

FindActiveByAgentAndProfile checks status='active' AND date range (schema v2.1)

func (*GrantRepo) FindByID

func (r *GrantRepo) FindByID(ctx context.Context, id string) (*authority.AuthorityGrant, error)

func (*GrantRepo) ListByAgent

func (r *GrantRepo) ListByAgent(ctx context.Context, agentID string) ([]*authority.AuthorityGrant, error)

func (*GrantRepo) ListByProfile

func (r *GrantRepo) ListByProfile(ctx context.Context, profileID string) ([]*authority.AuthorityGrant, error)

func (*GrantRepo) Reactivate

func (r *GrantRepo) Reactivate(ctx context.Context, id string) error

Reactivate sets status='active' from suspended (schema v2.1)

func (*GrantRepo) Revoke

func (r *GrantRepo) Revoke(ctx context.Context, id string, revokedBy string) error

Revoke sets status='revoked' and records revocation metadata (schema v2.1)

func (*GrantRepo) Suspend

func (r *GrantRepo) Suspend(ctx context.Context, id string) error

Suspend sets status='suspended' (schema v2.1)

func (*GrantRepo) Update

type LocalSessionRepo

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

LocalSessionRepo is the in-memory implementation of localiam.SessionRepository.

func NewLocalSessionRepo

func NewLocalSessionRepo() *LocalSessionRepo

func (*LocalSessionRepo) Create

func (*LocalSessionRepo) Delete

func (r *LocalSessionRepo) Delete(_ context.Context, id string) error

func (*LocalSessionRepo) DeleteExpired

func (r *LocalSessionRepo) DeleteExpired(_ context.Context) error

func (*LocalSessionRepo) FindByID

func (r *LocalSessionRepo) FindByID(_ context.Context, id string) (*localiam.Session, error)

type LocalUserRepo

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

LocalUserRepo is the in-memory implementation of localiam.UserRepository. It is safe for concurrent access.

func NewLocalUserRepo

func NewLocalUserRepo() *LocalUserRepo

func (*LocalUserRepo) Count

func (r *LocalUserRepo) Count(_ context.Context) (int, error)

func (*LocalUserRepo) Create

func (r *LocalUserRepo) Create(_ context.Context, u *localiam.User) error

func (*LocalUserRepo) FindByID

func (r *LocalUserRepo) FindByID(_ context.Context, id string) (*localiam.User, error)

func (*LocalUserRepo) FindByUsername

func (r *LocalUserRepo) FindByUsername(_ context.Context, username string) (*localiam.User, error)

func (*LocalUserRepo) Update

func (r *LocalUserRepo) Update(_ context.Context, u *localiam.User) error

type ProfileRepo

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

ProfileRepo is an in-memory implementation of authority.ProfileRepository. Profiles are stored as version slices keyed by their logical ID. Within each slice, versions are ordered by insertion order which mirrors ascending version numbers (callers assign monotonically increasing versions). This matches the postgres implementation: the most recently inserted version is the "latest".

func NewProfileRepo

func NewProfileRepo() *ProfileRepo

func (*ProfileRepo) Create

Create appends a new version for the profile's logical ID. The caller is responsible for setting a Version number that is higher than all existing versions for this ID.

func (*ProfileRepo) FindActiveAt

func (r *ProfileRepo) FindActiveAt(ctx context.Context, id string, at time.Time) (*authority.AuthorityProfile, error)

FindActiveAt returns the version of the profile that is active at the given time: status == active, effective_date <= at, and (effective_until IS NULL OR effective_until > at). When multiple versions are active at the same instant (which is an invariant violation), the latest version is returned.

func (*ProfileRepo) FindByID

FindByID returns the latest version (highest version number) for the logical profile ID. Returns nil, nil when no profile with that ID exists.

func (*ProfileRepo) FindByIDAndVersion

func (r *ProfileRepo) FindByIDAndVersion(ctx context.Context, id string, version int) (*authority.AuthorityProfile, error)

FindByIDAndVersion returns the exact (id, version) profile. Returns nil, nil when the logical ID does not exist or does not have the requested version.

func (*ProfileRepo) ListBySurface

func (r *ProfileRepo) ListBySurface(ctx context.Context, surfaceID string) ([]*authority.AuthorityProfile, error)

ListBySurface returns all profile versions whose SurfaceID matches, ordered by logical ID and then version descending. This matches the postgres implementation (ORDER BY id, version DESC) so that callers see all versions, not just the latest per logical profile.

func (*ProfileRepo) ListVersions

func (r *ProfileRepo) ListVersions(ctx context.Context, id string) ([]*authority.AuthorityProfile, error)

ListVersions returns all versions of the profile ordered by version DESC, matching the postgres implementation behaviour.

func (*ProfileRepo) Update

Update replaces the matching (ID, Version) entry in place. Returns nil without error if the (ID, Version) does not exist (no-op).

type Store

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

func NewStore

func NewStore() *Store

func NewStoreWithRepositories

func NewStoreWithRepositories(repos *store.Repositories) *Store

func (*Store) Repositories

func (s *Store) Repositories() (*store.Repositories, error)

func (*Store) WithTx

func (s *Store) WithTx(ctx context.Context, operation string, fn func(*store.Repositories) error) error

type SurfaceRepo

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

SurfaceRepo is a thread-unsafe in-memory implementation of surface.SurfaceRepository. It maintains full version history per logical surface ID, matching the semantics of the Postgres implementation:

  • Create appends a new version; it never overwrites an existing one.
  • FindLatestByID returns the highest-version entry.
  • FindByIDVersion returns a specific (ID, version) pair.
  • ListVersions returns all versions in descending order (latest first).
  • Update modifies an existing (ID, version) entry in place.

Versions are stored in ascending insertion order. Because the apply executor always increments version numbers monotonically (1, 2, 3 …), the last element is always the latest version. All methods rely on this invariant.

func NewSurfaceRepo

func NewSurfaceRepo() *SurfaceRepo

func (*SurfaceRepo) Create

Create appends a new version for the surface's logical ID. The caller (the apply executor) is responsible for assigning a monotonically increasing Version number.

func (*SurfaceRepo) FindActiveAt

func (r *SurfaceRepo) FindActiveAt(_ context.Context, id string, at time.Time) (*surface.DecisionSurface, error)

FindActiveAt returns the surface version that is active at the given time: status == active, effective_from <= at, and (effective_until IS NULL OR effective_until > at). When multiple versions satisfy the condition (an invariant violation), the highest-version one is returned.

func (*SurfaceRepo) FindByIDVersion

func (r *SurfaceRepo) FindByIDVersion(_ context.Context, id string, version int) (*surface.DecisionSurface, error)

FindByIDVersion returns the surface with the given logical ID and exact version. Returns nil, nil when the (ID, version) pair does not exist.

func (*SurfaceRepo) FindLatestByID

func (r *SurfaceRepo) FindLatestByID(_ context.Context, id string) (*surface.DecisionSurface, error)

FindLatestByID returns the highest-version surface for the given logical ID. Returns nil, nil when no surface with that ID exists.

func (*SurfaceRepo) ListAll

ListAll returns the latest version of each surface.

func (*SurfaceRepo) ListByDomain

func (r *SurfaceRepo) ListByDomain(_ context.Context, domain string) ([]*surface.DecisionSurface, error)

ListByDomain returns the latest version of each surface in the given domain.

func (*SurfaceRepo) ListByStatus

func (r *SurfaceRepo) ListByStatus(_ context.Context, status surface.SurfaceStatus) ([]*surface.DecisionSurface, error)

ListByStatus returns the latest version of each surface that has the given status.

func (*SurfaceRepo) ListVersions

func (r *SurfaceRepo) ListVersions(_ context.Context, id string) ([]*surface.DecisionSurface, error)

ListVersions returns all versions of the surface in descending version order (latest first), matching the Postgres implementation behaviour. Returns an empty slice when the surface does not exist.

func (*SurfaceRepo) Search

Search returns the latest version of each surface whose latest version matches the given search criteria.

func (*SurfaceRepo) Update

Update replaces the matching (ID, Version) entry in place. Returns nil without error if the (ID, Version) does not exist (no-op).

Jump to

Keyboard shortcuts

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