Skip to content

refactor: tech-debt passes 1-6 (validation perf, rule tables, log caps, ai.ts split) - #115

Merged
tonythethompson merged 11 commits into
mainfrom
tech-debt-passes-1-6
Aug 5, 2026
Merged

tonythethompson merged 11 commits into
mainfrom
tech-debt-passes-1-6

Conversation

@tonythethompson

@tonythethompson tonythethompson commented Aug 5, 2026 •

Copy link
Copy Markdown
Owner

Summary

Tech-debt remediation passes 1–6 from docs/Tech Debt & Issues.md, plus the accumulated work-in-progress that was in the tree.

Pass 1 — Quick fixes

  • QueryClient scoped inside App (no module-level singleton)
  • OLIVE_SERVE_STATIC env switch for static serving (argv heuristic reduced to back-compat fallback)
  • vite dynamically imported in the dev branch; moved to devDependencies only
  • OliveRecipe.systems / PassConfig.config → Record<string, unknown>

Pass 2 — Validation pipeline performance

  • Ref-equality memo on buildOliveRecipe
  • buildRecipeFromState reuses validation.recipe (was rebuilding 4–19×/render)
  • ExecutionWorkspace defers pipeline derivation via useDeferredValue; Execute/Queue rebuild fresh from live state at click time

Pass 3 — Hygiene

  • Removed dead @mendable/firecrawl-js dep + allowBuilds entry
  • Confirmed onnxruntime-web / @huggingface/transformers already ship as separate lazy chunks

Pass 4 — Declarative rule tables

  • CROSS_PASS_RULES: single source of truth for coercePassFields + getCrossPassIssues (drift now structurally impossible)
  • inferHfTask / inferModelType → explicit ordered lookup tables

Pass 5 — Job pipeline robustness

  • Job logs capped at 1,000 lines (batched trim at 1,250 watermark)
  • logsTruncated flag + SSE reconnect replay marker; /olive/status exposes the flag
  • New gpu.test.ts + truncated-replay stream test

Pass 6 — ai.ts split

  • 2,120-line routes/ai.ts → 12 modules under routes/ai/ (provider, chat, lmStudio, ollama, installEngine, codex, devin, cloudflare, localEngines, modelCatalog, streamHelpers, index)
  • Local-engine mutable state → services/ai/localEngineState.ts with resetLocalEngineRuntime()
  • Dropped dead registerAiRoutes export

Verification

Gate Result
tsc + eslint ✅ 0 errors, 12 pre-existing warnings (under the 20 budget)
Unit ✅ 54/54 files, 794 tests
Server ✅ 21/21 files, 229 tests
Component ✅ 16/16 files, 103 tests
Integration ✅ 41 tests
Build ✅ vite + esbuild clean

Full re-verification of the final tree is running and will be reported on this PR.

Notes

  • Local vitest runs use --pool=forks --no-file-parallelism (environmental worker-spawn flake on this disk; default pool silently drops 2 test files here).
  • No CI config changes; pnpm-lock.yaml synced.

Review in cubic

Pass 1 (quick fixes): queryClient scoped inside App; OLIVE_SERVE_STATIC env
switch for static serving; vite dynamically imported in dev branch and moved
to devDependencies; types.ts OliveRecipe.systems/PassConfig.config to
Record<string, unknown>.

Pass 2 (validation perf): ref-equality memo on buildOliveRecipe;
buildRecipeFromState reuses validation.recipe and derives advisories inline;
StepInspector drops duplicate validation; ExecutionWorkspace defers the
pipeline derivation (useDeferredValue) and rebuilds fresh at Execute/Queue
time so submissions are never stale.

Pass 3 (hygiene): removed dead @mendable/firecrawl-js dependency and its
allowBuilds entry; confirmed onnxruntime-web/@huggingface/transformers
already ship as lazy chunks.

Pass 4 (rule tables): CROSS_PASS_RULES is the single source of truth for
coercePassFields and getCrossPassIssues (autoCoerce flag per rule);
inferHfTask/inferModelType rewritten as explicit ordered lookup tables.

Pass 5 (job robustness): job logs capped at 1000 lines with batched trim
(1250 watermark), OliveJob.logsTruncated flag, SSE reconnect replay emits a
trim marker, /olive/status exposes logsTruncated. Adds gpu.test.ts and a
truncated-replay stream test.

Pass 6 (ai.ts split): routes/ai.ts (2,120 lines) split into routes/ai/
sub-modules (provider, chat, lmStudio, ollama, installEngine, codex, devin,
cloudflare, localEngines, modelCatalog, streamHelpers, index); all
local-engine mutable state moved to services/ai/localEngineState.ts with
resetLocalEngineRuntime() for tests; dropped dead registerAiRoutes export.

Also includes accumulated work-in-progress changes across the tree.
@vercel

vercel Bot commented Aug 5, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
olive-studio Ready Ready Preview Aug 5, 2026 12:43pm

@sourcery-ai sourcery-ai Bot left a comment

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.

