Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions resources/review-validation-findings-kernel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<!-- SPDX-License-Identifier: Apache-2.0 -->

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.
8 changes: 4 additions & 4 deletions resources/review-validation-findings.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 6 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1344,13 +1344,17 @@ 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,
repo: &Path,
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.
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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,
Expand Down
47 changes: 47 additions & 0 deletions src/target.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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::*;
Expand All @@ -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"
);
}
}
}
6 changes: 6 additions & 0 deletions src/target/kernel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"
))
}
}
Loading