Skip to content

Make the JSON ingestion spec extension fully opt-in#1249

Open
jwils wants to merge 2 commits into
mainfrom
joshuaw/lazy-json-ingestion-spec-default
Open

Make the JSON ingestion spec extension fully opt-in#1249
jwils wants to merge 2 commits into
mainfrom
joshuaw/lazy-json-ingestion-spec-default

Conversation

@jwils

@jwils jwils commented Jun 11, 2026

Copy link
Copy Markdown
Collaborator

Why

On #1205, @myronmarston suggested that the DEFAULT_SCHEMA_DEFINITION_EXTENSION_MODULES availability probe in spec_support/schema_definition_helpers.rb (a begin/rescue LoadError evaluated at file load) could go away in a follow-up once the extraction settled. The review here then asked the natural follow-on question: is there anything left that really needs the defaulting, or is this a good time to force tests to opt in?

Answer: nothing needs the defaulting anymore. This PR removes it entirely.

What

  • spec_support/schema_definition_helpers.rb no longer applies any extension modules by default — define_schema in specs builds a plain core schema unless the caller passes extension_modules:.
  • The places that genuinely need JSON schemas now opt in explicitly, at the level where the need exists:
    • generate_schema_artifacts includes the extension only when loading the repository's main test schema (config/schema.rb), which uses the JSON ingestion schema definition DSL. Schemas defined via a block get no extensions unless requested.
    • build_indexer includes the extension when it generates schema artifacts itself, since the indexer can only ingest JSON events today. The require is lazy so spec bundles without elasticgraph-json_ingestion (apollo, warehouse, health_check, query_interceptor) can still build an indexer from an externally built datastore_core:.
    • The camelCase acceptance run and individual specs that index documents with inline schemas pass schema_definition_extension_modules: / extension_modules: at their build call sites.
  • Vestigial t.json_schema calls in unit specs that never index are removed, along with a JsonSafeLong placeholder assertion in elasticgraph-graphql that duplicated coverage now living in elasticgraph-json_ingestion.
  • Per @myronmarston's suggestion on Migrate JSON ingestion specs into gem #1224, a gem-local "JSONIngestionSchemaDefinitionHelpers" shared context (modeled on elasticgraph-warehouse's warehouse_schema_support) now applies APIExtension to every schema defined in elasticgraph-json_ingestion's own specs, so those call sites don't each pass extension_modules: explicitly.

Verification

  • script/run_gem_specs for elasticgraph-schema_definition, elasticgraph-json_ingestion, elasticgraph-indexer, elasticgraph-graphql, elasticgraph-datastore_core, elasticgraph-admin, elasticgraph-health_check, and elasticgraph-query_interceptor
  • script/type_check
  • script/quick_build

Stack

Current PR is marked with ->.

Comment thread spec_support/spec_helper.rb Outdated
@jwils jwils force-pushed the joshuaw/indexer-ingestion-adapters branch from e8e1a67 to 1631628 Compare June 11, 2026 16:04
@jwils jwils force-pushed the joshuaw/lazy-json-ingestion-spec-default branch from 81cb325 to 5e11583 Compare June 11, 2026 16:04
@jwils jwils changed the title Load the JSON ingestion spec extension default lazily Make the JSON ingestion spec extension fully opt-in Jun 11, 2026
@jwils jwils force-pushed the joshuaw/lazy-json-ingestion-spec-default branch from 8dc35fb to 39af63e Compare June 11, 2026 17:14
@jwils jwils force-pushed the joshuaw/indexer-ingestion-adapters branch 2 times, most recently from 4a79422 to b1abdb0 Compare June 12, 2026 02:34
@jwils jwils force-pushed the joshuaw/lazy-json-ingestion-spec-default branch from 39af63e to 6a733f1 Compare June 12, 2026 02:45
@jwils jwils force-pushed the joshuaw/indexer-ingestion-adapters branch from b1abdb0 to 908b4c9 Compare June 15, 2026 20:58
@jwils jwils force-pushed the joshuaw/indexer-ingestion-adapters branch from 908b4c9 to 247ac28 Compare June 16, 2026 21:37
@jwils jwils force-pushed the joshuaw/lazy-json-ingestion-spec-default branch from e37cb08 to ec47261 Compare June 16, 2026 21:39
@jwils jwils changed the base branch from joshuaw/indexer-ingestion-adapters to main June 16, 2026 21:39
@jwils jwils force-pushed the joshuaw/lazy-json-ingestion-spec-default branch from efab4d7 to f136921 Compare June 30, 2026 23:19
@myronmarston myronmarston force-pushed the joshuaw/lazy-json-ingestion-spec-default branch from 01bcbd3 to 2a45ad6 Compare July 1, 2026 04:22
Keep JSON ingestion schema support opt-in instead of baking it into the
indexer helpers. Specs that actually ingest JSON data now use
:ingests_json_data, which composes datastore, indexer, and
:json_ingestion_schema_definition support. Schema-only specs use
:json_ingestion_schema_definition directly. This keeps elasticgraph-indexer
tests from assuming JSON as the only ingestion format and leaves room for
future non-JSON ingestion paths.

The json_ingestion gem applies the shared JSON schema-definition support by
convention from its spec helper, so its specs no longer need a separate
helper that duplicates APIExtension wiring.

Two subtleties matter for keeping the full suite green:

- `define_derived_metadata` does not reliably expand a derived tag declared
  on a `shared_context` into the groups produced when the context is combined
  with `include_examples` (RSpec raises inside `update_inherited_metadata`;
  see rspec/rspec#333). So the shared contexts that
  ingest JSON data list the component tags (`:json_ingestion_schema_definition`,
  `:uses_datastore`, `:builds_indexer`) literally rather than via
  `:ingests_json_data`, with a comment referencing the upstream issue so the
  workaround can be collapsed once it is fixed. Dropping the (redundant)
  `:capture_logs` tag alone does not avoid the crash, and reverting either
  shared context to `:ingests_json_data` reintroduces it in the full suite.
- The elasticgraph-apollo and elasticgraph-health_check bundles do not include
  elasticgraph-json_ingestion, and their specs use prebuilt on-disk artifacts,
  so they stay on `:uses_datastore`/`:builds_indexer` rather than opting into
  the JSON schema-definition extension they cannot load.

Generated with Claude Code
@myronmarston myronmarston force-pushed the joshuaw/lazy-json-ingestion-spec-default branch 4 times, most recently from ce6ba87 to b214bfe Compare July 1, 2026 04:57
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