Sorry, we are unable to review this pull request

The GitHub API does not allow us to fetch diffs exceeding 20000 lines

@coderabbitai

coderabbitai Bot commented Aug 5, 2026 •

Copy link
Copy Markdown
Contributor

Important

Review skipped

Too many files!

This PR contains 229 files, which is 129 over the limit of 100.

To get a review, reduce the PR to 100 files or fewer by splitting it into smaller PRs or changing its base branch.

Upgrade to a paid plan to raise the limit.

This review couldn't start because sufficient usage credits or metered capacity aren't available. Add credits or update usage-based reviews in the billing tab, then retry.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 5b7af806-e18f-40d4-9064-15287e48c234

📥 Commits

Reviewing files that changed from the base of the PR and between 89ed044 and e70e0cc.

⛔ Files ignored due to path filters (2)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
  • src-tauri/Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (229)
  • .agents/skills/vite-react-best-practices/AGENTS.md
  • .agents/skills/vite-react-best-practices/rules/react-colocation.md
  • .agents/skills/vite-react-best-practices/rules/react-server-state.md
  • .agents/skills/vite-react-best-practices/rules/vite-troubleshooting.md
  • .gitattributes
  • .github/workflows/ci.yml
  • .github/workflows/dependabot-auto-merge.yml
  • .github/workflows/kb-update.yml
  • .github/workflows/playwright.yml
  • .github/workflows/tauri-build.yml
  • .gitignore
  • AGENTS.md
  • CHANGELOG.md
  • CLAUDE.md
  • LICENSE
  • bin/cli.js
  • docs/OLIVE_COMPREHENSIVE_API_REFERENCE.md
  • docs/OLIVE_MCP_PROMPT_FOR_DEVELOPER.md
  • docs/ORIGINAL_REQUEST.md
  • docs/ROADMAP.md
  • docs/Tech Debt & Issues.md
  • docs/mcp-validation-kb-feedback.plan.md
  • index.html
  • launch-tauri.cmd
  • launch-tauri.ps1
  • olive-mcp-server/Dockerfile
  • olive-mcp-server/olive_mcp_server/fetchers/__init__.py
  • olive-mcp-server/olive_mcp_server/knowledge_base/studio_troubleshooting.json
  • olive-mcp-server/olive_mcp_server/knowledge_base/troubleshooting.json
  • olive-mcp-server/olive_mcp_server/mcp_server.py
  • olive-mcp-server/olive_mcp_server/tools/__init__.py
  • olive-mcp-server/olive_mcp_server/tools/compatibility.py
  • olive-mcp-server/olive_mcp_server/tools/config_generator.py
  • olive-mcp-server/olive_mcp_server/tools/docs_search.py
  • olive-mcp-server/olive_mcp_server/tools/embeddings.py
  • olive-mcp-server/olive_mcp_server/tools/pass_chain.py
  • olive-mcp-server/olive_mcp_server/tools/passive_context.py
  • olive-mcp-server/olive_mcp_server/tools/strategy_advisor.py
  • olive-mcp-server/olive_mcp_server/tools/troubleshooting.py
  • olive-mcp-server/pyproject.toml
  • olive-mcp-server/scripts/expand_kb.py
  • olive-mcp-server/tests/test_call_tool.py
  • olive-mcp-server/tests/test_docs_search_semantic.py
  • olive-mcp-server/tests/test_embeddings.py
  • olive-mcp-server/tests/test_integration.py
  • olive-mcp-server/tests/test_passive_context.py
  • olive-mcp-server/tests/test_tools.py
  • olive-mcp-server/tests/test_troubleshoot_integration.py
  • olive-mcp-server/tests/test_troubleshooting_hybrid.py
  • package.json
  • pnpm-workspace.yaml
  • scripts/probe-python-version.mjs
  • scripts/sync-pass-catalog.mjs
  • server.ts
  • src-tauri/.gitignore
  • src-tauri/Cargo.toml
  • src-tauri/build.rs
  • src-tauri/capabilities/default.json
  • src-tauri/icons/android/mipmap-anydpi-v26/ic_launcher.xml
  • src-tauri/icons/android/values/ic_launcher_background.xml
  • src-tauri/src/lib.rs
  • src-tauri/src/main.rs
  • src/App.tsx
  • src/components/DesktopMinimumViewport.tsx
  • src/components/ErrorBoundary.tsx
  • src/components/LicenseNotice.tsx
  • src/components/ReportIssueModal.tsx
  • src/components/TitleBar.tsx
  • src/components/features/ArenaPanel.helpers.test.ts
  • src/components/features/ArenaPanel.tsx
  • src/components/features/AuditPanel.tsx
  • src/components/features/BatchProcessingPanel.test.tsx
  • src/components/features/BatchProcessingPanel.tsx
  • src/components/features/CompatStatus.tsx
  • src/components/features/EnterpriseInfraPanel.tsx
  • src/components/features/ExecutionWorkspace.tsx
  • src/components/features/GeminiSidebar.flows.test.tsx
  • src/components/features/GeminiSidebar.tsx
  • src/components/features/GraphConflictBanner.tsx
  • src/components/features/InBrowserValidation.tsx
  • src/components/features/InputEnvironmentPanel.test.tsx
  • src/components/features/KbSyncIndicator.tsx
  • src/components/features/LocalModelManager.test.tsx
  • src/components/features/LocalModelManager.tsx
  • src/components/features/MCPDiagnosticCard.tsx
  • src/components/features/PlaygroundPanel.tsx
  • src/components/features/ProviderErrorBlock.test.tsx
  • src/components/features/ProviderErrorBlock.tsx
  • src/components/features/RuntimeEnvControls.tsx
  • src/components/features/WebGpuBenchmarkPanel.tsx
  • src/components/features/gemini/ChatPanel.tsx
  • src/components/features/gemini/LocalAiSetupCard.tsx
  • src/components/features/gemini/ManualProviderSetup.tsx
  • src/components/features/gemini/ModelCombobox.test.tsx
  • src/components/features/gemini/ModelCombobox.tsx
  • src/components/features/gemini/SettingsPanel.tsx
  • src/components/features/gemini/aiProviderCatalog.ts
  • src/components/features/gemini/types.ts
  • src/components/features/gemini/useAiAudit.ts
  • src/components/features/gemini/useAiProviderSettings.ts
  • src/components/features/gemini/useLocalEngineSetup.ts
  • src/components/features/recipe-graph/GraphCanvas.tsx
  • src/components/features/recipe-graph/RecipeGraphView.tsx
  • src/components/features/recipe-graph/StepInspector.tsx
  • src/components/features/recipe-graph/inspectors/ConversionInspector.tsx
  • src/components/features/recipe-graph/inspectors/InputInspector.tsx
  • src/components/features/recipe-graph/inspectors/OrtTransformsInspector.tsx
  • src/components/features/recipe-graph/inspectors/PeftInspector.tsx
  • src/components/features/recipe-graph/inspectors/ProviderInspector.tsx
  • src/components/features/recipe-graph/inspectors/PruningInspector.tsx
  • src/components/features/recipe-graph/inspectors/QuantizationInspector.tsx
  • src/components/features/recipe-graph/inspectors/SplittingInspector.tsx
  • src/components/ui/Card.tsx
  • src/components/ui/Label.tsx
  • src/index.css
  • src/lib/__tests__/arenaConstants.test.ts
  • src/lib/__tests__/arenaEndpointPolicy.test.ts
  • src/lib/__tests__/arenaLocalInference.test.ts
  • src/lib/__tests__/assistantSettingsMode.test.ts
  • src/lib/__tests__/gpuMetrics.test.ts
  • src/lib/__tests__/hooks.test.ts
  • src/lib/__tests__/localFileDetails.test.ts
  • src/lib/__tests__/noNotAModelCopy.test.ts
  • src/lib/aiResponse.ts
  • src/lib/apiClient.ts
  • src/lib/arenaAssistantSnapshot.ts
  • src/lib/arenaConstants.ts
  • src/lib/arenaEndpointPolicy.ts
  • src/lib/arenaLocalInference.ts
  • src/lib/arenaOliveOutputs.ts
  • src/lib/assistantSettingsMode.ts
  • src/lib/auditAnalysis.test.ts
  • src/lib/auditAnalysis.ts
  • src/lib/auditSuggestionFilter.ts
  • src/lib/chatScope.ts
  • src/lib/cloudflare/client.ts
  • src/lib/cloudflare/credentials.ts
  • src/lib/cloudflare/wrangler.test.ts
  • src/lib/cloudflare/wrangler.ts
  • src/lib/codex/CodexAppServerClient.ts
  • src/lib/codex/codexAgent.ts
  • src/lib/defaultPasses.ts
  • src/lib/devin/README.md
  • src/lib/devin/client.ts
  • src/lib/devin/oauth/types.ts
  • src/lib/envCredentialUi.test.ts
  • src/lib/envCredentialUi.ts
  • src/lib/errorFrequency.test.ts
  • src/lib/errorFrequency.ts
  • src/lib/gpuMetrics.ts
  • src/lib/hooks.ts
  • src/lib/hooks/useKbSync.ts
  • src/lib/issueReport.ts
  • src/lib/lmsPullProgress.test.ts
  • src/lib/lmsPullProgress.ts
  • src/lib/localEngineDisk.test.ts
  • src/lib/localEngineDisk.ts
  • src/lib/localEngineStarters.ts
  • src/lib/localFileDetails.ts
  • src/lib/localModelTag.test.ts
  • src/lib/localModelTag.ts
  • src/lib/logFailurePatterns.test.ts
  • src/lib/logFailurePatterns.ts
  • src/lib/mcpConfigMapping.ts
  • src/lib/modelCatalog.ts
  • src/lib/modelCatalogMembership.test.ts
  • src/lib/modelCatalogMembership.ts
  • src/lib/oliveGpuRuntime.ts
  • src/lib/oliveRecipeBuilder.ts
  • src/lib/openExternal.ts
  • src/lib/owrExportConfigs.ts
  • src/lib/pipelineNavigation.ts
  • src/lib/pipelineValidation.ts
  • src/lib/presetVramEstimate.test.ts
  • src/lib/recipePipeline.ts
  • src/lib/tensorrtDeps.test.ts
  • src/lib/tensorrtDeps.ts
  • src/lib/tensorrtRtxDeps.test.ts
  • src/server/__tests__/routes.integration.test.ts
  • src/server/loadStudioEnv.ts
  • src/server/middleware/rateLimit.ts
  • src/server/routes/ai.ts
  • src/server/routes/ai/chatRoutes.ts
  • src/server/routes/ai/cloudflareRoutes.ts
  • src/server/routes/ai/codexRoutes.ts
  • src/server/routes/ai/devinRoutes.ts
  • src/server/routes/ai/index.ts
  • src/server/routes/ai/installEngineRoutes.ts
  • src/server/routes/ai/lmStudioRoutes.ts
  • src/server/routes/ai/localEngines.ts
  • src/server/routes/ai/modelCatalog.ts
  • src/server/routes/ai/ollamaRoutes.ts
  • src/server/routes/ai/providerRoutes.ts
  • src/server/routes/ai/streamHelpers.ts
  • src/server/routes/mcp.ts
  • src/server/routes/olive.sse.test.ts
  • src/server/routes/olive.stream.test.ts
  • src/server/routes/olive.ts
  • src/server/services/ai/anthropic.ts
  • src/server/services/ai/arenaSnapshotCatalog.test.ts
  • src/server/services/ai/cloudflare.ts
  • src/server/services/ai/detect.test.ts
  • src/server/services/ai/env.ts
  • src/server/services/ai/index.ts
  • src/server/services/ai/localEngineState.ts
  • src/server/services/ai/oliveMcpKnowledge.test.ts
  • src/server/services/ai/oliveMcpKnowledge.ts
  • src/server/services/ai/openai.ts
  • src/server/services/ai/registry.test.ts
  • src/server/services/ai/registry.ts
  • src/server/services/ai/security.test.ts
  • src/server/services/ai/security.ts
  • src/server/services/ai/state.ts
  • src/server/services/arena/ssrfGuard.test.ts
  • src/server/services/arena/ssrfGuard.ts
  • src/server/services/mcp/client.ts
  • src/server/services/olive/cuda.test.ts
  • src/server/services/olive/gpu.test.ts
  • src/server/services/olive/gpu.ts
  • src/server/services/olive/state.test.ts
  • src/server/services/olive/state.ts
  • src/server/services/playground/oliveOutputScan.ts
  • src/server/services/shared/http.test.ts
  • src/server/services/shared/http.ts
  • src/server/services/venv/gpu.ts
  • src/server/services/venv/pythonGuard.ts
  • src/server/shared/anyDotVenvDir.ts
  • src/server/types.ts
  • src/types.ts

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


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.

