Skip to content

[Refactor] Architecture, contracts and ergonomics audit (Part 3: Engine SRP decomposition & dead code purge) (#643) - #648

Merged
remiceres merged 4 commits into
feature/corese-nextfrom
refactor/643-engine-srp-decomposition
Oct 26, 2026
Merged

remiceres merged 4 commits into
feature/corese-nextfrom
refactor/643-engine-srp-decomposition

Conversation

@remiceres

Copy link
Copy Markdown
Contributor

Summary

This PR delivers Part 3 of the architectural audit and refactoring track (#643), targeting the modern KGRAM query execution engine (fr.inria.corese.core.next.query.impl.engine).

1. Legacy Event System Purge & Eval State Extraction

  • Deleted historical dead event classes: Event.java, EventImpl.java, EventListener.java, KgramEventDispatcher.java.
  • Extracted EvaluationState.java (lifecycle, cancellation, timeout tracking) and EvalVisitorDispatcher.java (visitor dispatching).
  • Enforced strict private encapsulation on Exp.java fields.

2. P0 Quick Wins & Safety

  • Federated SERVICE Safety: Guarded Eval.service() against silent local fallback when no provider is configured. Throws QueryEvaluationException unless explicit SERVICE SILENT is requested.
  • Dead Code Eradication: Physically deleted unreferenced classes QueryDefinitionChecker.java and Merge.java.
  • Dormant Flags Purge: Purged unused flags (isCheck, isConnect, COUNT_PROFILE, CACHE_MODE) and dead fields in Exp.java (level, num, generated).
  • Reduced cognitive complexity in Eval.service() by extracting processServiceMappings().

3. P1 SRP Decomposition & Dependency Inversion

  • Dependency Inversion (DIP): Decoupled Mappings.java from sparql.bridge.DirectGroupAggregation via the new functional SPI GroupAggregator.java.
  • Solution Materialization: Extracted SolutionMaterializer.java from Memory.java to isolate solution mapping construction, projection, and sorting key evaluation.
  • Binding Management: Extracted BindingStack.java to manage primitive node/edge array bindings and backjump level indices.
  • Resource Lifecycle: Introduced ExecutionSession.java in SparqlQueryExecutor.java (AutoCloseable) ensuring clean lifecycle closure for producers.

Validation

  • 100% unit tests pass across corese-core (3,200+ tests).
  • 100% architecture boundary tests pass (NextModuleBoundaryTest).
  • 0 SonarLint issues (cognitive complexity < 15, no silent catches).

…te and visitor dispatching (#643)

- Eradicate legacy dead event classes (Event, EventImpl, EventListener, KgramEventDispatcher)
- Remove unused event manager references in Memory, Mappings, and Environments
- Extract EvaluationState from Eval to isolate execution counters and cooperative cancellation
- Extract EvalVisitorDispatcher to isolate ProcessVisitor and ResultListener lifecycle hooks
- Encapsulate all Exp fields as private
- Add comprehensive unit tests with zero SonarLint alerts and 100% test pass
…legacy stubs (#643)

- Guard federated SERVICE execution against silent local fallback (throw QueryEvaluationException unless SILENT)
- Delete dead classes QueryDefinitionChecker and Merge
- Purge unused flags (isCheck, isConnect, COUNT_PROFILE, CACHE_MODE) and dead Exp fields (level, num, generated)
- Consolidate empty edge arrays in Memory and remove dead Matcher mode
- Reduce cognitive complexity of Eval.service by extracting processServiceMappings
- Update unit tests with 100% pass
…ution materialization (#643)

- Introduce GroupAggregator SPI to decouple Mappings from sparql.bridge.DirectGroupAggregation
- Extract SolutionMaterializer from Memory.java to isolate query solution mapping materialization and projection
- Extract BindingStack to manage low-level node/edge arrays and backjump levels
- Introduce AutoCloseable ExecutionSession in SparqlQueryExecutor for clean producer lifecycle management
- Add unit tests for GroupAggregator, BindingStack, and ExecutionSession with 100% pass
@github-actions

Copy link
Copy Markdown
Overall Project 58.17% -0.08% 🍏
Files changed 83.27% 🍏

File Coverage
RdfTermMatcher.java 100% 🍏
ExecutionSession.java 100% 🍏
SparqlQueryExecutor.java 96.28% -0.32% 🍏
DirectGroupAggregation.java 96.17% 🍏
Evaluator.java 95% -5% 🍏
BindingStack.java 91.86% -8.14% 🍏
EvaluationState.java 91.18% -8.82% 🍏
EvalVisitorDispatcher.java 90.45% -9.55% 🍏
Group.java 87.92% 🍏
Query.java 80.1% 🍏
SparqlKgramEvaluator.java 80% 🍏
SolutionMaterializer.java 77.78% -22.22% 🍏
Mappings.java 75.06% -0.09% 🍏
EvalOptional.java 71.47% 🍏
Exp.java 68.9% 🍏
Eval.java 67.83% -3.68% 🍏
Memory.java 53.26% 🍏
StorageBindingEnvironment.java 10.25% 🍏
EnvironmentImpl.java 2.52% 🍏
Environment.java 0% 🍏

@github-actions

github-actions Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

Test Results

  422 files    422 suites   26s ⏱️
3 391 tests 3 391 ✅ 0 💤 0 ❌
3 425 runs  3 425 ✅ 0 💤 0 ❌

Results for commit de42126.

♻️ This comment has been updated with latest results.

…ty and volatile aggregator (#643)

- Guard ExecutionSession constructor against resource leaks if Eval.create fails
- Make Mappings.groupAggregator volatile for thread-safe access
- Remove orphan BindingStack to keep codebase strictly pruned of unused classes
- Add comprehensive fallback tests in GroupAggregatorTest (null and false returning)
@github-actions

Copy link
Copy Markdown
Overall Project 58.12% -0.07% 🍏
Files changed 79.49% 🍏

File Coverage
RdfTermMatcher.java 100% 🍏
DirectGroupAggregation.java 96.17% 🍏
SparqlQueryExecutor.java 96.12% -0.32% 🍏
Evaluator.java 95% -5% 🍏
EvaluationState.java 91.18% -8.82% 🍏
EvalVisitorDispatcher.java 90.45% -9.55% 🍏
ExecutionSession.java 89.8% -10.2% 🍏
Group.java 87.92% 🍏
Query.java 80.1% 🍏
SparqlKgramEvaluator.java 80% 🍏
SolutionMaterializer.java 77.78% -22.22% 🍏
Mappings.java 75.06% -0.09% 🍏
EvalOptional.java 71.47% 🍏
Exp.java 68.9% 🍏
Eval.java 67.83% -3.68% 🍏
Memory.java 53.26% 🍏
StorageBindingEnvironment.java 10.25% 🍏
EnvironmentImpl.java 2.52% 🍏
Environment.java 0% 🍏

@remiceres
remiceres merged commit e4f926a into feature/corese-next Oct 26, 2026
2 checks passed
@remiceres
remiceres deleted the refactor/643-engine-srp-decomposition branch October 26, 2026 14:01
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