Skip to content

Add DRP CLI, extensible linter, packaging entry point, and validation workflow#6

Open
safal207 wants to merge 6 commits into
mainfrom
codex/add-cli-utility,-linter,-and-ci/cd-pipeline
Open

Add DRP CLI, extensible linter, packaging entry point, and validation workflow#6
safal207 wants to merge 6 commits into
mainfrom
codex/add-cli-utility,-linter,-and-ci/cd-pipeline

Conversation

@safal207

@safal207 safal207 commented May 2, 2026

Copy link
Copy Markdown
Owner

Motivation

  • Provide a simple, standard CLI to run the existing DRP validator over files and globs and to surface results in a human-friendly colored format.
  • Provide a lightweight, extensible linter for style and best-practice guidance for DRP records so projects can opt-in to non-blocking hygiene checks.
  • Make the CLI installable via a console_scripts entry point so CI and developers can call drp-validate consistently.
  • Add a dedicated GitHub Actions workflow to run validation on examples/*.json for push and PRs to main.

Description

  • Added drp_cli.py, a small CLI wrapper that supports validation of one or more paths/globs, a --strict placeholder flag, an optional --lint run-after-validation flag, and a lint subcommand; it prints ANSI-colored output and returns a non-zero exit code when validation fails. The CLI uses the existing validator API (tools/drp_validator).
  • Added linter.py, an extensible linter with a Warning dataclass, a @register_rule decorator for rule registration, and the requested baseline rules: record_id format, timestamp recommendation for decisions, priority recommendation for root decisions, causal_trace linkage recommendation, and non-empty content.description checks; provides lint_record and lint_data helpers.
  • Added setup.py packaging metadata with a console_scripts entry point so pip install . exposes drp-validate.
  • Added .github/workflows/drp_validate.yml which installs the package on Python 3.10 and runs drp-validate examples/*.json (blocking) and drp-validate --lint examples/*.json (non-blocking).
  • Added basic tests tests/test_drp_cli_linter.py covering path expansion and a simple lint rule behavior.

Testing

  • Ran unit tests: python -m pytest tests/test_drp_cli_linter.py -q, which passed (2 passed).
  • Ran CLI smoke validation: python drp_cli.py examples/minimal_valid.json succeeded and reported the example as valid.
  • Ran CLI linting modes: python drp_cli.py --lint examples/minimal_valid.json and python drp_cli.py lint examples/minimal_valid.json which ran and reported lint warnings (non-blocking) as expected.
  • The added GitHub Actions workflow (.github/workflows/drp_validate.yml) is present and configured to run drp-validate against examples/*.json on push and pull_request to main (workflow not executed as part of these local tests).

Codex Task

safal207 and others added 5 commits May 2, 2026 19:55
…pyproject.toml

Address review feedback on PR #6 by fixing latent bugs and broadening
the linter / CLI surface.

linter.py
  - Drop rules DRP003/DRP004/DRP005 that referenced non-existent fields
    ('priority', 'causal_trace', 'content.description') -- these never
    fired against actual DRP records. Replace with rules that check
    real schema fields (rationale length, options count, tags,
    metadata.author, future timestamps, supersession consistency).
  - Loosen DRP001 record_id regex to accept the conventions used by
    existing examples ('dec-a1', 'dec-0001') while still rejecting
    free-form IDs.
  - Add Rule registry with declared severity and description, expose
    via all_rules(); idempotent re-registration so re-imports do not
    duplicate warnings.
  - Add severity filter (info / style / best_practice) and per-rule
    enable/disable; track record_index for batch lints.

drp_cli.py
  - Use the documented EXIT_USAGE (2) for missing files, bad flags,
    and argparse errors via a custom ArgumentParser subclass.
  - TTY-aware ANSI colors with NO_COLOR / FORCE_COLOR / --no-color
    support.
  - Add 'rules' subcommand, --quiet, --min-severity, --rule,
    --disable-rule, --version. Print a per-run summary line.
  - Wrap JSON output in {validate, lint} envelope so combined runs are
    parseable as a single document.
  - Robust path handling: split into existing/missing inputs, warn on
    skipped paths, return EXIT_USAGE only when nothing usable remains.
  - Preserve 'drp-validate FILE' shorthand without breaking top-level
    flags such as --version.

Packaging
  - Replace setup.py with pyproject.toml (PEP 517/518). Align
    requires-python with the CI matrix (>=3.9 -- previously declared
    >=3.10 while CI tested 3.9). Add classifiers, URLs, optional dev
    extras. Ignore build/ and *.egg-info/ artifacts.

CI workflow
  - Pin actions/checkout@v4 and actions/setup-python@v5 to match the
    rest of the repo. Extend matrix to 3.9-3.12. Add smoke tests for
    --version, rules, JSON output, invalid fixtures, and bare-path
    shorthand. Also run on claude/** branches like ci.yml.

Tests
  - Expand from 4 tests to 55: per-rule coverage, severity/rule
    filters, batch lint with record_index, EXIT_USAGE paths,
    --no-color, --quiet, JSON envelope structure, console-script entry.

README
  - Fix leading-space typos in code blocks. Document new flags, exit
    code semantics, and the full lint rule table.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants