Skip to content

fix: FakeBus does not fold the default session on receive#395

Closed
JarbasAl wants to merge 1 commit into
devfrom
fix/fakebus-default-session-guard
Closed

fix: FakeBus does not fold the default session on receive#395
JarbasAl wants to merge 1 commit into
devfrom
fix/fakebus-default-session-guard

Conversation

@JarbasAl

@JarbasAl JarbasAl commented Jul 1, 2026

Copy link
Copy Markdown
Member

Restores the if sess.session_id != "default" guard in FakeBus.on_message / AsyncFakeBus.on_message that #393 (commit 9317a8d) dropped.

Root cause

#393's message claimed to match the real MessageBusClient, but the real MessageBusClient.on_message still guards the default id (ovos-bus-client 2.6.2a2, line 263):

sess = Session.from_message(parsed_message)
if sess.session_id != "default":   # 'default' can only be updated by core
    SessionManager.update(sess)

Only the explicit ovos.session.update_default broadcast updates the default session. By dropping the guard, FakeBus diverged from production and folds the default session on every received message, wholesale-replacing the singleton's context with the incoming message's (pre-mutation) snapshot via Session.update_from.

This silently wipes every in-place add_context mutation the instant the next message is received — handle_add_context injects the token into the singleton's context, and FakeBus's emit then runs on_message on the same add_context message, folding its own pre-injection (token-less) snapshot back over the singleton.

What it breaks

Intent-layer gating (ovos-workshop IntentLayers, refactored to context-gating in OpenVoiceOS/ovos-workshop#427). activate_layer() calls set_context() -> add_context -> handle_add_context injects the layer_<name> token -> the very next emitted message folds a token-less default session snapshot and discards it -> gated intents never match. The two test_intent_layers_e2e.py tests started XFAILing right after 9317a8d landed (2026-06-29), inside the same singleton-registry refactor window as ovos-bus-client 2.6.2a1/a2.

after _utter('begin'): reached=['begin'] active_layers=['demo-layers.test:layer0']
post-begin TOKENS=[]           <- token injected by handle_add_context, then wiped by the next fold
layer0 token present: False

Fix

Restore the guard so FakeBus matches the real bus: the default session is never folded on receive. Verified locally:

post-begin TOKENS=['layer_layer0']   <- token survives
layer0 token present: True

and the full ovos-workshop/test/unittests/skills/test_intent_layers_e2e.py suite passes (both tests, previously XFAIL).

Production is unaffected (the real bus already guarded) — this is purely a test-harness divergence regression. No behavior change for non-default sessions.

🤖 Generated with Claude Code

on_message re-introduces the 'default' guard that the real
MessageBusClient.on_message keeps (line 263): the default session is
never folded on receive — only the explicit ovos.session.update_default
broadcast updates it.

Commit 9317a8d / #393 dropped that guard claiming to 'match the real
MessageBusClient', but the real bus still guards the default id. Folding a
stale token-less default snapshot back over the SessionManager singleton
on every received message wipes in-place add_context mutations, regressing
intent-layer gating: the activate_layer() context token is injected by
handle_add_context then immediately discarded by the next message's fold,
so gated intents never match.

Restoring the guard makes FakeBus match production again (production never
wipes, so layer gating works there) and un-breaks the ovos-workshop
intent-layers e2e suite that XFAILed after 9317a8d landed.
@coderabbitai

coderabbitai Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: ae751423-dc54-4638-8177-727aa572ebce

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/fakebus-default-session-guard

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added the fix label Jul 1, 2026
@github-actions

github-actions Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Beep boop! The automated check sequence is complete. 🦾

I've aggregated the results of the automated checks for this PR below.

📋 Repo Health

I've performed a health check on the project. 🏥

✅ All required files present.

Latest Version: 0.13.3a1

ovos_utils/version.py — Version file
README.md — README
LICENSE — License file
pyproject.toml — pyproject.toml
⚠️ setup.py — setup.py
CHANGELOG.md — Changelog
ovos_utils/version.py has valid version block markers

🔍 Lint

A quick update on the status of your PR. 🔔

ruff: issues found — see job log

🔒 Security (pip-audit)

I've checked the security of our build pipeline. 🏗️

✅ No known vulnerabilities found (47 packages scanned).

⚖️ License Check

Scanning for any 'no-derivatives' clauses. 🚫

✅ No license violations found.

Policy: Apache 2.0 (universal donor). StrongCopyleft / NetworkCopyleft / WeakCopyleft / Other / Error categories fail. MPL allowed.

🏷️ Release Preview

I've checked the countdown clock for the next release. ⏰

Current: 0.13.3a1Next: 0.13.4a1

Signal Value
Label (none)
PR title fix: FakeBus does not fold the default session on receive
Bump build

✅ PR title follows conventional commit format.


🚀 Release Channel Compatibility

Predicted next version: 0.13.4a1

Channel Status Note Current Constraint
Stable Too new (must be <0.9.0) ovos-utils>=0.8.1,<0.9.0
Testing Too new (must be <0.8.5) ovos-utils>=0.8.4,<0.8.5
Alpha Compatible ovos-utils>=0.13.3a1

📊 Coverage

Ensuring our tests aren't missing a beat. 🥁

85.1% total coverage

Files below 80% coverage (5 files)
File Coverage Missing lines
ovos_utils/log_parser.py 48.4% 225
ovos_utils/__init__.py 63.6% 16
ovos_utils/file_utils.py 73.3% 55
ovos_utils/thread_utils.py 76.9% 12
ovos_utils/geolocation.py 78.4% 22

Full report: download the coverage-report artifact.

🔨 Build Tests

The build report has been filed and is ready. 📁

✅ All versions pass

Python Build Install Tests
3.10
3.11
3.12
3.13
3.14

The automation never sleeps, but I might reboot. 💤

JarbasAl added a commit to OpenVoiceOS/ovos-workshop that referenced this pull request Jul 1, 2026
… pins

Root cause of the intent-layers e2e XFAILs is an upstream regression in
ovos-utils (#393 / 9317a8d): FakeBus.on_message dropped the
'if sess.session_id != "default"' guard that the real
MessageBusClient.on_message still keeps, so the default session is folded
on every received message, wiping every in-place add_context mutation
(intent-layer tokens included). Fixed in OpenVoiceOS/ovos-utils#395.

- test_intent_layers_e2e.py: revert the xfail markers added in this PR;
  both tests pass once ovos-utils >= 0.13.3a2 lands.
- test_base.py: replace test_on_event_end_is_intent_still_emits_utterance_handled
  (stale vs PIPELINE-1 §9.5) with two deterministic branches:
    * _defers_utterance_handled_to_core — modern core (>=2.3.0a1) owns the
      end-marker, so workshop must NOT also emit ovos.utterance.handled.
    * _emits_utterance_handled_legacy — absent/old core, workshop still emits
      (migration-window back-compat). Both monkeypatch _core_owns_utterance_handled.
- pyproject.toml: bump floors to the latest alphas that carry the
  singleton-registry SessionManager + §9.5 orchestrator ownership:
  ovos-utils >= 0.13.3a2, ovos_bus_client >= 2.6.2a2, ovos-spec-tools >= 1.2.3a1,
  ovos-core >= 2.4.0a1 (test), ovos-adapt-parser >= 1.4.2a1 (test).
@JarbasAl

JarbasAl commented Jul 1, 2026

Copy link
Copy Markdown
Member Author

Withdrawn — restoring the if sess.session_id != "default" guard is spec-violating (OVOS-CONTEXT-1 §4 / OVOS-SESSION-1: the default session folds like any other; §8 says mutations must propagate via ovos.session.sync, not be masked by an owner-only fold guard). Thanks for the correction; pursuing the spec-correct fix elsewhere.

@JarbasAl JarbasAl closed this Jul 1, 2026
@JarbasAl JarbasAl deleted the fix/fakebus-default-session-guard branch July 1, 2026 18:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant