Add version two LLM reports and safe execution diagnostics
This commit is contained in:
@@ -13,9 +13,12 @@ const (
|
||||
ArtifactNormalizationSummary = "normalization-summary.json"
|
||||
ArtifactChunkingSummary = "chunking-summary.json"
|
||||
ArtifactUtilizationSummary = "utilization-diagnostics.json"
|
||||
ArtifactLLMExecution = "llm-execution.json"
|
||||
ArtifactSelectedProfiles = "selected-profiles.yaml"
|
||||
ArtifactConfigOrigins = "config-origins.yaml"
|
||||
ArtifactCorrectionLedger = "correction-ledger.json"
|
||||
ArtifactInvocationMetadata = "invocation.json"
|
||||
ArtifactEffectiveConfig = "effective-config.yaml"
|
||||
ArtifactEffectiveConfig = "effective-config.redacted.yaml"
|
||||
ArtifactReport = "report.json"
|
||||
ArtifactErrorLog = "error.log"
|
||||
)
|
||||
@@ -29,6 +32,8 @@ func BuildDiagnosticsMetadata(runDirectoryPath string, runSucceeded bool) report
|
||||
NormalizationSummaryPath: filepath.Join(runDirectoryPath, ArtifactNormalizationSummary),
|
||||
ChunkingSummaryPath: filepath.Join(runDirectoryPath, ArtifactChunkingSummary),
|
||||
UtilizationSummaryPath: filepath.Join(runDirectoryPath, ArtifactUtilizationSummary),
|
||||
LLMExecutionPath: filepath.Join(runDirectoryPath, ArtifactLLMExecution),
|
||||
SelectedProfilesPath: filepath.Join(runDirectoryPath, ArtifactSelectedProfiles),
|
||||
CorrectionLedgerPath: filepath.Join(runDirectoryPath, ArtifactCorrectionLedger),
|
||||
InvocationMetadataPath: filepath.Join(runDirectoryPath, ArtifactInvocationMetadata),
|
||||
RedactedEffectiveConfigPath: filepath.Join(runDirectoryPath, ArtifactEffectiveConfig),
|
||||
|
||||
@@ -54,6 +54,7 @@ type InvocationMetadata struct {
|
||||
ReportJSONPath string `json:"report_json_path,omitempty"`
|
||||
ConfigPath string `json:"config_path,omitempty"`
|
||||
ConfigSource string `json:"config_source,omitempty"`
|
||||
Overlay string `json:"overlay,omitempty"`
|
||||
ConfigVersion *int `json:"config_version,omitempty"`
|
||||
TranscriptDescription string `json:"transcript_description,omitempty"`
|
||||
Modules []string `json:"modules"`
|
||||
@@ -222,6 +223,13 @@ func (r *RunDirectory) WriteJSONArtifact(name string, payload any) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r *RunDirectory) WriteArtifact(name string, payload []byte) error {
|
||||
if err := os.WriteFile(filepath.Join(r.path, name), payload, 0o644); err != nil {
|
||||
return fmt.Errorf("failed to write %s: %w", name, err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r *RunDirectory) ApplyRetention(input RetentionDecisionInput) error {
|
||||
decision := input
|
||||
if decision.RetentionMode == "" {
|
||||
|
||||
58
internal/core/reporting/llm.go
Normal file
58
internal/core/reporting/llm.go
Normal file
@@ -0,0 +1,58 @@
|
||||
package reporting
|
||||
|
||||
// TokenMetric distinguishes measured zero from unavailable provider usage.
|
||||
type TokenMetric struct {
|
||||
Value int `json:"value"`
|
||||
Known bool `json:"known"`
|
||||
Complete bool `json:"complete"`
|
||||
}
|
||||
|
||||
type LLMUsage struct {
|
||||
Prompt TokenMetric `json:"prompt"`
|
||||
Completion TokenMetric `json:"completion"`
|
||||
Total TokenMetric `json:"total"`
|
||||
Cached TokenMetric `json:"cached"`
|
||||
CacheWrite TokenMetric `json:"cache_write"`
|
||||
}
|
||||
|
||||
type LLMSummary struct {
|
||||
LogicalCalls uint64 `json:"logical_calls"`
|
||||
ProviderAttempts uint64 `json:"provider_attempts"`
|
||||
TransientRetries uint64 `json:"transient_retries"`
|
||||
StructuralRepairs uint64 `json:"structural_repairs"`
|
||||
Usage LLMUsage `json:"usage"`
|
||||
}
|
||||
|
||||
type BackendUtilization struct {
|
||||
Concurrency int `json:"concurrency"`
|
||||
QueueCapacity int `json:"queue_capacity"`
|
||||
LLMSummary
|
||||
CapacityWaitMS int64 `json:"capacity_wait_ms"`
|
||||
GenerationMS int64 `json:"generation_ms"`
|
||||
RetryDelayMS int64 `json:"retry_delay_ms"`
|
||||
LogicalWallMS int64 `json:"logical_wall_ms"`
|
||||
}
|
||||
|
||||
type UtilizationDiagnostics struct {
|
||||
Backends map[string]BackendUtilization `json:"backends"`
|
||||
RunWallTimeMS int64 `json:"run_wall_time_ms"`
|
||||
Modules []ModuleUtilization `json:"modules,omitempty"`
|
||||
Validators []ValidatorUtilization `json:"validators,omitempty"`
|
||||
}
|
||||
|
||||
type ModuleUtilization struct {
|
||||
ModuleKey string `json:"module_key"`
|
||||
ModuleInstance string `json:"module_instance"`
|
||||
ProposalLLMCalls uint64 `json:"proposal_llm_calls"`
|
||||
ValidationLLMCalls uint64 `json:"validation_llm_calls"`
|
||||
ModuleWallTimeMS int64 `json:"module_wall_time_ms"`
|
||||
}
|
||||
|
||||
type ValidatorUtilization struct {
|
||||
ModuleKey string `json:"module_key"`
|
||||
ModuleInstance string `json:"module_instance"`
|
||||
ValidatorKey string `json:"validator_key"`
|
||||
LLMBacked bool `json:"llm_backed"`
|
||||
Calls int `json:"calls"`
|
||||
ElapsedMS int64 `json:"elapsed_ms"`
|
||||
}
|
||||
@@ -30,13 +30,14 @@ type ProcessReport struct {
|
||||
NormalizationSkipped NormalizationSkipped `json:"normalization_skipped,omitempty"`
|
||||
Chunking *ChunkingSummary `json:"chunking,omitempty"`
|
||||
Diagnostics *DiagnosticsMetadata `json:"diagnostics,omitempty"`
|
||||
LLMSummary *LLMSummary `json:"llm_summary,omitempty"`
|
||||
ModulesSummary *ModulesSummary `json:"modules_summary,omitempty"`
|
||||
ModuleResults []ModuleReport `json:"module_results,omitempty"`
|
||||
}
|
||||
|
||||
const (
|
||||
DefaultProcessReportSchemaName = "audita-process-report"
|
||||
DefaultProcessReportSchemaVersion = "v1"
|
||||
DefaultProcessReportSchemaVersion = "v2"
|
||||
)
|
||||
|
||||
type ReportMetadata struct {
|
||||
@@ -98,6 +99,8 @@ type DiagnosticsMetadata struct {
|
||||
NormalizationSummaryPath string `json:"normalization_summary_path,omitempty"`
|
||||
ChunkingSummaryPath string `json:"chunking_summary_path,omitempty"`
|
||||
UtilizationSummaryPath string `json:"utilization_summary_path,omitempty"`
|
||||
LLMExecutionPath string `json:"llm_execution_path,omitempty"`
|
||||
SelectedProfilesPath string `json:"selected_profiles_path,omitempty"`
|
||||
CorrectionLedgerPath string `json:"correction_ledger_path,omitempty"`
|
||||
InvocationMetadataPath string `json:"invocation_metadata_path,omitempty"`
|
||||
RedactedEffectiveConfigPath string `json:"redacted_effective_config_path,omitempty"`
|
||||
|
||||
Reference in New Issue
Block a user