Skip to content

fix(audio_player): accept stop()'s leftover sentinel in the drain test (#2306 to stage) - #2370

Open
kwit75 wants to merge 10 commits into
stagefrom
fix/audio-drain-test-to-stage
Open

kwit75 wants to merge 10 commits into
stagefrom
fix/audio-drain-test-to-stage

Conversation

@kwit75

@kwit75 kwit75 commented Sep 18, 2026

Copy link
Copy Markdown
Collaborator

Cherry-pick of e0033a207 (#2306) onto stage. Test-only, one file.

Why this matters for the release

This test is currently failing intermittently and it has already blocked a PR today:

FAILED test/audio_player/test_player_stop_empty_stream.py::test_begin_write_end_still_drains_normally - assert False
1 failed, 4894 passed, 241 skipped

It failed on saas#724, which changes two k8s YAML files and cannot affect a Python audio test.

The fix is already on develop but was never cherry-picked to stage, so it is in none of our pins, including b7764b8b which the release now pins. The same test can therefore fail the release build at random, and a staging rebuild costs ~46 minutes each time.

Yesterday's staging build passed on the same pin, so this is intermittent rather than always-red. That is exactly what makes it worth removing before a release rather than re-rolling the dice.

Scope

nodes/test/audio_player/test_player_stop_empty_stream.py   +90 -13

Test-only. No production code, no node behaviour, no schema.

@asclearuc this is your commit — tagging you since stage requires a review and admins are not exempt here.

If this merges I will bump the saas stage engine pin to the new tip straight after, so it actually reaches the release.

asclearuc and others added 10 commits September 18, 2026 19:08
After a Python lane handler returns normally, the engine also forwards the handler's input on the same lane. Only `preventDefault()` stops that. Four nodes returned normally, so downstream received the raw input next to the node's own output.

- `context_optimizer`: both exits of `writeQuestions` now end in `return self.preventDefault()`. Downstream no longer gets the untrimmed original next to the trimmed question.
- `summarization`: `writeText` and `writeTable` collect the text, then suppress the forward. Only the summary from `closing()` goes on.
- `tool_guild`: `writeText`, `writeQuestions` and `writeDocuments` collect, then suppress. The docstring claiming "overriding suppresses raw passthrough" is corrected.
- `tool_n8n`: the same for `writeText`, `writeQuestions`, `writeDocuments`, and every `writeImage` / `writeAudio` / `writeVideo` chunk.
- Missing docstrings added in the four node files.

Tests:

- `test_lane_forward_once_nodes.py`: delivery-count cases for every changed handler.
- New `summarization/test_summarization.py`: the node had no unit tests.
- `context_optimizer/test_all.py` and `test_tool_n8n.py`: direct handler calls now require the `PreventDefault` exception.
…rs (#1682) (#2353)

* fix(memory_persistent): prevent double-forward of questions and answers

* test(memory_persistent): assert preventDefault is called on explicit forwards

* docs(memory_persistent): note preventDefault() unreachability and test stub caveat

* fix(memory_persistent): cover all six exits with delivery-count tests

- Every exit of `writeQuestions` and `writeAnswers` now ends in `return self.preventDefault()`. The separate `return` after `preventDefault()` could never run, because `preventDefault()` raises.
- `test_node.py`: two tests for the invalid `session_id` paths, which no test reached before. Removing `preventDefault()` from either path now fails a test.
- `test_lane_forward_once_nodes.py`: six delivery-count cases, one per exit (no store, invalid session, normal path), under the engine's forward rule. On the normal path, only the enriched or stored copy reaches downstream, never the original.
- Docstrings in `IInstance.py` now document their arguments.

---------

Co-authored-by: Abdul-Raqib Islam <86812966+PianoFanatic13@users.noreply.github.com>
…l sends (#2346) (#2351)

* fix(ai): accept the single-component validation payload the node panel sends

The node config panel validates one component on save and sends
`{version, component}` — the `IComponentValidatePayload` shape the shell
contract declares this endpoint accepts (shell/src/types/project.ts:308). The
engine validates pipelines and requires `components`, so every save answered
"'pipeline.components' must be an array", whatever the node.

The component now travels as a one-item `components` list, built before the
source is inferred so `resolve_implied_source` sees it. A config that already
carries `components` is untouched.

Reachable since #1573: until then `rrext_validate` failed on every call with
"'pipeline' is missing or invalid", so this payload never reached the
validator. The panel has sent this shape since #1843 (7 Aug).

Removing the four lines fails the two new tests, and the engine itself answers
the reported message:

    validatePipeline({'pipeline': {'version': 1, 'component': c}})    -> "'pipeline.components' must be an array"
    validatePipeline({'pipeline': {'version': 1, 'components': [c]}}) -> 0 errors

* docs(clients,ai): document the single-component validate payload

The endpoint now accepts {version, component} as well as a full pipeline, which
is a public-contract change: both SDK references say so, and on_rrext_validate's
Args: block does too — the inline comment explained it, but the docstring is
what a reader hits first.

Also states that a payload carrying both keys keeps 'components' and drops the
stray 'component', so the next reader does not have to derive that it is
deliberate.
…, engine URI, tools) (#2315) (#2354)

* fix(mcp): refuse query-string credentials on /mcp and never fall back to the shared client for authenticated callers

AuthMiddleware falls back to `?auth=` when no Authorization header is sent,
but auth.authorize() only read the header. `POST /mcp/?auth=<key>` therefore
passed the middleware, skipped every /mcp check (tk_/pk_/cd_ refusal, JWT
signature, issuer, audience) and ran tools on the server's shared engine
client.

- authorize() now refuses any request carrying an `auth` query parameter
  (parsed as Starlette parses query_params), per the MCP authorization spec.
- Defence in depth: a request the middleware authenticated
  (scope['state']['account']) that carries no header credential is refused
  instead of served by the shared client. The credential-less dev bypass
  (public route, no account) is unchanged.



* fix(mcp): reserve /mcp for the MCP API — move the shell page to /mcp-server and route bare /mcp to the handler

The shell registered a public GET page at /mcp. The MCP endpoint is a
Starlette Mount, which only matches /mcp/..., so the page won the bare
path: POST /mcp answered 405 with no WWW-Authenticate challenge (spec
clients POST to the advertised resource .../mcp and never saw the OAuth
challenge), and AuthMiddleware treated every /mcp request as public.
add_route's duplicate check never saw the clash because the Mount goes
straight onto the router.

- shell: the MCP marketing page moves to /mcp-server (still unlisted).
- mcp: an exact, method-agnostic Route serves bare /mcp alongside the
  Mount, so /mcp and /mcp/ reach handle_mcp identically (no 405/307).
- mcp: initModule refuses to start if any route already claims /mcp or
  /mcp/*, or a public pattern matches the endpoint.
- mcp: MCP_DEV_NO_AUTH now opens exactly /mcp and /mcp/ (loopback only).



* feat(mcp): default the engine URI to the public MCP origin, or the local address on loopback binds

ROCKETRIDE_URI had no default, so on staging/prod every MCP tool call
raised "Missing engine URI". The URI is now resolved once in initModule
and injected into the config every engine client is built from, and it
also drives the widget CSP origin and the upload/dropper links:

1. explicit: config rocketride_uri / env ROCKETRIDE_URI, used as-is
2. loopback default: ws://127.0.0.1:<port> (ws://[::1]:<port>) so a
   laptop engine never silently calls RocketRide's cloud
3. public default: the MCP_RESOURCE_IDENTIFIER origin, https->wss /
   http->ws (default wss://api.rocketride.ai)

One startup log line names the resolved URI (userinfo/query stripped)
and the rule that chose it. ROCKETRIDE_AUTH/APIKEY handling is unchanged.



* fix(mcp): only offer send_files on loopback-bound engines — it reads paths on the engine host

The SDK's send_files checks and opens each caller-supplied path on the
machine running the MCP module. On a deployed engine that is our server, so
any authenticated caller could probe file existence ("File not found") and
upload server files into their own pipeline.

initModule now decides local_engine = is_loopback_bind(bind_host) once and
passes it to build_mcp_server -> ToolRegistry(local_engine=...). Tools
registered local_engine_only (send_files) are neither listed nor dispatched
on a deployed engine: a call by name gets an Unavailable refusal that ignores
the client and arguments. The registry defaults to the deployed surface.
Loopback binds are unchanged.

Also corrects the send_files description (engine-host paths, not
store-relative), drops the stale "or filepath" from run_pipeline, and
updates the MCP docs and agent skill contract.



* fix(mcp): send no SDK env from deployed engines so caller secrets keep precedence

WsEngineClient built RocketRideClient(uri, auth) with no env, so the SDK
loaded os.environ plus ./.env and use() forwarded every ROCKETRIDE_* var as
the run's env. The engine applies caller env last, over org/team/user
secrets, so on a deployed engine the server's own ROCKETRIDE_* vars
overrode a customer's same-named secrets for MCP-started runs.

initModule injects local_engine (the same loopback decision that gates
send_files) into config alongside the resolved URI; make_engine_client
builds the client with env={} unless it is set. Loopback binds keep the SDK
default. Explicit uri/auth are unaffected.



* fix(mcp): rewrite deploy tools against the current SDK deploy API

The MCP deploy tools (#1880) were written against a Python SDK deploy API
that deploy-2 (#1764, 0dfdc8b) had already removed. In production every
call failed: deploy_add passed a `schedule` kwarg add() no longer takes,
deploy_status/deploy_update called methods that no longer exist,
deploy_remove omitted the now-required team_id, and deploy_list counted
the keys of the {rows,total,page,pageSize} envelope. The suite stayed
green because FakeEngine and the seam tests mirrored the old API.

The seam (WsEngineClient) is now one keyword-argument passthrough per
DeployApi method, and the tools are thin wrappers in the
teams-as-environments model:

- deploy_add -> add (pipeline, comment, deploy_to)
- deploy_list -> list (team_id, paging, search, filters, sort); returns
  deployments + count/total/page/pageSize
- deploy_status -> get (project_id, team_id)
- deploy_versions -> versions (project_id, paging)
- deploy_to_team -> deploy (project_id, version, team_id)
- deploy_set_schedule -> set_schedule (project_id, source_id, schedule,
  team_id, ttl)
- deploy_enable / deploy_disable / deploy_remove -> enable / disable /
  remove (project_id, team_id)

deploy_update is gone; its operations are deploy_add + deploy_to_team and
deploy_set_schedule. The rocketride://pipelines resource returns the
unwrapped envelope. Tool count: 33 (32 on a deployed engine).

Drift guard: test_engine.py calls every deploy_* seam method against a
recording fake and binds each recorded call to the real
rocketride.deploy.DeployApi signature (method must exist, arguments must
bind, every seam argument must arrive under the same name). It fails on
the old seam code. A second test pins the EngineClient protocol and the
conftest FakeEngineClient to the seam's deploy signatures.



* fix(task_http): don't re-send engine env as caller env from task_Execute on deployed engines

task_Execute built RocketRideClient(uri, auth) with no env, so the SDK
snapshotted os.environ plus ./.env and use() forwarded every ROCKETRIDE_*
var as the run's caller env. The engine applies caller env last, over the
org/team/user secrets from get_merged_env, so on a deployed engine the
server's own ROCKETRIDE_* vars overrode a user's same-named secrets for
runs started via POST /task.

Apply the rule MCP already uses (7670865): the client is built with
env={} unless the server's configured bind host is loopback
(ai.modules.mcp.auth.is_loopback_bind, falling back to the same
CONST_DEFAULT_WEB_HOST WebServer binds with). Loopback binds keep the SDK
default so a local developer's .env still applies. The MCP import is
deferred so loading task_http doesn't pull in the MCP package.



* fix(mcp): close the credential-less auth hole and harden the MCP boundary (#2315)

Addresses the four review findings on PR #2315.

1. Log the resolved bind mode at startup. `is_loopback_bind` judges the
   CONFIGURED host and `CONST_DEFAULT_WEB_HOST` is 'localhost', so a
   deployment that never sets `host` silently runs as a local engine.
   `is_loopback_bind` is unchanged (as the reviewer asked); instead the first
   lines of the log now state the mode, the host it was judged from, and what
   that grants (dev-bypass eligibility, `send_files`, caller-env forwarding),
   with a WARNING when the bind is loopback only by fallback.

2. Refuse credential-less MCP requests. A public route pattern matching an
   MCP descendant (`/mcp/{path}`) makes AuthMiddleware skip the request while
   the Mount still forwards it to `handle_mcp`, where `authorize()` used to
   return None and run tools on the shared, server-identity engine client.
   Both ends are fixed: `authorize()` now refuses a request with no credential
   unless the loopback dev bypass is genuinely active, and the startup guard
   probes representative descendant paths through `is_public_route`, not just
   `/mcp` and `/mcp/`. The bypass rule itself lives in one place --
   `auth.dev_bypass_active` -- used by both `initModule` and `authorize`.

3. Require encrypted engine transport on a non-loopback bind. `handle_mcp`
   hands the caller's credential to `WsEngineClient`, which sends it in the
   first DAP `auth` message, so a `ws://`/`http://` engine URI (explicit or
   derived from the MCP resource identifier) now fails boot with a message
   naming the value and the variable it came from. Loopback binds keep
   cleartext; the https staging/prod defaults are unaffected.

4. Reconcile MCP_TOOL_CONTRACT.md with the registrations. The tables listed
   ~23 of the 33 registered tools: `resolve_config` and `scaffold_node` were
   undocumented and grouped capability rows hid individual tools. Every tool
   now has its own row derived from its real schema and result, and the stale
   `origin/develop @ eb67dde` pin is replaced with what is accurate now.

Test-first: 27 new tests fail against the previous implementation. Three
existing tests encoded behaviour findings 2 and 3 deliberately change and were
updated; the WebServer-backed route tests now clear ROCKETRIDE_URI /
MCP_RESOURCE_IDENTIFIER after construction so a developer's dist/server/.env
no longer decides what they resolve.

717 passed, 0 skipped (was 683).



* fix(mcp): key the startup guards on patterns and targets, not probes and binds (#2315)

Three follow-ups to the review findings on PR #2315.

1. The startup guard now inspects the registered public PATTERN STRINGS, not
   just probe literals. Public entries are compiled with `compile_path`, so a
   converter-typed pattern (`/mcp/{id:int}`, `/mcp/{x:uuid}`) narrows the regex
   to values no fixed probe satisfies -- the guard missed it while
   AuthMiddleware still skipped auth for every `/mcp/<digits>` the Mount
   forwards. `_registered_public_patterns` reads `_public_paths` (real
   WebServer) and `public` (test double), the same pair the dev bypass already
   writes to, and degrades to nothing when neither is present.
   `_claims_mcp_pattern` normalises (whitespace, trailing slashes) and refuses
   only a whole-segment match, so `/mcp`, `/mcp/` and `/mcp/{...}` trip while
   `/mcpx` and `/mcp-server` do not. Message shape and per-claimant naming are
   unchanged.

2. The cleartext refusal now keys on the engine URI's TARGET HOST rather than
   the bind. A credential sent to `ws://127.0.0.1:5565` never reaches a wire
   anyone can tap, and the bind-keyed rule was a deployment hazard:
   `WebServer.__init__` loads `dist/server/.env`, `.env.template` ships
   `ROCKETRIDE_URI=http://localhost:5565`, and `docker/Dockerfile.engine`
   copies `dist/server/` into the image, so a pod carrying that file would have
   failed to boot. `auth.is_loopback_bind` judges a configured bind string
   against exact literals and does not fit a URI netloc (userinfo, port, IPv6
   brackets, the whole 127.0.0.0/8 range), so a small `_targets_loopback_host`
   helper was added next to the rule instead of bending it; it still reuses
   `auth.LOOPBACK_HOSTS` for the by-name allowlist. Non-loopback targets fail
   boot as before, with the same redaction.

3. `MCP_TOOL_CONTRACT.md`'s `scaffold_node` row described only
   `local_nodes/<name>/...`, so a contract-following client omitted the
   `local_nodes/__init__.py` package marker `_scaffold_node` also returns and
   the engine could not import `local_nodes.<name>`. The row now names the
   marker and says to write every returned path; `docs/public/mcp/http/tools.md`
   carried the same omission and is corrected too. The engine-module doc now
   states the target-keyed transport rule.

Test-first for 1 and 2: 46 new tests fail against the previous implementation.
No existing test encoded the old bind-keyed rule (every refusal case already
used a non-loopback target), so none needed updating.

763 passed, 0 skipped (was 717).



* fix(mcp): refuse a cleartext engine URI on every bind, not just a public one (#2315)

Closes the gap the previous commit left in `_resolve_engine_uri`. That commit
moved the cleartext refusal onto the engine's TARGET host
(`_targets_loopback_host`), but the explicit branch still guarded the call with
the BIND:

    if explicit:
        if not loopback:
            _refuse_cleartext_engine_uri(...)

so a loopback-bound MCP server with `ROCKETRIDE_URI=ws://engine.remote:5565`
skipped the check entirely and sent the CALLER's credential over the network in
the clear -- `handle_mcp` binds it to the per-request engine client and
`WsEngineClient` puts it in the first DAP `auth` frame. The bind says nothing
about whether the wire is exposed; only the target does.

`_refuse_cleartext_engine_uri` now runs for every explicit URI, on any bind,
with the same `rocketride_uri` / `ROCKETRIDE_URI` source naming and the same
redaction. Loopback TARGETS stay allowed inside the helper, so the shipped
`dist/server/.env` (`ROCKETRIDE_URI=http://localhost:5565`) still boots. The
local `loopback` variable is gone: `auth.is_loopback_bind` is now read inline
where it genuinely selects the DEFAULT URI, so no bind-keyed condition is left
anywhere near the encryption rule. The `loopback default` branch resolves
`ws://127.0.0.1:<port>`, a loopback target, and the `public default` branch
already called the helper.

Docs and docstrings that stated the old bind-keyed rule now say the check keys
on the target host: `_resolve_engine_uri`, `initModule`,
`_refuse_cleartext_engine_uri`, and `docs/development/engine/mcp-module.md`.
`docs/public/mcp/http/self-hosting.md` never stated the rule at all even though
it fails an operator's boot, so its guard list now carries it.

Test-first: 8 new cases fail against the previous implementation (explicit
`ws://` and `http://` remote targets on `127.0.0.1` / `localhost` / `::1`
binds, from env and from config, redaction included), plus explicit `wss://`
accepted on any bind and the loopback-target cases extended over loopback
binds. Two existing tests used an explicit remote `ws://` URI incidentally --
one for dropper-link origins, one for `engine_origin` threading -- and now use
`wss://`; neither was asserting the transport rule.

794 passed, 0 skipped (was 763).



---------


(cherry picked from commit 0d12d30)

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
Co-authored-by: Krish Garg <kg@g14-node1.tailb99b1b.ts.net>
* fix(search-hybrid): isolate fallback identities

Closes #2322

* test(search-hybrid): cover empty-ID fallback

Addresses CodeRabbit review on #2329

---------

Co-authored-by: Krish Garg <kg@g14-node1.tailb99b1b.ts.net>
Co-authored-by: Krish Garg <kg@g14-node1.tailb99b1b.ts.net>
Co-authored-by: Krish Garg <kg@g14-node1.tailb99b1b.ts.net>
* fix(notion): accept search pagination cursors

* test(notion): cover empty search cursors

---------

Co-authored-by: Krish Garg <kg@g14-node1.tailb99b1b.ts.net>
#2306)

`stop()` queues its own `None` sentinel when it starts waiting before the audio callback has reached the decoder's. The callback stops at the first `None`, so the second one stays in the queue. `test_begin_write_end_still_drains_normally` still required an empty queue, so it failed whenever `stop()` won that race, which happens on a loaded CI runner.

- The drain test now accepts `[]` or `[None]` as the leftover. Unplayed audio still fails it.
- New `test_stop_waiting_before_the_callback_leaves_only_its_own_sentinel` forces the `stop()`-first order. It requires exactly `[None]` to be left, all audio played, and `stop()` returned.
- The shared setup moved into `_player_with_queued_audio()` and `_start_simulated_hardware()`.

(cherry picked from commit e0033a2)
@coderabbitai

coderabbitai Bot commented Sep 18, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

🗂️ Base branches to auto review (2)
  • develop
  • release/.*

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: Repository: rocketride-org/rocketride-server/.coderabbit.yaml

Review profile: ASSERTIVE

Plan: Advanced

Run ID: 25c1afef-c580-40ce-9f5f-d7e2ece7a370

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

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 module:nodes Python pipeline nodes label Sep 18, 2026
@github-actions

Copy link
Copy Markdown
Contributor
🤖 Internal: Discord sync marker

Auto-managed by the Discord notification workflow. Stores the linked Discord message ID and forum thread ID. Do not edit or delete.

asclearuc
asclearuc previously approved these changes Sep 19, 2026
@dk-rocketride
dk-rocketride dismissed asclearuc’s stale review October 16, 2026 18:09

The merge-base changed after approval.

@joshuadarron joshuadarron 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.

Verdict: Request changes

This PR was meant to cherry-pick #2306 (one test file) onto stage. That fix has since landed on stage as e0033a20: git diff origin/stage pr2370 -- nodes/test/audio_player/ is empty. Meanwhile the branch carries nine other already-merged commits, so the PR now shows +4700/-500 across 57 files and conflicts with stage. As it stands, nothing in it still needs merging.

Blocking

  • Merge conflicts with the base branch. Rebase or merge the base branch and resolve them.
  • No linked issue. Link one with a closing keyword in the PR body (for example: Closes #123).
  • UI files changed with no screenshots in the PR body. Add before and after screenshots. Files: docs/public/mcp/http/index.mdx, docs/public/mcp/http/resources-and-widgets.md, docs/public/mcp/http/self-hosting.md, docs/public/mcp/http/tools.md. (These docs files come from the stale commits, not from this change. Dropping those commits clears this item.)
  • Scope: the diff does not match the PR body. The body says "Test-only, one file", but the branch includes #2352, #2355, #2357, #2358, #2359, #2365, the MCP HTTP rework (93e5ebae1), and the memory_persistent and validation-payload fixes. Close this PR, because its one intended change is already on stage via e0033a20. If something is still missing from stage, open a new PR from a fresh branch off origin/stage that contains only that commit.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

module:nodes Python pipeline nodes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants