use crate::google_trends_learning::trending_learning_report;
pub const GOOGLE_TRENDS_LEARNING_PATH: &str = "google-trends-learning.lino";
pub const GOOGLE_TRENDS_LEARNING_TASK: &str =
"Collect the Google Trends learning frontier — the trending searches Formal AI cannot \
yet resolve — route them through the human-gated self-improvement loop, and record the \
learning report in Links Notation.";
const GOOGLE_TRENDS_KEYWORDS: [&str; 2] = ["google trends", "trending search"];
#[must_use]
pub fn is_google_trends_learning_task(prompt: &str) -> bool {
let lower = prompt.to_lowercase();
let cannot_resolve = lower.contains("resolve")
&& (lower.contains("cannot") || lower.contains("can't") || lower.contains("not yet"));
GOOGLE_TRENDS_KEYWORDS
.iter()
.any(|keyword| lower.contains(keyword))
&& (lower.contains("learning frontier")
|| lower.contains("self-improvement loop")
|| cannot_resolve)
}
#[must_use]
pub fn render_document() -> String {
format!("{}\n", trending_learning_report().links_notation())
}
#[must_use]
pub fn final_answer(document: &str) -> String {
let report = trending_learning_report();
format!(
"Routed the Google Trends learning frontier through the human-gated self-improvement \
loop: of {total} trending prompts, the engine already resolves {handled} and leaves \
{frontier} on the learning frontier. Every frontier trace was handed to the issue-#558 \
learner, which — because trending searches are open-domain questions, not program-plan \
modifiers — proposed {proposals} rules and adopted {adopted}: nothing changes without \
human review. The report is a pure function of the committed catalog.\n\nGenerated \
document ({GOOGLE_TRENDS_LEARNING_PATH}):\n\n{document}",
total = report.total_prompts,
handled = report.handled_by_engine,
frontier = report.frontier_count(),
proposals = report.run.proposals.len(),
adopted = report.adopted_count(),
document = document.trim_end(),
)
}
#[must_use]
pub fn verification_command() -> String {
format!(
"python3 -c p='{GOOGLE_TRENDS_LEARNING_PATH}';s=open(p).read().splitlines();print(len(s));print('\\n'.join(s[:14]))"
)
}