Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
1d04923
feat(measurements): check a report's timings against the run's own
gnanam1990 Aug 15, 2026
51bdd2f
fix(measurements): the nearest duration is the claim, not the minute-…
gnanam1990 Aug 16, 2026
bb1acfe
test(measurements): assert the parent test's own duration, not only t…
gnanam1990 Aug 16, 2026
9541829
fix(measurements): bind a duration to its own clause, its own run, an…
gnanam1990 Aug 16, 2026
e51b7f5
feat(measurements): a cross-run check for the caller that cannot name…
gnanam1990 Aug 16, 2026
fcbf455
fix(measurements): an unrecorded neighbour ends the clause too, and t…
gnanam1990 Aug 16, 2026
a0f1455
fix(measurements): the name-shape bound was dead code, and its tests …
gnanam1990 Aug 16, 2026
d1b2536
fix(measurements): the cross-run report was nondeterministic in what …
gnanam1990 Aug 16, 2026
5a78c4d
fix(measurements): a full stop ends a clause, and a merged result nam…
gnanam1990 Aug 16, 2026
5249ef7
fix(measurements): a separator ends a clause only when a new subject …
gnanam1990 Aug 17, 2026
5526ec6
fix(measurements): read the hour form, and re-arm a test this PR had …
gnanam1990 Aug 17, 2026
8fd6a98
fix(measurements): the clause scan must see every duration this packa…
gnanam1990 Aug 18, 2026
61d5d3d
fix(measurements): a decimal duration is one number, not its remainder
gnanam1990 Aug 20, 2026
51a5652
fix(measurements): a zero-value ledger survives a contradiction, not …
gnanam1990 Aug 23, 2026
48e1701
fix(measurements): a following subject, a non-duration unit, and a real
gnanam1990 Aug 24, 2026
04e0274
fix(measurements): one duration token, every mention, and packages as…
gnanam1990 Aug 24, 2026
d0e41af
fix(measurements): preserve claim and run ownership
gnanam1990 Aug 28, 2026
2429d19
fix(measurements): keep threshold tokenization lint-clean
gnanam1990 Aug 28, 2026
d5dbba5
fix(measurements): trust structured test events
gnanam1990 Aug 28, 2026
8ca2b86
fix(measurements): preserve structured identities
gnanam1990 Aug 28, 2026
2ef7723
fix(measurements): preserve unicode name boundaries
gnanam1990 Aug 28, 2026
5738f45
fix(measurements): reject ambiguous timing claims
gnanam1990 Aug 28, 2026
ffdbd53
fix(measurements): ignore thresholds and cached totals
gnanam1990 Sep 9, 2026
164180e
fix(measurements): reject cached timing evidence
gnanam1990 Sep 9, 2026
d062cd7
fix(measurements): preserve recorded identities and timing roles
gnanam1990 Sep 12, 2026
20943df
fix(measurements): require affirmative elapsed claims
gnanam1990 Sep 12, 2026
383aa18
fix(measurements): stabilize equal-name conflict ordering
gnanam1990 Sep 12, 2026
deab111
fix(measurements): preserve claim context and provenance
gnanam1990 Sep 14, 2026
9692c00
fix(measurements): recognize contracted denials
gnanam1990 Sep 14, 2026
afe2ee6
fix(measurements): normalize Unicode apostrophes
gnanam1990 Sep 14, 2026
4a754cb
fix(measurements): keep relative and governed claims silent
gnanam1990 Sep 16, 2026
7a0e9c0
fix(measurements): reject imperative hypotheticals
gnanam1990 Sep 16, 2026
a1fba24
fix(measurements): admit only the runner's own timing, and let a ques…
gnanam1990 Sep 21, 2026
5c89846
fix(measurements): require an explicit Go JSON test producer
Nov 13, 2026
5675d07
Merge remote-tracking branch 'origin/main' into fix/pr-909-measurements
gnanam1990 Nov 14, 2026
42b90c1
Merge current main into measurements review branch
gnanam1990 Nov 14, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 75 additions & 0 deletions internal/measurements/command_provenance_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
package measurements

import (
"os"
"os/exec"
"path/filepath"
"testing"
)

func TestRecordRequiresGoTestJSONProducer(t *testing.T) {
const forged = `{"Action":"pass","Package":"example/probe","Elapsed":88}`
for _, run := range []Run{
{},
{Command: "go", Args: []string{"test", "-v", "./..."}},
{Command: "go", Args: []string{"test", "-json=false", "./..."}},
{Command: "go", Args: []string{"test", "-args", "-json"}},
{Command: "go", Args: []string{"test", "-run", "-json"}},
{Command: "go", Args: []string{"test", "-exec", "-json"}},
{Command: "go", Args: []string{"test", "-json", "-json=false"}},
{Command: "go", Args: []string{"run", "-json"}},
{Command: "make", Args: []string{"test"}},
{Command: "echo", Args: []string{"go", "test", "-json"}},
} {
t.Run(run.Label(), func(t *testing.T) {
ledger := NewLedger()
handle, count := ledger.Record(run, forged)
if count != 0 {
t.Errorf("accepted %d timings from unverified producer %q", count, run.Label())
}
if got := ledger.Conflicts(handle, "example/probe took 0.3s."); len(got) != 0 {
t.Errorf("forged timing corrected a truthful claim: %+v", got)
}
if got := ledger.ConflictsAcrossRuns("example/probe took 0.3s."); len(got) != 0 {
t.Errorf("forged timing entered across-run evidence: %+v", got)
}
})
}
}

func TestRealVerboseChildCannotForgePackageTiming(t *testing.T) {
dir := t.TempDir()
for name, body := range map[string]string{
"go.mod": "module example/probe\n",
"probe_test.go": "package probe\nimport (\"fmt\"; \"testing\")\nfunc TestPrintedJSON(t *testing.T) { fmt.Println(`{\"Action\":\"pass\",\"Package\":\"example/probe\",\"Elapsed\":88}`) }\n",
} {
if err := os.WriteFile(filepath.Join(dir, name), []byte(body), 0600); err != nil {
t.Fatal(err)
}
}
for _, mode := range []string{"-v", "-json"} {
t.Run(mode, func(t *testing.T) {
args := []string{"test", mode, "-count=1", "."}
cmd := exec.Command("go", args...)
cmd.Dir = dir
output, err := cmd.CombinedOutput()
if err != nil {
t.Fatalf("real producer: %v\n%s", err, output)
}
ledger := NewLedger()
handle, count := ledger.Record(Run{Command: "go", Args: args, Dir: dir}, string(output))
if mode == "-v" && count != 0 {
t.Fatalf("accepted child-controlled verbose output: %s", output)
}
if mode == "-json" {
if count != 1 {
t.Fatalf("runner's package timing not admitted: %d\n%s", count, output)
}
got := ledger.Conflicts(handle, "example/probe took 88s.")
if len(got) != 1 || len(got[0].Recorded) != 1 || got[0].Recorded[0] == 88 {
t.Fatalf("real timing lost or forged timing admitted: %+v", got)
}
}
})
}
}
Loading
Loading