Documentation
¶
Overview ¶
Package audit owns bounded access/control history. Events have reviewed fields and codes; credentials, content, request URLs and raw failures have no representation here. It borrows the process datastore and cannot drive motion.
Index ¶
Constants ¶
const ( RetentionDays = 30 PageSize = 100 PageMaxBytes = 256 << 10 )
Retention and response limits bound the durable history and each read.
const QueueLimit = 256
QueueLimit is the maximum number of waiting runtime events.
Variables ¶
This section is empty.
Functions ¶
func AppendTx ¶
AppendTx makes an access mutation and its audit record one durable outcome. Callers must propagate failure so the transaction cannot silently omit history.
func CorrelateCommand ¶
CorrelateCommand produces a domain-separated digest without retaining raw IDs.
Types ¶
type Actor ¶
type Actor struct {
Type string `json:"type"`
AccountID string `json:"account_id,omitempty"`
SessionID string `json:"session_id,omitempty"`
}
Actor identifies the authenticated caller or a non-account system/public lane.
func ActingAccount ¶
ActingAccount records the account checked by a domain write, retaining a session reference only when the context belongs to that same account.
func ContextActor ¶
ContextActor returns the caller attribution, defaulting to system work.
type Event ¶
type Event struct {
ID string `json:"id"`
Sequence int64 `json:"sequence"`
OccurredAt int64 `json:"occurred_at_ms"`
Kind Kind `json:"kind"`
Outcome string `json:"outcome"`
Actor Actor `json:"actor"`
TargetAccountID string `json:"target_account_id,omitempty"`
TargetSessionID string `json:"target_session_id,omitempty"`
GrantID string `json:"grant_id,omitempty"`
Operation string `json:"operation,omitempty"`
Epoch string `json:"epoch,omitempty"`
Generation uint64 `json:"generation,omitempty"`
StopSequence uint64 `json:"stop_sequence,omitempty"`
TraceSequence uint64 `json:"trace_sequence,omitempty"`
Correlation string `json:"correlation,omitempty"`
HTTPStatus int `json:"http_status,omitempty"`
Count uint64 `json:"count,omitempty"`
ExpiresAt int64 `json:"expires_at_ms,omitempty"`
Permanent bool `json:"permanent,omitempty"`
}
Event contains only reviewed fields. IDs are server-issued non-authenticating references. Correlation is a digest of the command ID, never the command body, token or private session key.
type Kind ¶
type Kind string
Kind identifies a reviewed access or control transition.
const ( AccountCreated Kind = "account_created" AccountEnabled Kind = "account_enabled" AccountDisabled Kind = "account_disabled" AccountAccessChanged Kind = "account_access_changed" PasswordChanged Kind = "password_changed" PasswordRecovered Kind = "password_recovered" RecoveryCodesReplaced Kind = "recovery_codes_replaced" RecoveryCodesRemoved Kind = "recovery_codes_removed" SessionCreated Kind = "session_created" SessionPolicyChanged Kind = "session_policy_changed" SessionRevoked Kind = "session_revoked" SessionsRevoked Kind = "sessions_revoked" GrantIssued Kind = "grant_issued" GrantRevoked Kind = "grant_revoked" LoginFailed Kind = "login_failed" LoginThrottled Kind = "login_throttled" CredentialCheckFailed Kind = "credential_check_failed" // #nosec G101 -- public event classification, not a credential. CredentialCheckThrottled Kind = "credential_check_throttled" // #nosec G101 -- public event classification, not a credential. ControlClaimed Kind = "control_claimed" ControlTransferred Kind = "control_transferred" ControlLost Kind = "control_lost" CommandFinished Kind = "command_finished" StopFinished Kind = "stop_finished" ServerStarted Kind = "server_started" ServerStopped Kind = "server_stopped" HistoryGap Kind = "history_gap" )
Supported event kinds deliberately exclude free-form application content.
type Page ¶
type Page struct {
Events []Event `json:"events"`
NewestSequence int64 `json:"newest_sequence"`
OldestSequence int64 `json:"oldest_sequence"`
NextBefore int64 `json:"next_before"`
HasMore bool `json:"has_more"`
RetentionDays int `json:"retention_days"`
Limit int `json:"limit"`
RowLimit int `json:"row_limit"`
}
Page is a bounded descending history window with stable sequence pagination.
type Recorder ¶
type Recorder struct {
// contains filtered or unexported fields
}
Recorder never puts database work on a motion/Stop caller. One bounded queue, one writer and short cancelable transactions limit failure and shutdown costs.
func NewRecorder ¶
NewRecorder starts one worker; its owner must close it before the datastore.
func (*Recorder) Close ¶
func (r *Recorder) Close()
Close drains after motion has quiesced, for at most two seconds; a blocked writer is canceled rather than leaking into the next app lifetime.
type Status ¶
type Status struct {
QueueDepth int64 `json:"queue_depth"`
QueueLimit int `json:"queue_limit"`
Dropped uint64 `json:"dropped_since_startup"`
WriteFailures uint64 `json:"write_failures_since_startup"`
StorageAvailable bool `json:"storage_available"`
LastWrite int64 `json:"last_write_ms"`
}
Status reports bounded queue occupancy and explicit loss since process start.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store borrows the shared process database; it does not own its lifetime.