Skip to content

Commit e521e96

Browse files
hyperpolymathclaude
andcommitted
feat(llm): Add frontier LLM advisor via BoJ Server integration
Integrate frontier language models (Claude, GPT-4, etc.) as proof advisors through BoJ Server's cartridge system. The LLM suggests tactics, ranks provers, decomposes goals, and generates auxiliary lemmas — but CANNOT influence trust levels. Architecture: ProofState → LlmAdvisor → BoJ REST API → Frontier LLM LLM suggestions → ProverDispatcher (trust pipeline unchanged) New module: src/rust/llm.rs - LlmAdvisor: connects to BoJ (localhost:7700) for LLM guidance - TacticSuggestionRequest/Response: structured JSON protocol - ProverRecommendation: LLM-ranked prover selection - GoalDecomposition: LLM-suggested subgoal splitting - DispatchOptimisation: LLM-guided dispatch configuration - In-context learning via proof attempt history - Cost-aware model routing via BoJ model-router cartridge - 8 tests (all passing) Integration into dispatch.rs: - ProverDispatcher.with_llm_advisor(): attach LLM advisor - verify_proof_llm_guided(): LLM-optimised dispatch path - Falls back to standard dispatch if LLM unavailable Trust invariant: LLM optimises WHICH PATH to take, never WHAT THE ANSWER IS. Trust levels computed solely by dispatch pipeline. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent ef47c3a commit e521e96

3 files changed

Lines changed: 771 additions & 1 deletion

File tree

src/rust/dispatch.rs

Lines changed: 59 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ use std::time::Instant;
1313
use tracing::{info, warn};
1414

1515
use crate::integrity::solver_integrity::{IntegrityChecker, IntegrityStatus};
16+
use crate::llm::{LlmAdvisor, DispatchOptimisation};
1617
use crate::provers::{ProverConfig, ProverFactory, ProverKind};
1718
use crate::verification::axiom_tracker::{AxiomTracker, AxiomUsage, DangerLevel};
1819
use crate::verification::confidence::{compute_trust_level, TrustFactors, TrustLevel};
@@ -71,6 +72,9 @@ impl Default for DispatchConfig {
7172
pub struct ProverDispatcher {
7273
config: DispatchConfig,
7374
integrity_checker: Option<IntegrityChecker>,
75+
/// Optional frontier LLM advisor for intelligent dispatch optimisation.
76+
/// Advisory only — cannot influence trust levels.
77+
llm_advisor: Option<LlmAdvisor>,
7478
}
7579

7680
impl ProverDispatcher {
@@ -79,12 +83,13 @@ impl ProverDispatcher {
7983
Self {
8084
config: DispatchConfig::default(),
8185
integrity_checker: None,
86+
llm_advisor: None,
8287
}
8388
}
8489

8590
/// Create a dispatcher with custom configuration
8691
pub fn with_config(config: DispatchConfig) -> Self {
87-
Self { config, integrity_checker: None }
92+
Self { config, integrity_checker: None, llm_advisor: None }
8893
}
8994

9095
/// Set the integrity checker for solver binary verification
@@ -93,6 +98,59 @@ impl ProverDispatcher {
9398
self
9499
}
95100

101+
/// Set the frontier LLM advisor for intelligent dispatch optimisation.
102+
/// Advisory only — the trust pipeline remains inviolable.
103+
pub fn with_llm_advisor(mut self, advisor: LlmAdvisor) -> Self {
104+
self.llm_advisor = Some(advisor);
105+
self
106+
}
107+
108+
/// Dispatch with LLM-guided optimisation
109+
///
110+
/// The LLM suggests which prover to try and which cross-checkers to use.
111+
/// If the LLM is unavailable, falls back to the provided prover_kind.
112+
/// Trust levels are NEVER influenced by the LLM.
113+
pub async fn verify_proof_llm_guided(
114+
&self,
115+
content: &str,
116+
fallback_prover: ProverKind,
117+
) -> Result<DispatchResult> {
118+
// Try to get LLM optimisation
119+
if let Some(ref advisor) = self.llm_advisor {
120+
if advisor.is_available() {
121+
// Parse content into a minimal proof state for the LLM
122+
let prover_config = ProverConfig::default();
123+
if let Ok(prover) = ProverFactory::create(fallback_prover, prover_config) {
124+
if let Ok(state) = prover.parse_string(content).await {
125+
if let Some(opt) = advisor.optimise_dispatch(&state).await {
126+
info!(
127+
"LLM dispatch optimisation: primary={:?}, cross_check={:?}",
128+
opt.primary_prover, opt.cross_check_provers
129+
);
130+
131+
let primary = opt.primary_prover.unwrap_or(fallback_prover);
132+
133+
if !opt.cross_check_provers.is_empty() {
134+
return self
135+
.verify_proof_cross_checked(
136+
primary,
137+
content,
138+
&opt.cross_check_provers,
139+
)
140+
.await;
141+
}
142+
143+
return self.verify_proof(primary, content).await;
144+
}
145+
}
146+
}
147+
}
148+
}
149+
150+
// Fallback: use provided prover without LLM guidance
151+
self.verify_proof(fallback_prover, content).await
152+
}
153+
96154
/// Dispatch a proof verification request through the trust-hardening pipeline
97155
pub async fn verify_proof(
98156
&self,

src/rust/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ pub mod core;
1010
pub mod provers;
1111
pub mod parsers;
1212
pub mod neural;
13+
pub mod llm; // Frontier LLM advisor (via BoJ Server)
1314
pub mod aspect;
1415
pub mod agent;
1516
pub mod ffi;
@@ -24,6 +25,7 @@ pub mod dispatch;
2425
pub use core::{ProofState, Term, Tactic, TacticResult};
2526
pub use provers::{ProverBackend, ProverKind, ProverConfig};
2627
pub use agent::{AgentCore, AgentConfig};
28+
pub use llm::{LlmAdvisor, LlmConfig};
2729

2830
#[cfg(test)]
2931
mod tests {

0 commit comments

Comments
 (0)