Documentation
¶
Index ¶
- Constants
- func Diagnose(s *store.Store) (Report, RuntimeCapture)
- func Export(s *store.Store) (string, error)
- func RenderExport(rep Report, rc RuntimeCapture) []byte
- func WriteExport(s *store.Store, rep Report, rc RuntimeCapture) (string, error)
- type Action
- type ActionKind
- type AutoLevel
- type Category
- type Confidence
- type DupStat
- type Finding
- func ChapterGaps(snap *Snapshot) []Finding
- func ChronicLowDimension(snap *Snapshot) []Finding
- func CompassDrift(snap *Snapshot) []Finding
- func ContractMissPattern(snap *Snapshot) []Finding
- func ExcessiveRewrites(snap *Snapshot) []Finding
- func GhostCharacter(snap *Snapshot) []Finding
- func HookWeakChain(snap *Snapshot) []Finding
- func MissingSummaries(snap *Snapshot) []Finding
- func OrphanedSteer(snap *Snapshot) []Finding
- func OutlineExhausted(snap *Snapshot) []Finding
- func PayoffMissPattern(snap *Snapshot) []Finding
- func PhaseFlowMismatch(snap *Snapshot) []Finding
- func RelationshipStagnation(snap *Snapshot) []Finding
- func RewritePendingPressure(snap *Snapshot) []Finding
- func StaleForeshadow(snap *Snapshot) []Finding
- func TimelineGaps(snap *Snapshot) []Finding
- func WordCountAnomaly(snap *Snapshot) []Finding
- type RepeatStat
- type Report
- type RoleModel
- type RuleFunc
- type RuntimeCapture
- type RuntimeRuleFunc
- type Severity
- type SkelEvent
- type SkelTool
- type Snapshot
- type Stats
Constants ¶
const ( ThresholdDimScoreLow = 70 // ChronicLowDimension: 维度均分低于此值告警 ThresholdContractMissRate = 0.3 // ContractMissPattern: 合同未达成率上限 ThresholdRewriteRate = 0.5 // ExcessiveRewrites: 改写率上限 ThresholdWordShortRatio = 0.4 // WordCountAnomaly: 字数低于均值此比例视为异常 ThresholdWordLongRatio = 2.5 // WordCountAnomaly: 字数高于均值此比例视为异常 ThresholdHookWeakScore = 75 // HookWeakChain: hook 低于此分视为偏弱 ThresholdHookWeakChain = 3 // HookWeakChain: 连续偏弱章数阈值 ThresholdPayoffMissRate = 0.4 // PayoffMissPattern: payoff 未兑现率上限 ThresholdCompassDrift = 15 // CompassDrift: 指南针未更新章数上限 ThresholdTimelineGapRate = 0.3 // TimelineGaps: 缺失率容忍上限 ThresholdForeshadowMin = 8 // StaleForeshadow: 伏笔停滞最小章数 )
const ExportRelPath = "meta/diag-export.md"
ExportRelPath 是脱敏诊断文件相对 output 目录的固定位置(覆盖式一份)。
Variables ¶
This section is empty.
Functions ¶
func Diagnose ¶ added in v0.4.5
func Diagnose(s *store.Store) (Report, RuntimeCapture)
Diagnose 是 /diag 的完整诊断入口:创作诊断 + 运行时信号 + 运行时检测, 返回合并后的 Report 与原始 RuntimeCapture(供导出复用,避免重复抓取)。 运行时 Finding 仅并入 Findings 供展示,不改 Actions——保持纯观察。
func RenderExport ¶ added in v0.4.5
func RenderExport(rep Report, rc RuntimeCapture) []byte
RenderExport 把创作 Report + 运行时抓取组合成脱敏 Markdown。
func WriteExport ¶ added in v0.4.5
WriteExport 把已算好的 Report + RuntimeCapture 渲染落盘,不重复抓取。 供 /diag 命令复用 Diagnose 的结果。
Types ¶
type Action ¶
type Action struct {
SourceRule string // 来源规则名
Kind ActionKind // 动作类型
Severity Severity // 继承自 Finding
Summary string // 简短描述
Message string // 传递给控制流的消息
Fingerprint string // 来源 Finding 的稳定指纹,用于运行时去重
}
Action 是 Planner 根据高置信 Finding 生成的可执行动作。
func PlanActions ¶
PlanActions 根据高置信 Finding 生成可执行动作。 只有 Confidence==high && AutoLevel==safe 的 Finding 才会产出 Action。
type ActionKind ¶
type ActionKind string
ActionKind 表示诊断动作的类型。
const ( ActionEmitNotice ActionKind = "emit_notice" // 发系统提示 ActionEnqueueFollowUp ActionKind = "enqueue_follow_up" // 注入 coordinator follow-up )
type Confidence ¶
type Confidence string
Confidence 表示规则判定的置信度。
const ( ConfHigh Confidence = "high" // 确定性强,可信赖 ConfMedium Confidence = "medium" // 启发式判断,可能有误判 ConfLow Confidence = "low" // 粗略信号,仅供参考 )
type Finding ¶
type Finding struct {
Rule string // 规则名,如 "StaleForeshadow"
Category Category // 分类
Severity Severity // 严重程度
Confidence Confidence // 判定置信度
AutoLevel AutoLevel // 自动化级别
Target string // 建议作用面,如 "runtime.flow"
Title string // 一行摘要
Evidence string // 具体数据证据
Suggestion string // 改进建议(指向 prompt/flow/config)
}
Finding 是一条可执行的诊断结果。
func ChronicLowDimension ¶
ChronicLowDimension 检测某评审维度跨多章持续低分。
func ContractMissPattern ¶
ContractMissPattern 检测合同履约率过低。
func ExcessiveRewrites ¶
ExcessiveRewrites 检测改写率过高。
func GhostCharacter ¶
GhostCharacter 检测 core/important 角色长期未出现。
func MissingSummaries ¶
MissingSummaries 检测已完成章节缺少摘要。
func OutlineExhausted ¶
OutlineExhausted 检测大纲耗尽但小说未完结。
func PayoffMissPattern ¶
PayoffMissPattern 检测带 payoff_points 的章节长期未兑现。
func PhaseFlowMismatch ¶
PhaseFlowMismatch 检测阶段与流程状态不匹配。
func RelationshipStagnation ¶
RelationshipStagnation 检测关系数据停止更新。
func RewritePendingPressure ¶
RewritePendingPressure 检测存在待改写章节(当前仅检测状态存在,不判定停滞)。
type RepeatStat ¶ added in v0.4.5
RepeatStat 是一条重复签名及其次数。
type RoleModel ¶ added in v0.4.5
type RoleModel struct {
Agent, Provider, Model string
}
RoleModel 记录某会话实际用的 provider/model。
type RuntimeCapture ¶ added in v0.4.5
type RuntimeCapture struct {
GoOS, GoArch string
Models []RoleModel // 各会话实际生效的 provider/model(从 _meta 收集)
CurrentStep string // 最新 checkpoint:scope.step
StuckStep string // 尾部连续同 step;"" = 不卡
StuckCount int // 连续次数
Repeats []RepeatStat // 重复签名 top-N(循环信号)
DupContent []DupStat // 同 sha 文本反复出现(反复生成同段)
LogKinds map[string]int
LogErrors int
LogWarns int
StopGuard int
Tail []SkelEvent // 末 N 条骨架(看顺序)
RedactedTexts int // 打码文本块总数(脱敏自检)
Sources []string // 实际读到的源(自检)
}
RuntimeCapture 是一次运行时抓取的脱敏结果。只承载运行时信号; phase/flow/章节等创作态由 Report.Stats 携带,不在此重复。
func CaptureRuntime ¶ added in v0.4.5
func CaptureRuntime(s *store.Store) RuntimeCapture
CaptureRuntime 从 output 目录只读抓取运行时信号并脱敏聚合。 任何源缺失都安全降级(不报错),尽力而为。
type RuntimeRuleFunc ¶ added in v0.4.5
type RuntimeRuleFunc func(rc *RuntimeCapture) []Finding
RuntimeRuleFunc 是运行时诊断规则的统一签名(对应创作侧的 RuleFunc)。 入参是脱敏聚合后的 RuntimeCapture,产出报告型 Finding——全部 AutoNone, 只诊断、不产 Action(观察者纪律,见 architecture.md §2.3)。
type SkelEvent ¶ added in v0.4.5
type SkelEvent struct {
Agent string // 来源会话:coordinator / writer-ch07 …
Role string // assistant / tool / user
Tools []SkelTool // 该消息内的工具调用
ErrClass string // role=tool 且 is_error:错误首行(框架错误串,不含正文)
TextSha string // 打码正文的短哈希;同 sha = 反复生成同一段(循环信号)
Redacted int // 本条打码的文本/思考块数(用于脱敏自检)
}
SkelEvent 是一条会话消息脱敏后的行为骨架:保留结构信号(角色 / 工具 / 错误 / 重复指纹),所有自由文本(正文、prompt、思考)一律打码。这是比 store.compactMessage 更严的一层投影——后者按体积压(>4KB),这里不看体积, 任何文本都不出包。
type SkelTool ¶ added in v0.4.5
type SkelTool struct {
Name string // 工具名(结构信号,不含正文)
Args map[string]string // key → 标量原值 / 短字符串带引号 / "<redacted len sha>"
Invalid bool // ArgsInvalid:模型发来的参数无法解析(#34 信号)
ParseErr string // ArgsParseError:解析失败原因
}
SkelTool 是一次工具调用的脱敏投影。
type Snapshot ¶
type Snapshot struct {
Progress *domain.Progress
RunMeta *domain.RunMeta
Compass *domain.StoryCompass
Outline []domain.OutlineEntry
Volumes []domain.VolumeOutline
Characters []domain.Character
CastLedger []domain.CastEntry
WorldRules []domain.WorldRule
Timeline []domain.TimelineEvent
Foreshadow []domain.ForeshadowEntry
Relationships []domain.RelationshipEntry
StateChanges []domain.StateChange
StyleRules *domain.WritingStyleRules
Reviews map[int]*domain.ReviewEntry
Plans map[int]*domain.ChapterPlan
Summaries map[int]*domain.ChapterSummary
LoadErrors []string // 非 NotExist 的加载失败,区分"无数据"和"读取出错"
}
Snapshot 是对 output 目录全部工件的只读快照。 所有规则函数只接收 Snapshot,不直接访问文件系统。
func (*Snapshot) CompletedCount ¶
CompletedCount 返回已完成章节数(安全访问)。
func (*Snapshot) LatestCompleted ¶
LatestCompleted 返回最大已完成章节号;无则返回 0。