{
  "schema_version": "spec-first.spec-write-tasks-output-quality-cases.v1",
  "skill": "spec-write-tasks",
  "source_refs": [
    "skills/spec-write-tasks/SKILL.md",
    "skills/spec-write-tasks/references/task-pack-schema.md",
    "skills/spec-write-tasks/references/task-quality-guide.md",
    "tests/fixtures/spec-write-tasks/valid/source-plan.md",
    "tests/fixtures/spec-write-tasks/valid/task-pack.md",
    "tests/fixtures/spec-write-tasks/small-plan/source-plan.md",
    "tests/fixtures/spec-write-tasks/high-risk-review/source-plan.md",
    "tests/fixtures/spec-write-tasks/high-risk-review/task-pack.md"
  ],
  "source_ref_authority": "source",
  "coverage_tags": ["expected", "output-quality"],
  "cases": [
    {
      "id": "file-backed-valid-task-pack-handoff",
      "input": "Compile a settled source plan into an executable task pack.",
      "input_files": [
        {
          "path": "tests/fixtures/spec-write-tasks/valid/source-plan.md",
          "evidence": "file-backed fixture"
        },
        {
          "path": "tests/fixtures/spec-write-tasks/valid/task-pack.md",
          "evidence": "file-backed fixture"
        }
      ],
      "baseline_risks": [
        "A generic task split omits spec_id/source_plan_hash and cannot be deterministically handed to spec-work.",
        "Task cards restate the plan instead of providing bounded files, test_focus, done_signal, and stop_if."
      ],
      "with_skill_expectations": [
        "The output includes a Task Pack Contract JSON block with executable task fields.",
        "The final decision envelope carries deterministic_handoff, validation, reason_code, and next_action."
      ],
      "objective_assertions": [
        "Task pack frontmatter has type: task-pack, generated_by: spec-write-tasks, status: derived, and mode: derived.",
        "source_plan_hash uses sha256:<64-hex> and is validated by spec-first tasks validate --json.",
        "Every executable task has files, test_focus, done_signal, wave, stop_if, and a source anchor."
      ],
      "deterministic_assertions": [
        {
          "id": "valid-frontmatter-type",
          "kind": "frontmatter_equals",
          "target_file": "tests/fixtures/spec-write-tasks/valid/task-pack.md",
          "field": "type",
          "expected": "task-pack"
        },
        {
          "id": "valid-task-pack-validates",
          "kind": "task_pack_validation",
          "target_file": "tests/fixtures/spec-write-tasks/valid/task-pack.md",
          "expected": {
            "task_pack_validity": "valid",
            "deterministic_handoff": true
          }
        },
        {
          "id": "valid-task-fields-present",
          "kind": "task_contract_every_task_has_fields",
          "target_file": "tests/fixtures/spec-write-tasks/valid/task-pack.md",
          "fields": ["task_id", "files", "test_focus", "done_signal", "wave", "stop_if"]
        },
        {
          "id": "valid-no-runtime-files",
          "kind": "task_contract_no_generated_runtime_files",
          "target_file": "tests/fixtures/spec-write-tasks/valid/task-pack.md"
        }
      ],
      "expected_outcome": "A skill-guided output is executable only when identity, freshness, and Task Pack Contract structure validate.",
      "evidence_status": "file-backed fixture"
    },
    {
      "id": "small-plan-skip-preserves-context-budget",
      "input": "Split a one-file documentation fix plan into tasks.",
      "input_files": [
        {
          "path": "tests/fixtures/spec-write-tasks/small-plan/source-plan.md",
          "evidence": "file-backed fixture"
        }
      ],
      "baseline_risks": [
        "The skill generates a task pack even though direct spec-work execution has lower carrying cost."
      ],
      "with_skill_expectations": [
        "The output chooses decision: skip and reason_code: small_plan.",
        "The output recommends spec-work-plan rather than creating a derived handoff."
      ],
      "objective_assertions": [
        "No docs/tasks artifact is required.",
        "The explanation says direct execution is intentional, not an omission."
      ],
      "deterministic_assertions": [
        {
          "id": "skip-branch-documented",
          "kind": "file_contains",
          "target_file": "skills/spec-write-tasks/SKILL.md",
          "expected": "`skip`"
        },
        {
          "id": "skip-does-not-require-task-artifact",
          "kind": "file_contains",
          "target_file": "skills/spec-write-tasks/references/execution-handoff-contract.md",
          "expected": "spec-work-plan"
        }
      ],
      "expected_outcome": "A high-quality run skips task compilation when it would add context cost without reducing execution risk.",
      "evidence_status": "file-backed fixture",
      "missing_evidence": ["model execution evidence", "human adjudication"]
    },
    {
      "id": "high-risk-pack-review-handoff-needs-authorization",
      "input": "Compile a task pack for a source/runtime boundary plan with review_gate: required tasks.",
      "input_files": [
        {
          "path": "tests/fixtures/spec-write-tasks/high-risk-review/source-plan.md",
          "evidence": "file-backed fixture"
        },
        {
          "path": "tests/fixtures/spec-write-tasks/high-risk-review/task-pack.md",
          "evidence": "file-backed fixture"
        }
      ],
      "baseline_risks": [
        "The skill silently chains into another workflow without explicit bounded dispatch authorization.",
        "The handoff loses the concrete review reason and current-host invocation."
      ],
      "with_skill_expectations": [
        "The output sets next_action: review-task-pack with one concrete reason.",
        "The output includes a copy-ready current-host document-review invocation.",
        "The output sets dispatch_authorization: missing unless the parent workflow or user explicitly authorized the continuation."
      ],
      "objective_assertions": [
        "No document-review continuation runs solely because this standalone skill was triggered.",
        "The returned envelope exposes dispatch_authorization and reason_code."
      ],
      "deterministic_assertions": [
        {
          "id": "high-risk-task-pack-validates",
          "kind": "task_pack_validation",
          "target_file": "tests/fixtures/spec-write-tasks/high-risk-review/task-pack.md",
          "expected": {
            "task_pack_validity": "valid",
            "deterministic_handoff": true
          }
        },
        {
          "id": "high-risk-review-gate-present",
          "kind": "task_contract_any_task_has_review_gate",
          "target_file": "tests/fixtures/spec-write-tasks/high-risk-review/task-pack.md",
          "expected": "required"
        },
        {
          "id": "high-risk-dispatch-missing-documented",
          "kind": "file_contains",
          "target_file": "skills/spec-write-tasks/references/execution-handoff-contract.md",
          "expected": "dispatch_authorization: missing"
        }
      ],
      "expected_outcome": "High-risk task packs get decisive review handoff without turning spec-write-tasks into a general workflow orchestrator.",
      "evidence_status": "file-backed fixture",
      "missing_evidence": ["provider telemetry", "human adjudication"]
    },
    {
      "id": "deep-plan-large-unit-fanout",
      "input": "Compile a deep source plan whose U4 contains a new module, path helpers, marker behavior, init orchestration, all-repos behavior, dry-run/apply behavior, and failure reporting.",
      "source_ref_authority": "historical",
      "source_refs": [
        "docs/plans/2026-06-22-001-feat-user-language-sync-plan.md",
        "docs/tasks/2026-06-22-001-feat-user-language-sync-tasks.md"
      ],
      "input_files": [
        {
          "path": "docs/plans/2026-06-22-001-feat-user-language-sync-plan.md",
          "evidence": "file-backed fixture"
        },
        {
          "path": "docs/tasks/2026-06-22-001-feat-user-language-sync-tasks.md",
          "evidence": "file-backed fixture"
        }
      ],
      "baseline_risks": [
        "The skill mechanically maps one large implementation unit to one task because the source plan uses a single U-ID.",
        "The resulting task passes deterministic validation but still forces the executor to privately split module, integration, output, and workspace behavior."
      ],
      "with_skill_expectations": [
        "The output may repeat the same source_unit on multiple tasks when a source unit has multiple independent feedback loops.",
        "The large unit is split by validation surface, such as module/path-helper behavior before init integration and output reporting.",
        "The final task pack remains deterministically valid after fan-out."
      ],
      "objective_assertions": [
        "At least one source_unit appears in more than one task when that unit has separable feedback loops.",
        "The fan-out tasks have narrower files, test_focus, done_signal, and stop_if values rather than duplicated goals.",
        "The task pack validates with spec-first tasks validate --json and deterministic_handoff: true."
      ],
      "deterministic_assertions": [
        {
          "id": "fanout-guidance-is-reference-owned",
          "kind": "file_contains",
          "target_file": "skills/spec-write-tasks/references/task-quality-guide.md",
          "expected": "Large Implementation Unit Fan-Out"
        },
        {
          "id": "large-plan-threshold-not-entrypoint",
          "kind": "file_not_contains",
          "target_file": "skills/spec-write-tasks/SKILL.md",
          "expected": "large-plan threshold"
        }
      ],
      "expected_outcome": "A high-quality run avoids preserving an oversized implementation unit as one executable task when it contains multiple independent feedback loops.",
      "evidence_status": "file-backed fixture",
      "missing_evidence": ["provider telemetry", "human adjudication"]
    },
    {
      "id": "degraded-helper-signal-does-not-downgrade-deep-plan",
      "input": "Compile a very large team-standards governance plan after `task-governance-signals` returns `collection_status: degraded`, `reason_codes: [planning-context-unreadable, candidate-lightweight]`, and `candidate_level: lightweight`.",
      "source_ref_authority": "historical",
      "source_refs": [
        "docs/plans/2026-06-21-004-feat-team-standards-governance-layer-plan.md"
      ],
      "input_files": [
        {
          "path": "docs/plans/2026-06-21-004-feat-team-standards-governance-layer-plan.md",
          "evidence": "file-backed fixture"
        }
      ],
      "baseline_risks": [
        "A generic task compiler lets a degraded helper output's lightweight candidate override the source plan's deep implementation structure.",
        "The final handoff omits the helper degradation from Orientation Evidence, so downstream reviewers cannot tell why helper-derived risk signals were ignored."
      ],
      "with_skill_expectations": [
        "The output records degraded helper output as advisory orientation evidence or envelope limitations.",
        "The compile/skip decision is based on source-plan structure, implementation units, dependency graph, file surfaces, and verification spread.",
        "Large source units fan out only when they have separable feedback loops, not merely because the helper signal is degraded."
      ],
      "objective_assertions": [
        "The task pack compiles despite the degraded helper returning candidate_level: lightweight.",
        "Orientation Evidence mentions the degraded helper status or `planning-context-unreadable` limitation.",
        "The task pack validates with spec-first tasks validate --json and deterministic_handoff: true.",
        "At least one source_unit appears in more than one task when the source unit contains distinct acquisition/template and skill-reference feedback loops."
      ],
      "deterministic_assertions": [
        {
          "id": "degraded-helper-advisory-guidance",
          "kind": "file_contains",
          "target_file": "skills/spec-write-tasks/references/task-quality-guide.md",
          "expected": "ignore its `candidate_level` for compile/skip decisions"
        },
        {
          "id": "task-signals-not-primary",
          "kind": "file_not_contains",
          "target_file": "skills/spec-write-tasks/SKILL.md",
          "expected": "Use `task-governance-signals.v1` as the primary complexity evidence"
        }
      ],
      "expected_outcome": "A high-quality run treats degraded helper signals as limitations, not as authority to skip or downgrade a deep source plan.",
      "evidence_status": "file-backed fixture",
      "missing_evidence": ["provider telemetry", "human adjudication"]
    }
  ]
}
