Compare commits
14
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
104b267627 | ||
|
|
86227cec37 | ||
|
|
728cc48f90 | ||
|
|
c32873b3d4 | ||
|
|
346b76bc00 | ||
|
|
2cab4b9cdf | ||
|
|
9028cb342d | ||
|
|
8d43f4c372 | ||
|
|
e8ba63e087 | ||
|
|
309ed277fe | ||
|
|
2ef31f6115 | ||
|
|
159a9a6a8b | ||
|
|
7ed181e682 | ||
|
|
203f81334a |
+11
-4
@@ -28,15 +28,18 @@ background scheduler
|
|||||||
|
|
||||||
- `server.py` is the stable command/import facade. Runtime composition lives in
|
- `server.py` is the stable command/import facade. Runtime composition lives in
|
||||||
`backend/application.py` and `backend/bootstrap/`.
|
`backend/application.py` and `backend/bootstrap/`.
|
||||||
- `backend/http/` owns common authentication, request IDs, responses, static delivery, and
|
- `backend/bootstrap/` owns process configuration, dependency construction, startup, and
|
||||||
error normalization. Feature-specific transport handlers live beside their feature.
|
shared input/display-format contracts. It does not own feature behavior.
|
||||||
|
- `backend/http/` owns common authentication, request IDs, JSON/NDJSON responses, static
|
||||||
|
delivery, streaming connection lifecycle, and error normalization. Feature-specific
|
||||||
|
transport handlers live beside their feature.
|
||||||
Exact POST endpoints that only delegate to one of those handlers use the explicit maps in
|
Exact POST endpoints that only delegate to one of those handlers use the explicit maps in
|
||||||
`backend/application.py`; endpoints with path parameters, body handling, or special error
|
`backend/application.py`; endpoints with path parameters, body handling, or special error
|
||||||
semantics remain visible control flow in `RequestHandler`.
|
semantics remain visible control flow in `RequestHandler`.
|
||||||
- `backend/features/<feature>/` owns the mechanically moved service, repository, HTTP, agent,
|
- `backend/features/<feature>/` owns the mechanically moved service, repository, HTTP, agent,
|
||||||
or deterministic calculation code for that product area.
|
or deterministic calculation code for that product area.
|
||||||
- `backend/data/` owns provider construction, source policy, provenance, units, freshness,
|
- `backend/data/` owns provider construction, source policy, provenance, units, freshness,
|
||||||
coverage, and display-versus-calculation eligibility.
|
coverage, display-versus-calculation eligibility, and shared numeric normalization policies.
|
||||||
- `backend/database/` owns connection management, ordered migrations, and narrow repository
|
- `backend/database/` owns connection management, ordered migrations, and narrow repository
|
||||||
adapters. Root `database.py` remains the legacy schema/composition anchor and combines the
|
adapters. Root `database.py` remains the legacy schema/composition anchor and combines the
|
||||||
feature repository mixins; do not add feature queries to it.
|
feature repository mixins; do not add feature queries to it.
|
||||||
@@ -55,7 +58,11 @@ background scheduler
|
|||||||
|
|
||||||
Root modules such as `screener.py`, `tushare_client.py`, and `mentor_agent.py` are compatibility
|
Root modules such as `screener.py`, `tushare_client.py`, and `mentor_agent.py` are compatibility
|
||||||
aliases to canonical modules. They contain no second implementation and remain only because
|
aliases to canonical modules. They contain no second implementation and remain only because
|
||||||
the original public import surface is part of the preservation contract.
|
the original public import surface is part of the preservation contract. Canonical backend
|
||||||
|
modules must import other canonical modules directly rather than routing through these aliases.
|
||||||
|
The remaining `api_access` import in `backend/application.py` and preserved lazy
|
||||||
|
`sentiment_engine` import in the screener repository are registered transition boundaries;
|
||||||
|
the root `database.py` remains the documented schema/composition anchor.
|
||||||
|
|
||||||
## Non-negotiable maintenance rules
|
## Non-negotiable maintenance rules
|
||||||
|
|
||||||
|
|||||||
@@ -128,14 +128,19 @@ class DashboardService(
|
|||||||
profile_supplier=self._resolved_llm_profile,
|
profile_supplier=self._resolved_llm_profile,
|
||||||
)
|
)
|
||||||
self.screener.ensure_builtin_strategies()
|
self.screener.ensure_builtin_strategies()
|
||||||
self._background_stop = threading.Event()
|
|
||||||
self._background_thread = self.jobs.start_scheduler(
|
def start_background_jobs(self) -> threading.Thread:
|
||||||
|
return self.jobs.start_scheduler(
|
||||||
self._background_refresh_tick,
|
self._background_refresh_tick,
|
||||||
self._background_stop,
|
|
||||||
interval_seconds=5,
|
interval_seconds=5,
|
||||||
initial_delay_seconds=3,
|
initial_delay_seconds=3,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def stop_background_jobs(self, timeout_seconds: float = 5) -> bool:
|
||||||
|
scheduler_stopped = self.jobs.stop_scheduler(timeout_seconds)
|
||||||
|
workers_stopped = self.jobs.wait_for_idle(timeout_seconds)
|
||||||
|
return scheduler_stopped and workers_stopped
|
||||||
|
|
||||||
|
|
||||||
def _load_system_credentials(self, environment: dict[str, str]) -> dict[str, Any]:
|
def _load_system_credentials(self, environment: dict[str, str]) -> dict[str, Any]:
|
||||||
encrypted = self.database.get_system_setting("credentials")
|
encrypted = self.database.get_system_setting("credentials")
|
||||||
@@ -472,38 +477,6 @@ class DashboardService(
|
|||||||
**self.database.status(),
|
**self.database.status(),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def _ifind_field(row: dict[str, Any], tokens: tuple[str, ...]) -> Any:
|
|
||||||
for key, value in row.items():
|
|
||||||
label = str(key or "")
|
|
||||||
if any(token.casefold() == label.casefold() for token in tokens):
|
|
||||||
return value
|
|
||||||
for key, value in row.items():
|
|
||||||
label = str(key or "")
|
|
||||||
if any(token in label for token in tokens):
|
|
||||||
return value
|
|
||||||
return None
|
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def _ifind_row_code(cls, row: dict[str, Any]) -> str:
|
|
||||||
value = cls._ifind_field(row, ("股票代码", "证券代码", "代码", "thscode"))
|
|
||||||
match = re.search(r"(?<!\d)(\d{6})(?!\d)", str(value or ""))
|
|
||||||
if match:
|
|
||||||
return match.group(1)
|
|
||||||
for value in row.values():
|
|
||||||
match = re.search(r"(?<!\d)(\d{6})\.(?:SH|SZ|BJ)(?![A-Z])", str(value or ""), re.I)
|
|
||||||
if match:
|
|
||||||
return match.group(1)
|
|
||||||
return ""
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
SERVICE = DashboardService()
|
SERVICE = DashboardService()
|
||||||
|
|
||||||
|
|
||||||
@@ -1020,16 +993,6 @@ class RequestHandler(
|
|||||||
return
|
return
|
||||||
self.send_json({"error": "Not found"}, HTTPStatus.NOT_FOUND)
|
self.send_json({"error": "Not found"}, HTTPStatus.NOT_FOUND)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def _write_stream_event(self, payload: dict[str, Any]) -> None:
|
|
||||||
self.wfile.write(
|
|
||||||
(json.dumps(payload, ensure_ascii=False, separators=(",", ":")) + "\n").encode("utf-8")
|
|
||||||
)
|
|
||||||
self.wfile.flush()
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def save_reason(self) -> None:
|
def save_reason(self) -> None:
|
||||||
try:
|
try:
|
||||||
body = self.read_json_body()
|
body = self.read_json_body()
|
||||||
|
|||||||
@@ -71,6 +71,10 @@ def normalize_date(value: str) -> str:
|
|||||||
return parsed.strftime("%Y%m%d")
|
return parsed.strftime("%Y%m%d")
|
||||||
|
|
||||||
|
|
||||||
|
def display_compact_date(value: str) -> str:
|
||||||
|
return f"{value[:4]}-{value[4:6]}-{value[6:8]}" if len(value) == 8 else value
|
||||||
|
|
||||||
|
|
||||||
def validate_stock_code(value: str) -> str:
|
def validate_stock_code(value: str) -> str:
|
||||||
code = value.strip()
|
code = value.strip()
|
||||||
if not re.fullmatch(r"\d{6}", code):
|
if not re.fullmatch(r"\d{6}", code):
|
||||||
|
|||||||
@@ -9,10 +9,10 @@ from backend.database.repositories import RepositoryBundle, build_repository_bun
|
|||||||
from backend.features.alerts import AlertService
|
from backend.features.alerts import AlertService
|
||||||
from backend.features.mentor.agent import MentorSkillRegistry
|
from backend.features.mentor.agent import MentorSkillRegistry
|
||||||
from backend.features.review import TradeJournalService
|
from backend.features.review import TradeJournalService
|
||||||
|
from backend.features.screener.engine import ScreenerEngine
|
||||||
from backend.features.screener.tracking import StrategyTrackingService
|
from backend.features.screener.tracking import StrategyTrackingService
|
||||||
from backend.jobs import InProcessJobRunner, JobRegistry, SQLiteJobRunRepository
|
from backend.jobs import InProcessJobRunner, JobRegistry, SQLiteJobRunRepository
|
||||||
from database import ReviewDatabase
|
from database import ReviewDatabase
|
||||||
from screener import ScreenerEngine
|
|
||||||
from backend.data.providers.ifind_client import IfindHttpClient
|
from backend.data.providers.ifind_client import IfindHttpClient
|
||||||
from backend.data.realtime import WebRealtimeAggregator
|
from backend.data.realtime import WebRealtimeAggregator
|
||||||
from backend.features.market.charts import MarketChartClient
|
from backend.features.market.charts import MarketChartClient
|
||||||
|
|||||||
@@ -16,12 +16,13 @@ def main(handler_class: type[Any] | None = None, service: Any | None = None) ->
|
|||||||
parser.add_argument("--port", type=int, default=8765)
|
parser.add_argument("--port", type=int, default=8765)
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
server = ThreadingHTTPServer((args.host, args.port), handler_class)
|
server = ThreadingHTTPServer((args.host, args.port), handler_class)
|
||||||
print(f"Xiaobai Review Web is running at http://{args.host}:{args.port}")
|
|
||||||
print("Press Ctrl+C to stop.")
|
|
||||||
try:
|
try:
|
||||||
|
service.start_background_jobs()
|
||||||
|
print(f"Xiaobai Review Web is running at http://{args.host}:{args.port}")
|
||||||
|
print("Press Ctrl+C to stop.")
|
||||||
server.serve_forever()
|
server.serve_forever()
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
pass
|
pass
|
||||||
finally:
|
finally:
|
||||||
service._background_stop.set()
|
service.stop_background_jobs()
|
||||||
server.server_close()
|
server.server_close()
|
||||||
|
|||||||
@@ -0,0 +1,20 @@
|
|||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
import math
|
||||||
|
from typing import Any
|
||||||
|
|
||||||
|
|
||||||
|
def finite_number(value: Any, default: float = 0.0) -> float:
|
||||||
|
try:
|
||||||
|
number = float(value)
|
||||||
|
return number if math.isfinite(number) else default
|
||||||
|
except (TypeError, ValueError):
|
||||||
|
return default
|
||||||
|
|
||||||
|
|
||||||
|
def non_nan_number(value: Any, default: float = 0.0) -> float:
|
||||||
|
try:
|
||||||
|
number = float(value)
|
||||||
|
return number if number == number else default
|
||||||
|
except (TypeError, ValueError):
|
||||||
|
return default
|
||||||
@@ -11,6 +11,8 @@ from datetime import datetime, time as dt_time, timedelta
|
|||||||
from threading import Lock
|
from threading import Lock
|
||||||
from typing import Any, ClassVar
|
from typing import Any, ClassVar
|
||||||
|
|
||||||
|
from backend.bootstrap.config import display_compact_date as _display_date
|
||||||
|
from backend.data.numbers import finite_number as _number
|
||||||
from backend.features.sentiment.engine import apply_sentiment_to_dashboard
|
from backend.features.sentiment.engine import apply_sentiment_to_dashboard
|
||||||
|
|
||||||
|
|
||||||
@@ -1812,14 +1814,6 @@ class TushareClient:
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def _number(value: Any, default: float = 0.0) -> float:
|
|
||||||
try:
|
|
||||||
number = float(value)
|
|
||||||
return number if math.isfinite(number) else default
|
|
||||||
except (TypeError, ValueError):
|
|
||||||
return default
|
|
||||||
|
|
||||||
|
|
||||||
def _text(value: Any) -> str:
|
def _text(value: Any) -> str:
|
||||||
if isinstance(value, (list, tuple, set)):
|
if isinstance(value, (list, tuple, set)):
|
||||||
return "、".join(str(item).strip() for item in value if str(item).strip())
|
return "、".join(str(item).strip() for item in value if str(item).strip())
|
||||||
@@ -2014,10 +2008,6 @@ def _display_time(value: Any) -> str:
|
|||||||
return f"{raw[:2]}:{raw[2:4]}:{raw[4:6]}"
|
return f"{raw[:2]}:{raw[2:4]}:{raw[4:6]}"
|
||||||
|
|
||||||
|
|
||||||
def _display_date(value: str) -> str:
|
|
||||||
return f"{value[:4]}-{value[4:6]}-{value[6:8]}" if len(value) == 8 else value
|
|
||||||
|
|
||||||
|
|
||||||
def _realtime_market_status(current_time: dt_time) -> str:
|
def _realtime_market_status(current_time: dt_time) -> str:
|
||||||
if current_time < dt_time(9, 25):
|
if current_time < dt_time(9, 25):
|
||||||
return "pre_open"
|
return "pre_open"
|
||||||
|
|||||||
@@ -7,6 +7,35 @@ from typing import Any
|
|||||||
|
|
||||||
|
|
||||||
class HeavenRepositoryMixin:
|
class HeavenRepositoryMixin:
|
||||||
|
def list_sector_phase_overrides(self) -> dict[str, str]:
|
||||||
|
with self.connect() as connection:
|
||||||
|
rows = connection.execute(
|
||||||
|
"SELECT name, element FROM sector_phase_overrides ORDER BY updated_at DESC, name"
|
||||||
|
).fetchall()
|
||||||
|
return {row["name"]: row["element"] for row in rows}
|
||||||
|
|
||||||
|
def save_sector_phase_override(self, name: str, element: str) -> None:
|
||||||
|
now = datetime.now().astimezone().isoformat(timespec="seconds")
|
||||||
|
with self.connect() as connection:
|
||||||
|
connection.execute(
|
||||||
|
"""
|
||||||
|
INSERT INTO sector_phase_overrides (name, element, updated_at)
|
||||||
|
VALUES (?, ?, ?)
|
||||||
|
ON CONFLICT(name) DO UPDATE SET
|
||||||
|
element = excluded.element,
|
||||||
|
updated_at = excluded.updated_at
|
||||||
|
""",
|
||||||
|
(name, element, now),
|
||||||
|
)
|
||||||
|
|
||||||
|
def delete_sector_phase_override(self, name: str) -> bool:
|
||||||
|
with self.connect() as connection:
|
||||||
|
cursor = connection.execute(
|
||||||
|
"DELETE FROM sector_phase_overrides WHERE name = ?",
|
||||||
|
(name,),
|
||||||
|
)
|
||||||
|
return cursor.rowcount > 0
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _heaven_reading_dict(row: sqlite3.Row | None) -> dict[str, Any] | None:
|
def _heaven_reading_dict(row: sqlite3.Row | None) -> dict[str, Any] | None:
|
||||||
if not row:
|
if not row:
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ from __future__ import annotations
|
|||||||
import copy
|
import copy
|
||||||
import json
|
import json
|
||||||
import re
|
import re
|
||||||
|
import secrets
|
||||||
from datetime import date, datetime, timedelta
|
from datetime import date, datetime, timedelta
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ from datetime import datetime, time as dt_time, timedelta
|
|||||||
from threading import Lock
|
from threading import Lock
|
||||||
from typing import Any, ClassVar
|
from typing import Any, ClassVar
|
||||||
|
|
||||||
|
from backend.bootstrap.config import tushare_code as _stock_market_code
|
||||||
from backend.data.providers.ifind_client import IfindError, IfindHttpClient
|
from backend.data.providers.ifind_client import IfindError, IfindHttpClient
|
||||||
|
|
||||||
|
|
||||||
@@ -475,16 +476,6 @@ def _ifind_point(row: dict[str, Any]) -> dict[str, Any] | None:
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def _stock_market_code(code: str) -> str:
|
|
||||||
if code.startswith(("4", "8", "9")):
|
|
||||||
suffix = "BJ"
|
|
||||||
elif code.startswith("6"):
|
|
||||||
suffix = "SH"
|
|
||||||
else:
|
|
||||||
suffix = "SZ"
|
|
||||||
return f"{code}.{suffix}"
|
|
||||||
|
|
||||||
|
|
||||||
def _number(value: Any) -> float:
|
def _number(value: Any) -> float:
|
||||||
try:
|
try:
|
||||||
return float(value or 0)
|
return float(value or 0)
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ from datetime import datetime, time as dt_time, timedelta, timezone
|
|||||||
from statistics import median
|
from statistics import median
|
||||||
from typing import TYPE_CHECKING, Any, Callable
|
from typing import TYPE_CHECKING, Any, Callable
|
||||||
|
|
||||||
|
from backend.data.numbers import non_nan_number as _number
|
||||||
from backend.data.providers.ifind_client import IfindError, IfindHttpClient
|
from backend.data.providers.ifind_client import IfindError, IfindHttpClient
|
||||||
from backend.data.providers.tushare_client import TushareClient, TushareError
|
from backend.data.providers.tushare_client import TushareClient, TushareError
|
||||||
|
|
||||||
@@ -16,14 +17,6 @@ if TYPE_CHECKING:
|
|||||||
CHINA_TIMEZONE = timezone(timedelta(hours=8))
|
CHINA_TIMEZONE = timezone(timedelta(hours=8))
|
||||||
|
|
||||||
|
|
||||||
def _number(value: Any, default: float = 0.0) -> float:
|
|
||||||
try:
|
|
||||||
number = float(value)
|
|
||||||
return number if number == number else default
|
|
||||||
except (TypeError, ValueError):
|
|
||||||
return default
|
|
||||||
|
|
||||||
|
|
||||||
def _display_date(value: str) -> str:
|
def _display_date(value: str) -> str:
|
||||||
text = str(value or "").replace("-", "")
|
text = str(value or "").replace("-", "")
|
||||||
if len(text) != 8:
|
if len(text) != 8:
|
||||||
|
|||||||
@@ -14,19 +14,4 @@ class MentorHttpMixin:
|
|||||||
except (ValueError, json.JSONDecodeError) as exc:
|
except (ValueError, json.JSONDecodeError) as exc:
|
||||||
self.send_json({"error": str(exc)}, HTTPStatus.BAD_REQUEST)
|
self.send_json({"error": str(exc)}, HTTPStatus.BAD_REQUEST)
|
||||||
return
|
return
|
||||||
self.send_response(HTTPStatus.OK)
|
self.send_ndjson_stream(stream, (ValueError, MentorAgentError))
|
||||||
self.send_header("Content-Type", "application/x-ndjson; charset=utf-8")
|
|
||||||
self.send_header("Cache-Control", "no-cache, no-transform")
|
|
||||||
self.send_header("X-Accel-Buffering", "no")
|
|
||||||
self.send_header("Connection", "close")
|
|
||||||
self.end_headers()
|
|
||||||
try:
|
|
||||||
for event in stream:
|
|
||||||
self._write_stream_event(event)
|
|
||||||
self._write_stream_event({"type": "done"})
|
|
||||||
except (ValueError, MentorAgentError) as exc:
|
|
||||||
self._write_stream_event({"type": "error", "error": str(exc)})
|
|
||||||
except (BrokenPipeError, ConnectionResetError):
|
|
||||||
pass
|
|
||||||
finally:
|
|
||||||
self.close_connection = True
|
|
||||||
|
|||||||
@@ -117,6 +117,30 @@ class PoolServiceMixin:
|
|||||||
finally:
|
finally:
|
||||||
self._ifind_event_lock.release()
|
self._ifind_event_lock.release()
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def _ifind_field(row: dict[str, Any], tokens: tuple[str, ...]) -> Any:
|
||||||
|
for key, value in row.items():
|
||||||
|
label = str(key or "")
|
||||||
|
if any(token.casefold() == label.casefold() for token in tokens):
|
||||||
|
return value
|
||||||
|
for key, value in row.items():
|
||||||
|
label = str(key or "")
|
||||||
|
if any(token in label for token in tokens):
|
||||||
|
return value
|
||||||
|
return None
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def _ifind_row_code(cls, row: dict[str, Any]) -> str:
|
||||||
|
value = cls._ifind_field(row, ("股票代码", "证券代码", "代码", "thscode"))
|
||||||
|
match = re.search(r"(?<!\d)(\d{6})(?!\d)", str(value or ""))
|
||||||
|
if match:
|
||||||
|
return match.group(1)
|
||||||
|
for value in row.values():
|
||||||
|
match = re.search(r"(?<!\d)(\d{6})\.(?:SH|SZ|BJ)(?![A-Z])", str(value or ""), re.I)
|
||||||
|
if match:
|
||||||
|
return match.group(1)
|
||||||
|
return ""
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _normalize_ifind_event_time(value: Any) -> str:
|
def _normalize_ifind_event_time(value: Any) -> str:
|
||||||
text = str(value or "").strip()
|
text = str(value or "").strip()
|
||||||
|
|||||||
@@ -26,22 +26,8 @@ class ReviewHttpMixin:
|
|||||||
except (ValueError, json.JSONDecodeError) as exc:
|
except (ValueError, json.JSONDecodeError) as exc:
|
||||||
self.send_json({"error": str(exc)}, HTTPStatus.BAD_REQUEST)
|
self.send_json({"error": str(exc)}, HTTPStatus.BAD_REQUEST)
|
||||||
return
|
return
|
||||||
self.send_response(HTTPStatus.OK)
|
events = ({"type": "delta", "content": chunk} for chunk in stream)
|
||||||
self.send_header("Content-Type", "application/x-ndjson; charset=utf-8")
|
self.send_ndjson_stream(events, (ValueError, ReviewAssistantError))
|
||||||
self.send_header("Cache-Control", "no-cache, no-transform")
|
|
||||||
self.send_header("X-Accel-Buffering", "no")
|
|
||||||
self.send_header("Connection", "close")
|
|
||||||
self.end_headers()
|
|
||||||
try:
|
|
||||||
for chunk in stream:
|
|
||||||
self._write_stream_event({"type": "delta", "content": chunk})
|
|
||||||
self._write_stream_event({"type": "done"})
|
|
||||||
except (ValueError, ReviewAssistantError) as exc:
|
|
||||||
self._write_stream_event({"type": "error", "error": str(exc)})
|
|
||||||
except (BrokenPipeError, ConnectionResetError):
|
|
||||||
pass
|
|
||||||
finally:
|
|
||||||
self.close_connection = True
|
|
||||||
|
|
||||||
def save_watchlist(self) -> None:
|
def save_watchlist(self) -> None:
|
||||||
try:
|
try:
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import json
|
|||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
from backend.llm import transport as llm_transport
|
from backend.llm import transport as llm_transport
|
||||||
from screener import FACTOR_FIELDS, REGIMES
|
from backend.features.screener.engine import FACTOR_FIELDS, REGIMES
|
||||||
|
|
||||||
|
|
||||||
class LLMCompilerError(RuntimeError):
|
class LLMCompilerError(RuntimeError):
|
||||||
|
|||||||
@@ -8,10 +8,12 @@ from collections import defaultdict
|
|||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
from advanced_strategies import ADVANCED_CURATED_STRATEGIES
|
from backend.bootstrap.config import display_compact_date as _display_date
|
||||||
|
from backend.data.numbers import finite_number as _number
|
||||||
|
from backend.data.providers.tushare_client import TushareClient, TushareError
|
||||||
|
from backend.features.screener.strategies import ADVANCED_CURATED_STRATEGIES
|
||||||
from database import ReviewDatabase
|
from database import ReviewDatabase
|
||||||
from backend.features.sentiment.engine import build_sentiment_history, latest_contiguous_history
|
from backend.features.sentiment.engine import build_sentiment_history, latest_contiguous_history
|
||||||
from tushare_client import TushareClient, TushareError
|
|
||||||
|
|
||||||
|
|
||||||
REGIMES = {
|
REGIMES = {
|
||||||
@@ -2199,15 +2201,3 @@ def _regime_reason(regime: str) -> str:
|
|||||||
"divergence": "指数或核心仍强,但广度、封板质量开始分化。",
|
"divergence": "指数或核心仍强,但广度、封板质量开始分化。",
|
||||||
"retreat": "情绪指标继续走弱,应提高筛选门槛并接受无候选结果。",
|
"retreat": "情绪指标继续走弱,应提高筛选门槛并接受无候选结果。",
|
||||||
}.get(regime, "市场阶段待确认。")
|
}.get(regime, "市场阶段待确认。")
|
||||||
|
|
||||||
|
|
||||||
def _number(value: Any, default: float = 0.0) -> float:
|
|
||||||
try:
|
|
||||||
number = float(value)
|
|
||||||
return number if math.isfinite(number) else default
|
|
||||||
except (TypeError, ValueError):
|
|
||||||
return default
|
|
||||||
|
|
||||||
|
|
||||||
def _display_date(value: str) -> str:
|
|
||||||
return f"{value[:4]}-{value[4:6]}-{value[6:8]}" if len(value) == 8 else value
|
|
||||||
|
|||||||
@@ -4,6 +4,8 @@ from copy import deepcopy
|
|||||||
from statistics import mean, median
|
from statistics import mean, median
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
|
from backend.data.numbers import non_nan_number as _number
|
||||||
|
|
||||||
|
|
||||||
COMPONENT_WEIGHTS = {
|
COMPONENT_WEIGHTS = {
|
||||||
"breadth": 20,
|
"breadth": 20,
|
||||||
@@ -16,14 +18,6 @@ COMPONENT_WEIGHTS = {
|
|||||||
SENTIMENT_ENGINE_VERSION = 2
|
SENTIMENT_ENGINE_VERSION = 2
|
||||||
|
|
||||||
|
|
||||||
def _number(value: Any, default: float = 0.0) -> float:
|
|
||||||
try:
|
|
||||||
number = float(value)
|
|
||||||
return number if number == number else default
|
|
||||||
except (TypeError, ValueError):
|
|
||||||
return default
|
|
||||||
|
|
||||||
|
|
||||||
def _clamp(value: float, lower: float = 0.0, upper: float = 100.0) -> float:
|
def _clamp(value: float, lower: float = 0.0, upper: float = 100.0) -> float:
|
||||||
return min(upper, max(lower, value))
|
return min(upper, max(lower, value))
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ from __future__ import annotations
|
|||||||
import json
|
import json
|
||||||
import mimetypes
|
import mimetypes
|
||||||
import secrets
|
import secrets
|
||||||
|
from collections.abc import Iterable
|
||||||
from http import HTTPStatus
|
from http import HTTPStatus
|
||||||
from http.cookies import SimpleCookie
|
from http.cookies import SimpleCookie
|
||||||
from typing import Any
|
from typing import Any
|
||||||
@@ -142,5 +143,33 @@ class HttpTransportMixin:
|
|||||||
self.end_headers()
|
self.end_headers()
|
||||||
self.wfile.write(content)
|
self.wfile.write(content)
|
||||||
|
|
||||||
|
def _write_stream_event(self, payload: dict[str, Any]) -> None:
|
||||||
|
self.wfile.write(
|
||||||
|
(json.dumps(payload, ensure_ascii=False, separators=(",", ":")) + "\n").encode("utf-8")
|
||||||
|
)
|
||||||
|
self.wfile.flush()
|
||||||
|
|
||||||
|
def send_ndjson_stream(
|
||||||
|
self,
|
||||||
|
events: Iterable[dict[str, Any]],
|
||||||
|
error_types: tuple[type[Exception], ...],
|
||||||
|
) -> None:
|
||||||
|
self.send_response(HTTPStatus.OK)
|
||||||
|
self.send_header("Content-Type", "application/x-ndjson; charset=utf-8")
|
||||||
|
self.send_header("Cache-Control", "no-cache, no-transform")
|
||||||
|
self.send_header("X-Accel-Buffering", "no")
|
||||||
|
self.send_header("Connection", "close")
|
||||||
|
self.end_headers()
|
||||||
|
try:
|
||||||
|
for event in events:
|
||||||
|
self._write_stream_event(event)
|
||||||
|
self._write_stream_event({"type": "done"})
|
||||||
|
except error_types as exc:
|
||||||
|
self._write_stream_event({"type": "error", "error": str(exc)})
|
||||||
|
except (BrokenPipeError, ConnectionResetError):
|
||||||
|
pass
|
||||||
|
finally:
|
||||||
|
self.close_connection = True
|
||||||
|
|
||||||
def log_message(self, format_string: str, *args: Any) -> None:
|
def log_message(self, format_string: str, *args: Any) -> None:
|
||||||
print(f"[{self.log_date_time_string()}] {format_string % args}")
|
print(f"[{self.log_date_time_string()}] {format_string % args}")
|
||||||
|
|||||||
+37
-19
@@ -18,6 +18,9 @@ class InProcessJobRunner:
|
|||||||
self.repository = repository
|
self.repository = repository
|
||||||
self._locks: dict[str, threading.Lock] = {}
|
self._locks: dict[str, threading.Lock] = {}
|
||||||
self._locks_guard = threading.Lock()
|
self._locks_guard = threading.Lock()
|
||||||
|
self._scheduler_guard = threading.Lock()
|
||||||
|
self._scheduler_stop = threading.Event()
|
||||||
|
self._scheduler_thread: threading.Thread | None = None
|
||||||
|
|
||||||
def submit(
|
def submit(
|
||||||
self, job_id: str, idempotency_key: str, action: JobAction,
|
self, job_id: str, idempotency_key: str, action: JobAction,
|
||||||
@@ -52,27 +55,42 @@ class InProcessJobRunner:
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
def start_scheduler(
|
def start_scheduler(
|
||||||
self, callback: Callable[[], None], stop_event: threading.Event,
|
self, callback: Callable[[], None], interval_seconds: float,
|
||||||
interval_seconds: float, initial_delay_seconds: float = 0,
|
initial_delay_seconds: float = 0,
|
||||||
) -> threading.Thread:
|
) -> threading.Thread:
|
||||||
def schedule_loop() -> None:
|
with self._scheduler_guard:
|
||||||
if stop_event.wait(initial_delay_seconds):
|
current = self._scheduler_thread
|
||||||
return
|
if current is not None and current.is_alive():
|
||||||
while not stop_event.is_set():
|
return current
|
||||||
try:
|
self._scheduler_stop.clear()
|
||||||
callback()
|
|
||||||
except Exception:
|
|
||||||
# Submitted jobs persist their own failures; the scheduler must stay alive.
|
|
||||||
pass
|
|
||||||
stop_event.wait(interval_seconds)
|
|
||||||
|
|
||||||
thread = threading.Thread(
|
def schedule_loop() -> None:
|
||||||
target=schedule_loop,
|
if self._scheduler_stop.wait(initial_delay_seconds):
|
||||||
name="background-job-scheduler",
|
return
|
||||||
daemon=True,
|
while not self._scheduler_stop.is_set():
|
||||||
)
|
try:
|
||||||
thread.start()
|
callback()
|
||||||
return thread
|
except Exception:
|
||||||
|
# Submitted jobs persist failures; the scheduler must stay alive.
|
||||||
|
pass
|
||||||
|
self._scheduler_stop.wait(interval_seconds)
|
||||||
|
|
||||||
|
thread = threading.Thread(
|
||||||
|
target=schedule_loop,
|
||||||
|
name="background-job-scheduler",
|
||||||
|
daemon=True,
|
||||||
|
)
|
||||||
|
self._scheduler_thread = thread
|
||||||
|
thread.start()
|
||||||
|
return thread
|
||||||
|
|
||||||
|
def stop_scheduler(self, timeout_seconds: float = 5) -> bool:
|
||||||
|
with self._scheduler_guard:
|
||||||
|
thread = self._scheduler_thread
|
||||||
|
self._scheduler_stop.set()
|
||||||
|
if thread is not None and thread is not threading.current_thread():
|
||||||
|
thread.join(max(0, timeout_seconds))
|
||||||
|
return thread is None or not thread.is_alive()
|
||||||
|
|
||||||
def wait_for_idle(self, timeout_seconds: float = 5) -> bool:
|
def wait_for_idle(self, timeout_seconds: float = 5) -> bool:
|
||||||
deadline = time.monotonic() + max(0, timeout_seconds)
|
deadline = time.monotonic() + max(0, timeout_seconds)
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ from datetime import datetime, timezone
|
|||||||
from typing import Any
|
from typing import Any
|
||||||
from urllib.parse import urlparse
|
from urllib.parse import urlparse
|
||||||
|
|
||||||
|
from backend.bootstrap.config import validate_text
|
||||||
from backend.features.screener.compiler import LLMCompilerError, test_llm_connection
|
from backend.features.screener.compiler import LLMCompilerError, test_llm_connection
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -220,6 +220,41 @@
|
|||||||
"runtime_role": "index observation fallback"
|
"runtime_role": "index observation fallback"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
"provider_construction": [
|
||||||
|
{
|
||||||
|
"client": "TushareClient",
|
||||||
|
"owner": "backend/data/providers/tushare.py",
|
||||||
|
"compatibility_fallback": "backend/features/market/service.py"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"client": "IfindHttpClient",
|
||||||
|
"owner": "backend/data/gateway.py"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"client": "MarketChartClient",
|
||||||
|
"owner": "backend/data/gateway.py"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"client": "WebRealtimeAggregator",
|
||||||
|
"owner": "backend/data/gateway.py"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"numeric_normalization": [
|
||||||
|
{
|
||||||
|
"function": "finite_number",
|
||||||
|
"path": "backend/data/numbers.py"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"function": "non_nan_number",
|
||||||
|
"path": "backend/data/numbers.py"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"date_formatting": [
|
||||||
|
{
|
||||||
|
"function": "display_compact_date",
|
||||||
|
"path": "backend/bootstrap/config.py"
|
||||||
|
}
|
||||||
|
],
|
||||||
"llm_entrypoints": [
|
"llm_entrypoints": [
|
||||||
{
|
{
|
||||||
"function": "stream_with_mentor",
|
"function": "stream_with_mentor",
|
||||||
@@ -252,6 +287,16 @@
|
|||||||
"path": "backend/llm/transport.py"
|
"path": "backend/llm/transport.py"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
"http_transport": [
|
||||||
|
{
|
||||||
|
"function": "send_json",
|
||||||
|
"path": "backend/http/handler.py"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"function": "send_ndjson_stream",
|
||||||
|
"path": "backend/http/handler.py"
|
||||||
|
}
|
||||||
|
],
|
||||||
"css_layers": [
|
"css_layers": [
|
||||||
"/shared/tokens.css?v=20260729-1",
|
"/shared/tokens.css?v=20260729-1",
|
||||||
"/styles/styles.css",
|
"/styles/styles.css",
|
||||||
@@ -264,13 +309,13 @@
|
|||||||
"code_hotspots": [
|
"code_hotspots": [
|
||||||
{
|
{
|
||||||
"path": "frontend/styles/styles.css",
|
"path": "frontend/styles/styles.css",
|
||||||
"bytes": 361776,
|
"bytes": 360238,
|
||||||
"lines": 15465
|
"lines": 15385
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"path": "frontend/styles/redesign-v2.css",
|
"path": "frontend/styles/redesign-v2.css",
|
||||||
"bytes": 263539,
|
"bytes": 262826,
|
||||||
"lines": 8570
|
"lines": 8554
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"path": "frontend/index.html",
|
"path": "frontend/index.html",
|
||||||
@@ -279,13 +324,13 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"path": "backend/features/screener/engine.py",
|
"path": "backend/features/screener/engine.py",
|
||||||
"bytes": 108552,
|
"bytes": 108387,
|
||||||
"lines": 2213
|
"lines": 2203
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"path": "backend/data/providers/tushare_client.py",
|
"path": "backend/data/providers/tushare_client.py",
|
||||||
"bytes": 94329,
|
"bytes": 94124,
|
||||||
"lines": 2175
|
"lines": 2165
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"path": "frontend/app.js",
|
"path": "frontend/app.js",
|
||||||
@@ -299,8 +344,8 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"path": "frontend/styles/renovation.css",
|
"path": "frontend/styles/renovation.css",
|
||||||
"bytes": 83949,
|
"bytes": 83812,
|
||||||
"lines": 1553
|
"lines": 1550
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"path": "frontend/pages/heaven/page.css",
|
"path": "frontend/pages/heaven/page.css",
|
||||||
@@ -309,13 +354,13 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"path": "backend/features/heaven/service.py",
|
"path": "backend/features/heaven/service.py",
|
||||||
"bytes": 63123,
|
"bytes": 63138,
|
||||||
"lines": 1303
|
"lines": 1304
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"path": "backend/features/market/insights.py",
|
"path": "backend/features/market/insights.py",
|
||||||
"bytes": 58150,
|
"bytes": 57998,
|
||||||
"lines": 1314
|
"lines": 1307
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"path": "frontend/pages/market/runtime.js",
|
"path": "frontend/pages/market/runtime.js",
|
||||||
@@ -329,8 +374,8 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"path": "backend/application.py",
|
"path": "backend/application.py",
|
||||||
"bytes": 48749,
|
"bytes": 47769,
|
||||||
"lines": 1129
|
"lines": 1092
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"path": "frontend/styles/theme.css",
|
"path": "frontend/styles/theme.css",
|
||||||
@@ -339,8 +384,8 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"path": "database.py",
|
"path": "database.py",
|
||||||
"bytes": 33284,
|
"bytes": 32073,
|
||||||
"lines": 746
|
"lines": 716
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-31
@@ -2,7 +2,7 @@ from __future__ import annotations
|
|||||||
|
|
||||||
import json
|
import json
|
||||||
import sqlite3
|
import sqlite3
|
||||||
from datetime import datetime, timezone
|
from datetime import datetime
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
@@ -665,36 +665,6 @@ class ReviewDatabase(
|
|||||||
)
|
)
|
||||||
MigrationRunner().apply(connection, MIGRATIONS)
|
MigrationRunner().apply(connection, MIGRATIONS)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def list_sector_phase_overrides(self) -> dict[str, str]:
|
|
||||||
with self.connect() as connection:
|
|
||||||
rows = connection.execute(
|
|
||||||
"SELECT name, element FROM sector_phase_overrides ORDER BY updated_at DESC, name"
|
|
||||||
).fetchall()
|
|
||||||
return {row["name"]: row["element"] for row in rows}
|
|
||||||
|
|
||||||
def save_sector_phase_override(self, name: str, element: str) -> None:
|
|
||||||
now = datetime.now().astimezone().isoformat(timespec="seconds")
|
|
||||||
with self.connect() as connection:
|
|
||||||
connection.execute(
|
|
||||||
"""
|
|
||||||
INSERT INTO sector_phase_overrides (name, element, updated_at)
|
|
||||||
VALUES (?, ?, ?)
|
|
||||||
ON CONFLICT(name) DO UPDATE SET
|
|
||||||
element = excluded.element,
|
|
||||||
updated_at = excluded.updated_at
|
|
||||||
""",
|
|
||||||
(name, element, now),
|
|
||||||
)
|
|
||||||
|
|
||||||
def delete_sector_phase_override(self, name: str) -> bool:
|
|
||||||
with self.connect() as connection:
|
|
||||||
cursor = connection.execute(
|
|
||||||
"DELETE FROM sector_phase_overrides WHERE name = ?",
|
|
||||||
(name,),
|
|
||||||
)
|
|
||||||
return cursor.rowcount > 0
|
|
||||||
def list_wencai_saved_queries(
|
def list_wencai_saved_queries(
|
||||||
self, user_id: int, limit: int = 30
|
self, user_id: int, limit: int = 30
|
||||||
) -> list[dict[str, Any]]:
|
) -> list[dict[str, Any]]:
|
||||||
|
|||||||
@@ -751,9 +751,6 @@ body.sidebar-collapsed .status-bar { left: 64px; }
|
|||||||
min-height: 50px;
|
min-height: 50px;
|
||||||
padding: 6px 8px;
|
padding: 6px 8px;
|
||||||
}
|
}
|
||||||
.market-tape { display: none; }
|
|
||||||
.header-actions { width: 100%; }
|
|
||||||
.header-command-group { position: absolute; }
|
|
||||||
.module-nav,
|
.module-nav,
|
||||||
body.sidebar-collapsed .module-nav {
|
body.sidebar-collapsed .module-nav {
|
||||||
inset: auto 0 0;
|
inset: auto 0 0;
|
||||||
@@ -769,14 +766,6 @@ body.sidebar-collapsed .status-bar { left: 64px; }
|
|||||||
border: 0;
|
border: 0;
|
||||||
border-top: 1px solid var(--r2-line);
|
border-top: 1px solid var(--r2-line);
|
||||||
}
|
}
|
||||||
.sidebar-brand,
|
|
||||||
.module-nav .nav-group-label,
|
|
||||||
.sidebar-collapse-button,
|
|
||||||
.module-nav .market-sub-tab { display: none; }
|
|
||||||
.module-nav .nav-group,
|
|
||||||
body.sidebar-collapsed .module-nav .nav-group { display: contents; }
|
|
||||||
.module-nav .module-tab,
|
|
||||||
body.sidebar-collapsed .module-nav .module-tab { display: none; }
|
|
||||||
.module-nav .module-tab.mobile-primary-tab,
|
.module-nav .module-tab.mobile-primary-tab,
|
||||||
body.sidebar-collapsed .module-nav .module-tab.mobile-primary-tab {
|
body.sidebar-collapsed .module-nav .module-tab.mobile-primary-tab {
|
||||||
min-height: 54px;
|
min-height: 54px;
|
||||||
@@ -789,12 +778,8 @@ body.sidebar-collapsed .status-bar { left: 64px; }
|
|||||||
padding: 3px 2px;
|
padding: 3px 2px;
|
||||||
font-size: 10px;
|
font-size: 10px;
|
||||||
}
|
}
|
||||||
.module-nav .module-tab.mobile-primary-tab span { display: inline; }
|
|
||||||
.app-main { width: 100%; margin: 0; padding: 0 8px 16px; overflow: visible; }
|
.app-main { width: 100%; margin: 0; padding: 0 8px 16px; overflow: visible; }
|
||||||
.overview-strip { margin-inline: -8px; padding-inline: 8px; overflow-x: auto; }
|
.overview-strip { margin-inline: -8px; padding-inline: 8px; overflow-x: auto; }
|
||||||
.overview-strip .metric:nth-of-type(n + 4),
|
|
||||||
.overview-strip .metric-wide { display: none; }
|
|
||||||
.overview-toggle { display: none; }
|
|
||||||
.redesigned-page-head { align-items: flex-start; flex-wrap: wrap; margin-top: 12px; }
|
.redesigned-page-head { align-items: flex-start; flex-wrap: wrap; margin-top: 12px; }
|
||||||
.redesigned-page-head .section-title-group { width: 100%; flex-wrap: wrap; }
|
.redesigned-page-head .section-title-group { width: 100%; flex-wrap: wrap; }
|
||||||
.redesigned-page-head .toolbar-controls { width: 100%; margin-left: 0; justify-content: space-between; }
|
.redesigned-page-head .toolbar-controls { width: 100%; margin-left: 0; justify-content: space-between; }
|
||||||
@@ -4318,7 +4303,6 @@ body.sidebar-collapsed .status-bar { left: 64px; }
|
|||||||
#dragonView .dragon-operation-table .dragon-col-direction { width: 72px; }
|
#dragonView .dragon-operation-table .dragon-col-direction { width: 72px; }
|
||||||
#dragonView .dragon-operation-table .dragon-col-number { width: 82px; }
|
#dragonView .dragon-operation-table .dragon-col-number { width: 82px; }
|
||||||
#dragonView .dragon-operation-table .dragon-col-seat { width: 190px; }
|
#dragonView .dragon-operation-table .dragon-col-seat { width: 190px; }
|
||||||
#dragonView .dragon-operation-table .dragon-col-reason { width: auto; }
|
|
||||||
#dragonView .dragon-operation-table :is(th, td).row-number { padding-inline: 8px; text-align: center; }
|
#dragonView .dragon-operation-table :is(th, td).row-number { padding-inline: 8px; text-align: center; }
|
||||||
#dragonView .dragon-operation-table td.stock-code { font-variant-numeric: tabular-nums; }
|
#dragonView .dragon-operation-table td.stock-code { font-variant-numeric: tabular-nums; }
|
||||||
#dragonView .dragon-operation-table thead th { position: sticky; top: 0; z-index: 2; background: #fafbfc; }
|
#dragonView .dragon-operation-table thead th { position: sticky; top: 0; z-index: 2; background: #fafbfc; }
|
||||||
|
|||||||
@@ -127,7 +127,6 @@ body.sidebar-collapsed .app-main { margin-left: 0; }
|
|||||||
background: transparent;
|
background: transparent;
|
||||||
}
|
}
|
||||||
|
|
||||||
.overview-strip .sentiment-block { padding-left: 0; }
|
|
||||||
.overview-strip .sentiment-gauge { width: 26px; height: 26px; flex: 0 0 26px; border-width: 2px; font-size: 10px; }
|
.overview-strip .sentiment-gauge { width: 26px; height: 26px; flex: 0 0 26px; border-width: 2px; font-size: 10px; }
|
||||||
.overview-strip .sentiment-text { font-size: 12px; white-space: nowrap; }
|
.overview-strip .sentiment-text { font-size: 12px; white-space: nowrap; }
|
||||||
.overview-strip .metric-label { color: var(--text-tertiary); font-size: 10.5px; white-space: nowrap; }
|
.overview-strip .metric-label { color: var(--text-tertiary); font-size: 10.5px; white-space: nowrap; }
|
||||||
@@ -160,8 +159,6 @@ body.sidebar-collapsed .app-main { margin-left: 0; }
|
|||||||
.overview-strip[data-overview-expanded="true"] .metric { min-height: 76px; align-items: flex-start; justify-content: center; flex-direction: column; gap: 4px; }
|
.overview-strip[data-overview-expanded="true"] .metric { min-height: 76px; align-items: flex-start; justify-content: center; flex-direction: column; gap: 4px; }
|
||||||
.overview-strip[data-overview-expanded="true"] .sentiment-block { flex-direction: row; justify-content: flex-start; align-items: center; }
|
.overview-strip[data-overview-expanded="true"] .sentiment-block { flex-direction: row; justify-content: flex-start; align-items: center; }
|
||||||
.overview-strip[data-overview-expanded="true"] .sentiment-gauge { width: 48px; height: 48px; flex-basis: 48px; font-size: 13px; }
|
.overview-strip[data-overview-expanded="true"] .sentiment-gauge { width: 48px; height: 48px; flex-basis: 48px; font-size: 13px; }
|
||||||
.overview-strip[data-overview-expanded="true"] .metric-value { font-size: 18px; }
|
|
||||||
|
|
||||||
/* Page frame and shared information architecture. */
|
/* Page frame and shared information architecture. */
|
||||||
.workspace-view,
|
.workspace-view,
|
||||||
body[data-active-view="screenerView"] .workspace-view,
|
body[data-active-view="screenerView"] .workspace-view,
|
||||||
|
|||||||
@@ -666,10 +666,6 @@ time {
|
|||||||
box-shadow: var(--shadow-soft);
|
box-shadow: var(--shadow-soft);
|
||||||
}
|
}
|
||||||
|
|
||||||
.workspace-view.active-view {
|
|
||||||
display: block;
|
|
||||||
}
|
|
||||||
|
|
||||||
.workspace-view.active-view.view-entering {
|
.workspace-view.active-view.view-entering {
|
||||||
animation: view-enter var(--motion-medium) var(--ease-out) both;
|
animation: view-enter var(--motion-medium) var(--ease-out) both;
|
||||||
}
|
}
|
||||||
@@ -4745,10 +4741,6 @@ textarea {
|
|||||||
outline-color: rgba(29, 101, 193, 0.48);
|
outline-color: rgba(29, 101, 193, 0.48);
|
||||||
}
|
}
|
||||||
|
|
||||||
body.sidebar-collapsed {
|
|
||||||
grid-template-columns: 64px minmax(0, 1fr);
|
|
||||||
}
|
|
||||||
|
|
||||||
body.sidebar-collapsed .module-nav {
|
body.sidebar-collapsed .module-nav {
|
||||||
width: 64px;
|
width: 64px;
|
||||||
padding-right: 7px;
|
padding-right: 7px;
|
||||||
@@ -4783,10 +4775,6 @@ body.sidebar-collapsed .sidebar-collapse-button .lucide {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@media (min-width: 721px) and (max-width: 1279px) {
|
@media (min-width: 721px) and (max-width: 1279px) {
|
||||||
.market-tape {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.app-header {
|
.app-header {
|
||||||
grid-template-columns: 190px minmax(0, 1fr) auto;
|
grid-template-columns: 190px minmax(0, 1fr) auto;
|
||||||
}
|
}
|
||||||
@@ -4988,21 +4976,6 @@ body.sidebar-collapsed .sidebar-collapse-button .lucide {
|
|||||||
box-shadow: 0 -4px 18px rgba(24, 34, 45, 0.07);
|
box-shadow: 0 -4px 18px rgba(24, 34, 45, 0.07);
|
||||||
}
|
}
|
||||||
|
|
||||||
.module-nav .nav-brand,
|
|
||||||
.module-nav .nav-group-label,
|
|
||||||
.module-nav .market-sub-tab,
|
|
||||||
.module-nav .sidebar-collapse-button {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.module-nav .nav-group,
|
|
||||||
body.sidebar-collapsed .module-nav .nav-group {
|
|
||||||
display: contents;
|
|
||||||
margin: 0;
|
|
||||||
padding: 0;
|
|
||||||
border: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.module-nav .module-tab,
|
.module-nav .module-tab,
|
||||||
body.sidebar-collapsed .module-nav .module-tab {
|
body.sidebar-collapsed .module-nav .module-tab {
|
||||||
min-height: 54px;
|
min-height: 54px;
|
||||||
@@ -5017,11 +4990,6 @@ body.sidebar-collapsed .sidebar-collapse-button .lucide {
|
|||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
.module-nav .module-tab.mobile-primary-tab,
|
|
||||||
body.sidebar-collapsed .module-nav .module-tab.mobile-primary-tab {
|
|
||||||
display: flex;
|
|
||||||
}
|
|
||||||
|
|
||||||
.module-nav .module-tab span,
|
.module-nav .module-tab span,
|
||||||
body.sidebar-collapsed .module-nav .module-tab span {
|
body.sidebar-collapsed .module-nav .module-tab span {
|
||||||
display: block;
|
display: block;
|
||||||
@@ -5369,8 +5337,6 @@ body.sidebar-collapsed .sidebar-collapse-button .lucide {
|
|||||||
border-right: 1px solid var(--border);
|
border-right: 1px solid var(--border);
|
||||||
transition: background-color var(--motion-medium) ease, opacity var(--motion-medium) ease;
|
transition: background-color var(--motion-medium) ease, opacity var(--motion-medium) ease;
|
||||||
}
|
}
|
||||||
.rotation-day:last-child { border-right: 0; }
|
|
||||||
|
|
||||||
.rotation-day header { display: grid; gap: 2px; margin-bottom: 8px; }
|
.rotation-day header { display: grid; gap: 2px; margin-bottom: 8px; }
|
||||||
.rotation-day header time { font-size: 12px; font-weight: 700; }
|
.rotation-day header time { font-size: 12px; font-weight: 700; }
|
||||||
.rotation-day header span { color: var(--text-secondary); font-size: 10px; }
|
.rotation-day header span { color: var(--text-secondary); font-size: 10px; }
|
||||||
@@ -7130,11 +7096,6 @@ body.sidebar-collapsed .sidebar-collapse-button .lucide {
|
|||||||
box-shadow: 1px 0 0 var(--border);
|
box-shadow: 1px 0 0 var(--border);
|
||||||
}
|
}
|
||||||
|
|
||||||
#screenerView .probability-value strong,
|
|
||||||
#screenerView .probability-value small {
|
|
||||||
display: block;
|
|
||||||
}
|
|
||||||
|
|
||||||
#screenerView .probability-value small {
|
#screenerView .probability-value small {
|
||||||
margin-top: 3px;
|
margin-top: 3px;
|
||||||
color: var(--text-secondary);
|
color: var(--text-secondary);
|
||||||
@@ -13032,10 +12993,6 @@ button.account-role-badge:focus-visible { outline: 2px solid var(--blue); outlin
|
|||||||
}
|
}
|
||||||
|
|
||||||
@media (max-width: 720px) {
|
@media (max-width: 720px) {
|
||||||
body.mentor-directory-open {
|
|
||||||
overflow: hidden;
|
|
||||||
}
|
|
||||||
|
|
||||||
.mentor-layout {
|
.mentor-layout {
|
||||||
height: auto;
|
height: auto;
|
||||||
min-height: 580px;
|
min-height: 580px;
|
||||||
@@ -14889,13 +14846,6 @@ dialog::backdrop {
|
|||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
body,
|
|
||||||
body.sidebar-collapsed {
|
|
||||||
display: block;
|
|
||||||
min-height: 100dvh;
|
|
||||||
padding-bottom: calc(68px + env(safe-area-inset-bottom));
|
|
||||||
}
|
|
||||||
|
|
||||||
.app-header {
|
.app-header {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 108px;
|
height: 108px;
|
||||||
@@ -14908,10 +14858,6 @@ dialog::backdrop {
|
|||||||
background: rgba(255, 255, 255, .98);
|
background: rgba(255, 255, 255, .98);
|
||||||
}
|
}
|
||||||
|
|
||||||
.brand-block {
|
|
||||||
height: 42px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.brand-block .brand-mark,
|
.brand-block .brand-mark,
|
||||||
.brand-block .brand-logo {
|
.brand-block .brand-logo {
|
||||||
width: 34px;
|
width: 34px;
|
||||||
@@ -14927,20 +14873,6 @@ dialog::backdrop {
|
|||||||
font-size: 16px;
|
font-size: 16px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.header-actions {
|
|
||||||
position: absolute;
|
|
||||||
inset: 56px 10px auto;
|
|
||||||
display: flex;
|
|
||||||
justify-content: space-between;
|
|
||||||
gap: 6px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.header-date-group {
|
|
||||||
height: 42px;
|
|
||||||
min-width: 0;
|
|
||||||
flex: 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
.header-date-group .date-input {
|
.header-date-group .date-input {
|
||||||
width: 112px;
|
width: 112px;
|
||||||
flex: 1;
|
flex: 1;
|
||||||
@@ -14952,12 +14884,6 @@ dialog::backdrop {
|
|||||||
min-width: 30px;
|
min-width: 30px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.header-actions > .icon-button {
|
|
||||||
width: 40px;
|
|
||||||
min-width: 40px;
|
|
||||||
min-height: 42px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.header-menu-button {
|
.header-menu-button {
|
||||||
display: grid;
|
display: grid;
|
||||||
}
|
}
|
||||||
@@ -15071,9 +14997,7 @@ dialog::backdrop {
|
|||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.overview-strip .metric:nth-of-type(1) { grid-column: 2; grid-row: 1; }
|
|
||||||
.overview-strip .metric:nth-of-type(2) { grid-column: 3; grid-row: 1; border-right: 0; }
|
.overview-strip .metric:nth-of-type(2) { grid-column: 3; grid-row: 1; border-right: 0; }
|
||||||
.overview-strip .metric:nth-of-type(3) { grid-column: 2; grid-row: 2; }
|
|
||||||
.overview-strip .metric:nth-of-type(4) { grid-column: 3; grid-row: 2; border-right: 0; }
|
.overview-strip .metric:nth-of-type(4) { grid-column: 3; grid-row: 2; border-right: 0; }
|
||||||
.overview-strip .metric:nth-of-type(5) { grid-column: 1 / 2; grid-row: 3; border-bottom: 0; }
|
.overview-strip .metric:nth-of-type(5) { grid-column: 1 / 2; grid-row: 3; border-bottom: 0; }
|
||||||
.overview-strip .metric:nth-of-type(6) { grid-column: 2 / 4; grid-row: 3; border-right: 0; border-bottom: 0; }
|
.overview-strip .metric:nth-of-type(6) { grid-column: 2 / 4; grid-row: 3; border-right: 0; border-bottom: 0; }
|
||||||
@@ -15330,10 +15254,6 @@ dialog::backdrop {
|
|||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
.curated-strategy-list {
|
|
||||||
grid-template-columns: 1fr;
|
|
||||||
}
|
|
||||||
|
|
||||||
.quant-universe-grid {
|
.quant-universe-grid {
|
||||||
grid-template-columns: 1fr 1fr;
|
grid-template-columns: 1fr 1fr;
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-1
@@ -3,7 +3,8 @@ from __future__ import annotations
|
|||||||
import argparse
|
import argparse
|
||||||
from datetime import date
|
from datetime import date
|
||||||
|
|
||||||
from server import SERVICE, normalize_date
|
from backend.application import SERVICE
|
||||||
|
from backend.bootstrap.config import normalize_date
|
||||||
|
|
||||||
|
|
||||||
def main() -> None:
|
def main() -> None:
|
||||||
|
|||||||
@@ -1803,6 +1803,38 @@ test("heart breathing prepares once then contracts on each exhale", async ({ pag
|
|||||||
await expect(page.locator(".heart-breath-ripple span").first()).toHaveCSS("transition-duration", "4s");
|
await expect(page.locator(".heart-breath-ripple span").first()).toHaveCSS("transition-duration", "4s");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test("stylesheet layers do not repeat identical rules in the same cascade context", async ({ page }) => {
|
||||||
|
await mockApplication(page, session("admin", true));
|
||||||
|
await page.goto("/index.html");
|
||||||
|
|
||||||
|
const duplicates = await page.evaluate(() => {
|
||||||
|
const occurrences = new Map();
|
||||||
|
const visitRules = (rules, href, context = []) => {
|
||||||
|
for (const rule of Array.from(rules || [])) {
|
||||||
|
if (typeof rule.selectorText === "string" && rule.style) {
|
||||||
|
const key = `${context.join("\u0001")}\u0000${rule.selectorText}\u0000${rule.style.cssText}`;
|
||||||
|
const rows = occurrences.get(key) || [];
|
||||||
|
rows.push(href);
|
||||||
|
occurrences.set(key, rows);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (!rule.cssRules) continue;
|
||||||
|
const condition = rule.conditionText || rule.media?.mediaText || rule.name || "";
|
||||||
|
visitRules(rule.cssRules, href, [...context, `${rule.type}:${condition}`]);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
for (const sheet of Array.from(document.styleSheets)) {
|
||||||
|
const href = sheet.href ? new URL(sheet.href).pathname : "inline";
|
||||||
|
visitRules(sheet.cssRules, href);
|
||||||
|
}
|
||||||
|
return Array.from(occurrences.entries())
|
||||||
|
.filter(([, paths]) => new Set(paths).size > 1)
|
||||||
|
.map(([rule, paths]) => ({ rule, paths }));
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(duplicates).toEqual([]);
|
||||||
|
});
|
||||||
|
|
||||||
test("mobile shell stays within the viewport", async ({ page }) => {
|
test("mobile shell stays within the viewport", async ({ page }) => {
|
||||||
await page.setViewportSize({ width: 375, height: 812 });
|
await page.setViewportSize({ width: 375, height: 812 });
|
||||||
await mockApplication(page, session("user", true));
|
await mockApplication(page, session("user", true));
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
|
import ast
|
||||||
import hashlib
|
import hashlib
|
||||||
import re
|
import re
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
@@ -28,11 +29,168 @@ RETIRED_FRONTEND_SOURCE_RANGES = (
|
|||||||
)
|
)
|
||||||
AUDITED_FRONTEND_SOURCE_LINE_COUNT = 9283
|
AUDITED_FRONTEND_SOURCE_LINE_COUNT = 9283
|
||||||
|
|
||||||
|
# CR-12 and CR-13 remove only declarations repeated by a later stylesheet
|
||||||
|
# layer under the same cascade context. Entries are either an exact retired
|
||||||
|
# fragment or an exact (source, replacement) pair when surrounding context is
|
||||||
|
# needed to identify one nested occurrence. Every other byte remains part of
|
||||||
|
# the accepted CSS baseline.
|
||||||
|
AUDITED_CSS_RETIREMENTS = {
|
||||||
|
"styles.css": (
|
||||||
|
".workspace-view.active-view {\n display: block;\n}\n\n",
|
||||||
|
"body.sidebar-collapsed {\n grid-template-columns: 64px minmax(0, 1fr);\n}\n\n",
|
||||||
|
".rotation-day:last-child { border-right: 0; }\n\n",
|
||||||
|
(
|
||||||
|
"#screenerView .probability-value strong,\n"
|
||||||
|
"#screenerView .probability-value small {\n"
|
||||||
|
" display: block;\n"
|
||||||
|
"}\n\n"
|
||||||
|
),
|
||||||
|
(
|
||||||
|
(
|
||||||
|
"@media (min-width: 721px) and (max-width: 1279px) {\n"
|
||||||
|
" .market-tape {\n"
|
||||||
|
" display: none;\n"
|
||||||
|
" }\n\n"
|
||||||
|
" .app-header {"
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"@media (min-width: 721px) and (max-width: 1279px) {\n"
|
||||||
|
" .app-header {"
|
||||||
|
),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
" .module-nav .nav-brand,\n"
|
||||||
|
" .module-nav .nav-group-label,\n"
|
||||||
|
" .module-nav .market-sub-tab,\n"
|
||||||
|
" .module-nav .sidebar-collapse-button {\n"
|
||||||
|
" display: none;\n"
|
||||||
|
" }\n\n"
|
||||||
|
),
|
||||||
|
(
|
||||||
|
" .module-nav .nav-group,\n"
|
||||||
|
" body.sidebar-collapsed .module-nav .nav-group {\n"
|
||||||
|
" display: contents;\n"
|
||||||
|
" margin: 0;\n"
|
||||||
|
" padding: 0;\n"
|
||||||
|
" border: 0;\n"
|
||||||
|
" }\n\n"
|
||||||
|
),
|
||||||
|
(
|
||||||
|
" .module-nav .module-tab.mobile-primary-tab,\n"
|
||||||
|
" body.sidebar-collapsed .module-nav .module-tab.mobile-primary-tab {\n"
|
||||||
|
" display: flex;\n"
|
||||||
|
" }\n\n"
|
||||||
|
),
|
||||||
|
" body.mentor-directory-open {\n overflow: hidden;\n }\n\n",
|
||||||
|
(
|
||||||
|
" body,\n"
|
||||||
|
" body.sidebar-collapsed {\n"
|
||||||
|
" display: block;\n"
|
||||||
|
" min-height: 100dvh;\n"
|
||||||
|
" padding-bottom: calc(68px + env(safe-area-inset-bottom));\n"
|
||||||
|
" }\n\n"
|
||||||
|
),
|
||||||
|
" .brand-block {\n height: 42px;\n }\n\n",
|
||||||
|
(
|
||||||
|
" .header-actions {\n"
|
||||||
|
" position: absolute;\n"
|
||||||
|
" inset: 56px 10px auto;\n"
|
||||||
|
" display: flex;\n"
|
||||||
|
" justify-content: space-between;\n"
|
||||||
|
" gap: 6px;\n"
|
||||||
|
" }\n\n"
|
||||||
|
),
|
||||||
|
(
|
||||||
|
" .header-date-group {\n"
|
||||||
|
" height: 42px;\n"
|
||||||
|
" min-width: 0;\n"
|
||||||
|
" flex: 1;\n"
|
||||||
|
" }\n\n"
|
||||||
|
),
|
||||||
|
(
|
||||||
|
" .header-actions > .icon-button {\n"
|
||||||
|
" width: 40px;\n"
|
||||||
|
" min-width: 40px;\n"
|
||||||
|
" min-height: 42px;\n"
|
||||||
|
" }\n\n"
|
||||||
|
),
|
||||||
|
" .overview-strip .metric:nth-of-type(1) { grid-column: 2; grid-row: 1; }\n",
|
||||||
|
" .overview-strip .metric:nth-of-type(3) { grid-column: 2; grid-row: 2; }\n",
|
||||||
|
" .curated-strategy-list {\n grid-template-columns: 1fr;\n }\n\n",
|
||||||
|
),
|
||||||
|
"renovation.css": (
|
||||||
|
".overview-strip .sentiment-block { padding-left: 0; }\n",
|
||||||
|
(
|
||||||
|
'.overview-strip[data-overview-expanded="true"] .metric-value '
|
||||||
|
"{ font-size: 18px; }\n\n"
|
||||||
|
),
|
||||||
|
),
|
||||||
|
"redesign-v2.css": (
|
||||||
|
"#dragonView .dragon-operation-table .dragon-col-reason { width: auto; }\n",
|
||||||
|
(
|
||||||
|
" .market-tape { display: none; }\n"
|
||||||
|
" .header-actions { width: 100%; }\n"
|
||||||
|
" .header-command-group { position: absolute; }\n"
|
||||||
|
),
|
||||||
|
(
|
||||||
|
" .sidebar-brand,\n"
|
||||||
|
" .module-nav .nav-group-label,\n"
|
||||||
|
" .sidebar-collapse-button,\n"
|
||||||
|
" .module-nav .market-sub-tab { display: none; }\n"
|
||||||
|
" .module-nav .nav-group,\n"
|
||||||
|
" body.sidebar-collapsed .module-nav .nav-group { display: contents; }\n"
|
||||||
|
" .module-nav .module-tab,\n"
|
||||||
|
" body.sidebar-collapsed .module-nav .module-tab { display: none; }\n"
|
||||||
|
),
|
||||||
|
" .module-nav .module-tab.mobile-primary-tab span { display: inline; }\n",
|
||||||
|
(
|
||||||
|
" .overview-strip .metric:nth-of-type(n + 4),\n"
|
||||||
|
" .overview-strip .metric-wide { display: none; }\n"
|
||||||
|
" .overview-toggle { display: none; }\n"
|
||||||
|
),
|
||||||
|
),
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
def sha256(path: Path) -> str:
|
def sha256(path: Path) -> str:
|
||||||
return hashlib.sha256(path.read_bytes()).hexdigest()
|
return hashlib.sha256(path.read_bytes()).hexdigest()
|
||||||
|
|
||||||
|
|
||||||
|
def function_contract(path: Path, name: str) -> tuple[str, str]:
|
||||||
|
tree = ast.parse(path.read_text(encoding="utf-8"), filename=str(path))
|
||||||
|
function = next(
|
||||||
|
node for node in tree.body if isinstance(node, ast.FunctionDef) and node.name == name
|
||||||
|
)
|
||||||
|
body = ast.Module(body=function.body, type_ignores=[])
|
||||||
|
return (
|
||||||
|
ast.dump(function.args, include_attributes=False),
|
||||||
|
ast.dump(body, include_attributes=False),
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def module_contract(
|
||||||
|
path: Path,
|
||||||
|
*,
|
||||||
|
excluded_definitions: set[str] | None = None,
|
||||||
|
excluded_import_modules: set[str] | None = None,
|
||||||
|
exclude_imports: bool = False,
|
||||||
|
) -> str:
|
||||||
|
excluded_definitions = excluded_definitions or set()
|
||||||
|
excluded_import_modules = excluded_import_modules or set()
|
||||||
|
tree = ast.parse(path.read_text(encoding="utf-8"), filename=str(path))
|
||||||
|
tree.body = [
|
||||||
|
node
|
||||||
|
for node in tree.body
|
||||||
|
if not (exclude_imports and isinstance(node, (ast.Import, ast.ImportFrom)))
|
||||||
|
and not (
|
||||||
|
isinstance(node, ast.ImportFrom)
|
||||||
|
and node.module in excluded_import_modules
|
||||||
|
)
|
||||||
|
and getattr(node, "name", None) not in excluded_definitions
|
||||||
|
]
|
||||||
|
return ast.dump(tree, include_attributes=False)
|
||||||
|
|
||||||
|
|
||||||
def reassembled_frontend_runtime() -> str:
|
def reassembled_frontend_runtime() -> str:
|
||||||
chunks: dict[tuple[int, int], str] = {}
|
chunks: dict[tuple[int, int], str] = {}
|
||||||
for path in FRONTEND_ROOT.rglob("*.js"):
|
for path in FRONTEND_ROOT.rglob("*.js"):
|
||||||
@@ -87,6 +245,18 @@ def assert_moved_asset_matches(
|
|||||||
frontend_relative: str | None = None,
|
frontend_relative: str | None = None,
|
||||||
) -> None:
|
) -> None:
|
||||||
target_relative = frontend_relative or original_relative
|
target_relative = frontend_relative or original_relative
|
||||||
|
if original_relative in AUDITED_CSS_RETIREMENTS:
|
||||||
|
original = (ORIGINAL_STATIC / original_relative).read_text(encoding="utf-8")
|
||||||
|
for retired in AUDITED_CSS_RETIREMENTS[original_relative]:
|
||||||
|
source, replacement = retired if isinstance(retired, tuple) else (retired, "")
|
||||||
|
testcase.assertEqual(original.count(source), 1, source)
|
||||||
|
original = original.replace(source, replacement, 1)
|
||||||
|
testcase.assertEqual(
|
||||||
|
(FRONTEND_ROOT / target_relative).read_text(encoding="utf-8"),
|
||||||
|
original,
|
||||||
|
original_relative,
|
||||||
|
)
|
||||||
|
return
|
||||||
testcase.assertEqual(
|
testcase.assertEqual(
|
||||||
sha256(FRONTEND_ROOT / target_relative),
|
sha256(FRONTEND_ROOT / target_relative),
|
||||||
sha256(ORIGINAL_STATIC / original_relative),
|
sha256(ORIGINAL_STATIC / original_relative),
|
||||||
|
|||||||
@@ -0,0 +1,65 @@
|
|||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
import ast
|
||||||
|
import sys
|
||||||
|
import unittest
|
||||||
|
from pathlib import Path
|
||||||
|
from unittest.mock import patch
|
||||||
|
|
||||||
|
from backend.bootstrap import runtime
|
||||||
|
|
||||||
|
|
||||||
|
class BackgroundLifecycleTests(unittest.TestCase):
|
||||||
|
def test_service_construction_does_not_start_the_scheduler(self) -> None:
|
||||||
|
source = (Path(__file__).parents[1] / "backend" / "application.py").read_text(
|
||||||
|
encoding="utf-8"
|
||||||
|
)
|
||||||
|
tree = ast.parse(source)
|
||||||
|
service_class = next(
|
||||||
|
node for node in tree.body
|
||||||
|
if isinstance(node, ast.ClassDef) and node.name == "DashboardService"
|
||||||
|
)
|
||||||
|
constructor = next(
|
||||||
|
node for node in service_class.body
|
||||||
|
if isinstance(node, ast.FunctionDef) and node.name == "__init__"
|
||||||
|
)
|
||||||
|
called_methods = {
|
||||||
|
node.func.attr for node in ast.walk(constructor)
|
||||||
|
if isinstance(node, ast.Call) and isinstance(node.func, ast.Attribute)
|
||||||
|
}
|
||||||
|
self.assertNotIn("start_scheduler", called_methods)
|
||||||
|
|
||||||
|
def test_runtime_starts_jobs_after_bind_and_stops_before_close(self) -> None:
|
||||||
|
events: list[str] = []
|
||||||
|
|
||||||
|
class Service:
|
||||||
|
def start_background_jobs(self) -> None:
|
||||||
|
events.append("start-jobs")
|
||||||
|
|
||||||
|
def stop_background_jobs(self) -> None:
|
||||||
|
events.append("stop-jobs")
|
||||||
|
|
||||||
|
class Server:
|
||||||
|
def __init__(self, address: tuple[str, int], handler: object) -> None:
|
||||||
|
events.append("bind")
|
||||||
|
|
||||||
|
def serve_forever(self) -> None:
|
||||||
|
events.append("serve")
|
||||||
|
raise KeyboardInterrupt
|
||||||
|
|
||||||
|
def server_close(self) -> None:
|
||||||
|
events.append("close")
|
||||||
|
|
||||||
|
with (
|
||||||
|
patch.object(runtime, "ThreadingHTTPServer", Server),
|
||||||
|
patch.object(sys, "argv", ["server.py", "--port", "8797"]),
|
||||||
|
):
|
||||||
|
runtime.main(object, Service())
|
||||||
|
|
||||||
|
self.assertEqual(
|
||||||
|
events, ["bind", "start-jobs", "serve", "stop-jobs", "close"]
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
unittest.main()
|
||||||
@@ -1,7 +1,9 @@
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
|
import ast
|
||||||
import unittest
|
import unittest
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
from backend.data import (
|
from backend.data import (
|
||||||
DataPolicyError,
|
DataPolicyError,
|
||||||
@@ -45,8 +47,6 @@ class DataGatewayTests(unittest.TestCase):
|
|||||||
self.assertIs(gateway.chart_data.ifind, gateway.ifind)
|
self.assertIs(gateway.chart_data.ifind, gateway.ifind)
|
||||||
|
|
||||||
def test_server_has_no_direct_runtime_tushare_construction(self) -> None:
|
def test_server_has_no_direct_runtime_tushare_construction(self) -> None:
|
||||||
from pathlib import Path
|
|
||||||
|
|
||||||
source = (
|
source = (
|
||||||
Path(__file__).resolve().parents[1]
|
Path(__file__).resolve().parents[1]
|
||||||
/ "backend"
|
/ "backend"
|
||||||
@@ -57,6 +57,33 @@ class DataGatewayTests(unittest.TestCase):
|
|||||||
self.assertEqual(source.count("TushareClient(self.token)"), 1)
|
self.assertEqual(source.count("TushareClient(self.token)"), 1)
|
||||||
self.assertIn("return gateway.tushare()", source)
|
self.assertIn("return gateway.tushare()", source)
|
||||||
|
|
||||||
|
def test_provider_construction_has_unique_declared_owners(self) -> None:
|
||||||
|
root = Path(__file__).resolve().parents[1]
|
||||||
|
owners = {
|
||||||
|
"EastmoneyChartClient": {"backend/data/gateway.py"},
|
||||||
|
"IfindHttpClient": {"backend/data/gateway.py"},
|
||||||
|
"IfindProvider": {"backend/data/gateway.py"},
|
||||||
|
"MarketChartClient": {"backend/data/gateway.py"},
|
||||||
|
"TushareClient": {"backend/features/market/service.py"},
|
||||||
|
"TushareProvider": {"backend/data/gateway.py"},
|
||||||
|
"WebRealtimeAggregator": {"backend/data/gateway.py"},
|
||||||
|
}
|
||||||
|
found = {name: set() for name in owners}
|
||||||
|
for path in (root / "backend").rglob("*.py"):
|
||||||
|
relative = path.relative_to(root).as_posix()
|
||||||
|
tree = ast.parse(path.read_text(encoding="utf-8"), filename=str(path))
|
||||||
|
for node in ast.walk(tree):
|
||||||
|
if not isinstance(node, ast.Call):
|
||||||
|
continue
|
||||||
|
name = getattr(node.func, "id", None) or getattr(node.func, "attr", None)
|
||||||
|
if name in found:
|
||||||
|
found[name].add(relative)
|
||||||
|
self.assertEqual(found, owners)
|
||||||
|
provider_source = (root / "backend/data/providers/tushare.py").read_text(
|
||||||
|
encoding="utf-8"
|
||||||
|
)
|
||||||
|
self.assertIn("client_factory: Callable[[str], TushareClient] = TushareClient", provider_source)
|
||||||
|
|
||||||
def test_quality_gate_accepts_matching_daily_evidence(self) -> None:
|
def test_quality_gate_accepts_matching_daily_evidence(self) -> None:
|
||||||
timezone = market_timezone()
|
timezone = market_timezone()
|
||||||
now = datetime(2026, 7, 29, 16, 0, tzinfo=timezone)
|
now = datetime(2026, 7, 29, 16, 0, tzinfo=timezone)
|
||||||
|
|||||||
@@ -20,12 +20,6 @@ class FeatureBoundaryTests(unittest.TestCase):
|
|||||||
}
|
}
|
||||||
violations = []
|
violations = []
|
||||||
for path in FEATURES.rglob("*.py"):
|
for path in FEATURES.rglob("*.py"):
|
||||||
# The screener engine is an exact-preservation move of the legacy
|
|
||||||
# calculation module. Its provider dependency is covered by the
|
|
||||||
# slice equivalence tests and will be addressed only after the
|
|
||||||
# behavior-preserving migration is complete.
|
|
||||||
if path.relative_to(FEATURES).as_posix() == "screener/engine.py":
|
|
||||||
continue
|
|
||||||
tree = ast.parse(path.read_text(encoding="utf-8"), filename=str(path))
|
tree = ast.parse(path.read_text(encoding="utf-8"), filename=str(path))
|
||||||
for node in ast.walk(tree):
|
for node in ast.walk(tree):
|
||||||
names = []
|
names = []
|
||||||
@@ -38,6 +32,53 @@ class FeatureBoundaryTests(unittest.TestCase):
|
|||||||
violations.append(f"{path.relative_to(ROOT)} -> {name}")
|
violations.append(f"{path.relative_to(ROOT)} -> {name}")
|
||||||
self.assertEqual(violations, [])
|
self.assertEqual(violations, [])
|
||||||
|
|
||||||
|
def test_backend_uses_root_compatibility_modules_only_at_declared_boundaries(self) -> None:
|
||||||
|
compatibility_modules = {
|
||||||
|
"advanced_strategies",
|
||||||
|
"alert_service",
|
||||||
|
"api_access",
|
||||||
|
"app_config",
|
||||||
|
"assistant_agent",
|
||||||
|
"chart_data_provider",
|
||||||
|
"heaven_agent",
|
||||||
|
"heaven_engine",
|
||||||
|
"ifind_client",
|
||||||
|
"llm_strategy",
|
||||||
|
"llm_stream",
|
||||||
|
"market_insights",
|
||||||
|
"mentor_agent",
|
||||||
|
"realtime_aggregator",
|
||||||
|
"screener",
|
||||||
|
"security",
|
||||||
|
"sentiment_engine",
|
||||||
|
"server",
|
||||||
|
"strategy_tracking",
|
||||||
|
"trade_journal",
|
||||||
|
"tushare_client",
|
||||||
|
}
|
||||||
|
allowed = {
|
||||||
|
"backend/application.py": {"api_access"},
|
||||||
|
"backend/features/screener/repository.py": {"sentiment_engine"},
|
||||||
|
}
|
||||||
|
violations = []
|
||||||
|
for path in (ROOT / "backend").rglob("*.py"):
|
||||||
|
relative = path.relative_to(ROOT).as_posix()
|
||||||
|
tree = ast.parse(path.read_text(encoding="utf-8"), filename=str(path))
|
||||||
|
for node in ast.walk(tree):
|
||||||
|
names = []
|
||||||
|
if isinstance(node, ast.Import):
|
||||||
|
names = [alias.name for alias in node.names]
|
||||||
|
elif isinstance(node, ast.ImportFrom) and node.module:
|
||||||
|
names = [node.module]
|
||||||
|
for name in names:
|
||||||
|
root_name = name.split(".")[0]
|
||||||
|
if (
|
||||||
|
root_name in compatibility_modules
|
||||||
|
and root_name not in allowed.get(relative, set())
|
||||||
|
):
|
||||||
|
violations.append(f"{relative} -> {name}")
|
||||||
|
self.assertEqual(violations, [])
|
||||||
|
|
||||||
def test_legacy_service_modules_are_compatibility_exports_only(self) -> None:
|
def test_legacy_service_modules_are_compatibility_exports_only(self) -> None:
|
||||||
for filename in ("alert_service.py", "trade_journal.py", "strategy_tracking.py"):
|
for filename in ("alert_service.py", "trade_journal.py", "strategy_tracking.py"):
|
||||||
tree = ast.parse((ROOT / filename).read_text(encoding="utf-8"))
|
tree = ast.parse((ROOT / filename).read_text(encoding="utf-8"))
|
||||||
|
|||||||
@@ -124,6 +124,50 @@ class HeavenReadingTests(unittest.TestCase):
|
|||||||
len(self.database.list_heaven_readings(self.owner["id"], "fortune")), 1
|
len(self.database.list_heaven_readings(self.owner["id"], "fortune")), 1
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def test_trend_interpretation_saves_successful_agent_result(self):
|
||||||
|
service = DashboardService.__new__(DashboardService)
|
||||||
|
service.database = self.database
|
||||||
|
service._request_context = threading.local()
|
||||||
|
service._request_context.user_id = self.owner["id"]
|
||||||
|
setup = {
|
||||||
|
"trade_date": "20260723",
|
||||||
|
"chart": {
|
||||||
|
"available": True,
|
||||||
|
"sector": "银行",
|
||||||
|
"stock": {"code": "000001", "name": "平安银行"},
|
||||||
|
"hexagram": {
|
||||||
|
"name": "中孚",
|
||||||
|
"lines": [],
|
||||||
|
"transformed": {"name": "小畜"},
|
||||||
|
},
|
||||||
|
"movement": {},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
with patch.object(service, "heaven_setup", return_value=setup), patch.object(
|
||||||
|
service,
|
||||||
|
"_call_heaven_agent",
|
||||||
|
return_value=(
|
||||||
|
{"answer": "完整的解势结果", "model": "test", "latency_ms": 1},
|
||||||
|
"primary",
|
||||||
|
),
|
||||||
|
):
|
||||||
|
result = service.heaven_interpret(
|
||||||
|
{
|
||||||
|
"mode": "trend",
|
||||||
|
"trade_date": "2026-07-23",
|
||||||
|
"stock_code": "000001",
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
self.assertFalse(result["reused"])
|
||||||
|
self.assertEqual(result["answer"], "完整的解势结果")
|
||||||
|
self.assertEqual(result["reading"]["subject"], "000001 平安银行")
|
||||||
|
self.assertEqual(
|
||||||
|
self.database.list_heaven_readings(self.owner["id"], "trend")[0]["answer"],
|
||||||
|
"完整的解势结果",
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
|||||||
@@ -0,0 +1,85 @@
|
|||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
import io
|
||||||
|
import json
|
||||||
|
import unittest
|
||||||
|
|
||||||
|
from backend.http.handler import HttpTransportMixin
|
||||||
|
|
||||||
|
|
||||||
|
class StreamError(RuntimeError):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class TransportStub(HttpTransportMixin):
|
||||||
|
def __init__(self) -> None:
|
||||||
|
self.statuses: list[int] = []
|
||||||
|
self.response_headers: list[tuple[str, str]] = []
|
||||||
|
self.wfile = io.BytesIO()
|
||||||
|
self.close_connection = False
|
||||||
|
|
||||||
|
def send_response(self, status: int) -> None:
|
||||||
|
self.statuses.append(int(status))
|
||||||
|
|
||||||
|
def send_header(self, name: str, value: str) -> None:
|
||||||
|
self.response_headers.append((name, value))
|
||||||
|
|
||||||
|
def end_headers(self) -> None:
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class HttpStreamingTests(unittest.TestCase):
|
||||||
|
def test_stream_transport_preserves_headers_events_and_completion(self) -> None:
|
||||||
|
handler = TransportStub()
|
||||||
|
handler.send_ndjson_stream(
|
||||||
|
({"type": "delta", "content": value} for value in ("甲", "乙")),
|
||||||
|
(StreamError,),
|
||||||
|
)
|
||||||
|
|
||||||
|
self.assertEqual(handler.statuses, [200])
|
||||||
|
self.assertEqual(
|
||||||
|
dict(handler.response_headers),
|
||||||
|
{
|
||||||
|
"Content-Type": "application/x-ndjson; charset=utf-8",
|
||||||
|
"Cache-Control": "no-cache, no-transform",
|
||||||
|
"X-Accel-Buffering": "no",
|
||||||
|
"Connection": "close",
|
||||||
|
},
|
||||||
|
)
|
||||||
|
events = [
|
||||||
|
json.loads(line)
|
||||||
|
for line in handler.wfile.getvalue().decode("utf-8").splitlines()
|
||||||
|
]
|
||||||
|
self.assertEqual(
|
||||||
|
events,
|
||||||
|
[
|
||||||
|
{"type": "delta", "content": "甲"},
|
||||||
|
{"type": "delta", "content": "乙"},
|
||||||
|
{"type": "done"},
|
||||||
|
],
|
||||||
|
)
|
||||||
|
self.assertTrue(handler.close_connection)
|
||||||
|
|
||||||
|
def test_stream_transport_preserves_feature_error_event(self) -> None:
|
||||||
|
def events():
|
||||||
|
yield {"type": "delta", "content": "partial"}
|
||||||
|
raise StreamError("stream failed")
|
||||||
|
|
||||||
|
handler = TransportStub()
|
||||||
|
handler.send_ndjson_stream(events(), (StreamError,))
|
||||||
|
payloads = [
|
||||||
|
json.loads(line)
|
||||||
|
for line in handler.wfile.getvalue().decode("utf-8").splitlines()
|
||||||
|
]
|
||||||
|
self.assertEqual(
|
||||||
|
payloads,
|
||||||
|
[
|
||||||
|
{"type": "delta", "content": "partial"},
|
||||||
|
{"type": "error", "error": "stream failed"},
|
||||||
|
],
|
||||||
|
)
|
||||||
|
self.assertTrue(handler.close_connection)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
unittest.main()
|
||||||
@@ -68,6 +68,29 @@ class JobRunnerTests(unittest.TestCase):
|
|||||||
)
|
)
|
||||||
self.assertEqual(self.repository.recent(1)[0]["status"], "failed")
|
self.assertEqual(self.repository.recent(1)[0]["status"], "failed")
|
||||||
|
|
||||||
|
def test_scheduler_start_is_idempotent_and_stop_waits_for_exit(self) -> None:
|
||||||
|
first = self.runner.start_scheduler(
|
||||||
|
lambda: None, interval_seconds=60, initial_delay_seconds=60
|
||||||
|
)
|
||||||
|
second = self.runner.start_scheduler(
|
||||||
|
lambda: None, interval_seconds=60, initial_delay_seconds=60
|
||||||
|
)
|
||||||
|
self.assertIs(first, second)
|
||||||
|
self.assertTrue(first.is_alive())
|
||||||
|
self.assertTrue(self.runner.stop_scheduler())
|
||||||
|
self.assertFalse(first.is_alive())
|
||||||
|
|
||||||
|
def test_scheduler_can_restart_after_an_orderly_stop(self) -> None:
|
||||||
|
first = self.runner.start_scheduler(
|
||||||
|
lambda: None, interval_seconds=60, initial_delay_seconds=60
|
||||||
|
)
|
||||||
|
self.assertTrue(self.runner.stop_scheduler())
|
||||||
|
second = self.runner.start_scheduler(
|
||||||
|
lambda: None, interval_seconds=60, initial_delay_seconds=60
|
||||||
|
)
|
||||||
|
self.assertIsNot(first, second)
|
||||||
|
self.assertTrue(self.runner.stop_scheduler())
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import unittest
|
import unittest
|
||||||
|
from unittest.mock import patch
|
||||||
|
|
||||||
from backend.llm import LLMGateway, LLMGatewayError
|
from backend.llm import LLMGateway, LLMGatewayError
|
||||||
|
from backend.llm.service import LLMServiceMixin
|
||||||
|
|
||||||
|
|
||||||
class ProviderFailure(RuntimeError):
|
class ProviderFailure(RuntimeError):
|
||||||
@@ -113,6 +115,31 @@ class LLMGatewayTests(unittest.TestCase):
|
|||||||
with self.assertRaisesRegex(LLMGatewayError, "额度已用完"):
|
with self.assertRaisesRegex(LLMGatewayError, "额度已用完"):
|
||||||
gateway.call("mentor", "mentor-v1", lambda model: "unused", (ProviderFailure,))
|
gateway.call("mentor", "mentor-v1", lambda model: "unused", (ProviderFailure,))
|
||||||
|
|
||||||
|
def test_saved_system_model_can_reach_the_connection_probe(self) -> None:
|
||||||
|
service = LLMServiceMixin()
|
||||||
|
service._system_credentials = {
|
||||||
|
"llm_models": [
|
||||||
|
{
|
||||||
|
"id": "primary-model",
|
||||||
|
"name": "主模型",
|
||||||
|
"api_key": "secret",
|
||||||
|
"base_url": "https://model.example/v1",
|
||||||
|
"model": "model-name",
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
service.llm_gateway = self.gateway()
|
||||||
|
expected = {"ok": True, "reply": "OK"}
|
||||||
|
with patch(
|
||||||
|
"backend.llm.service.test_llm_connection", return_value=expected
|
||||||
|
) as connection_probe:
|
||||||
|
result = service.test_system_llm_profile("primary-model", {})
|
||||||
|
|
||||||
|
self.assertEqual(result, expected)
|
||||||
|
connection_probe.assert_called_once_with(
|
||||||
|
"secret", "https://model.example/v1", "model-name"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
|||||||
@@ -0,0 +1,26 @@
|
|||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
import unittest
|
||||||
|
|
||||||
|
from backend.bootstrap.config import tushare_code
|
||||||
|
from backend.features.market import charts
|
||||||
|
|
||||||
|
|
||||||
|
class MarketSymbolNormalizationTests(unittest.TestCase):
|
||||||
|
def test_chart_and_market_services_share_one_suffix_converter(self) -> None:
|
||||||
|
self.assertIs(charts._stock_market_code, tushare_code)
|
||||||
|
|
||||||
|
def test_existing_exchange_mapping_is_preserved(self) -> None:
|
||||||
|
cases = {
|
||||||
|
"000001": "000001.SZ",
|
||||||
|
"600000": "600000.SH",
|
||||||
|
"430047": "430047.BJ",
|
||||||
|
"830799": "830799.BJ",
|
||||||
|
}
|
||||||
|
for code, expected in cases.items():
|
||||||
|
with self.subTest(code=code):
|
||||||
|
self.assertEqual(charts._stock_market_code(code), expected)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
unittest.main()
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
import math
|
||||||
|
import unittest
|
||||||
|
|
||||||
|
from backend.data.numbers import finite_number, non_nan_number
|
||||||
|
from backend.data.providers import tushare_client
|
||||||
|
from backend.features.market import insights
|
||||||
|
from backend.features.screener import engine as screener_engine
|
||||||
|
from backend.features.sentiment import engine as sentiment_engine
|
||||||
|
|
||||||
|
|
||||||
|
class NumericNormalizationTests(unittest.TestCase):
|
||||||
|
def test_consumers_use_their_declared_shared_policy(self) -> None:
|
||||||
|
self.assertIs(tushare_client._number, finite_number)
|
||||||
|
self.assertIs(screener_engine._number, finite_number)
|
||||||
|
self.assertIs(insights._number, non_nan_number)
|
||||||
|
self.assertIs(sentiment_engine._number, non_nan_number)
|
||||||
|
|
||||||
|
def test_finite_policy_preserves_existing_results(self) -> None:
|
||||||
|
self.assertEqual(finite_number("12.5"), 12.5)
|
||||||
|
self.assertEqual(finite_number(None), 0.0)
|
||||||
|
self.assertEqual(finite_number("invalid", 7.0), 7.0)
|
||||||
|
self.assertEqual(finite_number(math.nan, 7.0), 7.0)
|
||||||
|
self.assertEqual(finite_number(math.inf, 7.0), 7.0)
|
||||||
|
self.assertEqual(finite_number(-math.inf, 7.0), 7.0)
|
||||||
|
|
||||||
|
def test_non_nan_policy_keeps_infinity_but_rejects_nan(self) -> None:
|
||||||
|
self.assertEqual(non_nan_number("12.5"), 12.5)
|
||||||
|
self.assertEqual(non_nan_number(None), 0.0)
|
||||||
|
self.assertEqual(non_nan_number("invalid", 7.0), 7.0)
|
||||||
|
self.assertEqual(non_nan_number(math.nan, 7.0), 7.0)
|
||||||
|
self.assertEqual(non_nan_number(math.inf, 7.0), math.inf)
|
||||||
|
self.assertEqual(non_nan_number(-math.inf, 7.0), -math.inf)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
unittest.main()
|
||||||
@@ -40,6 +40,8 @@ class AccountSliceStructureTests(unittest.TestCase):
|
|||||||
"require_access",
|
"require_access",
|
||||||
"serve_static",
|
"serve_static",
|
||||||
"send_json",
|
"send_json",
|
||||||
|
"_write_stream_event",
|
||||||
|
"send_ndjson_stream",
|
||||||
):
|
):
|
||||||
self.assertNotIn(method, RequestHandler.__dict__)
|
self.assertNotIn(method, RequestHandler.__dict__)
|
||||||
self.assertIn(method, HttpTransportMixin.__dict__)
|
self.assertIn(method, HttpTransportMixin.__dict__)
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ class FrontendPreservationSliceTests(unittest.TestCase):
|
|||||||
(ORIGINAL_STATIC / "index.html").read_text(encoding="utf-8"),
|
(ORIGINAL_STATIC / "index.html").read_text(encoding="utf-8"),
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_complete_stylesheet_stack_is_byte_identical_after_relocation(self) -> None:
|
def test_stylesheet_stack_matches_baseline_after_audited_retirements(self) -> None:
|
||||||
for original, migrated in (
|
for original, migrated in (
|
||||||
("shared/tokens.css", "shared/tokens.css"),
|
("shared/tokens.css", "shared/tokens.css"),
|
||||||
("styles.css", "styles/styles.css"),
|
("styles.css", "styles/styles.css"),
|
||||||
|
|||||||
@@ -38,6 +38,9 @@ HEAVEN_SERVICE_METHODS = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
HEAVEN_REPOSITORY_METHODS = {
|
HEAVEN_REPOSITORY_METHODS = {
|
||||||
|
"list_sector_phase_overrides",
|
||||||
|
"save_sector_phase_override",
|
||||||
|
"delete_sector_phase_override",
|
||||||
"_heaven_reading_dict",
|
"_heaven_reading_dict",
|
||||||
"save_heaven_reading",
|
"save_heaven_reading",
|
||||||
"list_heaven_readings",
|
"list_heaven_readings",
|
||||||
|
|||||||
@@ -9,13 +9,16 @@ import chart_data_provider
|
|||||||
import ifind_client
|
import ifind_client
|
||||||
import realtime_aggregator
|
import realtime_aggregator
|
||||||
import tushare_client
|
import tushare_client
|
||||||
|
from backend.bootstrap import config as bootstrap_config
|
||||||
from backend.data import realtime
|
from backend.data import realtime
|
||||||
|
from backend.data.numbers import finite_number
|
||||||
from backend.data.providers import ifind_client as canonical_ifind
|
from backend.data.providers import ifind_client as canonical_ifind
|
||||||
from backend.data.providers import tushare_client as canonical_tushare
|
from backend.data.providers import tushare_client as canonical_tushare
|
||||||
from backend.features.market import charts
|
from backend.features.market import charts
|
||||||
from tests.preservation_helpers import (
|
from tests.preservation_helpers import (
|
||||||
assert_frontend_runtime_matches_audited_baseline,
|
assert_frontend_runtime_matches_audited_baseline,
|
||||||
assert_moved_asset_matches,
|
assert_moved_asset_matches,
|
||||||
|
function_contract,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@@ -141,14 +144,40 @@ class MarketSliceSourceEquivalenceTests(unittest.TestCase):
|
|||||||
)
|
)
|
||||||
for original, migrated in exact_moves:
|
for original, migrated in exact_moves:
|
||||||
self.assertEqual(sha256(ORIGINAL_ROOT / original), sha256(APP_ROOT / migrated))
|
self.assertEqual(sha256(ORIGINAL_ROOT / original), sha256(APP_ROOT / migrated))
|
||||||
|
original_tushare = top_level_definitions(ORIGINAL_ROOT / "tushare_client.py")
|
||||||
|
original_tushare.pop("_number")
|
||||||
|
original_tushare.pop("_display_date")
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
top_level_definitions(ORIGINAL_ROOT / "tushare_client.py"),
|
original_tushare,
|
||||||
top_level_definitions(APP_ROOT / "backend/data/providers/tushare_client.py"),
|
top_level_definitions(APP_ROOT / "backend/data/providers/tushare_client.py"),
|
||||||
)
|
)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
top_level_definitions(ORIGINAL_ROOT / "chart_data_provider.py"),
|
function_contract(ORIGINAL_ROOT / "tushare_client.py", "_number"),
|
||||||
|
function_contract(APP_ROOT / "backend/data/numbers.py", "finite_number"),
|
||||||
|
)
|
||||||
|
self.assertIs(canonical_tushare._number, finite_number)
|
||||||
|
self.assertEqual(
|
||||||
|
function_contract(ORIGINAL_ROOT / "tushare_client.py", "_display_date"),
|
||||||
|
function_contract(
|
||||||
|
APP_ROOT / "backend/bootstrap/config.py", "display_compact_date"
|
||||||
|
),
|
||||||
|
)
|
||||||
|
self.assertIs(canonical_tushare._display_date, bootstrap_config.display_compact_date)
|
||||||
|
original_charts = top_level_definitions(ORIGINAL_ROOT / "chart_data_provider.py")
|
||||||
|
original_charts.pop("_stock_market_code")
|
||||||
|
self.assertEqual(
|
||||||
|
original_charts,
|
||||||
top_level_definitions(APP_ROOT / "backend/features/market/charts.py"),
|
top_level_definitions(APP_ROOT / "backend/features/market/charts.py"),
|
||||||
)
|
)
|
||||||
|
self.assertEqual(
|
||||||
|
function_contract(
|
||||||
|
ORIGINAL_ROOT / "chart_data_provider.py", "_stock_market_code"
|
||||||
|
),
|
||||||
|
function_contract(
|
||||||
|
APP_ROOT / "backend/bootstrap/config.py", "tushare_code"
|
||||||
|
),
|
||||||
|
)
|
||||||
|
self.assertIs(charts._stock_market_code, bootstrap_config.tushare_code)
|
||||||
|
|
||||||
def test_relocated_frontend_preserves_original_market_runtime_and_styles(self) -> None:
|
def test_relocated_frontend_preserves_original_market_runtime_and_styles(self) -> None:
|
||||||
assert_frontend_runtime_matches_audited_baseline(self)
|
assert_frontend_runtime_matches_audited_baseline(self)
|
||||||
|
|||||||
@@ -6,11 +6,13 @@ import unittest
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
import market_insights
|
import market_insights
|
||||||
|
from backend.data.numbers import non_nan_number
|
||||||
from backend.features.market import insights as canonical_insights
|
from backend.features.market import insights as canonical_insights
|
||||||
from tests.preservation_helpers import (
|
from tests.preservation_helpers import (
|
||||||
assert_frontend_runtime_matches_audited_baseline,
|
assert_frontend_runtime_matches_audited_baseline,
|
||||||
assert_moved_asset_matches,
|
assert_moved_asset_matches,
|
||||||
assert_page_prefix_matches,
|
assert_page_prefix_matches,
|
||||||
|
function_contract,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@@ -106,6 +108,11 @@ class MarketInsightsSliceSourceEquivalenceTests(unittest.TestCase):
|
|||||||
MARKET_INSIGHT_METHODS,
|
MARKET_INSIGHT_METHODS,
|
||||||
)
|
)
|
||||||
self.assertIs(market_insights.MarketInsightsService, canonical_insights.MarketInsightsService)
|
self.assertIs(market_insights.MarketInsightsService, canonical_insights.MarketInsightsService)
|
||||||
|
self.assertEqual(
|
||||||
|
function_contract(ORIGINAL_ROOT / "market_insights.py", "_number"),
|
||||||
|
function_contract(APP_ROOT / "backend/data/numbers.py", "non_nan_number"),
|
||||||
|
)
|
||||||
|
self.assertIs(canonical_insights._number, non_nan_number)
|
||||||
|
|
||||||
def test_dashboard_service_methods_are_exact_original_ast(self) -> None:
|
def test_dashboard_service_methods_are_exact_original_ast(self) -> None:
|
||||||
original = ORIGINAL_ROOT / "server.py"
|
original = ORIGINAL_ROOT / "server.py"
|
||||||
|
|||||||
@@ -9,12 +9,16 @@ import advanced_strategies
|
|||||||
import llm_strategy
|
import llm_strategy
|
||||||
import screener
|
import screener
|
||||||
import strategy_tracking
|
import strategy_tracking
|
||||||
|
from backend.bootstrap import config as bootstrap_config
|
||||||
|
from backend.data.numbers import finite_number
|
||||||
from backend.features.screener import compiler, engine, strategies, tracking
|
from backend.features.screener import compiler, engine, strategies, tracking
|
||||||
from backend.features.screener import service as screener_service
|
from backend.features.screener import service as screener_service
|
||||||
from tests.preservation_helpers import (
|
from tests.preservation_helpers import (
|
||||||
assert_frontend_runtime_matches_audited_baseline,
|
assert_frontend_runtime_matches_audited_baseline,
|
||||||
assert_moved_asset_matches,
|
assert_moved_asset_matches,
|
||||||
assert_page_prefix_matches,
|
assert_page_prefix_matches,
|
||||||
|
function_contract,
|
||||||
|
module_contract,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@@ -91,14 +95,6 @@ def top_level_definition(path: Path, name: str) -> str:
|
|||||||
return ast.dump(node, include_attributes=False)
|
return ast.dump(node, include_attributes=False)
|
||||||
|
|
||||||
|
|
||||||
def module_without_imports(path: Path) -> str:
|
|
||||||
tree = ast.parse(path.read_text(encoding="utf-8"), filename=str(path))
|
|
||||||
tree.body = [
|
|
||||||
node for node in tree.body if not isinstance(node, (ast.Import, ast.ImportFrom))
|
|
||||||
]
|
|
||||||
return ast.dump(tree, include_attributes=False)
|
|
||||||
|
|
||||||
|
|
||||||
def sha256(path: Path) -> str:
|
def sha256(path: Path) -> str:
|
||||||
return hashlib.sha256(path.read_bytes()).hexdigest()
|
return hashlib.sha256(path.read_bytes()).hexdigest()
|
||||||
|
|
||||||
@@ -154,11 +150,29 @@ class ScreenerSliceSourceEquivalenceTests(unittest.TestCase):
|
|||||||
|
|
||||||
def test_engine_and_tracking_logic_match_the_original(self) -> None:
|
def test_engine_and_tracking_logic_match_the_original(self) -> None:
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
module_without_imports(ORIGINAL_ROOT / "screener.py"),
|
module_contract(
|
||||||
module_without_imports(
|
ORIGINAL_ROOT / "screener.py",
|
||||||
APP_ROOT / "backend" / "features" / "screener" / "engine.py"
|
excluded_definitions={"_display_date", "_number"},
|
||||||
|
exclude_imports=True,
|
||||||
|
),
|
||||||
|
module_contract(
|
||||||
|
APP_ROOT / "backend" / "features" / "screener" / "engine.py",
|
||||||
|
excluded_definitions={"_display_date", "_number"},
|
||||||
|
exclude_imports=True,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
self.assertEqual(
|
||||||
|
function_contract(ORIGINAL_ROOT / "screener.py", "_number"),
|
||||||
|
function_contract(APP_ROOT / "backend/data/numbers.py", "finite_number"),
|
||||||
|
)
|
||||||
|
self.assertIs(engine._number, finite_number)
|
||||||
|
self.assertEqual(
|
||||||
|
function_contract(ORIGINAL_ROOT / "screener.py", "_display_date"),
|
||||||
|
function_contract(
|
||||||
|
APP_ROOT / "backend/bootstrap/config.py", "display_compact_date"
|
||||||
|
),
|
||||||
|
)
|
||||||
|
self.assertIs(engine._display_date, bootstrap_config.display_compact_date)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
class_methods(
|
class_methods(
|
||||||
ORIGINAL_ROOT / "backend" / "features" / "screener" / "tracking.py",
|
ORIGINAL_ROOT / "backend" / "features" / "screener" / "tracking.py",
|
||||||
|
|||||||
@@ -6,11 +6,14 @@ import unittest
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
import sentiment_engine
|
import sentiment_engine
|
||||||
|
from backend.data.numbers import non_nan_number
|
||||||
from backend.features.sentiment import engine as canonical_engine
|
from backend.features.sentiment import engine as canonical_engine
|
||||||
from tests.preservation_helpers import (
|
from tests.preservation_helpers import (
|
||||||
assert_frontend_runtime_matches_audited_baseline,
|
assert_frontend_runtime_matches_audited_baseline,
|
||||||
assert_moved_asset_matches,
|
assert_moved_asset_matches,
|
||||||
assert_page_prefix_matches,
|
assert_page_prefix_matches,
|
||||||
|
function_contract,
|
||||||
|
module_contract,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@@ -26,6 +29,8 @@ POOL_METHODS = {
|
|||||||
"_apply_reason_overrides",
|
"_apply_reason_overrides",
|
||||||
"_schedule_ifind_event_enrichment",
|
"_schedule_ifind_event_enrichment",
|
||||||
"_refresh_ifind_event_enrichment",
|
"_refresh_ifind_event_enrichment",
|
||||||
|
"_ifind_field",
|
||||||
|
"_ifind_row_code",
|
||||||
"_normalize_ifind_event_time",
|
"_normalize_ifind_event_time",
|
||||||
"_merge_ifind_event_enrichment",
|
"_merge_ifind_event_enrichment",
|
||||||
}
|
}
|
||||||
@@ -94,10 +99,22 @@ class SentimentPoolSliceSourceEquivalenceTests(unittest.TestCase):
|
|||||||
|
|
||||||
def test_sentiment_engine_is_exact_original_with_legacy_alias(self) -> None:
|
def test_sentiment_engine_is_exact_original_with_legacy_alias(self) -> None:
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
sha256(ORIGINAL_ROOT / "sentiment_engine.py"),
|
module_contract(
|
||||||
sha256(APP_ROOT / "backend" / "features" / "sentiment" / "engine.py"),
|
ORIGINAL_ROOT / "sentiment_engine.py",
|
||||||
|
excluded_definitions={"_number"},
|
||||||
|
),
|
||||||
|
module_contract(
|
||||||
|
APP_ROOT / "backend" / "features" / "sentiment" / "engine.py",
|
||||||
|
excluded_definitions={"_number"},
|
||||||
|
excluded_import_modules={"backend.data.numbers"},
|
||||||
|
),
|
||||||
|
)
|
||||||
|
self.assertEqual(
|
||||||
|
function_contract(ORIGINAL_ROOT / "sentiment_engine.py", "_number"),
|
||||||
|
function_contract(APP_ROOT / "backend/data/numbers.py", "non_nan_number"),
|
||||||
)
|
)
|
||||||
self.assertIs(sentiment_engine, canonical_engine)
|
self.assertIs(sentiment_engine, canonical_engine)
|
||||||
|
self.assertIs(canonical_engine._number, non_nan_number)
|
||||||
|
|
||||||
def test_api_and_frontend_assets_are_unchanged(self) -> None:
|
def test_api_and_frontend_assets_are_unchanged(self) -> None:
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
|
|||||||
@@ -155,6 +155,19 @@ def build() -> dict[str, Any]:
|
|||||||
{"provider": "eastmoney", "path": "backend/data/realtime.py", "runtime_role": "isolated realtime observation"},
|
{"provider": "eastmoney", "path": "backend/data/realtime.py", "runtime_role": "isolated realtime observation"},
|
||||||
{"provider": "tencent", "path": "backend/data/realtime.py", "runtime_role": "index observation fallback"},
|
{"provider": "tencent", "path": "backend/data/realtime.py", "runtime_role": "index observation fallback"},
|
||||||
],
|
],
|
||||||
|
"provider_construction": [
|
||||||
|
{"client": "TushareClient", "owner": "backend/data/providers/tushare.py", "compatibility_fallback": "backend/features/market/service.py"},
|
||||||
|
{"client": "IfindHttpClient", "owner": "backend/data/gateway.py"},
|
||||||
|
{"client": "MarketChartClient", "owner": "backend/data/gateway.py"},
|
||||||
|
{"client": "WebRealtimeAggregator", "owner": "backend/data/gateway.py"},
|
||||||
|
],
|
||||||
|
"numeric_normalization": [
|
||||||
|
{"function": "finite_number", "path": "backend/data/numbers.py"},
|
||||||
|
{"function": "non_nan_number", "path": "backend/data/numbers.py"},
|
||||||
|
],
|
||||||
|
"date_formatting": [
|
||||||
|
{"function": "display_compact_date", "path": "backend/bootstrap/config.py"},
|
||||||
|
],
|
||||||
"llm_entrypoints": [
|
"llm_entrypoints": [
|
||||||
{"function": "stream_with_mentor", "path": "backend/features/mentor/agent.py"},
|
{"function": "stream_with_mentor", "path": "backend/features/mentor/agent.py"},
|
||||||
{"function": "interpret_heaven", "path": "backend/features/heaven/agent.py"},
|
{"function": "interpret_heaven", "path": "backend/features/heaven/agent.py"},
|
||||||
@@ -166,6 +179,10 @@ def build() -> dict[str, Any]:
|
|||||||
{"function": "chat_completion", "path": "backend/llm/transport.py"},
|
{"function": "chat_completion", "path": "backend/llm/transport.py"},
|
||||||
{"function": "stream_chat_completion", "path": "backend/llm/transport.py"},
|
{"function": "stream_chat_completion", "path": "backend/llm/transport.py"},
|
||||||
],
|
],
|
||||||
|
"http_transport": [
|
||||||
|
{"function": "send_json", "path": "backend/http/handler.py"},
|
||||||
|
{"function": "send_ndjson_stream", "path": "backend/http/handler.py"},
|
||||||
|
],
|
||||||
"css_layers": css_layers(html),
|
"css_layers": css_layers(html),
|
||||||
"code_hotspots": code_hotspots(),
|
"code_hotspots": code_hotspots(),
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,17 +32,22 @@ def main() -> None:
|
|||||||
from server import RequestHandler, SERVICE
|
from server import RequestHandler, SERVICE
|
||||||
|
|
||||||
server = ThreadingHTTPServer(("127.0.0.1", args.port), RequestHandler)
|
server = ThreadingHTTPServer(("127.0.0.1", args.port), RequestHandler)
|
||||||
print(
|
|
||||||
f"Preservation runtime is running at http://127.0.0.1:{args.port} "
|
|
||||||
f"with database {SERVICE.database.path}",
|
|
||||||
flush=True,
|
|
||||||
)
|
|
||||||
try:
|
try:
|
||||||
|
if hasattr(SERVICE, "start_background_jobs"):
|
||||||
|
SERVICE.start_background_jobs()
|
||||||
|
print(
|
||||||
|
f"Preservation runtime is running at http://127.0.0.1:{args.port} "
|
||||||
|
f"with database {SERVICE.database.path}",
|
||||||
|
flush=True,
|
||||||
|
)
|
||||||
server.serve_forever()
|
server.serve_forever()
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
pass
|
pass
|
||||||
finally:
|
finally:
|
||||||
SERVICE._background_stop.set()
|
if hasattr(SERVICE, "stop_background_jobs"):
|
||||||
|
SERVICE.stop_background_jobs()
|
||||||
|
else:
|
||||||
|
SERVICE._background_stop.set()
|
||||||
server.server_close()
|
server.server_close()
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -20,6 +20,16 @@
|
|||||||
|---|---|---|---|---|
|
|---|---|---|---|---|
|
||||||
| CR-01 | LLM供应商传输 | 问师、问天、复盘助手和策略编译各自构造HTTP请求、解析响应和读取错误 | 只保留`backend/llm/transport.py`一个网络出口 | 已完成 |
|
| CR-01 | LLM供应商传输 | 问师、问天、复盘助手和策略编译各自构造HTTP请求、解析响应和读取错误 | 只保留`backend/llm/transport.py`一个网络出口 | 已完成 |
|
||||||
| CR-02 | HTTP精确POST委托 | 27个端点重复使用“比较路径、调用无参数处理器、返回”三行分支 | 用公开/受保护两张显式映射统一委托,同时保留复杂路由的原控制流 | 已完成 |
|
| CR-02 | HTTP精确POST委托 | 27个端点重复使用“比较路径、调用无参数处理器、返回”三行分支 | 用公开/受保护两张显式映射统一委托,同时保留复杂路由的原控制流 | 已完成 |
|
||||||
|
| CR-03 | 股票市场后缀转换 | Tushare业务与iFinD图表各保留一份完全相同的沪深京代码转换函数 | 图表复用`bootstrap/config.py::tushare_code`,只保留一份函数体 | 已完成 |
|
||||||
|
| CR-04 | 数值归一化策略 | 四个业务模块分别保留两组完全相同的数值转换函数体 | 由`backend/data/numbers.py`集中拥有两种既有语义,消费者保留原局部别名 | 已完成 |
|
||||||
|
| CR-05 | 根级兼容入口 | 正式后端仍有五处通过迁移兼容模块反向导入规范实现 | 正式代码改用规范路径;兼容入口只服务原公开导入契约 | 已完成 |
|
||||||
|
| CR-06 | 紧凑日期显示 | Tushare与选股引擎各保留一份完全相同的`YYYYMMDD`显示转换 | 由`bootstrap/config.py`拥有唯一格式策略,消费者保留原局部别名 | 已完成 |
|
||||||
|
| CR-07 | 数据Provider组装 | 核查网关、容器和业务服务是否重复创建外部数据客户端 | 固化唯一创建位置及兼容例外,不改数据源语义 | 已完成 |
|
||||||
|
| CR-08 | NDJSON流式传输 | 问师与复盘助手重复维护响应头、事件写入、完成、断线及关闭流程 | HTTP共享层拥有唯一流式连接生命周期 | 已完成 |
|
||||||
|
| CR-09 | 应用服务门面 | 两个仅服务股池iFinD补全的方法仍错位在全局`DashboardService` | 原函数体机械归位到`PoolServiceMixin` | 已完成 |
|
||||||
|
| CR-10 | Repository所有权 | 五行行业阶段覆盖的三项持久化方法仍错位在根级数据库门面 | 原函数体机械归位到问天Repository,兼容数据继续保留 | 已完成 |
|
||||||
|
| CR-11 | 后台任务生命周期 | 导入应用即启动调度线程,启动早于端口绑定,停止只置位但不等待 | 运行时显式启停,每个Runner只拥有一个可等待的调度线程 | 已完成 |
|
||||||
|
| CR-12 | CSS跨层精确重复 | 七层样式保留多次视觉改造形成的重复顶层规则,前层声明被后层逐字覆盖 | 只删除能够由CSSOM证明完全重复的前层规则,并建立浏览器级重复门禁 | 已完成 |
|
||||||
|
|
||||||
## CR-01验收口径
|
## CR-01验收口径
|
||||||
|
|
||||||
@@ -66,3 +76,279 @@
|
|||||||
|
|
||||||
本批基线为`xiaobai-reduction-01-llm-transport-20260801`;检查点为
|
本批基线为`xiaobai-reduction-01-llm-transport-20260801`;检查点为
|
||||||
`xiaobai-reduction-02-http-dispatch-20260801`。
|
`xiaobai-reduction-02-http-dispatch-20260801`。
|
||||||
|
|
||||||
|
## CR-03验收口径
|
||||||
|
|
||||||
|
- 图表模块不再定义第二份市场后缀转换函数,仍保留原局部名称和两个调用点。
|
||||||
|
- 深市、沪市、北交所的既有映射结果保持不变;不借本批修正或扩展代码规则。
|
||||||
|
- 原图表文件除该函数外的所有顶层定义继续与原版AST逐项相等。
|
||||||
|
- 原版`_stock_market_code`函数的参数和函数体必须与唯一共享实现AST相等,运行时别名必须指向
|
||||||
|
同一个函数对象。
|
||||||
|
|
||||||
|
## CR-03结果
|
||||||
|
|
||||||
|
- 删除`backend/features/market/charts.py`中第二份10行定义,以1行导入别名复用共享实现,生产代码
|
||||||
|
净减少9行;全仓后端只剩一份沪深京后缀转换函数体。
|
||||||
|
- 未合并实时聚合、东方财富图表、iFinD和Tushare的HTTP传输;它们的缓存、错误、重试和降级语义
|
||||||
|
不同,仅有外形相似,证据不足以安全抽象。
|
||||||
|
- 原有迁移期整文件相等断言被等价范围断言、共享函数AST断言和唯一对象断言替代,没有降低门禁。
|
||||||
|
- 原版231项、候选317项、纯`app/`导出254项、45项Playwright通过;API/架构注册表、
|
||||||
|
24个JavaScript文件、Git空白检查和SQLite完整性检查通过。
|
||||||
|
- 本批不修改图表请求、数据来源、缓存、时间范围、行情计算、前端、CSS、数据库或部署。
|
||||||
|
|
||||||
|
本批基线为`xiaobai-reduction-02-http-dispatch-20260801`;检查点为
|
||||||
|
`xiaobai-reduction-03-market-symbol-20260801`。
|
||||||
|
|
||||||
|
## CR-04验收口径
|
||||||
|
|
||||||
|
- 只合并参数、函数体和运行结果完全一致的数值转换函数,不借本批改变任何业务计算或异常默认值。
|
||||||
|
- `finite_number`继续拒绝`NaN`与正负无穷;`non_nan_number`继续只拒绝`NaN`并保留正负无穷。
|
||||||
|
- Tushare与智能选股必须复用有限数策略;市场洞察与情绪引擎必须复用非NaN策略,并继续暴露原局部
|
||||||
|
`_number`名称以保持兼容。
|
||||||
|
- 实时行情和图表转换器的空值、默认值或参数签名语义不同,必须继续独立保留,不能因名称相同而合并。
|
||||||
|
- 原版函数参数和函数体分别与共享实现AST相等;四个消费者的局部别名必须指向对应的唯一函数对象。
|
||||||
|
|
||||||
|
## CR-04结果
|
||||||
|
|
||||||
|
- 删除Tushare、智能选股、市场洞察和情绪引擎中的四份重复函数体,新建两种明确命名的共享策略;生产
|
||||||
|
代码净减少约12行,全仓AST扫描不再发现完全相同的函数定义。
|
||||||
|
- 将可复用的函数及模块AST契约归入测试辅助层,原有迁移保持性测试改为“未改范围保持相等、被替换
|
||||||
|
函数与共享实现相等、运行时唯一对象”三重断言,没有降低门禁。
|
||||||
|
- 实时行情`backend/data/realtime.py::_number`与图表`backend/features/market/charts.py::_number`
|
||||||
|
被明确保留;它们不是本批重复实现,也未改变行为。
|
||||||
|
- 58项定向测试、41项保持性/治理测试、原版231项、候选320项、纯`app/`导出257项和45项
|
||||||
|
Playwright通过;24个JavaScript文件、API/架构注册表、Git空白检查和SQLite完整性检查通过。
|
||||||
|
- 本批不修改前端、CSS、接口、数据来源、行情口径、选股条件、数据库、LLM、权限或部署。
|
||||||
|
|
||||||
|
本批基线为`xiaobai-reduction-03-market-symbol-20260801`;检查点为
|
||||||
|
`xiaobai-reduction-04-numeric-normalization-20260801`。
|
||||||
|
|
||||||
|
## CR-05验收口径
|
||||||
|
|
||||||
|
- 逐项扫描根级Python入口、生产代码、测试、工具和动态导入;没有消费者或兼容责任的入口才能删除。
|
||||||
|
- 规范后端不得经由`screener`、`advanced_strategies`、`tushare_client`或`server`兼容入口
|
||||||
|
间接访问已经归位的实现。
|
||||||
|
- 所有根级模块继续保持原导入名称、导出对象及模块对象身份,既有启动命令和第三方维护脚本不受影响。
|
||||||
|
- `api_access`、选股Repository的惰性`sentiment_engine`导入及根级`database.py`属于已登记边界,
|
||||||
|
分别留到HTTP、Repository阶段处理,不在本批跨边界修改。
|
||||||
|
|
||||||
|
## CR-05结果
|
||||||
|
|
||||||
|
- 审计确认21个根级兼容入口均有测试、工具、启动或原公开导入契约消费者,因此本批没有冒险删除文件。
|
||||||
|
- 容器、策略编译器、选股引擎及数据同步命令的五处导入改为规范模块路径,正式代码不再通过四个根级
|
||||||
|
兼容模块反向进入实现;运行代码行数未增加。
|
||||||
|
- 特性边界测试取消选股引擎旧例外,并新增全后端兼容导入门禁;只允许两项已登记过渡边界,后续代码
|
||||||
|
无法重新引入隐式根级依赖。
|
||||||
|
- 候选321项、纯`app/`导出258项、24个JavaScript文件、API/架构注册表、Git空白检查和SQLite
|
||||||
|
完整性检查通过;本批不涉及页面、CSS或浏览器行为。
|
||||||
|
- 本批不修改业务计算、策略公式、数据源、API、数据库、LLM、权限、前端或部署。
|
||||||
|
|
||||||
|
本批基线为`xiaobai-reduction-04-numeric-normalization-20260801`;检查点为
|
||||||
|
`xiaobai-reduction-05-compatibility-boundaries-20260801`。
|
||||||
|
|
||||||
|
## CR-06验收口径
|
||||||
|
|
||||||
|
- 只合并参数、函数体和异常行为完全相同的日期/文本转换;名称相似但空值、未来日期、错误文案或
|
||||||
|
输入格式不同的函数不得合并。
|
||||||
|
- Tushare与选股引擎继续暴露局部`_display_date`名称,并分别指向唯一共享实现。
|
||||||
|
- 原版两个`_display_date`函数必须分别与共享实现AST相等,所有原调用结果保持不变。
|
||||||
|
- 市场洞察的日期显示函数会清理连字符并容忍空值,语义不同,必须继续独立保留。
|
||||||
|
|
||||||
|
## CR-06结果
|
||||||
|
|
||||||
|
- 删除Tushare与选股引擎内两个重复日期函数体,新增`display_compact_date`唯一策略;生产代码总
|
||||||
|
行数不增加,重复函数体由两份降为一份。
|
||||||
|
- 架构清单登记日期格式唯一所有权;保持性测试改为未改范围AST相等、共享函数AST相等和运行时
|
||||||
|
对象身份三重契约,没有放宽原迁移门禁。
|
||||||
|
- `normalize_date`、市场洞察日期显示、实时行情时间格式和会员日期边界因语义不同均原样保留。
|
||||||
|
- 候选321项、纯`app/`导出258项、24个JavaScript文件、API/架构注册表、Git空白检查和SQLite
|
||||||
|
完整性检查通过;本批不涉及页面、CSS或浏览器行为。
|
||||||
|
- 本批不修改日期输入规则、业务计算、选股结果、接口、数据库、数据源、LLM、权限或部署。
|
||||||
|
|
||||||
|
本批基线为`xiaobai-reduction-05-compatibility-boundaries-20260801`;检查点为
|
||||||
|
`xiaobai-reduction-06-date-formatting-20260801`。
|
||||||
|
|
||||||
|
## CR-07验收口径
|
||||||
|
|
||||||
|
- iFinD、图表、实时观察器和Provider适配器必须只在`build_data_gateway`创建,并由容器共享。
|
||||||
|
- Tushare必须继续通过实时Token供应器按需创建,不能为了减少对象数量缓存过期Token。
|
||||||
|
- 市场服务中为原版隔离测试桩保留的一处`TushareClient(self.token)`是明确兼容例外,不得被误判为
|
||||||
|
第二条正式数据链路。
|
||||||
|
- 不得合并Tushare、iFinD、东方财富和腾讯的传输、缓存、重试或降级逻辑。
|
||||||
|
|
||||||
|
## CR-07结果
|
||||||
|
|
||||||
|
- 全后端构造点扫描确认iFinD、MarketChart、东方财富图表和实时观察器均只有网关一个创建位置;
|
||||||
|
`ApplicationContainer`暴露的是同一对象引用,没有第二份客户端。
|
||||||
|
- Tushare Provider使用动态Token供应器,市场服务只有一处已登记测试兼容回退;本批没有发现可安全
|
||||||
|
删除的生产实现,因此不为追求行数强行修改运行代码。
|
||||||
|
- 架构清单新增Provider创建所有权,自动测试会在未来出现第二个未登记构造点时失败。
|
||||||
|
- 候选322项、纯`app/`导出259项、24个JavaScript文件、API/架构注册表、Git空白检查和SQLite
|
||||||
|
完整性检查通过;本批不涉及页面、CSS或浏览器行为。
|
||||||
|
- 本批不修改请求频率、缓存、重试、Token更新、数据源选择、计算口径、API、数据库或前端。
|
||||||
|
|
||||||
|
本批基线为`xiaobai-reduction-06-date-formatting-20260801`;检查点为
|
||||||
|
`xiaobai-reduction-07-provider-ownership-20260801`。
|
||||||
|
|
||||||
|
## CR-08验收口径
|
||||||
|
|
||||||
|
- 只合并NDJSON响应头、事件序列化、完成事件、业务错误事件、客户端断线和连接关闭这些传输行为。
|
||||||
|
- 问师继续直接输出原事件字典;复盘助手继续把文本分片包装为`delta/content`事件。
|
||||||
|
- 两个功能各自的业务异常类型、请求体错误状态码、错误正文和流创建时机保持不变。
|
||||||
|
- `_write_stream_event`与连接生命周期必须只由`backend/http/handler.py`拥有,应用大类和功能HTTP
|
||||||
|
模块不再保留第二份实现。
|
||||||
|
|
||||||
|
## CR-08结果
|
||||||
|
|
||||||
|
- 删除问师和复盘助手各16行重复流式控制流,并将应用大类中的10行事件写入方法归入HTTP共享层;
|
||||||
|
新共享实现29行、两个调用适配共3行,生产代码净减少10行。
|
||||||
|
- 新增专项测试固定四个响应头、中文NDJSON序列化、增量顺序、完成事件、业务错误事件和关闭状态。
|
||||||
|
- 候选324项、纯`app/`导出261项及45项Playwright通过;24个JavaScript文件、API/架构注册表、
|
||||||
|
Git空白检查和SQLite完整性检查通过。
|
||||||
|
- 本批不修改提示词、模型选择、会员计次、流式正文、前端解析、API路径、数据库或数据源。
|
||||||
|
|
||||||
|
本批基线为`xiaobai-reduction-07-provider-ownership-20260801`;检查点为
|
||||||
|
`xiaobai-reduction-08-ndjson-transport-20260801`。
|
||||||
|
|
||||||
|
## CR-09验收口径
|
||||||
|
|
||||||
|
- 只有消费者全部属于单一领域、且能够按原函数体机械移动的方法才从应用门面移出。
|
||||||
|
- `_ifind_field`与`_ifind_row_code`继续保持静态/类方法签名、字段优先级、大小写规则和代码正则。
|
||||||
|
- 账号委托属于稳定公开门面;系统设置属于跨领域协调;后台刷新留到CR-11,本批均不得删除或重写。
|
||||||
|
- 移动后`DashboardService`必须继续通过Mixin解析同名方法,调用点和返回值不变。
|
||||||
|
|
||||||
|
## CR-09结果
|
||||||
|
|
||||||
|
- 将iFinD字段匹配和股票代码提取两个方法从应用大类机械移动到股池服务,原版与迁移方法AST逐项
|
||||||
|
相等;应用大类不再直接拥有股池专属实现。
|
||||||
|
- 连同迁移期遗留空行,`backend/application.py`减少32行,股池服务增加24行,生产代码净减少8行。
|
||||||
|
- 候选324项、纯`app/`导出261项、24个JavaScript文件、API/架构注册表、Git空白检查和SQLite
|
||||||
|
完整性检查通过;本批不涉及页面、CSS或浏览器行为。
|
||||||
|
- 本批不修改字段匹配、涨跌停原因补全、接口、数据源、缓存、数据库、权限或前端。
|
||||||
|
|
||||||
|
本批基线为`xiaobai-reduction-08-ndjson-transport-20260801`;检查点为
|
||||||
|
`xiaobai-reduction-09-service-facade-20260801`。
|
||||||
|
|
||||||
|
## CR-10验收口径
|
||||||
|
|
||||||
|
- 只移动调用方、数据表和业务含义均明确属于单一领域的方法;数据库连接、事务和返回值必须保持不变。
|
||||||
|
- `list_sector_phase_overrides`、`save_sector_phase_override`与`delete_sector_phase_override`必须由
|
||||||
|
`backend/features/heaven/repository.py`拥有,并继续通过`ReviewDatabase`的Mixin解析。
|
||||||
|
- 不修改表结构、迁移顺序、时间格式、排序、冲突更新或删除结果语义。
|
||||||
|
- `wencai_saved_queries`及其三个方法属于已登记的账户隔离兼容数据;即使前端入口已取消,也必须保留。
|
||||||
|
|
||||||
|
## CR-10结果
|
||||||
|
|
||||||
|
- 将五行行业阶段覆盖的查询、保存和删除三个方法从根级`database.py`机械移动到问天Repository;
|
||||||
|
调用名称、SQL、事务边界、时间值和返回结果均未改变。
|
||||||
|
- 根级数据库门面不再直接拥有问天领域的持久化实现,问财历史兼容表和方法完整保留,未扩大删除范围。
|
||||||
|
- 34项Repository、问天、账户隔离、清理契约及迁移定向测试通过;候选324项、纯`app/`导出261项、
|
||||||
|
24个JavaScript文件、API/架构注册表、Git空白检查和SQLite完整性检查通过。
|
||||||
|
- 本批不修改页面、CSS、API、数据库结构、行情、数据源、业务计算、LLM、权限或后台任务。
|
||||||
|
|
||||||
|
本批基线为`xiaobai-reduction-09-service-facade-20260801`;检查点为
|
||||||
|
`xiaobai-reduction-10-repository-ownership-20260801`。
|
||||||
|
|
||||||
|
## CR-11验收口径
|
||||||
|
|
||||||
|
- 导入`backend.application`或构造`DashboardService`不得启动后台调度;必须先成功绑定HTTP端口,
|
||||||
|
再由运行时显式启动。
|
||||||
|
- 同一`InProcessJobRunner`重复启动调度器必须返回同一活动线程,停止必须置位并在限定时间内等待退出,
|
||||||
|
有序停止后允许重新启动。
|
||||||
|
- 运行时关闭顺序固定为:停止调度、等待已提交任务、关闭HTTP服务器;迁移对比工具继续兼容原版入口。
|
||||||
|
- 三个任务的注册定义、5秒刷新频率、3秒初始延迟、幂等键、锁、重试、业务函数和结果不得改变。
|
||||||
|
- 声明的超时继续是目标与审计字段;Python线程不能安全强杀,本批不伪造硬取消能力。
|
||||||
|
|
||||||
|
## CR-11结果
|
||||||
|
|
||||||
|
- 删除`DashboardService`构造阶段的调度副作用,端口占用、模块导入和单元测试不再提前创建后台写线程;
|
||||||
|
`backend/bootstrap/runtime.py`成为正式启动与停止所有者。
|
||||||
|
- `InProcessJobRunner`集中持有调度停止事件和线程引用;重复启动幂等,停止可等待,原任务锁、持久化运行
|
||||||
|
状态、成功幂等、失败记录和后续重试逻辑保持不变。
|
||||||
|
- 新增语法树与运行顺序门禁,固定“构造不启动”“绑定后启动”“停止后关服”,并补齐重复启动与重启测试。
|
||||||
|
- 候选328项、纯`app/`导出265项和45项Playwright通过;24个JavaScript文件、API/架构注册表、
|
||||||
|
Git空白检查和SQLite完整性检查通过。
|
||||||
|
- 本批没有可安全删除的重复任务实现;为补齐原先缺失的生命周期,生产代码净增加24行。增加内容仅为
|
||||||
|
调度状态、幂等启停和运行时委托,不新增业务层、任务或兼容包装。
|
||||||
|
- 本批不修改页面、CSS、API、数据源、刷新计算、自动选股条件、数据库结构、权限或LLM。
|
||||||
|
|
||||||
|
本批基线为`xiaobai-reduction-10-repository-ownership-20260801`;检查点为
|
||||||
|
`xiaobai-reduction-11-background-jobs-20260801`。
|
||||||
|
|
||||||
|
## CR-11人工验收修正
|
||||||
|
|
||||||
|
- 2026-08-02人工验收发现本地页面可访问,但行情与LLM同时无法连接。第一原因是验收服务由受限
|
||||||
|
自动化会话启动,子进程继承了禁止外部网络访问的权限;重新在主机正常网络权限下启动后恢复。
|
||||||
|
- 随后的主模型连接测试暴露`LLMServiceMixin`机械迁移时遗漏`validate_text`导入,导致请求在真正
|
||||||
|
访问模型前抛出`NameError`并关闭HTTP连接;恢复原依赖并增加保存模型连接探测的运行契约测试。
|
||||||
|
- 网站自身实测`000001`返回Tushare日K 60根、分时242点;主模型
|
||||||
|
`MiniMax-M2.7-highspeed`在2236毫秒内回复`OK`,证明服务进程的数据与LLM出网链路均已恢复。
|
||||||
|
- 修正后候选329项、纯`app/`导出266项通过;本次只恢复缺失导入和测试,不修改模型配置、额度、
|
||||||
|
提示词、回退策略、行情来源或计算逻辑。
|
||||||
|
- 继续验收观势时发现模型已经成功返回,但问天服务在保存解势记录前关闭了HTTP连接。原因是原版
|
||||||
|
`server.py`已有的`secrets`导入在机械拆分到问天服务时遗漏,生成非观气记录去重键时触发
|
||||||
|
`NameError`。迁移版恢复该标准库依赖,并增加“模型成功返回后保存观势结果”的完整服务回归测试。
|
||||||
|
- 使用`000001 平安银行`完成真实页面复测:六爻安全门6/6通过,解势结果正常返回并写入历史,
|
||||||
|
`8797`错误日志为空。该修正不改变提示词、模型选择、额度、卦象计算、记录结构或前端行为。
|
||||||
|
|
||||||
|
本修正基线为`xiaobai-reduction-11-background-jobs-20260801`;检查点为
|
||||||
|
`xiaobai-reduction-11-runtime-connectivity-fix-20260802`;后续解势修正检查点为
|
||||||
|
`xiaobai-reduction-11-heaven-interpret-fix-20260802`。
|
||||||
|
|
||||||
|
## CR-12验收口径
|
||||||
|
|
||||||
|
- 本批只处理不同样式文件中、同为顶层、选择器与完整声明逐字等价的规则;媒体查询、伪状态、
|
||||||
|
动画、问天隔离样式以及仅外形相似的规则不进入删除范围。
|
||||||
|
- 删除的必须是较早加载的副本,较晚层继续提供完全相同的最终声明;样式加载顺序、变量、HTML、
|
||||||
|
JavaScript和主题切换逻辑均不改变。
|
||||||
|
- 迁移保真测试必须逐段登记允许退休的原始CSS文本,除登记片段外,其余源码继续与原版逐字符相等。
|
||||||
|
- 浏览器必须验证跨层顶层精确重复为零,并通过日间、夜间、桌面、390px移动端及全站交互回归。
|
||||||
|
|
||||||
|
## CR-12结果
|
||||||
|
|
||||||
|
- 通过浏览器CSSOM扫描七层运行样式,共发现57组完整重复规则;本批只批准其中7组跨文件顶层重复,
|
||||||
|
分别涉及工作区显示、折叠侧栏、板块轮动末列、选股概率值、摘要条两项声明及龙虎榜原因列。
|
||||||
|
其余50组位于同文件或嵌套媒体条件等更复杂环境,证据不足,继续保留。
|
||||||
|
- 删除7条较早加载的规则,三个生产CSS文件净减少19行、480字节;后层最终规则、选择器优先级与
|
||||||
|
加载顺序均未改变,没有新增兼容覆盖或第二套样式实现。
|
||||||
|
- 新增浏览器CSSOM门禁,任何两个样式层再次出现相同顶层选择器与完整声明都会失败;迁移保真门禁
|
||||||
|
只允许已登记的7个精确源码片段退休,其他CSS差异仍会失败。
|
||||||
|
- 真实`8797`页面复核情绪周期日间/夜间、龙虎榜和390×844移动端;三个受影响节点的计算样式
|
||||||
|
与删除前一致,移动端无横向溢出。候选330项、CSS/前端契约33项、迁移对照63项及46项
|
||||||
|
Playwright全部通过,24个JavaScript文件、API/架构注册表和SQLite完整性检查通过。
|
||||||
|
- 本批不修改页面布局、颜色、字体、间距、响应式规则、主题、动画、业务功能、API、数据库或部署。
|
||||||
|
|
||||||
|
本批基线为`xiaobai-reduction-11-heaven-interpret-fix-20260802`;检查点为
|
||||||
|
`xiaobai-reduction-12-css-exact-duplicates-20260802`。
|
||||||
|
|
||||||
|
## CR-13验收口径
|
||||||
|
|
||||||
|
- 本批只处理不同样式文件中、处于浏览器规范化后完全相同媒体条件下、选择器与完整CSSOM声明完全
|
||||||
|
相同的规则;不同媒体上下文、同文件重复、近似声明、动画和问天隔离样式继续保留。
|
||||||
|
- 删除的必须是较早加载的副本,较晚样式层继续提供相同声明;媒体条件、规则顺序、选择器优先级、
|
||||||
|
变量、HTML、JavaScript和主题逻辑不得改变。
|
||||||
|
- 保真门禁必须逐段登记允许退休的原始源码;浏览器门禁必须递归遍历嵌套规则,并只将同一上下文内
|
||||||
|
跨文件的完整重复判为失败。
|
||||||
|
- 390×844明暗主题、1000×800中等宽度和1000×600低高度断点必须保持原计算样式与视觉结果。
|
||||||
|
|
||||||
|
## CR-13结果
|
||||||
|
|
||||||
|
- 浏览器CSSOM确认22组跨文件嵌套重复:1组位于721-1279px媒体条件,12组位于720px移动端条件,
|
||||||
|
9组位于720px或1023px低高度复合条件;全部删除较早层副本,后层规则原样保留。
|
||||||
|
- `styles.css`减少65行,`redesign-v2.css`减少15行,生产CSS合计净减少80行、约1.9 KB;没有新增
|
||||||
|
兼容覆盖、声明值、选择器或样式文件。
|
||||||
|
- Playwright门禁由顶层扫描扩展为递归上下文扫描,修改后同一嵌套上下文的跨文件完整重复为0;同文件
|
||||||
|
重复和不同上下文规则不在本批范围,未被误删。
|
||||||
|
- 1000×800和1000×600修改前后截图逐字节一致;390×844明暗主题的关键显示、定位、间距、网格、
|
||||||
|
溢出和导航状态一致,页面目视无差异。
|
||||||
|
- 候选330项、CSS/前端契约33项、迁移对照63项及46项Playwright全部通过;24个JavaScript文件、
|
||||||
|
API/架构注册表和SQLite完整性检查通过。
|
||||||
|
- 本批不修改页面布局、颜色、字体、间距、主题、动画、业务功能、API、数据库、数据源、LLM或部署。
|
||||||
|
|
||||||
|
本批基线为`xiaobai-reduction-12-css-exact-duplicates-20260802`;检查点为
|
||||||
|
`xiaobai-reduction-13-css-nested-duplicates-20260802`。
|
||||||
|
|
||||||
|
## 人工验收记录
|
||||||
|
|
||||||
|
- 2026-08-01:用户检查CR-02与CR-03运行结果,确认未发现明显异常。本记录仅表示本轮可见功能与
|
||||||
|
页面使用未发现明显回归,不替代后续批次各自的自动测试和人工抽查。
|
||||||
|
|||||||
Reference in New Issue
Block a user