Skip to content

Improve ATIF conversion test coverage - #77823

Merged
pelikhan merged 2 commits into
mainfrom
copilot/testify-expert-improve-test-quality
Nov 15, 2026
Merged

pelikhan merged 2 commits into
mainfrom
copilot/testify-expert-improve-test-quality

Conversation

@gh-aw-bot

@gh-aw-bot gh-aw-bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Collaborator

ATIF tests missed several Trajectory.Validate rejection paths and edge cases in Encode and metric reconciliation. Some assertions could panic on type mismatches, and fixture verification included an opt-in file-writing side effect.

  • Coverage: Add table-driven validation cases for each error message, an Encode failing-writer test, and non-object usage reconciliation coverage. Pin the 64 MiB input-limit message.
  • Safer assertions: Check raw JSON types explicitly, guard indexed steps, and use assert for post-setup conversation and tool validations.
  • Organization: Make nested-caller, provenance-scope, and invalid-trajectory cases table-driven; move the repeated-reader helper to a shared test helper; isolate fixture output writes in a dedicated opt-in test.
require.ErrorContains(t, trajectory.Validate(), tc.want)

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
@gh-aw-bot gh-aw-bot changed the title [WIP] Improve test quality for convert_test.go Improve ATIF conversion test coverage Nov 14, 2026
@pelikhan
pelikhan marked this pull request as ready for review November 14, 2026 20:29
Copilot AI adaptive review requested due to automatic review settings November 14, 2026 20:29
@github-actions

github-actions Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

✅ Test Quality Sentinel completed test quality analysis.

Test Quality Sentinel

Outcome: reported_no_action

The agent completed and reported no action. A no-op output alone does not verify that all required work was completed or that publication was possible.

Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.

🧪 Test quality analysis by Test Quality Sentinel · copilot · routed: haiku55 xhigh · ~1 AIC · ⌖ ~2 AIC · ◇ ~1 AIC · ⊞ 7.2K · ◷

@github-actions

github-actions Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

✅ PR Specification Reviewer completed successfully!

PR Specification Reviewer

Outcome: reported_action

The agent completed and reported one or more actions. The no-op output is a completion signal, not a claim that no action was taken.

Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.

Generated by PR Specification Reviewer for #77823 · copilot · gpt56 · ~2 AIC · ⌖ ~1 AIC · ◇ ~1 AIC · ⊞ 1.6K · ◷

@github-actions

github-actions Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

🧠 Matt Pocock Skills Reviewer has completed the skills-based review. ✅

Matt Pocock Skills Reviewer

Outcome: reported_action

The agent completed and reported one or more actions. The no-op output is a completion signal, not a claim that no action was taken.

Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · copilot · routed: haiku55 xhigh · ~8 AIC · ⌖ ~2 AIC · ⊞ 6.6K · ◷

@github-actions

github-actions Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

✅ PR Code Quality Reviewer completed the code quality review.

PR Code Quality Reviewer

Outcome: reported_action

The agent completed and reported one or more actions. The no-op output is a completion signal, not a claim that no action was taken.

Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.

🔎 Code quality review by PR Code Quality Reviewer · copilot · gpt56 · ~3 AIC · ⌖ ~1 AIC · ◇ ~1 AIC · ⊞ 1.5K · ◷

@github-actions

github-actions Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

✅ Ponytail Reviewer completed successfully!

Generated by Ponytail Reviewer for #77823 · codex · routed: gpt61 medium · ~5 AIC · ⌖ ~1 AIC · ◇ ~1 AIC · ⊞ 185 · ◷

@github-actions

github-actions Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

✅ Design Decision Gate 🏗️ completed the design decision gate check. See the comment below for the result and any generated ADR draft.

🏗️ ADR gate enforced by Design Decision Gate 🏗️ · pi · routed: haiku55 xhigh · ~2 AIC · ⌖ ~2 AIC · ◇ ~1 AIC · ⊞ 8.6K · ◷

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What this change does: It expands ATIF validation and encoding tests and separates optional fixture output from fixture checks. It also makes several assertions safer.

Should fix

  1. The encoding test repeats cases already covered by validation and public API tests. Restore the original unmatched-observation test to keep the useful encoding check with less code.

Verdict: Ship.
Lean: -32 lines possible.

Generated by ✂️ Ponytail Reviewer for #77823 · codex · routed: gpt61 medium · ~5 AIC · ⌖ ~1 AIC · ⊞ 185
Comment /ponytail to run again

