Skip to content

Commit 2422b1d

Browse files
committed
wip
1 parent 2c1b752 commit 2422b1d

3 files changed

Lines changed: 461 additions & 69 deletions

File tree

json-java21-schema/AGENTS.md

Lines changed: 42 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,85 +1,68 @@
11
# JSON Schema Validator - AGENTS Development Guide
22

3-
Note: Prefer mvnd (Maven Daemon) for faster builds. If installed, you can alias mvn to mvnd so top-level instructions work consistently:
43

5-
```bash
6-
if command -v mvnd >/dev/null 2>&1; then alias mvn=mvnd; fi
7-
```
4+
### Running Tests
85

9-
## Quick Start Commands
6+
You MUST NOT ever filter test output as you are looking for something you do not know what it is that is the nature of debugging.
107

11-
### Building and Testing
12-
```bash
13-
# Compile only
14-
mvnd compile -pl json-java21-schema
8+
You MUST restrict the amount of tokens by adding logging at INFO, FINE, FINER and FINEST and you SHOULD run at a specific model/test/method level that best zooms in on the issue.
159

16-
# Run all tests
17-
mvnd test -pl json-java21-schema
10+
You MUST NOT add any 'temporary logging' all logging MUST be as above
1811

19-
# Run specific test
20-
mvnd test -pl json-java21-schema -Dtest=JsonSchemaTest#testStringTypeValidation
12+
You SHOULD NOT delete logging as that makes no sense only change the level be finer to turn it down.
2113

22-
# Run tests with debug logging
23-
mvnd test -pl json-java21-schema -Dtest=JsonSchemaTest -Djava.util.logging.ConsoleHandler.level=FINE
14+
You MUST add a jul log statement at INFO level at the top of each and every test method announcing that it is running.
2415

25-
# Run integration tests (JSON Schema Test Suite)
26-
mvnd verify -pl json-java21-schema
27-
```
16+
You MUST have all new tests extend a class such as ` extends JsonSchemaLoggingConfig` so that the correct env vars set log levels in a way that is compatible with ./mvn-test-no-boilerplate.sh as outlined below.
2817

29-
### Logging Configuration
30-
The project uses `java.util.logging` with levels:
31-
- `FINE` - Schema compilation and validation flow
32-
- `FINER` - Conditional validation branches
33-
- `FINEST` - Stack frame operations
18+
You MUST NOT GUESS you SHOULD add more logging or more test methods you are a text based mind you can see all bugs with appropriate logging.
19+
20+
You MUST prefer the rich and varied use of ./mvn-test-no-boilerplate.sh as per:
3421

35-
#### Two-Level Logging Strategy
36-
Use **FINE** for general flow visibility and **FINER** for detailed debugging:
3722
```bash
38-
# General flow - good for understanding compilation/validation patterns
39-
mvnd test -pl json-java21-schema -Dtest=JsonSchemaTest#testMethod -Djava.util.logging.ConsoleHandler.level=FINE
23+
# Run tests with clean output (only recommended post all bugs fixed expected to be fixed)
24+
./mvn-test-no-boilerplate.sh
4025

41-
# Detailed debugging - use when tracing specific execution paths
42-
mvnd test -pl json-java21-schema -Dtest=JsonSchemaTest#testMethod -Djava.util.logging.ConsoleHandler.level=FINER
43-
```
26+
# Run specific test class
27+
./mvn-test-no-boilerplate.sh -Dtest=BlahTest -Djava.util.logging.ConsoleHandler.level=FINE
4428

45-
#### Systematic Debugging Approach
46-
When code isn't being reached, use systematic logging rather than guessing:
47-
1. Add FINE or logging at entry points
48-
2. Add FINER logging at key decision points in the call stack
49-
3. Use binary search approach - add logging halfway between working and non-working code
50-
4. Text-based minds excel at processing log output systematically
29+
# Run specific test method
30+
./mvn-test-no-boilerplate.sh -Dtest=BlahTest#testSomething -Djava.util.logging.ConsoleHandler.level=FINEST
5131

52-
You also need to ensure that the test class extends `JsonSchemaLoggingConfig` to honour the system property:
53-
```java
54-
/// Test local reference resolution for JSON Schema 2020-12
55-
class JsonSchemaRefLocalTest extends JsonSchemaLoggingConfig {
56-
...
57-
}
32+
# Run tests in specific module
33+
./mvn-test-no-boilerplate.sh -pl json-java21-api-tracker -Dtest=ApiTrackerTest -Djava.util.logging.ConsoleHandler.level=FINE
5834
```
5935

