{
  "batch": "naming_quality",
  "batch_index": 5,
  "assessments": {
    "naming_quality": 81.0
  },
  "dimension_notes": {
    "naming_quality": {
      "evidence": [
        "The 16 handle_* functions clearly communicate their purpose: handle_init, handle_clarify, handle_plan, handle_critique, handle_evaluate, handle_integrate, handle_gate, handle_execute, handle_review, handle_status, handle_audit, handle_list, handle_override, handle_setup, handle_setup_global, handle_config",
        "Domain-specific names are precise: slugify, compute_plan_delta_percent, unresolved_significant_flags, normalize_flag_record, update_flags_after_critique, build_evaluation, flag_weight, robustness_critique_instruction",
        "Generic utility names are appropriate for their scope: now_utc, json_dump, atomic_write_text, atomic_write_json, read_json, sha256_text, sha256_file",
        "The artifact file 'link.json' does not communicate that it is the gate check result",
        "The function 'ensure_command' returns Optional[str] — the name suggests it ensures something exists (imperative) but it actually just checks and returns the path or None (query). Name/behavior mismatch.",
        "The naming vocabulary shows 'handle' (16), 'run' (5), 'load' (3), 'save' (3) — these are consistent verb conventions",
        "MOCK_ENV_VAR name is clear. WORKER_TIMEOUT_SECONDS is self-documenting.",
        "session_key_for returns a string key — the name is slightly indirect but acceptable",
        "create_claude_prompt and create_codex_prompt are clear, but create_codex_prompt delegates to create_claude_prompt for some steps, which is confusing given the distinct names"
      ],
      "impact_scope": "module",
      "fix_scope": "single_edit",
      "confidence": "high"
    }
  },
  "dimension_judgment": {
    "naming_quality": {
      "dimension_character": "Names in this codebase are generally domain-precise and follow consistent verb conventions (handle_*, load_*, save_*, compute_*). A developer reading the function list can predict behavior in most cases. The main friction points are a few name/behavior mismatches: ensure_command acts as a query not an imperative, and the artifact name 'link.json' obscures its role as the gate check result. The create_codex_prompt function name implies independent prompt construction but actually delegates to create_claude_prompt for several steps.",
      "score_rationale": "The handle_* naming convention is exemplary — 16 handlers all named after their workflow step. Domain functions like compute_plan_delta_percent, unresolved_significant_flags, and flag_weight communicate intent precisely. This pushes toward 85+. However, ensure_command is a genuine name/behavior mismatch (imperative name, query behavior), and the asymmetric relationship between create_claude_prompt and create_codex_prompt is confusing when their names suggest they are peers. Against the 80 anchor (names that regularly don't communicate intent), this is slightly above — most names are good, with a few specific mismatches."
    }
  },
  "issues": [
    {
      "dimension": "naming_quality",
      "identifier": "ensure_command_name_mismatch",
      "summary": "ensure_command() name implies it ensures/installs a command but it only checks existence",
      "related_files": ["megaplan/cli.py"],
      "evidence": [
        "Line 520-521: def ensure_command(name: str) -> str | None: return shutil.which(name)",
        "The 'ensure' prefix in the codebase is used for side-effecting functions: ensure_runtime_layout() actually creates directories. ensure_command() is a pure query returning Optional[str].",
        "Callers use it as a check: bool(ensure_command('claude')) in handle_init and run_gate_checks"
      ],
      "suggestion": "Rename to find_command() or which_command() to match its query semantics. The 'ensure' prefix should be reserved for functions that guarantee a postcondition.",
      "confidence": "high",
      "impact_scope": "local",
      "fix_scope": "single_edit"
    },
    {
      "dimension": "naming_quality",
      "identifier": "codex_prompt_misleading_delegation",
      "summary": "create_codex_prompt delegates to create_claude_prompt for clarify/plan/integrate steps, obscuring the relationship",
      "related_files": ["megaplan/cli.py"],
      "evidence": [
        "Line 857-859: create_codex_prompt checks if step is in {clarify, plan, integrate} and returns create_claude_prompt(step, state, plan_dir)",
        "Conversely, create_claude_prompt delegates to create_codex_prompt for critique/execute steps (line 851-852)",
        "The names suggest two independent, agent-specific prompt generators, but they are actually cross-dependent with shared logic"
      ],
      "suggestion": "Extract a shared create_prompt(step, state, plan_dir) function that handles common steps, then have create_claude_prompt and create_codex_prompt only handle their agent-specific steps. Alternatively, rename to clarify the delegation: create_prompt_for_agent(step, agent, state, plan_dir).",
      "confidence": "medium",
      "impact_scope": "module",
      "fix_scope": "single_edit"
    }
  ],
  "retrospective": {
    "root_causes": ["ensure_command was likely named by analogy with ensure_runtime_layout but without matching the imperative semantics", "The prompt generation functions grew organically as agents were added, leading to mutual delegation rather than a clean shared base"],
    "likely_symptoms": [],
    "possible_false_positives": []
  },
  "context_updates": {
    "naming_quality": {
      "add": [
        {
          "header": "Domain-precise handle_* verb convention",
          "description": "All 16 command handlers use handle_ prefix followed by the exact workflow step name. A developer can find any handler by searching handle_{step}. This is an exemplary naming convention for CLI dispatch.",
          "settled": true,
          "positive": true
        },
        {
          "header": "Precise domain function names",
          "description": "Functions like compute_plan_delta_percent, unresolved_significant_flags, update_flags_after_critique, and robustness_critique_instruction communicate their exact purpose. A developer can predict behavior from the name alone.",
          "settled": true,
          "positive": true
        },
        {
          "header": "Consistent verb vocabulary across codebase",
          "description": "The codebase uses a small, consistent set of verb prefixes: handle (command dispatch), load/save (state persistence), compute/build (derivation), create (prompt generation), run (execution). Each prefix has consistent semantics.",
          "settled": true,
          "positive": true
        }
      ]
    }
  }
}
