diff --git a/docs/next-engine-ast-boundary.md b/docs/next-engine-ast-boundary.md index e4ab1056c..0da162598 100644 --- a/docs/next-engine-ast-boundary.md +++ b/docs/next-engine-ast-boundary.md @@ -1,58 +1,31 @@ # Engine / AST dependency boundary -The target is an execution engine independent of parser and SPARQL AST types. -The current engine still exposes three dependencies. `NextModuleBoundaryTest` -inventories them as exact source-path / referenced-type pairs, rather than -exempting whole files or packages. +The query execution engine is independent of parser and SPARQL AST types. +`NextModuleBoundaryTest` enforces this invariant with zero exceptions across all +engine sources. -## Existing exceptions +## Decoupling history -Paths below are relative to `next/query/impl/engine`. +Previously, three source files in `next/query/impl/engine` retained AST dependencies: -| Source | AST type | Current use and callers | -| --- | --- | --- | -| `model/Filter.java` | `TermAst` | Return types of `getFilterExpression()` and `coreseNextSource()`. `NextFilterFromAst` implements both in the bridge. `Exp` delegates the first; `AstBackedExprTest` checks its result. No production caller of `coreseNextSource()` was found in `next`. | -| `pattern/Exp.java` | `TermAst` | Return type of `getFilterExpression()`, delegating to `Filter`. No production caller of this accessor was found in `next`. | -| `pattern/Query.java` | `QueryAst` | Field `ast` and accessors `getAST()`, `getGlobalAST()`, `setAST()`. `CoreseAstQueryBuilder` sets the source AST for each query form; `QueryTest` tests the accessors. No external production reader of these accessors was found in `next`. | - -This is a source-reference inventory, not a statement that these APIs can be -removed without checking downstream clients. Bridge implementations may still -own AST objects internally after the engine contracts stop exposing their types. +- `model/Filter.java`: returned `TermAst` via `getFilterExpression()` and `coreseNextSource()`. + These AST accessors were removed from the engine interface; the bridge implementation + `NextFilterFromAst` retains AST-level access internally where needed. +- `pattern/Exp.java`: exposed `getFilterExpression()` delegating to `Filter`. Removed as it + had no engine callers. +- `pattern/Query.java`: retained `QueryAst ast` with `getAST()`, `getGlobalAST()`, and `setAST()`. + Removed from `Query`; query builder compilation produces pure engine operator trees. ## Guard behavior +- Zero exceptions: `EXISTING_ENGINE_AST_DEPENDENCIES` is empty. - Parser dependencies have no exceptions. - Both the actual `query.impl.sparql.ast` package and the historical `query.impl.ast` package are checked. - Imports, wildcard imports, static references and fully qualified references - are detected by the existing source-reference matching approach. -- Adding a type to an already listed file is rejected. -- Adding an existing AST type to another file is rejected. -- Removing a dependency requires removing its exception in the same change. - -The source scanner also sees fully qualified names in comments and strings. It -does not perform bytecode or transitive dependency analysis. Its regression test -uses synthetic sources to check new files, new types, wildcard imports and fully -qualified references outside imports. - -## Follow-up: remove the exceptions - -1. Check repository-wide and downstream uses of the source-AST accessors before - removing them; assess compatibility of these implementation classes. -2. Remove the unused `Exp` forwarding accessor and the AST accessors from the - engine `Filter` contract. Keep source-AST access inside the bridge where needed; - adapt `AstBackedExprTest` to test bridge behavior rather than an engine AST API. -3. Remove AST retention from `Query` if no required consumer exists. If diagnostics - need source information, keep it in a bridge-owned structure with an explicit - lifecycle, rather than replacing typed accessors with `Object` or unsafe casts. -4. Remove the corresponding builder writes and accessor-only tests. Preserve - behavioral tests for query forms, expressions and subqueries. -5. Delete each exception as its dependency disappears, then restore the strict - no-AST-dependencies invariant in the engine package documentation. - -Do not introduce new runtime behavior as part of this follow-up. Validate with -the architecture tests, the full core test suite and a comparison against the -existing W3C baseline. + are detected by the source-reference scanner. +- Any new dependency on parser or AST packages within `query/impl/engine` causes + `NextModuleBoundaryTest.queryEngineMustNotAddParserOrAstDependencies` to fail immediately. ## Validation diff --git a/src/main/java/fr/inria/corese/core/next/query/impl/engine/model/Filter.java b/src/main/java/fr/inria/corese/core/next/query/impl/engine/model/Filter.java index 16c4a97b0..dc6347d6e 100644 --- a/src/main/java/fr/inria/corese/core/next/query/impl/engine/model/Filter.java +++ b/src/main/java/fr/inria/corese/core/next/query/impl/engine/model/Filter.java @@ -1,27 +1,14 @@ package fr.inria.corese.core.next.query.impl.engine.model; - -import fr.inria.corese.core.next.query.impl.sparql.ast.TermAst; - import java.util.List; -import java.util.Optional; - /** - * Native filter contract backed by the Corese-next SPARQL AST. + * Native filter contract for the Corese-next execution engine. * * @author Olivier Corby, Edelweiss, INRIA 2010 */ public interface Filter { - /** - * When non-empty, the Corese-next AST node this filter was produced from - * (filter expression: {@link TermAst} / constraint subtypes). - */ - default Optional coreseNextSource() { - return Optional.empty(); - } - /** * List of variable names contained in the filter * @@ -33,8 +20,6 @@ default Optional coreseNextSource() { /** Evaluable expression processed by the native KGRAM evaluator. */ Expr getExp(); - TermAst getFilterExpression(); - /** * Does filter contain a bound() function * diff --git a/src/main/java/fr/inria/corese/core/next/query/impl/engine/package-info.java b/src/main/java/fr/inria/corese/core/next/query/impl/engine/package-info.java index 190301ed2..c96eb4718 100644 --- a/src/main/java/fr/inria/corese/core/next/query/impl/engine/package-info.java +++ b/src/main/java/fr/inria/corese/core/next/query/impl/engine/package-info.java @@ -7,11 +7,10 @@ * *

Architectural Invariants & Development Guardrails

*