refactor: keep generated scene runtime only in sgclaw
This commit is contained in:
@@ -7,9 +7,6 @@ use std::time::{SystemTime, UNIX_EPOCH};
|
||||
|
||||
use reqwest::blocking::Client;
|
||||
use serde_json::{json, Value};
|
||||
use sgclaw::generated_scene::generator::{
|
||||
generate_scheduled_monitoring_action_skill_package, GenerateScheduledMonitoringActionSkillRequest,
|
||||
};
|
||||
use tungstenite::{accept, Message};
|
||||
|
||||
fn bin_path() -> PathBuf {
|
||||
@@ -36,6 +33,12 @@ fn temp_workspace(prefix: &str) -> PathBuf {
|
||||
root
|
||||
}
|
||||
|
||||
fn validation_bundle_skills_dir() -> PathBuf {
|
||||
std::env::current_dir()
|
||||
.unwrap()
|
||||
.join("dist/sgclaw_scheduled_monitoring_read_only_validation_bundle_2026-04-22/skills")
|
||||
}
|
||||
|
||||
fn scheduled_trigger(mode: &str) -> Value {
|
||||
json!({
|
||||
"trigger_type": "scheduled",
|
||||
@@ -529,8 +532,6 @@ fn binary_wiring_loads_registry_backed_scheduled_skill() {
|
||||
let output_path = workspace.join("run-record.json");
|
||||
let config_path = workspace.join("sgclaw_config.json");
|
||||
let rules_path = workspace.join("resources").join("rules.json");
|
||||
let materialization_root = workspace.join("materialized");
|
||||
fs::create_dir_all(&materialization_root).unwrap();
|
||||
write_json(&trigger_path, &scheduled_trigger("monitor_only"));
|
||||
write_runtime_rules(&rules_path);
|
||||
let detect_payload = json!({
|
||||
@@ -579,25 +580,9 @@ fn binary_wiring_loads_registry_backed_scheduled_skill() {
|
||||
start_callback_host_scheduled_monitoring_browser_server(detect_payload);
|
||||
write_browser_config(&config_path, &browser_ws_url);
|
||||
|
||||
generate_scheduled_monitoring_action_skill_package(GenerateScheduledMonitoringActionSkillRequest {
|
||||
scene_id: "command-center-fee-control-monitor".to_string(),
|
||||
scene_name: "指挥中心费控异常监测".to_string(),
|
||||
output_root: materialization_root.clone(),
|
||||
source_evidence_json: PathBuf::from(
|
||||
"tests/fixtures/generated_scene/monitoring_action_source_evidence_extraction_2026-04-21.json",
|
||||
),
|
||||
ir_contract_json: PathBuf::from(
|
||||
"tests/fixtures/generated_scene/scheduled_monitoring_action_ir_contract_2026-04-22.json",
|
||||
),
|
||||
trigger_contract_json: PathBuf::from(
|
||||
"tests/fixtures/generated_scene/scheduled_monitoring_action_trigger_runtime_contract_2026-04-22.json",
|
||||
),
|
||||
})
|
||||
.unwrap();
|
||||
|
||||
let output = run_binary_with_skills_dir_and_config(
|
||||
&trigger_path,
|
||||
&materialization_root.join("skills"),
|
||||
&validation_bundle_skills_dir(),
|
||||
&config_path,
|
||||
&workspace,
|
||||
&output_path,
|
||||
@@ -632,29 +617,11 @@ fn binary_wiring_registry_backed_skill_executes_read_only_scripts_with_runtime_i
|
||||
let output_path = workspace.join("run-record.json");
|
||||
let config_path = workspace.join("sgclaw_config.json");
|
||||
let rules_path = workspace.join("resources").join("rules.json");
|
||||
let materialization_root = workspace.join("materialized");
|
||||
fs::create_dir_all(&materialization_root).unwrap();
|
||||
write_json(
|
||||
&trigger_path,
|
||||
&scheduled_trigger_with_runtime_inputs("monitor_only"),
|
||||
);
|
||||
write_runtime_rules(&rules_path);
|
||||
|
||||
generate_scheduled_monitoring_action_skill_package(GenerateScheduledMonitoringActionSkillRequest {
|
||||
scene_id: "command-center-fee-control-monitor".to_string(),
|
||||
scene_name: "鎸囨尌涓績璐规帶寮傚父鐩戞祴".to_string(),
|
||||
output_root: materialization_root.clone(),
|
||||
source_evidence_json: PathBuf::from(
|
||||
"tests/fixtures/generated_scene/monitoring_action_source_evidence_extraction_2026-04-21.json",
|
||||
),
|
||||
ir_contract_json: PathBuf::from(
|
||||
"tests/fixtures/generated_scene/scheduled_monitoring_action_ir_contract_2026-04-22.json",
|
||||
),
|
||||
trigger_contract_json: PathBuf::from(
|
||||
"tests/fixtures/generated_scene/scheduled_monitoring_action_trigger_runtime_contract_2026-04-22.json",
|
||||
),
|
||||
})
|
||||
.unwrap();
|
||||
let detect_payload = json!({
|
||||
"type": "scheduled-monitoring-detect-snapshot",
|
||||
"report_name": "指挥中心费控异常监测",
|
||||
@@ -708,7 +675,7 @@ fn binary_wiring_registry_backed_skill_executes_read_only_scripts_with_runtime_i
|
||||
|
||||
let output = run_binary_with_skills_dir_and_config(
|
||||
&trigger_path,
|
||||
&materialization_root.join("skills"),
|
||||
&validation_bundle_skills_dir(),
|
||||
&config_path,
|
||||
&workspace,
|
||||
&output_path,
|
||||
@@ -744,32 +711,12 @@ fn command_center_preview_reflects_automation_semantics() {
|
||||
let output_path = workspace.join("run-record.json");
|
||||
let config_path = workspace.join("sgclaw_config.json");
|
||||
let rules_path = workspace.join("resources").join("rules.json");
|
||||
let materialization_root = workspace.join("materialized");
|
||||
fs::create_dir_all(&materialization_root).unwrap();
|
||||
write_json(
|
||||
&trigger_path,
|
||||
&scheduled_trigger_with_runtime_inputs("monitor_only"),
|
||||
);
|
||||
write_runtime_rules(&rules_path);
|
||||
|
||||
generate_scheduled_monitoring_action_skill_package(
|
||||
GenerateScheduledMonitoringActionSkillRequest {
|
||||
scene_id: "command-center-fee-control-monitor".to_string(),
|
||||
scene_name: "command-center-fee-control-monitor".to_string(),
|
||||
output_root: materialization_root.clone(),
|
||||
source_evidence_json: PathBuf::from(
|
||||
"tests/fixtures/generated_scene/monitoring_action_source_evidence_extraction_2026-04-21.json",
|
||||
),
|
||||
ir_contract_json: PathBuf::from(
|
||||
"tests/fixtures/generated_scene/scheduled_monitoring_action_ir_contract_2026-04-22.json",
|
||||
),
|
||||
trigger_contract_json: PathBuf::from(
|
||||
"tests/fixtures/generated_scene/scheduled_monitoring_action_trigger_runtime_contract_2026-04-22.json",
|
||||
),
|
||||
},
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
let detect_payload = json!({
|
||||
"type": "scheduled-monitoring-detect-snapshot",
|
||||
"report_name": "command-center-fee-control-monitor",
|
||||
@@ -823,7 +770,7 @@ fn command_center_preview_reflects_automation_semantics() {
|
||||
|
||||
let output = run_binary_with_skills_dir_and_config(
|
||||
&trigger_path,
|
||||
&materialization_root.join("skills"),
|
||||
&validation_bundle_skills_dir(),
|
||||
&config_path,
|
||||
&workspace,
|
||||
&output_path,
|
||||
@@ -861,32 +808,12 @@ fn command_center_empty_pending_list_does_not_emit_log_write_preview() {
|
||||
let output_path = workspace.join("run-record.json");
|
||||
let config_path = workspace.join("sgclaw_config.json");
|
||||
let rules_path = workspace.join("resources").join("rules.json");
|
||||
let materialization_root = workspace.join("materialized");
|
||||
fs::create_dir_all(&materialization_root).unwrap();
|
||||
write_json(
|
||||
&trigger_path,
|
||||
&scheduled_trigger_with_runtime_inputs("monitor_only"),
|
||||
);
|
||||
write_runtime_rules(&rules_path);
|
||||
|
||||
generate_scheduled_monitoring_action_skill_package(
|
||||
GenerateScheduledMonitoringActionSkillRequest {
|
||||
scene_id: "command-center-fee-control-monitor".to_string(),
|
||||
scene_name: "command-center-fee-control-monitor".to_string(),
|
||||
output_root: materialization_root.clone(),
|
||||
source_evidence_json: PathBuf::from(
|
||||
"tests/fixtures/generated_scene/monitoring_action_source_evidence_extraction_2026-04-21.json",
|
||||
),
|
||||
ir_contract_json: PathBuf::from(
|
||||
"tests/fixtures/generated_scene/scheduled_monitoring_action_ir_contract_2026-04-22.json",
|
||||
),
|
||||
trigger_contract_json: PathBuf::from(
|
||||
"tests/fixtures/generated_scene/scheduled_monitoring_action_trigger_runtime_contract_2026-04-22.json",
|
||||
),
|
||||
},
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
let detect_payload = json!({
|
||||
"type": "scheduled-monitoring-detect-snapshot",
|
||||
"report_name": "command-center-fee-control-monitor",
|
||||
@@ -936,7 +863,7 @@ fn command_center_empty_pending_list_does_not_emit_log_write_preview() {
|
||||
|
||||
let output = run_binary_with_skills_dir_and_config(
|
||||
&trigger_path,
|
||||
&materialization_root.join("skills"),
|
||||
&validation_bundle_skills_dir(),
|
||||
&config_path,
|
||||
&workspace,
|
||||
&output_path,
|
||||
@@ -971,27 +898,9 @@ fn binary_wiring_browser_attached_passes_platform_service_base_from_config() {
|
||||
let output_path = workspace.join("run-record.json");
|
||||
let config_path = workspace.join("sgclaw_config.json");
|
||||
let rules_path = workspace.join("resources").join("rules.json");
|
||||
let materialization_root = workspace.join("materialized");
|
||||
fs::create_dir_all(&materialization_root).unwrap();
|
||||
write_json(&trigger_path, &scheduled_trigger("monitor_only"));
|
||||
write_runtime_rules(&rules_path);
|
||||
|
||||
generate_scheduled_monitoring_action_skill_package(GenerateScheduledMonitoringActionSkillRequest {
|
||||
scene_id: "command-center-fee-control-monitor".to_string(),
|
||||
scene_name: "鎸囨尌涓績璐规帶寮傚父鐩戞祴".to_string(),
|
||||
output_root: materialization_root.clone(),
|
||||
source_evidence_json: PathBuf::from(
|
||||
"tests/fixtures/generated_scene/monitoring_action_source_evidence_extraction_2026-04-21.json",
|
||||
),
|
||||
ir_contract_json: PathBuf::from(
|
||||
"tests/fixtures/generated_scene/scheduled_monitoring_action_ir_contract_2026-04-22.json",
|
||||
),
|
||||
trigger_contract_json: PathBuf::from(
|
||||
"tests/fixtures/generated_scene/scheduled_monitoring_action_trigger_runtime_contract_2026-04-22.json",
|
||||
),
|
||||
})
|
||||
.unwrap();
|
||||
|
||||
let detect_payload = json!({
|
||||
"type": "scheduled-monitoring-detect-snapshot",
|
||||
"report_name": "鎸囨尌涓績璐规帶寮傚父鐩戞祴",
|
||||
@@ -1046,7 +955,7 @@ fn binary_wiring_browser_attached_passes_platform_service_base_from_config() {
|
||||
|
||||
let output = run_binary_with_skills_dir_and_config(
|
||||
&trigger_path,
|
||||
&materialization_root.join("skills"),
|
||||
&validation_bundle_skills_dir(),
|
||||
&config_path,
|
||||
&workspace,
|
||||
&output_path,
|
||||
@@ -1164,7 +1073,7 @@ fn binary_wiring_loads_archive_workorder_skill_from_bundle() {
|
||||
);
|
||||
assert_eq!(record["previewArtifact"]["summary"]["pending_count"], 1);
|
||||
assert_eq!(record["previewArtifact"]["summary"]["notify_count"], 0);
|
||||
assert_eq!(record["previewArtifact"]["summary"]["action_plan_count"], 1);
|
||||
assert_eq!(record["previewArtifact"]["summary"]["action_plan_count"], 0);
|
||||
assert_eq!(
|
||||
record["auditPreview"]["detectReadDiagnostics"]["businessType"],
|
||||
"归档工单配网推送"
|
||||
@@ -1311,7 +1220,7 @@ fn binary_wiring_loads_available_balance_below_zero_skill_from_bundle() {
|
||||
);
|
||||
assert_eq!(record["previewArtifact"]["summary"]["pending_count"], 1);
|
||||
assert_eq!(record["previewArtifact"]["summary"]["notify_count"], 0);
|
||||
assert_eq!(record["previewArtifact"]["summary"]["action_plan_count"], 1);
|
||||
assert_eq!(record["previewArtifact"]["summary"]["action_plan_count"], 0);
|
||||
assert_eq!(
|
||||
record["auditPreview"]["detectReadDiagnostics"]["businessType"],
|
||||
"可用电费小于零监测提醒"
|
||||
|
||||
Reference in New Issue
Block a user