60-
IMPORTANT:
36+
You MUST NEVER pipe any output to anything that limits visiablity. We only use logging to find what we didn't know. It is an oxymoron to pipe logging to head or tail or grep.
6137

62-
- Always adjust the logging levels to be balanced before committing code.
63-
- NEVER comment out code.
64-
- NEVER use System.out.println or e.printStackTrace().
65-
- ALWAYS use lamba based JUL logging.
66-
- NEVER filter logging output with head, tail, grep, etc. You shoould set the logging to the correct level of INFO, FINE, FINER, FINEST and run just the one test or method with the correct logging level to control token output.
67-
- ALWAYS add a INFO level logging line at the top of each `@Test` method so that we can log at INFO level and see which tests might hang forever.
68-
- You SHOULD run tests as `timeout 30 mvnd test ...` to ensure that no test can hang forever and the timeout should not be too long.
38+
You MAY opt to log the actual data structures as the come on and off the stack or are reified at `FINEST` as that is trace level for detailed debuging. You should only run one test method at a time at that level. If it is creating vast amounts of output due to infinite loops then this is the ONLY time you may use head or tail yet you MUST head A LARGE ENOUGH SIMPLE OF DATA to see the actual problem it is NOT ACCEPTABLE to create a million line trace file then look at 100 top lines when all of that is mvn start up. The fraction of any log you look at MUST be as large as should be the actual trace log of a good test and you should do 2x that such as thousands of lines.
6939

70-
### JSON Schema Test Suite Metrics
40+
IMPORTANT: if you cannot see the `mvn-test-no-boilerplate.sh` then obviously as it takes mvn/mvnd module parameters like `-pl` it is at the root of the mvn project. You are forbidden from running any maven command directly as it forces me to authorize each one and they do not filter noise. You MUST use the script.
7141

72-
The integration test now provides defensible compatibility metrics:
42+
IMPORTANT: we use jul logging for safety and performance yet it is widely ignored by companies and when it is used it is often bridged to something like slf4j. this runs the risk that teams filter on the key log line string `ERROR` not `SEVERE` so for extra protection when you log as level severe prefix the world ERROR as per:
7343

74-
```bash
75-
# Run with console metrics (default)
76-
mvnd verify -pl json-java21-schema
44+
```java
45+
LOG.severe(() -> "ERROR: Remote references disabled but computeIfAbsent called for: " + key);
46+
```
47+
48+
Only do this for errors like logging before throwing an exception or clear validation issue or the like where normally we would expect someone using log4j or slf4j to be logging at level `error` such that by default `ERROR` would be seen. This is because they may have cloud log filter setup to monitor for ERROR.
7749

78-
# Export detailed JSON metrics
79-
mvnd verify -pl json-java21-schema -Djson.schema.metrics=json
50+
The official Oracle JDK documentation defines a clear hierarchy with specific target audiences:
51+
* SEVERE (1000): "Serious failure preventing normal program execution" - must be "reasonably intelligible to end users and system administrators"
52+
* WARNING (900): "Potential problems of interest to end users or system managers"
53+
* INFO (800): "Reasonably significant messages for end users and system administrators" - "should only be used for reasonably significant messages"
54+
* CONFIG (700): "Static configuration information" to assist debugging configuration-related problems
55+
* FINE (500): "Information broadly interesting to developers who do not have specialized interest in the specific subsystem" - includes "minor recoverable failures" and "potential performance problems"
56+
* FINER (400): "Fairly detailed tracing" - official default for method entry/exit and exception throwing
57+
* FINEST (300): "Highly detailed tracing" for deep debugging
58+
59+
When logging possible performance issues use a common and consistent refix:
60+
61+
```java
62+
// official java guidelines say fine 500 level is appropriate for "potential performance problems"
63+
LOG.fine(() -> "PERFORMANCE WARNING: Validation stack processing " + count + ... );
64+
```
8065

81-
# Export CSV metrics for analysis
82-
mvnd verify -pl json-java21-schema -Djson.schema.metrics=csv
8366
```
8467
### Development Workflow
8568

0 commit comments

Comments
 (0)