feat(profiler/behave_shell): emit motor.command_chunking
BEHAVE-EXTRACTOR.md Phase B Step B.4. First implementation —
prototype doesn't ship this primitive.
* SessionContext gains intra_command_iats: per-command tuple of
IATs between consecutive input events whose timestamps fall
inside [cmd.start_ts, cmd.end_ts). Excludes the terminator IAT.
Built by _per_command_iats.
* _features/motor.py:command_chunking(ctx) emits one Observation
in {fluent, fragmented, single_command}.
- 0 commands → skip emit
- 1 command → single_command (registry-allowed point)
- ≥2 commands → median CV across per-command typed-IATs;
< CMD_CHUNKING_FLUENT_CV_MAX (0.50) → fluent, else fragmented
- paste-only sessions (no command has ≥3 typed IATs) → skip emit
(no honest within-command rhythm to measure)
Confidence 0.80 / 0.65 / 0.60.
* Calibration grid widened to include motor.command_chunking;
green across all five shards. Phase B primitive set complete.
Tests: no commands → skip, 1 command → single_command, uniform
typing → fluent, alternating fast/slow → fragmented, paste-only
multi-command → skip emit.
This commit is contained in:
@@ -18,6 +18,7 @@ from decnet.profiler.behave_shell._features.cognitive import (
|
||||
inter_command_latency_class,
|
||||
)
|
||||
from decnet.profiler.behave_shell._features.motor import (
|
||||
command_chunking,
|
||||
error_correction,
|
||||
input_modality,
|
||||
keystroke_cadence,
|
||||
@@ -33,6 +34,7 @@ FEATURES: tuple[FeatureFn, ...] = (
|
||||
keystroke_cadence,
|
||||
motor_stability,
|
||||
error_correction,
|
||||
command_chunking,
|
||||
inter_command_latency_class,
|
||||
command_branch_diversity,
|
||||
feedback_loop_engagement,
|
||||
|
||||
@@ -16,6 +16,7 @@ from decnet.profiler.behave_shell._ctx import SessionContext
|
||||
from decnet.profiler.behave_shell._features._emit import make_observation
|
||||
from decnet.profiler.behave_shell._thresholds import (
|
||||
BACKSPACE_IMMEDIATE_MAX_S,
|
||||
CMD_CHUNKING_FLUENT_CV_MAX,
|
||||
CV_BURSTY_MAX,
|
||||
CV_MACHINE_MAX,
|
||||
CV_STEADY_MAX,
|
||||
@@ -205,3 +206,49 @@ def error_correction(ctx: SessionContext) -> Iterator[Observation]:
|
||||
value=value,
|
||||
confidence=confidence,
|
||||
)
|
||||
|
||||
|
||||
def command_chunking(ctx: SessionContext) -> Iterator[Observation]:
|
||||
"""Emit ``motor.command_chunking`` ∈ {fluent, fragmented, single_command}.
|
||||
|
||||
* 0 commands → skip (no honest answer).
|
||||
* 1 command → ``single_command`` (registry-allowed, distinct from
|
||||
the fluent/fragmented continuum that needs multiple commands).
|
||||
* ≥2 commands → median CV across per-command intra-typing IATs;
|
||||
below ``CMD_CHUNKING_FLUENT_CV_MAX`` → fluent, else fragmented.
|
||||
|
||||
Skips emission if no command has ≥3 typed IATs to compute a CV
|
||||
over (paste-driven sessions where every command arrived as one
|
||||
bulk write — no honest within-command rhythm to measure).
|
||||
"""
|
||||
n = len(ctx.commands)
|
||||
if n == 0:
|
||||
return
|
||||
if n == 1:
|
||||
yield make_observation(
|
||||
ctx,
|
||||
primitive="motor.command_chunking",
|
||||
value="single_command",
|
||||
confidence=0.80,
|
||||
)
|
||||
return
|
||||
cvs: list[float] = []
|
||||
for iats in ctx.intra_command_iats:
|
||||
if len(iats) < 3:
|
||||
continue
|
||||
m = statistics.fmean(iats)
|
||||
if m > 0:
|
||||
cvs.append(statistics.pstdev(iats) / m)
|
||||
if not cvs:
|
||||
return
|
||||
cv = statistics.median(cvs)
|
||||
if cv < CMD_CHUNKING_FLUENT_CV_MAX:
|
||||
value, confidence = "fluent", 0.65
|
||||
else:
|
||||
value, confidence = "fragmented", 0.60
|
||||
yield make_observation(
|
||||
ctx,
|
||||
primitive="motor.command_chunking",
|
||||
value=value,
|
||||
confidence=confidence,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user