⚙️ STARLARK RUNE DIFFICULTY: Adept Behavioral

The Template Method

Outlining the skeleton of a build ritual with deferred hooks.

✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Template Method
ARCANUM SCHOOL: Conjuration // Ritual Skeletons
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// STARLARK PATTERN //
def execute_build_ritual(hooks_struct):
    results = []
    
    # Hook 1
    if hasattr(hooks_struct, "pre_build"):
        results.append(hooks_struct.pre_build())
        
    # Core inflexible ritual
    results.append("Forging core binary...")
    
    # Hook 2
    if hasattr(hooks_struct, "post_build"):
        results.append(hooks_struct.post_build())
        
    return results

def python_hooks():
    return struct(
        pre_build = lambda: "Linting Python files",
        post_build = lambda: "Bundling into ZIP"
    )
    
# Usage
process = execute_build_ritual(python_hooks())

When standardizing build pipelines across an entire organization, consistency is critical. The Template Method defines the unbreakable skeleton of the build ritual within a core Starlark function. However, it leaves specific semantic gaps—hooks—that can be fulfilled by passing in a structurally typed struct. This enforces the corporate standard while allowing language-specific mages to inject their own pre- and post-processing steps.

Runic Tags: #behavioral #starlark #hermetic