Skip to content

Design resource observability split#209

Closed
shuxueshuxue wants to merge 6 commits intodevfrom
issue-205-resource-observability-split
Closed

Design resource observability split#209
shuxueshuxue wants to merge 6 commits intodevfrom
issue-205-resource-observability-split

Conversation

@shuxueshuxue
Copy link
Copy Markdown
Collaborator

@shuxueshuxue shuxueshuxue commented Apr 6, 2026

Summary

  • keep monitor as the global/admin observability surface
  • split product resources onto a dedicated user-scoped contract instead of /api/monitor/resources
  • move shared resource helper ownership into backend/web/services/resource_common.py so product projection no longer depends on resource_service.py internals
  • move monitor/resource read paths, raw sandbox CRUD paths, and chat-session status writes onto strategy-aware wiring instead of SQLite-only sidecar factories
  • record the honest scope boundary: full Supabase-only parity still reaches into lower lease/terminal domain state machines, not just routers/services

What This Branch Actually Changes

  • add product-only routes in backend/web/routers/resources.py
    • GET /api/resources/overview
    • POST /api/resources/overview/refresh
    • GET /api/resources/sandbox/{lease_id}/browse
    • GET /api/resources/sandbox/{lease_id}/read
  • keep /api/monitor/* for the global monitor surface
  • switch product frontend resources callers from /api/monitor/resources* to /api/resources/overview*
  • switch product sandbox file browser calls from /api/monitor/sandbox/* to /api/resources/sandbox/*
  • add minimal browser-proof selectors to the product resources page and provider cards
  • make make_sandbox_monitor_repo() strategy-aware so Supabase mode returns SupabaseSandboxMonitorRepo
  • add make_lease_repo(), make_terminal_repo(), and make_chat_session_repo() to backend/web/core/storage_factory.py
  • route raw lease / terminal / chat-session repo instantiation in backend/web/services/activity_tracker.py, backend/web/utils/helpers.py, backend/web/services/file_channel_service.py, backend/web/routers/threads.py, and sandbox/manager.py through those strategy-aware factories
  • make list_user_leases() use runtime repo builders instead of directly constructing SQLite member/thread repos
  • stop sandbox/resource_snapshot.py from creating or writing SQLite snapshot tables in Supabase mode
  • extract shared provider catalog, telemetry normalization, capability lookup, and runtime thread/member owner lookup into backend/web/services/resource_common.py
  • keep backend/web/services/resource_projection_service.py as the user-visible projection owner and point resource_cache.py at that projection boundary
  • reduce backend/web/services/resource_service.py to sandbox browse/read plus snapshot probe duties
  • make sandbox/chat_session.py::ChatSession write touch() and close() through the injected ChatSessionRepo when available, instead of always issuing raw SQLite updates
  • let ChatSessionManager reuse injected terminal/lease/session repos on the rehydrate path
  • fix storage/providers/supabase/sandbox_monitor_repo.py::list_sessions_with_leases() to match SQLite fallback semantics for terminal rows and latest-session fallback
  • add direct SQLite-vs-Supabase parity coverage for the monitor repo session fallback contract
  • fix frontend/monitor dev proxy to use the current worktree backend port instead of hardcoded 8001

Final Design Direction

  • keep /api/monitor/resources as the global monitor contract for ops/debugging
  • add /api/resources/* for user-visible product resources
  • keep monitor DTOs and product DTOs separate
  • keep frontend churn minimal; backend boundary correctness comes first
  • keep shared helper logic in a neutral module instead of private cross-service imports
  • treat raw CRUD factory swaps as a distinct seam from the lower lease/terminal domain state machines

Honest Scope Boundary

  • this PR does not pretend that read-path rewiring alone completes the Supabase migration
  • raw CRUD creation / deletion / activity updates now have strategy-aware paths, and chat-session touch/close can write back through ChatSessionRepo
  • but lower sandbox truth writes still exist outside this slice: SQLiteLease.apply() and SQLiteTerminal._persist_state() remain SQLite-backed, so full Supabase-only claims remain larger than this PR

Real Evidence

  • product Playwright proof on local app /resources
    • real page rendered with header, counts, refresh button, and provider cards
    • browser requests included GET /api/resources/overview -> 200
    • refresh produced POST /api/resources/overview/refresh -> 200
    • no /api/monitor/resources request appeared in that browser trace
  • monitor Playwright proof on local monitor /leases
    • real monitor shell and leases table rendered
    • browser requests included GET /api/monitor/leases -> 200
    • no /api/resources/* request appeared in that browser trace

Verification

  • env -u ALL_PROXY -u all_proxy -u HTTPS_PROXY -u https_proxy -u HTTP_PROXY -u http_proxy uv run pytest -q tests/Unit/backend/web/services/test_resource_common.py tests/Fix/test_monitor_resource_overview_uniqueness.py tests/Integration/test_resources_route.py tests/Integration/test_monitor_resources_route.py tests/Unit/monitor/test_monitor_resource_probe.py tests/Fix/test_sandbox_user_leases.py tests/Unit/backend/web/core/test_storage_factory.py tests/Unit/sandbox/test_resource_snapshot_strategy.py tests/Unit/sandbox/test_sandbox_manager_volume_repo.py tests/Unit/monitor/test_sqlite_sandbox_monitor_repo.py
  • result: 42 passed
  • uv run pytest -q tests/Unit/sandbox/test_manager_repo_strategy.py tests/Unit/sandbox/test_chat_session.py tests/Unit/sandbox/test_lease.py tests/Unit/backend/web/core/test_storage_factory.py
  • result: 54 passed
  • uv run ruff check backend/web/core/storage_factory.py backend/web/services/activity_tracker.py backend/web/utils/helpers.py backend/web/services/file_channel_service.py backend/web/routers/threads.py sandbox/chat_session.py sandbox/manager.py sandbox/lease.py tests/Unit/backend/web/core/test_storage_factory.py tests/Unit/sandbox/test_manager_repo_strategy.py tests/Unit/sandbox/test_chat_session.py tests/Unit/sandbox/test_lease.py
  • uv run ruff format --check backend/web/core/storage_factory.py backend/web/services/activity_tracker.py backend/web/utils/helpers.py backend/web/services/file_channel_service.py backend/web/routers/threads.py sandbox/chat_session.py sandbox/manager.py sandbox/lease.py tests/Unit/backend/web/core/test_storage_factory.py tests/Unit/sandbox/test_manager_repo_strategy.py tests/Unit/sandbox/test_chat_session.py tests/Unit/sandbox/test_lease.py
  • uv run pyright backend/web/core/storage_factory.py backend/web/services/activity_tracker.py backend/web/utils/helpers.py backend/web/services/file_channel_service.py backend/web/routers/threads.py sandbox/chat_session.py sandbox/manager.py sandbox/lease.py
  • result: 0 errors, 0 warnings, 0 informations
  • cd frontend/app && npm test -- src/pages/resources/api.test.ts src/pages/resources/ProviderCard.test.ts
  • cd frontend/app && npx eslint src/pages/resources/api.ts src/pages/ResourcesPage.tsx src/pages/resources/ProviderCard.tsx src/components/SandboxFileBrowser.tsx src/pages/resources/api.test.ts src/pages/resources/ProviderCard.test.ts
  • cd frontend/app && npm run build
  • cd frontend/monitor && npm run build

Links

@shuxueshuxue
Copy link
Copy Markdown
Collaborator Author

Superseded by #210. #209 established valid resource-split and wiring seams, but it was built on the stripped monitor shell. #210 carries those seams forward while transplanting the richer compat monitor surface from #182 and continuing the work there.

@shuxueshuxue
Copy link
Copy Markdown
Collaborator Author

Closing this in favor of #210.\n\nReason: the resource observability split in this branch was built on the wrong monitor baseline. #210 carries forward the useful resource/contract work from here, but integrates it onto the compat monitor transplant and continues as the single review surface.

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