[FEAT]: Add template schema registry with compatibility validation#289
Open
Aryama-srivastav wants to merge 3 commits intofireform-core:mainfrom
Open
[FEAT]: Add template schema registry with compatibility validation#289Aryama-srivastav wants to merge 3 commits intofireform-core:mainfrom
Aryama-srivastav wants to merge 3 commits intofireform-core:mainfrom
Conversation
- Implement TemplateSchema and TemplateRegistry for managing PDF templates - Support template metadata: required fields, aliases, type constraints, versioning - Add CompatibilityChecker for pre-fill validation with detailed reporting - Support template families for multi-template organization - Comprehensive type validation (email, phone, date, number, checkbox, dropdown) - Missing/extra fields detection and dependency tracking - Integration with Filler.check_compatibility_before_fill() - 23 comprehensive tests for all acceptance criteria
There was a problem hiding this comment.
Pull request overview
Adds a template schema registry + compatibility validation layer to support predictable, reproducible PDF pre-fill behavior across multiple template “families”, and wires optional compatibility checks into the existing PDF filler.
Changes:
- Introduces
TemplateSchema/FieldSchema/TemplateRegistryandCompatibilityReportfor template metadata and validation reporting. - Adds
CompatibilityCheckerto validate extracted data (mapping, required fields, type checks, dependencies) and to discover compatible templates. - Extends
Fillerwith optional registry support and acheck_compatibility_before_fill()helper; adds a comprehensive pytest suite.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| src/template_schema.py | New schema/registry/report datamodels for template metadata and compatibility reporting. |
| src/compatibility_checker.py | New validation engine for template compatibility checks and template discovery. |
| src/filler.py | Adds optional template-registry integration and a pre-fill compatibility check API. |
| src/test/test_template_schema.py | Adds end-to-end unit tests for registry behaviors and compatibility validation. |
| src/inputs/input.txt | Updates sample input content used for local/manual runs. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
Comment on lines
+63
to
+73
| report.matched_fields.add(canonical_name) | ||
|
|
||
| # Type validation | ||
| type_issue = self._validate_field_type( | ||
| canonical_name, | ||
| extracted_value, | ||
| field_schema, | ||
| ) | ||
| if type_issue: | ||
| report.type_mismatches[canonical_name] = type_issue | ||
| report.compatible = False |
Comment on lines
+46
to
+47
| # Track which fields we've seen | ||
| extracted_field_names = set(extracted_data.keys()) |
| if canonical_name is None: | ||
| # Field not found in template | ||
| report.extra_fields.add(extracted_name) | ||
| report.unmapped_fields.add(extracted_name) |
Comment on lines
+103
to
+113
| """ | ||
| # Exact match | ||
| if extracted_name in self.fields: | ||
| return extracted_name | ||
|
|
||
| # Check aliases | ||
| for canonical_name, schema in self.fields.items(): | ||
| if extracted_name in schema.aliases: | ||
| return canonical_name | ||
|
|
||
| return None |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Multiple PDF templates need predictable behavior and reproducibility across different form families:
What Changed
Added comprehensive template schema registry system with pre-fill compatibility checking:
template_schema.py
compatibility_checker.py
filler.py — Enhanced with template support
test_template_schema.py
Test Validation
✅ 23/23 tests pass — All acceptance criteria met