Skip to content

Add models for Node native actions (node.hello, node.invoke_native) - #35

Merged
NeonDaniel merged 2 commits into
NeonGeckoCom:devfrom
OscillateLabsLLC:FEAT_NodeNativeActions
Jul 21, 2026
Merged

Add models for Node native actions (node.hello, node.invoke_native)#35
NeonDaniel merged 2 commits into
NeonGeckoCom:devfrom
OscillateLabsLLC:FEAT_NodeNativeActions

Conversation

@mikejgray

Copy link
Copy Markdown
Collaborator

Adds the wire models for the Platform-Native Actions spec (PLATFORM_NATIVE_ACTIONS.md v0.3, approved in neon-node-design#3).

Changes

  • NodeHello — capability advertisement at WS connect. Carries node_id, user-editable node_name (US-N01), and a flat capabilities map.
  • NodeInvokeNative — Hub→Node action dispatch. params is an open dict; only launch_sms_app/launch_email_app read it in v1 (composer pre-fill).
  • NodeInvokeNativeResponse — Node→Hub ack. Validator enforces status: error carries an error object and status: success does not.
  • NodeNativeAction / NativeActionErrorCode enums — the authoritative wire strings for both sides.
  • NodeContext + optional MessageContext.node — the per-session identity/capability snapshot HANA stamps on outbound bus messages (Hub-side half of US-N01).

Design notes

  • capabilities is Dict[str, bool], not enum-keyed: a newer Node advertising an unknown capability must not fail validation on an older hub ("absent means unsupported"). action stays a strict enum so a hub never dispatches an action it doesn't recognize.
  • node_name is capped at 128 chars — it rides on every outbound bus message via context.node, so an unbounded value would be amplified per-message.
  • All changes are additive. MessageContext.node defaults to None; existing messages are unaffected.

Testing

New tests cover validation (unknown action/error code rejected, error-state coherence), serialization round-trips, as_messagebus_message output (enums arrive as wire strings), version-skew tolerance (unknown fields/params from newer Nodes), and the wire-string golden list.

Implements the wire models from PLATFORM_NATIVE_ACTIONS.md v0.3:
- NodeHello, NodeInvokeNative, NodeInvokeNativeResponse
- NodeNativeAction and NativeActionErrorCode enums
- NodeContext with optional MessageContext.node for the hub-stamped
  per-session capability snapshot

@NeonDaniel NeonDaniel left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Couple nits noted, but overall looks good

Comment thread neon_data_models/models/api/node_v1/__init__.py Outdated
Comment thread neon_data_models/models/base/contexts.py Outdated
- `params` enforces string keys (`Dict[str, Any]`)
- `capabilities` keys are typed as `NodeNativeAction` in both
  `NodeHelloData` and `NodeContext` via a shared `NodeCapabilities`
  type, preventing re-definition of equivalent actions under new names.
  Unknown keys are dropped rather than rejected so a newer Node cannot
  invalidate `node.hello` on an older hub; keys serialize back to wire
  strings.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@mikejgray
mikejgray requested a review from NeonDaniel July 21, 2026 01:09
@NeonDaniel
NeonDaniel merged commit 451cecc into NeonGeckoCom:dev Jul 21, 2026
5 checks passed
@mikejgray
mikejgray deleted the FEAT_NodeNativeActions branch July 21, 2026 01:48
NeonDaniel pushed a commit to NeonGeckoCom/neon-hana that referenced this pull request Jul 28, 2026
## Summary

Server side of the Node native actions spec (companion to
NeonGeckoCom/neon-data-models#35, now merged and consumed here as
`neon-data-models>=0.0.3a2`).

- **`node.hello`**: HANA validates the message, caches the Node's
identity/capability snapshot per session, and stamps it onto every
outbound bus message as `context.node` — skills read capabilities
synchronously with no extra round-trip. The token-derived session ID is
authoritative: a mismatched self-reported `node_id` is logged and
overridden, so a client cannot claim another Node's identity. Unknown
capability keys are dropped at validation (a Node newer than the hub's
schema must not fail its hello).
- **`node.invoke_native`**: a new `handle_neon_response` override
dispatches these from the MQ response queue and relays them to the
target Node's WebSocket. Everything else delegates to `NeonAIClient`
unchanged. The message is relayed as-is: the Node re-validates the
action and reports `not_supported` itself, which reaches the skill
faster than a hub-side drop would.
- **`node.invoke_native.response`**: passes through the existing
client-input path to the bus unchanged.
- `/node/v1/doc` signature updated so the new models appear in the
generated docs.

## Testing

- 20 new unit tests in `tests/test_mq_websocket_api.py` (previously a
TODO stub): hello caching/validation/identity, context enrichment, MQ
dispatch/delegation, response passthrough. 57 pass locally.
- Verified end-to-end against a live Hub running this branch: WebSocket
session as a real NODE-permission user — `node.hello` with a spoofed
`node_id` and an unknown capability key, `context.node` confirmed
stamped (string-keyed, unknown key dropped, session identity enforced)
via response context echo; `node.invoke_native` published to HANA's MQ
queue arrived on the client socket; response passthrough produced no
server-side errors.
NeonDaniel pushed a commit to NeonGeckoCom/neon-hana that referenced this pull request Aug 4, 2026
Implements the HANA half of `PLATFORM_NATIVE_ACTIONS.md` v0.3 (approved
in `neon-node-design#3`). Depends on the models from
`neon-data-models#35`, merged 2026-07-21 — this pins
`neon-data-models>=0.0.3a2`, which is a published release, so there is
no git pin to unwind.

## What's here

**`node.hello` handling.** Caches per-session `capabilities` and
`node_name` before forwarding to the bus.

The payload's self-reported `data.node_id` is treated as **informational
only** — the JWT-derived session id is authoritative for identity. The
cache is never keyed from it and `context.node.node_id` is never stamped
from it. Without that rule a Node could claim another Node's identity in
its hello.

**`context.node` enrichment.** Every outbound bus message from a Node
session carries `{node_id, node_name, site_id, capabilities}`, so a
skill's `if node:` branch reads capabilities synchronously instead of
round-tripping. This also closes the Hub-side half of US-N01.

**`node.invoke_native` dispatch.** Implemented as a peek-and-delegate
override of `handle_neon_response`: peek at `msg_type`, handle
`node.invoke_native` locally, delegate everything else to iris
unchanged. That avoids duplicating iris's dispatch and timing logic; the
cost is deserializing twice, which was accepted deliberately.

The hub relays the invoke **without validating the action**. A Node-side
`not_supported` reaches the skill faster than a hub-side drop, which
would make the skill wait out its full timeout with nothing in the logs.

**`node.invoke_native.response`** flows inbound through
`handle_client_input` unchanged, with a test confirming it.

## Tests

10 new in `tests/test_mq_websocket_api.py`, covering the trust rule,
context enrichment, dispatch, and the inbound response path.

Full suite: 56 passed, 1 failed. The failure is
`tests/test_auth.py::TestClientManager::test_check_auth_request`, which
**reproduces identically on clean `dev`** — pre-existing, unrelated to
this change.

## E2E validation

Verified 2026-07-18 against a live hub (this branch running locally on
:8083, wired to the hub's real MQ, driven by a scripted Node client):

- login (`node_auth`) → WS → `node.hello` → utterance → `klat.response`
- `context.node` stamped on the bus-side utterance (spy-verified) and
echoed back on `klat.response`
- trust rule fired live: a spoofed `node_id` in the hello logged a
warning and `context.node.node_id` stayed the session identity
- `node.invoke_native` published to HANA's MQ queue → delivered over WS
to the client
- `node.invoke_native.response` → arrived on the hub bus

## Also included

`scripts/inject_invoke_native.py` publishes a `node.invoke_native`
straight to HANA's MQ queue, standing in for a skill. It made the E2E
above repeatable and stays useful afterward: it isolates the Node app
from the skill layer, so a failure while running it is unambiguously
app-side. Happy to drop it from this PR if you'd rather it not ship in
the repo.

## Notes

- Touches `MQWebsocketAPI`, which has the known pika channel leak. Not
addressed here — expect restarts while live-testing.
- Gated on `NeonGeckoCom/neon-messagebus-mq-connector#66` for the skill
path end-to-end: that whitelist currently drops `node.invoke_native`, so
a skill's emission never reaches HANA. This PR is independently
reviewable; the two together complete the hub-side path.

## Related

- `NeonGeckoCom/neon-data-models#35` (merged) — the wire models
- `NeonGeckoCom/neon-messagebus-mq-connector#66` (open) — bus → MQ
forwarding
- Node app side: `OscillateLabsLLC/neon-node-flutter-app` commits
`2cde9af`, `1509ef2`
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