ArchUnitPython icon indicating copy to clipboard operation
ArchUnitPython copied to clipboard

[FEATURE] Determinism / seam boundary

Open LukasNiessen opened this issue 4 months ago • 0 comments

In short

Business logic that calls the clock, randomness, environment variables, or the network directly is hard to test and unpredictable. This bans those calls in the domain layer so they're passed in instead.

Problem

Pure/domain code that reaches for wall-clock time, randomness, environment, or the network directly is untestable and non-deterministic; enforcing seams automatically improves testability.

Proposal

A rule that bans ambient side-effect calls in a layer, e.g. project_files("src/").in_folder("**/domain/**").should_not().use_symbols("datetime.now", "random", "os.environ", "requests"), forcing injected clocks/RNG/config/ports.

Add to README a section on this, include reference and explanation a la "Working Effectively with Legacy Code — Michael Feathers; Building Evolutionary Architectures — Ford, Parsons, Kua: In plain terms. Business logic that calls the clock, randomness, environment variables, or the network directly is hard to test and unpredictable. This bans those calls in the domain layer so they're passed in instead."

Acceptance criteria

  • [ ] A domain module calling datetime.now() fails; an injected clock passes; the banned-symbol list is configurable.

LukasNiessen avatar Jul 26 '26 22:07 LukasNiessen