Skip to content

PLUME-60: Writable model parameters negotiation - #30

Open
cducher wants to merge 1 commit into
feature/two-way-couplingfrom
feature/two-way-coupling-negotiation
Open

PLUME-60: Writable model parameters negotiation#30
cducher wants to merge 1 commit into
feature/two-way-couplingfrom
feature/two-way-coupling-negotiation

Conversation

@cducher

@cducher cducher commented Jul 2, 2026

Copy link
Copy Markdown
Collaborator

Description

I decided to break down the PRs for the two-way coupling feature as to allow more efficient and targeted review.
This PR implements the negotiation changes required in Plume.

Other PRs will come: ifs-source plume module | Plume run phase (state pattern) | WF plugin

The following criteria were applied:

  • the model declares what parameters are writable (plume or model owned)
  • the plugins request in read-only or writable mode either from the negotiate method or configuration
  • the plume negotiator evaluates plugin needs and read/write intents: strict gating
  • the write-back (coupling) feature handles cases where:
    • multiple plugins are loaded and consume the same parameters (readers and writers)
    • multiple plugins are loaded and write to the same parameter
    • a plugin writes to a parameter that is an actively observed observable
  • Plume remains model agnostic
  • models and plugins interface through the ModelData, no API breakage
  • Plume monitors the coupling state [to come in the next PR] and ensures only plugins pre-authorised during negotiation do write back.

Contributor Declaration

By opening this pull request, I affirm the following:

  • All authors agree to the Contributor License Agreement.
  • The code follows the project's coding standards.
  • I have performed self-review and added comments where needed.
  • I have added or updated tests to verify that my changes are effective and functional.
  • I have run all existing tests and confirmed they pass.

@cducher
cducher requested a review from Copilot July 2, 2026 16:02
@cducher cducher self-assigned this Jul 2, 2026

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.

Pull request overview

Implements “writable parameter” negotiation needed for two-way coupling, allowing models to declare which parameters may be written back by plugins, and enforcing cross-plugin write/read conflict rules via a configurable write-back policy—while keeping the core model/plugin interface centered on ModelData.

Changes:

  • Add a writable attribute to parameter definitions and surface it through Protocol offer/require paths (including new writable-offer C/Fortran API variants).
  • Introduce WriteBackPolicy and extend Negotiator to gate writable requests and track cross-plugin conflicts across negotiation order, with a post-negotiation summary.
  • Expand unit/API tests to cover writable offers/requests, policy gating, and multi-plugin conflict scenarios.

Reviewed changes

Copilot reviewed 20 out of 20 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
tests/core/test_protocol.cc Adds Protocol-level tests for writable offer/require semantics
tests/core/test_plugin_params.cc Adds Manager/Negotiator integration tests for write-back policy + conflicts
tests/core/test_negotiator.cc Updates Negotiator tests for plugin-name-based negotiation + writable gating
tests/core/test_catalogue.cc Adds tests for ParameterDefinition(writable) and derived+writable rejection
tests/api/test_params_api.F90 Extends Fortran API test to include writable offers + writable plugin requests
src/plume/Protocol.h Adds requireWritable() and extends offer() with writable flag
src/plume/Negotiator.h Adds write-back policy + cross-plugin conflict state + log summary API
src/plume/Negotiator.cc Implements writable gating, conflict detection, claim recording, and summary logging
src/plume/ManagerConfig.h Adds write-back-policy key validation + accessors
src/plume/Manager.h Documents new negotiation behavior and adds getActivePluginNames()
src/plume/Manager.cc Wires Manager negotiation to WriteBackPolicy + Negotiator summary logging
src/plume/data/ParameterCatalogue.h Adds writable field to ParameterDefinition API/schema
src/plume/data/ParameterCatalogue.cc Parses writable, prevents derived+writable definitions, and stores writable in config
src/plume/coupling/WriteBackPolicy.h New enum + helpers defining policy semantics
src/plume/coupling/WriteBackPolicy.cc String parsing + stream output for policies
src/plume/coupling/README.md New policy reference documentation for write-back behavior
src/plume/CMakeLists.txt Adds new write-back policy sources to build
src/plume/api/plume.h Adds writable-offer C API entrypoints
src/plume/api/plume.cc Implements writable-offer C API wrappers
src/plume/api/plume_protocol.F90 Exposes writable-offer APIs to Fortran

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/plume/coupling/README.md Outdated
Comment thread src/plume/coupling/README.md Outdated
Comment thread src/plume/Negotiator.cc
@codecov-commenter

codecov-commenter commented Jul 2, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 89.04382% with 55 lines in your changes missing coverage. Please review.
✅ Project coverage is 72.99%. Comparing base (18b475c) to head (f7a58ee).

Files with missing lines Patch % Lines
src/plume/api/plume.cc 20.00% 24 Missing ⚠️
src/plume/api/plume_protocol.F90 20.00% 12 Missing ⚠️
src/plume/Negotiator.cc 92.63% 7 Missing ⚠️
src/plume/coupling/WriteAuthorisation.cc 70.58% 5 Missing ⚠️
src/plume/Manager.cc 81.25% 3 Missing ⚠️
src/plume/coupling/WriteBackPolicy.cc 88.23% 2 Missing ⚠️
tests/core/test_negotiator.cc 98.58% 2 Missing ⚠️
Additional details and impacted files
@@                     Coverage Diff                      @@
##           feature/two-way-coupling      #30      +/-   ##
============================================================
+ Coverage                     71.24%   72.99%   +1.74%     
============================================================
  Files                            92       97       +5     
  Lines                          3912     4358     +446     
  Branches                        348      386      +38     
============================================================
+ Hits                           2787     3181     +394     
- Misses                         1125     1177      +52     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@cducher
cducher requested review from antons-it and dsarmany July 3, 2026 15:16
@cducher
cducher force-pushed the feature/two-way-coupling-negotiation branch from 27e8e92 to dbd791b Compare July 3, 2026 15:22
@cducher
cducher force-pushed the feature/two-way-coupling-negotiation branch from dbd791b to 7efa12e Compare July 20, 2026 17:48

@antons-it antons-it left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Nice work! only a minor suggestion

*
* See README for the full policy reference.
*/
enum class WriteBackPolicy : uint8_t {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

just a note: I think this list of policies should cover most (all) cases that we can think of right now. I would not worry about the flexibility of this.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I am not sure I understand your note, do you mean that I currently have anticipated too many scenarios ? As you said, that's the configurations I could think of for now in our current context, and it will be straightforward in the future to add another policy via this enum if we identify a new case indeed.

Comment thread src/plume/Negotiator.cc
}


void Negotiator::logSummary() const {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think it would be useful to also add the revers of this map. param -> plugins(s). From the "Claimants_" maps already recorded. If too verbose we can add it under a "verbose" configuration flag.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Yes in fact I see you have a "verbose" flag in the configuration which is not really used anywhere, either plugins or Plume, but during this dev I was thinking it'd be nice to give power to this flag by implementing a verbose mode or even some levels. For now I can add the reverse map log here as well, and open a ticket specifically to leverage this verbose flag and filter through the current Plume log. What do you think?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Created PLUME-88 to follow up on this, and will add extra logging here in the meantime.

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.

4 participants