feat(trace): record the device a run executed on

meta.json carried the host but not the device, so a trace could not say what
hardware produced it without the campaign manifest beside it. An experiment
splitting cells across api levels could only join them through that manifest.

Claude-Session: https://claude.ai/code/session_01A5KmftdEJ49A9z5mF5ESrX
This commit is contained in:
pj committed 2026-08-18 13:03:42 +05:30
1 parent a7f26e27c4
commit 7b6a346443
4 files changed
+38 -1

No files matched your search

+1
View File
@@ -102,6 +102,7 @@ func buildRunMeta(options Options, bundleSHA256 string, seed int64, host string,
MaxSteps: options.MaxSteps,
DurationMillis: options.Duration.Milliseconds(),
Host: host,
Device: options.Device,
}
if options.Generator == "llm" && hasLLMConfig {
meta.Model = llmConfig.Model
+30
View File
@@ -13,6 +13,7 @@ import (
"github.com/priyanshujain/sanderling/internal/driver"
"github.com/priyanshujain/sanderling/internal/runner"
"github.com/priyanshujain/sanderling/internal/trace"
"github.com/priyanshujain/sanderling/internal/verifier"
)
@@ -222,6 +223,35 @@ func TestBuildRunMeta_RecordsArmMembership(t *testing.T) {
}
}
// The device a run drove has to survive in the run's own artifact. Held only in
// the campaign's runs.jsonl, a trace read on its own cannot say which emulator,
// or which API level, produced it.
func TestBuildRunMeta_RecordsTheDeviceInMetaJSON(t *testing.T) {
directory := t.TempDir()
writer, err := trace.NewWriter(directory)
if err != nil {
t.Fatal(err)
}
defer writer.Close()
options := Options{Platform: "android", Generator: "seeded", Duration: time.Minute, Device: "emulator-5556"}
if err := writer.WriteMeta(buildRunMeta(options, "deadbeef", 3, "farm-01", verifier.LLMConfig{}, false)); err != nil {
t.Fatal(err)
}
body, err := os.ReadFile(filepath.Join(directory, "meta.json"))
if err != nil {
t.Fatal(err)
}
var stored trace.Meta
if err := json.Unmarshal(body, &stored); err != nil {
t.Fatalf("meta.json is not valid JSON: %v\n%s", err, body)
}
if stored.Device != "emulator-5556" {
t.Errorf("device in meta.json: got %q, want emulator-5556\n%s", stored.Device, body)
}
}
func TestBuildRunMeta_OmitsModelWhenSeededPickerRuns(t *testing.T) {
options := Options{Platform: "android", Generator: "seeded", Duration: time.Minute}
meta := buildRunMeta(options, "deadbeef", 1, "farm-01",