merge: hoà cập nhật mới từ origin/feature/delta-team/epic-R04 (R08 Chat UI Hub + R10)
Đồng nghiệp đã push thêm 10 commit lên nhánh trong lúc đang xử lý merge
trước đó (R08-T01..T06 chat_panel.py split, R08 folder/dashboard/graph/
scheduling hoàn thiện, R10 CI Quality Gates + Contributor Recipes + E2E
smoke test). Resolve conflict:
- application/monitoring/__init__.py, domain/tasks/__init__.py,
infrastructure/persistence/json/__init__.py: chỉ khác docstring — giữ bản
HEAD (đầy đủ ngữ cảnh EPIC hơn), hợp nhất __all__ khi cần
(MonitoringQueryService).
- tests/fakes/__init__.py: hợp nhất __getattr__ để lazy-load cả
FakeToolExecutor lẫn ToolInvocation (bản HEAD thiếu ToolInvocation), bỏ
entry "FakeClock" bị lặp trong __all__.
- tests/integration/test_routing_surfaces.py (deleted by them): khôi phục
lại bản đã sửa ở lần merge trước — verify lại: API routing
(RoutingApplicationService.resolve/_apply_routing/_apply_co4e_routing)
không đổi sau khi chat_panel.py chuyển sang presentation/chat/*, 9/9 test
vẫn pass trên code đã merge.
Ghi chú (không sửa, ngoài phạm vi merge): tests/fakes/__init__.py trên nhánh
remote export "ToolInvocation" từ fake_tool_executor.py nhưng class này đã
bị xoá nhầm từ commit chung 10739f1 (breakdown folder tree epic R01) — hiện
là dead code, không ai import, nhưng sẽ raise ImportError nếu có test nào
sau này thử dùng.
Đã chạy pytest tests/: 793 passed (không phát sinh fail mới so với lần
merge trước — 8 fail còn lại đều do môi trường sandbox: thiếu package
keyring, và tên thư mục checkout "cowork-local" thay vì "cowork_local"
khiến vài test spawn-subprocess không import được package).
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -14,5 +14,6 @@ should move once Monitoring's own query service exists.
|
||||
"""
|
||||
|
||||
from .dashboard_query_service import DashboardQueryService
|
||||
from .monitoring_query_service import MonitoringQueryService
|
||||
|
||||
__all__ = ["DashboardQueryService"]
|
||||
__all__ = ["DashboardQueryService", "MonitoringQueryService"]
|
||||
|
||||
@@ -28,10 +28,12 @@ class DashboardQueryService:
|
||||
ctx: ``AppContext`` — read for ``ctx.config`` (pricing table,
|
||||
currency, budget) and nothing else; this class does no I/O of
|
||||
its own beyond what ``core.usage_tracker`` already does.
|
||||
directory: Optional custom usage directory. If None, uses default USAGE_DIR.
|
||||
"""
|
||||
|
||||
def __init__(self, ctx: Any) -> None:
|
||||
def __init__(self, ctx: Any, directory: Optional[Path] = None) -> None:
|
||||
self.ctx = ctx
|
||||
self._directory = directory
|
||||
|
||||
def pricing(self) -> Dict[str, Any]:
|
||||
"""The merged price table (defaults + user overrides), synced from
|
||||
@@ -58,7 +60,7 @@ class DashboardQueryService:
|
||||
read the same numbers instead of loading events twice."""
|
||||
from cowork_local.core import usage_tracker as ut
|
||||
|
||||
events = ut.load_events(start, end)
|
||||
events = ut.load_events(start, end, directory=self._directory)
|
||||
pricing = self.pricing()
|
||||
stats = ut.summarize(events)
|
||||
costs = ut.cost_usd_events(events, pricing)
|
||||
@@ -77,7 +79,7 @@ class DashboardQueryService:
|
||||
("tokens" | "cost") was selected."""
|
||||
from cowork_local.core import usage_tracker as ut
|
||||
|
||||
events = ut.load_events() # all events; breakdown slices by period
|
||||
events = ut.load_events(directory=self._directory) # all events; breakdown slices by period
|
||||
pricing = self.pricing()
|
||||
parts = ut.period_breakdown(events, granularity, pricing, offset=offset)
|
||||
mi = 0 if metric == "tokens" else 1 # (label, tokens, cost) -> +1 for the value
|
||||
@@ -88,7 +90,7 @@ class DashboardQueryService:
|
||||
vs-previous-period delta the chart's reference line shows."""
|
||||
from cowork_local.core import usage_tracker as ut
|
||||
|
||||
events = ut.load_events()
|
||||
events = ut.load_events(directory=self._directory)
|
||||
return ut.period_totals(events, granularity, self.pricing(), offset)
|
||||
|
||||
def period_range_label(self, granularity: str, offset: int) -> str:
|
||||
|
||||
Reference in New Issue
Block a user