Reconcile reuse and inspection with native extraction
This commit is contained in:
@@ -15,21 +15,7 @@ import (
|
||||
"gitea.maximumdirect.net/eric/narratio/internal/pathsafe"
|
||||
)
|
||||
|
||||
const (
|
||||
maxReceiptBytes = 1 << 20
|
||||
maxIndexBytes = 4 << 20
|
||||
maxSummaryBytes = 4 << 20
|
||||
canonicalIndexFile = "index.json"
|
||||
canonicalManifestFile = "manifest.json"
|
||||
canonicalRejectedFile = "rejected.json"
|
||||
canonicalWarningsFile = "warnings.json"
|
||||
canonicalDiagnosticsFile = "diagnostics.json"
|
||||
warningsSchemaVersion = "notarius.warnings.v2"
|
||||
diagnosticsSchemaVersion = "notarius.diagnostics.v1"
|
||||
maxWarningGroups = 128
|
||||
maxDiagnosticGroups = 256
|
||||
maxFindingSamples = 3
|
||||
)
|
||||
const maxReportBytes = 1 << 20
|
||||
|
||||
type subprocessRun func(context.Context, subprocess.RunRequest) (subprocess.RunResult, error)
|
||||
|
||||
@@ -64,16 +50,16 @@ func (r *SubprocessRunner) Run(ctx context.Context, req RunRequest) (RunResult,
|
||||
WorkingDir: req.WorkingDirectory,
|
||||
Timeout: req.Timeout,
|
||||
DiagnosticOwner: "notarius",
|
||||
StdoutLogPath: req.ReceiptPath,
|
||||
StdoutLogPath: req.ReportPath,
|
||||
StderrLogPath: req.LogPath,
|
||||
EnvOverrides: envOverrides,
|
||||
SensitiveEnvNames: sensitiveEnvNames,
|
||||
})
|
||||
baseResult := RunResult{
|
||||
ReceiptPath: req.ReceiptPath,
|
||||
LogPath: req.LogPath,
|
||||
ExitCode: processResult.ExitCode,
|
||||
Duration: processResult.Duration,
|
||||
ReportPath: req.ReportPath,
|
||||
LogPath: req.LogPath,
|
||||
ExitCode: processResult.ExitCode,
|
||||
Duration: processResult.Duration,
|
||||
}
|
||||
if err != nil {
|
||||
return baseResult, fmt.Errorf("run notarius pipeline %q: %w", req.PipelineID, err)
|
||||
@@ -81,7 +67,7 @@ func (r *SubprocessRunner) Run(ctx context.Context, req RunRequest) (RunResult,
|
||||
if processResult.ExitCode != 0 {
|
||||
return baseResult, fmt.Errorf("run notarius pipeline %q: exit code %d", req.PipelineID, processResult.ExitCode)
|
||||
}
|
||||
report, err := loadCompletionReport(req.ReceiptPath, req.PipelineID)
|
||||
report, err := loadCompletionReport(req.ReportPath, req.PipelineID)
|
||||
if err != nil {
|
||||
return baseResult, err
|
||||
}
|
||||
@@ -128,7 +114,7 @@ func loadCompletionReport(path, pipelineID string) (CompletionReport, error) {
|
||||
DebugDirectory string `json:"debug_directory"`
|
||||
FallbackCount *int `json:"fallback_count"`
|
||||
}
|
||||
if err := decodeBoundedJSON(path, maxReceiptBytes, &document); err != nil {
|
||||
if err := decodeBoundedJSON(path, maxReportBytes, &document); err != nil {
|
||||
return CompletionReport{}, fmt.Errorf("decode notarius completion report: %w", err)
|
||||
}
|
||||
if document.Pipeline != pipelineID || document.ArtifactCount == nil || *document.ArtifactCount < 0 || !filepath.IsAbs(document.OutputDirectory) {
|
||||
@@ -165,7 +151,7 @@ func validateRunRequest(req RunRequest) ([]ReferenceBinding, error) {
|
||||
"input": req.InputPath,
|
||||
"output root": req.OutputRoot,
|
||||
"working directory": req.WorkingDirectory,
|
||||
"receipt": req.ReceiptPath,
|
||||
"report": req.ReportPath,
|
||||
"log": req.LogPath,
|
||||
"debug directory": req.DebugDirectory,
|
||||
} {
|
||||
@@ -176,8 +162,8 @@ func validateRunRequest(req RunRequest) ([]ReferenceBinding, error) {
|
||||
return nil, fmt.Errorf("notarius %s path must be absolute", label)
|
||||
}
|
||||
}
|
||||
if filepath.Clean(req.ReceiptPath) == filepath.Clean(req.LogPath) {
|
||||
return nil, fmt.Errorf("notarius receipt and log paths must be different")
|
||||
if filepath.Clean(req.ReportPath) == filepath.Clean(req.LogPath) {
|
||||
return nil, fmt.Errorf("notarius report and log paths must be different")
|
||||
}
|
||||
references := make([]ReferenceBinding, 0, len(req.References))
|
||||
selectors := make(map[string]struct{}, len(req.References))
|
||||
@@ -210,8 +196,8 @@ func validateRunRequest(req RunRequest) ([]ReferenceBinding, error) {
|
||||
if err := requireDirectory(req.WorkingDirectory); err != nil {
|
||||
return nil, fmt.Errorf("validate notarius working directory: %w", err)
|
||||
}
|
||||
if err := validateLogDestination(req.ReceiptPath); err != nil {
|
||||
return nil, fmt.Errorf("validate notarius receipt path: %w", err)
|
||||
if err := validateLogDestination(req.ReportPath); err != nil {
|
||||
return nil, fmt.Errorf("validate notarius report path: %w", err)
|
||||
}
|
||||
if err := validateLogDestination(req.LogPath); err != nil {
|
||||
return nil, fmt.Errorf("validate notarius log path: %w", err)
|
||||
|
||||
Reference in New Issue
Block a user