Skip to content

workflow fix re-adds stale code-review usage.options metadata #133

Description

@dkropachev

Summary

codex workflow fix code-review currently mutates the code-review workflow by adding a hard-coded usage.options block for the old public API. That block includes removed actions and flags such as read-report, incremental, resume, --action, --target-ref, --base-ref, --review-id, --review-model, and --repro-model.

This conflicts with the current TS-first workflow contract for code-review, where src/workflow.ts owns the API and autocomplete contract. The current public API is only plan and review, with the supported input fields action, commit, target, workingDirectory, model, output, and detailed.

Reproduction

From a clean ~/.codex/workflows/code-review workflow checkout with no usage: block in workflow.yaml:

codex workflow fix code-review

Observe that workflow.yaml is modified to append a legacy block like:

usage:
  options:
    - flag: --action
      valueHint: <review|read-report|list-reports|incremental|resume>
      description: Run mode: review, read-report, list-reports, incremental, or resume.
    - flag: --review-id
      valueHint: <string>
      description: Existing review ID for read-report, incremental, or resume.
    # ...more removed flags...

Actual Behavior

The fixer adds stale autocomplete metadata for the old code-review API.

This directly contradicts the workflow's current docs and tests:

  • README.md says old actions read-report, list-reports, incremental, resume, and retry-repro are no longer public.
  • README.md says removed flags such as --action, --review-id, --target-ref, --base-ref, etc. are rejected.
  • src/workflow.ts parses the action as the first positional argument and rejects unsupported flags.
  • src/tests/code-review-redesign.test.ts asserts review --action review fails with Unsupported CLI flag '--action'.

Expected Behavior

codex workflow fix code-review should not add workflow.yaml usage.options for this TS-first workflow.

Autocomplete and public API metadata should come from src/workflow.ts / generated contract / complete(...), not from stale YAML metadata. If the fixer still needs to repair static metadata, it should only repair neutral metadata such as id, command, title, or userDescription, and should not reintroduce removed API flags.

Likely Source

The stale block appears to be hard-coded in the CLI compatibility repair path:

  • codex-rs/cli/src/workflow_cmd/compat.rs
  • apply_compatibility_repairs(...)
  • is_code_review_repair_target(...)
  • repair_code_review_workflow_metadata(...)
  • CODE_REVIEW_USAGE_OPTIONS_YAML

There are also CLI tests that currently encode the old expectation and should be updated, for example:

  • codex-rs/cli/tests/workflows__cli.rs::assert_code_review_autocomplete_metadata

Suggested Fix

  • Remove the special-case injection of CODE_REVIEW_USAGE_OPTIONS_YAML for code-review.
  • Update CLI repair tests so they no longer expect usage.options, --action, --review-id, or other removed code-review flags.
  • Add or update a regression test proving codex workflow fix code-review does not mutate an already-valid TS-first code-review workflow by appending legacy usage.options.
  • Keep codex workflow validate code-review green after the repair behavior changes.

Validation Used Locally

After manually removing the stale block from the workflow checkout, the workflow validation loop passes:

codex workflow validate code-review
bun run typecheck
bun run build
bun test --preload ./src/tests/setup-env.ts src/tests/*.test.ts

Observed result: code-review is valid, typecheck/build pass, and 4 workflow tests pass.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions