generated-scene: add scheduled monitoring runtime and helper lifecycle hardening

This commit is contained in:
木炎
2026-05-06 09:47:12 +08:00
parent 6cdd71b682
commit 8162118e6d
183 changed files with 103674 additions and 130 deletions

View File

@@ -165,13 +165,23 @@ fn build_scene_execution_plan(
instruction: &str,
mut args: Map<String, Value>,
) -> SceneExecutionPlan {
let bootstrap = entry
.manifest
.bootstrap
.as_ref()
.expect("report scene registry should only contain manifests with bootstrap");
let artifact = entry
.manifest
.artifact
.as_ref()
.expect("report scene registry should only contain manifests with artifact");
args.insert(
"expected_domain".to_string(),
Value::String(entry.manifest.bootstrap.expected_domain.clone()),
Value::String(bootstrap.expected_domain.clone()),
);
args.insert(
"target_url".to_string(),
Value::String(entry.manifest.bootstrap.target_url.clone()),
Value::String(bootstrap.target_url.clone()),
);
SceneExecutionPlan {
@@ -181,11 +191,11 @@ fn build_scene_execution_plan(
"{}.{}",
entry.manifest.scene.skill, entry.manifest.scene.tool
),
expected_domain: entry.manifest.bootstrap.expected_domain.clone(),
target_url: entry.manifest.bootstrap.target_url.clone(),
expected_domain: bootstrap.expected_domain.clone(),
target_url: bootstrap.target_url.clone(),
args,
success_statuses: entry.manifest.artifact.success_status.clone(),
failure_statuses: entry.manifest.artifact.failure_status.clone(),
success_statuses: artifact.success_status.clone(),
failure_statuses: artifact.failure_status.clone(),
postprocess: entry.manifest.postprocess.clone(),
}
}
@@ -252,7 +262,8 @@ fn score_scene(
page_url: Option<&str>,
page_title: Option<&str>,
) -> Option<usize> {
let deterministic = &entry.manifest.deterministic;
let deterministic = entry.manifest.deterministic.as_ref()?;
let bootstrap = entry.manifest.bootstrap.as_ref()?;
if deterministic.suffix != DETERMINISTIC_SUFFIX {
return None;
}
@@ -279,11 +290,7 @@ fn score_scene(
let normalized_url = page_url.unwrap_or_default().to_ascii_lowercase();
if !normalized_url.is_empty() {
if normalized_url.contains(
&entry
.manifest
.bootstrap
.expected_domain
.to_ascii_lowercase(),
&bootstrap.expected_domain.to_ascii_lowercase(),
) {
score += 100;
} else if normalized_url.contains(&entry.manifest.scene.id.to_ascii_lowercase()) {
@@ -296,6 +303,7 @@ fn score_scene(
&& entry
.manifest
.bootstrap
.as_ref()?
.page_title_keywords
.iter()
.any(|keyword| !keyword.trim().is_empty() && title.contains(keyword.as_str()))
@@ -324,8 +332,18 @@ fn log_registry_diag(registry: &[SceneRegistryEntry]) {
registry.len(),
DIAGNOSTIC_SCENE_ID,
entry.skill_root.display(),
entry.manifest.deterministic.suffix == DETERMINISTIC_SUFFIX,
entry.manifest.deterministic.include_keywords
entry
.manifest
.deterministic
.as_ref()
.map(|deterministic| deterministic.suffix == DETERMINISTIC_SUFFIX)
.unwrap_or(false),
entry
.manifest
.deterministic
.as_ref()
.map(|deterministic| deterministic.include_keywords.clone())
.unwrap_or_default()
)),
None => log_deterministic_diag(format!(
"registry loaded count={} diagnostic_scene={} registered=false",
@@ -336,7 +354,13 @@ fn log_registry_diag(registry: &[SceneRegistryEntry]) {
}
fn log_scene_match_diag(entry: &SceneRegistryEntry, instruction: &str) {
let deterministic = &entry.manifest.deterministic;
let Some(deterministic) = entry.manifest.deterministic.as_ref() else {
log_deterministic_diag(format!(
"diagnostic_scene={} deterministic=false",
entry.manifest.scene.id
));
return;
};
let include_hits = deterministic
.include_keywords
.iter()