package docrevision import ( "os" "strings" "sync" ) // EnvPIChangeReportNarrative gates optional PI change-report narrative enrichment. // Default off: deterministic fallback only. const EnvPIChangeReportNarrative = "PI_CHANGE_REPORT_NARRATIVE" var ( flagsMu sync.RWMutex narrativeOn = envBool(EnvPIChangeReportNarrative, false) ) func envBool(key string, def bool) bool { v := strings.TrimSpace(os.Getenv(key)) if v == "" { return def } return v == "1" || strings.EqualFold(v, "true") || strings.EqualFold(v, "yes") } // PIChangeReportNarrativeEnabled reports whether PI narrative enrichment is on. func PIChangeReportNarrativeEnabled() bool { flagsMu.RLock() defer flagsMu.RUnlock() return narrativeOn } // SetPIChangeReportNarrativeForTest overrides the flag in tests. func SetPIChangeReportNarrativeForTest(on bool) { flagsMu.Lock() narrativeOn = on flagsMu.Unlock() } // ResetPIChangeReportNarrativeForTest restores the flag from the process environment. func ResetPIChangeReportNarrativeForTest() { flagsMu.Lock() narrativeOn = envBool(EnvPIChangeReportNarrative, false) flagsMu.Unlock() }