Skip to content

test(schema): check the Google schema against the loader - #555

Merged
merr1988 merged 2 commits into
mainfrom
feat/schema/model-agreement
Oct 23, 2026
Merged

merr1988 merged 2 commits into
mainfrom
feat/schema/model-agreement

Conversation

@merr1988

@merr1988 merr1988 commented Oct 23, 2026 •

Copy link
Copy Markdown
Collaborator

Part 2 of b/568049508, after #551.

What

Agreement tests: each case is one document and whether it is valid. It is checked against the published schema and against what push accepts. A case where the two disagree fails.

  • Model documents. Schema root vs. fromDocument({bindingOptional: true}), then resolveModelDeployments, undeclaredProfileError, validateInlineDialects, validateDeployments and validatePushRequirements({targetOptional: true}) on the model with no deployments, as the Knowledge Catalog push runs them.
  • Profile files. #/$defs/ProfileDocument vs. the layout's profile-name rules (nameProblem, reservedProfileNameError), then loadProfileFile, validateProfileCompleteness, and validatePushRequirements on the model with the profile applied.

The cases cover the bug's test list:

  • valid minimal and full models;
  • invalid shapes;
  • constraints, and deployments that use the model file's own bindings;
  • names and length limits;
  • key and join columns;
  • executors;
  • metrics_exclude and fields_exclude;
  • one valid and one malformed case per source form (6) and target form (3).

Both tables share one runner (describeAgreement) and one source-case builder (sourceCases).

Schema change

Found by the cases: an executor coordinate (for example server: " ") and a SQL statement may not be blank, as push already requires. Both use one new NonBlankText definition.

Known disagreements

Two rules about what a metric's SQL reads, which no JSON Schema can state: a metric reading a field with no expression, and a ratio metric on a BigQuery deployment. Each case names the reason and expects the disagreement.

b/577102892

The loader accepts an empty name or description on actions, action parameters and constraints. The schema rejects them, as the bug specifies. The six cases name b/577102892 and expect the disagreement, so they fail once the loader is fixed and the entries are removed.

Testing

  • tsc clean. Semantic suite: 2054 pass.
  • Every invalid case was checked to fail on both sides for the reason its label names.
  • Mutation check: removing maxProperties, the backtick in ColumnName, or the blank-statement rule each fails exactly the matching cases.

@merr1988
merr1988 requested a review from feixufeixu October 23, 2026 17:32
@merr1988
merr1988 force-pushed the feat/schema/model-agreement branch from feb5aed to 4e0c47c Compare October 23, 2026 17:50
@merr1988
merr1988 changed the base branch from feat/schema/google-flavor to main October 23, 2026 17:56
@merr1988
merr1988 force-pushed the feat/schema/model-agreement branch from 4e0c47c to 0ea1a0c Compare October 23, 2026 17:56

@feixufeixu feixufeixu left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Approving. I left five required changes, each with its exact fix, and a few optional ones.

Comment thread toolbox/mdcode/tests/libts/semantic/osi_schema.test.ts Outdated
Comment thread toolbox/mdcode/tests/libts/semantic/osi_schema.test.ts
Comment thread toolbox/mdcode/tests/libts/semantic/osi_schema.test.ts
Comment thread toolbox/mdcode/tests/libts/semantic/osi_schema.test.ts Outdated
Comment thread toolbox/mdcode/tests/libts/semantic/osi_schema.test.ts
Comment thread toolbox/mdcode/tests/libts/semantic/osi_schema.test.ts Outdated
Comment thread toolbox/mdcode/tests/libts/semantic/osi_schema.test.ts Outdated
Comment thread toolbox/mdcode/tests/libts/semantic/osi_schema.test.ts
Comment thread toolbox/mdcode/tests/libts/semantic/osi_schema.test.ts Outdated
Comment thread toolbox/mdcode/tests/libts/semantic/osi_schema.test.ts Outdated
Adds the agreement tests b/568049508 asks for. Each case is one document
and its verdict, checked against the published schema and against what
push accepts. A case where the two disagree fails.

- Model documents (114 cases): the schema root against the loader with
  bindingOptional, then resolveModelDeployments, validateDeployments and
  validatePushRequirements with targetOptional on the model with no
  deployments, as a Knowledge Catalog push runs them.
- Profile files (49 cases): #/$defs/ProfileDocument against the layout's
  profile-name rules (nameProblem, reservedProfileNameError),
  loadProfileFile and validateProfileCompleteness.

The cases cover the bug's test list: valid minimal and full models,
invalid shapes, constraints, deployments that use the model
file's own bindings, names, key and join columns, executors, metrics_exclude,
fields_exclude, and one valid and one malformed case per source and
target form. Both tables share one runner and one source-case builder.

Schema fixes found by the cases: an executor coordinate and a sql
statement may not be blank, as push requires.

Known disagreement: the loader accepts an empty name or description on
actions, action parameters and constraints; the schema does not. Those six
cases name b/577102892 and expect the disagreement, so they fail once
the loader is fixed.

Bug: b/568049508
- The model runner also runs undeclaredProfileError and
  validateInlineDialects, and the profile runner validates the model with
  the profile applied, as push does.
- Known differences that no JSON Schema can state: a metric reading a
  field with no expression, and a ratio metric on a BigQuery deployment.
- New cases: a deployment profile with a space, a blank mcp tool, rest
  endpoint and grpc method, and a profile action with a blank server.
- A profile entity with no primary_key is checked against the schema
  alone, since push decides it from the model file.
- One columnCases helper serves both tables; fields_exclude '*' no longer
  leaves a field unbound.

Bug: b/568049508
@merr1988
merr1988 force-pushed the feat/schema/model-agreement branch from 6cbf37a to f879ae3 Compare October 23, 2026 23:14
@merr1988
merr1988 merged commit 9effb13 into main Oct 23, 2026
7 checks passed
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.

2 participants