Files
ruflo/scripts
rUv 90889f4772 feat(sona): default the learning mode from RUFLO_INTELLIGENCE_MODE (#3334)
* feat(sona): default the learning mode from RUFLO_INTELLIGENCE_MODE

The SONA learning mode was only settable per call (`config.mode`), defaulting
to `balanced` otherwise. A deployment that wants every session to learn in a
specific profile — a managed desktop fleet running `research` for +55% quality,
or `edge` on constrained hosts — had no way to set that default short of
threading `mode` through every call site or patching a generated helper.

This reads `RUFLO_INTELLIGENCE_MODE` as the fleet-wide default in both the SONA
config merge (`@claude-flow/integration` sona-adapter) and the memory learning
bridge (`@claude-flow/memory`). Precedence is unchanged where a caller is
explicit: `config.mode` (or `sonaMode`) still wins; the env only fills the
former default slot; and an unset or unrecognised value returns undefined so
the code falls through to `balanced` — a typo can never silently select a
profile nobody asked for. Validated against the mode enum in each package.

Co-Authored-By: claude-flow <ruv@ruv.net>
Claude-Session: https://claude.ai/code/session_01MUrJdDHhQ91hwpUBQhV4fC

* fix(sona): resolve sonaMode per-instance in LearningBridge, not at module load

learning-bridge.ts captured sonaModeFromEnv() into a module-scope
DEFAULT_CONFIG constant, evaluated once on first import — so any
RUFLO_INTELLIGENCE_MODE set later in the same process (including
test setup) was permanently missed. sona-adapter.ts's equivalent
(mergeConfig()) already re-reads the env var on every call; this
brings LearningBridge's constructor in line with that behavior,
preserving the same precedence (explicit config.sonaMode > env > default).

Adds regression tests for both packages (sona-adapter.ts had none
previously) and registers RUFLO_INTELLIGENCE_MODE in
KNOWN_ESCAPE_HATCHES per the audit script's existing requirement for
operator-knob env vars outside its SCAN_ROOTS.

Co-Authored-By: RuFlo <ruv@ruv.net>
Claude-Session: https://claude.ai/code/session_01SjxUvZnyBdwtx4Y1jKAqt6
2026-09-16 02:22:13 +00:00
..
2026-01-04 19:30:59 +00:00