Skip to content

refactor(manifests): type repo-control manifests and schema catalogs #629

Closed

Description

@Sinity

Scope

Composite issue for replacing repo-control manifest and schema package hand-validation with typed Pydantic models.

Problem

Polylogue's repo-control manifests and schema package catalogs are central to verification, but their validation is currently mostly handwritten:

  • devtools/verify_manifests.py implements manual YAML shape walkers for lint escalation, suppressions, assurance domains, and coverage gaps;
  • schemas/packages.py uses dataclasses with custom to_dict() / from_dict() and local coercion helpers for lists, ints, string-int maps, provider values, and JSON documents;
  • manifest validation and schema package loading therefore have parallel local parsing behavior instead of one typed contract.

Manifest inventory (17 YAML manifests under docs/plans/)

File Current validation Priority
layering.yaml verify_layering.py High — core architectural rule
topology-target.yaml verify_topology.py High — placement rules
file-size-budgets.yaml verify_file_budgets.py Medium
test-ownership.yaml verify_test_ownership.py Medium
lint-escalation.yaml verify_manifests.py Medium
suppressions.yaml verify_suppressions.py Medium
assurance-domains.yaml verify_manifests.py High — proof routing
coverage-manifests/* verify_manifests.py High — #590 depends on these
migrations.yaml verify_migrations.py Low

Implementation order

  1. Create typed Pydantic models for the coverage-gap families first (assurance-domains.yaml, evidence-freshness.yaml, oracle-quality.yaml, scenario-coverage.yaml, test-quality-coverage.yaml) — fix(verification): make coverage declarations executable contracts #590 needs typed lifecycle fields.
  2. Type the schema package catalog (schemas/packages.py) — replace dataclass to_dict()/from_dict() with Pydantic model_dump(mode="json").
  3. Type the remaining manifest families, retiring one hand-validator per manifest family.

Design constraints

  • Use Pydantic BaseModel/TypeAdapter as the single loader for docs/plans manifests, proof coverage manifest subjects, rendered docs, and verify-manifests.
  • Extra fields forbidden by default unless a specific manifest model declares an extension map.
  • Coverage-gap lifecycle fields added by fix(verification): make coverage declarations executable contracts #590 are part of the typed coverage manifest model.
  • Schema package serialization uses model_dump(mode="json"); normal loading and verify-schema-roundtrip exercise the same models, not parallel hand-written conversion.
  • verify-manifests --json emits structured errors with manifest path, JSON pointer, field, expected type, actual value, and owning manifest family.
  • Avoid preserving current forgiving coercions by accident. Numeric/string-map/provider coercions should become typed validators with focused tests, not silent best-effort conversion.

Acceptance criteria

  • Manifest families under docs/plans/*.yaml have typed Pydantic models or TypeAdapter contracts.
  • verify-manifests reports validation errors from those typed contracts and no longer carries one-off mapping/list/string checks for each manifest family.
  • Coverage-gap lifecycle fields added by fix(verification): make coverage declarations executable contracts #590 are part of the typed coverage manifest model.
  • Schema package manifests/catalogs are Pydantic models with strict or intentionally documented extra behavior.
  • Schema package serialization uses model_dump(mode="json"); normal loading and verify-schema-roundtrip exercise the same models.
  • JSON schemas for repo-control manifest families can be emitted for editors/bots or generated into docs if useful.

Relationship to #601

#629 owns typed package/manifest loading; #601 owns corpus/runtime validation. Do not create a second schema-package parser in #601.

Ref #578
Ref #590
Ref #601

Activity

  1. Sinity commented on May 1, 2026

    @Sinity
    OwnerAuthor

    Additional scope from the compactness audit: this should explicitly distinguish two Pydantic conversions.

    1. Manifest validation: replace devtools/verify_manifests.py raw YAML walking with typed models/TypeAdapter validation for docs/plans manifests, including coverage-gap lifecycle fields once those are added.
    2. Schema package catalogs: replace schemas/packages.py dataclass to_dict() / from_dict() helpers and custom coercion (_string_list, _int_value, _string_int_dict, provider coercion, JSON-document coercion) with Pydantic models and model_dump(mode="json").

    The second part matters because verify-schema-roundtrip should test the same typed loading machinery used by normal schema package loading, not a parallel hand-written conversion layer.

    Ref #578

  2. added
    type:refactor
    on May 1, 2026
  3. changed the title [-]refactor(manifests): use typed Pydantic models for plan and schema catalogs[/-] [+]refactor(manifests): type repo-control manifests and schema catalogs[/+] on May 1, 2026
  4. added
    area:devtools
    theme:verifiability
    on May 1, 2026
  5. Sinity commented on May 1, 2026

    @Sinity
    OwnerAuthor

    Typed-model guard: when replacing manifest/catalog hand-validation with Pydantic, avoid preserving the current forgiving coercions by accident.

    Acceptance should define the extra and coercion policy per manifest family:

    • repo-control manifests should generally be strict enough that typoed keys fail verification;
    • schema package catalogs may need explicit compatibility fields, but those should be modeled, not accepted as arbitrary extras;
    • numeric/string-map/provider coercions should become typed validators with focused tests, not silent best-effort conversion;
    • emitted JSON schemas for manifests should be generated from the same models that verify-manifests and normal loading use.

    The goal is one authoritative typed contract. A Pydantic wrapper around the same ad hoc permissive parsing would not materially improve the current state.

  6. Sinity commented on May 1, 2026

    @Sinity
    OwnerAuthor

    Implementation anchors and acceptance additions from the 2026-05-01 follow-up audit.

    Replacement targets:

    • devtools/verify_manifests.py:15-24: load_manifest() returns raw YAML mappings.
    • devtools/verify_manifests.py:130-158: coverage gap shape validation only checks a small set of prose fields.
    • polylogue/schemas/packages.py:46-83, :86-140, :155-193: dataclass schema package/catalog models plus ad hoc coercion helpers.
    • devtools/verify_schema_roundtrip.py:36-68: current roundtrip is structural: package to_dict()/from_dict(), schema loadability, root type.

    Acceptance additions:

    • Use Pydantic BaseModel/TypeAdapter as the single loader for docs/plans manifests, proof coverage manifest subjects, rendered docs, and verify-manifests.
    • verify-manifests --json emits structured errors with manifest path, JSON pointer, field, expected type, actual value, and owning manifest family.
    • Extra fields are forbidden by default unless a specific manifest model declares an extension map.
    • Schema packages use model_dump(mode='json') and the same loader in normal runtime, docs generation, and verify-schema-roundtrip.

    Relationship to #601: #629 owns typed package/manifest loading; #601 owns corpus/runtime validation. Do not create a second schema-package parser in #601.

  7. Sinity commented on May 1, 2026

    @Sinity
    OwnerAuthor

    Manifest typing decision from 2026-05-01 bundle

    Typed manifests/schema package catalogs are accepted, but should not create another parallel parsing stack.

    Acceptance refinements:

    • Coverage-gap lifecycle fields from fix(verification): make coverage declarations executable contracts #590 should be part of typed manifest models.
    • Schema package typed loading should be shared with verify-schema-roundtrip and runtime schema package loading.
    • Prefer one model/loader per manifest family over raw YAML walkers plus separate dataclass/Pydantic/manual conversion paths.
    • Validation errors should identify manifest path, object identity, field path, and expected realized consumer where applicable.

    Ref #590
    Ref #601

  8. Sinity commented on May 2, 2026

    @Sinity
    OwnerAuthor

    Manifest inventory

    17 YAML manifests under docs/plans/:

    File Current validation Priority for typing
    layering.yaml verify_layering.py High — core architectural rule
    topology-target.yaml verify_topology.py High — placement rules
    file-size-budgets.yaml verify_file_budgets.py Medium
    test-ownership.yaml verify_test_ownership.py Medium
    lint-escalation.yaml verify_manifests.py Medium
    suppressions.yaml verify_suppressions.py Medium
    assurance-domains.yaml verify_manifests.py High — proof routing
    coverage-manifests/* verify_manifests.py High — #590 depends on these
    migrations.yaml verify_migrations.py Low

    Implementation order

    The highest-leverage starting point is the manifest families that verify_manifests.py already validates with hand-rolled YAML walkers — those are the ones where typed models immediately eliminate fragile manual checks.

    Suggested order:

    1. Create polylogue/proof/coverage_manifests.py (or schemas/manifests/) with Pydantic models for the coverage-gap families first — assurance-domains.yaml, evidence-freshness.yaml, oracle-quality.yaml, scenario-coverage.yaml, test-quality-coverage.yaml — because fix(verification): make coverage declarations executable contracts #590 needs typed lifecycle fields
    2. Type the schema package catalog (schemas/packages.py) — replace dataclass to_dict()/from_dict() with Pydantic model_dump(mode="json")
    3. Type the remaining manifest families, retiring one hand-validator per manifest family

    Already-typed manifests

    Check docs/plans/topology-target.yaml — devtools/verify_topology.py may already use Pydantic for this one (it was added during the topology projection work). If so, use it as the reference pattern.

  9. Sinity commented on May 3, 2026

    @Sinity
    OwnerAuthor

    Closed by #755. All 17 YAML manifests have Pydantic v2 models with extra='forbid'. validate_manifest() dispatch validates by manifest type. devtools verify-manifests runs typed validation.

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

    area:devtoolsarea:schematheme:verifiabilitytype:refactor

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions