Skip to content

Make layer specification optional - #817

Open
beojan wants to merge 12 commits into
Framework-R-D:mainfrom
beojan:optional-layer
Open

Make layer specification optional#817
beojan wants to merge 12 commits into
Framework-R-D:mainfrom
beojan:optional-layer

Conversation

@beojan

@beojan beojan commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Layer specifications are now optional in product_selectors. As discussed with Kyle and Marc, this is currently limited to single input functions. Folds are always considered multi-input (they have an implicit accumulator input).

In addition, this is not currently enabled for unfolds because their input layers are used in the flush machinery.

AI summary below


  • Core behavior

    • Allows omitted product_selector layers for single-input functions.
    • Resolves omitted layers from explicit or implicit providers.
    • Treats omitted query layers as wildcards during selector matching.
    • Keeps folds as multi-input functions and requires their layers.
    • Rejects unfold inputs without layers because flush machinery uses those layers.
    • Improves diagnostics for missing and invalid layer names.
  • Implementation

    • Adds optional layer storage and validation in product_selector.
    • Updates provider wiring and implicit-provider reuse.
    • Uses wildcard identifiers for unresolved provider input layers.
    • Updates products_consumer to enforce layers for multi-input consumers.
    • Adds required compiler-specific linking for GNU toolchains.
  • Tests

    • Covers layerless selectors for computational nodes, predicates, observers, transformed products, and explicit or implicit providers.
    • Verifies shared implicit-provider inputs and execution counts.
    • Verifies the expected diagnostic for layerless unfold inputs.

@coderabbitai

coderabbitai Bot commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 5fe30869-295d-45d1-801a-1ae713b57060

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

The PR adds optional layers to product selectors, treats unset layers as wildcards, validates mandatory layers, updates provider and unfold wiring, adds coverage for layerless selection, and adjusts GNU compiler-specific linkage.

Changes

Layerless product selection

Layer / File(s) Summary
Optional selector layers
phlex/core/product_selector.*, phlex/core/CMakeLists.txt
product_selector now supports unset layers, wildcard matching, [ANY] formatting, and validated conversions. GNU linkage supports GCC-specific standard library components.
Consumer layer validation
phlex/core/products_consumer.*, phlex/core/declared_fold.cpp, phlex/core/multilayer_join_node.hpp
products_consumer derives wildcard layers and validates required layers. Declared folds enable mandatory-layer validation.
Provider and unfold wiring
phlex/core/make_computational_edges.cpp, phlex/core/index_router.cpp, phlex/core/framework_graph.cpp
Provider registration propagates matched layers and reuses matching implicit providers. Layerless inputs use wildcard identifiers. Unfolds reject inputs without defined layers.
Selection and provider tests
test/product_selecting.cpp
Tests cover layerless selectors, creator and layer matching, predicates, observers, rejected unfolds, and shared implicit providers.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant IndexRouter
  participant MakeComputationalEdges
  participant ProductSelector
  IndexRouter->>MakeComputationalEdges: Register provider inputs
  MakeComputationalEdges->>ProductSelector: Match layerless selector
  ProductSelector-->>MakeComputationalEdges: Return matching provider
  MakeComputationalEdges-->>IndexRouter: Apply provider layer or wildcard identifier
Loading

Possibly related PRs

