Skip to content

refactor: Simplify core provenance, preparation, and application layer - #373

Merged
ericchansen merged 1 commit into
masterfrom
ericchansen-simplify-core-and-application-layer
Oct 19, 2026
Merged

ericchansen merged 1 commit into
masterfrom
ericchansen-simplify-core-and-application-layer

Conversation

@ericchansen

Copy link
Copy Markdown
Owner

Summary

Simplify the core provenance, canonicalization, settings, preparation, and application modules (177 insertions, 346 deletions, -169 net lines) while preserving all public, architectural, and lazy-import contracts.

Changes

  • Replace the dual _CREDENTIAL_KEY regex + startswith/endswith check in q2mm/_provenance.py with a normalized alphanumeric substring check against _CREDENTIAL_KEY_TERMS, and export thaw_json_value for reuse in q2mm/settings.py (including BackendSettings.factory_options()).
  • Factor the recursive normalization closure in q2mm/_canonical.py (json_value) to eliminate repeated keyword-argument forwarding and _screen_key boilerplate.
  • Reuse ActiveParameterSpace.pack/expand/with_baseline, QFuerzaSettings.model_dump(), and PreparationProvenance.__post_init__ freezing in q2mm/preparation.py.
  • Share _validate_execution_controls and _validate_result_vectors across q2mm/application/models.py and q2mm/application/optimization.py, collapse _result_gradient_mode and _settings_gradient_mode into one function, replace manual dataclass-to-dict reconstructions in OptimizationRun.from_result and _manifest_payload with vars(...), and inline _install_staged in q2mm/application/persistence.py.

Testing

  • python -m pytest test/ -x -q -m "not (openmm or tinker or jax or jax_md or psi4)" (7582 passed, 185 skipped)
  • python -m ruff check q2mm/ test/ scripts/ (All checks passed!)
  • python -m ruff format --check q2mm test scripts examples (288 files already formatted)
  • python -m mypy q2mm/ (Success: no issues found in 109 source files)

Base automatically changed from ericchansen-refactor-review to master October 19, 2026 22:42
@ericchansen
ericchansen force-pushed the ericchansen-simplify-core-and-application-layer branch from 314c823 to d18d160 Compare October 19, 2026 22:44
Copilot AI balanced review requested due to automatic review settings October 19, 2026 22:44

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Credential screening now accepts previously blocked auth keys, allowing opaque credentials into saved manifests.

1 open issue
What changed in this PR

Simplifies shared provenance, preparation, and application code by reusing normalization, validation, and serialization helpers.

Changes:

  • Consolidates JSON handling and credential screening.
  • Reuses parameter-space operations and settings serialization.
  • Shares execution validation and simplifies persistence staging.
File Description
q2mm/​settings.py Reuses JSON thawing for options and serialization.
q2mm/​preparation.py Reuses parameter-space helpers and settings exports.
q2mm/​application/​persistence.py Simplifies manifest construction and staged writes.
q2mm/​application/​optimization.py Consolidates gradient resolution and validation.
q2mm/​application/​models.py Shares validators and simplifies provenance capture.
q2mm/​application/​configuration.py Passes configured finite-difference step directly.
q2mm/​_provenance.py Adds shared thawing and changes credential-key screening.
q2mm/​_canonical.py Consolidates recursive JSON normalization.

Review effort: Balanced

Comment thread q2mm/_provenance.py Resolved
Consolidate credential-key screening and JSON thawing in q2mm._provenance,
factor recursive normalization in q2mm._canonical, reuse ActiveParameterSpace
and QFuerzaSettings helpers in q2mm.preparation, and eliminate redundant
gradient-mode and payload wrappers across q2mm.application.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@ericchansen
ericchansen force-pushed the ericchansen-simplify-core-and-application-layer branch from d18d160 to 9d89bc5 Compare October 19, 2026 22:55
Copilot AI balanced review requested due to automatic review settings October 19, 2026 22:55

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The refactors have no identified blocking issues, and regression coverage addresses the previously reported credential-screening gap.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

@ericchansen
ericchansen merged commit dc3c46d into master Oct 19, 2026
20 checks passed
@ericchansen
ericchansen deleted the ericchansen-simplify-core-and-application-layer branch October 19, 2026 22:58
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.

2 participants