Documentation
¶
Index ¶
- Variables
- func CommitAuditedMutation(ctx context.Context, mutation AuditedMutation, entry model.AuditEntry) error
- type AuditHead
- type AuditedMutation
- type DB
- func (database *DB) AppendEvent(ctx context.Context, event model.EventEnvelope) (bool, error)
- func (database *DB) AppendSecureActionLifecycleMutation(eventID string, expected SecureActionRecord, nodeID, lifecycle string, ...) AuditedMutation
- func (database *DB) AppendSecureActionLifecycleWithAudit(ctx context.Context, eventID string, expected SecureActionRecord, ...) error
- func (database *DB) ApproveEnrollmentRequestMutation(enrollmentID, actorID, operationID, reasonCode string, tags []string, ...) AuditedMutation
- func (database *DB) ApproveEnrollmentRequestWithAudit(ctx context.Context, enrollmentID, actorID, operationID, reasonCode string, ...) error
- func (database *DB) AuditEntryMutation() AuditedMutation
- func (database *DB) Close() error
- func (database *DB) CompareAndSwapNanoCursor(ctx context.Context, programDigest, nodeID string, ...) (bool, error)
- func (database *DB) CompareAndSwapSecureActionMutation(expected, next SecureActionRecord) AuditedMutation
- func (database *DB) CompareAndSwapSecureActionWithAudit(ctx context.Context, expected, next SecureActionRecord, entry model.AuditEntry) error
- func (database *DB) CountSecureActionsByDecision(ctx context.Context, decision string) (int, error)
- func (database *DB) CreateEnrollmentToken(ctx context.Context, token EnrollmentTokenRecord) error
- func (database *DB) CreateEnrollmentTokenMutation(token EnrollmentTokenRecord) AuditedMutation
- func (database *DB) CreateEnrollmentTokenWithAudit(ctx context.Context, token EnrollmentTokenRecord, entry model.AuditEntry) error
- func (database *DB) CreateNanoWatchdogProgramMutation(record NanoWatchdogProgramRecord) AuditedMutation
- func (database *DB) CreateNanoWatchdogProgramWithAudit(ctx context.Context, record NanoWatchdogProgramRecord, entry model.AuditEntry) error
- func (database *DB) CreateSecureActionMutation(record SecureActionRecord) AuditedMutation
- func (database *DB) CreateSecureActionWithAudit(ctx context.Context, record SecureActionRecord, entry model.AuditEntry) error
- func (database *DB) DenyEnrollmentRequestMutation(enrollmentID, actorID, operationID, reasonCode string, now time.Time) AuditedMutation
- func (database *DB) DenyEnrollmentRequestWithAudit(ctx context.Context, enrollmentID, actorID, operationID, reasonCode string, ...) error
- func (database *DB) EnrollNode(ctx context.Context, tokenHash []byte, now time.Time, node model.Node) error
- func (database *DB) EnrollNodeRequestWithAudit(ctx context.Context, tokenHash []byte, now time.Time, requestID string, ...) error
- func (database *DB) EnrollNodeWithAudit(ctx context.Context, tokenHash []byte, now time.Time, node model.Node, ...) error
- func (database *DB) GetAuditHead(ctx context.Context) (AuditHead, error)
- func (database *DB) GetEnrollmentRequest(ctx context.Context, id string) (EnrollmentRequestRecord, error)
- func (database *DB) GetEnrollmentRequestByToken(ctx context.Context, tokenID string) (EnrollmentRequestRecord, error)
- func (database *DB) GetEnrollmentToken(ctx context.Context, tokenHash []byte, now time.Time) (EnrollmentTokenRecord, error)
- func (database *DB) GetEnrollmentTokenByOperation(ctx context.Context, operationID string) (EnrollmentTokenRecord, error)
- func (database *DB) GetEvent(ctx context.Context, eventID string) (model.EventEnvelope, error)
- func (database *DB) GetNanoWatchdogProgram(ctx context.Context, id string) (NanoWatchdogProgramRecord, error)
- func (database *DB) GetNanoWatchdogProgramByOperation(ctx context.Context, operationID string) (NanoWatchdogProgramRecord, error)
- func (database *DB) GetNode(ctx context.Context, id string) (model.Node, error)
- func (database *DB) GetNodeEventState(ctx context.Context, nodeID string) (NodeEventState, error)
- func (database *DB) GetProjectionCursor(ctx context.Context, projection string) (ProjectionCursor, error)
- func (database *DB) GetSecureAction(ctx context.Context, id string) (SecureActionRecord, error)
- func (database *DB) GetSecureActionAuditEvent(ctx context.Context, eventID string) (SecureActionAuditEventRecord, error)
- func (database *DB) GetSecureActionByOperationID(ctx context.Context, operationID string) (SecureActionRecord, error)
- func (database *DB) GetSecureActionByRequestID(ctx context.Context, requestID string) (SecureActionRecord, error)
- func (database *DB) GetSecureActionExecutionState(ctx context.Context, actionID string) (SecureActionExecutionState, error)
- func (database *DB) Health(ctx context.Context) error
- func (database *DB) InsertAuditEntry(ctx context.Context, entry model.AuditEntry) error
- func (database *DB) LastAuditHash(ctx context.Context) (string, error)
- func (database *DB) ListAuditEntries(ctx context.Context, limit int) ([]model.AuditEntry, error)
- func (database *DB) ListAuditEntriesAfter(ctx context.Context, afterSequence uint64, limit int) ([]model.AuditEntry, error)
- func (database *DB) ListEvents(ctx context.Context, after time.Time, limit int) ([]model.EventEnvelope, error)
- func (database *DB) ListEventsFromOrdinal(ctx context.Context, afterOrdinal uint64, limit int) ([]model.EventEnvelope, error)
- func (database *DB) ListEventsPage(ctx context.Context, after time.Time, afterEventID string, limit int) ([]model.EventEnvelope, error)
- func (database *DB) ListLatestEventsForNode(ctx context.Context, nodeID string, kinds []string) ([]model.EventEnvelope, error)
- func (database *DB) ListNanoWatchdogPrograms(ctx context.Context, nodeID string) ([]NanoWatchdogProgramRecord, error)
- func (database *DB) ListNodes(ctx context.Context) ([]model.Node, error)
- func (database *DB) ListSecureActions(ctx context.Context, decision string, limit int) ([]SecureActionRecord, error)
- func (database *DB) LoadNanoCursor(ctx context.Context, programDigest, nodeID string) (NanoCursorRecord, error)
- func (database *DB) PruneEvents(ctx context.Context, cutoff time.Time, requiredProjections []string, ...) (RetentionResult, error)
- func (database *DB) PruneEventsWithCutoffs(ctx context.Context, cutoffs EventRetentionCutoffs, ...) (RetentionResult, error)
- func (database *DB) ResolveEnrollmentReplay(ctx context.Context, tokenHash []byte, requestID string, requestDigest []byte) (model.Node, error)
- func (database *DB) ResolveEnrollmentRequestReplay(ctx context.Context, tokenHash []byte, requestID string, requestDigest []byte) (EnrollmentRequestRecord, error)
- func (database *DB) SaveNanoCursor(ctx context.Context, programDigest, nodeID string, record NanoCursorRecord, ...) error
- func (database *DB) SetNodeStatus(ctx context.Context, id string, status model.NodeStatus, now time.Time) error
- func (database *DB) SetNodeStatusMutation(nodeID string, status model.NodeStatus, now time.Time) AuditedMutation
- func (database *DB) SetNodeStatusWithAudit(ctx context.Context, id string, status model.NodeStatus, now time.Time, ...) error
- func (database *DB) SetProjectionCursor(ctx context.Context, cursor ProjectionCursor) error
- func (database *DB) SubmitEnrollmentRequestMutation(tokenHash []byte, now time.Time, record EnrollmentRequestRecord) AuditedMutation
- func (database *DB) SubmitEnrollmentRequestWithAudit(ctx context.Context, tokenHash []byte, now time.Time, ...) error
- func (database *DB) UpdateNodeMetadataMutation(nodeID, name string, tags []string) AuditedMutation
- func (database *DB) UpdateNodeMetadataWithAudit(ctx context.Context, id, name string, tags []string, entry model.AuditEntry) error
- func (database *DB) VerifyEventRetentionTombstones(ctx context.Context) error
- type EnrollmentRequestRecord
- type EnrollmentTokenRecord
- type EventRetentionCutoffs
- type NanoCursorRecord
- type NanoWatchdogProgramRecord
- type NanoWatchdogStatus
- type NodeEventState
- type ProjectionCursor
- type RetentionResult
- type SecureActionAuditEventRecord
- type SecureActionExecutionState
- type SecureActionRecord
Constants ¶
This section is empty.
Variables ¶
var ( ErrAuditHeadConflict = errors.New("audit head changed concurrently") ErrAuditedMutationRequired = errors.New("a storage-issued audited mutation is required") )
var ( ErrEnrollmentRequestNotFound = errors.New("enrollment request not found") ErrEnrollmentRequestDecided = errors.New("enrollment request has already been decided") ErrEnrollmentRequestExpired = errors.New("enrollment request has expired") ErrCredentialReused = errors.New("node credential has already been admitted or proposed") ErrNodeIdentityUsed = errors.New("node identity has already been admitted or proposed") )
var ( ErrEventSequenceConflict = errors.New("event sequence conflicts with a different stored event") ErrEventSequenceGap = errors.New("event sequence is not contiguous") ErrEventBootRegression = errors.New("event boot id was already closed") ErrEventNotFound = errors.New("event not found") )
var ( ErrEnrollmentTokenInvalid = errors.New("enrollment token is invalid") ErrEnrollmentTokenExpired = errors.New("enrollment token has expired") ErrEnrollmentTokenUsed = errors.New("enrollment token has already been used") ErrNodeNotFound = errors.New("node not found") ErrNodeRevoked = errors.New("revoked node must be re-enrolled with new credentials") ErrOperationConflict = errors.New("operation id has already been used") )
var ( ErrRetentionProjectionNotReady = errors.New("required projection has not durably processed events") ErrRetentionIntegrity = errors.New("event retention tombstone chain failed verification") )
var ( ErrSecureActionNotFound = errors.New("secure action not found") ErrSecureActionConflict = errors.New("secure action id was reused with different input") ErrSecureActionAuditConflict = errors.New("secure action audit event id was reused with different input") ErrOneTimeGrantConsumed = errors.New("one-time authorization was already consumed or expired") ErrInvalidActionLifecycle = errors.New("secure action lifecycle transition is invalid") )
var ErrProgramConflict = errors.New("node already admits a program with this digest")
ErrProgramConflict reports that a node already has an admitted program with this content digest. The table carries two uniqueness guarantees, so a replay can trip either one; SQLite checks (node_id, program_digest) first.
Functions ¶
func CommitAuditedMutation ¶
func CommitAuditedMutation(ctx context.Context, mutation AuditedMutation, entry model.AuditEntry) error
Types ¶
type AuditedMutation ¶
type AuditedMutation interface {
// contains filtered or unexported methods
}
AuditedMutation is a closed capability: only this package can implement it. Each implementation commits one reviewed domain transition and the supplied signed audit entry in the same SQLite transaction. This prevents callers from acknowledging an audit entry after an unrelated mutation committed.
type DB ¶
type DB struct {
// contains filtered or unexported fields
}
func (*DB) AppendEvent ¶
func (*DB) AppendSecureActionLifecycleMutation ¶
func (database *DB) AppendSecureActionLifecycleMutation( eventID string, expected SecureActionRecord, nodeID, lifecycle string, requestDigest []byte, occurredAt, now time.Time, ) AuditedMutation
func (*DB) AppendSecureActionLifecycleWithAudit ¶
func (database *DB) AppendSecureActionLifecycleWithAudit( ctx context.Context, eventID string, expected SecureActionRecord, nodeID, lifecycle string, requestDigest []byte, occurredAt, now time.Time, entry model.AuditEntry, ) error
AppendSecureActionLifecycleWithAudit makes lifecycle event idempotency and one-time grant consumption part of the same transaction as the signed audit entry. The SDK_ACTION_EXECUTION_STARTED transition is the authoritative single-use boundary until a dedicated token-bearing consume call is added.
func (*DB) ApproveEnrollmentRequestMutation ¶
func (*DB) ApproveEnrollmentRequestWithAudit ¶
func (*DB) AuditEntryMutation ¶
func (database *DB) AuditEntryMutation() AuditedMutation
func (*DB) CompareAndSwapNanoCursor ¶
func (database *DB) CompareAndSwapNanoCursor(ctx context.Context, programDigest, nodeID string, previous, next NanoCursorRecord, now time.Time) (bool, error)
CompareAndSwapNanoCursor advances a cursor only if it still equals the evaluation input. This prevents concurrent Core requests from both exposing a proposal for one schedule tick.
func (*DB) CompareAndSwapSecureActionMutation ¶
func (database *DB) CompareAndSwapSecureActionMutation(expected, next SecureActionRecord) AuditedMutation
func (*DB) CompareAndSwapSecureActionWithAudit ¶
func (database *DB) CompareAndSwapSecureActionWithAudit(ctx context.Context, expected, next SecureActionRecord, entry model.AuditEntry) error
CompareAndSwapSecureActionWithAudit replaces only the decision projection and lifecycle timestamps when every mutable field still matches the record the caller read. The audit entry is committed in the same transaction. This prevents a delayed evaluator or authorizer from clearing a consumed grant.
func (*DB) CountSecureActionsByDecision ¶
func (*DB) CreateEnrollmentToken ¶
func (database *DB) CreateEnrollmentToken(ctx context.Context, token EnrollmentTokenRecord) error
func (*DB) CreateEnrollmentTokenMutation ¶
func (database *DB) CreateEnrollmentTokenMutation(token EnrollmentTokenRecord) AuditedMutation
func (*DB) CreateEnrollmentTokenWithAudit ¶
func (database *DB) CreateEnrollmentTokenWithAudit(ctx context.Context, token EnrollmentTokenRecord, entry model.AuditEntry) error
func (*DB) CreateNanoWatchdogProgramMutation ¶
func (database *DB) CreateNanoWatchdogProgramMutation(record NanoWatchdogProgramRecord) AuditedMutation
func (*DB) CreateNanoWatchdogProgramWithAudit ¶
func (database *DB) CreateNanoWatchdogProgramWithAudit(ctx context.Context, record NanoWatchdogProgramRecord, entry model.AuditEntry) error
func (*DB) CreateSecureActionMutation ¶
func (database *DB) CreateSecureActionMutation(record SecureActionRecord) AuditedMutation
func (*DB) CreateSecureActionWithAudit ¶
func (database *DB) CreateSecureActionWithAudit(ctx context.Context, record SecureActionRecord, entry model.AuditEntry) error
CreateSecureActionWithAudit commits the initial decision and its signed audit entry in one SQLite transaction.
func (*DB) DenyEnrollmentRequestMutation ¶
func (database *DB) DenyEnrollmentRequestMutation( enrollmentID, actorID, operationID, reasonCode string, now time.Time, ) AuditedMutation
func (*DB) DenyEnrollmentRequestWithAudit ¶
func (*DB) EnrollNode ¶
func (*DB) EnrollNodeRequestWithAudit ¶
func (*DB) EnrollNodeWithAudit ¶
func (*DB) GetEnrollmentRequest ¶
func (*DB) GetEnrollmentRequestByToken ¶
func (*DB) GetEnrollmentToken ¶
func (*DB) GetEnrollmentTokenByOperation ¶
func (*DB) GetNanoWatchdogProgram ¶
func (*DB) GetNanoWatchdogProgramByOperation ¶
func (*DB) GetNodeEventState ¶
func (*DB) GetProjectionCursor ¶
func (*DB) GetSecureAction ¶
func (*DB) GetSecureActionAuditEvent ¶
func (*DB) GetSecureActionByOperationID ¶
func (*DB) GetSecureActionByRequestID ¶
func (*DB) GetSecureActionExecutionState ¶
func (*DB) InsertAuditEntry ¶
func (*DB) ListAuditEntries ¶
func (*DB) ListAuditEntriesAfter ¶
func (*DB) ListEvents ¶
func (*DB) ListEventsFromOrdinal ¶
func (*DB) ListEventsPage ¶
func (*DB) ListLatestEventsForNode ¶
func (database *DB) ListLatestEventsForNode(ctx context.Context, nodeID string, kinds []string) ([]model.EventEnvelope, error)
ListLatestEventsForNode returns at most one durable event per requested kind, choosing the greatest observed time and then the greatest ingest ordinal. It is intentionally a storage read, not a cache, so topology and path views cannot outlive retention or report facts that were never committed.
func (*DB) ListNanoWatchdogPrograms ¶
func (*DB) ListSecureActions ¶
func (*DB) LoadNanoCursor ¶
func (*DB) PruneEvents ¶
func (database *DB) PruneEvents(ctx context.Context, cutoff time.Time, requiredProjections []string, batchSize int) (RetentionResult, error)
PruneEvents deletes a bounded batch only after every required durable projection has advanced through the candidate. It never compacts audit data.
func (*DB) PruneEventsWithCutoffs ¶
func (database *DB) PruneEventsWithCutoffs( ctx context.Context, cutoffs EventRetentionCutoffs, requiredProjections []string, batchSize int, ) (RetentionResult, error)
PruneEventsWithCutoffs applies privacy-reducing class and sensitivity overrides while preserving the projection gate and a chained deletion receipt. Tombstone metadata is committed atomically with source deletion.
func (*DB) ResolveEnrollmentReplay ¶
func (*DB) ResolveEnrollmentRequestReplay ¶
func (*DB) SaveNanoCursor ¶
func (*DB) SetNodeStatus ¶
func (*DB) SetNodeStatusMutation ¶
func (database *DB) SetNodeStatusMutation(nodeID string, status model.NodeStatus, now time.Time) AuditedMutation
func (*DB) SetNodeStatusWithAudit ¶
func (*DB) SetProjectionCursor ¶
func (database *DB) SetProjectionCursor(ctx context.Context, cursor ProjectionCursor) error
func (*DB) SubmitEnrollmentRequestMutation ¶
func (database *DB) SubmitEnrollmentRequestMutation(tokenHash []byte, now time.Time, record EnrollmentRequestRecord) AuditedMutation
func (*DB) SubmitEnrollmentRequestWithAudit ¶
func (database *DB) SubmitEnrollmentRequestWithAudit( ctx context.Context, tokenHash []byte, now time.Time, record EnrollmentRequestRecord, entry model.AuditEntry, ) error
func (*DB) UpdateNodeMetadataMutation ¶
func (database *DB) UpdateNodeMetadataMutation(nodeID, name string, tags []string) AuditedMutation
func (*DB) UpdateNodeMetadataWithAudit ¶
func (*DB) VerifyEventRetentionTombstones ¶
VerifyEventRetentionTombstones checks the complete local deletion-receipt chain and its transactionally maintained head. A separately protected witness is still required to detect coordinated rollback of the whole DB.
type EnrollmentRequestRecord ¶
type EnrollmentRequestRecord struct {
ID string
TokenID string
RequestID string
RequestDigest []byte
Status string
ProposedNodeID string
DisplayName string
NodeType string
Platform string
PlatformVersion string
PublicKey []byte
CapabilitiesJSON json.RawMessage
AllowedTags []string
RequestedAt time.Time
ExpiresAt time.Time
DecisionReasonCode string
DecisionOperationID string
DecidedByPrincipalID string
DecidedAt *time.Time
ApprovedTags []string
NodeID string
}
type EnrollmentTokenRecord ¶
type EventRetentionCutoffs ¶
type EventRetentionCutoffs struct {
DefaultBefore time.Time
ByClassification map[model.EvidenceClass]time.Time
BySensitivity map[model.Sensitivity]time.Time
}
EventRetentionCutoffs defines the oldest record each class may retain. Class and sensitivity cutoffs may only move forward from DefaultBefore, making overrides privacy-preserving reductions rather than covert extensions.
type NanoCursorRecord ¶
NanoCursorRecord is the durable scheduling state for one admitted Nano watchdog program on one active node. It contains no program source or input.
type NanoWatchdogProgramRecord ¶
type NanoWatchdogProgramRecord struct {
ID string
NodeID string
Name string
Source string
ProgramDigest string
BindingID string
Status NanoWatchdogStatus
OperationID string
CreatedAt time.Time
UpdatedAt time.Time
}
NanoWatchdogProgramRecord preserves the reviewed source and its canonical digest. It never stores a finding frame, provider secret, or proposed action.
type NanoWatchdogStatus ¶
type NanoWatchdogStatus string
const ( NanoWatchdogAdmitted NanoWatchdogStatus = "ADMITTED" NanoWatchdogDisabled NanoWatchdogStatus = "DISABLED" )
type NodeEventState ¶
type ProjectionCursor ¶
type RetentionResult ¶
type SecureActionRecord ¶
type SecureActionRecord struct {
ID string
RequestID string
ApplicationID string
OperationID string
Decision string
RequestJSON []byte
DecisionJSON []byte
CreatedAt time.Time
UpdatedAt time.Time
ReleasedAt *time.Time
BypassExpiresAt *time.Time
}
SecureActionRecord is the durable transport-neutral state for a protected application action. RequestJSON and DecisionJSON are canonical JSON; callers must never place application payloads or bearer credentials in either field.
func (SecureActionRecord) RequestMatches ¶
func (record SecureActionRecord) RequestMatches(canonical []byte) bool
RequestMatches reports whether a retry is byte-for-byte identical to the canonical request already committed for this action.