Skip to content

Formalize v0.6 extension contract - #12

Merged
miraflor merged 1 commit into
mainfrom
v0.6-phase5-extension-contract
Aug 28, 2026
Merged

Formalize v0.6 extension contract#12
miraflor merged 1 commit into
mainfrom
v0.6-phase5-extension-contract

Conversation

@miraflor

Copy link
Copy Markdown
Owner

Summary

Formalize the narrow downstream extension contract for the CGE-Core v0.6
public Hosoe workflow.

Contract

The protected lifecycle is:

CGE -> solve_benchmark() -> Equilibrium -> scenario() -> Scenario.set() -> Scenario.solve() -> Result

The contract also protects:

  • public value() reads;
  • repeated set() / solve() cycles on the same Scenario;
  • immutability of previously returned Result snapshots;
  • benchmark isolation;
  • Result.compare() as the stable comparison path;
  • public imports from cge_core and cge_core.models.

Public/private boundary

The contract deliberately does not include:

  • private _engine or _snapshot state;
  • raw Pyomo traversal;
  • a universal Closure abstraction;
  • plugin/backend registration;
  • persistence or serialization guarantees;
  • Scenario.unfix() as a required downstream capability;
  • IFPRI or CAMCGE adaptation to the Hosoe facade;
  • dynamic transition logic.

PyCGE remains available as the advanced/lower-level API, but its mutable
engine state is outside the downstream stability promise.

Changes

  • add docs/developer/extension-contract.md;
  • update the developer overview;
  • add the extension contract to the docs TOC;
  • add downstream contract regression tests.

Scope

This PR adds no new economic behavior and no new runtime abstraction. It
formalizes and tests capabilities already implemented in the v0.6 public API.

Validation

The Phase 5 contract tests and existing v0.6 documentation guards pass locally.

Merge policy

Do not merge until all CI checks are green.

Document the minimal downstream stability contract for the CGE-Core v0.6
public Hosoe workflow.

Protect the benchmark -> scenario -> set -> solve -> read lifecycle, including
repeated Scenario modification/solve cycles, immutable earlier Result
snapshots, benchmark isolation, and Result.compare().

Clarify the public/private boundary for downstream packages and explicitly
exclude private engine state, raw Pyomo traversal, universal closure/plugin
abstractions, persistence, dynamic logic, and IFPRI/CAMCGE adaptation from the
minimal contract.

Add regression tests that exercise the contract using only public namespaces.
@miraflor
miraflor marked this pull request as ready for review August 28, 2026 16:33
@miraflor
miraflor merged commit 7dcde31 into main Aug 28, 2026
11 checks passed
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