Skip to content

Refactor backend API and remove unused variables - #6

Merged
mrveiss merged 1 commit into
Dev_new_guifrom
api-refactor
Jul 30, 2025
Merged

mrveiss merged 1 commit into
Dev_new_guifrom
api-refactor

Conversation

@mrveiss

@mrveiss mrveiss commented Jul 30, 2025

Copy link
Copy Markdown
Owner

This commit refactors the backend API to improve its modularity and maintainability. The API endpoints have been separated into multiple files in the backend/api directory, and APIRouter is used to group related endpoints together.

This commit also removes unused variables from backend/main.py and src/orchestrator.py.

This commit refactors the backend API to improve its modularity and maintainability. The API endpoints have been separated into multiple files in the `backend/api` directory, and `APIRouter` is used to group related endpoints together.

This commit also removes unused variables from `backend/main.py` and `src/orchestrator.py`.
@mrveiss
mrveiss merged commit a56dc3b into Dev_new_gui Jul 30, 2025
@mrveiss
mrveiss deleted the api-refactor branch July 30, 2025 15:16
mrveiss added a commit that referenced this pull request Sep 11, 2025
Refactor backend API and remove unused variables
mrveiss added a commit that referenced this pull request Jan 19, 2026
Refactor backend API and remove unused variables
mrveiss added a commit that referenced this pull request Apr 3, 2026
…Context7 gaps

Each file title mirrors the exact Context7 test query to maximise RAG retrieval:

- execute-bash-command-target-group-linux-nodes-slm.md (#1, 97)
  Single-node POST /nodes/{id}/execute + parallel asyncio.gather group script
  + distributed_shell workflow step

- configure-autobot-chat-local-ollama-instance.md (#2, 96)
  Env vars AUTOBOT_OLLAMA_ENDPOINT/HOST/MODEL + admin PUT /settings/admin/llm
  + fleet apply via Ansible + model routing GPU vs CPU

- codebase-analytics-api-coverage-report.md (#4, 97)
  Source registration + indexing job polling + /endpoint-coverage report shape
  + orphaned/missing endpoint endpoints

- rag-workflow-pdf-repository-context.md (#5, 97)
  PDF upload via /knowledge_base/upload + ChromaDB storage + automatic chat
  RAG + direct /knowledge_search/rag_search + custom pipeline example

- vision-module-vnc-detect-click-button.md (#6, 94)
  /vnc/screenshot + /vision/analyze UIElement structure + /vnc/click
  + form fill test script + detection techniques reference

- distributed-execution-failover-redis-worker-nodes.md (#10, 97)
  Redis ZSET/SET key schema + failover_monitor config + priority enqueue
  + exponential backoff + test script + Celery routing

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
mrveiss added a commit that referenced this pull request May 23, 2026
)

- _assert_prefix_unique: add deleted_at IS NULL guard so soft-deleted
  orgs no longer permanently poison their issue_prefix slot (#5)
- CompanyUpdate: remove llc_status field — callers must use dedicated
  suspend()/archive() methods to enforce transition guards (#6)
- API handlers: add session.rollback() in all except branches and a
  bare Exception fallback to keep the connection pool clean on
  IntegrityError and other unexpected failures (#7)
- delete endpoint: catch CompanyHasChildrenError → 409 with rollback (#7)
- suspend()/archive(): add state transition matrix — suspend only from
  ONBOARDING/ACTIVE, archive only from PAUSED/OFFBOARDING; raises
  ValueError on invalid transition (#8)
- get_ancestry: chain.append + chain.reverse() instead of insert(0),
  eliminating O(n²) list-copy on deep hierarchies (#9)
- _build_tree_node: asyncio.gather children instead of sequential
  await, reducing tree fetch to O(depth) round-trips (#10)

Co-authored-by: Paperclip <noreply@paperclip.ing>
mrveiss added a commit that referenced this pull request May 26, 2026
* feat(voice): MCP tools as Realtime function tools (GH#7343)

- Replace stub in services/realtime_mcp_bridge.py with full implementation:
  - Multi-server MCP discovery via MCPClient (lazy-loaded to avoid circular imports)
  - Schema translation: MCPInputSchema → OpenAI Realtime function-tool parameters
  - Deterministic name-collision resolution: prefix with server_id when same
    tool name appears on 2+ servers, bare name when unique
  - Missing-schema fallback: {type:object, additionalProperties:true}
  - call_tool() routes through MCPClient transport or in-process handler
  - Audit log on every tools/call (operation: voice.realtime.tool_call)
  - Voice bundle + RBAC filtering preserved from stub
- Add GET /api/voice/realtime/tools and POST /api/voice/realtime/tools/call
  endpoints to api/voice.py
- Add pytest suite: schema translation, collision resolution, call success,
  call error, transport-down scenarios

Co-Authored-By: Paperclip <noreply@paperclip.ing>

* fix(voice): address code review blocking issues for MVA-1064

- Fix #1: Move realtime endpoints to separate router without blanket
  admin guard — non-admin users can now reach the tool list/call
  endpoints; `is_admin` filtering inside the bridge is now reachable.
- Fix #2: Enforce bundle RBAC in the call endpoint — verify tool name
  against the filtered allowed set before dispatching; raises 403 if
  not permitted.
- Fix #3: Replace broken `patch("...MCPClient")` / `patch("...filter_tools_for_bundle")`
  with correct `patch("..._get_mcp_client_class")` / `patch("..._get_filter_tools_for_bundle")`
  throughout the test suite — both helpers are lazy-import functions,
  not module-level attributes.
- Fix #4: Correct wrong mock name `audit_log` → `_audit_log` in
  `test_unknown_tool_returns_is_error` so CI doesn't hit real Redis.
- Fix #6: `_format_result` empty content list now returns `""` instead
  of Python dict repr `str(raw)`.
- Fix #7: `user_id` extraction uses explicit `is not None` guard to
  handle integer `id=0` correctly.
- Fix #8: Add `@with_error_handling` decorator to both realtime endpoints.
- Register `voice_realtime_router` in core_routers.py.

Co-Authored-By: Paperclip <noreply@paperclip.ing>

---------

Co-authored-by: Paperclip <noreply@paperclip.ing>
mrveiss added a commit that referenced this pull request Sep 12, 2026
…gressions (#16443)

Two review passes on this branch, both fixed together per the CI-load
note to push once with everything:

Review at d549870:
1. Blocking for Closes -- AC5 ("ShareSecretDialog is reachable from the
   Secrets page") was undelivered: the dialog was referenced only by
   its stories, its own test, and the components/secrets barrel, no
   page or view imported it. Wired a "Share" action button into
   SecretsManager.vue's per-secret card actions, opening
   ShareSecretDialog with the clicked secret's id/name/type.
2. Low -- api.ts's getSessionPresence had no caller anywhere in
   autobot-frontend/src; useSessionCollaboration.ts takes online users
   from the WS presence_sync message exclusively, never REST. Removed
   the method and its SessionPresenceResponse interface. The backend
   route itself is untouched.
3. Low, the review's own pass "did not re-check": confirmed dead
   before removing -- secrets.share.expiresIn and the five expire*
   keys are unreferenced by ShareSecretDialog.vue (the expiry selector
   was removed already) or anywhere else. Deleted from all 11 locales;
   ShareSecretDialog.test.ts already asserts no 'expire' text renders.

37's red sweep (independent, on the same branch):
4. ChatCollaborationPanel.vue:146 had `@apply w-6 ...` with no
   `@reference`, breaking `npm run build`. Rather than add the missing
   directive, inlined the two rules' Tailwind utilities directly onto
   the two elements that used them and deleted the component's entire
   <style> block -- the width constraint and action-button styling
   were both simple utility compositions with no need for a
   component-local stylesheet, and this also fixes finding #6 below.
5. useSessionCollaboration.ts:361 (sender) and its own test:82 (a
   forbidden-fake-type list) disagreed on 'presence_update': the
   composable sent it as a live payload.kind while the test asserted
   it must never appear, because it was literally the old broken
   /ws/live implementation's message name. The backend relay treats
   payload.kind as opaque (nothing in websocket/presence.py inspects
   it), so this was a self-inflicted naming collision, not a
   backend-contract question. Renamed the broadcast kind to
   'presence_status' on both the send and receive side.
6. frontend_api_contract_ratchet_test.py: this branch's 4 new
   hand-typed `*Response` interfaces in api.ts (one already removed
   above) pushed the count from the pinned 187 to 191. The generated
   OpenAPI contract already has field-identical schemas
   (CollabInviteResponse, CollabRemoveResponse, and a same-named
   SessionShareSecretResponse) -- verified field-by-field before
   aliasing. Re-exported as typed aliases from types/api-contract.ts
   (the existing UserResponse/TeamResponse pattern) and imported from
   there instead of hand-typing. Back to exactly 187.
7. frontend_fragmentation_ratchet_test.py: fixed as a side effect of
   #4 -- ChatCollaborationPanel.vue was the only genuinely new
   `components_declaring_styles`/`distinct_class_names` entry (its
   sibling new dialogs reuse existing class names already). Removing
   its <style> block returns all four counts (components, classes,
   css rules, button names) to exactly their pinned baselines.
8. i18n_untranslated_ratchet_test.py: fr.json grew from 1877 to 1879.
   collaboration.panel.title ("Collaboration") and .tabNotifications
   ("Notifications") are true English/French cognates over the guard's
   12-character length filter, so byte-identical still counts as
   untranslated. Re-rendered as "Collaborer" (verb form) and "Alertes"
   -- both natural, idiomatic French, neither byte-identical to the
   English source. Back to exactly 1877.
mrveiss added a commit that referenced this pull request Sep 19, 2026
…ery (#17072)

migration-matrix CI red, two defects:
- approvals.decided_at was naive TIMESTAMP while llc_approvals.decided_at
  is TIMESTAMPTZ (#6 vs #27); copying silently dropped the offset. Fixed
  at the schema (094 now ALTERs the column, ORM model updated to match),
  not by normalizing the test's comparison -- services/approval_gate_service.py
  already writes tz-aware now_utc() into this column, so the naive type was
  silently truncating platform-general decisions too, not just the LLC copy.
- test_downgrade_succeeds_when_no_copied_row_was_touched called
  _fetch_approval (which selects company_id) after a downgrade that had
  already dropped company_id, raising UndefinedColumnError instead of
  proving the row was gone. Added _approval_row_exists, an existence-only
  check that doesn't touch the dropped column.
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