---
phase: 08-dork-engine
plan: 07
type: execute
wave: 3
depends_on: [08-02, 08-03, 08-04, 08-06]
files_modified:
  - pkg/dorks/count_test.go
autonomous: true
requirements:
  - DORK-02
must_haves:
  truths:
    - "A guardrail test asserts pkg/dorks.NewRegistry() loads >= 150 dorks"
    - "Per-source minimums enforced: github>=50, google>=30, shodan>=20, censys>=15, zoomeye>=10, fofa>=10, gitlab>=10, bing>=5"
    - "All 8 sources present in Stats().BySource"
    - "All 5 categories present in Stats().ByCategory"
    - "All dork IDs are unique (no collisions between source files)"
  artifacts:
    - path: "pkg/dorks/count_test.go"
      provides: "Guardrail test preventing regression below 150-dork threshold"
      contains: "TestDorkCountGuardrail"
  key_links:
    - from: "pkg/dorks/count_test.go"
      to: "pkg/dorks.NewRegistry()"
      via: "direct call to real embedded FS"
      pattern: "NewRegistry\\(\\)"
---

<objective>
Lock in the DORK-02 "150+ built-in dorks" requirement with a guardrail test
that runs against the real embedded filesystem. If a future contributor removes
a dork file or breaks a source's YAML, CI fails loudly instead of silently
dropping coverage. Also asserts per-source minimums and ID uniqueness so partial
regressions are caught.

Purpose: Prevents silent regression of the requirement that took plans 02-04
to satisfy.
Output: One test file with a few targeted assertions.
</objective>

<execution_context>
@$HOME/.claude/get-shit-done/workflows/execute-plan.md
@$HOME/.claude/get-shit-done/templates/summary.md
</execution_context>

<context>
@.planning/phases/08-dork-engine/08-CONTEXT.md
@pkg/dorks/registry.go
</context>

<tasks>

<task type="auto" tdd="true">
  <name>Task 1: Dork count + uniqueness guardrail test</name>
  <files>pkg/dorks/count_test.go</files>
  <behavior>
    - TestDorkCountGuardrail: NewRegistry() returns >= 150 dorks total
    - TestDorkCountPerSource: each of the 8 sources meets its minimum
    - TestDorkCategoriesPresent: all 5 categories appear in Stats().ByCategory
    - TestDorkIDsUnique: walking Registry.List(), no duplicate IDs
  </behavior>
  <action>
    Create pkg/dorks/count_test.go:

    ```go
    package dorks

    import "testing"

    func TestDorkCountGuardrail(t *testing.T) {
        r, err := NewRegistry()
        if err != nil {
            t.Fatalf("NewRegistry: %v", err)
        }
        const minTotal = 150
        if got := len(r.List()); got < minTotal {
            t.Fatalf("dork count regression: got %d, want >= %d (see DORK-02)", got, minTotal)
        }
    }

    func TestDorkCountPerSource(t *testing.T) {
        r, err := NewRegistry()
        if err != nil { t.Fatal(err) }

        minimums := map[string]int{
            "github":  50,
            "google":  30,
            "shodan":  20,
            "censys":  15,
            "zoomeye": 10,
            "fofa":    10,
            "gitlab":  10,
            "bing":    5,
        }
        stats := r.Stats()
        for src, min := range minimums {
            if stats.BySource[src] < min {
                t.Errorf("source %s: got %d, want >= %d", src, stats.BySource[src], min)
            }
        }
    }

    func TestDorkCategoriesPresent(t *testing.T) {
        r, err := NewRegistry()
        if err != nil { t.Fatal(err) }
        required := []string{"frontier", "specialized", "infrastructure", "emerging", "enterprise"}
        stats := r.Stats()
        for _, c := range required {
            if stats.ByCategory[c] == 0 {
                t.Errorf("category %q missing", c)
            }
        }
    }

    func TestDorkIDsUnique(t *testing.T) {
        r, err := NewRegistry()
        if err != nil { t.Fatal(err) }
        seen := map[string]string{}
        for _, d := range r.List() {
            if existing, ok := seen[d.ID]; ok {
                t.Errorf("duplicate dork id %q (second occurrence: %s, first: %s)", d.ID, d.Source, existing)
            }
            seen[d.ID] = d.Source
        }
    }
    ```

    Note: Stats struct was defined in 08-01 with BySource and ByCategory
    map[string]int fields — confirm the exact field names match. If the
    implementation used different names, align test accordingly (do not
    modify 08-01; adjust the test).
  </action>
  <verify>
    <automated>cd /home/salva/Documents/apikey && go test ./pkg/dorks/ -run 'TestDork(Count|Categories|IDs)' -v</automated>
  </verify>
  <done>
    All four guardrail tests pass against the real embedded filesystem. The
    DORK-02 150+ floor is now CI-enforced.
  </done>
</task>

</tasks>

<verification>
`go test ./pkg/dorks/...` passes (full suite).
`go test ./...` for the repo passes.
</verification>

<success_criteria>
- DORK-02 enforced by test (not just counted by grep)
- Per-source minimums match the 50/30/20/15/10/10/10/5 distribution
- No duplicate dork IDs across the embedded corpus
</success_criteria>

<output>
After completion, create `.planning/phases/08-dork-engine/08-07-SUMMARY.md`
</output>
