feat(eval): add input_id passthrough field to preserve caller-supplied correlation ID in results output#2857
Conversation
d426295 to
3487a36
Compare
| assert.Equal(t, "Auto-generated title", sess.Title) | ||
| } | ||
|
|
||
| func TestInputIDPassthrough(t *testing.T) { |
There was a problem hiding this comment.
[MEDIUM] TestInputIDPassthrough is tautological — it does not exercise the runSingleEval copy path
The test manually assigns sess.InputID = knownInputID and then immediately asserts sess.InputID == knownInputID. That assertion is trivially true regardless of what runSingleEval does — removing the copy line result.Session.InputID = evalSess.Session.InputID in eval.go would not cause this test to fail.
The actual behaviour being fixed — that InputID flows from the deserialized evalSess.Session through runSingleEval into result.Session — is left uncovered. A regression in eval.go would be silent.
Suggested fix: test the end-to-end path. At minimum, construct an InputSession with Session.InputID pre-populated, call runSingleEval (or a lightweight helper that mirrors its copy logic), and assert the output result.Session.InputID equals the input value. Alternatively, add a round-trip integration test that writes a .json eval file containing "input_id", runs the evaluator, and checks that the field appears in the result.
…d correlation ID in results output
3487a36 to
075149f
Compare
Plan: Preserve caller-supplied
"input_id"from input eval JSON in results output1. Goal Restatement
Each eval input is one
.jsonfile in a directory. When a file contains a top-level"input_id"field, that value must be carried through untouched to the corresponding session entry in the results output (the*.jsonfile and the SQLite.dbfile). The session's own"id"(a random UUID) is never touched — it is always freshly generated as today."input_id"is simply a new passthrough field. If the input file has no"input_id", the field is absent from the output — no change to existing behaviour.2. User-side: Before vs After
"input_id": "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"docker agent eval"id"91907fe1-cd72-4e88-b1a5-1b439675f7c5(random UUID)91907fe1-cd72-4e88-b1a5-1b439675f7c5(same random UUID)"input_id""aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"— carried through from the input fileinput_idis gone"input_id"input_idin outputinput_idin output ✅3. Root Cause
loadEvalSessionsdeserializes each.jsonfile intosession.Sessionviajson.Unmarshal.session.Sessionhas noInputIDfield, so"input_id"from the file is silently discarded right at load time and never reaches the output.4. Affected Files
pkg/session/session.goInputID stringfield (`json:"input_id,omitempty"`) to theSessionstruct.pkg/evaluation/eval.goSessionFromEvents, copyevalSess.Session.InputID→result.Session.InputID.pkg/evaluation/save_test.goTestSessionFromEventsPreservesInputIDthat verifiesinput_idis carried through andidis still a fresh UUID.No changes needed to
SessionFromEvents,session.New, or any other file.5. Step-by-Step Approach
Step 1 — Add
InputIDfield tosession.Sessioninsession.goIn the
Sessionstruct, add after theIDfield:omitemptyensures the field is absent from output JSON when empty — no change for existing eval files that don't include it.Verify:
go build ./...compiles clean.Step 2 — Copy
InputIDthrough ineval.goIn
runSingleEval, after the existing line:add:
evalSess.Session.InputIDis already populated byjson.UnmarshalinloadEvalSessions(from Step 1). When the input file had no"input_id", it is an empty string andomitemptykeeps it out of the output — correct behaviour.Verify:
go build ./pkg/evaluation/...compiles clean.Step 3 — Add test
TestInputIDPassthroughtosave_test.goAdd a test that:
InputSessionwhoseSession.InputIDis set to a known value.SessionFromEventsand copiesInputIDas in Step 2.result.Session.InputIDequals the known value.result.Session.IDis a non-empty UUID different fromInputID(i.e. the random UUID was not disturbed).Verify:
go test ./pkg/evaluation/... -run TestInputIDPassthroughpasses.Step 4 — Run the full test suite
go test ./...All pre-existing tests must continue to pass with no regressions.
6. Risks and Unknowns
"input_id"input_idis purely a passthrough label, not used as a key anywhere. No uniqueness constraint applies.InputIDtosession.Sessionaffects unrelated session serializationomitemptymeans the field is invisible in all existing sessions that don't set it.session.Sessionas JSON blob —input_idwill be included automatically7. Open Questions
None.