Files
DECNET/tests/ttp/_stub_store.py
anti f2b3393669 chore: relicense to AGPL-3.0-or-later and add SPDX headers
Replaces LICENSE (GPLv3 -> AGPLv3) and prepends
`SPDX-License-Identifier: AGPL-3.0-or-later` to every source file
across decnet/, decnet_web/, tests/, scripts/, and tools/.

Rationale: closes the GPLv3 ASP loophole so any party operating a
modified DECNET as a network service must offer their modified
source. Personal copyright (Samuel Paschuan) + inbound=outbound
contributions make a future unilateral relicense infeasible.

- LICENSE: full AGPL-3.0 text (gnu.org/licenses/agpl-3.0.txt)
- COPYRIGHT: project copyright notice
- tools/add_spdx_headers.py: idempotent header injector
  (shebang- and PEP 263-aware)

Touches 1565 source files (.py, .ts, .tsx, .js, .jsx, .css, .sh).
No behavior change; comments only.
2026-05-22 21:04:16 -04:00

50 lines
1.5 KiB
Python

# SPDX-License-Identifier: AGPL-3.0-or-later
"""Shared stub :class:`RuleStore` for lifter unit tests.
Tests that exercise :class:`BehavioralLifter` / :class:`IntelLifter` /
:class:`CanaryFingerprintLifter` / :class:`EmailLifter` need a store
reference at construction. Most don't drive the watch loop — they
inject rules into the lifter's :class:`RuleIndex` directly. This stub
provides just enough of the ABC to satisfy construction.
"""
from __future__ import annotations
from collections.abc import AsyncIterator
from typing import Any
from decnet.ttp.impl.rule_engine import CompiledRule
from decnet.ttp.store.base import RuleChange, RuleState, RuleStore
class StubRuleStore(RuleStore):
"""In-memory store with optional preloaded compiled rules."""
def __init__(
self,
compiled: list[CompiledRule] | None = None,
changes: list[RuleChange] | None = None,
) -> None:
self._compiled = list(compiled or [])
self._changes = list(changes or [])
async def load_compiled(self) -> list[CompiledRule]:
return list(self._compiled)
async def get_state(self, _rule_id: str) -> RuleState:
return RuleState()
async def set_state(self, *_a: Any, **_kw: Any) -> None:
return None
def subscribe_changes(self) -> AsyncIterator[RuleChange]:
changes = list(self._changes)
async def _gen() -> AsyncIterator[RuleChange]:
for change in changes:
yield change
return _gen()
__all__ = ["StubRuleStore"]