Skip to content

Commit 7d38ba4

Browse files
evaluation: document real-mode budgets and harden report regex compilation
1 parent 22c4938 commit 7d38ba4

2 files changed

Lines changed: 36 additions & 6 deletions

File tree

  • evaluation/workflow/promptiter/regression
  • examples/evaluation/promptiter_regression_loop

evaluation/workflow/promptiter/regression/report.go

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -676,18 +676,42 @@ func validSHA256(value string) bool {
676676
}
677677

678678
var (
679-
reportSensitiveAssignment = regexp.MustCompile(
679+
reportSensitiveAssignment *regexp.Regexp
680+
reportBearerValue *regexp.Regexp
681+
reportOpenAIKey *regexp.Regexp
682+
reportJWT *regexp.Regexp
683+
reportPrivateKey *regexp.Regexp
684+
)
685+
686+
func init() {
687+
var compileErr error
688+
reportSensitiveAssignment, compileErr = regexp.Compile(
680689
`(?i)\b(authorization|api[ _-]?key|access[ _-]?token|refresh[ _-]?token|token|password|` +
681690
`client[ _-]?secret|secret|credential|credentials|private[ _-]?key|cookie)` +
682691
`(\s*[:=]\s*)[^\r\n,;|]+`,
683692
)
684-
reportBearerValue = regexp.MustCompile(`(?i)\bbearer\s+[^\s,;|]+`)
685-
reportOpenAIKey = regexp.MustCompile(`\bsk-[A-Za-z0-9_-]{12,}\b`)
686-
reportJWT = regexp.MustCompile(`\beyJ[A-Za-z0-9_-]{5,}\.[A-Za-z0-9_-]{5,}\.[A-Za-z0-9_-]{5,}\b`)
687-
reportPrivateKey = regexp.MustCompile(
693+
if compileErr != nil {
694+
panic(fmt.Errorf("report sensitive assignment regex: %w", compileErr))
695+
}
696+
reportBearerValue, compileErr = regexp.Compile(`(?i)\bbearer\s+[^\s,;|]+`)
697+
if compileErr != nil {
698+
panic(fmt.Errorf("report bearer value regex: %w", compileErr))
699+
}
700+
reportOpenAIKey, compileErr = regexp.Compile(`\bsk-[A-Za-z0-9_-]{12,}\b`)
701+
if compileErr != nil {
702+
panic(fmt.Errorf("report OpenAI key regex: %w", compileErr))
703+
}
704+
reportJWT, compileErr = regexp.Compile(`\beyJ[A-Za-z0-9_-]{5,}\.[A-Za-z0-9_-]{5,}\.[A-Za-z0-9_-]{5,}\b`)
705+
if compileErr != nil {
706+
panic(fmt.Errorf("report JWT regex: %w", compileErr))
707+
}
708+
reportPrivateKey, compileErr = regexp.Compile(
688709
`(?is)-----BEGIN [^-\r\n]*PRIVATE KEY-----.*?-----END [^-\r\n]*PRIVATE KEY-----`,
689710
)
690-
)
711+
if compileErr != nil {
712+
panic(fmt.Errorf("report private key regex: %w", compileErr))
713+
}
714+
}
691715

692716
func sanitizeReportText(value string) string {
693717
value = reportPrivateKey.ReplaceAllString(value, redactedReportValue)

examples/evaluation/promptiter_regression_loop/real.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,12 @@ func runRealLoop(
8585
audit: runtime.audit,
8686
}
8787
gatePolicy := config.gatePolicy
88+
// Real-mode budgets replace the tiny fixture values originally meant for
89+
// deterministic fake mode. Three rounds with backwarder+aggregator+optimizer
90+
// plus candidate serving evaluation produce at most ~50 model calls and
91+
// ~100 000 tokens in typical scenarios. 200 calls / 500k tokens per budget
92+
// category provide a generous safety margin while still catching runaway
93+
// loops.
8894
gatePolicy.MaxCandidateServingModelCalls = 200
8995
gatePolicy.MaxCandidateServingTotalTokens = 500000
9096
gatePolicy.MaxOptimizationModelCalls = 200

0 commit comments

Comments
 (0)