Skip to content

fix(sl-toolkit): align payload keys with metastore contract (sql_dialect, constraint rule) - #92

Draft
jbotor wants to merge 1 commit into
mainfrom
fix/sl-toolkit-metastore-payload-keys
Draft

fix(sl-toolkit): align payload keys with metastore contract (sql_dialect, constraint rule)#92
jbotor wants to merge 1 commit into
mainfrom
fix/sl-toolkit-metastore-payload-keys

Conversation

@jbotor

@jbotor jbotor commented Jul 27, 2026

Copy link
Copy Markdown

Summary

The sl-toolkit documented payloads diverged from the Metastore's canonical JSON schemas, so a real /sl-build push fails with 422 before anything is created. This fixes the two payload-key mismatches and re-points the regression tests (which were pinned to the wrong keys) at the actual contract.

Source of truth = the schemas the Metastore validates against, in keboola/go-monorepo services/metastore/migrations/schema/:

  • semantic-model_schema_1.0.0.jsonrequired: ["name", "sql_dialect"] (snake_case)
  • semantic-constraint_schema_1.0.0.jsonrequired: [..., "rule", ...], additionalProperties: false; ruleExpression is optional {operator, left, right, bounds}

1. semantic-model: sqlDialectsql_dialect

The skill sent camelCase; the Metastore's additionalProperties is lax so the unknown key is silently dropped, leaving the required sql_dialect missing → 422 on the first POST, killing the run.

- "data": { "name": ..., "description": ..., "sqlDialect": "Snowflake" }
+ "data": { "name": ..., "description": ..., "sql_dialect": "Snowflake" }

Also corrects PR #72, which "fixed" a dialect problem in the wrong direction and locked camelCase in via regression tests. Those tests are inverted here to assert snake_case (with a comment pointing at the metastore schema so the direction can't silently flip again).

2. semantic-constraint: rule is required (string)

The skill documented only ruleExpression: {bounds: {...}}; the Metastore requires a string rule422 missing property 'rule'. Fix documents rule as the required field and keeps ruleExpression as the optional structured companion (downstream pipelines read ruleExpression.bounds; the API enforces rule). Also notes the constraint schema is additionalProperties: false (unlike the model), so payloads must be clean.

  "metrics": ["Net Profit Margin"],
+ "rule": "-2.0 <= Net Profit Margin <= 0.05",
- "ruleExpression": { "bounds": { "min": -2.0, "max": 0.05 } },
+ "ruleExpression": { "operator": "between", "left": "Net Profit Margin", "bounds": { "min": -2.0, "max": 0.05 } },
  "severity": "error"

Files

  • skills/semantic-layer/SKILL.md, commands/sl-build.md — payload docs + POST body
  • tests/fixtures/{semantic-model,semantic-constraint}.json, tests/schemas/{semantic-model,semantic-constraint}.json — fixtures + local validation schemas
  • tests/test_smoke.py, tests/test_skill_consistency.py, tests/README.md — inverted the sql_dialect invariant, added a constraint-rule invariant
  • version bump 3.0.03.0.1 (plugin.json, marketplace.json)

All 32 plugin tests pass locally.

Out of scope (follow-up)

A third finding — db_name() hardcodes the KEBOOLA_<projectId> database pattern (wrong on some stacks; should read the real DB off an existing table/dataset FQN) — is intentionally not in this PR. Happy to do it next.

Release Notes

Justification, description

Fixes sl-toolkit semantic-layer push failures caused by payload keys that don't match the Metastore contract (sql_dialect, constraint rule).

Plans for Customer Communication

N/A

Impact Analysis

Docs/fixtures/tests only for the sl-toolkit plugin; no runtime service code. Unblocks /sl-build and conversational constraint creation.

Deployment Plan

N/A

Rollback Plan

Revert the PR.

Post-Release Support Plan

N/A

Link to Devin session: https://app.devin.ai/sessions/267d4c07e859442c871eb6e817482749
Requested by: @jbotor

…ect, constraint rule)

Co-Authored-By: jan.botorek <botorekj@gmail.com>
@jbotor jbotor self-assigned this Jul 27, 2026
@devin-ai-integration

Copy link
Copy Markdown
Contributor

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

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