Skip to content

refactor(harness): migrate capabilities through Rutis - #2465

Draft
zerob13 wants to merge 36 commits into
devfrom
dimagent/rutis-harness-bootstrap
Draft

zerob13 wants to merge 36 commits into
devfrom
dimagent/rutis-harness-bootstrap

Conversation

@zerob13

@zerob13 zerob13 commented Oct 25, 2026 •

Copy link
Copy Markdown
Collaborator

DeepChat coordinates Agent execution, Memory and shared persistence in Electron main. This migration moves cohesive owners behind Rutis while retaining the current application contracts, one storage authority and measured resource limits.

Current status:

  • Draft; base dev; do not merge. G0–G3 are complete, G4 is active, and G5–G12 remain in the live plan.
  • Current head: ec74d772c — startup callback drain, integrated with dev at 5128430a9. Required CI is running and Package CI is running on this exact head. No manual rerun or cancellation has been requested. Normal catalog refreshes are a separate commit, 93d0518a4; startup drain is 4bff056f3.
  • The request-ownership head 99fdb0710 passes required CI and all six platform packages, including both required barriers.
  • The maintenance-command head 5c7efdc1e passes required CI and all six platform packages, including both required barriers.
  • The preceding Provider OAuth head bc4ad41db passes required CI and all six platform packages, including both required barriers.
  • RFC and live plan define the full Store, cohesive Harness/Memory, Rust and Everywhere scope. G4 still has other atomic Store/configuration and desktop/maintenance boundaries; the shared backend has not moved yet.

Runtime and ownership:

  • Invocation admission uses the Rust/Rutis host and a TS plugin by default. Ordering, cancellation, owner limits and bounded transport remain enforced.
  • One lazy native TS vector worker runs under the same host. Kernel file ownership, persistent Agent leases and quarantine fences protect uncertain work and worker loss. Admission survives; recall degrades to FTS, and vector recovery requires explicit rebuilding.
  • Rust stages bounded packed Float32 uploads and dispatches atomic native upserts on commit. Transfer acknowledgements, queue/control reserves, finite/native-buffer validation and strict private-buffer/base64 contracts remain active. Pinned SDK patches retain embedding validation and raw-response isolation.
  • The Scheduler timer helper holds no database connection, path/password or SQL. It requests a bounded Store command selecting at most 100 due jobs and atomically creating deduplicated runs and schedule heads. Dispatch precedes acknowledgement. One correlated scan, coalescing and generation/sequence checks fence missing, stale or duplicate replies.
  • Main supplies the approved Scheduler helper through a cancelable plain command/event/lifecycle facade. The manager has no Electron/filesystem/path imports or optional native-construction fallback. Main also owns the single system-resume listener and suppresses delivery during maintenance/shutdown.

Store and desktop boundaries:

  • Credential persistence uses an explicit async string/boolean crypto port supplied by Main's native safeStorage adapter. Sync, MCP/plugin configuration, Nowledge and export consumers await real operations; wrapped storage, destination binding and cancellation remain enforced.
  • Sync connector and peer-pairing tokens retain their existing private files, legacy ciphertext, Linux secure-backend policy and generation-fenced pairing/connector startup.
  • Database security receives explicit path, metadata and native crypto ports; Main owns unlock and quit. A per-file lock holds through target wrapping, SQLCipher copy/reopen and metadata commit. Runtime rollback retains the original database and metadata on failure; cross-file power-loss recovery remains conditional Store work.
  • Session clearing uses one owner command for pending inputs, transcript projection and Tape reset. Runtime preparation/post-commit cleanup remain with the mutation coordinator. Retry truncation uses the atomic transcript range operation; replaced closure/row wiring is removed.
  • Sixteen selected settings fields use one application service with snapshots, acknowledged mutations and per-key presentation revisions. Agent display tools retain authorization and journal commitment while awaiting validated native mutation receipts.
  • Skill services receive explicit host directories and an async native directory capability. Selected business modules no longer import Electron; discovery, watcher ownership, rollback and scoped authorization remain in the same owner.
  • Shared database maintenance accepts six explicit data commands for verified backup files, named local/cloud backups, encryption enable/change/disable and live schema repair. Actual consumers use these commands; caller-supplied operation callbacks are removed. SQL, handles and transaction closures stay inside the owner.
  • One maintenance operation owns pause, drain, dispatch, reopen, reconciliation and resume. Live repair uses the same exclusive admission as import/encryption. Backup and shutdown reject admission; shutdown is rechecked after drain, and preparation errors enter recovery. Ordinary ingress now shares one running/maintenance/failed state. Renderer and finite CLI requests drain before writer replacement, with a 30-second failure before dispatch. Queued startup work rechecks admission and its original cancellation signal; a canceled reply cannot release ownership of a still-running handler. Event watchers count only their initial database snapshot. Native presentation/status and identity-checked approval settlement remain available. Detached background effects, remaining configuration snapshots and native/window owners keep G4 open.
  • Main startup cancellation keeps immediate replies while a separate completion promise retains actual callback lifetime in the existing in-flight inventory. Maintenance cancels and drains the Main target, including canceled older runs, before pausing/recreating services or replacing the writer. Pending tasks never execute and release deduplication entries. A 30-second preflight failure restores ordinary admission without database replacement or duplicated services; shutdown is rechecked after the wait. Successful maintenance schedules background migrations again.
  • Normal build-generated Provider and ACP registry refreshes are retained. The large catalog diff is generated registry data.

MCP OAuth:

  • Main supplies the private credential path, secure async crypto and browser-open capability. Credential persistence, interactive/enterprise identity owners, SDK providers and actual connection/diagnostic consumers use this path; replaced native imports and default Store construction are removed.
  • One bounded owner queue serializes acknowledged writes and atomic binding-key moves. Initial decrypt is single-flight; RAM publication follows persistence, and encryption/rename failures preserve old RAM and disk. Twenty-four normal writes reserve eight control slots; stop rejects queued and pending native results without waiting for queue capacity.
  • Existing v1/v2 envelopes, bounds, memory-only fallback, Linux basic-text refusal, legacy native ciphertext and settings-window credential permissions remain compatible. V2 reads do not rewrite credentials or add another plaintext cache.
  • Synchronous loopback validation uses acknowledged public discovery metadata. Finalized identity uses one settings-owner CAS against server ID, generation, hash and endpoint. Profile edits retain concurrent unrelated profiles and reject replacement of the same profile.
  • Originating server/profile leases fence delayed refresh, browser, status and runtime effects. Plugin-owned connection changes use the existing supervisor through its probe, integrity/recovery, adapter/native launch and symmetric stop waits; canceled startup still cleans owned resources. Connection failures await OAuth classification and reject stale notifications.

Provider OAuth:

  • Main supplies Codex/Grok private paths, async string-only native crypto and browser-open capabilities. Both private Store/auth owners no longer import Electron or construct native defaults. Status/events, refresh, logout, global initialization and shutdown use these explicit dependencies.
  • Existing v1 encrypted/plain-file formats, native ciphertext, corrupt backups, fsync/rename and Provider file fallback remain compatible. Each file is bounded to 16 MiB and token payloads to 8 MiB; 24 normal mutations reserve eight control slots. Only pending reads coalesce, with no retained plaintext token cache. Failed deletion cannot acknowledge logout.
  • Grok synchronous token peeking is removed. The existing async fetch adapter supplies credentials to SDK and trusted direct requests. Original auth scopes and request cancellation are checked before dispatch and 401 refresh; interrupted owners cannot become API-key fallback. Ordinary refresh failure retains fallback.
  • Native wrapping, browser/device login, discovery, refresh and status effects are fenced against account replacement, logout, cancellation and shutdown. Status queries retry at most once on an observed account transition, and newer publications supersede delayed status reads.
  • Each auth owner admits at most 32 HTTP requests, with declared/streamed bodies bounded to 8 MiB. Existing timeouts and cancellation cover body reads as well as headers.

Validation:

  • Current acceptance: 217 main checks across ten files and 291 renderer checks across seven files pass. Main tests run under Electron Node mode with required native SQLite and no skips. Real coordinator regressions cover canceled older runs and replacements, late callback failure, unrelated-target isolation, queued cancellation and timeout followed by a later drain. The deadline uses fake time; it is a lifecycle check. App and modified-test types, the normal build, format/check, lint and i18n pass. The integrated tree also passes renderer architecture and generated-icon checks; only the two generated catalogs conflicted with the new base, and the normal build scripts regenerated them. Evidence: .deepchat/rutis-g4-startup-drain-acceptance/.
  • Request-ownership acceptance retains: 616 checks across 36 CLI/route/app files pass. Regressions cover rejected-request cleanup, maintenance self-exclusion, native presentation, bounded drain, queued execution, canceled replies with active handlers, and event subscriptions whose finite snapshot has drained.
  • 4 real-app scenarios pass in 23.7 s on the final integrated tree in isolated owned profiles: encryption/legacy unlock, wrong-password recovery, rekey and disable (12.3 s); actual built-CLI Provider-list plus backup/import/repair/relaunch (5.3 s); concurrent maintenance rejection (3.0 s); delayed credential drain (2.9 s). Native preparation rejects configuration/Provider/CLI work while native/security/CLI status works; an interrupted credential cannot persist its secret. The startup-drain slice retains its 21.6-s baseline and 21.3-s migrated sample in the plan. These are functional observations without timing gates or speed claims. No external account is contacted. Held-startup and timeout behavior are verified at the coordinator boundary; the app comparison exercises default wiring without a held-startup fault.
  • App types, scoped new gate/dispatcher regression, CLI and E2E types, normal/final runtime builds, format/check, lint and i18n pass. The large legacy dispatcher fixture has unrelated type drift outside the scoped type checks; its runtime suite passes. Evidence: .deepchat/rutis-g4-request-drain-acceptance/ and the live plan.
  • Maintenance-command acceptance: 158 checks across nine files pass under Electron Node mode with required native SQLite and no skips. The pre-cutover four-file native group passes all 37 checks. SQLCipher rollback, backup snapshot consistency, imported-data normalization, route and composition contracts remain active.
  • Maintenance-command actual-app acceptance: 3 scenarios pass in 19.6 s. Encryption/legacy unlock, failed-password recovery, rekey and disable pass before/after in 12.5/11.2 s. Backup, rejected import, incremental restoration, overwrite removal, live repair and durable session restoration pass in 4.8/5.2 s. A native preparation gate verifies concurrent repair/import are rejected, then repair succeeds after encryption completes. Empty sessions use public creation without a Provider request; no external account is contacted. These functional timings have no timing gate or speed claim.
  • App and scoped E2E types, the normal build, format/check, lint and i18n pass. Normal generated catalogs remain retained. Evidence: local .deepchat/rutis-g4-maintenance-acceptance/ and the live plan.
  • Provider OAuth acceptance retains 1,213 checks across 79 files, final 150 checks across nine files, and the four-launch native/plaintext compatibility, cancel, durable logout and signed-out relaunch E2E (12.0 s). Evidence remains in .deepchat/rutis-g4-provider-oauth-acceptance/.
  • MCP acceptance retains 657 checks across 33 files and 3 real-app E2Es in 34.2 s. Its supplemental selection recorded 13 passes, two skips and an unmodified Provider headers fixture failure waiting for the absent disabled-providers-toggle; that failure/artifacts remain recorded and are not represented as passing OAuth acceptance.

Settings behavior:

BEFORE
new event v2 -> UI value v2
late read v1 -> UI value v1

AFTER
new event v2 -> UI value v2
late read v1 -> ignore older keys; hydrate untouched keys

Performance policy:

  • Shared Memory CI timing overruns are reports through DEEPCHAT_MEMORY_PERF_REPORT_ONLY=1. Correctness, native operations, finite measurements, runtime/ABI identity, workload/queue bounds and timeouts still block; no continue-on-error hides failures.
  • Every slice requires relevant tests and matching functional app E2E. Fixed-device resource comparisons are selected for material process, IPC, batching or storage-path changes, or an explicit performance objective. Ordinary async port extraction does not require another whole-process capture.
  • Select workloads and a bounded confirmation budget before measuring, retain all samples, and resolve reproducible material regressions. Do not rerun CI until timing happens to pass. Inconclusive/noise-level differences establish no speed claim.
  • G3 retains all 52 successful app runs and the original loaded-control failure. Its prespecified independent five-pair confirmation and all ten pooled pairs pass the frozen resource rules. Full sample groups, immutable artifacts and resource/protocol limits remain in the live plan; this is not a Rust CPU speedup claim.

Limits:

  • Native OAuth credential compatibility is verified on macOS arm64. Real Windows/Linux vaults, external identity-provider/browser flows, physical suspend/resume and signed full-app fault scenarios remain unverified locally.
  • Six-platform packages execute the production Memory runtime smoke; they do not establish those full-app native scenarios. Local process-tree evidence uses unpackaged builds and records shared/native costs.
  • G5 must move the cohesive shared owner without a second writer and transport legal large credential envelopes through bounded frames. No gateway-limit increase, truncated result, generic SQL/row RPC or automatic fallback is introduced.

@coderabbitai

coderabbitai Bot commented Oct 25, 2026

Copy link
Copy Markdown
Contributor

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

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.

1 participant