Skip to content

feat(codequality,qa): reorganize verification into make qa-<speed>[-<filter>] architecture - #1297

Merged
kyasbal merged 2 commits into
mainfrom
push-xmlkwwoxools
Nov 20, 2026
Merged

kyasbal merged 2 commits into
mainfrom
push-xmlkwwoxools

Conversation

@kyasbal

@kyasbal kyasbal commented Nov 20, 2026

Copy link
Copy Markdown
Member

Summary

Reorganizes KHI's code quality and verification entrypoints into a workflow-agnostic, read-only make qa-<speed>[-<filter>] architecture backed by scripts/codequality so developers, hooks, CI, and multi-agent workflows can compose fast/slow and blocking/advisory verification cleanly.

Key Changes

  • Unified Make QA Targets (scripts/make/qa.mk):
    • Adds all 9 qa-<speed>[-<filter>] targets (fast / slow / all × omitted / must / advisory), all read-only, with unified exit code contract (MUSTFIX >= 1 -> exit 1, otherwise exit 0, CLI/runtime errors -> exit 2).
    • Consolidates and removes 6 legacy duplicate Make targets from scripts/make/testing.mk (codequality, codequality-fast, codequality-decisions, codequality-go, codequality-web, codequality-web-container).
    • Supports BASE, TARGET, PATHS, CHANGED_SINCE, FORMAT (text|github|json), QA_LANG, USE_CONTAINER, COLOR, VCS, and CODEQUALITY_* overrides, including automatic -include $(HOME)/.config/khi/codequality.mk.
  • Reorganized scripts/codequality CLI & Internal Orchestrator (internal/qarunner):
    • Splits CLI modes into 4 explicit subcommands: qa, check, conventions, and unused-exports.
    • Adds --speed, --filter, --paths, --changed-since, --skip-sources, --use-container, and --format=json (mustfix, advisory, skipped_sources).
    • Keeps external billed/API advisories (--decisions / CODEQUALITY_DECISIONS=true, --similarity / CODEQUALITY_SIMILARITY=true) strictly opt-in by default so OSS contributors never trigger external APIs unintentionally, while allowing per-user environment control via ~/.config/khi/codequality.mk or env vars without changing Make commands or skills.
    • Sets default --max-mutants=0 and --decisions-max-targets=0 (unlimited) across qa and check (retaining explicit --decisions-max-targets=20 in .github/workflows/codequality-comment.yaml).
    • Adds fast fault isolation (ClassifyGoCompileError) to isolate external-file Go compile errors into skipped_sources, (all, must) fail-fast on fast build/test failure, single-file CheckFileConventions, SkipCloneScan in fast mode, and bounded-worker parallel evaluation in decisioncheck.
    • Consolidates scripts/gotestutil into scripts/codequality/internal/gotestutil with CurrentOnly default scoping for qa, FilterDiffByPaths, and IntersectDiffChangedSince.
  • CI-Parity & Hook Alignment:
    • qa-fast-must runs scoped addlicense, gofmt, golangci_lint, go_test_short, prettier, prettier_misc, eslint, stylelint, test_scripts, buf_lint, markdownlint, and Stage-1 Go AST + single-file conventions.
    • qa-slow-must runs unused_exports (Go), deadcode (path-filtered), go_test_race, 4-target cross-platform build_go (windows/amd64, linux/amd64, darwin/arm64, darwin/amd64), lint_unused, read-only build_web, build_web_dev, build_storybook, test_web (with --use-container support), and dynamic Go/TS coverage/mutation/redundancy checks.
    • Removes unnecessary whole-project parserOptions.project loading from web/eslint.config.mjs to enable fast single-file ESLint execution.
    • Updates scripts/pre-commit.sh, scripts/pre-push.sh, scripts/run-codequality-ci.sh, scripts/make/lint.mk, .github/workflows/pullrequest.yaml, and .github/workflows/codequality-comment.yaml directly to the new commands (retaining build-proto in pre-commit.sh and pre-push.sh when proto files change).

Verification

  • make pre-commit: PASS (0 mustfix, 0 advisory, 0 skipped)
  • make qa-slow-must QA_LANG=go CODEQUALITY_TIMEOUT=10m (and Go + Web build phases of make pre-push): PASS (670/670 Go mutants killed, 0 survived, 100% patch coverage, 0 test_redundancy, unused_exports, deadcode, go_test_race, 4-OS build_go, lint_unused, build_web, build_web_dev, build_storybook all PASS)
  • go run ./scripts/codequality qa --speed=slow --filter=must --lang=ts --use-container --skip-sources=lint_unused,build_web,build_web_dev,build_storybook: PASS (containerized Karma test_web PASS)
  • make qa-all-advisory FORMAT=json and make qa-all-advisory FORMAT=json CODEQUALITY_SIMILARITY=false CODEQUALITY_DECISIONS=false: Verified opt-in control via ~/.config/khi/codequality.mk / overrides and zero external API calls when opted out.
  • go test -race -count=1 ./scripts/vrt/...: PASS

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors the monorepo's code quality and QA pipeline by transitioning the 'codequality' tool to a subcommand-based CLI supporting 'qa', 'check', 'conventions', and 'unused-exports'. It introduces unified speed ('fast', 'slow', 'all') and severity ('must', 'advisory', 'all') filters, coordinated by a new 'qarunner' package that integrates external checks, internal AST rules, coverage, mutation testing, and remote advisory APIs. Additionally, 'gotestutil' has been internalized, Makefiles and git hooks have been updated to target the new 'qa-fast-must' and 'qa-all-must' workflows, and 'web/eslint.config.mjs' has been optimized to isolate pure AST rules from whole-project TSConfig loading. Extensive contract and unit tests have been added to validate the new scoping, parallel evaluation, and reporting capabilities. I have reviewed the changes and have no feedback to provide.

@github-actions

github-actions Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

Go Quality Report (origin/main) — ✅ PASS

Metric Result
Changed Scope 40 prod file(s), 37 test file(s), 280 unit(s)
Patch Coverage 96.2% (1352/1405 lines)
Mutation Score 100.0% (667/667 killed, 0 survived)
Function Similarity Advisory (1/102 new unit(s) matched across 3007 corpus units)

Similar Existing Go Functions (Advisory)

New Unit Top Existing Candidate AST-Norm Score Action
isTargetGoSource (scripts/codequality/internal/qarunner/external.go:258) isConventionTargetGoFile (scripts/codequality/internal/astcheck/conventions.go:165) 0.967 Similar logic exists in another module; extract a shared helper or verify intentional symmetry.

Commit: b3df87a8dc2f · Cloud Build Logs

@kyasbal
kyasbal enabled auto-merge November 20, 2026 11:17
@kyasbal
kyasbal added this pull request to the merge queue Nov 20, 2026
Merged via the queue into main with commit 517a76b Nov 20, 2026
23 checks passed
@kyasbal
kyasbal deleted the push-xmlkwwoxools branch November 20, 2026 11:32
@kyasbal

kyasbal commented Nov 24, 2026

Copy link
Copy Markdown
Member Author

CI Repair & Retained Advisory Notes (b3df87a8dc2f)

  • CI Repair (github-codequality):
    • Root cause: On 095f4411b3f7, TestPipelineStageGatingAndASTCloneScan used an 0o000 subdirectory to trigger a DiscoverProdGoFiles failure, which remained readable under root (uid=0) inside the Cloud Build container and allowed 2 mutants in runASTStage (scripts/codequality/main.go:417) to survive.
    • Fix (b3df87a8dc2f): Replaced the permission-based fixture with a root-safe ENOTDIR path (<file>/sub) and tightened qa_test.go assertions on runCLI(qa) and executeCheckStages. All 23 CI checks (including github-codequality: 667/667 mutants killed, 100.0%) now pass.
  • Retained Similarity Advisory (isTargetGoSource vs isConventionTargetGoFile, score 0.967):
    • Intentionally kept separate: isTargetGoSource (scripts/codequality/internal/qarunner/external.go) filters qarunner Go lint/test scope by excluding web/, pkg/generated/, and zzz_*.go, whereas isConventionTargetGoFile (scripts/codequality/internal/astcheck/conventions.go) has a distinct exclusion rule and lives in a separate internal package (astcheck) that qarunner intentionally does not import.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant