← Back to Phase Detail

Routing Logic

The complete Phase 0 decision tree: source detection, HARD BLOCK, audience routing, and every edge case with full pseudocode

01

Source Detection in Detail

Source detection is the very first decision node in the orchestrator. Before any analysis token is spent, the skill must know where the source code lives. There are exactly three paths — and every edge case that can occur along the way.

The complete decision tree:

💬
User Input
🔍
Pattern Match
Validation
📂
Source Object

Path 1 — Git URL: If the input starts with "http" or "git@", a git clone is executed into a temporary directory. GitHub URLs without a ".git" suffix get it appended automatically. URLs containing "/tree/" or "/blob/" (pointing to a subdirectory or file in the browser) are reduced to the repository root. If the clone fails, the skill distinguishes between auth errors (private repo, missing token) and 404 (repo does not exist).

Path 2 — Filesystem Path: Absolute paths (/...), relative paths (./...), and home paths (~/) are resolved. Critical edge case: if the path points to a file instead of a directory, the skill does not fail silently but provides a clear error message suggesting the parent directory. Empty directories also trigger an error.

Path 3 — CWD: The input ".", empty input, or phrases like "this project" use the current working directory. Here too, the directory must contain at least one readable file.

No Match: If none of the three patterns matches, an error message listing all three accepted formats is shown. No fallback, no guessing.

02

The HARD BLOCK Mechanism

After successful source detection, the orchestrator faces an impassable gate: two mandatory questions must be answered before Phase 1 may begin. There is no shortcut, no default, and no "later".

HARD BLOCK — The Two Mandatory Questions

Question 1: Language(s)?

Accepted: "de", "en", "both", "Deutsch", "English", "German and English". Determines filename suffixes (_de.html, _en.html) and content language.

Question 2: Audiences?

Accepted: explicit naming of one or more standard audiences (Developers, Users, Executives) or custom audiences. "all" and "everyone" are not accepted — too vague.

The guard logic works as follows:

1. The orchestrator has a fixed list of two mandatory questions. Each question has a prompt and a validator.

2. For each question, the user is asked. Their response is first checked for bypass attempts: "just go", "skip", "whatever", and similar phrases are detected and rejected.

3. Then the response is validated. For audiences: "all" or "everyone" is too vague and rejected. Specific names (Developers, Users, Executives) or custom audiences are accepted.

4. The loop repeats up to 5 times. After that, the skill execution is aborted — better no result than a wrong one.

Core rule: No defaults. No inference from context. No heuristics. The user must answer explicitly.

03

Audience Routing

Once the mandatory questions are answered, the orchestrator must derive a pipeline configuration from the responses: who gets which files, with which suffixes, to what depth?

Order Audience File Suffix Example L0
1st (Most general) Most general audience No suffix index_en.html
2nd Developers _dev index_dev_en.html
3rd Executives _exec index_exec_en.html
4th (Custom) e.g. "DevOps Team" _devops-team index_devops-team_en.html

The routing algorithm creates one pipeline per audience-language combination:

1. Audiences are sorted by generality. The most general (typically Users) comes first and receives no suffix — their files are the "default" view.

2. Each subsequent audience gets its predefined suffix: _dev for Developers, _exec for Executives, a derived slug for custom audiences.

3. For each audience, as many pipelines as languages are created. With 2 audiences and 2 languages, this yields 4 pipelines.

4. Each pipeline contains all information the pipeline agent needs: audience name, emoji, suffix, language, max depth, HS thresholds, and naming pattern.

04

Edge Cases & Error Handling

Every decision node in Phase 0 has failure states. Here is the complete directory of all edge cases with their handling strategies.

Edge Case Detection Handling
User changes audiences mid-generation "Change audiences" during Phase 3/4 Full restart. Discard all generated files. Rerun Phase 0 with new answers. Partial updates are inconsistent.
Source directory is empty count_readable_files() == 0 Immediate error in source detection. Clear message: "No analyzable files found."
Path does not exist !exists(resolved_path) Immediate error. Show path so user can spot the typo.
Path points to a file is_file(resolved_path) Error with hint: "Please provide the parent directory." The skill analyzes projects, not individual files.
GitHub returns 404 git clone exit code 128 Distinguish: repo does not exist vs. repo is private. Both produce code 128, but stderr differs.
Private repo, no token stderr contains "auth" Error with clear hint about missing token. Suggest cloning locally as alternative.
User says "all" as audience validate_audiences() rejects Re-prompt: "Please name audiences specifically." No default to all three standard audiences.
User fails to answer 5 times attempt > max_attempts Skill abort. Better no result than a wrong one.

Audience change mid-generation: If the user wants to change audiences while generation is running, there is no way to "bend" already-generated files. Helpfulness scores are audience-specific, curricula are based on those scores, and cross-links reference audience-specific variants. A partial update would lead to inconsistent results. Therefore: full restart.

GitHub error diagnosis: A failed clone (exit code 128) can have two causes: the repository does not exist, or it is private and access is missing. The skill analyzes the stderr output to distinguish between the two cases and provides a specific error message.

✏️ Knowledge Check

User says: "Make a course from ./my-project for everyone." Is the HARD BLOCK satisfied?

Yes — source is clear (./my-project) and "everyone" means all three standard audiences
No — "everyone" is too vague, specific audiences are missing, and language is not specified
Partially — source is fine, but audiences and language still need follow-up
🔧 Developer — All L3 Pages