Comment thread pkg/atif/convert_test.go
var output bytes.Buffer
require.ErrorContains(t, Encode(&output, trajectory), "unmatched")
require.Empty(t, output.String())
for _, tc := range []struct {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Should fix — Remove duplicate encoding cases: Encode returns validation errors directly, while the new validation table covers both cases and TestSpec_PublicAPI_EncodeValidatesBeforeWriting already checks nil input and empty output. Restore the original unmatched-observation test; this keeps the encoding check while removing 32 lines that would otherwise need maintaining.

@github-actions

Copy link
Copy Markdown
Contributor

🏗️ Design Decision Gate — ADR Needed, No Architectural Decision Found

ADR enforcement was triggered by volume: this PR adds 325 lines under pkg/ and has no implementation label or .design-gate.yml. All of those lines are in test files, and no production code changed. I did not find an architectural decision to document, so I did not generate a draft ADR.

Next action: a maintainer should confirm whether this test-only change is exempt. If it is not exempt, add an ADR under docs/adr/ and link it in the PR body.

🔍 Evidence
  • Trigger: no implementation label; no custom config; default_business_additions = 325 (> 100)
  • Files (all test code): pkg/atif/convert_test.go (+308/−68), pkg/atif/spec_test.go (+1/−14), pkg/atif/spec_test_helpers_test.go (+16, new)
  • ADR in PR body: none. Fixes #77821 links to a test-quality checklist with no ADR content.
  • ADR in docs/adr/: no file references PR Improve ATIF conversion test coverage #77823.
  • Decision check: the changes are test-quality edits: assert vs require for non-setup checks, table-driven cases, a failing-writer test, Validate() error cases, moving the repeatingReader helper into its own file, and isolating the ATIF_VALIDATION_DIR fixture writer. None changes a design choice such as an API, storage, dependency, or production behavior.
❓ Why no draft ADR

A draft ADR needs a real decision with real alternatives. The closest candidates here (test helper placement and assertion style) are local conventions within the existing testify pattern, so an ADR would document style rather than architecture. The 100-line threshold also counts test code. A maintainer may want to decide whether test-only changes should count toward it.

🏗️ ADR gate enforced by Design Decision Gate 🏗️ · pi · routed: haiku55 xhigh · ~2 AIC · ⌖ ~2 AIC · ⊞ 8.6K · ◷
Comment /review to run again

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues are present, and the changes add targeted coverage and safer assertions across the affected conversion and validation paths.

No open issues 🎉

What changed in this PR

Improves ATIF conversion test coverage and assertion safety while isolating optional fixture-writing behavior.

Changes:

  • Adds table-driven Trajectory.Validate cases, failing-writer Encode coverage, and non-object usage reconciliation tests.
  • Strengthens raw JSON type checks, setup assertions, and bounds guards.
  • Refactors provenance and nested-caller tests, shares the repeating-reader helper, and pins the documented 64 MiB input-limit error.
File Description
pkg/​atif/​spec_test.go Pins the documented 64 MiB input-limit error and removes the local repeating-reader helper.
pkg/​atif/​spec_test_helpers_test.go Provides the shared repeating-reader test helper.
pkg/​atif/​convert_test.go Expands validation, metric, encoding, assertion-safety, provenance, and fixture-output test coverage.

Review effort: Lite (dynamic)

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Found one test-coverage issue: several validation cases only assert the same generic error substring, so they can pass without exercising the named rejection rule. I left an inline comment at the table entry. The remaining changes appear scoped and safe based on static review; tests were not run per review instructions.

🔎 Code quality review by PR Code Quality Reviewer · copilot · gpt50 · ~3 AIC · ⌖ ~1 AIC · ⊞ 1.5K
Comment /review to run again

Comment thread pkg/atif/convert_test.go
mutate: func(trajectory *Trajectory) {
trajectory.Agent.Name = ""
},
want: "supported schema",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These cases all assert only the generic supported schema substring, so they do not prove the specific validation rule named by each test. A regression that rejects every malformed trajectory with that same message would still pass the missing-name, missing-version, no-steps, and unsupported-schema cases. Please assert the rule-specific error (or otherwise distinguish the cases) so this table actually covers each rejection path.

@github-actions

Copy link
Copy Markdown
Contributor

Comment Memory

Peek at saved memory (spec-review-history)
{"id":"ldg-c1e43ee0-3414-4e54-827f-e6cb8378a258","parents":[],"payload":{"id":"ldg-3bbcc966-8c7a-41a9-a2a1-9b4d939af6e5","operation":"append","value":{"finding_count":0,"head_sha":"a37cfb9f75ae4bd1d048d11017feade12d27a0e6","outcome":"aligned"}},"sha":"sha256:3e1d1e61f1a420739c166eed10e76964a110d4c62631b717206f66ee76c838d0","timestamp":"2026-11-14T20:37:17.380Z","type":"ledger_append","version":1}
History

@github-actions

Copy link
Copy Markdown
Contributor

Comment Memory

Peek at saved memory (review-history)
{"id":"ldg-dd48a303-384e-4b7e-8388-6eea6c8996ed","parents":[],"payload":{"id":"ldg-2fd21f8a-754e-4f46-ad93-edbf6254cda0","operation":"append","value":{"finding_count":1,"head_sha":"a37cfb9f75ae4bd1d048d11017feade12d27a0e6","outcome":"findings"}},"sha":"sha256:3913623c9f6cee3aaca40d61df084bd1e63217cf889032e9ab5a88b435eb877e","timestamp":"2026-11-14T20:38:03.672Z","type":"ledger_append","version":1}
History

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Skills-Based Review 🧠

Applied /tdd (coverage and assertion strength). Requesting changes on the provenance metrics tests.

📋 Key Themes & Highlights

Key Themes

  • Vacuous provenance metrics assertions: the phase and path cases put "component":"detection" on session.result, which isPrimaryEvent drops. Their CompletionTokens == nil assertions pass regardless of scoping.
  • Limit-path coverage: the removed repeatingReader oversize test in spec_test.go was replaced by a public-API assertion, which covers the behavior. A convert-level regression test would make the 64 MiB limit branch in convert.go (lines 96–101) easier to maintain.

Positive Highlights

  • ✅ Validate and Encode tests now cover all rejection branches, and Encode writes nothing on rejection.
  • ✅ Good use of table-driven tests with descriptive names.
  • ✅ go test, go vet (including the integration tag), and gofmt are clean.

Unverified

  • golangci-lint is not installed in this environment, so the lint status is unknown.

@copilot please address the review comments above.

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · copilot · routed: haiku55 xhigh · ~8 AIC · ⌖ ~2 AIC · ⊞ 6.6K
Comment /matt to run again

Comment thread pkg/atif/convert_test.go
start: `"path":"parent.jsonl","phase":"first"`,
mismatch: `"path":"parent.jsonl","phase":"second"`,
match: `"path":"parent.jsonl","phase":"first"`,
metrics: `"path":"parent.jsonl","phase":"detection","component":"detection"`,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[/tdd] This phase case passes for the wrong reason. The session.result line carries "component":"detection", and isPrimaryEvent (pkg/atif/convert.go:182) accepts only an empty or agent component, so the event is dropped before its metrics are read. The path case at line 190 has the same defect.

A local probe showed that without the component, a mismatched phase still reports 999 output tokens, so this test does not establish that phase scopes terminal metrics. Decide the intended scoping rule, then use a primary metrics line and assert the value it should produce.

@copilot please address this.

Comment thread pkg/atif/convert_test.go
require.Len(t, trajectory.Steps[0].Observation.Results, 1)
assert.Equal(t, "correct scope", trajectory.Steps[0].Observation.Results[0].Content)
assert.Equal(t, "system", trajectory.Steps[1].Source)
assert.Nil(t, trajectory.FinalMetrics.CompletionTokens)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[/tdd] This Nil assertion is vacuous. With the metrics line above, CompletionTokens is always nil, so the test would still pass if phase scoping broke. Once the metrics line is fixed, assert the concrete expected value (for example require.NotNil followed by assert.Equal(t, int64(999), *trajectory.FinalMetrics.CompletionTokens)).

@copilot please address this.

@pelikhan
pelikhan merged commit 42a34d5 into main Nov 15, 2026
146 checks passed
@pelikhan
pelikhan deleted the copilot/testify-expert-improve-test-quality branch November 15, 2026 04:50
@github-actions

Copy link
Copy Markdown
Contributor

🎉 This pull request is included in a new release.

Release: v1.3.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[testify-expert] Improve Test Quality: ./pkg/atif/convert_test.go

4 participants