BEHAVE-EXTRACTOR.md Phase A Step 2. The first primitive — picked
first because it has the highest discriminative value (HUMAN vs
everyone) and the simplest implementation (paste-event ratio over
total inputs).
* _features/motor.py:input_modality(ctx) emits one Observation
per session in {typed, pasted, mixed} with confidence 0.75 / 0.70.
* _features/_emit.py centralises the make_observation helper so
every feature module gets the same Window/source/evidence_ref
boilerplate without copy-paste.
* Thresholds inherited from the prototype's calibration history
(MODALITY_PASTED_MIN=0.40, MODALITY_TYPED_MAX=0.05).
* Zero-input session skips emission — registry doesn't admit
"unknown" here.
Tests: pure-typed → typed, pure-pasted → pasted, mixed → mixed,
output-only session → no observation, full envelope round-trip.
33 lines
958 B
Python
33 lines
958 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 decnet_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,
|
|
)
|