Run the dependency direction detector against ddtrace and propose architectural fixes for any violations found. Use this when adding or refactoring modules under ddtrace/internal, ddtrace/contrib, or any product package, or when the detect_layering_violations CI job reports new violations on a PR.
scripts/import-analysis/layers.json is the authority for zones, foundation modules, and
intentional exceptions. internal-core/contrib imports into products and imports between
products are restricted; the configured contrib-to-tracing exception is intentional.
Explicitly listed foundation modules are exempt from these dependency-direction rules.
uv run --script scripts/import-analysis/layers.py analyze --root <candidate-checkout>/ddtrace <candidate.json>
uv run --script scripts/import-analysis/layers.py analyze --root <merge-base-checkout>/ddtrace <base.json>
uv run --script scripts/import-analysis/layers.py compare <base.json> <candidate.json>Run both analyses with the candidate's detector and adjacent layers.json, matching CI;
only the source tree passed through --root changes. Keep outputs in a temporary location.
The result lists violations and uncovered top-level modules. Read the detector's current
comparison rules when diagnosing CI; severity scores prioritize investigation, not correctness.
For each violation, from/to identify the importing/imported modules and from_zone/to_zone
show their classified owners. in_tangle means the target participates in a circular-import
component; it does not by itself prove this particular edge creates the cycle.
score combines the rule's weight, how many modules depend on the target, and a cycle bonus.
Within the task's scope, investigate high scores and tangled targets first; read the current
formula in layers.py. A lower score does not make a forbidden dependency acceptable.
uncovered identifies top-level modules missing a zone or foundation classification. Resolve
that configuration gap explicitly; new uncovered modules fail the comparison independently of
violation scores. The comparison also distinguishes new edges from worsened existing edges.
.cursor/rules/isolated-responsibility.mdc.Protocol or callback contract
at the shared boundary and let the product supply its implementation through the existing
lifecycle. Product in ddtrace/internal/products.py is an example of a lifecycle contract.Tracer or Span into shared code just to
satisfy the detector. They are exported by ddtrace/trace/__init__.py; preserve that API and
product ownership, using a narrower interface or event for other products' needs.layers.json: product code belongs in its product zone;
shared foundation code must be explicitly listed. Product-owned internal packages need
the corresponding zone mapping rather than falling into generic internal-core.circular-import-analysis for cycles.Rerun both analysis and base comparison to confirm that the intended violation is resolved and no new violations or uncovered modules were introduced.
DataDog/dd-trace-py
4adf35e
If you maintain this skill, you can claim it as your own. Once claimed, you can manage eval scenarios, bundle related skills, attach documentation or rules, and ensure cross-agent compatibility.