Files
DECNET/tests/profiler/behave_shell/test_emotional_valence_arousal.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

69 lines
2.2 KiB
Python

# SPDX-License-Identifier: AGPL-3.0-or-later
"""Step G.6: ``emotional_valence.arousal`` ∈ {low_calm, medium_engaged,
high_agitated}.
Hard 0.5 confidence cap.
"""
from __future__ import annotations
from decnet.profiler.behave_shell import extract_session
from decnet.profiler.behave_shell._parse import AsciinemaEvent
PRIMITIVE = "emotional_valence.arousal"
def _of(observations: list, primitive: str):
obs = [o for o in observations if o.primitive == primitive]
assert len(obs) == 1, f"expected exactly one {primitive}, got {len(obs)}"
return obs[0]
def _typed(text: str, t0: float = 0.0, dt: float = 0.05) -> list[AsciinemaEvent]:
return [(t0 + i * dt, "i", c) for i, c in enumerate(text)]
def test_no_typing_bursts_no_emission() -> None:
out = list(extract_session([(0.0, "i", "x")], sid="g6-empty"))
assert [o for o in out if o.primitive == PRIMITIVE] == []
def test_high_agitated_via_caps_run() -> None:
"""Long capslock streak fires high_agitated regardless of pace."""
text = "ls\rWHAT IS GOING ON HERE\rls\r"
obs = _of(list(extract_session(_typed(text), sid="g6-caps")), PRIMITIVE)
assert obs.value == "high_agitated"
assert obs.confidence <= 0.50
def test_high_agitated_via_bangs() -> None:
text = "ls\rno!!!! something\rls\r"
obs = _of(list(extract_session(_typed(text), sid="g6-bang")), PRIMITIVE)
assert obs.value == "high_agitated"
def test_high_agitated_via_fast_typing() -> None:
"""Long fast burst (dt=0.04) fires high_agitated."""
text = "thequickbrownfoxjumpsoverthelazydog" * 2
obs = _of(
list(extract_session(_typed(text, dt=0.04), sid="g6-fast")), PRIMITIVE
)
assert obs.value == "high_agitated"
def test_low_calm_slow_typing() -> None:
"""Long slow burst (dt=0.40) fires low_calm."""
text = "thequickbrownfoxjumpsoverthelazydog" * 2
obs = _of(
list(extract_session(_typed(text, dt=0.40), sid="g6-calm")), PRIMITIVE
)
assert obs.value == "low_calm"
def test_confidence_capped_at_05() -> None:
text = "thequickbrownfoxjumpsoverthelazydog" * 2
obs = _of(
list(extract_session(_typed(text, dt=0.10), sid="g6-cap")), PRIMITIVE
)
assert obs.confidence <= 0.50