memory

package
v0.1.2 Latest Latest
Warning

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

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

Documentation

Overview

Package memory provides in-memory repository implementations for the walking skeleton and tests. Replaced by the Postgres adapters.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AdvisoryStore

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

AdvisoryStore is the in-memory owned-advisory store (dev/tests, mirrors the Postgres adapter). It is GLOBAL reference data – NOT tenant-scoped. Advisories are indexed by every affected (ecosystem, package) so ByPackage is a map lookup, and Upsert is idempotent by advisory id (re-syncable reference data, replaced in place – not append-only). The stored ecosystem+package keys are the ingester-normalized, OSV-canonical ids per the ports.AdvisoryStore KEY CONTRACT.

func NewAdvisoryStore

func NewAdvisoryStore() *AdvisoryStore

NewAdvisoryStore returns an empty in-memory advisory store.

func (*AdvisoryStore) ByPackage

func (s *AdvisoryStore) ByPackage(_ context.Context, ecosystem, name string) ([]advisory.Advisory, error)

ByPackage returns the advisories that list (ecosystem, name) as affected, in deterministic id order (matching the Postgres adapter's ORDER BY id COLLATE "C"); the caller runs advisory.Match to decide which actually hit the component's version.

func (*AdvisoryStore) Upsert

Upsert inserts or replaces an advisory by id and (re)builds its (ecosystem, package) index entries. A re-sync may change the affected set, so the prior index entries for the id are dropped first. Idempotent.

type AgentSessionStore

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

AgentSessionStore is the in-memory ports.AgentSessionStore (dev/tests). It keeps the same (session, seq) transcript fork-guard as the Postgres adapter so a duplicate seq is rejected, not silently overwritten.

func NewAgentSessionStore

func NewAgentSessionStore() *AgentSessionStore

NewAgentSessionStore returns an empty in-memory agent session store.

func (*AgentSessionStore) AppendMessage

func (s *AgentSessionStore) AppendMessage(_ context.Context, sessionID shared.ID, seq int, m agent.Message) error

func (*AgentSessionStore) GetSession

func (s *AgentSessionStore) GetSession(_ context.Context, id shared.ID) (agent.Session, error)

func (*AgentSessionStore) ListByEngagement

func (s *AgentSessionStore) ListByEngagement(_ context.Context, engagementID shared.ID) ([]agent.Session, error)

func (*AgentSessionStore) ListResumable

func (s *AgentSessionStore) ListResumable(_ context.Context, staleFor time.Duration, now time.Time, limit int) ([]agent.Session, error)

func (*AgentSessionStore) Messages

func (s *AgentSessionStore) Messages(_ context.Context, sessionID shared.ID) ([]agent.Message, error)

func (*AgentSessionStore) SaveSession

func (s *AgentSessionStore) SaveSession(_ context.Context, sess agent.Session) error

type ApprovalStore

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

ApprovalStore is the in-memory ports.ApprovalStore (dev/tests). Decide is idempotent: the first terminal decision wins; a second returns ErrConflict (so a double-click / race cannot re-open an admitted action).

func NewApprovalStore

func NewApprovalStore() *ApprovalStore

NewApprovalStore returns an empty in-memory approval store.

func (*ApprovalStore) Decide

func (*ApprovalStore) EngagementsWithPending

func (s *ApprovalStore) EngagementsWithPending(_ context.Context) ([]shared.ID, error)

func (*ApprovalStore) Enqueue

func (*ApprovalStore) Get

func (*ApprovalStore) Pending

func (s *ApprovalStore) Pending(_ context.Context, engagementID shared.ID) ([]agent.ProposedAction, error)

type CommentRepository

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

CommentRepository is an in-memory per-finding comment thread (dev/tests).

func NewCommentRepository

func NewCommentRepository() *CommentRepository

NewCommentRepository returns an empty in-memory comment repository.

func (*CommentRepository) Add

func (*CommentRepository) ListByEngagementFinding

func (r *CommentRepository) ListByEngagementFinding(_ context.Context, engagementID, findingID shared.ID) ([]finding.Comment, error)

type DecisionStore

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

DecisionStore is the in-memory ports.DecisionStore (dev/tests). It mirrors the Postgres adapter: a monotonic per-session seq, idempotent on (session_id, action_id) for step decisions and a single stop per session (a re-record is a no-op, so a redelivered drive cannot fork the log).

func NewDecisionStore

func NewDecisionStore() *DecisionStore

NewDecisionStore returns an empty in-memory decision store.

func (*DecisionStore) AppendDecision

func (s *DecisionStore) AppendDecision(_ context.Context, d agent.AgentDecision) error

func (*DecisionStore) ListBySession

func (s *DecisionStore) ListBySession(_ context.Context, sessionID shared.ID) ([]agent.AgentDecision, error)

type EngagementRepository

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

EngagementRepository is a goroutine-safe in-memory engagement store.

func NewEngagementRepository

func NewEngagementRepository() *EngagementRepository

NewEngagementRepository returns an empty in-memory repository.

func (*EngagementRepository) Create

func (*EngagementRepository) Delete

Delete removes an engagement (idempotent). In Postgres the FK cascade removes children; in memory other stores are independent, but import rollback only needs the engagement gone so a re-import isn't blocked.

func (*EngagementRepository) GetByID

func (*EngagementRepository) GetByIDInTenant

func (r *EngagementRepository) GetByIDInTenant(_ context.Context, tenantID, id shared.ID) (*engagement.Engagement, error)

GetByIDInTenant loads an engagement scoped to tenantID. A caller tenant of ” matches any row; a non-empty tenant matches only its own – tenant A cannot read tenant B's engagement (ErrNotFound).

func (*EngagementRepository) GetByProjectID

func (r *EngagementRepository) GetByProjectID(_ context.Context, tenantID, projectID shared.ID) (*engagement.Engagement, error)

func (*EngagementRepository) List

func (*EngagementRepository) ProjectContexts

func (r *EngagementRepository) ProjectContexts(_ context.Context, tenantID shared.ID, projectIDs []shared.ID) (map[shared.ID]*engagement.Engagement, error)

func (*EngagementRepository) Update

type EvidenceStore

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

EvidenceStore is an in-memory append-only evidence ledger.

func NewEvidenceStore

func NewEvidenceStore() *EvidenceStore

NewEvidenceStore returns an empty in-memory evidence store.

func (*EvidenceStore) Append

func (s *EvidenceStore) Append(_ context.Context, items []evidence.Evidence) error

func (*EvidenceStore) Head

func (s *EvidenceStore) Head(_ context.Context, engagementID shared.ID) (string, error)

func (*EvidenceStore) ListByEngagement

func (s *EvidenceStore) ListByEngagement(_ context.Context, engagementID shared.ID) ([]evidence.Evidence, error)

type FindingRepository

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

FindingRepository is an in-memory finding store (dev/tests), deduped per engagement by dedup key. Replaced by Postgres when a DB is configured.

func NewFindingRepository

func NewFindingRepository() *FindingRepository

NewFindingRepository returns an empty in-memory finding repository.

func (*FindingRepository) ListByEngagement

func (r *FindingRepository) ListByEngagement(_ context.Context, engagementID shared.ID) ([]finding.Finding, error)

ListByEngagement returns the engagement's findings, highest risk first (KEV -> EPSS x CVSS).

func (*FindingRepository) ListPublishableByEngagement

func (r *FindingRepository) ListPublishableByEngagement(ctx context.Context, engagementID shared.ID) ([]finding.Finding, error)

ListPublishableByEngagement returns only the engagement's findings that clear the evidence gate, reusing the single domain rule finding.Publishable.

func (*FindingRepository) SetAssignee

func (r *FindingRepository) SetAssignee(_ context.Context, engagementID, findingID shared.ID, assignee string, expectedVersion int) (finding.Finding, error)

SetAssignee sets a finding's assignee with the same optimistic-concurrency guard.

func (*FindingRepository) SetEvidenceScore

func (r *FindingRepository) SetEvidenceScore(_ context.Context, engagementID, findingID shared.ID, score, expectedVersion int) (finding.Finding, error)

SetEvidenceScore sets a finding's evidence score with the same optimistic-concurrency guard as UpdateStatus (the adversarial-verdict path). Returns shared.ErrConflict on a version mismatch, shared.ErrNotFound if absent.

func (*FindingRepository) UpdateStatus

func (r *FindingRepository) UpdateStatus(_ context.Context, engagementID, findingID shared.ID, status finding.Status, expectedVersion int) (finding.Finding, error)

UpdateStatus sets a finding's triage status with optimistic concurrency (expectedVersion must match the stored version), bumping the version. Returns shared.ErrConflict on a version mismatch, shared.ErrNotFound if absent.

func (*FindingRepository) Upsert

func (r *FindingRepository) Upsert(_ context.Context, findings []finding.Finding) error

Upsert inserts or updates findings, deduped by (engagement, dedup key). On update it preserves the existing triage status + created timestamp.

type ImportedSBOMStore

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

ImportedSBOMStore keeps the active imported SBOM per engagement in memory.

func NewImportedSBOMStore

func NewImportedSBOMStore() *ImportedSBOMStore

NewImportedSBOMStore returns an empty imported-SBOM store.

func (*ImportedSBOMStore) LatestByEngagement

func (s *ImportedSBOMStore) LatestByEngagement(_ context.Context, tenantID, engagementID shared.ID) (importedsbom.Record, error)

LatestByEngagement returns a copy of the active imported SBOM.

func (*ImportedSBOMStore) SaveActive

func (s *ImportedSBOMStore) SaveActive(_ context.Context, record importedsbom.Record) error

SaveActive stores a copy of the active imported SBOM for its engagement.

type JobQueue

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

JobQueue is an in-memory ports.JobQueue for dev/single-process + tests, with the same visibility-lease + reclaim semantics as the Postgres adapter (not durable across restarts). Time is injected so tests can exercise lease expiry deterministically.

func NewJobQueue

func NewJobQueue(ids ports.IDGenerator, now func() time.Time) *JobQueue

NewJobQueue returns an in-memory job queue. now may be nil (uses time.Now).

func (*JobQueue) Claim

func (q *JobQueue) Claim(_ context.Context, visibility time.Duration, kinds ...string) (*ports.QueuedJob, error)

func (*JobQueue) Complete

func (q *JobQueue) Complete(_ context.Context, id string) error

func (*JobQueue) Deadletter

func (q *JobQueue) Deadletter(_ context.Context, id string) error

func (*JobQueue) Depth

func (q *JobQueue) Depth(_ context.Context, kinds ...string) (int, error)

Depth counts not-yet-terminal jobs (queued or claimed); 'done'/'failed' are excluded. Optional kind filter (empty = any). Mirrors the Postgres adapter.

func (*JobQueue) Enqueue

func (q *JobQueue) Enqueue(_ context.Context, kind string, payload []byte) (string, error)

func (*JobQueue) Fail

func (q *JobQueue) Fail(_ context.Context, id string, retryIn time.Duration) error

func (*JobQueue) Heartbeat

func (q *JobQueue) Heartbeat(_ context.Context, id string, extend time.Duration) error

type JudgmentStore

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

JudgmentStore is the in-memory judgment repository (dev/tests). It mirrors the Postgres adapter to come: SetScoreState is the ONLY score/state mover and is guarded by optimistic concurrency (expectedVersion → shared.ErrConflict on mismatch), the same discipline as the finding repo's SetEvidenceScore. The score mover is deliberately not exposed on a broad read port.

func NewJudgmentStore

func NewJudgmentStore() *JudgmentStore

NewJudgmentStore returns an empty in-memory judgment store.

func (*JudgmentStore) ListByEngagement

func (s *JudgmentStore) ListByEngagement(_ context.Context, engagementID shared.ID) ([]judgment.Judgment, error)

ListByEngagement returns a copy of the engagement's judgments.

func (*JudgmentStore) ListBySubject

func (s *JudgmentStore) ListBySubject(_ context.Context, engagementID, subjectID shared.ID) ([]judgment.Judgment, error)

ListBySubject returns the engagement's judgments about a given subject id.

func (*JudgmentStore) Save

Save inserts or replaces a judgment within its engagement (idempotent by id).

func (*JudgmentStore) SetScoreState

func (s *JudgmentStore) SetScoreState(_ context.Context, engagementID, id shared.ID, score int, state judgment.State, expectedVersion int) (judgment.Judgment, error)

SetScoreState moves a judgment's score + state under optimistic concurrency. A version mismatch returns shared.ErrConflict (lost-update guard); an unknown id returns shared.ErrNotFound.

type PlanStore

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

PlanStore is the in-memory ports.PlanStore (dev/tests). It mirrors the Postgres adapter's contract: one plan per session, and SavePlan is an optimistic-concurrency CAS on the revision (a stale revision returns ErrConflict). Plans are deep-copied in and out so a caller mutating its own Plan value cannot retroactively change stored state.

func NewPlanStore

func NewPlanStore() *PlanStore

NewPlanStore returns an empty in-memory plan store.

func (*PlanStore) CreatePlan

func (s *PlanStore) CreatePlan(_ context.Context, p agent.Plan) error

func (*PlanStore) GetBySession

func (s *PlanStore) GetBySession(_ context.Context, sessionID shared.ID) (agent.Plan, bool, error)

func (*PlanStore) SavePlan

func (s *PlanStore) SavePlan(_ context.Context, p agent.Plan) error

type ProjectAnalysisStore

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

func NewProjectAnalysisStore

func NewProjectAnalysisStore() *ProjectAnalysisStore

func (*ProjectAnalysisStore) CurrentAnalysisHotspotSummary

func (s *ProjectAnalysisStore) CurrentAnalysisHotspotSummary(ctx context.Context, tenantID, projectID, analysisID shared.ID, lens hotspot.Lens) (hotspot.Summary, error)

func (*ProjectAnalysisStore) Get

func (s *ProjectAnalysisStore) Get(_ context.Context, tenantID, projectID, analysisID shared.ID) (projectanalysis.Analysis, error)

func (*ProjectAnalysisStore) GetHotspot

func (s *ProjectAnalysisStore) GetHotspot(ctx context.Context, tenantID, projectID, hotspotID shared.ID) (hotspot.Hotspot, error)

func (*ProjectAnalysisStore) GetIssue

func (s *ProjectAnalysisStore) GetIssue(ctx context.Context, tenantID, projectID, issueID shared.ID) (issue.Issue, error)

func (*ProjectAnalysisStore) HotspotHistory

func (s *ProjectAnalysisStore) HotspotHistory(ctx context.Context, tenantID, projectID, hotspotID shared.ID) ([]hotspot.ReviewEvent, error)

func (*ProjectAnalysisStore) IssueHistory

func (s *ProjectAnalysisStore) IssueHistory(ctx context.Context, tenantID, projectID, issueID shared.ID) ([]issue.ReviewEvent, error)

func (*ProjectAnalysisStore) LatestForProjects

func (s *ProjectAnalysisStore) LatestForProjects(_ context.Context, tenantID shared.ID, projectIDs []shared.ID) (map[shared.ID]projectanalysis.Analysis, error)

func (*ProjectAnalysisStore) LatestWithResult

func (s *ProjectAnalysisStore) LatestWithResult(_ context.Context, tenantID, projectID shared.ID) (projectanalysis.Analysis, []byte, error)

func (*ProjectAnalysisStore) List

func (s *ProjectAnalysisStore) List(_ context.Context, tenantID, projectID shared.ID, limit int, beforeCreatedAt time.Time, beforeID shared.ID) ([]projectanalysis.Analysis, bool, error)

func (*ProjectAnalysisStore) ListAnalysisHotspots

func (s *ProjectAnalysisStore) ListAnalysisHotspots(ctx context.Context, tenantID, projectID, analysisID shared.ID, lens hotspot.Lens, filter hotspot.ListFilter) (hotspot.Page, hotspot.Summary, error)

func (*ProjectAnalysisStore) ListHotspots

func (s *ProjectAnalysisStore) ListHotspots(ctx context.Context, tenantID, projectID shared.ID, filter hotspot.ListFilter) (hotspot.Page, error)

func (*ProjectAnalysisStore) ListIssues

func (s *ProjectAnalysisStore) ListIssues(ctx context.Context, tenantID, projectID shared.ID, filter issue.ListFilter) (issue.Page, error)

func (*ProjectAnalysisStore) ResolvedIssueKeys

func (s *ProjectAnalysisStore) ResolvedIssueKeys(ctx context.Context, tenantID, projectID shared.ID) (map[string]bool, error)

func (*ProjectAnalysisStore) Save

func (*ProjectAnalysisStore) SaveWithResult

func (s *ProjectAnalysisStore) SaveWithResult(_ context.Context, analysis projectanalysis.Analysis, result []byte) error

func (*ProjectAnalysisStore) SaveWithResultAndHotspots

func (s *ProjectAnalysisStore) SaveWithResultAndHotspots(ctx context.Context, analysis projectanalysis.Analysis, result []byte, candidates []hotspot.Candidate) error

SaveWithResultAndHotspots satisfies ports.ProjectAnalysisProjectionStore; it is the hotspot-only projection (no issues), delegating to the combined path.

func (*ProjectAnalysisStore) SaveWithResultAndProjections

func (s *ProjectAnalysisStore) SaveWithResultAndProjections(_ context.Context, analysis projectanalysis.Analysis, result []byte, candidates []hotspot.Candidate, issues []issue.Candidate) error

func (*ProjectAnalysisStore) TransitionHotspot

func (*ProjectAnalysisStore) TransitionIssue

type ProjectRepository

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

ProjectRepository is a goroutine-safe in-memory project store.

func NewProjectRepository

func NewProjectRepository() *ProjectRepository

func (*ProjectRepository) AssignProfile

func (r *ProjectRepository) AssignProfile(_ context.Context, tenantID shared.ID, projectKey, language, profileKey string) error

func (*ProjectRepository) CountByGate

func (r *ProjectRepository) CountByGate(_ context.Context, tenantID shared.ID, gateID string) (int, error)

func (*ProjectRepository) Create

func (*ProjectRepository) DeleteByKey

func (r *ProjectRepository) DeleteByKey(_ context.Context, tenantID shared.ID, key string) error

func (*ProjectRepository) GetByID

func (r *ProjectRepository) GetByID(_ context.Context, tenantID, projectID shared.ID) (*project.Project, error)

func (*ProjectRepository) GetByKey

func (r *ProjectRepository) GetByKey(_ context.Context, tenantID shared.ID, key string) (*project.Project, error)

func (*ProjectRepository) List

func (r *ProjectRepository) List(_ context.Context, tenantID shared.ID) ([]*project.Project, error)

func (*ProjectRepository) UpdateGate

func (r *ProjectRepository) UpdateGate(_ context.Context, tenantID shared.ID, key, gateID string) error

type QualityGateMutator

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

QualityGateMutator makes managed-gate writes atomic with their audit record in memory.

func NewQualityGateMutator

func NewQualityGateMutator(gates *QualityGateStore, projects *ProjectRepository, audit ports.AuditLogger) *QualityGateMutator

func (*QualityGateMutator) AssignProjectGate

func (m *QualityGateMutator) AssignProjectGate(ctx context.Context, tenantID shared.ID, projectKey, gateID string, entry ports.AuditEntry) error

func (*QualityGateMutator) CreateGate

func (m *QualityGateMutator) CreateGate(ctx context.Context, tenantID shared.ID, gate qualitygate.Gate, entry ports.AuditEntry) error

func (*QualityGateMutator) CreateProjectWithGate

func (m *QualityGateMutator) CreateProjectWithGate(ctx context.Context, p *project.Project) error

func (*QualityGateMutator) DeleteGate

func (m *QualityGateMutator) DeleteGate(ctx context.Context, tenantID shared.ID, key string, entry ports.AuditEntry) error

func (*QualityGateMutator) UpdateGate

func (m *QualityGateMutator) UpdateGate(ctx context.Context, tenantID shared.ID, gate qualitygate.Gate, entry ports.AuditEntry) error

type QualityGateStore

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

QualityGateStore is a goroutine-safe in-memory custom quality-gate store.

func NewQualityGateStore

func NewQualityGateStore() *QualityGateStore

func (*QualityGateStore) Create

func (s *QualityGateStore) Create(_ context.Context, tenantID shared.ID, gate qualitygate.Gate) error

func (*QualityGateStore) Delete

func (s *QualityGateStore) Delete(_ context.Context, tenantID shared.ID, key string) error

func (*QualityGateStore) DeleteIfUnassigned

func (s *QualityGateStore) DeleteIfUnassigned(ctx context.Context, tenantID shared.ID, key string) error

func (*QualityGateStore) Get

func (s *QualityGateStore) Get(_ context.Context, tenantID shared.ID, key string) (qualitygate.Gate, error)

func (*QualityGateStore) List

func (s *QualityGateStore) List(_ context.Context, tenantID shared.ID) ([]qualitygate.Gate, error)

func (*QualityGateStore) Update

func (s *QualityGateStore) Update(_ context.Context, tenantID shared.ID, gate qualitygate.Gate) error

type QualityProfileStore

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

QualityProfileStore is a goroutine-safe in-memory custom quality-profile store.

func NewQualityProfileStore

func NewQualityProfileStore() *QualityProfileStore

func (*QualityProfileStore) Create

func (s *QualityProfileStore) Create(_ context.Context, tenantID shared.ID, profile qualityprofile.Profile) error

func (*QualityProfileStore) Delete

func (s *QualityProfileStore) Delete(_ context.Context, tenantID shared.ID, key string) error

func (*QualityProfileStore) Get

func (*QualityProfileStore) List

func (*QualityProfileStore) Update

func (s *QualityProfileStore) Update(_ context.Context, tenantID shared.ID, profile qualityprofile.Profile) error

type ReconRunRepository

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

ReconRunRepository is an in-memory ports.ReconRunStore for dev/tests.

func NewReconRunRepository

func NewReconRunRepository() *ReconRunRepository

NewReconRunRepository returns an empty in-memory recon-run store.

func (*ReconRunRepository) Get

Get returns a run by id, or shared.ErrNotFound.

func (*ReconRunRepository) ListByEngagement

func (r *ReconRunRepository) ListByEngagement(_ context.Context, engagementID shared.ID) ([]recon.Run, error)

ListByEngagement returns an engagement's runs, newest first.

func (*ReconRunRepository) ListStaleRunning

func (r *ReconRunRepository) ListStaleRunning(_ context.Context, olderThan time.Time, limit int) ([]recon.Run, error)

ListStaleRunning returns runs still 'running' that started before olderThan (≤ limit), oldest first.

func (*ReconRunRepository) Save

func (r *ReconRunRepository) Save(_ context.Context, run recon.Run) error

Save upserts a run.

type RetestRepository

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

RetestRepository is an in-memory ports.RetestRepository for dev/tests.

func NewRetestRepository

func NewRetestRepository() *RetestRepository

NewRetestRepository returns an empty in-memory retest store.

func (*RetestRepository) Add

Add appends a retest.

func (*RetestRepository) ListByEngagementFinding

func (r *RetestRepository) ListByEngagementFinding(_ context.Context, engagementID, findingID shared.ID) ([]finding.Retest, error)

ListByEngagementFinding returns a finding's retests oldest-first, engagement-scoped.

type RunLock

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

RunLock is the single-process ports.RunLocker (F9): an in-memory set of currently- executing run ids. It guards against a same-process redelivery (the in-memory queue's lease expiry) re-running a run that is still in flight. Cross-process guarding requires the Postgres advisory-lock implementation.

func NewRunLock

func NewRunLock() *RunLock

NewRunLock returns an in-memory run locker.

func (*RunLock) TryLock

func (l *RunLock) TryLock(_ context.Context, runID string) (func(), bool, error)

type ScanJobStore

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

ScanJobStore is an in-memory store of asynchronous scan-job status.

func NewScanJobStore

func NewScanJobStore() *ScanJobStore

NewScanJobStore returns an empty in-memory scan-job store.

func (*ScanJobStore) CreateRunning

func (s *ScanJobStore) CreateRunning(_ context.Context, j ports.ScanJob) error

func (*ScanJobStore) GetJob

func (s *ScanJobStore) GetJob(_ context.Context, id string) (ports.ScanJob, error)

GetJob returns a job by its own id, or ErrNotFound.

func (*ScanJobStore) LatestForEngagement

func (s *ScanJobStore) LatestForEngagement(_ context.Context, engagementID shared.ID) (ports.ScanJob, error)

LatestForEngagement returns the engagement's most recent job, or ErrNotFound.

func (*ScanJobStore) LatestForEngagements

func (s *ScanJobStore) LatestForEngagements(_ context.Context, engagementIDs []shared.ID) (map[shared.ID]ports.ScanJob, error)

func (*ScanJobStore) ListStaleRunning

func (s *ScanJobStore) ListStaleRunning(_ context.Context, olderThan time.Time, limit int) ([]ports.ScanJob, error)

ListStaleRunning returns jobs still 'running' that started before olderThan (≤ limit), oldest first.

func (*ScanJobStore) Save

Save upserts a job; a newly-seen id becomes the latest for its engagement.

type ScanRepository

type ScanRepository struct{}

ScanRepository is a no-op scan store for dev/tests: scan results are returned in the API response and not persisted without a database.

func NewScanRepository

func NewScanRepository() *ScanRepository

NewScanRepository returns a no-op scan repository.

func (ScanRepository) SaveScan

SaveScan discards the scan (dev mode has no durable storage); nothing is skipped.

type ScanResultStore

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

ScanResultStore is an in-memory cache of the latest scan result per engagement.

func NewScanResultStore

func NewScanResultStore() *ScanResultStore

NewScanResultStore returns an empty in-memory scan-result store.

func (*ScanResultStore) LatestResult

func (s *ScanResultStore) LatestResult(_ context.Context, engagementID shared.ID) ([]byte, error)

LatestResult returns the cached scan result, or shared.ErrNotFound.

func (*ScanResultStore) SaveResult

func (s *ScanResultStore) SaveResult(_ context.Context, engagementID shared.ID, result []byte) error

SaveResult stores a copy of the engagement's latest scan result JSON.

type ScanRunStore

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

ScanRunStore is an in-memory store of scan-run manifests.

func NewScanRunStore

func NewScanRunStore() *ScanRunStore

NewScanRunStore returns an empty in-memory scan-run store.

func (*ScanRunStore) Get

func (s *ScanRunStore) Get(_ context.Context, runID string) (ports.ScanRun, error)

func (*ScanRunStore) List

func (s *ScanRunStore) List(_ context.Context, engagementID shared.ID) ([]ports.ScanRun, error)

func (*ScanRunStore) Save

func (s *ScanRunStore) Save(_ context.Context, run ports.ScanRun) error

type ThreatModelStore

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

ThreatModelStore is the in-memory architecture-input threat-model store (dev/tests, mirrors the Postgres adapter): one model per engagement, replaced on each Save (re-syncable, not append-only). Reads are engagement-scoped (the tenant gate runs upstream at the child route).

func NewThreatModelStore

func NewThreatModelStore() *ThreatModelStore

NewThreatModelStore returns an empty in-memory threat-model store.

func (*ThreatModelStore) Get

func (s *ThreatModelStore) Get(_ context.Context, engagementID shared.ID) (threatmodel.Model, bool, error)

Get returns the engagement's model, ok=false when none has been ingested.

func (*ThreatModelStore) Save

func (s *ThreatModelStore) Save(_ context.Context, engagementID, _ shared.ID, m threatmodel.Model) error

Save upserts the engagement's model (tenant id unused in memory; the Postgres adapter persists it).

type TimestampStore

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

TimestampStore is an in-memory ports.TimestampStore for dev/tests: external RFC-3161 tokens keyed by (chain, engagement, head).

func NewTimestampStore

func NewTimestampStore() *TimestampStore

NewTimestampStore returns an empty in-memory timestamp store.

func (*TimestampStore) Get

func (s *TimestampStore) Get(_ context.Context, chain string, eng shared.ID, head string) (*ports.TimestampToken, error)

Get returns the stored token for a head, or nil if not yet anchored.

func (*TimestampStore) LatestHead

func (s *TimestampStore) LatestHead(_ context.Context, chain string, eng shared.ID) (string, bool, error)

LatestHead returns the most-recently-Put head for a chain (ok=false if none) – the retained head for out-of-band tail-truncation detection.

func (*TimestampStore) Put

func (s *TimestampStore) Put(_ context.Context, chain string, eng shared.ID, head string, token ports.TimestampToken) error

Put stores a token for a head (idempotent – first write wins, like the SQL ON CONFLICT DO NOTHING).

type UserRepository

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

UserRepository is an in-memory ports.UserRepository for dev/tests.

func NewUserRepository

func NewUserRepository() *UserRepository

NewUserRepository returns an empty in-memory user store.

func (*UserRepository) Create

func (r *UserRepository) Create(_ context.Context, u *user.User) error

func (*UserRepository) GetByAPIKeyHash

func (r *UserRepository) GetByAPIKeyHash(_ context.Context, hash string) (*user.User, error)

func (*UserRepository) GetByID

func (r *UserRepository) GetByID(_ context.Context, id shared.ID) (*user.User, error)

func (*UserRepository) List

func (r *UserRepository) List(_ context.Context) ([]*user.User, error)

func (*UserRepository) Upsert

func (r *UserRepository) Upsert(_ context.Context, u *user.User) error

type WriteupDraftStore

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

WriteupDraftStore is the in-memory write-up-draft repository (dev/tests). It mirrors the Postgres adapter to come: Save is an UPSERT by draft id (a draft is mutable working data – edited then accepted/rejected), and reads are engagement-scoped (tenant isolation is enforced upstream at the route). ListByEngagement returns a deterministic (created_at, id) order to match the SQL adapter.

func NewWriteupDraftStore

func NewWriteupDraftStore() *WriteupDraftStore

NewWriteupDraftStore builds an empty in-memory draft store.

func (*WriteupDraftStore) Get

func (s *WriteupDraftStore) Get(_ context.Context, engagementID, id shared.ID) (writeupdraft.Draft, error)

Get returns the engagement's draft by id, or shared.ErrNotFound.

func (*WriteupDraftStore) ListByEngagement

func (s *WriteupDraftStore) ListByEngagement(_ context.Context, engagementID shared.ID) ([]writeupdraft.Draft, error)

ListByEngagement returns a copy of the engagement's drafts ordered by (created_at, id).

func (*WriteupDraftStore) Save

Save upserts a draft by id within its engagement (replace in place if present, else append).

Jump to

Keyboard shortcuts

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