Context
Surfaced during self-review of #221 (PR #234). match_vcf_header_pattern bakes the matched field into code, one canonical field per header type:
So a rule can only ever match the one hard-coded field per type. Matching a different ##contig subfield (e.g. species, md5) would require a code change.
The asymmetry
The SAM side is already data-driven — the field is a parameter and rules declare it:
match_sam_header_pattern(header, section, field, pattern) # SAM: field is a PARAMETER (rules carry header_field: PL/SN/AS/...)
match_vcf_header_pattern(header, header_type, pattern) # VCF: field baked in per type
Proposal
Make the VCF matched field declarative, mirroring SAM. Either a vcf_header_field key in the rule when (preferred, matches the SAM header_field convention) or a type.field selector form (e.g. ##contig.assembly). The engine's _match_vcf_header would pass the field through, and match_vcf_header_pattern would look it up instead of hard-coding it.
Interaction with #154 (READ BEFORE STARTING)
#154 (rules with fact-based antecedents: extractors + derivers + rules) is the umbrella this sits under. If #154 introduces extractors that emit named facts and rules that match facts, the entire regex-against-a-named-header-field mechanism — both today's and this proposal's — is subsumed: rules would match a reference_assembly fact, not a regex against ##contig.assembly.
Therefore:
Related deriver work: #236 (accession->assembly) is itself a #154-style deriver.
Definition of done
Related
Context
Surfaced during self-review of #221 (PR #234).
match_vcf_header_patternbakes the matched field into code, one canonical field per header type:##reference/##source-> the value##INFO/##FORMAT/##FILTER-> theIDfield##contig-> theassemblyfield (added in VCF ##contig assembly= rules can never match (scanner splits fields, patterns expect key=value) #221)So a rule can only ever match the one hard-coded field per type. Matching a different
##contigsubfield (e.g.species,md5) would require a code change.The asymmetry
The SAM side is already data-driven — the field is a parameter and rules declare it:
Proposal
Make the VCF matched field declarative, mirroring SAM. Either a
vcf_header_fieldkey in the rulewhen(preferred, matches the SAMheader_fieldconvention) or atype.fieldselector form (e.g.##contig.assembly). The engine's_match_vcf_headerwould pass the field through, andmatch_vcf_header_patternwould look it up instead of hard-coding it.Interaction with #154 (READ BEFORE STARTING)
#154 (rules with fact-based antecedents: extractors + derivers + rules) is the umbrella this sits under. If #154 introduces extractors that emit named facts and rules that match facts, the entire regex-against-a-named-header-field mechanism — both today's and this proposal's — is subsumed: rules would match a
reference_assemblyfact, not a regex against##contig.assembly.Therefore:
Related deriver work: #236 (accession->assembly) is itself a #154-style deriver.
Definition of done
vcf_header_fieldkey vstype.fieldselector); prefer parity with SAM'sheader_field.match_vcf_header_patternlooks up the declared field; engine_match_vcf_headerpasses it through.make test-all,make lint,make format-check,make typepass.Related