Skip to content

implement configuration by file. - #595

Open
Ahmed-Elsaka-JC wants to merge 2 commits into
eclipse-score:mainfrom
Ahmed-Elsaka-JC:afe_config_by_file_per
Open

Ahmed-Elsaka-JC wants to merge 2 commits into
eclipse-score:mainfrom
Ahmed-Elsaka-JC:afe_config_by_file_per

Conversation

@Ahmed-Elsaka-JC

Copy link
Copy Markdown
Contributor

adding new support to config by file

#411

@github-actions

github-actions Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

License Check Results

🚀 The license check job ran with the Bazel command:

bazel run --lockfile_mode=error //:license-check

Status: ⚠️ Needs Review

Click to expand output
[License Check Output]
Starting local Bazel server (8.7.0) and connecting to it...
INFO: Invocation ID: a1a06680-0a9f-4234-aec7-24c77806ec06
Computing main repo mapping: 
Computing main repo mapping: 
Computing main repo mapping: 
Computing main repo mapping: 
Loading: 
Loading: 2 packages loaded
Loading: 2 packages loaded
    currently loading: 
Loading: 2 packages loaded
    currently loading: 
Loading: 2 packages loaded
    currently loading: 
Loading: 2 packages loaded
    currently loading: 
Loading: 2 packages loaded
    currently loading: 
Loading: 2 packages loaded
    currently loading: 
Analyzing: target //:license-check (3 packages loaded, 0 targets configured)
Analyzing: target //:license-check (3 packages loaded, 0 targets configured)

Analyzing: target //:license-check (83 packages loaded, 14 targets configured)

Analyzing: target //:license-check (99 packages loaded, 14 targets configured)

Analyzing: target //:license-check (100 packages loaded, 14 targets configured)

Analyzing: target //:license-check (100 packages loaded, 14 targets configured)

Analyzing: target //:license-check (153 packages loaded, 3717 targets configured)

Analyzing: target //:license-check (204 packages loaded, 8002 targets configured)

Analyzing: target //:license-check (207 packages loaded, 11661 targets configured)

Analyzing: target //:license-check (207 packages loaded, 11661 targets configured)

Analyzing: target //:license-check (212 packages loaded, 17771 targets configured)

Analyzing: target //:license-check (212 packages loaded, 17774 targets configured)

Analyzing: target //:license-check (212 packages loaded, 17774 targets configured)

INFO: Analyzed target //:license-check (213 packages loaded, 17903 targets configured).
[12 / 16] JavaToolchainCompileClasses external/rules_java+/toolchains/platformclasspath_classes; 0s disk-cache, processwrapper-sandbox ... (2 actions running)
INFO: From Generating Dash formatted dependency file ...:
INFO: Successfully converted 50 packages from Cargo.lock to bazel-out/k8-fastbuild/bin/tools/formatted.txt
[14 / 16] JavaToolchainCompileBootClasspath external/rules_java+/toolchains/platformclasspath.jar; 0s disk-cache, processwrapper-sandbox
INFO: Found 1 target...
Target //tools:license.check.license_check up-to-date:
  bazel-bin/tools/license.check.license_check
  bazel-bin/tools/license.check.license_check.jar
INFO: Elapsed time: 53.757s, Critical Path: 2.49s
INFO: 16 processes: 12 internal, 3 processwrapper-sandbox, 1 worker.
INFO: Build completed successfully, 16 total actions
INFO: Running command line: bazel-bin/tools/license.check.license_check tools/formatted.txt <args omitted>
[main] INFO Querying Eclipse Foundation for license data for 42 items.
[main] INFO Found 32 items.
[main] INFO Querying ClearlyDefined for license data for 10 items.
[main] INFO Found 10 items.
[main] INFO License information could not be automatically verified for the following content:
[main] INFO 
[main] INFO crate/cratesio/-/lazy_static/1.5.1
[main] INFO 
[main] INFO This content is either not correctly mapped by the system, or requires review.

@github-actions

Copy link
Copy Markdown
Contributor

Documentation preview for this pull request is available at:
pr-595: https://eclipse-score.github.io/persistency/pr-595/

@Ahmed-Elsaka-JC
Ahmed-Elsaka-JC deployed to workflow-approval October 27, 2026 10:52 — with GitHub Actions Active
@Ahmed-Elsaka-JC
Ahmed-Elsaka-JC deployed to workflow-approval October 27, 2026 10:52 — with GitHub Actions Active

@arkjedrz arkjedrz left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Review to internal/ files is not thorough yet, since many raised points relate to design.

#include <optional>

/*
* This header declares the abstraction over deployment-time "configuration by file" discovery and

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Since this is generated - ask Your LLM of choice to rework docs and comments. Following rules seem to be a good first step.

  • Be concise, use short sentences.
  • One sentence per line.
  • If a sentence is too long, try to rephrase it first.
  • This one's interesting, but turned out to be the most effective. Write as if it was written for an impatient developer that is not using English as a native language.

This is required, because otherwise those docs needlessly meander.

namespace score::mw::per::kvs
{

class IKvsConfigParser

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please use non-prefixed name for interface, and then suffix Impl for concrete implementation.
This is the already-required approach in baselibs, already followed by logging.

#include <cstddef>
#include <optional>

/*

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Follow new docs format. /// for docs, Doxygen-style @xyz keywords, // for comments.

* input: the `InstanceId::id` of the KVS instance about to be opened.
* behavior: Discovers whether a configuration-by-file document applies at all, and if so
* parses and strictly validates it in full before looking for an entry matching
* `instance_id`. Performs no mutation; intended to be called once per

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Performs no mutation -> then the function should be marked as const, and docs require no additional statement.

* input: the `InstanceId::id` of the KVS instance about to be opened.
* behavior: Discovers whether a configuration-by-file document applies at all, and if so
* parses and strictly validates it in full before looking for an entry matching
* `instance_id`. Performs no mutation; intended to be called once per

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

intended to be called once per -> additional request to LLM, do not state what is the expected usage and even where it is used, this is just a fluff.

(void)value;
const std::string_view key_view = key.GetAsStringView();
bool found = false;
for (const auto& allowed_key : allowed)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

std::any_of, return false quickly if not satisfied.
Do not use single point of return rule.

score::Unexpected KvsConfigParser::fail(ErrorCode code, std::string_view user_message) const
{
const auto error = MakeError(code, user_message);
logger_->LogError() << "KVS config:" << error.Message() << error.UserMessage();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

logger_ can become an object placed in anonymous namespace, then this function can be in anonymous function as well. Or a KVS-wide internal object, because it's using the same code.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is already done upstream, please use global logger.

return fail(ErrorCode::InvalidConfiguration, "unknown need_* value");
}

/*

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

cpp is not a place for docs.


/*
* Determine the directory containing the currently running binary.
* Used only as part of the fallback configuration file lookup; exposed for unit testing.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No fallback or candidates. It's a known path or an error.

EDIT: took a look at communication, here it's a default constructor or given path, but the overall approach is different - RuntimeConfiguration is created first, then provided to Initialize function. This is incompatible with persistency approach, but as mentioned in other comment - maybe other places in persistency component need a redesign too.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Dropping most of the comment, I don't think it should be there but the reasoning is now different - will explain in place.

* Determine the directory containing the currently running binary.
* Used only as part of the fallback configuration file lookup; exposed for unit testing.
*/
std::optional<std::string> running_binary_directory() const;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Do not pollute public API. I disagree this is needed, but if it is - move to anonymous namespace, and recreate in unit tests.

@Ahmed-Elsaka-JC
Ahmed-Elsaka-JC deployed to workflow-approval October 27, 2026 12:08 — with GitHub Actions Active
@Ahmed-Elsaka-JC
Ahmed-Elsaka-JC deployed to workflow-approval October 27, 2026 12:08 — with GitHub Actions Active

@tizava tizava left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

My proposal is to use the flatbuffes instead of parsing the json files on target.
Benefits:

  • Smaller memory footprint
  • No parsing overhead
  • More performant (Binary file is smaller)
  • Schema evolution / Verisoning

@arkjedrz

Copy link
Copy Markdown
Contributor

Writing down my point from the meeting.
I don't agree with then implicit merge of configuration. comp_req__kvs__constraints_priority should be dropped, no additional AoU specifying expectation that app is not doing mandatory config by code, comp_req__kvs__constraints should be rephrased into either X or Y.
This approach removes an entire class of issues that can occur on mismatched expectation from configuration provider or app developer. It simplifies requirements, documentation, and code.

