Add DRP CLI, extensible linter, packaging entry point, and validation workflow#6
Open
safal207 wants to merge 6 commits into
Open
Add DRP CLI, extensible linter, packaging entry point, and validation workflow#6safal207 wants to merge 6 commits into
safal207 wants to merge 6 commits into
Conversation
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
console_scriptsentry point so CI and developers can calldrp-validateconsistently.examples/*.jsonfor push and PRs tomain.Description
drp_cli.py, a small CLI wrapper that supports validation of one or more paths/globs, a--strictplaceholder flag, an optional--lintrun-after-validation flag, and alintsubcommand; 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).linter.py, an extensible linter with aWarningdataclass, a@register_ruledecorator for rule registration, and the requested baseline rules:record_idformat, timestamp recommendation for decisions, priority recommendation for root decisions,causal_tracelinkage recommendation, and non-emptycontent.descriptionchecks; provideslint_recordandlint_datahelpers.setup.pypackaging metadata with aconsole_scriptsentry point sopip install .exposesdrp-validate..github/workflows/drp_validate.ymlwhich installs the package on Python 3.10 and runsdrp-validate examples/*.json(blocking) anddrp-validate --lint examples/*.json(non-blocking).tests/test_drp_cli_linter.pycovering path expansion and a simple lint rule behavior.Testing
python -m pytest tests/test_drp_cli_linter.py -q, which passed (2 passed).python drp_cli.py examples/minimal_valid.jsonsucceeded and reported the example as valid.python drp_cli.py --lint examples/minimal_valid.jsonandpython drp_cli.py lint examples/minimal_valid.jsonwhich ran and reported lint warnings (non-blocking) as expected..github/workflows/drp_validate.yml) is present and configured to rundrp-validateagainstexamples/*.jsonon push and pull_request tomain(workflow not executed as part of these local tests).Codex Task