Skip to content

Subcontext: refactor evaluation stages from context#442

Merged
Anilm3 merged 1 commit into
anilm3/v2from
anilm3/refactor-context
Aug 19, 2025
Merged

Subcontext: refactor evaluation stages from context#442
Anilm3 merged 1 commit into
anilm3/v2from
anilm3/refactor-context

Conversation

@Anilm3

@Anilm3 Anilm3 commented Aug 19, 2025

Copy link
Copy Markdown
Collaborator

Subcontexts will be implemented by:

  • Adding and enforcing a scope (context, subcontext) to the evaluation process
  • Adding a scope to the data (replacing attribute::none and attribute::ephemeral)
  • Creating a new subcontext and subcontext_wrapper class which will be created from the current context (and with a linked lifecycle)

To do this, the evaluation process must be refactored out of the context, so that it can be used separately within the subcontext using the correct scope. This PR does exactly this first step, splitting these from context into the evaluation_engine.

The next PR will:

  • Implement the subcontext piggybacking on ephemerals.
  • Remove the concept of ephemerality in favour of scope (context, subcontext).
  • Split the API to create and use subcontexts.

@Anilm3
Anilm3 requested a review from a team as a code owner August 19, 2025 12:30
Comment thread src/evaluation_engine.cpp
// This scope ensures that all ephemeral and cached objects are removed
// from the store at the end of the evaluation
auto store_cleanup_scope = store_.get_eval_scope();
auto storecleanup_scope = store.get_eval_scope();

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.

Will fix with any review comments or in a subsequent PR.

@codecov-commenter

codecov-commenter commented Aug 19, 2025

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 90.00000% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 85.24%. Comparing base (86cbf40) to head (1b1da69).

Files with missing lines Patch % Lines
src/evaluation_engine.hpp 80.00% 0 Missing and 5 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           anilm3/v2     #442   +/-   ##
==========================================
  Coverage      85.23%   85.24%           
==========================================
  Files            181      182    +1     
  Lines           9356     9362    +6     
  Branches        4065     4067    +2     
==========================================
+ Hits            7975     7981    +6     
  Misses           538      538           
  Partials         843      843           
Flag Coverage Δ
waf_test 85.24% <90.00%> (+<0.01%) ⬆️

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

☔ View full report in Codecov by Sentry.
📢 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.

@pr-commenter

pr-commenter Bot commented Aug 19, 2025

Copy link
Copy Markdown

Benchmarks clang

Benchmark execution time: 2025-08-19 17:36:49

Comparing candidate commit 1b1da69 in PR branch anilm3/refactor-context with baseline commit 86cbf40 in branch anilm3/v2.

Found 0 performance improvements and 1 performance regressions! Performance is the same for 0 metrics, 0 unstable metrics.

scenario:global-benchmark.random.clang

  • 🟥 execution_time [+36.778ms; +36.793ms] or [+15.516%; +15.522%]

@pr-commenter

pr-commenter Bot commented Aug 19, 2025

Copy link
Copy Markdown

Benchmarks gcc

Benchmark execution time: 2025-08-19 17:38:08

Comparing candidate commit 1b1da69 in PR branch anilm3/refactor-context with baseline commit 86cbf40 in branch anilm3/v2.

Found 0 performance improvements and 0 performance regressions! Performance is the same for 1 metrics, 0 unstable metrics.

@github-actions

github-actions Bot commented Aug 19, 2025

Copy link
Copy Markdown

Artifact Size Comparison 📦

Artifact Previous Release This PR Difference
darwin-arm64::libddwaf.a 86105528 89238632 0.03%
darwin-arm64::libddwaf.a.stripped 4442896 4704056 0.05%
darwin-arm64::libddwaf.dylib 1920368 1969920 0.02%
darwin-universal::libddwaf.a 173548224 180009904 0.03%
darwin-universal::libddwaf.a.stripped 9465600 10016976 0.05%
darwin-universal::libddwaf.dylib 4050288 4132608 0.02%
darwin-x86_64::libddwaf.a 87442648 90771224 0.03%
darwin-x86_64::libddwaf.a.stripped 5022656 5312872 0.05%
darwin-x86_64::libddwaf.dylib 2107008 2139800 0.01%
linux-aarch64::libddwaf.a 70896324 73083728 0.03%
linux-aarch64::libddwaf.a.stripped 11575224 11937292 0.03%
linux-aarch64::libddwaf.so 2427912 2444688 0.00%
linux-armv7::libddwaf.a 62633514 64484756 0.02%
linux-armv7::libddwaf.a.stripped 10576914 10931736 0.03%
linux-armv7::libddwaf.so 2108812 2099752 0.00%
linux-i386::libddwaf.a 60811086 62649072 0.03%
linux-i386::libddwaf.a.stripped 9140778 9459704 0.03%
linux-i386::libddwaf.so 2346940 2353896 0.00%
linux-x86_64::libddwaf.a 71366196 73556320 0.03%
linux-x86_64::libddwaf.a.stripped 11397112 11740100 0.03%
linux-x86_64::libddwaf.so 2616768 2630496 0.00%
windows-win32::ddwaf.dll 3298304 3395584 0.02%
windows-win32::ddwaf.lib 11922 14126 0.18%
windows-win32::ddwaf_static.lib 47761216 49633480 0.03%
windows-x64::ddwaf.dll 4030976 4106752 0.01%
windows-x64::ddwaf.lib 11698 13860 0.18%
windows-x64::ddwaf_static.lib 55348460 57258590 0.03%

@pr-commenter

pr-commenter Bot commented Aug 19, 2025

Copy link
Copy Markdown

Benchmarks clang-pgo

Benchmark execution time: 2025-08-19 13:01:07

Comparing candidate commit 1b1da69 in PR branch anilm3/refactor-context with baseline commit 86cbf40 in branch anilm3/v2.

Found 0 performance improvements and 0 performance regressions! Performance is the same for 1 metrics, 0 unstable metrics.

@Anilm3
Anilm3 marked this pull request as draft August 19, 2025 16:57
@Anilm3
Anilm3 force-pushed the anilm3/refactor-context branch from f0198ef to 1b1da69 Compare August 19, 2025 17:16
@Anilm3
Anilm3 marked this pull request as ready for review August 19, 2025 17:16
@Anilm3
Anilm3 enabled auto-merge (squash) August 19, 2025 17:33
@Anilm3
Anilm3 merged commit 2b7ad55 into anilm3/v2 Aug 19, 2025
101 of 102 checks passed
@Anilm3
Anilm3 deleted the anilm3/refactor-context branch August 19, 2025 17:43
Anilm3 added a commit that referenced this pull request Oct 1, 2025
* Object view: read only abstraction to ddwaf_object (#341)
* [v2] Remove mingw builds (#381)
* Writable objects: owned and borrowed object and object limits removal (#378, #382)
* [v2] Refactor and improve object types (#387)
* [v2] Update unit tests to use new abstractions (#389)
* [v2] Update `raw_configuration` type to use `object_view` (#390)
* [v2] Remove remaining uses of ddwaf_object in `src` and `tests/unit` (#391)
* [v2] JWT Decoding Processor (#401)
* [v2] First iteration of object layout changes (#394)
* Split context data insertion from evaluation (#407)
* [v2] Second iteration of object layout changes (#408)
* [v2] Add new fingerprint and object view tests (#414)
* Reenable attribute collector unit test (#415)
* [v2] Container view types (#413)
* Exclude assertions from coverage (#416)
* [v2] Use allocators internally instead of malloc/free and stop generating zero-terminated strings (#418)
* Add memory resource to owned and borrowed objects (#428)
* [v2] Propagate allocators from context (#420)
* [v2] Update interface and expose allocators (#427)
* Refactor evaluation stages out of the context (#442)
* Subcontext: replace ephemerals with a new scope with user-defined lifetime derived from the context (#443)
* Validator: Add support for testing subcontexts and attributes (#451)
* [v2] Pass allocator to context and subcontext eval and add new allocators (#452)
* Update logger to avoid dependencies on ddwaf.h (#453)
* [v2] Return DDWAF_MATCH when there are events, attributes or actions (#455)
* [v2] Cleanup: remove exclusion namespace and some redundant references (#456)
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