Skip to content

Commit e4957a0

Browse files
committed
Merge branch 'main' into merge-main-20251215
# Conflicts: # PLANS.md
2 parents 4f37a2e + 8cdbc7e commit e4957a0

11 files changed

Lines changed: 1540 additions & 33 deletions

File tree

AGENTS.md

Lines changed: 88 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,70 @@
1-
# AGENTS.md
1+
# You are a very strong reasoner and planner. Use these critical instructions to structure your plans, thoughts, and responses.
22

3-
Welcome, AI Agent! Your persistence, curiosity, and craftsmanship make a difference. Take your time, work methodically, validate thoroughly, and iterate. This repository is large and tests can take time — that’s expected and supported.
3+
Before taking any action (either tool calls *or* responses to the user), you must proactively, methodically, and independently plan and reason about:
44

5-
You need to read the entire AGENTS.md file and follow all instructions exactly. Keep this fresh in your context as you work.
5+
1) Logical dependencies and constraints: Analyze the intended action against the following factors. Resolve conflicts in order of importance:
6+
7+
1.1) Policy-based rules, mandatory prerequisites, and constraints.
8+
9+
1.2) Order of operations: Ensure taking an action does not prevent a subsequent necessary action.
10+
11+
1.2.1) The user may request actions in a random order, but you may need to reorder operations to maximize successful completion of the task.
12+
13+
1.3) Other prerequisites (information and/or actions needed).
14+
15+
1.4) Explicit user constraints or preferences.
16+
17+
2) Risk assessment: What are the consequences of taking the action? Will the new state cause any future issues?
18+
19+
2.1) For exploratory tasks (like searches), missing *optional* parameters is a LOW risk.
20+
**Prefer calling the tool with the available information over asking the user, unless** your `Rule 1` (Logical Dependencies) reasoning determines that optional information is required for a later step in your plan.
21+
22+
3) Abductive reasoning and hypothesis exploration: At each step, identify the most logical and likely reason for any problem encountered.
23+
24+
3.1) Look beyond immediate or obvious causes. The most likely reason may not be the simplest and may require deeper inference.
25+
26+
3.2) Hypotheses may require additional research. Each hypothesis may take multiple steps to test.
27+
28+
3.3) Prioritize hypotheses based on likelihood, but do not discard less likely ones prematurely. A low-probability event may still be the root cause.
29+
30+
4) Outcome evaluation and adaptability: Does the previous observation require any changes to your plan?
31+
32+
4.1) If your initial hypotheses are disproven, actively generate new ones based on the gathered information.
33+
34+
5) Information availability: Incorporate all applicable and alternative sources of information, including:
35+
36+
5.1) Using available tools and their capabilities
37+
5.2) All policies, rules, checklists, and constraints
38+
5.3) Previous observations and conversation history
39+
5.4) Information only available by asking the user
40+
41+
6) Precision and Grounding: Ensure your reasoning is extremely precise and relevant to each exact ongoing situation.
42+
43+
6.1) Verify your claims by quoting the exact applicable information (including policies) when referring to them.
44+
45+
7) Completeness: Ensure that all requirements, constraints, options, and preferences are exhaustively incorporated into your plan.
46+
47+
7.1) Resolve conflicts using the order of importance in #1.
48+
49+
7.2) Avoid premature conclusions: There may be multiple relevant options for a given situation.
50+
51+
7.2.1) To check for whether an option is relevant, reason about all information sources from #5.
52+
53+
7.2.2) You may need to consult the user to even know whether something is applicable. Do not assume it is not applicable without checking.
54+
55+
7.3) Review applicable sources of information from #5 to confirm which are relevant to the current state.
56+
57+
8) Persistence and patience: Do not give up unless all the reasoning above is exhausted.
58+
59+
8.1) Don't be dissuaded by time taken or user frustration.
60+
61+
8.2) This persistence must be intelligent: On *transient* errors (e.g. please try again), you *must* retry **unless an explicit retry limit (e.g., max x tries) has been reached**. If such a limit is hit, you *must* stop. On *other* errors, you must change your strategy or arguments, not repeat the same failed call.
62+
63+
9) Inhibit your response: only take an action after all the above reasoning is completed. Once you've taken an action, you cannot take it back.
664

765
---
866

