diff --git a/resources/review-validation-findings-kernel.md b/resources/review-validation-findings-kernel.md new file mode 100644 index 0000000..701da69 --- /dev/null +++ b/resources/review-validation-findings-kernel.md @@ -0,0 +1,6 @@ + + +Kernel-specific linkage rules for absence/export claims: check Kbuild/Makefile +ownership and aggregator `#include "*.c"` files for linkage claims. +`EXPORT_SYMBOL*()` is only required across a loadable-module boundary, not +between built-in objects or within one textual translation unit. diff --git a/resources/review-validation-findings.md b/resources/review-validation-findings.md index eaaf2db..95dadf1 100644 --- a/resources/review-validation-findings.md +++ b/resources/review-validation-findings.md @@ -122,10 +122,10 @@ unexpanded spelling of an intermediate macro body. Repository-verifiable absence/linkage claims are not matters of taste. Before KEEP or TIGHTEN of a claim that a declaration, definition, export, stub, symbol, or caller is missing, you MUST use repository tools to inspect the -reviewed commit. Check Kbuild/Makefile ownership and aggregator `#include -"*.c"` files for linkage claims. `EXPORT_SYMBOL*()` is only required across a -loadable-module boundary, not between built-in objects or within one textual -translation unit. If the claim cannot be verified, DROP it. The runtime will +reviewed commit. Verify the claim against the project's build system and any +aggregator sources that textually include one translation unit into another +before treating a symbol as unlinked, unexported, or unreferenced. If the claim +cannot be verified, DROP it. The runtime will reject a sensitive non-empty result when no repository tool was executed. Validation may cover multiple commits while repository search tools see the main worktree's current HEAD. For commit-specific evidence, use `git_show` with diff --git a/src/main.rs b/src/main.rs index d742137..5b4bd56 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1344,6 +1344,7 @@ async fn run_findings_validation( validation_cfg: &config::ResolvedModel, main_model: &config::ResolvedModel, mode: ValidationMode, + target: config::ReviewTarget, out: &mut Value, totals: &mut RunTotals, vdest: &VerboseDest, @@ -1351,6 +1352,9 @@ async fn run_findings_validation( no_tools: bool, progress_ui: Option<&MultiPatchSpinner>, ) { + // Domain-neutral findings validator, plus the target's linkage/build + // addendum (kernel adds Kbuild/EXPORT_SYMBOL rules; other targets none). + let validation_system = crate::target::review_validation_findings(target); // Snapshot regular-stage candidates and specialist proof challenges. // `findings[]` remains the protected baseline unless the strong validator // explicitly confirms one of the challenges. @@ -1498,7 +1502,7 @@ async fn run_findings_validation( api::chat_completion_with_retry_stage_timeout_preserve_input( client, validation_cfg, - api::SYSTEM_REVIEW_VALIDATION_FINDINGS, + &validation_system, &user_msg, validation_cfg.temperature, Some(&label), @@ -2893,6 +2897,7 @@ The review will use {} prompts and persona and may be inaccurate — did you mea validation_cfg, &model, validation_mode, + review_target, &mut out, &mut totals, &vdest, diff --git a/src/target.rs b/src/target.rs index 54a356a..f9d5433 100644 --- a/src/target.rs +++ b/src/target.rs @@ -41,6 +41,14 @@ pub trait TargetSpec: Sync { fn stage_instructions(&self, _stage: u8) -> Option<&'static str> { None } + + /// Target-specific addendum appended to the shared, domain-neutral + /// findings-validation system prompt. `None` keeps the neutral prompt as-is; + /// a target returns `Some` to add domain-specific linkage/build rules (e.g. + /// the kernel's Kbuild ownership and loadable-module `EXPORT_SYMBOL` rules). + fn validation_findings_addendum(&self) -> Option<&'static str> { + None + } } pub fn spec(target: ReviewTarget) -> &'static dyn TargetSpec { @@ -125,6 +133,17 @@ pub fn stage_instructions(target: ReviewTarget, stage: u8) -> Option<&'static st spec(target).stage_instructions(stage) } +/// Findings-validation system prompt for `target`: the shared domain-neutral +/// base ([`crate::api::SYSTEM_REVIEW_VALIDATION_FINDINGS`]) plus any +/// target-specific linkage/build addendum. +pub fn review_validation_findings(target: ReviewTarget) -> String { + let base = crate::api::SYSTEM_REVIEW_VALIDATION_FINDINGS; + match spec(target).validation_findings_addendum() { + Some(addendum) => format!("{}\n\n{}", base.trim_end(), addendum.trim()), + None => base.to_string(), + } +} + #[cfg(test)] mod tests { use super::*; @@ -144,4 +163,32 @@ mod tests { assert!(quick_summary_system_prompt(ReviewTarget::Qemu).contains("QEMU")); assert!(quick_summary_system_prompt(ReviewTarget::Libvirt).contains("libvirt")); } + + #[test] + fn findings_validator_is_domain_neutral_except_kernel() { + // The shared base must not carry kernel-only linkage jargon; those + // concepts now live in the kernel-specific addendum. + let base = crate::api::SYSTEM_REVIEW_VALIDATION_FINDINGS; + for tok in ["Kbuild", "EXPORT_SYMBOL", "loadable-module"] { + assert!( + !base.contains(tok), + "shared findings validator leaked kernel token: {tok}" + ); + } + + // A kernel review re-attaches the kernel linkage rules via its addendum. + let kernel = review_validation_findings(ReviewTarget::Kernel); + assert!(kernel.contains("Kbuild")); + assert!(kernel.contains("EXPORT_SYMBOL")); + assert!(kernel.contains("loadable-module")); + + // Non-kernel targets get exactly the domain-neutral base, no kernel rules. + for t in [ReviewTarget::Qemu, ReviewTarget::Libvirt] { + let prompt = review_validation_findings(t); + assert_eq!( + prompt, base, + "non-kernel findings validator must equal the shared base" + ); + } + } } diff --git a/src/target/kernel.rs b/src/target/kernel.rs index b685072..ee0bf8d 100644 --- a/src/target/kernel.rs +++ b/src/target/kernel.rs @@ -155,4 +155,10 @@ impl TargetSpec for KernelTarget { fn quick_summary_system_prompt(&self) -> &'static str { QUICK_SUMMARY_SYSTEM_PROMPT } + + fn validation_findings_addendum(&self) -> Option<&'static str> { + Some(include_str!( + "../../resources/review-validation-findings-kernel.md" + )) + } }