Skip to content

fix: preserve tested_by edges for Swift, Rust, Ruby, and PHP - #689

Merged
Lum1104 merged 1 commit into
Egonex-AI:mainfrom
ZHCHJ888:fix/swift-test-coverage
Sep 12, 2026
Merged

Lum1104 merged 1 commit into
Egonex-AI:mainfrom
ZHCHJ888:fix/swift-test-coverage

Conversation

@ZHCHJ888

Copy link
Copy Markdown
Contributor

Summary

Extend deterministic test-file classification for Swift, Rust, Ruby, and PHP so valid LLM-emitted tested_by edges are not misclassified as production-to-production relationships and dropped during graph merging.

The change adds language-specific filename and test-directory conventions while preserving the existing JavaScript/TypeScript helper-file behavior.

Linked issue(s)

Closes #646

What changed

  • Added test filename conventions for:
    • Swift: *Test.swift, *Tests.swift, and *Spec.swift
    • Rust: test_*.rs and *_test.rs
    • Ruby: test_*.rb, *_test.rb, *_spec.rb, and spec_helper.rb
    • PHP: *Test.php
  • Recognize Swift, Rust, and PHP source files below tests/ directories as test files.
  • Preserve canonical production-to-test tested_by edges for these languages.
  • Allow the existing linker to canonicalize inverted Swift tested_by edges and apply the tested tag to production nodes.
  • Added positive classification tests for the new conventions.
  • Added negative tests to prevent ordinary production files such as Contest.swift, contest.rs, latest.rb, and Contest.php from being misclassified.
  • Added regression coverage for canonical and inverted LLM-emitted edges.
  • Added a Swift integration test through the complete merge_and_normalize() path.

Scope

Objective-C .m/.mm classification and reporting extensions without configured test patterns are outside the scope of this focused fix.

This PR focuses on preserving test-coverage relationships for the ecosystems identified in #646.

How I tested this

Test environment:

  • Windows
  • Node.js 22.23.2
  • pnpm 10.6.2, as pinned by the repository

Results:

  • merge-batch-graphs.py test suite: 91 passed
  • Python CI helper suite: 105 passed, 1 skipped
  • Core test suite: 1,012 passed, 1 skipped
  • Root test suite: 787 passed, 6 skipped
  • Root test files: 38 passed
  • pnpm lint: passed
  • pnpm build: passed
  • git diff --check: passed

Skipped tests

The skipped tests cover POSIX-only filesystem behavior that cannot be reliably tested on Windows, such as case-sensitive filenames, literal backslashes, newlines, and trailing dots. None of them exercise the test-file classification or tested_by edge-preservation logic changed by this PR; all relevant tests ran and passed.

Manual Swift smoke test

Ran merge-batch-graphs.py against a temporary batch containing:

  • Sources/App/App.swift
  • Tests/AppTests/AppTests.swift
  • A canonical tested_by edge from the production file to the test file

Verified that:

  • The tested_by edge remained in assembled-graph.json.

  • The edge direction remained production → test.

  • The production node received the tested tag.

  • pnpm lint

  • pnpm --filter @understand-anything/core test

  • pnpm test

  • Manual smoke test (described above)

  • pnpm build

Versioning

  • Version bumped from 2.9.6 to 2.9.7 in all six manifests listed in CLAUDE.md.

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.

merge-batch-graphs.py silently deletes all Swift (and Rust/Ruby/PHP) test coverage: _TEST_NAME_PATTERNS has no .swift key

2 participants