brainstorming
brainstorming
You MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or planning anything new, in software or out of it (a talk, a business, a renovation).
cicd-automation-workflow-automateImplements intelligent cicd automation workflow automate with multi-factor skill selection, fallback chains, and adherence to the 5 Laws of Elegant Defense
Independent GitHub snapshot · Automated classification · Original documentation governs
name: cicd-automation-workflow-automate compatibility: opencode completeness: 95 content-types:
Orchestrates intelligent skill selection and execution for cicd automation workflow automate workflows. Applies the 5 Laws of Elegant Defense to guide data naturally through the orchestration pipeline, preventing errors before they occur. Selects optimal skills based on multi-factor scoring including text similarity, historical performance, and system availability.
┌───────────────────────────────────────────────────────────────────────────────┐ │ Orchestration Flow │ └───────────────────────────────────────────────────────────────────────────────┘
User Request ↓ ┌─────────────────┐ │ Parse Request │ │ & Extract │ │ Features │ └────────┬────────┘ ↓ ┌─────────────────────────────────────────────────────────────────────┐ │ Evaluate Available Skills │ │ │ │ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ │ │ │ Skill A │ │ Skill B │ │ Skill C │ │ │ │ - Match Score│ │ - Match Score│ │ - Match Score│ │ │ │ - Confidence │ │ - Confidence │ │ - Confidence │ │ │ │ - History │ │ - History │ │ - History │ │ │ └──────┬───────┘ └──────┬───────┘ └──────┬───────┘ │ │ │ │ │ │ │ └─────────────────┴─────────────────┘ │ │ ↓ │ │ Select Best Skill │ └─────────────────────────────────────────────────────────────────────┘ ↓ ┌─────────────────┐ │ Execute Skill │ └────────┬────────┘ ↓ ┌─────────────────┐ │ Handle Result │ └────────┬────────┘ ↓ ┌─────────────────────────────────────────────────────────────────────┐ │ Error Handling & Fallback │ │ │ │ Success? ────────► Return Result │ │ │ │ Fail? ────────┐ │ │ ↓ │ │ ┌──────────────────────────────────────────────────────────┐ │ │ │ Fallback Chain │ │ │ │ │ │ │ │ 1. Retry with adjusted parameters │ │ │ │ 2. Try Alternative Skill (if available) │ │ │ │ 3. Defer to Human Operator (if critical) │ │ │ │ 4. Log & Return Error │ │ │ └──────────────────────────────────────────────────────────┘ │ └─────────────────────────────────────────────────────────────────────┘
Use this skill when:
Avoid this skill for:
Parse and Analyze Request - Extract intent, entities, and constraints from user input. Checkpoint: All required parameters must be present and in valid format before proceeding.
Score Available Skills - Calculate match scores using multi-factor algorithm:
Checkpoint: Skip to fallback if no skill scores above threshold.
Select Optimal Skill - Choose skill with highest score that meets minimum confidence. Checkpoint: Verify skill has not been disabled or deprecated.
Execute with Fallback - Run skill execution wrapped in retry and fallback logic. Checkpoint: Log all execution attempts for audit trail.
Return or Fallback - Either return successful result or apply fallback chain:
related-skillsCheckpoint: Record outcome with timing and confidence metadata.
def orchestrate_cicd_pipeline(
pipeline_config: Dict[str, Any],
target_env: str,
branch_rules: List[Dict[str, str]]
) -> Dict[str, Any]:
"""Orchestrate CI/CD workflow by validating stages and selecting execution strategy.
Applies 5 Laws of Elegant Defense:
- Law 1: Early exit on missing pipeline config or invalid target environment
- Law 2: Parse and validate pipeline structure before execution
- Law 3: Return new execution plan without mutating original config
- Law 4: Fail immediately on invalid stage dependencies or missing secrets
"""
if not pipeline_config or "stages" not in pipeline_config:
raise ValueError("Pipeline config must contain 'stages' definition")
if target_env not in ("dev", "staging", "production"):
raise ValueError(f"Invalid target environment: {target_env}")
# Parse pipeline structure (Law 2)
stages = pipeline_config["stages"]
execution_plan = []
for stage in stages:
# Validate stage dependencies (Law 4)
if "depends_on" in stage:
for dep in stage["depends_on"]:
if dep not in [s["name"] for s in stages]:
raise ValueError(f"Stage '{stage['name']}' depends on unknown stage '{dep}'")
# Select execution strategy based on environment rules (Law 1)
strategy = _match_branch_rule(stage, branch_rules, target_env)
if not strategy:
strategy = "default_runner"
execution_plan.append({
"stage": stage["name"],
"strategy": strategy,
"timeout_minutes": stage.get("timeout", 30),
"retry_policy": stage.get("retry", {"max_attempts": 2})
})
# Return new structure (Law 3)
return {
"pipeline_id": pipeline_config.get("id", "unknown"),
"target_env": target_env,
"execution_order": execution_plan,
"validation_status": "passed"
}
def execute_cicd_stage(
stage_config: Dict[str, Any],
runner_pool: List[Dict[str, str]],
artifact_store: Dict[str, Any]
) -> Dict[str, Any]:
"""Execute a CI/CD stage with environment-specific fallback chains.
Implements Fail Fast, Fail Loud (Law 4) for pipeline execution:
- Invalid runner states halt immediately
- No silent stage skips or partial artifact commits
Fallback chain for CI/CD:
1. Retry stage on same runner with exponential backoff
2. Failover to secondary runner pool
3. Trigger manual approval gate if production deployment
4. Rollback previous stage artifacts if critical failure
"""
if not stage_config or "name" not in stage_config:
raise ValueError("Stage config must contain 'name'")
active_runners = [r for r in runner_pool if r.get("status") == "available"]
if not active_runners:
raise RuntimeError("No available CI/CD runners in pool")
current_runner = active_runners[0]
max_retries = stage_config.get("retry_policy", {}).get("max_attempts", 2)
for attempt in range(max_retries + 1):
try:
# Execute stage on selected runner
result = _run_stage_on_runner(current_runner, stage_config)
# Validate artifacts were produced (Law 4)
if not result.get("artifacts") and stage_config.get("requires_artifacts"):
raise RuntimeError(f"Stage '{stage_config['name']}' failed to produce required artifacts")
# Store artifacts atomically (Law 3)
artifact_store[f"{stage_config['name']}_v{attempt}"] = result["artifacts"]
return {
"stage": stage_config["name"],
"status": "completed",
"runner_used": current_runner["id"],
"attempts": attempt + 1,
"artifacts_stored": True
}
except RunnerOfflineError:
if attempt == max_retries:
return _failover_to_backup_runner(stage_config, runner_pool)
continue
except ArtifactValidationError as e:
raise RuntimeError(f"Artifact validation failed for {stage_config['name']}: {e}") from e
# All retries exhausted - Fail Loud
raise RuntimeError(f"Stage '{stage_config['name']}' exhausted all runner retries")
code-philosophy (5 Laws of Elegant Defense) in all logicWhen applying this skill, produce:
| Skill | Purpose |
|---|---|
closed-loop-delivery | Delivery pipeline feedback and iteration patterns |
Authoritative documentation links for this skill's domain. The model follows markdown links at load time to resolve external references and inline content.