Skip to content

Add a neutral daemon:data-plane-ready event and stop reloading on pro:tier-detected #3318

Closed as not planned

Description

@mstomar125

Summary

The free app reloads schemas and collections when pro:tier-detected fires. That works only because the Pro capability probe happens to be the first real gRPC round trip at startup.

This issue:

  • adds one shared, bounded data-plane round trip to GrpcClient, and makes the wedge probe in probe_and_recover_channel use it, with the same semantics;
  • emits a neutral daemon:data-plane-ready event from core's startup task, after the post-startup reachability check succeeds and the daemon answers (ADR-082 (proposed) §3.4);
  • switches app-shell.svelte to that event;
  • replaces the tautological test with a source-contract test.

The Pro probe and its pro:tier-detected emit stay untouched; #3334 deletes them. After this issue, #3334 can do so without silently dropping the free app's reload.

Context (main @ af8ddb6; locate by symbol)

  • The emitter. In src-tauri/src/lib.rs run(), the spawned startup task runs the Pro probe block (607-635), which emits pro:tier-detected whatever the outcome. The post-startup reachability check follows (637-663): check_daemon_socket on resolve_socket_path(). On NotRunning it logs nodespaced unreachable after startup and emits daemon-status: not_running.

  • The listener. In src/lib/components/layout/app-shell.svelte:

    • import { schemasData } (22); this listener is its only use;
    • unlistenTier (249);
    • the listener (277-284), which calls schemasData.loadSchemas() and collectionsData.loadCollections();
    • its cleanup (599-601).

    Its comment gives the reason for it: healthy only proves the socket accepts a connection (daemon_setup.rs check_daemon_socket, a UnixStream::connect), not that gRPC answers.

  • Duplicated probe logic. src-tauri/src/commands/nodes.rs probe_and_recover_channel has a private probe(). It sends one GetNode for __ns_channel_probe__ bounded by 5 s, treats any completion as live, and treats only a timeout as a wedge. A healthy daemon answers that id with NotFound (packages/daemon/src/services/node_service.rs get_node).

  • The only test is a tautology. src/tests/unit/props-driven-components.test.ts 246-270 defines its own handler and calls it.

  • The doc. src/lib/services/daemon-status.ts 17-19 describes the module as generalising "the one-off pro:tier-detected reload pattern".

  • ADR-082 §3.4 says this reload must not be lost silently: core emits a core-named event after its post-startup reachability check succeeds.

Scope

  1. src-tauri/src/services/grpc_client.rs
    • Add pub const DATA_PLANE_PROBE_TIMEOUT: Duration = Duration::from_secs(5); and the sentinel id __ns_channel_probe__, moved from nodes.rs.
    • Add #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub enum DataPlaneRoundTrip { Answered, Failed(tonic::Code), TimedOut }:
      • Answered: a response, or NotFound, which is what a healthy daemon returns for the sentinel id;
      • Failed(code): the call completed with any other status, such as a transport failure while nothing serves the socket, or a daemon-side error;
      • TimedOut: no completion within the timeout, meaning a wedged channel or a daemon that does not answer.
    • Add pub async fn data_plane_round_trip(&self, timeout: Duration) -> DataPlaneRoundTrip to impl GrpcClient, next to channel(). It sends one GetNode for the sentinel id on self.client().await, inside tokio::time::timeout.
  2. src-tauri/src/commands/nodes.rs probe_and_recover_channel
  3. src-tauri/src/lib.rs
    • Next to check_daemon_status, add pub const DATA_PLANE_READY_EVENT: &str = "daemon:data-plane-ready";. Document it as emitted at most once per app start, after the post-startup reachability check, when the daemon answers a real gRPC round trip, with a null payload.
    • In the startup task, clone the client before it moves into start_token_stream_subscription, for example let data_plane_client = grpc_client.clone();.
    • Make the reachability block evaluate to socket_reachable: true unless check_daemon_socket reports NotRunning. Keep its not_running emit and the nodespaced unreachable after startup log line byte-identical; Add daemon-ready tasks and a channel-rebuilt hook to AppExtensions #3307's source-text test anchors on that line.
    • After that block, at the end of the task:
      • if socket_reachable and data_plane_client.data_plane_round_trip(DATA_PLANE_PROBE_TIMEOUT).await is Answered, call app_handle.emit(DATA_PLANE_READY_EVENT, ()). This is a broadcast, like the event it replaces. Log tracing::warn! if the emit fails, and tracing::info! when it succeeds.
      • Otherwise log a tracing::warn! with the outcome and emit nothing.
    • Reword the reachability comment (637-646). It says "After the probe has exercised the channel"; describe the socket check without referring to the probe.
    • Do not change the Pro probe block (607-635), or Add daemon-ready tasks and a channel-rebuilt hook to AppExtensions #3307's channel-ready hook call if Add daemon-ready tasks and a channel-rebuilt hook to AppExtensions #3307 has landed.
  4. src/lib/services/daemon-status.ts
    • Export DATA_PLANE_READY_EVENT = 'daemon:data-plane-ready', documented as mirroring the Rust constant.
    • Reword the module doc at 17-19 so it names the neutral event and no Pro event.
  5. src/lib/components/layout/app-shell.svelte
    • Add DATA_PLANE_READY_EVENT to the existing $lib/services/daemon-status import.
    • Rename unlistenTier (249) to unlistenDataPlaneReady, and rename its cleanup (599-601) to match.
    • Replace 277-284 with a listener on DATA_PLANE_READY_EVENT that makes the same two calls. Its comment describes gRPC readiness and does not mention Pro.
    • Keep import { schemasData }. Leave the proSync lines (36, 248, 256-263, 605) for Stop driving Pro sync lifecycle from the app shell, database store and debug channel #3329.
  6. src/tests/unit/props-driven-components.test.ts
    • Replace the tautological test (246-270) and keep the NavigationSidebar Tauri independence describe.
    • The new tests read source with node:fs readFileSync. The cwd is packages/desktop-app, as in src/tests/services/persistence-timing-constants.test.ts. They assert:
      • app-shell.svelte contains listen(DATA_PLANE_READY_EVENT, and the 300 characters after it contain schemasData.loadSchemas() and collectionsData.loadCollections();
      • app-shell.svelte does not contain the legacy event name. Build that needle from fragments (['pro', 'tier-detected'].join(':')), per Add the Pro-boundary ratchet check and the CLAUDE.md Pro/sync placement rule #3299's absence-test convention, so neither the ratchet nor any rg pro:tier-detected search matches this test;
      • DATA_PLANE_READY_EVENT is 'daemon:data-plane-ready', and src-tauri/src/lib.rs (or the constant's new file, if Split the desktop Tauri crate and add ADR-082's Tauri extension points #3322's library split moved it) contains that value in double quotes;
      • navigation-sidebar.svelte does not import @tauri-apps/api/event.

Out of scope

Coordination

Steps

  1. Run the CLAUDE.md startup sequence:
    • git pull origin main in the primary checkout;
    • EnterWorktree({name: "issue-<N>-data-plane-ready-event"});
    • bun install;
    • a bun run test baseline;
    • bun run gh:assign <N> "@me";
    • bun run gh:status <N> "In Progress".
  2. Add data_plane_round_trip, the enum and their unit tests, and point probe_and_recover_channel at them.
  3. Add the Rust constant, the emit, the comment rewording and the source-text test in lib.rs, plus the integration test.
  4. Add the TS constant and the doc rewording, switch app-shell.svelte, and replace the test.
  5. Run bun run scripts/check-pro-boundary.ts and paste the printed BASELINES.
  6. Finish and ship:
    • bun run test:changed;
    • bun run quality:fix, then commit;
    • git push origin HEAD:issue-<N>-data-plane-ready-event;
    • gh pr create --repo NodeSpaceAI/nodespace-core --head issue-<N>-data-plane-ready-event;
    • /pragmatic-code-review, then /address-review, until no re-review is needed;
    • after the user approves, bun run merge <PR#> in the background.

Standards:

  • No #[allow(dead_code)].
  • No issue numbers in code comments.
  • Use createLogger, not console.*.
  • Run frontend tests with bun run test, never bun test.

Acceptance criteria

  • GrpcClient::data_plane_round_trip returns Failed(_) for a refused endpoint and TimedOut for one that accepts but never answers (unit tests), and Answered against a real daemon (integration test).

  • probe_and_recover_channel behaves as before: any completion is live, and only a timeout rebuilds the channel. src/tests/services/daemon-status.test.ts passes unchanged.

  • Each app start emits daemon:data-plane-ready at most once: after the reachability check, and only when the daemon answered. A source-text test in lib.rs pins the placement.

  • app-shell.svelte reloads schemas and collections on daemon:data-plane-ready and no longer references pro:tier-detected.

  • The Pro probe and its pro:tier-detected emit are unchanged, and the pro-sync store tests pass.

  • The new contract test fails if the listener is removed or pointed back at the legacy event. It contains no pro:tier-detected literal.

  • bun run scripts/check-pro-boundary.ts passes, with BASELINES lowered in this PR to the printed counts. Expected at af8ddb6:

    • proEvents −4: app-shell 281, daemon-status.ts 17, and the old test's lines 247 and 259;
    • proWording −2: the app-shell comment at 277 and 279.

    New code adds no marker line.

Tests and verification

  • Unit tests in a new #[cfg(test)] mod data_plane_round_trip_tests in grpc_client.rs. They use TCP, so they are platform-agnostic, and run under #[tokio::test]. Build the client with the private GrpcClient::from_channel.
    • a_refused_endpoint_fails_without_timing_out: bind 127.0.0.1:0, note the port, drop the listener, and build a channel with Endpoint::from_shared(format!("http://127.0.0.1:{port}"))?.connect_lazy(). Expect Failed(_) with a 2 s timeout.
    • a_silent_endpoint_times_out: a tokio::net::TcpListener that accepts connections and holds them without writing. With a 200 ms timeout, expect TimedOut.
  • Integration test. In tests/it/startup_readiness_data_plane_test.rs, add the_data_plane_round_trip_answers_once_the_daemon_is_healthy: SpawnedDaemon::spawn(), hold_connect_mutex_and_socket_env, GrpcClient::connect_lazy(), wait_for_daemon, then expect Answered.
  • Source-text test. A new #[cfg(test)] mod data_plane_ready_emit_tests in lib.rs. It finds nodespaced unreachable after startup, takes the text from there up to StreamingTaskRegistry::default(), and asserts it contains data_plane_round_trip( and emit(DATA_PLANE_READY_EVENT.
  • Mutation-check each new test: break the code path it covers, confirm the test fails, then restore.
  • Commands:
    • cargo test --lib -p nodespace-app data_plane
    • cargo build --bin nodespaced && NODESPACED_TEST_BIN="$PWD/target/debug/nodespaced" .tools/bin/cargo-nextest nextest run -p nodespace-app --test it startup_readiness_data_plane_test::
    • cargo clippy -p nodespace-app --all-targets -- -D warnings -D clippy::unused-async
    • bun run --cwd packages/desktop-app test src/tests/unit/props-driven-components.test.ts src/tests/services/daemon-status.test.ts
    • bun run test:changed
  • Manual check. Run bun run dev:tauri against a dev daemon, never your real ~/.nodespace.
    • Collections and schemas populate, and the log shows the data-plane line after Pro capability probe done.
    • With the daemon stopped, the not-running banner shows and no data-plane event is emitted.

Dependencies

Risks and rollback


Plan key: C4.1 (pro-boundary DAG).

🤖 Generated with Claude Code

Activity

  1. self-assigned this
    on Sep 30, 2026
  2. added
    pro-boundary
    on Sep 30, 2026
  3. mstomar125 commented on Oct 1, 2026

    @mstomar125
    ContributorAuthor

    Frontend baseline at cb778ae: 308 files, 5606 tests passed

  4. mstomar125 commented on Oct 1, 2026

    @mstomar125
    ContributorAuthor

    Superseded by #3412 (umbrella against the final ADR-081–085)

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

Metadata

Metadata

Assignees

Labels

pro-boundary

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions