Skip to main content

perspt_sdk/prompt/
plan.rs

1//! Issue-conditioned prompt plans (PSP-10 system 23).
2//!
3//! Perspt does not ask a model to write its next system prompt: a reviewed,
4//! exhaustive policy rule maps typed issue state to an ordered set of
5//! compiled, active section ids. Evidence values stay delimited data; they
6//! cannot add instructions, effects, tools, or capabilities.
7
8use serde::{Deserialize, Serialize};
9
10use crate::residual::{CorrectionPacketRef, ResidualClass};
11
12use super::section::PromptSectionId;
13use super::stage::PromptStage;
14
15/// A concrete verifier witness (failing input, test, or trace). Only a
16/// sound verifier's concrete artifact earns this name; an ordinary
17/// diagnostic is correction evidence, never mislabeled a counterexample.
18#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
19pub struct CounterexampleRef {
20    /// Content address of the recorded witness artifact.
21    pub artifact: String,
22    /// The producing verifier's identity.
23    pub verifier: String,
24}
25
26/// The pages an issue plan asks the resident-context assembler to consider.
27#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize)]
28pub struct ContextRequest {
29    /// Page ids, paths, symbols, diagnostic ids, or test ids to prefer.
30    pub keys: Vec<String>,
31}
32
33/// One compiled issue plan: the policy rule's output for the current state.
34#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
35pub struct IssuePromptPlan {
36    /// The exhaustive policy rule that produced this plan.
37    pub rule_id: String,
38    pub stage: PromptStage,
39    pub issue: ResidualClass,
40    /// Present only when a sound verifier supplied a concrete witness.
41    #[serde(default, skip_serializing_if = "Option::is_none")]
42    pub witness: Option<CounterexampleRef>,
43    pub correction: CorrectionPacketRef,
44    /// Ordered active section ids to instantiate.
45    pub sections: Vec<PromptSectionId>,
46    #[serde(default)]
47    pub context_request: ContextRequest,
48}