Harden model results with lossless isolated repair and scoped permissions

This commit is contained in:
2026-10-09 20:02:41 +01:00
parent 0f80ff4e95
commit 67ac79765f
23 changed files with 977 additions and 58 deletions
+4 -1
View File
@@ -83,7 +83,7 @@ func bar(title, right string, width int, focused bool) string {
func dateLabel(value string) string {
if stamp, err := time.Parse(time.RFC3339, value); err == nil {
return stamp.Format("02 Jan 2006 15:04") + " UTC"
return stamp.UTC().Format("02 Jan 2006 15:04") + " UTC"
}
if value == "" {
return "—"
@@ -311,6 +311,9 @@ func (m Model) stageFields() []stageField {
}
fields = append(fields, stageField{"TOOLS", ansi.Strip(tools)})
}
if policy, ok := stage.Blocks["permissions"]; ok {
fields = append(fields, stageField{"PERMISSIONS", ansi.Strip(policy)})
}
if stage.Notify != nil {
fields = append(fields, stageField{"NOTIFY", "On: " + strings.Join(stage.Notify.On, ", ") + "\nConnection: global\nArtifacts: " + strings.Join(stage.Notify.Artifacts, ", ")})
}
+18 -1
View File
@@ -264,11 +264,19 @@ func valueLines(values map[string]any) []string {
func evidenceLines(step protocol.RunStep) []string {
lines := []string{"Session: " + step.SessionID, "Full evidence remains in the retained OpenCode session."}
if step.SessionID == "" {
lines = []string{"Recorded result evidence"}
}
if step.Transcript == "" {
return append(lines, "No captured tool evidence yet.")
}
var audit struct {
Data []json.RawMessage `json:"data"`
Data []json.RawMessage `json:"data"`
FormatRepairs []struct {
Method string `json:"method"`
Accepted bool `json:"accepted"`
Diagnostic string `json:"diagnostic"`
} `json:"format_repairs"`
}
if json.Unmarshal([]byte(step.Transcript), &audit) != nil {
lines = append(lines, "Audit preview is truncated; showing complete captured messages only.")
@@ -281,6 +289,12 @@ func evidenceLines(step protocol.RunStep) []string {
break
}
if key != "data" {
if key == "format_repairs" {
if decoder.Decode(&audit.FormatRepairs) != nil {
break
}
continue
}
var skip json.RawMessage
if decoder.Decode(&skip) != nil {
break
@@ -302,6 +316,9 @@ func evidenceLines(step protocol.RunStep) []string {
}
}
}
for _, repair := range audit.FormatRepairs {
lines = append(lines, fmt.Sprintf("JSON format repair: %s · accepted: %t", repair.Method, repair.Accepted), repair.Diagnostic)
}
count := 0
for i := len(audit.Data) - 1; i >= 0; i-- {
var message struct {
+17 -1
View File
@@ -54,11 +54,27 @@ func (m Model) runsView(height int) string {
if !m.runGraphFocus {
top, pan = m.runGraphFollow()
}
graph := graphViewport("Run path · actual visits", m.runGraphLines(max(3, m.width-4)), m.width, graphHeight, top, pan, m.runGraphFocus, "g graph/details · arrows pan · j/k scroll · live")
graph := graphViewport(m.runGraphTitle(), m.runGraphLines(max(3, m.width-4)), m.width, graphHeight, top, pan, m.runGraphFocus, "g graph/details · arrows pan · j/k scroll · live")
details := m.runsDetailsView(height - graphHeight)
return fitBlock(strings.Split(graph+"\n"+details, "\n"), m.width, height)
}
func (m Model) runGraphTitle() string {
r := m.runDetail
if r == nil {
return "Run path"
}
durationLabel := "elapsed"
if r.FinishedAt != "" {
durationLabel = "duration"
}
title := "Run path · " + durationLabel + " " + runDuration(r.CreatedAt, r.FinishedAt) + " · started " + dateLabel(r.CreatedAt)
if r.FinishedAt != "" {
title += " · finished " + dateLabel(r.FinishedAt)
}
return title
}
func (m Model) runGraphFollow() (int, int) {
graph := m.runPathGraph()
if len(graph.Stages) == 0 {
+11
View File
@@ -106,6 +106,17 @@ func TestRunningDurationAndOpenCodeEvidenceShortcut(t *testing.T) {
if got := runDuration("2026-10-09T00:00:00Z", "2026-10-09T00:01:02Z"); got != "1m2s" {
t.Fatal("finished duration changed", got)
}
graphModel := New(context.Background(), "")
graphModel.runDetail = &protocol.RunDetail{RunSummary: protocol.RunSummary{CreatedAt: "2026-10-09T00:00:00Z", FinishedAt: "2026-10-09T00:01:02Z"}}
title := graphModel.runGraphTitle()
for _, field := range []string{"duration 1m2s", "started ", "finished "} {
if !strings.Contains(title, field) {
t.Fatal("graph title omitted run timing", title)
}
}
if got := dateLabel("2026-10-09T00:00:00+02:00"); got != "08 Oct 2026 22:00 UTC" {
t.Fatal("start time mislabeled as UTC", got)
}
m := runInspectionModel()
m.runDetail.Steps[1].AgentActive = true
m = runKey(m, "a")