Skip to content

feat: add capability-driven routine debugging workspace - #1460

Merged
NewtTheWolf merged 5 commits into
TabularisDB:mainfrom
lejyfps:feat/1411-oracle-routine-debugger
Nov 10, 2026
Merged

NewtTheWolf merged 5 commits into
TabularisDB:mainfrom
lejyfps:feat/1411-oracle-routine-debugger

Conversation

@lejyfps

@lejyfps lejyfps commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Behaviour

Adds the shared host and workspace for #1411. A driver declaring routine_debug: 1 offers a routine context-menu debugger: select the routine identity and inputs, preview the target and engine warnings, then explicitly start. The workspace exposes source/current stop, breakpoints, stepping, stack, scalar watches and OUT/return values, including unavailable/partial/stale states.

Companion Oracle plugin PR: TabularisDB/tabularis-oracle-plugin#26. It supplies the real native implementation and live Oracle tests. This host change alone does not enable debugging in existing plugin releases.

Safety and plugin behaviour

  • Desktop commands and web RPC call the same application session manager. Sessions/previews belong to the authenticated owner and saved connection; native identities and credentials remain server-side.
  • Preview capacity includes pending requests and is reserved before native allocation. Closing, expiry and disconnect discard unused native previews; closing also blocks a concurrent start.
  • Optional versioned driver RPC, with no SQL execution fallback. Existing/built-in drivers and plugins without the supported capability hide the entry. Read-only drivers reject operations except status/stop; production execution and inspection keep the write-confirmation gate.
  • Start is reserved before awaiting the plugin and never retried after a lost response. Cancellation/disconnect/expiry request cleanup. Execution, transaction outcome and resource release are independent; unknown outcomes are not presented as rollback/success.
  • Variable inspection accepts at most 128 non-blank names of at most 128 UTF-8 bytes each. Failed inspection does not cancel or resume the target. An explicit close remains available when cleanup cannot be confirmed.
  • Replacing the frontend client keeps the open debugger session alive. Unmount cleanup uses the latest client and the connection that owns the session.
  • Protocol/schema/type documentation and translated debugger strings are updated across all 13 bundled locales.

Validation

  • 17 focused Rust contract/application/web-decoder tests pass with cargo test --no-default-features --lib routine_debug, including preview limits, expiry/disconnect cleanup, failed/disconnected preview requests, start/discard races and watch-input limits.
  • Six frontend/desktop/web transport and execution-safety tests pass, including a client replacement while the workspace remains open; 44 contrast tests passed for the workspace.
  • Typecheck, ESLint, theme-token checks, frontend production build, headless cargo check --no-default-features and desktop cargo check.
  • GitNexus impact analysis and staged-change review completed for the shared driver boundary and debugger session lifecycle.
  • Native Oracle execution passed the live Oracle integration job on companion commit 30219da86070ce40750a192811aef6bd6254d847, against Oracle AI Database 26ai Free 23.26.3.0.0 / Instant Client 23.26.2.0.0. The test exercised the real stdio plugin with ORACLE_TEST_HOST set, including unused preview disposal, entry stops, breakpoint replacement/deduplication, all step modes, variables, numeric OUT/return values, exceptions, cancellation, EOF, rollback and target/controller cleanup.
  • Full host CI passed on 806bc70c, including main tests and web E2E, PostgreSQL, MySQL 5.7/8.4, accessibility, contrast and formatting. The incremental automated review confirms all three findings are resolved and reports no new issues. The Windows desktop test executable failed to load locally with STATUS_ENTRYPOINT_NOT_FOUND; the same shared tests pass locally without the desktop feature, and desktop tests pass in CI.

The companion implementation supports precompiled standalone procedures/functions with scalar numeric/character arguments. Packaged overloads and composite/date parameters are explicitly unsupported. Upstream Oracle workflows still require maintainer approval; the passing fork job validates the exact companion commit.

@lejyfps
lejyfps marked this pull request as ready for review November 9, 2026 14:39
sessions.retain(|_, s| {
(s.started && s.terminal.is_none()) || s.created.elapsed() < Duration::from_secs(300)
});
if sessions.values().filter(|s| s.owner == owner).count() >= 16 {

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.

WARNING: Native preview leaks when the session cap or expiry rejects it

The plugin has already created a native preview (native_call(... Preview) above) before the 16-session cap is checked. When this returns Err, the native preview_id is dropped with no Stop/discard sent to the plugin. The retain above (line 103) has the same problem: expired, never-started previews are silently removed from the host map without any native cleanup. A plugin that holds resources per preview (connections, compiled state) will accumulate them. Check the cap before calling the plugin, and send a cleanup for evicted previews.

..
} => {
if session_id.is_empty() || frame_id.is_empty() {
return Err("Variable reads require a session and frame".into());

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.

WARNING: ReadVariables.names is passed to the native debugger without any validation

Only session_id and frame_id are checked. names is unbounded in count and length, may contain empty strings, and the PR itself notes that inspection can evaluate code in a native debugger (see the doc comment on validate). The UI forwards the raw comma-separated watch text. Add a cap on the number and length of names and reject empty entries at the host boundary, so a plugin never receives arbitrary-size input from a web client.

),
);
},
[client, connectionId],

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.

WARNING: Cleanup effect re-runs when client identity changes and stops a live session

The effect's cleanup runs on every dependency change, not only on unmount. If useTabularisClient() returns a new object (e.g. on reconnect or provider re-render), the cleanup sends stop for the active session and nulls sessionId.current while the modal is still open, silently killing a running debug session and leaving the UI controls dead. Keep the latest client/connectionId in refs and use an empty-dependency unmount effect.

@kilo-code-bot

kilo-code-bot Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: No Issues Found | Recommendation: Merge

The incremental changes since 806bc70c fix the late-preview leak raised in the existing review comment on DebugRoutineModal.tsx:

  • A mounted ref now gates state updates after unmount. A preview response that arrives after unmount is stopped with its owning connectionId, using the latest client held in a ref.
  • The unmount cleanup now uses a stable stopSession callback with an effect that depends only on that callback, so it does not fire on client identity changes. This also keeps the earlier fix for the cleanup-on-client-change finding.
  • The new test covers a late preview after close, with and without a replaced client, under StrictMode. It checks that no stop is sent before the preview resolves and exactly one afterwards.

Earlier findings on routine_debug.rs (preview cap reservation and ReadVariables.names validation) were fixed in the previous incremental review and are unchanged here.

Files Reviewed (2 files)
  • packages/web-ui/src/components/modals/DebugRoutineModal.tsx
  • packages/web-ui/tests/components/modals/DebugRoutineModal.test.tsx

Notes: Review was based on the incremental diff and targeted file reads; tests were not executed (read-only mode).

Previous Review Summaries (2 snapshots, latest commit 806bc70)

Current summary above is authoritative. Previous snapshots are kept for context only.

Previous review (commit 806bc70)

Status: No Issues Found | Recommendation: Merge

The incremental changes since a59b8483 resolve the three earlier findings:

  • Preview capacity is now reserved before the native call (PreviewReservation), and expired, closed or released previews get a native Stop.
  • ReadVariables.names is capped at 128 names, each non-blank and at most 128 bytes, with tests that reject invalid input before the native RPC.
  • The modal's cleanup now runs only on unmount, using useEffectEvent and a stored connection id.
Files Reviewed (8 files)
  • src-tauri/src/application/routine_debug.rs
  • src-tauri/src/application/routine_debug/tests.rs
  • src-tauri/src/routine_debug.rs
  • src-tauri/src/routine_debug/tests.rs
  • packages/web-ui/src/components/modals/DebugRoutineModal.tsx
  • packages/web-ui/tests/components/modals/DebugRoutineModal.test.tsx
  • plugins/PLUGIN_GUIDE.md
  • plugins/ROUTINE_DEBUG.md

Notes: Review was based on the incremental diff and targeted file reads; tests were not executed (read-only mode).

Previous review (commit a59b848)

Status: 3 Issues Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 0
WARNING 3
SUGGESTION 0
Issue Details (click to expand)

WARNING

