Commit 79d7c56
feat: add
* feat: add `altimate-code check` CLI command for deterministic SQL checks
Add a new `check` subcommand that runs deterministic SQL analysis
(lint, validate, safety, policy, PII, semantic, grade) without
requiring an LLM. The command:
- Accepts SQL files as positional args or globs (defaults to `**/*.sql`)
- Calls `Dispatcher.call()` for each check category (no direct napi imports)
- Processes files in batches of 10 for concurrency
- Supports `--format json|text`, `--severity`, `--fail-on` flags
- Outputs diagnostics to stderr, structured JSON to stdout
- Does NOT call `bootstrap()` — no session/db/server needed
- Registered in `index.ts` with proper `altimate_change` markers
* docs: add comprehensive documentation and tests for `altimate-code check` command
- Add `docs/docs/usage/check.md` with full documentation covering all 7 check
types, CLI options, JSON output schema, policy file format, schema file format,
severity levels, CI/CD integration (GitHub Actions, pre-commit, GitLab CI),
and real-world usage examples
- Update `docs/docs/usage/cli.md` to reference the `check` command in the
subcommands table
- Add `check` page to `docs/mkdocs.yml` navigation under Interfaces
- Extract helper functions (`normalizeSeverity`, `filterBySeverity`,
`toCategoryResult`, `formatText`, `buildCheckOutput`) into
`check-helpers.ts` for testability
- Refactor `check.ts` to import from `check-helpers.ts` (no behavior change)
- Add 53 unit tests covering: severity normalization, severity filtering,
category result building, text formatting, output assembly, constants
validation, and edge cases
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* test: add comprehensive E2E + adversarial tests for `check` command
- 58 new tests covering full handler flow with mocked `Dispatcher.call()`
- E2E: all 7 check types, `--fail-on` exit codes, `--severity` filtering,
`--policy` validation, unknown check names, schema resolution, batching,
text/JSON output, mixed success/failure across checks
- Adversarial: null bytes, shell metacharacters, 100K-char lines, Unicode/emoji,
CRLF, spaces in filenames, deeply nested paths, malformed policy JSON, 1MB
policy files, undefined/null finding fields, 5000 findings, XSS-like content,
non-string severity, `__proto__` pollution, binary `.sql` content, symlinks,
directory with `.sql` extension, duplicate file args, empty checks string
- Fix: `normalizeSeverity()` now handles non-string inputs without crashing
(previously threw on numeric/boolean/object severity from Dispatcher)
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix: address 4 major review findings in `check` command
1. `--fail-on` now evaluates UNFILTERED findings before `--severity`
filtering. Previously, `--severity error --fail-on warning` would
false-pass because warnings were filtered out before exit logic.
2. Removed unused CLI options (`--dialect`, `--dbt-project`, `--manifest`)
that were documented but had no effect — misleading for CI users.
3. `runPii` now checks `result.success` before processing data,
consistent with all other check runners.
4. Dispatcher failures now emit error-severity findings instead of
silently returning `[]`. A broken native bridge no longer reports
PASS with zero findings.
Also:
- Use `buildCheckOutput()` helper instead of duplicated inline logic
- Remove dead `|| ("error" as const)` fallbacks after `normalizeSeverity`
- Add 4 new tests: severity/fail-on interaction, runPii failure,
Dispatcher failure exit code
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix: address CodeRabbit review comments
1. Replace `process.exit()` with `process.exitCode` + `return` so the
outer `finally` block in `index.ts` can run `Telemetry.shutdown()`.
2. Preserve A-F grade value from `altimate_core.grade` response in
`CheckCategoryResult` metadata (`grade`, `score` fields).
3. Skip DB migration for `check` command — it only needs `Dispatcher`
and has zero database dependencies. Prevents startup failure on
read-only CI environments and removes multi-minute overhead.
4. Remove unused `--dialect`, `--dbt-project`, `--manifest` from docs
options table (code already removed in prior commit).
5. Add `text` language specifier to fenced code block in `check.md`.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix: remove unnecessary `undefined as any` casts for optional `schema_context`
`schema_context` is already optional (`?`) in the Dispatcher types.
The `undefined as any` casts were unnecessary type safety bypasses.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>altimate-code check CLI command for deterministic SQL checks (#453)1 parent cfe1bad commit 79d7c56
File tree
8 files changed
+2790
-2
lines changed- docs
- docs/usage
- packages/opencode
- src
- cli/cmd
- test/cli
8 files changed
+2790
-2
lines changedLarge diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
| 25 | + | |
25 | 26 | | |
26 | 27 | | |
27 | 28 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
101 | 101 | | |
102 | 102 | | |
103 | 103 | | |
| 104 | + | |
104 | 105 | | |
105 | 106 | | |
106 | 107 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
0 commit comments