I believe that an init step is missing from the KVS, and it's not specific to this change. Each KVS instance consumer is required to obtain the instance using same set of parameters as for the first time. This approach is not convenient (keeping track of parameters), might be a source of issues what is the expected configuration, since it initializes lazily - might be an issue to ensure allocations are done in the init phase.
I can imagine it could be like that:

  • At init the application configures the KVS instances. It's either by code or by config, ideally should config by code utilize same API as code by config internally.
  • At runtime the application obtains pre-configured instances using instance IDs.

@arkjedrz

Copy link
Copy Markdown
Contributor

Regarding flatbuffers - please hold on until it's no longer experimental. JSON is the way to go for now.

@arkjedrz arkjedrz left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I tried not to look too deeply into code etc., but rather focus on the approach. There are still valid comments unsolved.


/* Fixed filename of the configuration-by-file document, used standalone or appended to a
* directory named by the environment variable or to the binary-relative fallback directory. */
inline constexpr std::string_view kKvsConfigFileName = "key_value_storage_configs.json";

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Maybe to keep parity with com -> per_config.json, kvs_config.json?

{

/* Name of the environment variable naming the configuration directory or file. */
inline constexpr std::string_view kStorageConfigPathEnvVar = "STORAGE_CONFIG_PATH";

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

PER_CONFIG_PATH, KVS_CONFIG_PATH?

Comment thread score/kvs/kvsbuilder.hpp
/// @brief Specifies whether the KVS should be opened in read-only mode.
/// @param flag True to open read-only; false (default) for read-write.
/// @return Reference to this builder (for chaining).
KvsBuilder& read_only_flag(bool flag) noexcept;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please do split read-only into a separate PR to be merged first.
You can also add a component requirement for that.

Instead of using bool please use AccessMode enum with ReadWrite and ReadOnly modes.

Comment thread score/kvs/kvsbuilder.cpp
* (`ErrorCode::FileNotFound`, `ErrorCode::KvsFileReadError`, `ErrorCode::JsonParserError`,
* or `ErrorCode::InvalidConfiguration`), or any error from `Kvs::open()`.
*/
score::Result<Kvs> KvsBuilder::build() noexcept

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I stand by my point here.

  • An application that requires its data (need_kvs_flag(Required)) starts with an empty store if the file says "optional".
  • An application that opens a store with read_only_flag(true) can write to it if the file says "read_write".
  • A partial entry, for example only storage_path, combines file values and code values.
    Neither the integrator (who sees only the file) nor the developer (who sees only the code) sees the effective configuration.

BTW communication handles that by allowing only an add, otherwise it's an abort.

Comment thread score/kvs/kvsbuilder.cpp Resolved
Comment thread score/kvs/kvsbuilder.cpp
* (`ErrorCode::FileNotFound`, `ErrorCode::KvsFileReadError`, `ErrorCode::JsonParserError`,
* or `ErrorCode::InvalidConfiguration`), or any error from `Kvs::open()`.
*/
score::Result<Kvs> KvsBuilder::build() noexcept

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Keep const, store resolved variables in function scope.


/*
* Determine the directory containing the currently running binary.
* Used only as part of the fallback configuration file lookup; exposed for unit testing.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Dropping most of the comment, I don't think it should be there but the reasoning is now different - will explain in place.

{

/* Entry keys accepted inside a `key_value_storage_list` element. */
constexpr std::array<std::string_view, 7> kAllowedEntryKeys{"instance_id",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can a schema for JSON be used instead, like in communication?

score::Unexpected KvsConfigParser::fail(ErrorCode code, std::string_view user_message) const
{
const auto error = MakeError(code, user_message);
logger_->LogError() << "KVS config:" << error.Message() << error.UserMessage();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is already done upstream, please use global logger.

return std::optional<std::string>{std::nullopt};
}

const score::filesystem::Path candidate = score::filesystem::Path{bin_dir.value()} / ".." / "etc" /

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please align to communication, use <cwd>/etc/<config file>.

This branch was successfully deployed

1 active deployment
workflow-approval — 4ad857d5 Deployed Oct 27, 2026 by Ahmed-Elsaka-JC via qnx-build (score-qnx-aarch64) / approval #1445
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.

3 participants