Skip to content

feat(uec): UEC-first architecture with strict adapter contract enforcement - #15

Merged
m2papierz merged 15 commits into
mainfrom
feat/uec-first-engine
Jan 14, 2026
Merged

feat(uec): UEC-first architecture with strict adapter contract enforcement#15
m2papierz merged 15 commits into
mainfrom
feat/uec-first-engine

Conversation

@m2papierz

Copy link
Copy Markdown
Contributor

Summary

This PR implements the "UEC-first" architecture where ExecutionEnvelope becomes the single source of truth for program and result data. Key changes:

  • Schema extension: Added parametric_hash and executed_parametric_hash to ProgramSnapshot for distinguishing structural vs parametric changes (VQE support)
  • Strict contract enforcement: Adapter runs without envelope now raise MissingEnvelopeError (strict mode). Engine no longer silently synthesizes envelopes for adapter runs.
  • Bit order canonicalization: Single canonicalize_bitstrings() function in engine handles all bitstring normalization to cbit0_right format before comparison.
  • Manual runs: Continue to work with auto-generated envelopes but with documented limitations (no program hashes, compare reports "HASH_UNAVAILABLE").
  • Program comparison: New ProgramMatchStatus enum with FULL_MATCH, STRUCTURAL_MATCH_PARAM_MISMATCH, STRUCTURAL_MISMATCH, HASH_UNAVAILABLE for precise diff reporting.

Type of change

  • Bug fix
  • New feature
  • Refactor (no user-facing change)
  • Docs only
  • CI/build tooling
  • Breaking change

Changelog (user-facing only)

  • I added a towncrier fragment in changelog.d/ (skip for internal-only changes)

Checklist

  • I ran lint locally (uv run pre-commit run --all-files)
  • I ran tests locally (uv run pytest)
  • I added/updated tests for behavior changes
  • I updated docs/README/examples if needed
  • If I changed dependencies, I updated uv.lock (uv lock) and committed it
  • I considered backward compatibility and security impact

Notes for reviewers

Notes for reviewers

  • Breaking change for adapters: All adapters need to be updated to provide program_hash and parametric_hash. During migration, use strict=False in resolve_envelope().
  • Backward compatibility: diff_runs() uses strict=False internally so existing runs still work. Warnings are logged for adapter runs missing envelopes.
  • Manual runs: Work as before, but compare now clearly reports HASH_UNAVAILABLE instead of silently skipping hash comparison.

Follow-up work:

  • Update all adapters to provide program hashes
  • Add tests for canonicalize_bitstrings() with multi-register format
  • Consider adding strict=True enforcement in CI after adapter migration

@m2papierz
m2papierz merged commit b274c05 into main Jan 14, 2026
7 checks passed
@m2papierz
m2papierz deleted the feat/uec-first-engine branch January 14, 2026 09:28
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