Repository navigation
Done
Labels
Description
Current state
- File:
./pkg/atif/convert_test.go(438 lines, packageatif) - Source pair:
pkg/atif/convert.go - Test functions: 15 top-level
Test*functions with 11t.Runsubtests - Assertions:
requireonly (noassertimport) - Coverage: not measured in this run because the Go module download failed in the sandbox
Strengths
TestConvertEngineVersionandTestConvertRejectsInvalidInputare table-driven, and the latter checks messages withErrorContains- Metric tests (
TestConvertMetrics,TestConvertReconcilesMetricSnapshots,TestConvertMetricScopes) use subtests for each scenario TestConvertConversationchecks determinism, and most index access is guarded byrequire.Len
Prioritized improvements
1. Missing or high-value tests
Validate()intrajectory.go(lines 73-111) has several error branches: non-sequential step IDs, invalid source, agent-only fields, invalid timestamp, invalid tool call, and unsupported schema. Only theunmatched ATIF observationbranch is asserted, throughEncodeat line 411. Add a table test that checks each message withErrorContains.Encode(trajectory.goline 114) has no test for a writer that fails. Add a failingio.Writerand assert the error is returned.reconcileMetrics(metrics.go) has a fallback for ausagefield that is present but not a JSON object. No test input reaches it.- The oversize check at line 391 uses bare
require.Error. Switch it torequire.ErrorContainsso the 64 MiB message is pinned.
2. Testify assertion upgrades
- Validation checks in
TestConvertConversationandTestConvertToolscan useassertso one failing run reports every mismatch. Keeprequirefor setup steps such asrequire.NoErroronConvertandrequire.Lenbefore indexing. TestConvertToolProvenanceScope(lines 174-177) indexesSteps[0],Steps[1], andSteps[3]with norequire.Lenguard.- Unchecked type assertions at lines 98 and 125 panic on mismatch instead of failing cleanly.
Before and after example for the type assertion
// before
raw := trajectory.Steps[6].Extra["unified_event"].(json.RawMessage)
// after
raw, ok := trajectory.Steps[6].Extra["unified_event"].(json.RawMessage)
require.True(t, ok, "unified_event should be json.RawMessage")3. Table-driven refactors
TestConvertNestedCallerContext,TestConvertToolProvenanceScope, andTestEncodeRejectsInvalidTrajectoryeach check a single case. Convert them to table tests when they share setup or when more cases are added.
4. Organization and readability
repeatingReaderis defined inconvert_test.go(packageatif), andspec_test.go(packageatif_test) has its own reader helper. Consolidate the duplicated logic into one test helper file.TestCompatibilityFixtureswrites files as a side effect whenATIF_VALIDATION_DIRis set. Isolate that path in its own test so the side effect is explicit.
Acceptance checklist
- Add a table test for each
Validate()error message - Add a failing-writer test for
Encode - Add a
reconcileMetricstest with a non-objectusagevalue - Change the oversize check to
require.ErrorContains - Add
require.Lenguards inTestConvertToolProvenanceScope - Replace unchecked
json.RawMessageassertions with checked assertions - Move post-setup validations from
requiretoassert - Run
make fmt, thenmake lint - Run
make test-unitand confirmpkg/atifpasses - Measure coverage with
go test -coverprofilebefore and after the change
Generated by 🧪 Daily Testify Uber Super Expert · copilot · routed: haiku55 xhigh · ~8 AIC · ⌖ ~2 AIC · ⊞ 3.9K · ◷
- expires on Nov 16, 2026, 10:10 AM UTC-08:00
Reacted by Copilot
Activity
github-actions commentedon Nov 14, 2026
🍪 Issue Monster selected this for Copilot
I've identified this issue as a good candidate for automated resolution and requested assignment to the Copilot coding agent.
If assignment succeeds, Copilot will analyze the issue and create a pull request with the fix.
Om nom nom! 🍪