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
33 lines
951 B
Python
33 lines
951 B
Python
"""Helper for building registry-valid :class:`Observation` records.
|
|
|
|
Every feature module would otherwise repeat the same Window /
|
|
source / evidence_ref boilerplate. This helper centralises it and is
|
|
the one place to reach when emission semantics change (e.g. when we
|
|
start parametrising windows on a per-primitive basis).
|
|
"""
|
|
from __future__ import annotations
|
|
|
|
from typing import Any
|
|
|
|
from behave_core.spec.envelope import Observation, Window
|
|
|
|
from decnet.profiler.behave_shell._ctx import SessionContext
|
|
|
|
|
|
def make_observation(
|
|
ctx: SessionContext,
|
|
*,
|
|
primitive: str,
|
|
value: Any,
|
|
confidence: float,
|
|
) -> Observation:
|
|
"""Build one :class:`Observation` for the whole-session window."""
|
|
return Observation(
|
|
primitive=primitive,
|
|
value=value,
|
|
confidence=confidence,
|
|
window=Window(start_ts=ctx.t_start, end_ts=ctx.t_end),
|
|
source=ctx.source,
|
|
evidence_ref=ctx.evidence_ref,
|
|
)
|