Skip to content

fix(channels): unify hot-activation owner_id type and capabilities fallback - #2471

Merged
ilblackdragon merged 6 commits into
stagingfrom
fix/hot-activation-owner-id-parity
Apr 18, 2026
Merged

ilblackdragon merged 6 commits into
stagingfrom
fix/hot-activation-owner-id-parity

Conversation

@serrrfirat

Copy link
Copy Markdown
Collaborator

Summary

Follow-up to #2349 addressing two "Concerning" items from @henrypark133's re-review:

  • Type consistency: build_wasm_channel_runtime_config_updates now takes Option<&str> and injects owner_id as Value::String, matching the boot path. Previously the hot-activation path injected Value::Number while the boot path used Value::String — WASM modules received different JSON types depending on which path ran.
  • Capabilities fallback parity: complete_loaded_wasm_channel_activation and refresh_active_channel now consult capabilities.json via the extracted owner_id_from_capabilities() helper when neither runtime HashMap nor settings store have an owner_id. Previously only the boot path had this fallback.
  • Telegram WASM module: Changed owner_id: Option<i64> to Option<String> with a custom deserializer that accepts both string and number JSON (all other channels already use Option<String>).

Depends on #2349 (branched from its HEAD).

Test plan

  • Existing owner_actor_id_* tests in setup.rs still pass (pure refactor of extraction)
  • Updated test_telegram_hot_activation_runtime_config_includes_owner_id asserts Value::String
  • New test_hot_activation_uses_capabilities_owner_id_fallback drives complete_loaded_wasm_channel_activation with capabilities-only owner_id and verifies both owner_actor_id and config injection
  • New telegram tests for string and numeric JSON deserialization
  • cargo clippy --all --benches --tests --examples --all-features — zero warnings
  • cargo test --lib — 4712 passed (1 pre-existing failure unrelated to this PR)

🤖 Generated with Claude Code

serrrfirat and others added 5 commits April 12, 2026 09:22
The bundled Telegram capabilities.json ships `"owner_id": null`. The
previous code only called `Value::as_i64()`, which returns `None` for
`Null`, so the fallback silently produced no owner — the fix never
actually worked for Telegram.

Changes:
- Handle `Null`, `String`, and `Number` variants in
  `owner_actor_id_for_channel()` so the real production payload works.
- Propagate the *resolved* owner_id into the WASM runtime config map
  regardless of whether it came from runtime config or capabilities
  fallback (previously only the runtime-config path injected it).
- Add `tracing::debug!` for non-scalar owner_id values to aid debugging.
- Add tests: null config, missing capabilities file, empty string,
  non-scalar value, and caller-level register_channel tests that verify
  config injection and null-owner-id handling.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…ot-activation

Address two follow-up items from PR #2349 review:

1. Type consistency: boot path injected owner_id as Value::String, but
   hot-activation path (build_wasm_channel_runtime_config_updates) used
   Value::Number. Changed the function to accept Option<&str> and inject
   as Value::String, matching the boot path.

2. Capabilities fallback: hot-activation paths (complete_loaded_wasm_channel_activation
   and refresh_active_channel) only checked runtime HashMap and settings store.
   Now they also consult capabilities.json via the extracted
   owner_id_from_capabilities() helper, matching the boot path's behavior.

Also updates the telegram WASM module to accept both string and number
JSON for owner_id via a custom deserializer, since all other channels
already use Option<String>.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@github-actions github-actions Bot added size: L 200-499 changed lines risk: medium Business logic, config, or moderate-risk modules scope: channel/wasm WASM channel runtime scope: extensions Extension management scope: dependencies Dependency updates contributor: core 20+ merged PRs and removed risk: medium Business logic, config, or moderate-risk modules labels Apr 14, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the handling of owner_id for Telegram and WASM channels, transitioning the field from a numeric type to a string to support both JSON numbers and strings. It introduces a robust fallback mechanism for resolving the owner ID by checking runtime configuration, the settings store, and the channel's capabilities file. Additionally, the PR includes new deserialization utilities, updated dependency versions in Cargo.toml, and comprehensive unit tests for the new resolution logic. I have no feedback to provide as there are no review comments.

@serrrfirat
serrrfirat marked this pull request as draft April 14, 2026 20:20
@serrrfirat
serrrfirat marked this pull request as draft April 14, 2026 20:20
@serrrfirat
serrrfirat marked this pull request as ready for review April 17, 2026 07:17
henrypark133
henrypark133 previously approved these changes Apr 17, 2026

@henrypark133 henrypark133 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review: hot-activation owner_id parity

No verified findings in the current diff.