File Line Issue
src-tauri/src/application/routine_debug.rs 106 Native preview is created before the 16-session cap check; a rejected preview (and previews evicted by retain at line 103) is never discarded on the plugin side, so plugin resources can accumulate.
src-tauri/src/routine_debug.rs 116 ReadVariables.names is forwarded to the native debugger with no count/length/empty-entry validation at the host boundary.
packages/web-ui/src/components/modals/DebugRoutineModal.tsx 80 Unmount-cleanup effect depends on [client, connectionId], so a changed client identity sends stop for a live session while the modal is still open.
Files Reviewed (41 files)
  • src-tauri/src/application/routine_debug.rs - 1 issue
  • src-tauri/src/routine_debug.rs - 1 issue
  • packages/web-ui/src/components/modals/DebugRoutineModal.tsx - 1 issue
  • src-tauri/src/application/routine_debug/tests.rs
  • src-tauri/src/routine_debug/tests.rs
  • src-tauri/src/application/api.rs
  • src-tauri/src/application/connections.rs
  • src-tauri/src/application/database_objects.rs
  • src-tauri/src/application/mod.rs
  • src-tauri/src/drivers/driver_trait.rs
  • src-tauri/src/drivers/mysql/mod.rs
  • src-tauri/src/drivers/postgres/mod.rs
  • src-tauri/src/drivers/sqlite/mod.rs
  • src-tauri/src/lib.rs
  • src-tauri/src/plugins/driver.rs
  • src-tauri/src/transport/desktop/commands.rs
  • src-tauri/src/transport/desktop/mod.rs
  • src-tauri/src/transport/web/rpc.rs
  • src-tauri/src/transport/web/rpc_tests.rs
  • src-tauri/tests/postgres_integration/parity.rs
  • packages/web-ui/src/api/contract.ts
  • packages/web-ui/src/components/layout/ExplorerSidebar.tsx
  • packages/web-ui/src/types/plugins.ts
  • packages/web-ui/src/types/routineDebug.ts
  • packages/web-ui/tests/api/routineDebugContract.test.ts
  • packages/web-ui/tests/components/modals/DebugRoutineModal.test.tsx
  • plugins/PLUGIN_GUIDE.md
  • plugins/ROUTINE_DEBUG.md
  • plugins/manifest.schema.json
  • packages/web-ui/src/i18n/locales/*.json (13 locales)

Notes: Review was based on the diff and targeted file reads; tests were not executed (read-only mode).

Fix these issues in Kilo Cloud


Reviewed by claude-sonnet-5.5 · Input: 250 · Output: 2.1K · Cached: 284.2K

Review guidance: REVIEW.md from base branch main

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

Thanks for keeping debugger resources behind a versioned driver capability and sharing session ownership across desktop and web. I reviewed 806bc70cbd802eaa269210457f7a1bbcdcae5674. The 17 existing Rust debugger tests and six frontend/transport tests passed, as did typecheck, targeted source ESLint and the production frontend build.

I reproduced one cleanup gap with an additional deferred-response component test: start Preview, close/unmount the modal before the request resolves, then let the preview reply arrive. Only the preview request is sent; no stop is sent for the returned preview ID. Unmount cleanup sees a null ID, and the late reply stores the ID after that cleanup has already run. The native preview and host session reservation therefore remain until later expiry/disconnect cleanup. Repeated attempts can consume the 16-preview capacity.

Please dispose late preview responses after unmount, using the owning connection and latest client, and add this pending-preview-close regression. The backend test that removes a pending session does not cover this UI path because closing the modal never sends that removal. I have not run native Oracle E2E, and I am holding this open for the cleanup fix.

const next = await client.call('routine_debug', {connectionId, version: 1, command});
if (next.kind === 'preview') {
sessionId.current = next.preview_id;
sessionConnectionId.current = connectionId;

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.

[P2] Dispose preview responses that arrive after the modal closes. If unmount occurs while client.call is pending, stopOnUnmount sees sessionId.current === null. The continuation later stores next.preview_id, but no cleanup runs again. A deferred-preview component test reproduces zero stop requests after unmount. Track disposal and stop a late preview with its owning connection/latest client instead of retaining it.

@lejyfps
lejyfps requested a review from NewtTheWolf November 9, 2026 20:33

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

Thanks for handling the preview that arrives after the modal has closed. The cleanup now stops that preview using its original connection, including when the client instance changes while the request is pending.

I reran the six modal tests and my independent delayed-preview regression that failed on the previous revision. All pass, along with the 17 Rust debugger/contract tests, typecheck and targeted source lint. The previous resource-leak blocker is resolved. Approved.

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