feat: opencode plugin that warns on restated figures (#14)
build / test (push) Has been cancelled
build / image (push) Has been cancelled

Adds knox claims check (JSON on stdin) and a server plugin that runs it from
the session 'context' hook, which fires before every request is dispatched.

Staleness is measured against earlier *prose*, not earlier tool output. That is
the correction that makes this work: the incident had a tool printing
'6884 deletions' while the prose said '6,884 lines', so matching tool output by
number+unit classified the real failure as unsupported and stayed silent. A
figure repeated from an earlier turn without fresh evidence is the thing worth
warning about, and the first assertion is deliberately quiet.

Every failure path in the plugin is swallowed: missing binary, timeout, bad
JSON. A guardrail must not break what it guards.
This commit is contained in:
2026-11-04 18:49:54 -08:00
parent 029c5078ba
commit 12fe148cd9
5 changed files with 307 additions and 12 deletions
+6 -11
View File
@@ -205,10 +205,10 @@ type LintRun struct {
// quoted from an earlier turn count as unsourced.
func Lint(s *Session) []LintRun {
var out []LintRun
var turnOutputs, earlierOutputs []string
var turnOutputs []string
var priorProse strings.Builder
for _, m := range s.Messages {
if m.Role == "user" {
earlierOutputs = append(earlierOutputs, turnOutputs...)
turnOutputs = nil
continue
}
@@ -217,16 +217,11 @@ func Lint(s *Session) []LintRun {
continue
}
prose := strings.Join(m.Text, "\n")
for _, f := range Mark(Extract(prose), turnOutputs) {
run := LintRun{MessageID: m.ID, Seq: m.Seq, Finding: f, Status: Sourced}
if !f.Sourced {
run.Status = Unsupported
if len(Mark([]Finding{f}, earlierOutputs)) == 1 && Mark([]Finding{f}, earlierOutputs)[0].Sourced {
run.Status = Stale
}
}
out = append(out, run)
for _, sc := range Classify(Extract(prose), turnOutputs, priorProse.String()) {
out = append(out, LintRun{MessageID: m.ID, Seq: m.Seq, Finding: sc.Finding, Status: sc.Status})
}
priorProse.WriteString(prose)
priorProse.WriteString("\n")
}
return out
}