# Step 01.6.7: Implementation Guidance Detection

**Purpose:** Detect and display implementation guidance presence in the loaded story file.
**Behavior:** Purely informational — does not block, does not produce warnings, no error on absence.

---

## Detection Logic

After the story file is loaded into context (Step 01.6), scan for implementation guidance elements:

### Scan for `<implementation>` Elements

```
impl_elements = Grep(pattern="<implementation>", path=story_file, output_mode="count")
```

Count the number of ACs with `<implementation>` elements. Each AC may independently contain or lack implementation hints — handle partial guidance gracefully where some ACs have hints and others do not. Count only ACs with `<implementation>` elements and display accurate per AC count.

### Scan for `## Implementation Guide` Section

```
impl_guide = Grep(pattern="## Implementation Guide", path=story_file)
```

Check whether the story contains an `## Implementation Guide` section with cross-cutting concerns.

---

## Display Summary (Informational Only)

This step is purely informational and produces no error or warning in any scenario. It handles all edge cases gracefully, silently, and without error:

**When Implementation Guide is detected:**
```
Display: "Implementation Guide detected — agents will use for guidance"
Display: "  {count} AC(s) with <implementation> hint elements"
$HAS_IMPL_GUIDE = true
```

**When no Implementation Guide is present (v2.9 stories or absent section):**
```
Display: "No Implementation Guide — agents will rely on AC and Tech Spec only"
$HAS_IMPL_GUIDE = false
```

For v2.9 stories with zero implementation elements, the step completes with accurate zero counts and no error.

---

## Variable Output

| Variable | Type | Description |
|----------|------|-------------|
| `$HAS_IMPL_GUIDE` | Boolean | `true` when `## Implementation Guide` section is present, `false` when section is absent |

This variable is available for downstream phases (02, 03) to conditionally surface implementation guidance.

---

## Edge Case Handling

| Scenario | Behavior |
|----------|----------|
| v2.9 story (zero `<implementation>` elements, no `## Implementation Guide`) | Display zero counts, set `$HAS_IMPL_GUIDE = false`, no error produced |
| Partial guidance (some ACs with hints, some without) | Count only ACs with `<implementation>` elements, display accurate per AC count |
| `## Implementation Guide` present but no AC hints | Display guide detected, zero AC hint count |
| All ACs have `<implementation>` elements | Display total count |
| Malformed or empty `<implementation>` elements | Silently skip, no error |
