content-block-manager: 10. Make Content Block Manager the source of truth for schemas
Date: 2026-02-12
Status: Accepted
Context
Current State
Currently, schemas for the Content Block Manager are stored in the Publishing API. This allows the Publishing API to validate content shape upon receipt. The Content Block Manager also consumes these schemas to dynamically build form interfaces.
The Problem
This architecture creates several friction points:
- Coupled Deployments: Modifying a block type requires coordinated changes in both the Publishing API and the Content Block Manager.
- Split Configuration: Schema definitions live in the API, while block configuration lives in the Content Block Manager (YAML), creating two sources of truth.
- Outdated Validation Logic: The Publishing API uses the json-schema gem, which lags behind the latest specifications. Specifically, we are introducing a "Time Period" block that requires date validation, which the API's gem does not support.
Conversely, the Content Block Manager uses the json_schemer gem, which is actively maintained and supports the modern validation features we need.
Decision
We will shift schema ownership from the Publishing API to the Content Block Manager.
Strategy
We will adopt an incremental migration strategy rather than a "big bang" approach, starting immediately with the new "Time Period" block.
Implementation Details
-
Content Block Manager (Primary Validator):
- Will store schemas locally as JSON files.
- Is solely responsible for validating the complex
detailshash of a block (with optional custom validation).
-
Publishing API (Metadata Validator):
- Will use a generic
content_blockschema. - Is responsible for validating standard metadata, including:
titlebase_pathinstructions_to_publishers-
edition_links(e.g.,primary_publishing_organisation)
- Will accept any structure within the
detailshash, trusting that Content Block Manager has already validated it.
- Will use a generic
Consequences
-
Hybrid Schema Fetching: During the transition, the
Schemaobject must support fetching schemas from both the Publishing API (legacy) and local files (new). -
Presenter Logic: The
ContentBlockPresentermust be updated to inject the genericcontent_blockschema name when sending locally-defined blocks to the API. - Cleanup: Once all block types are migrated, the temporary fetching logic can be removed.
Future Plans
-
Config Consolidation: Move configuration currently housed in
config/content_block_manager.ymldirectly into the JSON schemas to create a single source of truth. - Advanced Validation: Leverage the newer gem capabilities to implement complex checks, such as date range validation.