feat(profiler/behave_shell): emit cognitive.exploration_style
Two-axis classification over the first_token_hash sequence: repetition_rate (drilling) vs backtrack_rate (jumping among prior tools). chaotic/targeted/methodical buckets. v0.1 thresholds; D.8 re-tunes.
This commit is contained in:
@@ -14,6 +14,7 @@ from decnet.profiler.behave_shell._ctx import SessionContext
|
||||
from decnet.profiler.behave_shell._features.cognitive import (
|
||||
cognitive_load,
|
||||
command_branch_diversity,
|
||||
exploration_style,
|
||||
feedback_loop_engagement,
|
||||
inter_command_consistency,
|
||||
inter_command_latency_class,
|
||||
@@ -47,4 +48,5 @@ FEATURES: tuple[FeatureFn, ...] = (
|
||||
feedback_loop_engagement,
|
||||
inter_command_consistency,
|
||||
cognitive_load,
|
||||
exploration_style,
|
||||
)
|
||||
|
||||
@@ -21,6 +21,8 @@ from decnet.profiler.behave_shell._thresholds import (
|
||||
COGNITIVE_LOAD_LOW_MAX,
|
||||
COGNITIVE_LOAD_MEDIUM_MAX,
|
||||
COGNITIVE_LOAD_PACE_REF_CV,
|
||||
EXPLORATION_CHAOTIC_BACKTRACK_MIN,
|
||||
EXPLORATION_TARGETED_REP_MIN,
|
||||
FEEDBACK_CORRELATION_MIN,
|
||||
FEEDBACK_MIN_PAIRS,
|
||||
INTER_CMD_DELIBERATE_MAX,
|
||||
@@ -179,6 +181,65 @@ def feedback_loop_engagement(ctx: SessionContext) -> Iterator[Observation]:
|
||||
)
|
||||
|
||||
|
||||
def exploration_style(ctx: SessionContext) -> Iterator[Observation]:
|
||||
"""Emit ``cognitive.exploration_style`` ∈ {methodical, chaotic, targeted}.
|
||||
|
||||
Two-axis classification over the first_token_hash sequence:
|
||||
|
||||
* **methodical** — low repetition, low backtracks. Operator marches
|
||||
forward through new tools.
|
||||
* **targeted** — high repetition (R ≥ EXPLORATION_TARGETED_REP_MIN).
|
||||
Same tool re-invoked repeatedly; the operator is drilling.
|
||||
* **chaotic** — high backtrack rate (J ≥ EXPLORATION_CHAOTIC_BACKTRACK_MIN).
|
||||
Jumps among previously-used tools without a clear thread.
|
||||
|
||||
The registry doesn't permit ``unknown``; below the
|
||||
MIN_COMMANDS_FOR_FULL_CONFIDENCE floor we emit at confidence 0.40
|
||||
rather than skip — the engine has *some* signal, just less of it.
|
||||
Skip emission only when there are no commands at all.
|
||||
"""
|
||||
n = len(ctx.commands)
|
||||
if n == 0:
|
||||
return
|
||||
hashes = [c.first_token_hash for c in ctx.commands]
|
||||
unique = len(set(hashes))
|
||||
repetition_rate = 0.0 if n == 0 else 1.0 - (unique / n)
|
||||
|
||||
# Backtrack: at position i, hashes[i] previously seen at index < i-1
|
||||
# and not equal to hashes[i-1]. (Repeating the immediate predecessor
|
||||
# is "drilling", picked up by repetition_rate; backtrack is the
|
||||
# non-local jump signal.)
|
||||
seen_before: set[str] = set()
|
||||
backtracks = 0
|
||||
transitions = 0
|
||||
if hashes:
|
||||
seen_before.add(hashes[0])
|
||||
for i in range(1, n):
|
||||
transitions += 1
|
||||
if hashes[i] != hashes[i - 1] and hashes[i] in seen_before:
|
||||
backtracks += 1
|
||||
seen_before.add(hashes[i])
|
||||
backtrack_rate = (backtracks / transitions) if transitions else 0.0
|
||||
|
||||
if backtrack_rate >= EXPLORATION_CHAOTIC_BACKTRACK_MIN:
|
||||
value = "chaotic"
|
||||
elif repetition_rate >= EXPLORATION_TARGETED_REP_MIN:
|
||||
value = "targeted"
|
||||
else:
|
||||
value = "methodical"
|
||||
|
||||
if n < MIN_COMMANDS_FOR_FULL_CONFIDENCE:
|
||||
confidence = 0.40
|
||||
else:
|
||||
confidence = 0.60
|
||||
yield make_observation(
|
||||
ctx,
|
||||
primitive="cognitive.exploration_style",
|
||||
value=value,
|
||||
confidence=confidence,
|
||||
)
|
||||
|
||||
|
||||
def cognitive_load(ctx: SessionContext) -> Iterator[Observation]:
|
||||
"""Emit ``cognitive.cognitive_load`` ∈ {low, medium, high}.
|
||||
|
||||
|
||||
@@ -108,6 +108,26 @@ COGNITIVE_LOAD_PACE_REF_CV: float = 1.50
|
||||
COGNITIVE_LOAD_LOW_MAX: float = 0.33
|
||||
COGNITIVE_LOAD_MEDIUM_MAX: float = 0.67
|
||||
|
||||
# ── cognitive.exploration_style (Step D.2) ─────────────────────────────────
|
||||
# Two-axis classification over the first_token_hash sequence:
|
||||
#
|
||||
# repetition_rate (R) = 1 - (unique_first_tokens / total_commands)
|
||||
# backtrack_rate (J) = transitions where commands[i+1].first_token_hash
|
||||
# appeared anywhere in commands[0..i-1] but is NOT
|
||||
# equal to commands[i].first_token_hash (jumping
|
||||
# back to an older tool, not just repeating).
|
||||
#
|
||||
# J >= EXPLORATION_CHAOTIC_BACKTRACK_MIN → chaotic
|
||||
# else if R >= EXPLORATION_TARGETED_REP_MIN → targeted
|
||||
# else → methodical
|
||||
#
|
||||
# Methodical = low repetition, low backtracks (linear progression through
|
||||
# novel tools). Targeted = high repetition (drilling the same tool).
|
||||
# Chaotic = jumping between prior tools without a clear thread.
|
||||
# v0.1; D.8 re-tunes.
|
||||
EXPLORATION_TARGETED_REP_MIN: float = 0.50
|
||||
EXPLORATION_CHAOTIC_BACKTRACK_MIN: float = 0.30
|
||||
|
||||
# ── motor.keystroke_cadence (Step B.1) ──────────────────────────────────────
|
||||
# Typing bursts split at gaps > IKI_THINK_MAX_S so think-pauses between
|
||||
# commands don't inflate the within-burst CV. Mirrors the prototype's
|
||||
|
||||
Reference in New Issue
Block a user