Back to stack
Dec 30, 2025
4 min read

Briq Enforcement – Guaranteed Consistency

Enforced briq sensitivity ranges with automatic retry and merge logic for predictable task decomposition

Briq Enforcement

The Briq Enforcement system ensures that InstruQtor produces a consistent number of briqs based on the configured sensitivity level.

The Problem It Solves

In previous versions, briq_sensitivity was just a “hint” to the AI. This resulted in wildly inconsistent outputs:

RunSensitivityExpected BriqsActual BriqsResult
A82-31Polish loop failure
B82-310Worked but inefficient
C82-37Unpredictable

The Solution (v1.0.0)

Hard-coded briq ranges with automatic enforcement:

BRIQ_RANGES = {
    9: (1, 1, 1),      # Monolithic: exactly 1 briq
    8: (2, 3, 2),      # Very Broad: 2-3 briqs
    7: (3, 5, 4),      # Broad: 3-5 briqs (RECOMMENDED)
    6: (5, 8, 6),      # Feature-level: 5-8 briqs
    5: (8, 12, 10),    # Component-level: 8-12 briqs
    4: (10, 15, 12),   # Balanced: 10-15 briqs
    3: (15, 20, 18),   # Standard: 15-20 briqs
    2: (20, 30, 25),   # High Granularity: 20-30 briqs
    1: (30, 40, 35),   # Very High: 30-40 briqs
    0: (40, 60, 50),   # Atomic: 40-60 briqs
}
# Format: (min_briqs, max_briqs, target_briqs)

How It Works

1. AI Generation with Mandatory Count:

prompt = f"""
Generate {target} briqs for this task.
MANDATORY: You MUST produce between {min_briqs} and {max_briqs} briqs.
"""

2. Count Validation:

def validate_briq_count(briqs, sensitivity):
    min_b, max_b, target = BRIQ_RANGES[sensitivity]
    actual = len(briqs)
    
    if actual < min_b:
        return "TOO_FEW", f"Got {actual}, need at least {min_b}"
    if actual > max_b:
        return "TOO_MANY", f"Got {actual}, max is {max_b}"
    
    return "OK", f"Briq count {actual} is within range [{min_b}-{max_b}]"

3. Enforcement Actions:

If Too Few → Retry (up to 2 attempts):

if status == "TOO_FEW":
    prompt = f"""
    Your previous attempt produced {actual} briqs.
    This is INSUFFICIENT. You MUST produce at least {min_b} briqs.
    Break down the task into MORE granular steps.
    """
    # Re-run AI with stronger prompt

If Too Many → Merge:

if status == "TOO_MANY":
    briqs = merge_briqs(briqs, max_b)
    # Intelligently merges consecutive briqs

Merge Logic

When the AI produces too many briqs, the system intelligently merges them:

def merge_briqs(briqs, target_count):
    """Merge consecutive briqs to reach target count"""
    while len(briqs) > target_count:
        # Find best merge candidate (smallest consecutive pair)
        best_idx = find_best_merge_pair(briqs)
        
        # Merge briq[best_idx] and briq[best_idx + 1]
        merged = {
            'title': f"{briqs[best_idx]['title']} + {briqs[best_idx+1]['title']}",
            'description': combine_descriptions(briqs[best_idx], briqs[best_idx+1]),
            'files': briqs[best_idx]['files'] + briqs[best_idx+1]['files']
        }
        
        briqs = briqs[:best_idx] + [merged] + briqs[best_idx+2:]
    
    return briqs

Configuration

Set in config.yaml:

options:
  briq_sensitivity: 7  # RECOMMENDED: 3-5 briqs per cycle

Or via CLI:

./qonqrete.sh run -b 5  # Component-level: 8-12 briqs
./qonqrete.sh run -b 3  # Standard: 15-20 briqs

Sensitivity Guide

SensitivityRangeBest For
91 briqSingle-file scripts, quick fixes
73-5Most projects (default)
58-12Multi-component systems
315-20Large applications
040-60Maximum granularity

Logging

The system logs enforcement status:

[InstruQtor] Validating briq count...
[InstruQtor] [OK] Briq count 4 is within range [3-5]

Or on retry:

[InstruQtor] [RETRY] Got 1 briq, need at least 3
[InstruQtor] Regenerating with stronger prompt...
[InstruQtor] [OK] Briq count 4 is within range [3-5]

Introduced In

v1.0.0-stable - December 30, 2025