Documentation
¶
Index ¶
- func NewRepositories() *store.Repositories
- type AgentRepo
- type ControlAuditRepo
- type EnvelopeRepo
- func (r *EnvelopeRepo) Create(ctx context.Context, e *envelope.Envelope) error
- func (r *EnvelopeRepo) GetByID(ctx context.Context, id string) (*envelope.Envelope, error)
- func (r *EnvelopeRepo) GetByRequestID(ctx context.Context, requestID string) (*envelope.Envelope, error)
- func (r *EnvelopeRepo) GetByRequestScope(ctx context.Context, requestSource, requestID string) (*envelope.Envelope, error)
- func (r *EnvelopeRepo) List(ctx context.Context) ([]*envelope.Envelope, error)
- func (r *EnvelopeRepo) ListByState(ctx context.Context, state envelope.EnvelopeState) ([]*envelope.Envelope, error)
- func (r *EnvelopeRepo) Update(ctx context.Context, e *envelope.Envelope) error
- type GrantRepo
- func (r *GrantRepo) Create(ctx context.Context, g *authority.AuthorityGrant) error
- func (r *GrantRepo) FindActiveByAgentAndProfile(ctx context.Context, agentID, profileID string) (*authority.AuthorityGrant, error)
- func (r *GrantRepo) FindByID(ctx context.Context, id string) (*authority.AuthorityGrant, error)
- func (r *GrantRepo) ListByAgent(ctx context.Context, agentID string) ([]*authority.AuthorityGrant, error)
- func (r *GrantRepo) ListByProfile(ctx context.Context, profileID string) ([]*authority.AuthorityGrant, error)
- func (r *GrantRepo) Reactivate(ctx context.Context, id string) error
- func (r *GrantRepo) Revoke(ctx context.Context, id string, revokedBy string) error
- func (r *GrantRepo) Suspend(ctx context.Context, id string) error
- func (r *GrantRepo) Update(_ context.Context, g *authority.AuthorityGrant) error
- type LocalSessionRepo
- func (r *LocalSessionRepo) Create(_ context.Context, s *localiam.Session) error
- func (r *LocalSessionRepo) Delete(_ context.Context, id string) error
- func (r *LocalSessionRepo) DeleteExpired(_ context.Context) error
- func (r *LocalSessionRepo) FindByID(_ context.Context, id string) (*localiam.Session, error)
- type LocalUserRepo
- func (r *LocalUserRepo) Count(_ context.Context) (int, error)
- func (r *LocalUserRepo) Create(_ context.Context, u *localiam.User) error
- func (r *LocalUserRepo) FindByID(_ context.Context, id string) (*localiam.User, error)
- func (r *LocalUserRepo) FindByUsername(_ context.Context, username string) (*localiam.User, error)
- func (r *LocalUserRepo) Update(_ context.Context, u *localiam.User) error
- type ProfileRepo
- func (r *ProfileRepo) Create(ctx context.Context, p *authority.AuthorityProfile) error
- func (r *ProfileRepo) FindActiveAt(ctx context.Context, id string, at time.Time) (*authority.AuthorityProfile, error)
- func (r *ProfileRepo) FindByID(ctx context.Context, id string) (*authority.AuthorityProfile, error)
- func (r *ProfileRepo) FindByIDAndVersion(ctx context.Context, id string, version int) (*authority.AuthorityProfile, error)
- func (r *ProfileRepo) ListBySurface(ctx context.Context, surfaceID string) ([]*authority.AuthorityProfile, error)
- func (r *ProfileRepo) ListVersions(ctx context.Context, id string) ([]*authority.AuthorityProfile, error)
- func (r *ProfileRepo) Update(ctx context.Context, p *authority.AuthorityProfile) error
- type Store
- type SurfaceRepo
- func (r *SurfaceRepo) Create(_ context.Context, s *surface.DecisionSurface) error
- func (r *SurfaceRepo) FindActiveAt(_ context.Context, id string, at time.Time) (*surface.DecisionSurface, error)
- func (r *SurfaceRepo) FindByIDVersion(_ context.Context, id string, version int) (*surface.DecisionSurface, error)
- func (r *SurfaceRepo) FindLatestByID(_ context.Context, id string) (*surface.DecisionSurface, error)
- func (r *SurfaceRepo) ListAll(_ context.Context) ([]*surface.DecisionSurface, error)
- func (r *SurfaceRepo) ListByDomain(_ context.Context, domain string) ([]*surface.DecisionSurface, error)
- func (r *SurfaceRepo) ListByStatus(_ context.Context, status surface.SurfaceStatus) ([]*surface.DecisionSurface, error)
- func (r *SurfaceRepo) ListVersions(_ context.Context, id string) ([]*surface.DecisionSurface, error)
- func (r *SurfaceRepo) Search(_ context.Context, criteria surface.SearchCriteria) ([]*surface.DecisionSurface, error)
- func (r *SurfaceRepo) Update(_ context.Context, s *surface.DecisionSurface) error
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
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 ¶
func (r *ControlAuditRepo) Append(_ context.Context, rec *controlaudit.ControlAuditRecord) error
Append appends an audit record. A defensive copy is stored so callers cannot mutate the record after appending.
func (*ControlAuditRepo) List ¶
func (r *ControlAuditRepo) List(_ context.Context, f controlaudit.ListFilter) ([]*controlaudit.ControlAuditRecord, error)
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) 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) 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.
type GrantRepo ¶
type GrantRepo struct {
// contains filtered or unexported fields
}
func NewGrantRepo ¶
func NewGrantRepo() *GrantRepo
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) ListByAgent ¶
func (*GrantRepo) ListByProfile ¶
func (*GrantRepo) Reactivate ¶
Reactivate sets status='active' from suspended (schema v2.1)
func (*GrantRepo) Revoke ¶
Revoke sets status='revoked' and records revocation metadata (schema v2.1)
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) Delete ¶
func (r *LocalSessionRepo) Delete(_ context.Context, id string) error
func (*LocalSessionRepo) DeleteExpired ¶
func (r *LocalSessionRepo) DeleteExpired(_ context.Context) 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) FindByUsername ¶
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 ¶
func (r *ProfileRepo) Create(ctx context.Context, p *authority.AuthorityProfile) error
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 ¶
func (r *ProfileRepo) FindByID(ctx context.Context, id string) (*authority.AuthorityProfile, error)
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 ¶
func (r *ProfileRepo) Update(ctx context.Context, p *authority.AuthorityProfile) error
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 NewStoreWithRepositories ¶
func NewStoreWithRepositories(repos *store.Repositories) *Store
func (*Store) Repositories ¶
func (s *Store) Repositories() (*store.Repositories, 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 ¶
func (r *SurfaceRepo) Create(_ context.Context, s *surface.DecisionSurface) error
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 ¶
func (r *SurfaceRepo) ListAll(_ context.Context) ([]*surface.DecisionSurface, error)
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 ¶
func (r *SurfaceRepo) Search(_ context.Context, criteria surface.SearchCriteria) ([]*surface.DecisionSurface, error)
Search returns the latest version of each surface whose latest version matches the given search criteria.
func (*SurfaceRepo) Update ¶
func (r *SurfaceRepo) Update(_ context.Context, s *surface.DecisionSurface) error
Update replaces the matching (ID, Version) entry in place. Returns nil without error if the (ID, Version) does not exist (no-op).