{"modulePath":"github.com/GoCodeAlone/workflow-plugin-cms","version":"v0.1.10","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package audit\n\nPackage audit emits HMAC-signed audit-chain entries for admin mutations. Per gocodealone-multisite SPEC.md T26.\n\nThe chain links each entry to the prior entry's signature, so any row mutation invalidates the chain from that point forward. The signing key (MULTISITE\\_AUDIT\\_SIGN\\_KEY) is rotated via the \\`wfctl multisite audit-rotate\\` runbook (docs/runbook/backup.md).\n\nIn-memory Sink ships here; production wires a postgres-backed Sink via workflow-plugin-audit-chain (separate module).\n\n## Types\n\n```go\ntype Entry struct {\n\tID         int64\n\tOccurredAt time.Time\n\tActor      string // user_id (or \"system\" for bootstrap entries)\n\tTenantID   int64  // 0 for cross-tenant ops\n\tAction     string // \"tenant.create\", \"page.update\", etc.\n\tSubject    string // resource id (\"page:42\")\n\tMeta       map[string]any\n\tPrevSig    string // hex; \"\" for the first entry\n\tSig        string // HMAC-SHA256(prev_sig || canonical(entry))\n}\n```\nEntry is one audit record.\n\n```go\ntype Logger struct {\n\t// contains filtered or unexported fields\n}\n```\nLogger produces signed entries + appends them to the configured Sink.\n\n```go\nfunc New(signKey string, sink Sink) *Logger\n```\nNew returns a Logger. signKey must be non-empty.\n\n```go\nfunc (l *Logger) Record(actor string, tenantID int64, action, subject string, meta map[string]any) (Entry, error)\n```\nRecord signs + appends one entry. Always returns the canonical stored copy.\n\n```go\nfunc (l *Logger) Verify(tenantID int64) (int, error)\n```\nVerify walks the chain returned by Sink.List + returns the first index that breaks (i.e. the first row whose stored Sig does not match the recomputed value). Returns -1 if the whole chain verifies.\n\n```go\ntype MemorySink struct {\n\t// contains filtered or unexported fields\n}\n```\nMemorySink stores audit entries in-process. Used for tests + local dev.\n\n```go\nfunc NewMemorySink() *MemorySink\n```\n\n```go\nfunc (s *MemorySink) Append(e Entry) (Entry, error)\n```\n\n```go\nfunc (s *MemorySink) List(tenantID int64) ([]Entry, error)\n```\n\n```go\ntype Sink interface {\n\tAppend(entry Entry) (Entry, error)\n\tList(tenantID int64) ([]Entry, error)\n}\n```\nSink persists audit entries.\n\n","path":"github.com/GoCodeAlone/workflow-plugin-cms/audit","name":"audit","synopsis":"Package audit emits HMAC-signed audit-chain entries for admin mutations.","isRedistributable":true}
