Skip to content

feat: weight field, fieldMappings config, and madrigal init wizard#14

Draft
delkc wants to merge 3 commits into
mainfrom
feat/weight-field-fieldmappings
Draft

feat: weight field, fieldMappings config, and madrigal init wizard#14
delkc wants to merge 3 commits into
mainfrom
feat/weight-field-fieldmappings

Conversation

@delkc

@delkc delkc commented Apr 27, 2026

Copy link
Copy Markdown
Collaborator

Why

Madrigal's original enforcement field assumed all teams use the same must/should/may vocabulary, which blocked adoption by teams with different frontmatter conventions (design systems using maturity levels, compliance kits using status fields, etc.). This makes the field system flexible enough for any team without requiring file renames.

What

  • Add src/weight.ts with config-driven level logic: parseWeight, compareWeight, isHighWeight, defaultWeight, buildWeightOrder
  • Rename enforcementweight throughout schema, loader, search, formats, compliance, MCP server — enforcement/severity kept as deprecated aliases
  • Add levels and fieldMappings to MadrigalConfig so teams can define custom ordered levels and map their existing frontmatter field names (with optional value translation)
  • Add applyFieldMappings to loader pipeline
  • Add madrigal init CLI command that scans source files, detects non-standard field vocabularies, and generates a starter config
  • Add src/init.ts with analyzeKnowledgeSources, generateConfig, printAnalysisSummary
  • Update README: weight field docs, levels/fieldMappings config reference, madrigal init section
  • Add docs/field-mapping.md: comprehensive guide with team-specific examples

Risk Assessment

Medium — touches most files in the repo (field rename), but backward compatibility is preserved through deprecated aliases on enforcement/severity. All 77 tests pass, typecheck clean.

References

  • enforcement/severity still parsed and mapped to weight at load time — no breaking change for existing knowledge files
  • Known weight vocabularies pre-loaded in init wizard: design-system-maturity, compliance-type, status-lifecycle, priority-levels, adoption

Generated with Claude Code

delkc and others added 3 commits April 27, 2026 11:13
Replaces the opinionated `enforcement` field with a flexible `weight`
system so any team can use their existing frontmatter vocabulary without
renaming files. Adds a `madrigal init` CLI command that scans source files
and generates a starter config with suggested fieldMappings and levels.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…emanticSearchOptions

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.

1 participant