This commit is contained in:
@@ -100,6 +100,7 @@
|
||||
- Phase 45 migration live smoke preview:新增 `/api/market_intel/migration_live_smoke` 與 UI「正式 DB 只讀 smoke」panel;預設 `execute=false` 只回 planned,人工 smoke 才可用 `execute=true` 整理 catalog / seed diff 結果,不執行 migration、不寫 DB、不跑 rollback、不掛 scheduler;版本同步至 V10.207。
|
||||
- Phase 46 live DB inventory preview:新增 `/api/market_intel/live_db_inventory` 與 UI「正式 DB 庫存總覽」panel;預設 `execute=false` 不連 DB,人工 smoke 才可用 `execute=true` 對 `market_*` tables 做只讀 count / group by,建立平台、活動、商品、比對、告警與 crawler run 基準;版本同步至 V10.209。
|
||||
- Phase 47 manual sample fetch plan:新增 `/api/market_intel/manual_sample_plan` 與 UI「人工樣本 Fetch 計畫」panel;預設只輸出平台順序、每平台 1 個公開入口、MCP gate、操作員步驟與備援,不抓外站、不寫 DB、不建立 crawler run、不掛 scheduler;版本同步至 V10.214。
|
||||
- Phase 48 manual sample acceptance contract:新增 `/api/market_intel/manual_sample_acceptance` 與 UI「樣本結果驗收契約」panel;定義 sample result 必要欄位、diagnostics 欄位、驗收門檻、拒收條件、人工決策與升級順序,不載入 sample result、不抓外站、不允許候選導入、不寫 DB;版本同步至 V10.215。
|
||||
- Schema smoke:`tests/test_market_intel_skeleton.py` 檢查 `Base.metadata` 內含 ADR-035 八張 `market_*` tables。
|
||||
- Desktop UI QA:本機只註冊 `market_intel_bp` 的 Flask harness 載入 `/market_intel`,確認 Phase 15、候選預覽、writer preview、安全 flags、點陣暖紙視覺正常,console error 0。
|
||||
- API QA:`/api/market_intel/schema_smoke` 通過 7 張表與 `market_platforms` 必要欄位檢查;`/api/market_intel/platform_seed_writer_plan` 回傳 4 筆 dry-run upsert preview,`writes_executed=false`,四平台皆 `blocked_dry_run_only`。
|
||||
|
||||
@@ -173,6 +173,7 @@ EwoooC 目前已有 MOMO EDM / 節慶活動資料、`promo_products`、PChome
|
||||
- 2026-05-18 追加 migration live smoke preview:`services.market_intel.migration_live_smoke` 與 `/api/market_intel/migration_live_smoke` 將 `execute=true` 的正式 DB 只讀探測整理成 smoke result,例如 `passed_not_applied_seed_table_missing`、`attention_partial_schema`、`passed_already_applied` 或 `failed_catalog_probe_error`。UI 預設仍只呼叫 `execute=false`;人工 smoke 可用 `execute=true` 只讀查 catalog,不執行 migration、不寫 DB、不跑 rollback、不掛 scheduler。
|
||||
- 2026-05-18 追加 live DB inventory preview:`services.market_intel.live_db_inventory` 與 `/api/market_intel/live_db_inventory` 預設 `execute=false` 只回 planned,不連 DB;人工 smoke 可用 `execute=true` 對 `market_*` tables 執行只讀 count / group by,產生平台、活動狀態、商品活躍度、比對狀態、告警審核佇列與 crawler run 基準總覽。此探針不建立 ORM session、不寫 DB、不執行 migration、不連外、不掛 scheduler。
|
||||
- 2026-05-19 追加 manual sample fetch plan preview:`services.market_intel.manual_sample_plan` 與 `/api/market_intel/manual_sample_plan` 定義第一次人工 sample fetch 的平台順序、每平台 1 個公開入口、MCP fetch gate、正式 DB 庫存基準、操作員步驟與備援。此階段只產生計畫,不抓外部網站、不寫 DB、不建立 crawler run、不掛 scheduler、不繞反爬。
|
||||
- 2026-05-19 追加 manual sample acceptance contract:`services.market_intel.manual_sample_acceptance` 與 `/api/market_intel/manual_sample_acceptance` 定義 sample fetch 結果回來後的必要欄位、診斷欄位、驗收門檻、拒收條件、人工決策與升級順序。此階段不載入 sample result、不抓外部網站、不允許候選導入、不寫 DB、不掛 scheduler。
|
||||
|
||||
### Phase 4:Coupang / Shopee Adapter
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
| `edm_routes.py` | EDM 與節慶儀表板 | `/edm`, `/festival` |
|
||||
| `monthly_routes.py` | 月結分析 | `/monthly_summary_analysis`, `/api/monthly_summary_data` |
|
||||
| `daily_sales_routes.py` | 當日業績 | `/daily_sales`, `/daily_sales/export*` |
|
||||
| `market_intel_routes.py` | 市場情報 Phase 47 manual sample fetch plan | `/market_intel`, `/market_intel/*`, `/api/market_intel/status`, `/api/market_intel/schema`, `/api/market_intel/schema_smoke`, `/api/market_intel/schema_db_probe`, `/api/market_intel/platform_seed_db_diff`, `/api/market_intel/legacy_source_bridge`, `/api/market_intel/mcp_readiness`, `/api/market_intel/mcp_tool_contract`, `/api/market_intel/mcp_deploy_preflight`, `/api/market_intel/mcp_activation_runbook`, `/api/market_intel/mcp_fetch_gate`, `/api/market_intel/scheduler_plan`, `/api/market_intel/manual_sample_plan`, `/api/market_intel/match_review_plan`, `/api/market_intel/opportunity_plan`, `/api/market_intel/opportunity_scoring_plan`, `/api/market_intel/opportunity_evidence_plan`, `/api/market_intel/opportunity_alert_plan`, `/api/market_intel/adapters`, `/api/market_intel/dry_run_plan`, `/api/market_intel/discovery_plan`, `/api/market_intel/manual_discovery`, `/api/market_intel/candidate_preview`, `/api/market_intel/platform_seed_plan`, `/api/market_intel/platform_seed_write_guard`, `/api/market_intel/platform_seed_writer_plan`, `/api/market_intel/migration_blueprint`, `/api/market_intel/migration_apply_drill`, `/api/market_intel/migration_catalog_review`, `/api/market_intel/migration_live_smoke`, `/api/market_intel/live_db_inventory`, `/api/market_intel/seed_writer_cli_status`, `/api/market_intel/write_approval_runbook`, `/api/market_intel/deployment_readiness` |
|
||||
| `market_intel_routes.py` | 市場情報 Phase 48 manual sample acceptance contract | `/market_intel`, `/market_intel/*`, `/api/market_intel/status`, `/api/market_intel/schema`, `/api/market_intel/schema_smoke`, `/api/market_intel/schema_db_probe`, `/api/market_intel/platform_seed_db_diff`, `/api/market_intel/legacy_source_bridge`, `/api/market_intel/mcp_readiness`, `/api/market_intel/mcp_tool_contract`, `/api/market_intel/mcp_deploy_preflight`, `/api/market_intel/mcp_activation_runbook`, `/api/market_intel/mcp_fetch_gate`, `/api/market_intel/scheduler_plan`, `/api/market_intel/manual_sample_plan`, `/api/market_intel/manual_sample_acceptance`, `/api/market_intel/match_review_plan`, `/api/market_intel/opportunity_plan`, `/api/market_intel/opportunity_scoring_plan`, `/api/market_intel/opportunity_evidence_plan`, `/api/market_intel/opportunity_alert_plan`, `/api/market_intel/adapters`, `/api/market_intel/dry_run_plan`, `/api/market_intel/discovery_plan`, `/api/market_intel/manual_discovery`, `/api/market_intel/candidate_preview`, `/api/market_intel/platform_seed_plan`, `/api/market_intel/platform_seed_write_guard`, `/api/market_intel/platform_seed_writer_plan`, `/api/market_intel/migration_blueprint`, `/api/market_intel/migration_apply_drill`, `/api/market_intel/migration_catalog_review`, `/api/market_intel/migration_live_smoke`, `/api/market_intel/live_db_inventory`, `/api/market_intel/seed_writer_cli_status`, `/api/market_intel/write_approval_runbook`, `/api/market_intel/deployment_readiness` |
|
||||
| `api_routes.py` | 通用任務與查詢 API | `/api/run_task`, `/api/history/*` |
|
||||
| `export_routes.py` | 匯出功能 | `/api/export/*` |
|
||||
| `import_routes.py` | 匯入功能 | `/api/import_excel`, `/api/import/monthly_summary` |
|
||||
|
||||
@@ -163,6 +163,12 @@ def market_intel_manual_sample_plan():
|
||||
return jsonify(_service().build_manual_sample_plan())
|
||||
|
||||
|
||||
@market_intel_bp.route("/api/market_intel/manual_sample_acceptance")
|
||||
@login_required
|
||||
def market_intel_manual_sample_acceptance():
|
||||
return jsonify(_service().build_manual_sample_acceptance())
|
||||
|
||||
|
||||
@market_intel_bp.route("/api/market_intel/match_review_plan")
|
||||
@login_required
|
||||
def market_intel_match_review_plan():
|
||||
|
||||
@@ -19,6 +19,7 @@ def build_deployment_readiness_preview(
|
||||
mcp_fetch_gate = service.build_mcp_fetch_gate()
|
||||
scheduler_plan = service.build_scheduler_plan()
|
||||
manual_sample_plan = service.build_manual_sample_plan()
|
||||
manual_sample_acceptance = service.build_manual_sample_acceptance()
|
||||
match_review_plan = service.build_match_review_plan()
|
||||
opportunity_plan = service.build_opportunity_plan()
|
||||
opportunity_scoring_plan = service.build_opportunity_scoring_plan()
|
||||
@@ -86,6 +87,15 @@ def build_deployment_readiness_preview(
|
||||
and not manual_sample_plan["database_commit_executed"]
|
||||
and not manual_sample_plan["scheduler_attached"]
|
||||
),
|
||||
"manual_sample_acceptance_preview_safe": bool(
|
||||
manual_sample_acceptance["mode"] == "manual_sample_acceptance_preview"
|
||||
and not manual_sample_acceptance["sample_result_loaded"]
|
||||
and not manual_sample_acceptance["candidate_import_allowed"]
|
||||
and not manual_sample_acceptance["external_network_executed"]
|
||||
and not manual_sample_acceptance["database_write_executed"]
|
||||
and not manual_sample_acceptance["database_commit_executed"]
|
||||
and not manual_sample_acceptance["scheduler_attached"]
|
||||
),
|
||||
"match_review_plan_preview_safe": bool(
|
||||
match_review_plan["mode"] == "match_review_plan_preview"
|
||||
and not match_review_plan["review_queue_created"]
|
||||
@@ -289,6 +299,7 @@ def build_deployment_readiness_preview(
|
||||
"/api/market_intel/mcp_fetch_gate",
|
||||
"/api/market_intel/scheduler_plan",
|
||||
"/api/market_intel/manual_sample_plan",
|
||||
"/api/market_intel/manual_sample_acceptance",
|
||||
"/api/market_intel/match_review_plan",
|
||||
"/api/market_intel/opportunity_plan",
|
||||
"/api/market_intel/opportunity_scoring_plan",
|
||||
@@ -323,6 +334,7 @@ def build_deployment_readiness_preview(
|
||||
"mcp_fetch_gate": mcp_fetch_gate,
|
||||
"scheduler_plan": scheduler_plan,
|
||||
"manual_sample_plan": manual_sample_plan,
|
||||
"manual_sample_acceptance": manual_sample_acceptance,
|
||||
"match_review_plan": match_review_plan,
|
||||
"opportunity_plan": opportunity_plan,
|
||||
"opportunity_scoring_plan": opportunity_scoring_plan,
|
||||
|
||||
160
services/market_intel/manual_sample_acceptance.py
Normal file
160
services/market_intel/manual_sample_acceptance.py
Normal file
@@ -0,0 +1,160 @@
|
||||
"""市場情報人工 sample fetch 結果驗收契約。
|
||||
|
||||
本模組只定義第一次 sample fetch 回來後的驗收欄位、門檻與人工決策;
|
||||
不讀外部網站、不查 DB、不寫 DB、不掛排程。
|
||||
"""
|
||||
|
||||
|
||||
REQUIRED_RESULT_FIELDS = (
|
||||
"batch_id",
|
||||
"platform_code",
|
||||
"source_key",
|
||||
"source_url",
|
||||
"status",
|
||||
"status_code",
|
||||
"content_length",
|
||||
"page_hash",
|
||||
"title",
|
||||
"diagnostics",
|
||||
)
|
||||
|
||||
REQUIRED_DIAGNOSTIC_FIELDS = (
|
||||
"link_count",
|
||||
"same_host_link_count",
|
||||
"campaign_link_candidates",
|
||||
)
|
||||
|
||||
|
||||
def build_manual_sample_acceptance_preview(*, runtime_status, manual_sample_plan):
|
||||
"""建立人工樣本結果驗收契約;不載入 sample result。"""
|
||||
gate_checks = {
|
||||
"manual_sample_plan_present": bool(manual_sample_plan),
|
||||
"sample_fetch_not_executed_by_api": not bool(
|
||||
manual_sample_plan.get("sample_fetch_executed")
|
||||
),
|
||||
"external_network_blocked_in_preview": not bool(
|
||||
manual_sample_plan.get("external_network_executed")
|
||||
),
|
||||
"database_write_still_blocked": not bool(
|
||||
getattr(runtime_status, "database_write_allowed", False)
|
||||
),
|
||||
"scheduler_detached": not bool(
|
||||
getattr(runtime_status, "scheduler_attached", False)
|
||||
),
|
||||
}
|
||||
blocked_reasons = [
|
||||
key for key, passed in gate_checks.items()
|
||||
if not passed
|
||||
]
|
||||
blocked_reasons.extend(
|
||||
[
|
||||
"sample_result_not_loaded",
|
||||
"manual_review_required_before_import",
|
||||
]
|
||||
)
|
||||
|
||||
return {
|
||||
"mode": "manual_sample_acceptance_preview",
|
||||
"contract_ready": True,
|
||||
"sample_result_loaded": False,
|
||||
"sample_result_accepted": False,
|
||||
"candidate_import_allowed": False,
|
||||
"external_network_executed": False,
|
||||
"database_connection_opened": False,
|
||||
"database_session_created": False,
|
||||
"database_write_executed": False,
|
||||
"database_commit_executed": False,
|
||||
"scheduler_attached": False,
|
||||
"writes_executed": False,
|
||||
"would_write_database": False,
|
||||
"gate_checks": gate_checks,
|
||||
"blocked_reasons": blocked_reasons,
|
||||
"required_result_fields": list(REQUIRED_RESULT_FIELDS),
|
||||
"required_diagnostic_fields": list(REQUIRED_DIAGNOSTIC_FIELDS),
|
||||
"acceptance_thresholds": {
|
||||
"http_status_min": 200,
|
||||
"http_status_max": 299,
|
||||
"minimum_content_length": 500,
|
||||
"page_hash_length": 64,
|
||||
"minimum_title_length": 2,
|
||||
"minimum_link_count": 1,
|
||||
"minimum_campaign_candidates": 1,
|
||||
"accepted_candidate_bands": ["high", "medium"],
|
||||
},
|
||||
"acceptance_checks": [
|
||||
{
|
||||
"key": "http_status_ok",
|
||||
"label": "HTTP status 必須為 2xx,redirect / 403 / 429 / 5xx 都不得進入候選導入",
|
||||
"status": "not_evaluated",
|
||||
},
|
||||
{
|
||||
"key": "content_has_body",
|
||||
"label": "content_length 必須超過最低門檻,避免只拿到 bot challenge 或空頁",
|
||||
"status": "not_evaluated",
|
||||
},
|
||||
{
|
||||
"key": "page_fingerprint_present",
|
||||
"label": "page_hash 必須存在,後續才能追蹤同頁變化",
|
||||
"status": "not_evaluated",
|
||||
},
|
||||
{
|
||||
"key": "parser_diagnostics_present",
|
||||
"label": "diagnostics 必須包含 title、link_count 與 campaign_link_candidates",
|
||||
"status": "not_evaluated",
|
||||
},
|
||||
{
|
||||
"key": "candidate_quality_reviewed",
|
||||
"label": "至少 1 筆 high/medium 候選需經人工確認,才可進入候選活動審核",
|
||||
"status": "not_evaluated",
|
||||
},
|
||||
],
|
||||
"reject_conditions": [
|
||||
{
|
||||
"key": "anti_bot_or_login_wall",
|
||||
"label": "頁面出現登入牆、驗證碼、bot challenge、會員頁或購物車內容",
|
||||
},
|
||||
{
|
||||
"key": "unexpected_personal_data",
|
||||
"label": "頁面含非公開個資、帳號資料或訂單資訊",
|
||||
},
|
||||
{
|
||||
"key": "too_many_failures",
|
||||
"label": "同平台樣本連續失敗時,不做快速重試,先回頭審查 adapter 入口",
|
||||
},
|
||||
{
|
||||
"key": "no_campaign_candidates",
|
||||
"label": "沒有任何 high/medium campaign candidate 時,不建立活動候選",
|
||||
},
|
||||
],
|
||||
"operator_decisions": [
|
||||
{
|
||||
"key": "approve_candidate_preview",
|
||||
"label": "樣本可進入候選活動人工審核,但仍不得寫 market_campaigns",
|
||||
"write_status": "blocked",
|
||||
},
|
||||
{
|
||||
"key": "revise_adapter_source",
|
||||
"label": "入口不適合時,調整 adapter source 後重新跑單一樣本",
|
||||
"write_status": "blocked",
|
||||
},
|
||||
{
|
||||
"key": "reject_platform_for_now",
|
||||
"label": "平台風險或阻擋過高時,暫停該平台,只保留其他平台預覽",
|
||||
"write_status": "blocked",
|
||||
},
|
||||
],
|
||||
"promotion_sequence": [
|
||||
"先把 sample result 與 diagnostics 以人工方式審核",
|
||||
"通過後只開 candidate preview,不建立正式 campaign/product",
|
||||
"累積至少 2 個平台樣本通過後,再設計候選活動審核資料流",
|
||||
"任何寫入 market_* 前仍需獨立 approval 與 rollback plan",
|
||||
],
|
||||
"safe_boundaries": [
|
||||
"do_not_accept_login_or_member_pages",
|
||||
"do_not_accept_anti_bot_challenge_pages",
|
||||
"do_not_import_candidates_without_human_review",
|
||||
"do_not_write_market_tables_from_acceptance_preview",
|
||||
"do_not_attach_scheduler_from_sample_result",
|
||||
"do_not_touch_momo_db_lifecycle",
|
||||
],
|
||||
}
|
||||
@@ -33,6 +33,9 @@ from services.market_intel.mcp_readiness import build_mcp_readiness_plan
|
||||
from services.market_intel.manual_sample_plan import (
|
||||
build_manual_sample_fetch_plan_preview,
|
||||
)
|
||||
from services.market_intel.manual_sample_acceptance import (
|
||||
build_manual_sample_acceptance_preview,
|
||||
)
|
||||
from services.market_intel.migration_blueprint import build_migration_blueprint
|
||||
from services.market_intel.migration_catalog_review import (
|
||||
build_migration_catalog_review_preview,
|
||||
@@ -95,7 +98,7 @@ class MarketIntelRuntimeStatus:
|
||||
class MarketIntelService:
|
||||
"""市場情報入口服務,先集中 feature gate 與安全狀態。"""
|
||||
|
||||
phase = "phase_47_manual_sample_fetch_plan"
|
||||
phase = "phase_48_manual_sample_acceptance_contract"
|
||||
|
||||
def get_runtime_status(self) -> MarketIntelRuntimeStatus:
|
||||
return MarketIntelRuntimeStatus(
|
||||
@@ -435,6 +438,15 @@ class MarketIntelService:
|
||||
plan["phase"] = self.phase
|
||||
return plan
|
||||
|
||||
def build_manual_sample_acceptance(self):
|
||||
"""回報人工 sample result 驗收契約;不載入外部結果、不寫 DB。"""
|
||||
acceptance = build_manual_sample_acceptance_preview(
|
||||
runtime_status=self.get_runtime_status(),
|
||||
manual_sample_plan=self.build_manual_sample_plan(),
|
||||
)
|
||||
acceptance["phase"] = self.phase
|
||||
return acceptance
|
||||
|
||||
def build_match_review_plan(self):
|
||||
"""回報商品比對審核計畫;不建立 queue、不自動確認。"""
|
||||
schema_smoke = self.build_schema_smoke()
|
||||
|
||||
@@ -504,6 +504,24 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="market-intel-panel" data-market-intel-sample-acceptance>
|
||||
<div class="market-intel-preview-head">
|
||||
<div>
|
||||
<p class="market-intel-muted momo-mono mb-1">MANUAL SAMPLE / ACCEPTANCE</p>
|
||||
<h2 class="market-intel-preview-title">樣本結果驗收契約</h2>
|
||||
</div>
|
||||
<button class="market-intel-icon-button" type="button" title="重新整理樣本結果驗收契約" data-market-intel-sample-acceptance-refresh>
|
||||
<i class="fas fa-rotate-right" aria-hidden="true"></i>
|
||||
</button>
|
||||
</div>
|
||||
<div class="market-intel-preview-meta" data-market-intel-sample-acceptance-meta>
|
||||
<span class="market-intel-pill">loading</span>
|
||||
</div>
|
||||
<div data-market-intel-sample-acceptance-body>
|
||||
<div class="market-intel-empty">讀取樣本結果驗收契約中...</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="market-intel-panel" data-market-intel-scheduler>
|
||||
<div class="market-intel-preview-head">
|
||||
<div>
|
||||
@@ -754,6 +772,7 @@
|
||||
const mcpActivationRoot = document.querySelector('[data-market-intel-mcp-activation]');
|
||||
const mcpFetchGateRoot = document.querySelector('[data-market-intel-mcp-fetch-gate]');
|
||||
const manualSampleRoot = document.querySelector('[data-market-intel-manual-sample]');
|
||||
const sampleAcceptanceRoot = document.querySelector('[data-market-intel-sample-acceptance]');
|
||||
const schedulerRoot = document.querySelector('[data-market-intel-scheduler]');
|
||||
const matchReviewRoot = document.querySelector('[data-market-intel-match-review]');
|
||||
const opportunityRoot = document.querySelector('[data-market-intel-opportunity]');
|
||||
@@ -767,7 +786,7 @@
|
||||
const liveInventoryRoot = document.querySelector('[data-market-intel-live-inventory]');
|
||||
const approvalRoot = document.querySelector('[data-market-intel-approval]');
|
||||
const deployRoot = document.querySelector('[data-market-intel-deploy]');
|
||||
if (!root && !writerRoot && !cliRoot && !dbProbeRoot && !seedDiffRoot && !legacyBridgeRoot && !mcpReadinessRoot && !mcpPreflightRoot && !mcpActivationRoot && !mcpFetchGateRoot && !manualSampleRoot && !schedulerRoot && !matchReviewRoot && !opportunityRoot && !opportunityScoringRoot && !opportunityEvidenceRoot && !opportunityAlertRoot && !migrationRoot && !migrationDrillRoot && !catalogReviewRoot && !liveSmokeRoot && !liveInventoryRoot && !approvalRoot && !deployRoot) return;
|
||||
if (!root && !writerRoot && !cliRoot && !dbProbeRoot && !seedDiffRoot && !legacyBridgeRoot && !mcpReadinessRoot && !mcpPreflightRoot && !mcpActivationRoot && !mcpFetchGateRoot && !manualSampleRoot && !sampleAcceptanceRoot && !schedulerRoot && !matchReviewRoot && !opportunityRoot && !opportunityScoringRoot && !opportunityEvidenceRoot && !opportunityAlertRoot && !migrationRoot && !migrationDrillRoot && !catalogReviewRoot && !liveSmokeRoot && !liveInventoryRoot && !approvalRoot && !deployRoot) return;
|
||||
|
||||
const meta = root ? root.querySelector('[data-market-intel-preview-meta]') : null;
|
||||
const body = root ? root.querySelector('[data-market-intel-preview-body]') : null;
|
||||
@@ -813,6 +832,10 @@
|
||||
const manualSampleBody = manualSampleRoot ? manualSampleRoot.querySelector('[data-market-intel-manual-sample-body]') : null;
|
||||
const manualSampleRefresh = manualSampleRoot ? manualSampleRoot.querySelector('[data-market-intel-manual-sample-refresh]') : null;
|
||||
const manualSampleEndpoint = "{{ url_for('market_intel.market_intel_manual_sample_plan') }}";
|
||||
const sampleAcceptanceMeta = sampleAcceptanceRoot ? sampleAcceptanceRoot.querySelector('[data-market-intel-sample-acceptance-meta]') : null;
|
||||
const sampleAcceptanceBody = sampleAcceptanceRoot ? sampleAcceptanceRoot.querySelector('[data-market-intel-sample-acceptance-body]') : null;
|
||||
const sampleAcceptanceRefresh = sampleAcceptanceRoot ? sampleAcceptanceRoot.querySelector('[data-market-intel-sample-acceptance-refresh]') : null;
|
||||
const sampleAcceptanceEndpoint = "{{ url_for('market_intel.market_intel_manual_sample_acceptance') }}";
|
||||
const schedulerMeta = schedulerRoot ? schedulerRoot.querySelector('[data-market-intel-scheduler-meta]') : null;
|
||||
const schedulerBody = schedulerRoot ? schedulerRoot.querySelector('[data-market-intel-scheduler-body]') : null;
|
||||
const schedulerRefresh = schedulerRoot ? schedulerRoot.querySelector('[data-market-intel-scheduler-refresh]') : null;
|
||||
@@ -1669,6 +1692,123 @@
|
||||
}
|
||||
};
|
||||
|
||||
const renderSampleAcceptanceMeta = data => {
|
||||
sampleAcceptanceMeta.innerHTML = [
|
||||
`mode=${data.mode || 'unknown'}`,
|
||||
`contract=${data.contract_ready ? 'ready' : 'blocked'}`,
|
||||
`loaded=${data.sample_result_loaded ? 'yes' : 'no'}`,
|
||||
`accepted=${data.sample_result_accepted ? 'yes' : 'no'}`,
|
||||
`import=${data.candidate_import_allowed ? 'allow' : 'blocked'}`
|
||||
].map(item => `<span class="market-intel-pill">${escapeHtml(item)}</span>`).join('');
|
||||
};
|
||||
|
||||
const renderSampleAcceptanceBody = data => {
|
||||
const blockers = (data.blocked_reasons || []).join(' / ');
|
||||
const checks = Object.entries(data.gate_checks || {});
|
||||
const acceptance = data.acceptance_checks || [];
|
||||
const reject = data.reject_conditions || [];
|
||||
const decisions = data.operator_decisions || [];
|
||||
const sequence = data.promotion_sequence || [];
|
||||
const boundaries = data.safe_boundaries || [];
|
||||
const thresholds = data.acceptance_thresholds || {};
|
||||
const renderCheck = ([name, passed]) => `
|
||||
<div class="market-intel-check">
|
||||
<div>
|
||||
<strong>${escapeHtml(name)}</strong>
|
||||
</div>
|
||||
<span>${passed ? 'PASS' : 'BLOCK'}</span>
|
||||
</div>
|
||||
`;
|
||||
const renderNamedItem = (item, status) => {
|
||||
const normalized = typeof item === 'string' ? { key: item, label: item } : (item || {});
|
||||
return `
|
||||
<div class="market-intel-check">
|
||||
<div>
|
||||
<strong>${escapeHtml(normalized.key || normalized.label || 'item')}</strong>
|
||||
<small>${escapeHtml(normalized.label || normalized.key || '')}</small>
|
||||
</div>
|
||||
<span>${escapeHtml(normalized.status || status || 'required').toUpperCase()}</span>
|
||||
</div>
|
||||
`;
|
||||
};
|
||||
sampleAcceptanceBody.innerHTML = `
|
||||
<div class="market-intel-empty mb-3">此卡只定義 sample fetch 回來後的驗收契約;不載入 sample result、不抓外站、不寫 DB、不建立候選活動。${blockers ? `阻擋:${escapeHtml(blockers)}` : ''}</div>
|
||||
<div class="market-intel-empty mb-3">required_fields=${escapeHtml((data.required_result_fields || []).length)} / diagnostics=${escapeHtml((data.required_diagnostic_fields || []).length)} / min_candidates=${escapeHtml(thresholds.minimum_campaign_candidates || 0)} / bands=${escapeHtml((thresholds.accepted_candidate_bands || []).join('/'))}</div>
|
||||
<div class="market-intel-deploy-grid">
|
||||
<div data-market-intel-sample-acceptance-checks>
|
||||
<p class="market-intel-deploy-section-title">CONTRACT GATES</p>
|
||||
<div class="market-intel-check-list">${
|
||||
checks.length
|
||||
? checks.map(renderCheck).join('')
|
||||
: '<div class="market-intel-empty">尚未提供 contract gate。</div>'
|
||||
}</div>
|
||||
</div>
|
||||
<div data-market-intel-sample-acceptance-fields>
|
||||
<p class="market-intel-deploy-section-title">REQUIRED FIELDS</p>
|
||||
<div class="market-intel-check-list">${
|
||||
(data.required_result_fields || []).map(item => renderNamedItem(String(item), 'required')).join('')
|
||||
|| '<div class="market-intel-empty">尚未提供欄位契約。</div>'
|
||||
}</div>
|
||||
</div>
|
||||
<div data-market-intel-sample-acceptance-rules>
|
||||
<p class="market-intel-deploy-section-title">ACCEPTANCE RULES</p>
|
||||
<div class="market-intel-check-list">${
|
||||
acceptance.length
|
||||
? acceptance.map(item => renderNamedItem(item, 'not_evaluated')).join('')
|
||||
: '<div class="market-intel-empty">尚未提供驗收規則。</div>'
|
||||
}</div>
|
||||
</div>
|
||||
<div data-market-intel-sample-acceptance-reject>
|
||||
<p class="market-intel-deploy-section-title">REJECT CONDITIONS</p>
|
||||
<div class="market-intel-check-list">${
|
||||
reject.length
|
||||
? reject.map(item => renderNamedItem(item, 'reject')).join('')
|
||||
: '<div class="market-intel-empty">尚未提供拒收條件。</div>'
|
||||
}</div>
|
||||
</div>
|
||||
<div data-market-intel-sample-acceptance-decisions>
|
||||
<p class="market-intel-deploy-section-title">OPERATOR DECISIONS</p>
|
||||
<div class="market-intel-check-list">${
|
||||
decisions.length
|
||||
? decisions.map(item => renderNamedItem(item, item.write_status || 'blocked')).join('')
|
||||
: '<div class="market-intel-empty">尚未提供人工決策。</div>'
|
||||
}</div>
|
||||
</div>
|
||||
<div data-market-intel-sample-acceptance-sequence>
|
||||
<p class="market-intel-deploy-section-title">PROMOTION SEQUENCE</p>
|
||||
<div class="market-intel-check-list">${
|
||||
sequence.length
|
||||
? sequence.map(item => renderNamedItem(String(item), 'required')).join('')
|
||||
: '<div class="market-intel-empty">尚未提供升級順序。</div>'
|
||||
}</div>
|
||||
</div>
|
||||
<div data-market-intel-sample-acceptance-boundaries>
|
||||
<p class="market-intel-deploy-section-title">BOUNDARIES</p>
|
||||
<div class="market-intel-check-list">${
|
||||
boundaries.length
|
||||
? boundaries.map(item => renderNamedItem(String(item), 'required')).join('')
|
||||
: '<div class="market-intel-empty">尚未提供安全邊界。</div>'
|
||||
}</div>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
};
|
||||
|
||||
const loadSampleAcceptance = async () => {
|
||||
if (!sampleAcceptanceMeta || !sampleAcceptanceBody) return;
|
||||
sampleAcceptanceBody.innerHTML = '<div class="market-intel-empty">讀取樣本結果驗收契約中...</div>';
|
||||
try {
|
||||
const response = await fetch(sampleAcceptanceEndpoint, { credentials: 'same-origin' });
|
||||
if (!response.ok) throw new Error(`HTTP ${response.status}`);
|
||||
const data = await response.json();
|
||||
renderSampleAcceptanceMeta(data);
|
||||
renderSampleAcceptanceBody(data);
|
||||
} catch (error) {
|
||||
sampleAcceptanceMeta.innerHTML = '<span class="market-intel-pill">error</span>';
|
||||
sampleAcceptanceBody.innerHTML = `<div class="market-intel-empty">樣本結果驗收契約讀取失敗:${escapeHtml(error.message)}</div>`;
|
||||
}
|
||||
};
|
||||
|
||||
const renderSchedulerMeta = data => {
|
||||
schedulerMeta.innerHTML = [
|
||||
`mode=${data.mode || 'unknown'}`,
|
||||
@@ -3154,6 +3294,9 @@
|
||||
if (manualSampleRefresh) {
|
||||
manualSampleRefresh.addEventListener('click', loadManualSample);
|
||||
}
|
||||
if (sampleAcceptanceRefresh) {
|
||||
sampleAcceptanceRefresh.addEventListener('click', loadSampleAcceptance);
|
||||
}
|
||||
if (schedulerRefresh) {
|
||||
schedulerRefresh.addEventListener('click', loadScheduler);
|
||||
}
|
||||
@@ -3204,6 +3347,7 @@
|
||||
loadMcpActivation();
|
||||
loadMcpFetchGate();
|
||||
loadManualSample();
|
||||
loadSampleAcceptance();
|
||||
loadScheduler();
|
||||
loadMatchReview();
|
||||
loadOpportunity();
|
||||
|
||||
@@ -506,6 +506,10 @@ def test_market_intel_preview_template_uses_safe_fetch_false_endpoint():
|
||||
assert "data-market-intel-manual-sample-checks" in template
|
||||
assert "data-market-intel-manual-sample-platforms" in template
|
||||
assert "data-market-intel-manual-sample-sequence" in template
|
||||
assert "data-market-intel-sample-acceptance" in template
|
||||
assert "data-market-intel-sample-acceptance-checks" in template
|
||||
assert "data-market-intel-sample-acceptance-fields" in template
|
||||
assert "data-market-intel-sample-acceptance-rules" in template
|
||||
assert "data-market-intel-approval" in template
|
||||
assert "data-market-intel-approval-gates" in template
|
||||
assert "data-market-intel-deploy" in template
|
||||
@@ -522,6 +526,7 @@ def test_market_intel_preview_template_uses_safe_fetch_false_endpoint():
|
||||
assert "market_intel.market_intel_mcp_activation_runbook" in template
|
||||
assert "market_intel.market_intel_mcp_fetch_gate" in template
|
||||
assert "market_intel.market_intel_manual_sample_plan" in template
|
||||
assert "market_intel.market_intel_manual_sample_acceptance" in template
|
||||
assert "market_intel.market_intel_scheduler_plan" in template
|
||||
assert "market_intel.market_intel_match_review_plan" in template
|
||||
assert "market_intel.market_intel_opportunity_plan" in template
|
||||
@@ -557,7 +562,7 @@ def test_legacy_source_bridge_default_is_planned_only():
|
||||
bridge = MarketIntelService().build_legacy_source_bridge()
|
||||
|
||||
assert bridge["mode"] == "legacy_source_bridge_planned"
|
||||
assert bridge["phase"] == "phase_47_manual_sample_fetch_plan"
|
||||
assert bridge["phase"] == "phase_48_manual_sample_acceptance_contract"
|
||||
assert bridge["execute_requested"] is False
|
||||
assert bridge["read_only_query_executed"] is False
|
||||
assert bridge["database_connection_opened"] is False
|
||||
@@ -715,7 +720,7 @@ def test_mcp_tool_contract_preview_is_read_only_and_whitelisted():
|
||||
contract = MarketIntelService().build_mcp_tool_contract()
|
||||
|
||||
assert contract["mode"] == "mcp_tool_contract_preview"
|
||||
assert contract["phase"] == "phase_47_manual_sample_fetch_plan"
|
||||
assert contract["phase"] == "phase_48_manual_sample_acceptance_contract"
|
||||
assert contract["caller"] == "market_intel"
|
||||
assert contract["contract_ready"] is True
|
||||
assert contract["blocked_reasons"] == []
|
||||
@@ -848,7 +853,7 @@ def test_mcp_activation_runbook_route_is_preview_only():
|
||||
|
||||
assert response.status_code == 200
|
||||
assert data["mode"] == "mcp_activation_runbook_preview"
|
||||
assert data["phase"] == "phase_47_manual_sample_fetch_plan"
|
||||
assert data["phase"] == "phase_48_manual_sample_acceptance_contract"
|
||||
assert data["deployment_actions_executed"] is False
|
||||
assert data["docker_command_executed"] is False
|
||||
assert data["ssh_command_executed"] is False
|
||||
@@ -861,7 +866,7 @@ def test_mcp_fetch_gate_default_blocks_external_fetch():
|
||||
gate = MarketIntelService().build_mcp_fetch_gate(fetch_requested=True)
|
||||
|
||||
assert gate["mode"] == "mcp_fetch_gate_planned"
|
||||
assert gate["phase"] == "phase_47_manual_sample_fetch_plan"
|
||||
assert gate["phase"] == "phase_48_manual_sample_acceptance_contract"
|
||||
assert gate["fetch_requested"] is True
|
||||
assert gate["manual_fetch_gate_open"] is False
|
||||
assert gate["network_request_allowed"] is False
|
||||
@@ -931,7 +936,7 @@ def test_mcp_fetch_gate_route_is_preview_only():
|
||||
|
||||
assert response.status_code == 200
|
||||
assert data["mode"] == "mcp_fetch_gate_planned"
|
||||
assert data["phase"] == "phase_47_manual_sample_fetch_plan"
|
||||
assert data["phase"] == "phase_48_manual_sample_acceptance_contract"
|
||||
assert data["fetch_requested"] is False
|
||||
assert data["network_request_allowed"] is False
|
||||
assert data["external_network_executed"] is False
|
||||
@@ -943,7 +948,7 @@ def test_manual_sample_plan_preview_blocks_fetch_and_write():
|
||||
plan = MarketIntelService().build_manual_sample_plan()
|
||||
|
||||
assert plan["mode"] == "manual_sample_fetch_plan_preview"
|
||||
assert plan["phase"] == "phase_47_manual_sample_fetch_plan"
|
||||
assert plan["phase"] == "phase_48_manual_sample_acceptance_contract"
|
||||
assert plan["ready_for_manual_sample_fetch"] is False
|
||||
assert plan["sample_fetch_executed"] is False
|
||||
assert plan["external_network_executed"] is False
|
||||
@@ -991,18 +996,72 @@ def test_manual_sample_plan_route_is_preview_only():
|
||||
|
||||
assert response.status_code == 200
|
||||
assert data["mode"] == "manual_sample_fetch_plan_preview"
|
||||
assert data["phase"] == "phase_47_manual_sample_fetch_plan"
|
||||
assert data["phase"] == "phase_48_manual_sample_acceptance_contract"
|
||||
assert data["sample_fetch_executed"] is False
|
||||
assert data["external_network_executed"] is False
|
||||
assert data["database_write_executed"] is False
|
||||
assert data["scheduler_attached"] is False
|
||||
|
||||
|
||||
def test_manual_sample_acceptance_preview_blocks_candidate_import():
|
||||
acceptance = MarketIntelService().build_manual_sample_acceptance()
|
||||
|
||||
assert acceptance["mode"] == "manual_sample_acceptance_preview"
|
||||
assert acceptance["phase"] == "phase_48_manual_sample_acceptance_contract"
|
||||
assert acceptance["contract_ready"] is True
|
||||
assert acceptance["sample_result_loaded"] is False
|
||||
assert acceptance["sample_result_accepted"] is False
|
||||
assert acceptance["candidate_import_allowed"] is False
|
||||
assert acceptance["external_network_executed"] is False
|
||||
assert acceptance["database_connection_opened"] is False
|
||||
assert acceptance["database_session_created"] is False
|
||||
assert acceptance["database_write_executed"] is False
|
||||
assert acceptance["database_commit_executed"] is False
|
||||
assert acceptance["scheduler_attached"] is False
|
||||
assert acceptance["writes_executed"] is False
|
||||
assert acceptance["would_write_database"] is False
|
||||
assert "sample_result_not_loaded" in acceptance["blocked_reasons"]
|
||||
assert "manual_review_required_before_import" in acceptance["blocked_reasons"]
|
||||
assert "status_code" in acceptance["required_result_fields"]
|
||||
assert "campaign_link_candidates" in acceptance["required_diagnostic_fields"]
|
||||
assert acceptance["acceptance_thresholds"]["minimum_campaign_candidates"] == 1
|
||||
assert acceptance["acceptance_thresholds"]["accepted_candidate_bands"] == ["high", "medium"]
|
||||
assert {item["key"] for item in acceptance["reject_conditions"]} >= {
|
||||
"anti_bot_or_login_wall",
|
||||
"no_campaign_candidates",
|
||||
}
|
||||
assert "do_not_import_candidates_without_human_review" in acceptance["safe_boundaries"]
|
||||
assert "do_not_write_market_tables_from_acceptance_preview" in acceptance["safe_boundaries"]
|
||||
|
||||
|
||||
def test_manual_sample_acceptance_route_is_preview_only():
|
||||
from routes.market_intel_routes import market_intel_bp
|
||||
|
||||
app = Flask(__name__)
|
||||
app.secret_key = "test-secret"
|
||||
app.register_blueprint(market_intel_bp)
|
||||
client = app.test_client()
|
||||
with client.session_transaction() as session:
|
||||
session["logged_in"] = True
|
||||
|
||||
response = client.get("/api/market_intel/manual_sample_acceptance")
|
||||
data = response.get_json()
|
||||
|
||||
assert response.status_code == 200
|
||||
assert data["mode"] == "manual_sample_acceptance_preview"
|
||||
assert data["phase"] == "phase_48_manual_sample_acceptance_contract"
|
||||
assert data["sample_result_loaded"] is False
|
||||
assert data["candidate_import_allowed"] is False
|
||||
assert data["external_network_executed"] is False
|
||||
assert data["database_write_executed"] is False
|
||||
assert data["scheduler_attached"] is False
|
||||
|
||||
|
||||
def test_scheduler_plan_preview_blocks_job_attachment():
|
||||
plan = MarketIntelService().build_scheduler_plan()
|
||||
|
||||
assert plan["mode"] == "scheduler_attach_plan_preview"
|
||||
assert plan["phase"] == "phase_47_manual_sample_fetch_plan"
|
||||
assert plan["phase"] == "phase_48_manual_sample_acceptance_contract"
|
||||
assert plan["ready_to_attach_scheduler"] is False
|
||||
assert plan["scheduler_attached"] is False
|
||||
assert plan["scheduler_registration_executed"] is False
|
||||
@@ -1040,7 +1099,7 @@ def test_scheduler_plan_route_is_preview_only():
|
||||
|
||||
assert response.status_code == 200
|
||||
assert data["mode"] == "scheduler_attach_plan_preview"
|
||||
assert data["phase"] == "phase_47_manual_sample_fetch_plan"
|
||||
assert data["phase"] == "phase_48_manual_sample_acceptance_contract"
|
||||
assert data["scheduler_registration_executed"] is False
|
||||
assert data["crawler_job_started"] is False
|
||||
assert data["external_network_executed"] is False
|
||||
@@ -1051,7 +1110,7 @@ def test_match_review_plan_preview_blocks_auto_confirm():
|
||||
plan = MarketIntelService().build_match_review_plan()
|
||||
|
||||
assert plan["mode"] == "match_review_plan_preview"
|
||||
assert plan["phase"] == "phase_47_manual_sample_fetch_plan"
|
||||
assert plan["phase"] == "phase_48_manual_sample_acceptance_contract"
|
||||
assert plan["ready_for_review_queue"] is False
|
||||
assert plan["review_queue_created"] is False
|
||||
assert plan["auto_match_executed"] is False
|
||||
@@ -1087,7 +1146,7 @@ def test_match_review_plan_route_is_preview_only():
|
||||
|
||||
assert response.status_code == 200
|
||||
assert data["mode"] == "match_review_plan_preview"
|
||||
assert data["phase"] == "phase_47_manual_sample_fetch_plan"
|
||||
assert data["phase"] == "phase_48_manual_sample_acceptance_contract"
|
||||
assert data["review_queue_created"] is False
|
||||
assert data["auto_confirm_executed"] is False
|
||||
assert data["external_network_executed"] is False
|
||||
@@ -1098,7 +1157,7 @@ def test_opportunity_plan_preview_blocks_alerts_and_ai_summary():
|
||||
plan = MarketIntelService().build_opportunity_plan()
|
||||
|
||||
assert plan["mode"] == "opportunity_plan_preview"
|
||||
assert plan["phase"] == "phase_47_manual_sample_fetch_plan"
|
||||
assert plan["phase"] == "phase_48_manual_sample_acceptance_contract"
|
||||
assert plan["ready_for_opportunity_queue"] is False
|
||||
assert plan["opportunity_queue_created"] is False
|
||||
assert plan["threat_alert_dispatched"] is False
|
||||
@@ -1139,7 +1198,7 @@ def test_opportunity_plan_route_is_preview_only():
|
||||
|
||||
assert response.status_code == 200
|
||||
assert data["mode"] == "opportunity_plan_preview"
|
||||
assert data["phase"] == "phase_47_manual_sample_fetch_plan"
|
||||
assert data["phase"] == "phase_48_manual_sample_acceptance_contract"
|
||||
assert data["opportunity_queue_created"] is False
|
||||
assert data["threat_alert_dispatched"] is False
|
||||
assert data["ai_summary_generated"] is False
|
||||
@@ -1150,7 +1209,7 @@ def test_opportunity_scoring_plan_preview_blocks_scoring_and_alerts():
|
||||
plan = MarketIntelService().build_opportunity_scoring_plan()
|
||||
|
||||
assert plan["mode"] == "opportunity_scoring_plan_preview"
|
||||
assert plan["phase"] == "phase_47_manual_sample_fetch_plan"
|
||||
assert plan["phase"] == "phase_48_manual_sample_acceptance_contract"
|
||||
assert plan["ready_for_scoring_job"] is False
|
||||
assert plan["scoring_job_created"] is False
|
||||
assert plan["score_calculation_executed"] is False
|
||||
@@ -1198,7 +1257,7 @@ def test_opportunity_scoring_plan_route_is_preview_only():
|
||||
|
||||
assert response.status_code == 200
|
||||
assert data["mode"] == "opportunity_scoring_plan_preview"
|
||||
assert data["phase"] == "phase_47_manual_sample_fetch_plan"
|
||||
assert data["phase"] == "phase_48_manual_sample_acceptance_contract"
|
||||
assert data["scoring_job_created"] is False
|
||||
assert data["score_calculation_executed"] is False
|
||||
assert data["sample_scores_generated"] is False
|
||||
@@ -1210,7 +1269,7 @@ def test_opportunity_evidence_plan_preview_blocks_queries_and_alerts():
|
||||
plan = MarketIntelService().build_opportunity_evidence_plan()
|
||||
|
||||
assert plan["mode"] == "opportunity_evidence_plan_preview"
|
||||
assert plan["phase"] == "phase_47_manual_sample_fetch_plan"
|
||||
assert plan["phase"] == "phase_48_manual_sample_acceptance_contract"
|
||||
assert plan["ready_for_evidence_bundle"] is False
|
||||
assert plan["evidence_bundle_created"] is False
|
||||
assert plan["evidence_query_executed"] is False
|
||||
@@ -1256,7 +1315,7 @@ def test_opportunity_evidence_plan_route_is_preview_only():
|
||||
|
||||
assert response.status_code == 200
|
||||
assert data["mode"] == "opportunity_evidence_plan_preview"
|
||||
assert data["phase"] == "phase_47_manual_sample_fetch_plan"
|
||||
assert data["phase"] == "phase_48_manual_sample_acceptance_contract"
|
||||
assert data["evidence_bundle_created"] is False
|
||||
assert data["evidence_query_executed"] is False
|
||||
assert data["sample_evidence_generated"] is False
|
||||
@@ -1269,7 +1328,7 @@ def test_opportunity_alert_plan_preview_blocks_dispatch_and_llm_calls():
|
||||
plan = MarketIntelService().build_opportunity_alert_plan()
|
||||
|
||||
assert plan["mode"] == "opportunity_alert_plan_preview"
|
||||
assert plan["phase"] == "phase_47_manual_sample_fetch_plan"
|
||||
assert plan["phase"] == "phase_48_manual_sample_acceptance_contract"
|
||||
assert plan["ready_for_alert_candidates"] is False
|
||||
assert plan["alert_candidate_created"] is False
|
||||
assert plan["alert_queue_created"] is False
|
||||
@@ -1354,7 +1413,7 @@ def test_opportunity_alert_plan_route_is_preview_only():
|
||||
|
||||
assert response.status_code == 200
|
||||
assert data["mode"] == "opportunity_alert_plan_preview"
|
||||
assert data["phase"] == "phase_47_manual_sample_fetch_plan"
|
||||
assert data["phase"] == "phase_48_manual_sample_acceptance_contract"
|
||||
assert data["alert_candidate_created"] is False
|
||||
assert data["alert_queue_created"] is False
|
||||
assert data["review_queue_created"] is False
|
||||
@@ -1432,7 +1491,7 @@ def test_mcp_deploy_preflight_route_is_preview_only():
|
||||
|
||||
assert response.status_code == 200
|
||||
assert data["mode"] == "mcp_external_deploy_preflight_preview"
|
||||
assert data["phase"] == "phase_47_manual_sample_fetch_plan"
|
||||
assert data["phase"] == "phase_48_manual_sample_acceptance_contract"
|
||||
assert data["deployment_actions_executed"] is False
|
||||
assert data["docker_command_executed"] is False
|
||||
assert data["ssh_command_executed"] is False
|
||||
@@ -1447,7 +1506,7 @@ def test_mcp_readiness_default_is_planned_only(monkeypatch):
|
||||
readiness = MarketIntelService().build_mcp_readiness()
|
||||
|
||||
assert readiness["mode"] == "mcp_readiness_planned"
|
||||
assert readiness["phase"] == "phase_47_manual_sample_fetch_plan"
|
||||
assert readiness["phase"] == "phase_48_manual_sample_acceptance_contract"
|
||||
assert readiness["execute_requested"] is False
|
||||
assert readiness["router_enabled"] is False
|
||||
assert readiness["external_mcp_complete"] is False
|
||||
@@ -1836,6 +1895,7 @@ def test_deployment_readiness_reports_app_only_release_gate():
|
||||
assert readiness["checks"]["mcp_fetch_gate_preview_safe"] is True
|
||||
assert readiness["checks"]["scheduler_plan_preview_safe"] is True
|
||||
assert readiness["checks"]["manual_sample_plan_preview_safe"] is True
|
||||
assert readiness["checks"]["manual_sample_acceptance_preview_safe"] is True
|
||||
assert readiness["checks"]["match_review_plan_preview_safe"] is True
|
||||
assert readiness["checks"]["opportunity_plan_preview_safe"] is True
|
||||
assert readiness["checks"]["opportunity_scoring_plan_preview_safe"] is True
|
||||
@@ -1867,6 +1927,7 @@ def test_deployment_readiness_reports_app_only_release_gate():
|
||||
assert "/api/market_intel/mcp_fetch_gate" in readiness["production_smoke_targets"]
|
||||
assert "/api/market_intel/scheduler_plan" in readiness["production_smoke_targets"]
|
||||
assert "/api/market_intel/manual_sample_plan" in readiness["production_smoke_targets"]
|
||||
assert "/api/market_intel/manual_sample_acceptance" in readiness["production_smoke_targets"]
|
||||
assert "/api/market_intel/match_review_plan" in readiness["production_smoke_targets"]
|
||||
assert "/api/market_intel/opportunity_plan" in readiness["production_smoke_targets"]
|
||||
assert "/api/market_intel/opportunity_scoring_plan" in readiness["production_smoke_targets"]
|
||||
@@ -1918,6 +1979,12 @@ def test_deployment_readiness_reports_app_only_release_gate():
|
||||
assert readiness["manual_sample_plan"]["external_network_executed"] is False
|
||||
assert readiness["manual_sample_plan"]["database_write_executed"] is False
|
||||
assert readiness["manual_sample_plan"]["scheduler_attached"] is False
|
||||
assert readiness["manual_sample_acceptance"]["mode"] == "manual_sample_acceptance_preview"
|
||||
assert readiness["manual_sample_acceptance"]["sample_result_loaded"] is False
|
||||
assert readiness["manual_sample_acceptance"]["candidate_import_allowed"] is False
|
||||
assert readiness["manual_sample_acceptance"]["external_network_executed"] is False
|
||||
assert readiness["manual_sample_acceptance"]["database_write_executed"] is False
|
||||
assert readiness["manual_sample_acceptance"]["scheduler_attached"] is False
|
||||
assert readiness["scheduler_plan"]["scheduler_registration_executed"] is False
|
||||
assert readiness["scheduler_plan"]["crawler_job_started"] is False
|
||||
assert readiness["scheduler_plan"]["database_write_executed"] is False
|
||||
@@ -2022,7 +2089,7 @@ def test_migration_apply_drill_planned_is_safe_and_manual_only():
|
||||
drill = MarketIntelService().build_migration_apply_drill()
|
||||
|
||||
assert drill["mode"] == "migration_apply_drill_preview"
|
||||
assert drill["phase"] == "phase_47_manual_sample_fetch_plan"
|
||||
assert drill["phase"] == "phase_48_manual_sample_acceptance_contract"
|
||||
assert drill["execute_requested"] is False
|
||||
assert drill["schema_state"] == "planned_no_db_probe"
|
||||
assert drill["drill_ready_for_operator_review"] is True
|
||||
@@ -2137,7 +2204,7 @@ def test_migration_apply_drill_route_is_preview_only():
|
||||
|
||||
assert response.status_code == 200
|
||||
assert data["mode"] == "migration_apply_drill_preview"
|
||||
assert data["phase"] == "phase_47_manual_sample_fetch_plan"
|
||||
assert data["phase"] == "phase_48_manual_sample_acceptance_contract"
|
||||
assert data["execute_requested"] is False
|
||||
assert data["migration_executed"] is False
|
||||
assert data["rollback_executed"] is False
|
||||
@@ -2149,7 +2216,7 @@ def test_migration_catalog_review_planned_is_safe_and_diagnostic():
|
||||
review = MarketIntelService().build_migration_catalog_review()
|
||||
|
||||
assert review["mode"] == "migration_catalog_review_preview"
|
||||
assert review["phase"] == "phase_47_manual_sample_fetch_plan"
|
||||
assert review["phase"] == "phase_48_manual_sample_acceptance_contract"
|
||||
assert review["execute_requested"] is False
|
||||
assert review["catalog_state"] == "planned_no_probe"
|
||||
assert review["seed_state"] == "planned_no_probe"
|
||||
@@ -2264,7 +2331,7 @@ def test_migration_catalog_review_route_is_preview_only():
|
||||
|
||||
assert response.status_code == 200
|
||||
assert data["mode"] == "migration_catalog_review_preview"
|
||||
assert data["phase"] == "phase_47_manual_sample_fetch_plan"
|
||||
assert data["phase"] == "phase_48_manual_sample_acceptance_contract"
|
||||
assert data["execute_requested"] is False
|
||||
assert data["catalog_state"] == "planned_no_probe"
|
||||
assert data["migration_executed"] is False
|
||||
@@ -2277,7 +2344,7 @@ def test_migration_live_smoke_planned_is_preview_only():
|
||||
smoke = MarketIntelService().build_migration_live_smoke()
|
||||
|
||||
assert smoke["mode"] == "migration_live_smoke_preview"
|
||||
assert smoke["phase"] == "phase_47_manual_sample_fetch_plan"
|
||||
assert smoke["phase"] == "phase_48_manual_sample_acceptance_contract"
|
||||
assert smoke["execute_requested"] is False
|
||||
assert smoke["smoke_result"] == "planned_no_execution"
|
||||
assert smoke["live_smoke_passed"] is False
|
||||
@@ -2339,7 +2406,7 @@ def test_migration_live_smoke_route_is_preview_only():
|
||||
|
||||
assert response.status_code == 200
|
||||
assert data["mode"] == "migration_live_smoke_preview"
|
||||
assert data["phase"] == "phase_47_manual_sample_fetch_plan"
|
||||
assert data["phase"] == "phase_48_manual_sample_acceptance_contract"
|
||||
assert data["execute_requested"] is False
|
||||
assert data["smoke_result"] == "planned_no_execution"
|
||||
assert data["migration_executed"] is False
|
||||
@@ -2352,7 +2419,7 @@ def test_live_db_inventory_planned_is_preview_only():
|
||||
inventory = MarketIntelService().build_live_db_inventory()
|
||||
|
||||
assert inventory["mode"] == "live_db_inventory_planned"
|
||||
assert inventory["phase"] == "phase_47_manual_sample_fetch_plan"
|
||||
assert inventory["phase"] == "phase_48_manual_sample_acceptance_contract"
|
||||
assert inventory["execute_requested"] is False
|
||||
assert inventory["read_only_query_executed"] is False
|
||||
assert inventory["database_connection_opened"] is False
|
||||
@@ -2496,7 +2563,7 @@ def test_live_db_inventory_route_is_preview_only():
|
||||
|
||||
assert response.status_code == 200
|
||||
assert data["mode"] == "live_db_inventory_planned"
|
||||
assert data["phase"] == "phase_47_manual_sample_fetch_plan"
|
||||
assert data["phase"] == "phase_48_manual_sample_acceptance_contract"
|
||||
assert data["execute_requested"] is False
|
||||
assert data["read_only_query_executed"] is False
|
||||
assert data["database_write_executed"] is False
|
||||
|
||||
Reference in New Issue
Block a user