9-
## Read‑Me‑Now: Proportional Test‑First Rule (Default)
67+
## Read‑Me‑Now: Proportional Test‑First Rule
1068

1169
**Default:** Use **test‑first (TDD)** for any change that alters externally observable behavior.
1270

@@ -31,21 +89,17 @@ It is illegal to `-q` when running tests!
3189

3290
## Four Routines: Choose Your Path
3391

34-
**Routine A — Full TDD (Default)**
92+
**Routine A — Full TDD**
3593
**Routine B — Change without new tests (Proportional, gated)**
3694
**Routine C — Spike/Investigate (No production changes)**
3795
**Routine D — ExecPlans: Complex features or significant refactors**
3896

3997
### Decision quickstart
4098

41-
1. **Is ExecPlans required (complex feature, significant refactor or requested by the user)?**
99+
1. **Is ExecPlans required (complex feature, significant refactor, etc. or explicitly requested by the user)?**
42100
**Yes:** **Routine D (ExecPlans)**. Use an ExecPlan (as described in .agent/PLANS.md) from design to implementation.
43101
**No:** continue.
44102

45-
2**Is new externally observable behavior required?**
46-
**Yes:** **Routine A (Full TDD)**. Add the smallest failing test first.
47-
**No:** continue.
48-
49103
3**Does a failing test already exist in this repo that pinpoints the issue?**
50104
**Yes:** **Routine B (Bugfix using existing failing test).**
51105
**No:** continue.
@@ -54,18 +108,24 @@ It is illegal to `-q` when running tests!
54108
**Yes:** **Routine B (Refactor/micro‑perf/documentation/build).**
55109
**No or unsure:** continue.
56110

57-
5**Is this purely an investigation/design spike with no production code changes?**
58-
**Yes:** **Routine C (Spike/Investigate).**
59-
**No or unsure:** **Routine A.**
111+
4. **Is new externally observable behavior required?**
112+
**Yes:** **Routine A (Full TDD)**. Add the smallest failing test first.
113+
**No:** continue.
60114

61-
**When in doubt, choose Routine A (Full TDD).** Ambiguity is risk; tests are insurance.
115+
5. **Is this purely an investigation/design spike with no production code changes?**
116+
**Yes:** **Routine C (Spike/Investigate).**
117+
**No or unsure:** **Routine A.**
62118

63119
---
64120

65121
## ExecPlans
66122

67123
When writing complex features or significant refactors, use an ExecPlan (as described in PLANS.md) from design to implementation.
68124

125+
## ExecPlans
126+
127+
When writing complex features or significant refactors, use an ExecPlan (as described in PLANS.md) from design to implementation.
128+
69129
## PIOSEE Decision Model (Adopted)
70130

71131
Use this as a compact, repeatable loop for anything from a one‑line bug fix to a multi‑quarter program.
@@ -257,12 +317,12 @@ Plan
257317
`-am` is helpful for **compiles**, hazardous for **tests**.
258318
259319
* ✅ Use `-am` **only** for compile/verify with tests skipped (e.g. `-Pquick`):
260-
* `mvn -o -Dmaven.repo.local=.m2_repo -pl <module> -am -Pquick install`
320+
* `mvn -o -Dmaven.repo.local=.m2_repo -pl <module> -am -Pquick clean install`
261321
* ❌ Do **not** use `-am` with `verify` when tests are enabled.
262322
263323
**Two-step pattern (fast + safe)**
264324
1. **Compile deps fast (skip tests):**
265-
`mvn -o -Dmaven.repo.local=.m2_repo -pl <module> -am -Pquick install`
325+
`mvn -o -Dmaven.repo.local=.m2_repo -pl <module> -am -Pquick clean install`
266326
2. **Run tests:**
267327
`mvn -o -Dmaven.repo.local=.m2_repo -pl <module> verify | tail -500`
268328
@@ -276,9 +336,10 @@ It is illegal to `-q` when running tests!
276336
The Maven reactor resolves inter-module dependencies from the configured local Maven repository (here: `.m2_repo`).
277337
Running `install` publishes your changed modules there so downstream modules and tests pick up the correct versions.
278338
279-
* Always run `mvn -o -Dmaven.repo.local=.m2_repo -Pquick clean install | tail -200` before you start working. This command typically takes up to 30 seconds. Never use a shorter timeout than 30,000 ms.
280-
* Always run `mvn -o -Dmaven.repo.local=.m2_repo -Pquick clean install | tail -200` before any `verify` or test runs.
281-
* If offline resolution fails due to a missing dependency or plugin, rerun the exact `install` command once without `-o`, then return offline.
339+
* Always run `mvn -T 1C -o -Dmaven.repo.local=.m2_repo -Pquick clean install | tail -200` before you start working. This command typically takes up to 30 seconds. Never use a shorter timeout than 60,000 ms.
340+
* Always run `mvn -T 1C -o -Dmaven.repo.local=.m2_repo -Pquick clean install | tail -200` before any `verify` or test runs.
341+
* If offline resolution fails due to a missing dependency or plugin, run the command without `-o`: `mvn -Dmaven.repo.local=.m2_repo -Pquick clean install | tail -200`, then return offline.
342+
* If it fails for any other reason, run the command without `-T 1C`: `mvn -o -Dmaven.repo.local=.m2_repo -Pquick clean install | tail -200`.
282343
* Skipping this step can lead to stale or missing artifacts during tests, producing confusing compilation or linkage errors.
283344
* Always use a workspace-local Maven repository: append `-Dmaven.repo.local=.m2_repo` to all Maven commands (install, verify, formatter, etc.).
284345
* Always try to run these commands first to see if they run without needing any approvals from the user w.r.t. the sandboxing.
@@ -287,8 +348,8 @@ Why this is mandatory
287348
288349
- Tests must not use `-am`. Without `-am`, Maven will not build upstream modules when you run tests; it will resolve cross‑module dependencies from the configured local repository (here: `.m2_repo`).
289350
- Therefore, tests only see whatever versions were last published to the configured local repo (`.m2_repo`). If you change code in one module and then run tests in another, those tests will not see your changes unless the updated module has been installed to `.m2_repo` first.
290-
- The reliable way to ensure all tests always use the latest code across the entire multi‑module build is to install all modules to the configured local repo (`.m2_repo`) before running any tests: run `mvn -o -Dmaven.repo.local=.m2_repo -Pquick install` at the repository root.
291-
- In tight loops you may also install a specific module and its deps (`-pl <module> -am -Pquick install`) to iterate quickly, but before executing tests anywhere that depend on your changes, run a root‑level `mvn -o -Dmaven.repo.local=.m2_repo -Pquick install` so the latest jars are available to the reactor from `.m2_repo`.
351+
- The reliable way to ensure all tests always use the latest code across the entire multi‑module build is to install all modules to the configured local repo (`.m2_repo`) before running any tests: run `mvn -T 1C -o -Dmaven.repo.local=.m2_repo -Pquick clean install` at the repository root.
352+
- In tight loops you may also install a specific module and its deps (`-pl <module> -am -Pquick clean install`) to iterate quickly, but before executing tests anywhere that depend on your changes, run a root‑level `mvn -T 1C -o -Dmaven.repo.local=.m2_repo -Pquick clean install` so the latest jars are available to the reactor from `.m2_repo`.
292353
---
293354
294355
## Quick Start (First 10 Minutes)
@@ -297,7 +358,7 @@ Why this is mandatory
297358
* Inspect root `pom.xml` and module tree (see “Maven Module Overview”).
298359
* Search fast with ripgrep: `rg -n "<symbol or string>"`
299360
2. **Build sanity (fast, skip tests)**
300-
* `mvn -o -Dmaven.repo.local=.m2_repo -Pquick install | tail -200`
361+
* `mvn -T 1C -o -Dmaven.repo.local=.m2_repo -Pquick clean install | tail -200`
301362
3. **Format (Java, imports, XML)**
302363
* `mvn -o -Dmaven.repo.local=.m2_repo -q -T 2C formatter:format impsort:sort xml-format:xml-format`
303364
* Ensure every touched Java file has the correct agent signature comment (`// Some portions generated by Codex` for Codex, `// Some portions generated by Co-Pilot` for GitHub Co-Pilot) inserted immediately below the header before formatting.
@@ -315,7 +376,7 @@ It is illegal to `-q` when running tests!
315376
316377
---
317378
318-
## Routine A — Full TDD (Default)
379+
## Routine A — Full TDD
319380
320381
> Use for **all behavior‑changing work** and whenever Routine B gates do not all pass.
321382
@@ -409,7 +470,7 @@ When writing complex features or significant refactors, use an ExecPlan (as desc
409470
* **Plan:** small, verifiable steps; keep one `in_progress`, or follow PLANS.md (ExecPlans)
410471
* **Change:** minimal, surgical edits; keep style/structure consistent.
411472
* **Format:** `mvn -o -Dmaven.repo.local=.m2_repo -q -T 2C formatter:format impsort:sort xml-format:xml-format`
412-
* **Compile (fast):** `mvn -o -Dmaven.repo.local=.m2_repo -pl <module> -am -Pquick install | tail -500`
473+
* **Compile (fast):** `mvn -o -Dmaven.repo.local=.m2_repo -pl <module> -am -Pquick clean install | tail -500`
413474
* **Test:** start smallest (class/method → module). For integration, run module `verify`.
414475
* **Triage:** read reports; fix root cause; expand scope only when needed.
415476
* **Iterate:** keep momentum; escalate only when blocked or irreversible.
@@ -520,7 +581,7 @@ Immediately after creating any new Java source file, add the signature comment (
520581
## Pre‑Commit Checklist
521582
522583
* **Format:** `mvn -o -Dmaven.repo.local=.m2_repo -q -T 2C formatter:format impsort:sort xml-format:xml-format`
523-
* **Compile (fast path):** `mvn -o -Dmaven.repo.local=.m2_repo -Pquick install | tail -200`
584+
* **Compile (fast path):** `mvn -T 1C -o -Dmaven.repo.local=.m2_repo -Pquick clean install | tail -200`
524585
* **Tests (targeted):** `mvn -o -Dmaven.repo.local=.m2_repo -pl <module> verify | tail -500` (broaden as needed)
525586
* **Reports:** zero new failures in Surefire/Failsafe, or explain precisely.
526587
* **Evidence:** Routine A — failing pre‑fix + passing post‑fix.
@@ -635,7 +696,7 @@ Immediately after creating any new Java source file, add the signature comment (
635696
## Build
636697
637698
* **Build without tests (fast path):**
638-
`mvn -o -Dmaven.repo.local=.m2_repo -Pquick install`
699+
`mvn -T 1C -o -Dmaven.repo.local=.m2_repo -Pquick clean install`
639700
* **Verify with tests:**
640701
Targeted module(s): `mvn -o -Dmaven.repo.local=.m2_repo -pl <module> verify`
641702
Entire repo: `mvn -o -Dmaven.repo.local=.m2_repo verify` (use judiciously)
@@ -757,7 +818,6 @@ rdf4j: root project
757818
│ ├── lmdb: Sail implementation that stores data to disk using LMDB.
758819
│ ├── lucene-api: StackableSail API offering full-text search on literals, based on Apache Lucene.
759820
│ ├── lucene: StackableSail implementation offering full-text search on literals, based on Apache Lucene.
760-
│ ├── solr: StackableSail implementation offering full-text search on literals, based on Solr.
761821
│ ├── elasticsearch: StackableSail implementation offering full-text search on literals, based on Elastic Search.
762822
│ ├── elasticsearch-store: Store for utilizing Elasticsearch as a triplestore.
763823
│ └── extensible-store: Store that can be extended with a simple user-made backend.
@@ -797,7 +857,6 @@ rdf4j: root project
797857
├── model: RDF4J: Model compliance tests
798858
├── sparql: Tests for the SPARQL query language implementation
799859
├── lucene: Compliance Tests for LuceneSail.
800-
├── solr: Tests for Solr Sail.
801860
├── elasticsearch: Tests for Elasticsearch.
802861
└── geosparql: Tests for the GeoSPARQL query language implementation
803862
├── examples: Examples and HowTos for use of RDF4J in Java
@@ -809,6 +868,7 @@ rdf4j: root project
809868
810869
* Don’t commit or push unless explicitly asked.
811870
* Don’t add new dependencies without explicit approval.
871+
* Never revert unrelated working tree changes
812872
813873
### Version Control Conventions
814874

core/sail/shacl/src/main/java/org/eclipse/rdf4j/sail/shacl/ShaclSailValidationReportHelper.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import org.eclipse.rdf4j.rio.Rio;
2323
import org.eclipse.rdf4j.rio.WriterConfig;
2424
import org.eclipse.rdf4j.rio.helpers.BasicWriterSettings;
25+
import org.eclipse.rdf4j.sail.shacl.results.ValidationReport;
2526

2627
/**
2728
* @author Florian Kleedorfer
@@ -54,6 +55,16 @@ public static Optional<String> getValidationReportAsString(Throwable t) {
5455
return Optional.of(reportAsString);
5556
}
5657

58+
public static Optional<String> getValidationReportAsString(ValidationReport t) {
59+
ByteArrayOutputStream baos = new ByteArrayOutputStream();
60+
printValidationReport(t, baos);
61+
String reportAsString = baos.toString();
62+
if (reportAsString == null || reportAsString.isBlank()) {
63+
return Optional.empty();
64+
}
65+
return Optional.of(reportAsString);
66+
}
67+
5768
/**
5869
* Finds a validation report using {@link #getValidationReport(Throwable)} and pretty-prints it to the specified
5970
* output stream.
@@ -68,6 +79,12 @@ public static void printValidationReport(Throwable t, OutputStream out) {
6879
}
6980
}
7081

82+
public static void printValidationReport(ValidationReport t, OutputStream out) {
83+
Model model = t.asModel();
84+
Rio.write(model, out, RDFFormat.TURTLE, WRITER_CONFIG);
85+
86+
}
87+
7188
/**
7289
* Looks for a {@link ValidationException} starting with the specified throwable and working back through the cause
7390
* references, and returns the validation report as a {@link Model} if one is found.

core/sail/shacl/src/main/java/org/eclipse/rdf4j/sail/shacl/ast/Shape.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -513,6 +513,13 @@ public final List<Literal> getMessage() {
513513
return message;
514514
}
515515

516+
/**
517+
* @return any explicit sh:message values defined on this shape, without falling back to constraint defaults.
518+
*/
519+
public final List<Literal> getExplicitMessages() {
520+
return message;
521+
}
522+
516523
@Override
517524
public List<Literal> getDefaultMessage() {
518525
return constraintComponents

core/sail/shacl/src/main/java/org/eclipse/rdf4j/sail/shacl/ast/constraintcomponents/SparqlConstraintComponent.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ public class SparqlConstraintComponent extends AbstractConstraintComponent imple
5454
private Boolean deactivated;
5555
private final Set<Namespace> namespaces;
5656
private final Model prefixes;
57+
private final boolean hasMessageTemplateVariables;
5758

5859
public SparqlConstraintComponent(Resource id, ShapeSource shapeSource, Shape shape) {
5960
super(id);
@@ -96,6 +97,8 @@ public SparqlConstraintComponent(Resource id, ShapeSource shapeSource, Shape sha
9697
});
9798
}
9899

100+
hasMessageTemplateVariables = containsMessageTemplateVariables(message);
101+
99102
var shaclNamespaces = ShaclPrefixParser.extractNamespaces(id, shapeSource);
100103
prefixes = shaclNamespaces.getModel();
101104
namespaces = shaclNamespaces.getNamespaces();
@@ -115,6 +118,21 @@ public SparqlConstraintComponent(Resource id, Shape shape, boolean produceValida
115118
this.deactivated = deactivated;
116119
this.prefixes = prefixes;
117120
this.namespaces = namespaces;
121+
this.hasMessageTemplateVariables = containsMessageTemplateVariables(message);
122+
}
123+
124+
public boolean hasMessageTemplateVariables() {
125+
return hasMessageTemplateVariables;
126+
}
127+
128+
private static boolean containsMessageTemplateVariables(List<Literal> messages) {
129+
for (Literal literal : messages) {
130+
String label = literal.getLabel();
131+
if (label.contains("{?") || label.contains("{$")) {
132+
return true;
133+
}
134+
}
135+
return false;
118136
}
119137

120138
@Override
@@ -155,6 +173,10 @@ public PlanNode generateTransactionalValidationPlan(ConnectionsGroup connections
155173
Path path = getTargetChain().getPath().get();
156174
String s = path.toSparqlPathString();
157175
select = select.replace(" $PATH ", " " + s + " ");
176+
if (select.contains("$PATH")) {
177+
throw new IllegalStateException(
178+
"Illegal use of $PATH in SPARQL constraint for property shape " + getId());
179+
}
158180
}
159181

160182
PlanNode allTargets;

0 commit comments

Comments
 (0)