feat(profiler/behave_shell): emit cognitive.inter_command_latency_class
BEHAVE-EXTRACTOR.md Phase A Step 5. Classifies the operator's
thinking pace between commands. Splits LW-sim / CLAUDE-FF /
CLAUDE-CL.
* _features/cognitive.py:inter_command_latency_class(ctx) emits one
Observation in {instant, typing_speed, deliberate,
llm_lightweight, llm_heavyweight, long}, computed as the median
of ctx.inter_cmd_iats bucketed against the prototype thresholds
(v0.2 split: lightweight 2-8s, heavyweight 8-30s).
* Sample-size honesty: < 5 commands halves confidence (0.40 vs
0.80) per BEHAVE-EXTRACTOR.md.
* Threshold consts (INTER_CMD_*_MAX, MIN_COMMANDS_FOR_FULL_CONFIDENCE,
plus parked Step 6/7/8 thresholds for the next three commits)
added to _thresholds.py.
Tests cover all six buckets at empirically-anchored IATs (15s ≈
Claude Opus driving recon via tmux send-keys), plus the
single-command no-IAT and low-sample-count paths.
This commit is contained in:
@@ -11,6 +11,9 @@ from typing import Callable, Iterable
|
||||
from decnet_behave_core.spec.envelope import Observation
|
||||
|
||||
from decnet.profiler.behave_shell._ctx import SessionContext
|
||||
from decnet.profiler.behave_shell._features.cognitive import (
|
||||
inter_command_latency_class,
|
||||
)
|
||||
from decnet.profiler.behave_shell._features.motor import (
|
||||
input_modality,
|
||||
paste_burst_rate,
|
||||
@@ -21,4 +24,5 @@ FeatureFn = Callable[[SessionContext], Iterable[Observation]]
|
||||
FEATURES: tuple[FeatureFn, ...] = (
|
||||
input_modality,
|
||||
paste_burst_rate,
|
||||
inter_command_latency_class,
|
||||
)
|
||||
|
||||
61
decnet/profiler/behave_shell/_features/cognitive.py
Normal file
61
decnet/profiler/behave_shell/_features/cognitive.py
Normal file
@@ -0,0 +1,61 @@
|
||||
"""``cognitive.*`` feature functions.
|
||||
|
||||
Step 5: ``cognitive.inter_command_latency_class``.
|
||||
Step 6: ``cognitive.command_branch_diversity``.
|
||||
Step 7: ``cognitive.feedback_loop_engagement``.
|
||||
Step 8: ``cognitive.inter_command_consistency``.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import statistics
|
||||
from typing import Iterator
|
||||
|
||||
from decnet_behave_core.spec.envelope import Observation
|
||||
|
||||
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 (
|
||||
INTER_CMD_DELIBERATE_MAX,
|
||||
INTER_CMD_INSTANT_MAX,
|
||||
INTER_CMD_LLM_HEAVYWEIGHT_MAX,
|
||||
INTER_CMD_LLM_LIGHTWEIGHT_MAX,
|
||||
INTER_CMD_TYPING_MAX,
|
||||
MIN_COMMANDS_FOR_FULL_CONFIDENCE,
|
||||
)
|
||||
|
||||
|
||||
def _bucket_inter_cmd_latency(median_iat: float) -> str:
|
||||
if median_iat <= INTER_CMD_INSTANT_MAX:
|
||||
return "instant"
|
||||
if median_iat <= INTER_CMD_TYPING_MAX:
|
||||
return "typing_speed"
|
||||
if median_iat <= INTER_CMD_DELIBERATE_MAX:
|
||||
return "deliberate"
|
||||
if median_iat <= INTER_CMD_LLM_LIGHTWEIGHT_MAX:
|
||||
return "llm_lightweight"
|
||||
if median_iat <= INTER_CMD_LLM_HEAVYWEIGHT_MAX:
|
||||
return "llm_heavyweight"
|
||||
return "long"
|
||||
|
||||
|
||||
def inter_command_latency_class(ctx: SessionContext) -> Iterator[Observation]:
|
||||
"""Emit ``cognitive.inter_command_latency_class``.
|
||||
|
||||
Operator's *thinking pace* between commands, bucketed against
|
||||
calibrated thresholds. Splits LW-sim / CLAUDE-FF / CLAUDE-CL.
|
||||
"""
|
||||
if not ctx.inter_cmd_iats:
|
||||
return
|
||||
median_iat = statistics.median(ctx.inter_cmd_iats)
|
||||
bucket = _bucket_inter_cmd_latency(median_iat)
|
||||
# Sample-size honesty: < 5 commands → halve confidence
|
||||
if len(ctx.commands) < MIN_COMMANDS_FOR_FULL_CONFIDENCE:
|
||||
confidence = 0.40
|
||||
else:
|
||||
confidence = 0.80
|
||||
yield make_observation(
|
||||
ctx,
|
||||
primitive="cognitive.inter_command_latency_class",
|
||||
value=bucket,
|
||||
confidence=confidence,
|
||||
)
|
||||
Reference in New Issue
Block a user