The current head makes the boot path and hot-activation path agree on both owner-id typing and capabilities fallback, and the added tests cover numeric/string/null capability values plus the actual hot-activation call site. This is still stacked on #2349, so merge order matters, but I did not find a new blocker in this follow-up diff.

Conflicts resolved:
- Cargo.toml / deny.toml: trivial key reordering; kept the superset of
  advisory ignores from staging.
- src/channels/wasm/setup.rs: took staging's async
  resolve_owner_actor_id_for_channel (adds pairing_store fallback) and
  staging's crate::pairing::approval::build_runtime_config_updates helper.
  Kept this PR's extraction of owner_id_from_capabilities() so the
  hot-activation path can still reuse it. Tests updated to expect the
  numeric owner_id representation that the shared helper produces.
- src/channels/wasm/wrapper.rs: took staging's async owner_actor_id_for_test
  (field is now Arc<RwLock<Option<String>>>).
- src/extensions/manager.rs: dropped this PR's local
  build_wasm_channel_runtime_config_updates in favor of the shared helper
  (imported under the same name via a use-alias in staging). The
  capabilities fallback for complete_loaded_wasm_channel_activation and
  refresh_active_channel now chains with staging's pairing_store lookup
  (current_channel_owner_actor_id -> owner_id_from_capabilities).
- The test_hot_activation_uses_capabilities_owner_id_fallback and
  test_telegram_hot_activation_runtime_config_includes_owner_id assertions
  were updated from Value::String to the numeric representation produced
  by build_runtime_config_updates.
@github-actions github-actions Bot added the risk: medium Business logic, config, or moderate-risk modules label Apr 18, 2026
@ilblackdragon
ilblackdragon merged commit 06527e4 into staging Apr 18, 2026
16 checks passed
@ilblackdragon
ilblackdragon deleted the fix/hot-activation-owner-id-parity branch April 18, 2026 04:22
@ilblackdragon ilblackdragon mentioned this pull request Apr 18, 2026
5 of 7 tasks
ilblackdragon added a commit that referenced this pull request Apr 18, 2026
PR #2471 changed `TelegramConfig::owner_id` from `Option<i64>` to
`Option<String>` with a string-or-number deserializer, but missed the
test case in channels-src/telegram/src/lib.rs:2622 which still asserts
`Some(42)`. That breaks the Telegram Channel Tests CI job and has been
blocking the staging→main promotion PR #2612.

Also bump registry/channels/telegram.json from 0.2.9 to 0.2.10 so the
Version Bump Check passes (changing channels-src/telegram/ requires a
registry version bump).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@henrypark133 henrypark133 mentioned this pull request Apr 21, 2026
theredspoon pushed a commit to theredspoon/ironclaw that referenced this pull request Jun 21, 2026
…llback (nearai#2471)

* Fix WASM channel owner_id fallback

* ci: ignore rand advisory

* ci: satisfy cargo-deny path dependency versions

* fix(telegram): handle null/string owner_id and propagate to WASM config

The bundled Telegram capabilities.json ships `"owner_id": null`. The
previous code only called `Value::as_i64()`, which returns `None` for
`Null`, so the fallback silently produced no owner — the fix never
actually worked for Telegram.

Changes:
- Handle `Null`, `String`, and `Number` variants in
  `owner_actor_id_for_channel()` so the real production payload works.
- Propagate the *resolved* owner_id into the WASM runtime config map
  regardless of whether it came from runtime config or capabilities
  fallback (previously only the runtime-config path injected it).
- Add `tracing::debug!` for non-scalar owner_id values to aid debugging.
- Add tests: null config, missing capabilities file, empty string,
  non-scalar value, and caller-level register_channel tests that verify
  config injection and null-owner-id handling.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* fix(channels): unify owner_id type and add capabilities fallback to hot-activation

Address two follow-up items from PR nearai#2349 review:

1. Type consistency: boot path injected owner_id as Value::String, but
   hot-activation path (build_wasm_channel_runtime_config_updates) used
   Value::Number. Changed the function to accept Option<&str> and inject
   as Value::String, matching the boot path.

2. Capabilities fallback: hot-activation paths (complete_loaded_wasm_channel_activation
   and refresh_active_channel) only checked runtime HashMap and settings store.
   Now they also consult capabilities.json via the extracted
   owner_id_from_capabilities() helper, matching the boot path's behavior.

Also updates the telegram WASM module to accept both string and number
JSON for owner_id via a custom deserializer, since all other channels
already use Option<String>.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-authored-by: Illia Polosukhin <ilblackdragon@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

contributor: core 20+ merged PRs risk: medium Business logic, config, or moderate-risk modules scope: channel/wasm WASM channel runtime scope: dependencies Dependency updates scope: extensions Extension management size: L 200-499 changed lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants