Skip to content

feat(0.2): finish Track 3 centerpiece — integration / e2e / unified PR comment#145

Open
pmclSF wants to merge 1 commit intomainfrom
feat/0.2-track3-finish
Open

feat(0.2): finish Track 3 centerpiece — integration / e2e / unified PR comment#145
pmclSF wants to merge 1 commit intomainfrom
feat/0.2-track3-finish

Conversation

@pmclSF
Copy link
Copy Markdown
Owner

@pmclSF pmclSF commented May 2, 2026

Summary

The three Track 3 deliverables that close the pitch's "maps how
your unit, integration, e2e, and AI tests actually relate to your
code" promise. Track 3 is the centerpiece of the parity-gated
0.2.0 plan; this PR finishes the three remaining items (3.3–3.5).

  • Track 3.3 — Integration-test classification rigor.
    Content-based detection of HTTP-testing libraries (supertest,
    httptest, MockMvc, requests, etc.) so integration tests living
    alongside unit tests in flat directories are correctly classified.
  • Track 3.4 — E2E-to-code attribution honest carve-out.
    Documents the exact limit of e2e attribution in 0.2 — structural-
    only, with the deeper coverage-instrumented path explicitly out
    of scope until 0.3.
  • Track 3.5 — Unified PR-comment rendering audit. A render-
    golden test enforces the visual contract: bracketed [LABEL]
    badges, **\path`**` locators, em-dash separators, and a single
    recommended-tests stanza for unit + integration + e2e.

What changed

New code (internal/testtype/, internal/analysis/):

  • integration_imports.go — pattern allowlist (30+ patterns
    across JS/TS, Go, Python, Java, Ruby) + InferFromContent and
    MergeContentInference helpers
  • integration_classification.go — analyzer wiring that reads each
    test file once via the existing FileCache and refines the
    test-type classification

New tests:

  • integration_imports_test.go — 14 tests covering positive
    matches, prose-mention false-positive guards, multi-library
    co-detection, and merge logic
  • integration_classification_test.go — 5 tests covering the
    promote-to-integration path, the leave-pure-unit-alone guard,
    the Go httptest case, the nil-cache path, and cancellation
  • unified_render_test.go — render-golden enforcing the four
    uniformity gates plus consistent section ordering

New docs (docs/product/):

  • test-type-classification.md — what 0.2 detects, what it
    doesn't, false-positive catalog, extension recipe
  • e2e-attribution.md — the honest carve-out (structural-only)
    and the 0.3 roadmap
  • unified-pr-comment.md — the visual contract, the alternatives
    considered, the AI section-level grouping exception

Why these three together

They're independent in code but co-located in the plan: all three
are "the pitch's promise about test types is now defensible."
Bundling minimizes review thrash on tightly-related work.

Test plan

  • go build ./... clean
  • go test ./internal/... all pass (incl. 19 new tests)
  • go test ./cmd/... all pass
  • go test ./internal/testdata/... all pass
  • make docs-verify passes
  • Manual smoke: terrain analyze on a repo with integration
    tests in flat directories → integration classification fires
  • Manual smoke: terrain report pr --format markdown on a
    mixed unit/integration/e2e + AI PR → unified comment shape

Plan tracker

Closes Track 3.3, 3.4, 3.5 from the parity-gated 0.2.0 plan.
Track 3 (the centerpiece) is now complete: 3.1 (PR --fail-on)
and 3.2 (--explain-selection) shipped earlier in the cycle; 3.3
through 3.5 land here. Remaining: Tracks 5, 6, 7, 9, 10.2-10.8.

🤖 Generated with Claude Code

…R comment

The three Track 3 deliverables that close the pitch's "maps how your
unit, integration, e2e, and AI tests actually relate to your code"
promise. Together they make the recommended workflow
(`terrain analyze && terrain report pr`) defensible against the
launch-readiness review's "this is uneven across test types" critique.

Track 3.3 — integration-test classification rigor
  Adds explicit content-based detection of HTTP-testing libraries
  (supertest, httptest, MockMvc, supertest, requests, etc.) so
  integration tests living alongside unit tests in flat directories
  are correctly classified. New
  `internal/testtype/integration_imports.go` with a curated allowlist
  of 30+ patterns spanning JS/TS, Go, Python, Java, Ruby ecosystems.
  New `refineIntegrationClassification` step in the analyzer reads
  each test file once via the existing FileCache and merges the
  content-based signal with the path/suite/framework-based signal,
  with explicit conflict-handling that lets explicit imports
  override directory naming. 14 new tests covering positive matches,
  prose-mention false-positive guards, multi-library co-detection,
  and the merge logic.

Track 3.4 — e2e-to-code attribution honest carve-out
  New `docs/product/e2e-attribution.md` documents the exact limit
  of e2e attribution in 0.2: structural-only, via path co-location
  + framework-config declarations + shared-fixture transitive
  links + convention fallback. Explicitly carves out runtime trace
  ingestion, URL-to-route mapping, DOM-selector-to-component
  mapping, and cross-language attribution as 0.3+ work. The honest
  carve-out is the contract — the recommended-tests stanza tags
  e2e selections as `[structural-only]` so adopters know to
  inspect rather than trust blindly.

Track 3.5 — unified PR-comment rendering audit
  New `internal/changescope/unified_render_test.go` enforces the
  visual contract for `terrain report pr --format markdown`:
  bracketed `[LABEL]` badges across stanzas, `**\`path\`**` locator
  format, em-dash separator, and a single recommended-tests stanza
  for unit + integration + e2e (no per-type splitting). Plus a
  consistent-section-order test. Companion doc
  `docs/product/unified-pr-comment.md` documents the contract,
  the section-level severity-grouping exception for the AI stanza
  (and why), and the alternatives that were considered and
  rejected.

Verification: all internal + cmd tests pass; `make docs-verify`
green; new tests run in ~0.5s combined.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 2, 2026

Terrain AI Risk Review

Metric Value
AI surfaces 13
Eval scenarios 16
Impacted scenarios 0
Uncovered surfaces 13

Decision: PASS — AI surfaces are covered.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 2, 2026

[RISK] Terrain — Merge with caution

High-severity gaps found in changed code.

Metric Value
Changed files 9 (3 source · 3 test)
Impacted units 7
Protection gaps 3
Tests selected 11 of 775 (1% of suite)

Coverage gaps in changed code

  • internal/analysis/analyzer.go [MED] — Exported function Analyze has no observed test coverage.
    → Add unit tests for exported function Analyze — this is public API surface.
  • internal/analysis/analyzer.go [MED] — Exported function AnalyzeContext has no observed test coverage.
    → Add unit tests for exported function AnalyzeContext — this is public API surface.
  • internal/analysis/integration_classification.go [LOW] — integration_classification.go has no observed test coverage.
    → Add unit tests for integration_classification.go.
4 pre-existing issues on changed files
  • internal/analysis/analyzer.go [HIGH] — [blastRadiusHotspot] Changes to this file propagate to 954 tests (450 direct, 504 indirect). High blast radius increases regression risk.
  • internal/analysis/integration_classification.go [HIGH] — [blastRadiusHotspot] Changes to this file propagate to 954 tests (450 direct, 504 indirect). High blast radius increases regression risk.
  • internal/testtype/integration_imports.go [HIGH] — [blastRadiusHotspot] Changes to this file propagate to 1578 tests (32 direct, 1546 indirect). High blast radius increases regression risk.
  • internal/analysis/integration_classification_test.go [LOW] — [fixtureFragilityHotspot] Fixture 'mustWrite' is used by 5 tests across 1 files. A single change cascades widely.

Recommended tests

11 test(s) with exact coverage of 4 impacted unit(s). 3 impacted unit(s) have no covering tests in the selected set.

Test Confidence Why
internal/analysis/analyzer_test.go exact exact coverage of New
internal/analysis/bench_test.go exact exact coverage of New
internal/analysis/context_test.go exact exact coverage of New
internal/analysis/fixture_deps_test.go exact exact coverage of Analyzer, New
internal/analysis/gitignore_test.go exact exact coverage of Analyzer, New
internal/analysis/integration_classification_test.go exact test file directly changed
internal/analysis/tsconfig_extends_test.go exact exact coverage of Analyzer, New
internal/analysis/vitest_in_source_test.go exact exact coverage of Analyzer, New
internal/changescope/unified_render_test.go exact test file directly changed
internal/engine/pipeline_test.go exact exact coverage of New
internal/testtype/integration_imports_test.go exact exact coverage of InferFromContent, MergeContentInference

Owners: PMCLSF

Limitations
  • No coverage artifacts provided; protection gaps reflect missing data, not measured absence. Provide --coverage to improve accuracy.
  • Mixed test cultures reduce cross-framework optimization confidence. Consider standardizing on fewer frameworks.

Generated by Terrain · terrain pr --json for machine-readable output

Targeted Test Results

Terrain selected 11 test(s) instead of the full suite.

  • Go tests: passed

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.

1 participant