Skip to main content

Module ai_synthesis

Module ai_synthesis 

Source
Expand description

Tier 1 AI synthesis — selective invocation, confidence gating, and decision recording (§17.2, §17.3, §17.4).

The synthesis layer augments the rule-based Tier 2 backends with AI generation at capability-gap points (§17.6) and target-flagged constructs (TargetProfile::ai_hints). It is the infrastructure half of “AI-first with deterministic fallback”:

  1. Walk the AIR module and identify nodes that warrant AI synthesis. Trivial constructs (literals, arithmetic, direct calls, …) are classified as None by crate::profile::classify_node and bypass AI entirely — per §17.2 (Q3 amended, 2026-04-20).
  2. For each flagged node, call the provider’s generate mode. Confidence gates acceptance (default 0.75); pinned cache replays (§17.8) bypass the threshold.
  3. Run the deterministic verifier (§17.3) on accepted output. Verification lives in this crate — it never goes through the AI provider.
  4. Record the accepted choice as a build-scope decision (§17.4) routed to .bock/decisions/build/.
  5. On rejection, provider error, or verification failure, fall through to Tier 2 rule-based generation (preserved guarantee).

Structs§

AiSynthesisDriver
Machinery driving a single-module AI synthesis pass.
SynthesisConfig
Runtime knobs for a single AI-augmented module compilation.
SynthesisStats
Aggregate counters across a synthesis pass.

Enums§

SynthesisOutcome
Result of synthesizing a single flagged node.

Functions§

cache_at
Convenience for callers that want to build a cache rooted at the project directory without importing bock_ai::AiCache.
needs_ai_synthesis
Returns true only when the node is flagged by target.ai_hints and matches a non-trivial crate::profile::NodeKindHint. Trivial constructs (literals, arithmetic, direct calls, variable bindings) always return false — the Q3 guarantee from the 2026-04-20 spec amendment.
synthesize_and_flush
Drives synthesis once per module and flushes the manifest writer.
verify_generated
Deterministic, provider-free verification of generated target code.