Skip to content

Add deterministic Autopilot demo quality scorecard - #7

Merged
rergards merged 2 commits into
mainfrom
feat/autopilot-demo-quality-scorecard
Jun 5, 2026
Merged

Add deterministic Autopilot demo quality scorecard#7
rergards merged 2 commits into
mainfrom
feat/autopilot-demo-quality-scorecard

Conversation

@rergards

@rergards rergards commented Jun 5, 2026

Copy link
Copy Markdown
Owner

Summary

Adds a deterministic, public-safe quality scorecard for the Autopilot demo backlog. The scorecard emits Markdown and JSON, tracks repo-local quality signals, and adds CI/verify gates for shape, determinism, public-safety, and drift against committed artifacts.

Review follow-up applied before opening this PR:

  • removed a generated Markdown EOF whitespace issue caught by git diff --check;
  • made secret-prefix detector patterns self-nonmatching so repo-level public-safety scans stay clean while rendered output still catches real tokens.

Verification

  • ruff check mempalace_code/ tests/ scripts/
  • ruff format --check mempalace_code/ tests/ scripts/
  • python -m pyright --pythonpath "$(python -c 'import sys; print(sys.executable)')"\n- python scripts/quality_scorecard.py --check\n- python -m pytest tests/test_quality_scorecard.py -q\n- python -m pytest tests/ -q -m "not needs_network" -> 2342 passed, 2 deselected\n- git diff --check main..HEAD\n- repo public-safety scan for private paths/token-like literals: clean\n\n## Public-Safety\n\nNo .tasks/, .protocols/, docs/audits/, private benchmark outputs, private paths, or secret-like values are staged or committed.

rergards and others added 2 commits June 5, 2026 21:43
…ity scorecard

Add scripts/quality_scorecard.py — a stdlib-only, deterministic, public-safe
scorecard that emits Markdown + JSON metrics for code size, largest modules,
Ruff ignores, Pyright mode, unreasoned suppressions, test count, available
CLI/MCP/smoke suites, and the canonical verification commands. Establishes the
measurable baseline for the AUTOPILOT DEMO backlog section so future cleanup
tasks report before/after deltas instead of inventing their own reporting.

- One-command usage: `python scripts/quality_scorecard.py [--format both|json]`.
- `--write` regenerates committed baseline under docs/quality/.
- `--check` validates shape, self-determinism, and public-safety (no private
  paths/secrets); wired into the CI lint job and /verify, failing on malformed
  or unsafe output. No network, no project import — runs without install.
- Suppression policy mirrors tests/test_type_suppressions.py; fixtures excluded.
- Focused tests cover metric logic (hermetic synthetic repo), output shape,
  determinism, public-safety, validation, and entry points.

Committed public-safe scorecard: docs/quality/scorecard.md, docs/quality/scorecard.json
Update workflow for demo tasks: docs/quality/README.md

Verification:
  ruff check mempalace_code/ tests/ scripts/            -> clean
  ruff format --check mempalace_code/ tests/ scripts/   -> clean
  python -m pyright                                      -> 0 errors
  python scripts/quality_scorecard.py --check           -> OK
  python -m pytest tests/test_quality_scorecard.py -q    -> 27 passed
  python -m pytest tests/ -q                             -> 2313 passed

Constraint: scorecard stays stdlib-only so it runs in the CI lint job and /verify without installing the package.
Scope-risk: --check validates shape/determinism, not exact counts, so normal code growth must not break CI.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…ial review

Multi-agent review (6 lenses, each finding adversarially verified, then
synthesized) surfaced real bugs and gaps in the baseline scorecard. Fixes,
all stdlib-only / deterministic / public-safe / bounded:

Correctness & determinism
- Suppression scan is now tokenize-aware: only real comment tokens count, so a
  `# type: ignore`/`# noqa` mentioned inside a string/docstring is no longer
  miscounted (type_pyright_total 109 -> 108; headline unreasoned stays 0).
- Test-def regex fallback tolerates PEP 695 generics (`def test_x[T](...)`) so
  the 3.11 SyntaxError fallback agrees with the 3.12+ AST count — the value is
  identical across machines.
- File traversal skips build/dist/.egg-info/.venv/__pycache__/vendor noise so a
  stray local artifact cannot perturb the byte-identical output.

Public-safety
- The default stdout path now runs the same public-safety scan as --write and
  --check (both md and js, regardless of --format) and refuses to emit a leak.
- --write no longer crashes on an absolute --out-dir outside the repo.
- Forbidden-pattern set anchors /home/ on the bare prefix and adds the home/temp
  /Windows roots that user-controlled config fields could carry verbatim.

Drift guards & tests
- verification_commands typecheck entry aligned to the canonical /verify form; a
  new test asserts every command appears verbatim in verify/INSTRUCTIONS.md.
- New test asserts committed docs/quality/* stay fresh vs a live render.
- New test asserts the suppression regexes match tests/test_type_suppressions.py.
- Added failure-path coverage for run_check, parametrized validate() negatives,
  non-UTF-8 fail-loud, --format both, json-arm refusal, and the tokenize fallback.

Verification:
  ruff check mempalace_code/ tests/ scripts/            -> clean
  ruff format --check mempalace_code/ tests/ scripts/   -> clean
  python -m pyright                                      -> 0 errors
  python scripts/quality_scorecard.py --check           -> OK
  python -m pytest tests/ -q                             -> 2340 passed

Deferred (out of scope for this bounded pass, see synthesis): tokenize-guarding
the live test_type_suppressions.py gate; AWS/Slack/email/IPv4 forbidden patterns
(no verbatim carrier in rendered output); a separate --check-committed CI mode
(superseded by the freshness test).

Constraint: scorecard stays stdlib-only; suppression scan must mirror the gate's policy.
Scope-risk: explanatory comments/strings in the scorecard tests must avoid bare suppression syntax or they trip the raw-line gate and inflate the scan.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@rergards
rergards merged commit 9a7fa77 into main Jun 5, 2026
6 checks passed
@rergards
rergards deleted the feat/autopilot-demo-quality-scorecard branch June 5, 2026 22:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant