Skip to content

Ls/async engine singleton#254

Closed
cmttt wants to merge 8 commits into
roostorg:mainfrom
cmttt:ls/async-engine-singleton
Closed

Ls/async engine singleton#254
cmttt wants to merge 8 commits into
roostorg:mainfrom
cmttt:ls/async-engine-singleton

Conversation

@cmttt
Copy link
Copy Markdown
Collaborator

@cmttt cmttt commented May 14, 2026

Description

Checklist

  • Tests pass locally
  • uv run ruff check . passes (no unused imports or other lint errors)
  • uv tool run fawltydeps --check-unused --pyenv .venv passes (no unused dependencies)
  • Updated CHANGELOG.md with my changes, if applicable

cmttt and others added 8 commits May 7, 2026 22:57
Adds an asyncio-native osprey worker as a sibling package to the gevent
worker. Includes coordinator input stream, sinks (rules, output), pigeon
client + interceptors, etcd-backed sources provider, executor, and engine.
Coordinator gains a bidirectional stream and pigeon module.

Subsequent tuning to match the gevent baseline:
- Move recompile off the event loop; force gc.collect after engine swap
- Match gevent's compile CPU profile (and later remove the gc.collect hack)
- Empirically widen pause-input-stream jitter (final: 0-600s)
- Preserve WatchMux dedup state across watcher iteration
Engine: AST/grammar tweaks, executor and execution-context refinements,
UDF helpers, stdlib UDF updates (categories, experiments, json_data, rules,
string), external service utils.

Worker: udf_register, osprey_engine, sources_provider (incl. skipping engine
recompile on no-op etcd sources events), output/rules sinks.

Plus repo housekeeping: CODEOWNERS, PR template, dev workflow doc, and a
small UI polish in FeatureSelectModal.
- _mux.py / test_watcher_mux.py: preserve dedup state correctly across
  watcher iteration.
- watcherd_impl.py: downgrade etcd watcher reconnect logs from exception
  to warning (these reconnects are routine, not errors).
- action.proto + generated pb2/pb2.pyi: add GuildBatchMLScore action.
add and register count regex matches udf
* Bootstrap async UDFs through first-party plugin hook

Move the async-stdlib MXLookup override from a hardcoded list inside
bootstrap_async_udfs into a small first-party pluggy plugin module
(stdlib_udfs/_async_stdlib_plugin.py).

The plugin registers async-native stdlib replacements through the same
register_udfs hook used by discord_osprey_async_plugins. _deduplicate_udfs
already handles override-by-class-name, so MXLookup (async) automatically
shadows MXLookup (sync) — no special path.

Adding a new async stdlib override now means: drop the class file in
stdlib_udfs/ and append it to _async_stdlib_plugin.register_udfs(). No
edits to bootstrap_async_udfs required.

* Tests for async UDF bootstrap behavior

Lock down that bootstrap_async_udfs:
- resolves MXLookup to the async-native class (not sync stdlib)
- doesn't leak SyncMXLookup into the registry
- preserves non-overridden stdlib UDFs (JsonData, Rule)
- registers the first-party async-stdlib plugin via the same hook
  used by third-party plugins
- emits AsyncMXLookup through the register_udfs hook
Mirrors the gevent osprey.worker.lib.singletons.ENGINE pattern so migrating
services (smite_ui_api, smite_rules_api, webhook_sink, bulk_label_sink) can
get a lazily-initialized AsyncOspreyEngine via ENGINE.instance().

Also adds get_feature_name_to_entity_type_mapping and
get_post_execution_feature_name_to_value_type_mapping on AsyncOspreyEngine,
mirroring the gevent OspreyEngine methods of the same names.
@cmttt cmttt requested review from a team, EXBreder, ayubun, haileyok and vinaysrao1 as code owners May 14, 2026 01:03
@cmttt cmttt closed this May 14, 2026
@cmttt cmttt deleted the ls/async-engine-singleton branch May 14, 2026 01:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants