Skip to content
This repository was archived by the owner on Nov 15, 2025. It is now read-only.
This repository was archived by the owner on Nov 15, 2025. It is now read-only.

[Feature] Guideline Reinforcement Engine – Enforce Prompt Rules in Markdown, YAML, SudoLang #19

Description

@christso

Problem

bbeval opt must generate structured, compliant prompts in Markdown, YAML, or SudoLang, while enforcing company guidelines (attached via --guidelines) Invalid prompts (missing {{examples}}, banned phrases, wrong format) must be rejected during optimization.

Proposed Solution

Add a multi-format Guideline Reinforcement Engine to bbeval opt that:

  • Validates every candidate before scoring
  • Supports Markdown, YAML, and SudoLang output
  • Enforces format-specific rules via --guidelines (YAML)

CLI Usage

bbeval opt tests.yaml base.prompt.md \
--mode direct-llm \
--guidelines constraints.yaml \
--format markdown \
--output optimized.prompt.md

constraints.yaml (Format-Agnostic + Format-Specific)

# Globalrequired_placeholders:
- "{{task}}"
- "{{guidelines}}"banned_phrases:
- "never"
- "always avoid"max_tokens: 500# Format: Markdownmarkdown:
required_headers:
- "# Task"
- "## Output"required_tools_in_frontmatter: trueno_universal_concepts: true # Ban SOLID, PascalCase, etc.# Format: YAMLyaml:
required_keys:
- persona
- workflow
- outputno_inheritance: true # Ban `extends`, `class`# Format: SudoLangsudolang:
no_class_keywords: trueprefer_natural_language: truerequired_constraints_block: truelint_rules: true # Auto-run SudoLang linter

Supported Output Formats

FormatWhen to UseValidation
Markdown (default)Single workflow, clear stepsHeaders, frontmatter, placeholders
YAMLMulti-workflow, context-awareKeys, no class, composition
SudoLangLoops, branching, stateNo new, constraints, lint

Auto-selection:bbeval opt picks simplest format that fits logic (Markdown > YAML > SudoLang).


Enforcement Flow

defvalidate_candidate(prompt_str: str, format: str) -> (bool, str):
# 1. Parse (Markdown → AST, YAML → dict, SudoLang → lint)# 2. Check global rules (tokens, phrases)# 3. Check format-specific rules# In optimizer:ifnotvalidate_candidate(candidate, format):
score=0.0# Reject early

Example: Optimized Markdown Output

---description: 'SQL schema review'mode: 'ask'tools: ['runInTerminal', 'getTerminalOutput']---# SQL Schema Reviewer
You are a senior DBA with 15 years in fintech.
## Task
Review `${selection}` for compliance with internal SQL standards.
{{guidelines}}
## Instructions1. Run `EXPLAIN` via terminal
2. Check for missing indexes
3. Suggest fixes only if critical
## Output```diff- Old+ New

SudoLang Linter Integration

# constraints.yamlsudolang:
lint: true

→ Auto-runs:

Lint { style constraints { * obey style guide; prohibit (class) } }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions