feat(profiler/behave_shell): emit cognitive.command_branch_diversity

BEHAVE-EXTRACTOR.md Phase A Step 6. Content-based playbook-vs-
adaptive split. Splits CLAUDE-FF (linear_playbook, ~10 distinct
tools) from CLAUDE-CL (adaptive_branching, 5-6 tools with curl
re-invoked) per the 2026-05-02 empirical anchor.

* _features/cognitive.py:command_branch_diversity(ctx) emits one
  Observation in {linear_playbook, adaptive_branching, unknown}.
* unique_first_token_hashes / total_commands ratio. ≥ 0.80 →
  linear_playbook, otherwise adaptive_branching (the doc instructs
  bias-to-adaptive in the middle band — that's the discriminative
  signal we actually want).
* < 5 commands → "unknown" at confidence 1.0 (the absence of data
  is itself a high-confidence answer per the registry's allowed
  vocabulary). Zero-command session skips emission entirely.

Tests cover unique-tokens → linear, repeated-tokens → adaptive,
middle band → adaptive (bias), under-floor → unknown @ 1.0, plus
PII regression: raw tokens never appear in the serialised
observation.
This commit is contained in:
2026-05-03 07:54:13 -04:00
parent e52a0e0381
commit 3fc6ea5f75
3 changed files with 107 additions and 0 deletions

View File

@@ -12,6 +12,7 @@ from decnet_behave_core.spec.envelope import Observation
from decnet.profiler.behave_shell._ctx import SessionContext
from decnet.profiler.behave_shell._features.cognitive import (
command_branch_diversity,
inter_command_latency_class,
)
from decnet.profiler.behave_shell._features.motor import (
@@ -25,4 +26,5 @@ FEATURES: tuple[FeatureFn, ...] = (
input_modality,
paste_burst_rate,
inter_command_latency_class,
command_branch_diversity,
)