Commit 8fd0c7b
fix: dbt tool regression — schema format mismatch, silent failures, wrong results (#263)
* fix: dbt tool regression — schema format mismatch, silent failures, wrong results (#261)
Root cause: `schema-resolver.ts` passed flat schema_context
(`{"table": {"col": "TYPE"}}`) directly to `Schema.fromJson()`,
which expects the Rust `SchemaDefinition` format
(`{"tables": {"table": {"columns": [{"name": "col", "type": "TYPE"}]}}}`).
The parse silently failed, falling back to an empty schema, causing
all schema-dependent tools to produce empty/wrong results.
Fixes:
- `schema-resolver.ts`: Auto-detect and normalize 3 schema_context
variants (flat map, array-of-columns, SchemaDefinition) before
calling `Schema.fromJson()`
- `sql-analyze.ts`: Check `result.error` instead of `!result.success`
to distinguish "issues found" from "analysis failed"
- `altimate-core-grade.ts`: Map Rust field names (`overall_grade`,
`scores.overall`) instead of `grade`/`score`
- `altimate-core-complete.ts`: Use `data.items` (Rust field) with
fallback to `data.suggestions`
- `altimate-core-schema-diff.ts`: Use `has_breaking_changes` (Rust)
and format tagged enum changes correctly
- `altimate-core-rewrite.ts`: Use `data.suggestions` (Rust) with
fallback to `data.rewrites`
- `altimate-core-fix.ts`: Map `fixes_applied`/`unfixable_errors`
(Rust fields) instead of `changes`/`errors`
- `altimate-core-column-lineage.ts`: Show `column_dict` and use
`lens_type` (Rust) for transform info
- `sql/register.ts`: Populate `can_auto_apply`, `original_fragment`,
`rewritten_fragment` in `sql.rewrite` handler
Closes #261
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix: additional tool field name mismatches found via full simulation
Full simulation of 77 tests across all altimate-core tools revealed
6 more field name mismatches between Rust napi output and TS formatters:
- `altimate_core.transpile`: QUALIFY post-processing checked `data.sql`
but Rust returns `transpiled_sql` (array)
- `altimate_core.resolve_term`: Rust returns array, `toData()` converts
to `{'0': ...}` object — now wraps as `{ matches: [...] }`
- `altimate_core_classify_pii`: checked `data.findings` but Rust returns
`columns` with `classification`/`suggested_masking` fields
- `altimate_core_query_pii`: checked `data.exposures` but Rust returns
`pii_columns` with `risk_level`/`suggested_alternatives`
- `altimate_core_testgen`: test cases have `inputs`/`expected` fields,
not `sql` — formatter now shows input values and expectations
- `altimate_core_prune_schema`: checked `data.pruned` but Rust returns
`pruned_schema_yaml`/`relevant_tables`/`tables_pruned`
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* test: add 168 simulation tests for altimate-core tool coverage
Two new test files exercising all 36 altimate-core napi functions
through the dispatcher layer:
- `issue-261-e2e.test.ts`: 14 tests reproducing all 11 broken tools
from #261 plus schema format variant tests
- `edge-cases-simulation.test.ts`: 76 tests covering empty inputs,
complex SQL patterns (nested subqueries, CTEs, window functions,
correlated subqueries), column lineage through transformations,
schema diff with large schemas, PII detection, multi-dialect
transpilation, DDL roundtrip, equivalence checks, policy enforcement,
and migration safety analysis
Total: 192 tests, 404 assertions, 0 failures.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* test: add 96-test stress simulation + fix empty table schema crash
Stress simulation covering: SQL pattern variants (recursive CTEs,
LATERAL joins, GROUPING SETS), lint anti-pattern detection, column
lineage through 10 transformation types, schema diff mutation matrix
(100-column tables, special chars), 10-dialect transpile matrix,
grading consistency, fuzzy fix matching, testgen feature coverage,
cursor-position completions, PII detection, and term resolution.
Also fixes schema-resolver to skip tables with empty column lists
(Rust engine requires >= 1 column per table).
Total simulation suite: 288 tests, 867 assertions, 0 failures.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* test: consolidate simulations into e2e tests with `-e2e.test.ts` naming
Moved all simulation tests into proper e2e test files following the
project convention (`*-e2e.test.ts` in `test/altimate/`):
- `altimate-core-e2e.test.ts` — 100 tests: all dispatcher methods,
schema format variants, error recovery, complex SQL patterns
- `altimate-core-stress-e2e.test.ts` — 80 tests: dialect matrix,
fuzzy fix matching, grading consistency, testgen coverage,
cursor completions, PII detection, lineage tracing, schema diffs
- `issue-261-e2e.test.ts` — 14 tests: regression tests for #261
Removed standalone simulation files (full-simulation, edge-cases,
stress-simulation) — content consolidated into the e2e files above.
Total e2e suite: 180 tests, 539 assertions, 0 failures.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix: address PR review comments — schema detection false positive and PII field fallbacks
1. `isSchemaDefinitionFormat`: now validates that values under `tables`
contain a `columns` array, preventing false positives when a flat
schema has a table literally named "tables"
2. `formatQueryPii` / `formatClassifyPii`: added fallbacks for missing
`table`/`column` properties to prevent "undefined.column_name" output
3. Added test for the "tables" false-positive scenario
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix: address Sentry comment + fix CI test isolation failures
1. `formatFix`: changed condition from `data.fixed && data.fixed_sql`
to `data.fixed_sql && data.fixed !== false` so a valid `fixed_sql`
is not silently discarded when `fixed` field is absent
2. `sql/register.ts`: wrapped all 10 composite SQL handlers in
exportable `registerAllSql()` function (mirrors `registerAll()`
pattern from `altimate-core.ts`)
3. All 3 e2e test files now call both `core.registerAll()` and
`sql.registerAllSql()` in `beforeAll` to survive `Dispatcher.reset()`
from other test files — fixes CI "No native handler" failures
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>1 parent ad52d87 commit 8fd0c7b
21 files changed
Lines changed: 2404 additions & 55 deletions
File tree
- packages/opencode
- src/altimate
- native
- sql
- tools
- test/altimate
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
131 | 131 | | |
132 | 132 | | |
133 | 133 | | |
134 | | - | |
135 | | - | |
136 | | - | |
137 | | - | |
138 | | - | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
139 | 143 | | |
140 | 144 | | |
141 | 145 | | |
| |||
326 | 330 | | |
327 | 331 | | |
328 | 332 | | |
329 | | - | |
| 333 | + | |
330 | 334 | | |
331 | 335 | | |
332 | 336 | | |
333 | 337 | | |
334 | | - | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
335 | 341 | | |
336 | 342 | | |
337 | 343 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
6 | 17 | | |
7 | 18 | | |
8 | 19 | | |
9 | 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 | + | |
10 | 94 | | |
11 | 95 | | |
12 | 96 | | |
| |||
19 | 103 | | |
20 | 104 | | |
21 | 105 | | |
22 | | - | |
| 106 | + | |
23 | 107 | | |
24 | 108 | | |
25 | 109 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
23 | 27 | | |
24 | 28 | | |
25 | 29 | | |
| |||
362 | 366 | | |
363 | 367 | | |
364 | 368 | | |
365 | | - | |
366 | | - | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
367 | 373 | | |
368 | 374 | | |
369 | 375 | | |
| |||
430 | 436 | | |
431 | 437 | | |
432 | 438 | | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
Lines changed: 16 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
19 | | - | |
| 19 | + | |
| 20 | + | |
20 | 21 | | |
21 | 22 | | |
22 | 23 | | |
| |||
31 | 32 | | |
32 | 33 | | |
33 | 34 | | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
38 | 49 | | |
39 | 50 | | |
40 | 51 | | |
Lines changed: 21 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
42 | 57 | | |
43 | | - | |
| 58 | + | |
| 59 | + | |
44 | 60 | | |
Lines changed: 4 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | | - | |
| 23 | + | |
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
38 | | - | |
| 38 | + | |
| 39 | + | |
39 | 40 | | |
40 | | - | |
| 41 | + | |
41 | 42 | | |
42 | 43 | | |
43 | 44 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
38 | | - | |
| 38 | + | |
39 | 39 | | |
40 | 40 | | |
41 | | - | |
| 41 | + | |
| 42 | + | |
42 | 43 | | |
43 | | - | |
44 | | - | |
| 44 | + | |
| 45 | + | |
45 | 46 | | |
46 | 47 | | |
47 | 48 | | |
48 | 49 | | |
49 | | - | |
| 50 | + | |
| 51 | + | |
50 | 52 | | |
51 | | - | |
52 | | - | |
| 53 | + | |
| 54 | + | |
53 | 55 | | |
54 | 56 | | |
55 | 57 | | |
| |||
Lines changed: 18 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| 21 | + | |
| 22 | + | |
21 | 23 | | |
22 | | - | |
23 | | - | |
| 24 | + | |
| 25 | + | |
24 | 26 | | |
25 | 27 | | |
26 | 28 | | |
| |||
33 | 35 | | |
34 | 36 | | |
35 | 37 | | |
36 | | - | |
37 | | - | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
38 | 52 | | |
39 | 53 | | |
40 | 54 | | |
| |||
Lines changed: 15 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
35 | | - | |
36 | | - | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
37 | 50 | | |
Lines changed: 19 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
21 | | - | |
| 21 | + | |
| 22 | + | |
22 | 23 | | |
23 | 24 | | |
24 | 25 | | |
| |||
33 | 34 | | |
34 | 35 | | |
35 | 36 | | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
40 | 54 | | |
41 | 55 | | |
42 | 56 | | |
0 commit comments