Enforce runtime report contracts and recoverable session exports
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
package protocol
|
||||
|
||||
import "fmt"
|
||||
|
||||
// ValidateOutputFormat deliberately does not infer a contract from prompt text.
|
||||
// Empty preserves historical behavior. Report filenames are server-owned.
|
||||
func ValidateOutputFormat(format string) error {
|
||||
switch format {
|
||||
case "", "html", "markdown":
|
||||
return nil
|
||||
default:
|
||||
return fmt.Errorf("output_format must be html or markdown (or omitted)")
|
||||
}
|
||||
}
|
||||
@@ -153,6 +153,11 @@ type Message struct {
|
||||
// them; the same fields are echoed on the run record.
|
||||
Model string `json:"model,omitempty"`
|
||||
StageModels map[string]string `json:"stage_models,omitempty"`
|
||||
// OutputFormat is an optional per-run runtime report contract, never a
|
||||
// pipeline definition or model-stage prompt change.
|
||||
OutputFormat string `json:"output_format,omitempty"`
|
||||
// ExportSequence identifies the exact recorded visit for repair_session_export.
|
||||
ExportSequence int `json:"export_sequence,omitempty"`
|
||||
// NotifyMode is auto (definition), on (terminal success/failure and attention) or off
|
||||
// (silence this run). It is optional so older clients keep auto.
|
||||
NotifyMode string `json:"notify_mode,omitempty"`
|
||||
|
||||
+41
-32
@@ -3,18 +3,19 @@ package protocol
|
||||
import "strings"
|
||||
|
||||
const (
|
||||
RunPipeline = "run_pipeline"
|
||||
RunStarted = "run_started"
|
||||
ListRuns = "list_runs"
|
||||
Runs = "runs"
|
||||
GetRun = "get_run"
|
||||
Run = "run"
|
||||
CancelRun = "cancel_run"
|
||||
RetryRun = "retry_run"
|
||||
DecideRun = "decide_run"
|
||||
SetRunTitle = "set_run_title"
|
||||
GetRunEvidence = "get_run_evidence"
|
||||
RunEvidence = "run_evidence"
|
||||
RunPipeline = "run_pipeline"
|
||||
RunStarted = "run_started"
|
||||
ListRuns = "list_runs"
|
||||
Runs = "runs"
|
||||
GetRun = "get_run"
|
||||
Run = "run"
|
||||
CancelRun = "cancel_run"
|
||||
RetryRun = "retry_run"
|
||||
DecideRun = "decide_run"
|
||||
SetRunTitle = "set_run_title"
|
||||
GetRunEvidence = "get_run_evidence"
|
||||
RunEvidence = "run_evidence"
|
||||
RepairSessionExport = "repair_session_export"
|
||||
)
|
||||
|
||||
// Waiting statuses. A human stage pauses its run without a live goroutine, so
|
||||
@@ -107,7 +108,13 @@ type SessionEvidence struct {
|
||||
// and a sanitized diagnostic. It is observed server-side evidence, not a model
|
||||
// claim. A record written before the HTML-only change also carried markdown and
|
||||
// markdown_bytes; readers ignore those fields.
|
||||
// Status explicitly describes evidence completeness, independently from the
|
||||
// stage outcome. Directory and capture time preserve export provenance.
|
||||
type SessionExport struct {
|
||||
Directory string `json:"directory,omitempty"`
|
||||
RecordedAt string `json:"recorded_at,omitempty"`
|
||||
Attempts int `json:"attempts,omitempty"`
|
||||
Status string `json:"status,omitempty"`
|
||||
SessionID string `json:"session_id,omitempty"`
|
||||
Backend string `json:"backend,omitempty"`
|
||||
Source string `json:"source,omitempty"`
|
||||
@@ -145,8 +152,9 @@ type RunSummary struct {
|
||||
// stays reproducible: Model covers every model stage and StageModels overrides
|
||||
// individual stages by key. They are empty for a run that used the pinned
|
||||
// models and for historical rows.
|
||||
Model string `json:"model,omitempty"`
|
||||
StageModels map[string]string `json:"stage_models,omitempty"`
|
||||
Model string `json:"model,omitempty"`
|
||||
StageModels map[string]string `json:"stage_models,omitempty"`
|
||||
OutputFormat string `json:"output_format,omitempty"`
|
||||
}
|
||||
|
||||
// Label is the operator-facing name of a run: the generated Title when the
|
||||
@@ -160,24 +168,25 @@ func (r RunSummary) Label() string {
|
||||
}
|
||||
|
||||
type RunStep struct {
|
||||
Control *ControlEvidence `json:"control,omitempty"`
|
||||
FileChanges *StageFileChanges `json:"file_changes,omitempty"`
|
||||
Verdict *StageVerdict `json:"verdict,omitempty"`
|
||||
SessionExport *SessionExport `json:"session_export,omitempty"`
|
||||
Usage *StageUsage `json:"usage,omitempty"`
|
||||
Notifications []NotificationReceipt `json:"notifications,omitempty"`
|
||||
Artifacts []StageArtifact `json:"artifacts,omitempty"`
|
||||
Sequence int `json:"sequence"`
|
||||
Stage string `json:"stage"`
|
||||
Status string `json:"status"`
|
||||
Outcome string `json:"outcome"`
|
||||
Target string `json:"target"`
|
||||
Input map[string]any `json:"input"`
|
||||
Output map[string]any `json:"output"`
|
||||
Diagnostic string `json:"diagnostic"`
|
||||
SessionID string `json:"session_id"`
|
||||
AgentActive bool `json:"agent_active"`
|
||||
Transcript string `json:"transcript"`
|
||||
Control *ControlEvidence `json:"control,omitempty"`
|
||||
FileChanges *StageFileChanges `json:"file_changes,omitempty"`
|
||||
Verdict *StageVerdict `json:"verdict,omitempty"`
|
||||
SessionExport *SessionExport `json:"session_export,omitempty"`
|
||||
SessionExportRepairs []*SessionExport `json:"session_export_repairs,omitempty"`
|
||||
Usage *StageUsage `json:"usage,omitempty"`
|
||||
Notifications []NotificationReceipt `json:"notifications,omitempty"`
|
||||
Artifacts []StageArtifact `json:"artifacts,omitempty"`
|
||||
Sequence int `json:"sequence"`
|
||||
Stage string `json:"stage"`
|
||||
Status string `json:"status"`
|
||||
Outcome string `json:"outcome"`
|
||||
Target string `json:"target"`
|
||||
Input map[string]any `json:"input"`
|
||||
Output map[string]any `json:"output"`
|
||||
Diagnostic string `json:"diagnostic"`
|
||||
SessionID string `json:"session_id"`
|
||||
AgentActive bool `json:"agent_active"`
|
||||
Transcript string `json:"transcript"`
|
||||
// Provider and Model are the effective provider/model this visit actually ran
|
||||
// with, recorded for every model stage (including failures). They are empty
|
||||
// for non-model stages and historical steps.
|
||||
|
||||
Reference in New Issue
Block a user