← Recipes

Question

What coupling creates this cycle, and which dependency could be removed without changing the intended behavior?

Recipe

loct cycles
loct follow cycles --limit 8
loct slice src/domain.rs --depth 1
loct slice src/service.rs --depth 1

Choose the two files from a reported cycle. Read each direction rather than treating the cycle count as a verdict. Determine what is carried: a type, runtime call, re-export, test import, lazy import or generated include.

Expected answer shape

A useful answer names the dependency in each direction, its source location and any platform/test conditions. Distinguish import cycles from runtime initialization cycles. A classification such as structural or diamond does not itself establish that an application fails.

Decision

Propose a specific change in ownership: move a shared contract, invert one dependency, or preserve an intentional recursive relationship. Explain which consumer behavior must remain intact before selecting a cut.

Check the interpretation

loct find AuthToken --literal --group-by-file --limit 30
loct body AuthToken --max-lines 60 --json
loct findings --summary

Use the symbol actually carried by the edge. Compare aggregate and detailed classifications only within the same scope and snapshot. If surfaces disagree, preserve the disagreement rather than choosing the more reassuring count.

Counterexample

A test module importing its parent, a platform-gated implementation, a lazy Python import or a recursive type can create a cycle-shaped structure with very different consequences. A suggested cut through a recursive type may be impossible without redesigning that contract.

Evidence

The September round found useful cycle classifications alongside self-import artifacts, unresolved external/local module collisions and inconsistent summary labels. It also found raw import facts that explained edges more precisely than the cycle presentation. Treat these as historical reasons to inspect the carried dependency, not as a claim that the same bugs persist today.