* feat: add audit log for feature usage tracking
Add full auditability for all mutating and core API operations across
HTTP, MCP, and system (worker) transports. Audit entries record raw
request/response as JSONB, timing (started_at/ended_at), action, and
transport type.
Backend:
- New audit_log table with JSONB columns for expandability without
future migrations (merge migration of 3 existing heads)
- AuditLogger with fire-and-forget writes via asyncio.create_task
- @audited decorator on 28 HTTP route handlers
- MCP tool audit wrapping for 16 auditable tools
- Worker task execution wrapped with audit_context
- List endpoint with action, transport, date range filters + pagination
- Stats endpoint with per-day counts for charting
- Configurable retention sweep (concurrent-safe DELETE)
Config (env-only, static):
- HINDSIGHT_API_AUDIT_LOG_ENABLED (default: false)
- HINDSIGHT_API_AUDIT_LOG_ACTIONS (comma-separated allowlist, empty=all)
- HINDSIGHT_API_AUDIT_LOG_RETENTION_DAYS (default: -1, keep forever)
Control Plane:
- New "Audit Logs" tab on bank configuration page
- Line chart showing request volume (today/7d/30d) with action filter
- Filterable table with action, transport, date range filters
- Paginated list with detail dialog showing raw request/response JSON
Tests:
- 13 tests covering list, filters, pagination, stats, disabled mode,
action allowlist, and ordering
* fix: split 3-way merge migration into two 2-way merges
Alembic doesn't support 3-parent merge migrations. Split into a no-op
merge of 2 heads (b1c2d3e4f5g6) followed by the audit_log table
migration merging the third head.
* fix: correct merge migration to merge actual 2 heads
The original analysis incorrectly identified 3 heads. There were only 2
(a3b4c5d6e7f8 and c8e5f2a3b4d1). Remove the unnecessary intermediate
merge migration and fix the audit_log migration to merge these 2 heads.
* fix: use 'heads' instead of 'head' in migration runner
Alembic's upgrade('head') fails when multiple heads exist (e.g. from
namespace package overlaps between hindsight-api and hindsight-api-slim).
Using 'heads' (plural) handles this gracefully by upgrading all branches.
* chore: regenerate OpenAPI spec with audit log endpoints
* chore: regenerate TypeScript client and docs skill OpenAPI spec
Python and Go clients still need regeneration (requires Docker).
* chore: regenerate all client SDKs (Python, Go, TypeScript)
Adds generated audit log API clients for Python (audit_api.py),
Go (api_audit.go), and TypeScript client type updates.
|
||
|---|---|---|
| .. | ||
| api | ||
| test | ||
| .gitignore | ||
| api_audit.go | ||
| api_banks.go | ||
| api_directives.go | ||
| api_documents.go | ||
| api_entities.go | ||
| api_files.go | ||
| api_memory.go | ||
| api_mental_models.go | ||
| api_monitoring.go | ||
| api_operations.go | ||
| api_webhooks.go | ||
| client.go | ||
| configuration.go | ||
| go.mod | ||
| go.sum | ||
| hindsight_client.go | ||
| integration_test.go | ||
| model_add_background_request.go | ||
| model_async_operation_submit_response.go | ||
| model_background_response.go | ||
| model_bank_config_response.go | ||
| model_bank_config_update.go | ||
| model_bank_list_item.go | ||
| model_bank_list_response.go | ||
| model_bank_profile_response.go | ||
| model_bank_stats_response.go | ||
| model_budget.go | ||
| model_cancel_operation_response.go | ||
| model_child_operation_status.go | ||
| model_chunk_data.go | ||
| model_chunk_include_options.go | ||
| model_chunk_response.go | ||
| model_clear_memory_observations_response.go | ||
| model_consolidation_response.go | ||
| model_create_bank_request.go | ||
| model_create_directive_request.go | ||
| model_create_mental_model_request.go | ||
| model_create_mental_model_response.go | ||
| model_create_webhook_request.go | ||
| model_delete_document_response.go | ||
| model_delete_response.go | ||
| model_directive_list_response.go | ||
| model_directive_response.go | ||
| model_disposition_traits.go | ||
| model_document_response.go | ||
| model_entity_detail_response.go | ||
| model_entity_include_options.go | ||
| model_entity_input.go | ||
| model_entity_list_item.go | ||
| model_entity_list_response.go | ||
| model_entity_observation_response.go | ||
| model_entity_state_response.go | ||
| model_features_info.go | ||
| model_file_retain_response.go | ||
| model_graph_data_response.go | ||
| model_http_validation_error.go | ||
| model_include_options.go | ||
| model_list_documents_response.go | ||
| model_list_memory_units_response.go | ||
| model_list_tags_response.go | ||
| model_memory_item.go | ||
| model_mental_model_list_response.go | ||
| model_mental_model_response.go | ||
| model_mental_model_trigger.go | ||
| model_not.go | ||
| model_observation_scopes.go | ||
| model_operation_response.go | ||
| model_operation_status_response.go | ||
| model_operations_list_response.go | ||
| model_recall_request.go | ||
| model_recall_request_tag_groups_inner.go | ||
| model_recall_response.go | ||
| model_recall_result.go | ||
| model_recover_consolidation_response.go | ||
| model_reflect_based_on.go | ||
| model_reflect_directive.go | ||
| model_reflect_fact.go | ||
| model_reflect_include_options.go | ||
| model_reflect_llm_call.go | ||
| model_reflect_mental_model.go | ||
| model_reflect_request.go | ||
| model_reflect_response.go | ||
| model_reflect_tool_call.go | ||
| model_reflect_trace.go | ||
| model_retain_request.go | ||
| model_retain_response.go | ||
| model_retry_operation_response.go | ||
| model_source_facts_include_options.go | ||
| model_tag_group_and.go | ||
| model_tag_group_leaf.go | ||
| model_tag_group_not.go | ||
| model_tag_group_or.go | ||
| model_tag_item.go | ||
| model_timestamp.go | ||
| model_token_usage.go | ||
| model_tool_calls_include_options.go | ||
| model_update_directive_request.go | ||
| model_update_disposition_request.go | ||
| model_update_document_request.go | ||
| model_update_document_response.go | ||
| model_update_mental_model_request.go | ||
| model_update_webhook_request.go | ||
| model_validation_error.go | ||
| model_validation_error_loc_inner.go | ||
| model_version_response.go | ||
| model_webhook_delivery_list_response.go | ||
| model_webhook_delivery_response.go | ||
| model_webhook_http_config.go | ||
| model_webhook_list_response.go | ||
| model_webhook_response.go | ||
| null_test.go | ||
| openapi-generator-cli.jar | ||
| openapi-generator-config.yaml | ||
| README.md | ||
| response.go | ||
| trace_test.go | ||
| utils.go | ||
Go API client for hindsight
HTTP API for Hindsight
Overview
This API client was generated by the OpenAPI Generator project. By using the OpenAPI-spec from a remote server, you can easily generate an API client.
- API version: 0.4.11
- Package version: 1.0.0
- Generator version: 7.10.0
- Build package: org.openapitools.codegen.languages.GoClientCodegen
Installation
Install the following dependencies:
go get github.com/stretchr/testify/assert
go get golang.org/x/net/context
Put the package under your project folder and add the following in import:
import hindsight "github.com/vectorize-io/hindsight/hindsight-clients/go"
To use a proxy, set the environment variable HTTP_PROXY:
os.Setenv("HTTP_PROXY", "http://proxy_name:proxy_port")
Configuration of Server URL
Default configuration comes with Servers field that contains server objects as defined in the OpenAPI specification.
Select Server Configuration
For using other server than the one defined on index 0 set context value hindsight.ContextServerIndex of type int.
ctx := context.WithValue(context.Background(), hindsight.ContextServerIndex, 1)
Templated Server URL
Templated server URL is formatted using default variables from configuration or from context value hindsight.ContextServerVariables of type map[string]string.
ctx := context.WithValue(context.Background(), hindsight.ContextServerVariables, map[string]string{
"basePath": "v2",
})
Note, enum values are always validated and all unused variables are silently ignored.
URLs Configuration per Operation
Each operation can use different server URL defined using OperationServers map in the Configuration.
An operation is uniquely identified by "{classname}Service.{nickname}" string.
Similar rules for overriding default operation server index and variables applies by using hindsight.ContextOperationServerIndices and hindsight.ContextOperationServerVariables context maps.
ctx := context.WithValue(context.Background(), hindsight.ContextOperationServerIndices, map[string]int{
"{classname}Service.{nickname}": 2,
})
ctx = context.WithValue(context.Background(), hindsight.ContextOperationServerVariables, map[string]map[string]string{
"{classname}Service.{nickname}": {
"port": "8443",
},
})
Documentation for API Endpoints
All URIs are relative to http://localhost
| Class | Method | HTTP request | Description |
|---|---|---|---|
| BanksAPI | AddBankBackground | Post /v1/default/banks/{bank_id}/background | Add/merge memory bank background (deprecated) |
| BanksAPI | ClearObservations | Delete /v1/default/banks/{bank_id}/observations | Clear all observations |
| BanksAPI | CreateOrUpdateBank | Put /v1/default/banks/{bank_id} | Create or update memory bank |
| BanksAPI | DeleteBank | Delete /v1/default/banks/{bank_id} | Delete memory bank |
| BanksAPI | GetAgentStats | Get /v1/default/banks/{bank_id}/stats | Get statistics for memory bank |
| BanksAPI | GetBankConfig | Get /v1/default/banks/{bank_id}/config | Get bank configuration |
| BanksAPI | GetBankProfile | Get /v1/default/banks/{bank_id}/profile | Get memory bank profile |
| BanksAPI | ListBanks | Get /v1/default/banks | List all memory banks |
| BanksAPI | ResetBankConfig | Delete /v1/default/banks/{bank_id}/config | Reset bank configuration |
| BanksAPI | TriggerConsolidation | Post /v1/default/banks/{bank_id}/consolidate | Trigger consolidation |
| BanksAPI | UpdateBank | Patch /v1/default/banks/{bank_id} | Partial update memory bank |
| BanksAPI | UpdateBankConfig | Patch /v1/default/banks/{bank_id}/config | Update bank configuration |
| BanksAPI | UpdateBankDisposition | Put /v1/default/banks/{bank_id}/profile | Update memory bank disposition |
| DirectivesAPI | CreateDirective | Post /v1/default/banks/{bank_id}/directives | Create directive |
| DirectivesAPI | DeleteDirective | Delete /v1/default/banks/{bank_id}/directives/{directive_id} | Delete directive |
| DirectivesAPI | GetDirective | Get /v1/default/banks/{bank_id}/directives/{directive_id} | Get directive |
| DirectivesAPI | ListDirectives | Get /v1/default/banks/{bank_id}/directives | List directives |
| DirectivesAPI | UpdateDirective | Patch /v1/default/banks/{bank_id}/directives/{directive_id} | Update directive |
| DocumentsAPI | DeleteDocument | Delete /v1/default/banks/{bank_id}/documents/{document_id} | Delete a document |
| DocumentsAPI | GetChunk | Get /v1/default/chunks/{chunk_id} | Get chunk details |
| DocumentsAPI | GetDocument | Get /v1/default/banks/{bank_id}/documents/{document_id} | Get document details |
| DocumentsAPI | ListDocuments | Get /v1/default/banks/{bank_id}/documents | List documents |
| EntitiesAPI | GetEntity | Get /v1/default/banks/{bank_id}/entities/{entity_id} | Get entity details |
| EntitiesAPI | ListEntities | Get /v1/default/banks/{bank_id}/entities | List entities |
| EntitiesAPI | RegenerateEntityObservations | Post /v1/default/banks/{bank_id}/entities/{entity_id}/regenerate | Regenerate entity observations (deprecated) |
| MemoryAPI | ClearBankMemories | Delete /v1/default/banks/{bank_id}/memories | Clear memory bank memories |
| MemoryAPI | GetGraph | Get /v1/default/banks/{bank_id}/graph | Get memory graph data |
| MemoryAPI | GetMemory | Get /v1/default/banks/{bank_id}/memories/{memory_id} | Get memory unit |
| MemoryAPI | ListMemories | Get /v1/default/banks/{bank_id}/memories/list | List memory units |
| MemoryAPI | ListTags | Get /v1/default/banks/{bank_id}/tags | List tags |
| MemoryAPI | RecallMemories | Post /v1/default/banks/{bank_id}/memories/recall | Recall memory |
| MemoryAPI | Reflect | Post /v1/default/banks/{bank_id}/reflect | Reflect and generate answer |
| MemoryAPI | RetainMemories | Post /v1/default/banks/{bank_id}/memories | Retain memories |
| MentalModelsAPI | CreateMentalModel | Post /v1/default/banks/{bank_id}/mental-models | Create mental model |
| MentalModelsAPI | DeleteMentalModel | Delete /v1/default/banks/{bank_id}/mental-models/{mental_model_id} | Delete mental model |
| MentalModelsAPI | GetMentalModel | Get /v1/default/banks/{bank_id}/mental-models/{mental_model_id} | Get mental model |
| MentalModelsAPI | ListMentalModels | Get /v1/default/banks/{bank_id}/mental-models | List mental models |
| MentalModelsAPI | RefreshMentalModel | Post /v1/default/banks/{bank_id}/mental-models/{mental_model_id}/refresh | Refresh mental model |
| MentalModelsAPI | UpdateMentalModel | Patch /v1/default/banks/{bank_id}/mental-models/{mental_model_id} | Update mental model |
| MonitoringAPI | GetVersion | Get /version | Get API version and feature flags |
| MonitoringAPI | HealthEndpointHealthGet | Get /health | Health check endpoint |
| MonitoringAPI | MetricsEndpointMetricsGet | Get /metrics | Prometheus metrics endpoint |
| OperationsAPI | CancelOperation | Delete /v1/default/banks/{bank_id}/operations/{operation_id} | Cancel a pending async operation |
| OperationsAPI | GetOperationStatus | Get /v1/default/banks/{bank_id}/operations/{operation_id} | Get operation status |
| OperationsAPI | ListOperations | Get /v1/default/banks/{bank_id}/operations | List async operations |
Documentation For Models
- AddBackgroundRequest
- AsyncOperationSubmitResponse
- BackgroundResponse
- BankConfigResponse
- BankConfigUpdate
- BankListItem
- BankListResponse
- BankProfileResponse
- BankStatsResponse
- Budget
- CancelOperationResponse
- ChunkData
- ChunkIncludeOptions
- ChunkResponse
- ConsolidationResponse
- CreateBankRequest
- CreateDirectiveRequest
- CreateMentalModelRequest
- CreateMentalModelResponse
- DeleteDocumentResponse
- DeleteResponse
- DirectiveListResponse
- DirectiveResponse
- DispositionTraits
- DocumentResponse
- EntityDetailResponse
- EntityIncludeOptions
- EntityInput
- EntityListItem
- EntityListResponse
- EntityObservationResponse
- EntityStateResponse
- FeaturesInfo
- GraphDataResponse
- HTTPValidationError
- IncludeOptions
- ListDocumentsResponse
- ListMemoryUnitsResponse
- ListTagsResponse
- MemoryItem
- MentalModelListResponse
- MentalModelResponse
- MentalModelTrigger
- OperationResponse
- OperationStatusResponse
- OperationsListResponse
- RecallRequest
- RecallResponse
- RecallResult
- ReflectBasedOn
- ReflectDirective
- ReflectFact
- ReflectIncludeOptions
- ReflectLLMCall
- ReflectMentalModel
- ReflectRequest
- ReflectResponse
- ReflectToolCall
- ReflectTrace
- RetainRequest
- RetainResponse
- TagItem
- TokenUsage
- ToolCallsIncludeOptions
- UpdateDirectiveRequest
- UpdateDispositionRequest
- UpdateMentalModelRequest
- ValidationError
- ValidationErrorLocInner
- VersionResponse
Documentation For Authorization
Endpoints do not require authorization.
Documentation for Utility Methods
Due to the fact that model structure members are all pointers, this package contains a number of utility functions to easily obtain pointers to values of basic types. Each of these functions takes a value of the given basic type and returns a pointer to it:
PtrBoolPtrIntPtrInt32PtrInt64PtrFloatPtrFloat32PtrFloat64PtrStringPtrTime