Suggested reviewers: knoepfel

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 13.79% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: making layer specifications optional.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@phlex/core/framework_graph.cpp`:
- Around line 69-72: Update framework_graph::finalize() to compute unfold
validation/data before the early return triggered by empty head_ports. Ensure
the resulting unfold information is passed to index_router_.finalize(), and
preserve validation of each unfold input’s layer, including the check in the
unfold handling around input.layer and n->name().

In `@phlex/core/multilayer_join_node.hpp`:
- Line 79: In the multilayer join setup around set_ports, validate that
layers_.size() is at least NInputs before indexing repeaters_[Is]. Restore the
equivalent assertion or throw a clear validation error, while preserving the
existing behavior for valid layer counts.

In `@phlex/core/products_consumer.hpp`:
- Around line 22-25: Replace the boolean layer-policy parameter in
products_consumer with a lower_case enum class and named enumerators; update
products_consumer.cpp to compare against the appropriate enum value, and update
declared_fold.cpp to pass the mandatory-layers enumerator. Apply these changes
at phlex/core/products_consumer.hpp lines 22-25,
phlex/core/products_consumer.cpp lines 25-49, and phlex/core/declared_fold.cpp
lines 8-11.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: bdd3e12f-a8d6-4970-8b88-c30859ed4aab

📥 Commits

Reviewing files that changed from the base of the PR and between 5f7a4a4 and c9b046c.

📒 Files selected for processing (11)
  • phlex/core/CMakeLists.txt
  • phlex/core/declared_fold.cpp
  • phlex/core/framework_graph.cpp
  • phlex/core/index_router.cpp
  • phlex/core/make_computational_edges.cpp
  • phlex/core/multilayer_join_node.hpp
  • phlex/core/product_selector.cpp
  • phlex/core/product_selector.hpp
  • phlex/core/products_consumer.cpp
  • phlex/core/products_consumer.hpp
  • test/product_selecting.cpp
📜 Review details
⏰ Context from checks skipped due to timeout. (4)
  • GitHub Check: Analyze cpp with CodeQL
  • GitHub Check: clang-tidy-check
  • GitHub Check: build (gcc, none)
  • GitHub Check: coverage
🧰 Additional context used
📓 Path-based instructions (3)
**/*.{cpp,cc,cxx,h,hpp}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

**/*.{cpp,cc,cxx,h,hpp}: Use clang-format tool for all C++ code formatting (VS Code auto-formats on save); configuration defined in .clang-format with 100-character line limit and 2-space indentation
Follow clang-tidy recommendations defined in .clang-tidy

Files:

  • phlex/core/declared_fold.cpp
  • phlex/core/products_consumer.hpp
  • phlex/core/make_computational_edges.cpp
  • phlex/core/framework_graph.cpp
  • phlex/core/index_router.cpp
  • phlex/core/multilayer_join_node.hpp
  • phlex/core/products_consumer.cpp
  • phlex/core/product_selector.cpp
  • test/product_selecting.cpp
  • phlex/core/product_selector.hpp
**/*.{hpp,cpp}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{hpp,cpp}: Use .hpp for header files, .cpp for implementation, and *_test.cpp for test files in C++
Enforce 100-character line limit and 2-space indentation in C++ code via .clang-format
Use QualifierAlignment: Right (east-const) style: int const x not const int x in C++
Use PointerAlignment: Left in C++ (pointer * attached to type, not variable name)
All C++ identifiers must use lower_case naming: namespaces, classes, structs, enums, functions, variables, parameters, members, and constants
Exception to C++ naming: template parameters use CamelCase
Exception to C++ naming: macros use UPPER_CASE
Private, protected, and constant members in C++ must have a trailing underscore (_), no trailing underscore on anything else
Use enum class preferred over plain enum in C++
Use std::shared_ptr for shared ownership, std::unique_ptr for exclusive ownership, raw pointers for non-owning references only in C++
Use functors with agent-noun pattern: ModelEvaluator evaluate_model(...) in C++
Apply .clang-tidy checks for bugprone, cert, clang-analyzer, concurrency, cppcoreguidelines, misc, modernize, performance, portability, and readability as defined in the .clang-tidy configuration file
Use phlex:: namespace for core code, phlex::experimental:: for experimental features in C++

Files:

  • phlex/core/declared_fold.cpp
  • phlex/core/products_consumer.hpp
  • phlex/core/make_computational_edges.cpp
  • phlex/core/framework_graph.cpp
  • phlex/core/index_router.cpp
  • phlex/core/multilayer_join_node.hpp
  • phlex/core/products_consumer.cpp
  • phlex/core/product_selector.cpp
  • test/product_selecting.cpp
  • phlex/core/product_selector.hpp
**/*.hpp

📄 CodeRabbit inference engine (AGENTS.md)

Avoid boolean parameters in C++ interfaces; prefer enumerations instead

Files:

  • phlex/core/products_consumer.hpp
  • phlex/core/multilayer_join_node.hpp
  • phlex/core/product_selector.hpp
🪛 Cppcheck (2.21.0)
test/product_selecting.cpp

[style] 60-60: The function 'initial_value' is never used.

(unusedFunction)

🔇 Additional comments (10)
test/product_selecting.cpp (1)

4-7: LGTM!

Also applies to: 31-66, 76-76, 92-106, 115-125, 127-143, 145-159, 161-174, 176-191

phlex/core/product_selector.hpp (2)

12-14: LGTM!

Also applies to: 47-77, 80-98


79-79: 🩺 Stability & Availability

Do not change layer_name::operator* in this patch. layer_name is intentionally optional, and its unchecked access matches std::optional::operator*. In-tree callers guard it before dereferencing. This patch only adds defaulted comparisons.

			> Likely an incorrect or invalid review comment.
phlex/core/product_selector.cpp (1)

12-12: LGTM!

Also applies to: 53-53, 80-80, 102-103

phlex/core/CMakeLists.txt (1)

42-48: LGTM!

Also applies to: 110-116

phlex/core/products_consumer.cpp (1)

3-18: LGTM!

phlex/core/make_computational_edges.cpp (2)

55-60: LGTM!

Also applies to: 123-128


86-86: 🗄️ Data Integrity & Integration

No change needed

product_selector::match treats an unset layer on the left as a wildcard and rejects a different concrete layer. Existing tests cover layerless requests and shared implicit providers.

phlex/core/index_router.cpp (2)

110-110: 🎯 Functional Correctness

No change needed for _id lookup. phlex/core/product_selector.hpp is transitively included before wire_provider_index_sets, and its namespace-scope using-directive makes "_id" visible at Line 201.

			> Likely an incorrect or invalid review comment.

201-201: 🗄️ Data Integrity & Integration

No wildcard precedence change is required. The selector layer is populated from the matched provider before registration, and "*"_id does not match concrete layer names.

			> Likely an incorrect or invalid review comment.

Comment thread phlex/core/framework_graph.cpp Outdated
Comment thread phlex/core/multilayer_join_node.hpp
Comment thread phlex/core/products_consumer.hpp Outdated
@codecov

codecov Bot commented Aug 11, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 77.08333% with 22 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
phlex/core/make_computational_edges.cpp 58.33% 9 Missing and 1 partial ⚠️
phlex/core/product_selector.hpp 65.21% 4 Missing and 4 partials ⚠️
phlex/core/products_consumer.cpp 91.30% 0 Missing and 2 partials ⚠️
phlex/core/index_router.cpp 50.00% 0 Missing and 1 partial ⚠️
phlex/core/registrar.hpp 88.88% 0 Missing and 1 partial ⚠️
@@            Coverage Diff             @@
##             main     #817      +/-   ##
==========================================
+ Coverage   83.89%   84.01%   +0.11%     
==========================================
  Files         171      172       +1     
  Lines        7234     7475     +241     
  Branches      850      887      +37     
==========================================
+ Hits         6069     6280     +211     
- Misses        881      901      +20     
- Partials      284      294      +10     
Flag Coverage Δ
scripts 80.09% <ø> (ø)
unittests 85.87% <77.08%> (+0.08%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
phlex/configuration.cpp 100.00% <100.00%> (ø)
phlex/core/declared_fold.cpp 100.00% <100.00%> (ø)
phlex/core/declared_unfold.cpp 100.00% <100.00%> (ø)
phlex/core/framework_graph.cpp 97.52% <ø> (+0.85%) ⬆️
phlex/core/multilayer_join_node.hpp 88.23% <100.00%> (+0.23%) ⬆️
phlex/core/product_selector.cpp 87.27% <100.00%> (-0.87%) ⬇️
phlex/core/products_consumer.hpp 100.00% <ø> (ø)
phlex/core/index_router.cpp 92.46% <50.00%> (-0.26%) ⬇️
phlex/core/registrar.hpp 89.47% <88.88%> (+2.80%) ⬆️
phlex/core/products_consumer.cpp 91.42% <91.30%> (-0.88%) ⬇️
... and 2 more

... and 7 files with indirect coverage changes


Continue to review full report in Codecov by Harness.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 67595f4...b54a049. Read the comment docs.

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

beojan and others added 9 commits August 11, 2026 10:11
Exercise omitted-layer resolution across computational nodes and explicit and implicit providers. Verify that unfolds reject selectors without a layer using the intended diagnostic.

AI-Authored-By: OpenAI Codex
AI-Model: gpt-5.6-sol
AI-Reasoning-Effort: medium
Select the libstdc++ stacktrace support library once from the compiler and version, then expose it through both core targets. This keeps the generated link interfaces complete for GCC and Clang without extra configuration probes.

AI-Authored-By: OpenAI Codex
AI-Model: gpt-5.6-sol
AI-Reasoning-Effort: medium
@beojan

beojan commented Aug 11, 2026

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3fc4abb7a2

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread phlex/core/product_selector.cpp
Comment thread phlex/core/product_selector.hpp
Comment thread phlex/core/product_selector.hpp
Comment thread phlex/core/products_consumer.cpp
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