Skip to content

feat(builder): evolution policy for data contracts and customer copies #294

Done

Description

@vaceslav

Part of epic #261, phase 4 step 4. Design: docs/superpowers/specs/2026-11-26-builder-evolution-policy-design.md on feature/builder.

Problem

The data a host gives its templates changes. A renamed or removed field silently prints nothing in a stored template that still reads it: a customer's edited copy (DOCX/ODT) or a stored JSON definition. Templates built from code are rebuilt and need nothing.

Scope (reduced, decided 2026-11-26)

The library checks, the host decides (storage, when to re-check, how to show the result, fixing).

  • One check for any stored template against the current data catalogue (not the current template's contract): TemplateInspector.Check for DOCX/ODT copies, TemplateInspector.CheckDefinition for JSON definitions.
  • Result: status Ok / Warning (works, but outdated or of unknown origin) / Broken (will not fill correctly), and problems with code, data path and location.
  • Component versions ([ComponentVersion(n)]) recorded in the stamp; an older component makes a copy a warning. JSON definitions get the current component on every build.
  • DataCatalog.ToJson() for agents and for hosts that keep a snapshot.
  • Policy in the docs: adding fields is safe; renaming or removing one is a breaking change, re-check stored templates.

Out of scope

Contract diff, declared renames, rewriting templates, a definition hash in the stamp, reading a catalogue from JSON. Fixing broken templates (for example by an agent that reads the host's changelog of data changes) is the host's work.

Activity

  1. added
    enhancement
    builder
    on Nov 26, 2026
  2. vaceslav commented on Nov 26, 2026

    @vaceslav
    ContributorAuthor

    Done on feature/builder (no release), reduced scope as described above.

    • TemplateInspector.Check(stream, TemplateCheckOptions) checks a DOCX/ODT copy against the current data catalogue: syntax (TB9300), unknown paths (TB9301), a trial fill with data of the catalogue's shape (TB9302), stamp: none (TB9303), other template (TB9304), older definition version (TB9305), older or unknown component (TB9306). Status Ok / Warning / Broken.
    • TemplateInspector.CheckDefinition(json, import, build?, expected?) checks a JSON definition: import with the catalogue (TB9203 with data path and JSON pointer) and, with build options, the build.
    • [ComponentVersion(n)] (opt-in) is recorded in the stamp (Templify.Components). A versioned component must be registered to be exported to JSON (TB9204), so builds from JSON always use its current version.
    • DataCatalog.ToJson(); CheckUpload/UploadCheckResult/TemplateOrigin replaced.
    • Developer docs: "Stamp and checking stored templates", codes table, "Changing the data" policy, known limits.

    Final review fixes (each with a test): whole paths of loop items through the trial fill, loops over open shapes (dictionaries) validated, indexed paths ([n]) accepted, duplicate catalogue paths, ToJson for types nested in generic types.

    Known limits (documented): a removed field deeper than the loop item read only in a condition, and a loop over a value in a branch the check's data does not take, are not detected (#299 for the engine side).

    Deferred minors: CLR members of dictionaries (count, keys) resolve on closed witness objects; a loop over an object passes when the body reads nothing from the item; a stream positioned at its end reads as "not a template"; a DOCX with a damaged styles part is Ok; TB9204 messages repeat per occurrence; stamp component names are bare type names; TemplateStamp.ToString shows the dictionary type; CheckDefinition takes positional parameters; TB9300 covers all non-variable validation errors.

  3. vaceslav commented on Dec 2, 2026

    @vaceslav
    ContributorAuthor

    Done on feature/builder, merged to main in #316 and released in builder 0.1.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    builderenhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions