Skip to content

Refactor strand tests off the private-member mega-harness #668

Description

@flyingrobots

Problem

The strand service test cluster has become a private-member mega-harness. It keeps coverage high, but it is testing too much through implementation details and casts instead of stable runtime contracts.

Evidence

Local scan on docs/cleanup:

rg -n "as any|as unknown as|Reflect\.apply|spyOn\(\(service\._|service\._|anyAnalyzer|nodeAddStrategy as any" test/unit/domain/services/strand --glob '*.test.ts'
wc -l test/unit/domain/services/strand/*.test.ts test/unit/domain/services/strand/*.ts

Representative findings:

  • test/unit/domain/services/strand/StrandService.test.ts is 2,870 lines.
  • test/unit/domain/services/strand/ConflictAnalyzerService.test.ts is 2,019 lines.
  • The suite directly reads service._descriptorStore, service._patchService, service._intentService, and service._materializer in many assertions.
  • The suite uses Reflect.apply(...) to bypass public call shapes in several negative tests.
  • The suite uses repeated as any / as unknown as casts to inject impossible shapes and spy on private implementation details.

This is test code, so it is not a runtime correctness defect by itself. The debt is that the tests now make refactors harder and reward implementation coupling.

Acceptance criteria

  • Introduce typed strand test builders/harnesses that construct invalid boundary inputs intentionally without broad as any corridors.
  • Move private collaborator assertions behind stable observable outcomes or intentionally exported test seams.
  • Split StrandService.test.ts into behavior-focused files under the 800 LOC test-file ceiling where practical.
  • Keep the same behavioral coverage or improve it; do not delete tests merely because they are ugly.
  • Any remaining casts are narrow, local, and justified by the specific boundary-invalid input being tested.

Non-goals

  • Changing strand runtime behavior.
  • Weakening negative coverage around invalid descriptors, queued intents, braid refs, or conflict analysis.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:testingPrimary work area: testing.priority:laterDeferred or speculative work.status:availableOpen and available for prioritization; not blocked or actively in progress.type:debtDebt, rot, or structural risk.

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions