perf(pytest): 194s → 4s collection — lazy heavy imports + norecursedirs

Four-part fix for the collection bottleneck that was blocking the dev loop:

1. Lazy mitreattack.stix20 import in attack_stix.py — deferred to first
   _load() call (TYPE_CHECKING guard at top level)

2. Lazy misp_stix_converter import in both MISP export routers — moved
   from module level into the route handler body

3. Lazy attack_catalog / attack_stix in ttp.py repo mixin — thin wrapper
   functions so the import chain never fires at module load time

4. tests/api/conftest.py — `from decnet.web.api import app` moved inside
   the `client()` fixture; `pytest_ignore_collect` broadened to skip all
   test_schemathesis*.py variants (not just test_schemathesis.py), which
   were launching a subprocess server at module-import time

5. pyproject.toml — `norecursedirs` for tests/live, tests/stress,
   tests/service_testing, tests/docker, tests/perf so these directories
   are never entered; `-m` filter removed from addopts (now redundant);
   `--dist loadscope` → `--dist load` to unblock workers immediately

6. behave_core / behave_shell rename — BEHAVE packages dropped the
   `decnet_` prefix; reinstalled editable installs and updated all 14
   import sites across profiler, ttp, bus, and correlation modules
This commit is contained in:
2026-05-10 06:41:25 -04:00
parent f63aca4186
commit e4626879f6
24 changed files with 59 additions and 36 deletions

View File

@@ -8,7 +8,7 @@ from __future__ import annotations
from typing import Callable, Iterable
from decnet_behave_core.spec.envelope import Observation
from behave_core.spec.envelope import Observation
from decnet.profiler.behave_shell._ctx import SessionContext
from decnet.profiler.behave_shell._features.cognitive import (

View File

@@ -9,7 +9,7 @@ from __future__ import annotations
from typing import Any
from decnet_behave_core.spec.envelope import Observation, Window
from behave_core.spec.envelope import Observation, Window
from decnet.profiler.behave_shell._ctx import SessionContext

View File

@@ -11,7 +11,7 @@ from __future__ import annotations
import statistics
from typing import Iterator
from decnet_behave_core.spec.envelope import Observation
from behave_core.spec.envelope import Observation
from decnet.profiler.behave_shell._ctx import SessionContext
from decnet.profiler.behave_shell._features._emit import make_observation

View File

@@ -15,7 +15,7 @@ from __future__ import annotations
import statistics
from typing import Iterator
from decnet_behave_core.spec.envelope import Observation
from behave_core.spec.envelope import Observation
from decnet.profiler.behave_shell._ctx import SessionContext
from decnet.profiler.behave_shell._features._emit import make_observation

View File

@@ -17,7 +17,7 @@ import collections
import re
from typing import Iterator
from decnet_behave_core.spec.envelope import Observation
from behave_core.spec.envelope import Observation
from decnet.profiler.behave_shell._ctx import SessionContext
from decnet.profiler.behave_shell._features._emit import make_observation

View File

@@ -10,7 +10,7 @@ import statistics
from itertools import chain
from typing import Iterator
from decnet_behave_core.spec.envelope import Observation
from behave_core.spec.envelope import Observation
from decnet.profiler.behave_shell._ctx import SessionContext
from decnet.profiler.behave_shell._features._emit import make_observation

View File

@@ -11,7 +11,7 @@ import collections
import statistics
from typing import Iterator
from decnet_behave_core.spec.envelope import Observation
from behave_core.spec.envelope import Observation
from decnet.profiler.behave_shell._ctx import SessionContext
from decnet.profiler.behave_shell._features._emit import make_observation

View File

@@ -16,7 +16,7 @@ import math
import statistics
from typing import Iterator
from decnet_behave_core.spec.envelope import Observation
from behave_core.spec.envelope import Observation
from decnet.profiler.behave_shell._ctx import SessionContext
from decnet.profiler.behave_shell._features._emit import make_observation

View File

@@ -17,8 +17,8 @@ import json
from pathlib import Path
from typing import Any, Callable, Iterable, Optional
from decnet_behave_core.spec.envelope import Observation
from decnet_behave_shell.spec.event_adapter import event_topic_for, to_event_payload
from behave_core.spec.envelope import Observation
from behave_shell.spec.event_adapter import event_topic_for, to_event_payload
from decnet.logging import get_logger
from decnet.profiler.behave_shell import extract_session

View File

@@ -9,7 +9,7 @@ from __future__ import annotations
from typing import Iterable, Iterator
from decnet_behave_core.spec.envelope import Observation
from behave_core.spec.envelope import Observation
from decnet.profiler.behave_shell._ctx import SessionContext, build_session_context
from decnet.profiler.behave_shell._features import FEATURES