@tonythethompson

Copy link
Copy Markdown
Owner Author

CI verification — all green ✅

GitHub Actions run #30966708317 on the PR head:

Job Result
validate (install → audit → lint → unit → server → integration → component → recipe smoke → build → artifact assert → prod-start smoke) ✅ success
security (CodeQL) ✅ success
python-tests (MCP server pytest) ✅ success
docker-build (MCP server image + tool smoke) ✅ success

Lint reports the 12 pre-existing warnings (under the project's --max-warnings 20 budget), zero errors.

Local full-suite verification on identical tree (WSL, forks pool serial): lint clean, unit 54/54 files (794 tests), server 22/22 (232), component 16/16 (103), integration 41/41, build clean — all green.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5fea0e20e2

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/components/features/ExecutionWorkspace.tsx Outdated
@qodo-code-review

Copy link
Copy Markdown
Contributor

PR Summary by Qodo

Tech-debt passes 1–6: validation perf, rule tables, log caps, ai.ts split

✨ Enhancement 🐞 Bug fix 🧪 Tests ⚙️ Configuration changes 🕐 40+ Minutes

Grey Divider

AI Description

• Fixes validation pipeline performance: memoizes buildOliveRecipe, reuses validation.recipe,
 and defers derivation via useDeferredValue.
• Replaces drift-prone validation logic with declarative ordered rule tables (tasks/model types +
 cross-pass rules).
• Caps Olive job logs at 1,000 lines, adds logsTruncated, and improves SSE reconnect replay
 behavior.
• Splits monolithic src/server/routes/ai.ts into focused modules under src/server/routes/ai/ and
 extracts local-engine runtime state.
• Tightens serving/deps: OLIVE_SERVE_STATIC, dev-only vite dynamic import, removes unused
 dependency, improves type safety.
Diagram

graph TD
    A["UIState store"] --> B["buildRecipeFromState()"] --> C["getPipelineValidation()"] --> D["buildOliveRecipe() memo"]
    B --> E["ExecutionWorkspace (deferred)"] --> F["POST /olive/run"] --> G["OliveJob logs (capped)"] --> H["SSE /olive/stream + /olive/status"]
    I["routes/ai.ts (old)"] --> J["routes/ai/index.ts"] --> K["ai/* route modules"] --> L["localEngineState"]

    subgraph Legend
      direction LR
      _mod["Module"] ~~~ _api(["API Route"]) ~~~ _store[(State/Store)]
    end
Loading
High-Level Assessment

Approach is appropriate: React deferred derivation + ref-equality memoization targets the real hot path without a state-management rewrite; declarative lookup tables prevent rule drift; log bounding + truncation flag is a pragmatic fix for memory/SSE replay behavior; ai.ts module split improves maintainability with minimal behavioral change.

Files changed (29) +3370 / -3283 · 5 not counted

Enhancement (4) +349 / -341
oliveRecipeBuilder.tsMemoize recipe building; add ordered inference tables and override helpers not counted

Memoize recipe building; add ordered inference tables and override helpers

• Adds ref-equality memoization to 'buildOliveRecipe' and introduces ordered rule tables for HF task/model type inference. Adds helpers to apply pass recipe overrides and enforce canonical pass ordering.

src/lib/oliveRecipeBuilder.ts

pipelineValidation.tsAttach pre-built recipe to validation result and expand provider conflict utilities not counted

Attach pre-built recipe to validation result and expand provider conflict utilities

• 'PipelineValidationResult' now includes a pre-built recipe for reuse. Adds/organizes provider capability helpers and conflict derivation to drive consistent validation/autofix behavior.

src/lib/pipelineValidation.ts

types.tsAdd OliveJob.logsTruncated flag +2/-0

Add OliveJob.logsTruncated flag

• Extends 'OliveJob' with an optional 'logsTruncated' boolean to expose truncation state to callers/clients.

src/server/types.ts

olive.tsIntegrate log-cap/truncation semantics into Olive routes +347/-341

Integrate log-cap/truncation semantics into Olive routes

• Updates Olive run/stream/status routes to align with capped logs and the new 'logsTruncated' signal (including replay behavior on reconnect and status output).

src/server/routes/olive.ts

Bug fix (2) +104 / -92
App.tsxScope QueryClient inside App not counted

Scope QueryClient inside App

• Moves 'QueryClient' creation into the App component to avoid a module-level singleton shared across instances/tests.

src/App.tsx

gpu.tsCap job logs and track truncation +104/-92

Cap job logs and track truncation

• Adds 'MAX_JOB_LOG_LINES=1000' with a 1250-line trim watermark; 'pushLog' trims old lines in batches and sets 'job.logsTruncated=true' when trimming occurs.

src/server/services/olive/gpu.ts

Refactor (15) +2429 / -2289
types.tsTighten recipe typing from any to unknown +167/-170

Tighten recipe typing from any to unknown

• Changes 'OliveRecipe.systems' and 'PassConfig.config' to 'Record<string, unknown>' to remove 'any' usage and improve type safety.

src/types.ts

ai.tsDelete monolithic AI router (2,120 lines) +0/-2119

Delete monolithic AI router (2,120 lines)

• Removes the old all-in-one AI routes implementation; functionality is redistributed into the new 'src/server/routes/ai/' modules.

src/server/routes/ai.ts

index.tsAdd AI route composition entrypoint +26/-0

Add AI route composition entrypoint

• Introduces 'mountAiRoutes' composition that wires provider/chat/engine/model/integration routes from dedicated submodules.

src/server/routes/ai/index.ts

providerRoutes.tsExtract provider management routes +282/-0

Extract provider management routes

• Moves provider selection/config and related endpoints out of the former monolith into a focused module.

src/server/routes/ai/providerRoutes.ts

chatRoutes.tsExtract chat/audit routes +148/-0

Extract chat/audit routes

• Splits chat-related endpoints into their own module to reduce ai routing coupling and file size.

src/server/routes/ai/chatRoutes.ts

lmStudioRoutes.tsExtract LM Studio routes +304/-0

Extract LM Studio routes

• Creates a dedicated module for LM Studio local-engine setup/pull/progress routes previously embedded in ai.ts.

src/server/routes/ai/lmStudioRoutes.ts

ollamaRoutes.tsExtract Ollama routes +299/-0

Extract Ollama routes

• Creates a dedicated module for Ollama local-engine setup/pull/progress routes previously embedded in ai.ts.

src/server/routes/ai/ollamaRoutes.ts

installEngineRoutes.tsExtract local engine install routes +69/-0

Extract local engine install routes

• Moves engine installation/setup endpoints into a dedicated module.

src/server/routes/ai/installEngineRoutes.ts

codexRoutes.tsExtract Codex integration routes +81/-0

Extract Codex integration routes

• Moves Codex-specific endpoints into a dedicated module.

src/server/routes/ai/codexRoutes.ts

devinRoutes.tsExtract Devin integration routes +47/-0

Extract Devin integration routes

• Moves Devin auth/account/model endpoints into a dedicated module.

src/server/routes/ai/devinRoutes.ts

cloudflareRoutes.tsExtract Cloudflare integration routes +78/-0

Extract Cloudflare integration routes

• Moves Cloudflare auth/account/model endpoints into a dedicated module.

src/server/routes/ai/cloudflareRoutes.ts

localEngines.tsExtract shared local-engine coordination logic +590/-0

Extract shared local-engine coordination logic

• Centralizes shared LM Studio/Ollama coordination helpers used across engine route modules.

src/server/routes/ai/localEngines.ts

modelCatalog.tsExtract model catalog routes +230/-0

Extract model catalog routes

• Moves model-catalog endpoints into a focused module.

src/server/routes/ai/modelCatalog.ts

streamHelpers.tsExtract AI route streaming helpers +58/-0

Extract AI route streaming helpers

• Adds shared streaming/response helper utilities for the split AI route modules.

src/server/routes/ai/streamHelpers.ts

localEngineState.tsExtract mutable local-engine runtime state with reset helper +50/-0

Extract mutable local-engine runtime state with reset helper

• Introduces a centralized 'localEngineRuntime' object for LM Studio/Ollama single-flight guards, cached CLI probes, busy tags, and progress subscribers, plus 'resetLocalEngineRuntime()' for test isolation/hot reload safety.

src/server/services/ai/localEngineState.ts

Tests (2) +353 / -280
gpu.test.tsAdd unit tests for log capping and truncation flag +54/-0

Add unit tests for log capping and truncation flag

• Introduces coverage ensuring 'pushLog' trims at the watermark, preserves newest lines, sets 'logsTruncated', and still notifies subscribers for every emitted line.

src/server/services/olive/gpu.test.ts

olive.stream.test.tsExtend SSE stream tests for truncation replay behavior +299/-280

Extend SSE stream tests for truncation replay behavior

• Adds/updates route-level SSE tests to validate reconnect replay behavior when logs have been trimmed, alongside existing buffered replay/live streaming checks.

src/server/routes/olive.stream.test.ts

Other (6) +135 / -281
server.tsAdd OLIVE_SERVE_STATIC and dev-only vite dynamic import +12/-9

Add OLIVE_SERVE_STATIC and dev-only vite dynamic import

• Introduces explicit 'OLIVE_SERVE_STATIC' precedence for static serving decisions and dynamically imports 'vite' only in the dev middleware branch to keep it off the production runtime path.

server.ts

package.jsonMove vite to devDependencies; remove unused @mendable/firecrawl-js +116/-118

Move vite to devDependencies; remove unused @mendable/firecrawl-js

• Relocates 'vite' to devDependencies (enabled by dynamic import) and drops unused '@mendable/firecrawl-js'. Updates dependency lists accordingly.

package.json

pnpm-lock.yamlSync lockfile for dependency cleanup +3/-152

Sync lockfile for dependency cleanup

• Lockfile updated to reflect dependency removals and 'vite' relocation.

pnpm-lock.yaml

recipePipeline.tsReuse validation.recipe and avoid redundant advisory validation passes not counted

Reuse validation.recipe and avoid redundant advisory validation passes

• 'buildRecipeFromState' now reuses 'validation.recipe' (instead of rebuilding) and derives advisories from the existing issues list to avoid re-running validation.

src/lib/recipePipeline.ts

ExecutionWorkspace.tsxDefer expensive pipeline derivation for input responsiveness not counted

Defer expensive pipeline derivation for input responsiveness

• Uses 'useDeferredValue' to defer recipe/validation derivation from UI state, while ensuring Execute/Queue actions rebuild from live state at click time to prevent stale submissions.

src/components/features/ExecutionWorkspace.tsx

StepInspector.tsxCompute advisories from existing validation result +4/-2

Compute advisories from existing validation result

• Removes an extra 'getRemainingAdvisories' call and instead filters advisories from 'validation.issues', avoiding a second full validation run.

src/components/features/recipe-graph/StepInspector.tsx

@qodo-code-review

qodo-code-review Bot commented Aug 5, 2026 •

Copy link
Copy Markdown
Contributor

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (0) 📜 Skill insights (0)

Grey Divider


Action required

1. Client module uses process.env ✓ Resolved 📜 Skill insight ≡ Correctness
Description
src/lib/aiResponse.ts reads process.env, but it is imported by client-side code, which is
unsupported in Vite (no process.env polyfill). This can cause runtime errors or bundling issues in
the browser.
Code

src/lib/aiResponse.ts[R175-178]

+export function readEnvApiKey(...names: string[]): string | undefined {
+  for (const name of names) {
+    const value = process.env[name]?.trim();
+    if (value && !isPlaceholderEnvValue(value)) {
Relevance

●●● Strong

Team previously accepted removing process.env from src/lib imported by client code.

PR-#93

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
PR Compliance ID 2450417 forbids process.env usage in Vite client-side code.
src/lib/chatActions.ts imports from @/lib/aiResponse, and src/lib/aiResponse.ts contains
process.env[...] reads, making this a direct violation.

src/lib/aiResponse.ts[175-199]
src/lib/chatActions.ts[5-8]
Skill: vite-react-best-practices

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
A Vite client-imported module (`src/lib/aiResponse.ts`) references `process.env`, which violates the rule requiring `import.meta.env` (or server-only env access) in Vite projects.

## Issue Context
`src/lib/chatActions.ts` imports `parseJsonFromAiResponse` from `@/lib/aiResponse`, so `aiResponse.ts` is part of the client bundle. Any `process.env` access in this module is non-compliant.

## Fix Focus Areas
- src/lib/aiResponse.ts[169-199]
- src/lib/chatActions.ts[5-8]
- src/server/routes/ai/providerRoutes.ts[1-40]
- src/server/services/ai/registry.ts[1-140]
- src/server/services/ai/state.ts[1-120]
- src/lib/cloudflare/client.ts[1-30]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools



Remediation recommended

2. npm install command in template ✓ Resolved 📘 Rule violation § Compliance
Description
A generated code snippet instructs users to run npm install onnxruntime-web, which violates the
repository policy to use pnpm exclusively in version-controlled commands/documentation. This can
lead to inconsistent lockfiles and tooling usage.
Code

src/lib/owrExportConfigs.ts[R95-97]

+  return `// ONNX Runtime Web (OWR) Service-Worker / App Loader
+// Configured dynamically for: ${modelName} (${architecture})
+// Execute: npm install onnxruntime-web
Relevance

●●● Strong

Team accepted replacing npm/npx commands with pnpm equivalents in repo-tracked docs/snippets.

PR-#62

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
PR Compliance ID 2436617 requires dependency-management commands in repo files to use pnpm, not
npm. The new snippet explicitly says npm install onnxruntime-web.

Rule 2436617: Use pnpm exclusively for dependency management commands
src/lib/owrExportConfigs.ts[95-99]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
A template string includes an `npm install ...` instruction.

## Issue Context
Repo policy requires pnpm-only dependency management commands in version-controlled content.

## Fix Focus Areas
- src/lib/owrExportConfigs.ts[95-99]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


3. Prod detection ignores dist/server.mjs ✓ Resolved 📘 Rule violation ≡ Correctness
Description
shouldServeProductionStatic() no longer checks that process.argv[1] ends with dist/server.mjs,
so production detection may misclassify non-prod server.mjs entrypoints. This violates the
requirement to detect production mode using the entry-script suffix, not just NODE_ENV.
Code

server.ts[R153-154]

  const entry = (process.argv[1] ?? "").replace(/\\/g, "/");
-  return (
-    entry.endsWith("/dist/server.mjs") ||
-    entry.endsWith("server.mjs") ||
-    // legacy CJS bundle name (older builds)
-    entry.endsWith("/dist/server.cjs") ||
-    entry.endsWith("server.cjs")
-  );
+  return entry.endsWith("server.mjs") || entry.endsWith("server.cjs");
Relevance

●●● Strong

Prod-mode heuristics around dist/server.* seem important; restoring dist/server.mjs suffix check
likely accepted.

PR-#15

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
PR Compliance ID 2506954 requires production detection to include a
process.argv[1]?.endsWith('dist/server.mjs') check. The updated implementation only checks
entry.endsWith('server.mjs')/server.cjs, which does not meet the required suffix condition.

Rule 2506954: Environment mode detection must check process.argv[1] suffix, not only NODE_ENV
server.ts[145-155]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`server.ts` production-mode detection no longer checks that `process.argv[1]` ends with `dist/server.mjs`, which is required for reliable prod/dev branching.

## Issue Context
Compliance requires that environment mode detection include an entry-script suffix check for `dist/server.mjs` (not solely `NODE_ENV`).

## Fix Focus Areas
- server.ts[145-155]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

Context used
✅ Compliance rules (platform): 86 rules
✅ REVIEW.md

To customize comments, go to the Qodo configuration screen, or learn more in the docs.

Qodo Logo

Comment thread server.ts Outdated
Comment thread src/lib/aiResponse.ts Outdated
Comment thread src/lib/owrExportConfigs.ts Outdated
@qodo-code-review

Copy link
Copy Markdown
Contributor

Qodo Fixer

✅ Committed (3) · ☑ Fixed (3)

Grey Divider

Commits pushed directly to this PR — no separate fix PR opened.

Process — 3 fixed
  • ☑ Fixed: Client module uses process.env
  • ☑ Fixed: npm install command in template
  • ☑ Fixed: Prod detection ignores dist/server.mjs

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
The env-read refactor (1a6f82f) moved readEnvApiKey from lib/aiResponse.ts
to services/ai/env.ts, but registry.test.ts still mocked the old path, so
the mock never intercepted and provider-detection assertions saw undefined.

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
@tonythethompson

Copy link
Copy Markdown
Owner Author

Re-verified green on final head (7a1fd74): CI run #30968033753 — validate, security, python-tests, docker-build all passing. (The intermediate red run was a stale mock path in registry.test.ts left behind by the env-read refactor; fixed in 7a1fd74.)

Addresses the Codex review comment on PR #115: the export handlers
serialized the deferred display recipe, which could lag the latest
keystroke. Export artifacts now rebuild fresh via
buildRecipeJsonFromState(state), matching the Execute/Queue handlers.

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
Rebase-equivalent merge of Dual ORT / QNN (#111, #117) into tech-debt
branch. Conflicts were mostly CRLF vs LF; keep both log-cap and QNN
probe imports in olive routes, and preserve .venvs ignore entries.

Co-authored-by: Anthony Thompson <github@trackdub.com>
@tonythethompson

Copy link
Copy Markdown
Owner Author

@greptile-apps review

@greptile-apps

greptile-apps Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR completes six tech-debt passes spanning recipe-validation performance, declarative validation rules, bounded job logs, production static-serving selection, dependency cleanup, and decomposition of the AI route module.

  • Defers display-only recipe derivation while rebuilding from live state for execution, queuing, and export.
  • Caps retained job logs and reports truncation through SSE replay and status responses.
  • Splits the former AI route monolith into focused route modules with shared local-engine runtime state.
  • Moves Vite to development dependencies and dynamically loads it only for development serving.

Confidence Score: 5/5

The PR appears safe to merge, with no concrete changed-code failure remaining after review.

Live-state rebuilds protect execution boundaries, log retention and replay remain internally consistent, and no reachable contract regression was established in the AI route decomposition.

Important Files Changed

Filename Overview
src/components/features/ExecutionWorkspace.tsx Defers expensive display derivation while correctly rebuilding recipes from live state at every execution and export boundary.
src/lib/oliveRecipeBuilder.ts Adds reference-equality memoization consistent with the store's immutable top-level state updates.
src/lib/pipelineValidation.ts Consolidates cross-pass coercion and issue generation into shared declarative rules.
src/server/services/olive/gpu.ts Bounds retained per-job logs using a watermark and records whether older entries were discarded.
src/server/routes/olive.ts Exposes log truncation in status responses and emits a clear marker before truncated SSE replay.
src/server/routes/ai/index.ts Composes the decomposed AI route modules in explicit provider and engine order with no concrete regression identified.
src/server/services/ai/localEngineState.ts Centralizes local-engine single-flight, cooldown, cache, busy-tag, and subscriber state with a reset hook.
server.ts Uses the new AI route entry point and conditionally loads Vite only on the development-serving path.
package.json Removes an unused dependency and keeps Vite solely as a development dependency.

Reviews (1): Last reviewed commit: "Merge branch 'main' into tech-debt-passe..." | Re-trigger Greptile

@codefactor-io

codefactor-io Bot commented Aug 5, 2026

Copy link
Copy Markdown

CodeFactor found an issue: Literal carriage return. Run script through tr -d '\r' .

It's currently on:
launch-tauri.sh:1
Commit 5fea0e2

@codefactor-io

codefactor-io Bot commented Aug 5, 2026

Copy link
Copy Markdown

CodeFactor found an issue: Literal carriage return. Run script through tr -d '\r' .

It's currently on:
launch-tauri.sh:2
Commit 5fea0e2

@codefactor-io

codefactor-io Bot commented Aug 5, 2026

Copy link
Copy Markdown

CodeFactor found an issue: Literal carriage return. Run script through tr -d '\r' .

It's currently on:
launch-tauri.sh:3
Commit 5fea0e2

@codefactor-io

codefactor-io Bot commented Aug 5, 2026

Copy link
Copy Markdown

CodeFactor found an issue: Literal carriage return. Run script through tr -d '\r' .

It's currently on:
launch-tauri.sh:4
Commit 5fea0e2

@codefactor-io

codefactor-io Bot commented Aug 5, 2026

Copy link
Copy Markdown

CodeFactor found an issue: Literal carriage return. Run script through tr -d '\r' .

It's currently on:
launch-tauri.sh:10
Commit 5fea0e2

ShellCheck rejects CRLF line endings; pin *.sh to LF via .gitattributes.

Co-authored-by: Cursor <cursoragent@cursor.com>
@greptile-apps

greptile-apps Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Too many files changed for review (231 files, 100 file limit).

Bypass the limit by tagging @greptile-apps to review.

@tonythethompson
tonythethompson merged commit dd0d3b3 into main Aug 5, 2026
12 checks passed
@tonythethompson
tonythethompson deleted the tech-debt-passes-1-6 branch August 5, 2026 14:08
@linear-code

linear-code Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

OLI-41

This branch was successfully deployed

1 active deployment
Preview — e70e0ccc Deployed Aug 5, 2026 by vercel[bot]
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