-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Antigravity take on the Gestalt DI PR - fixes multiplayer! #5304
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: temp/gestalt-di-migration
Are you sure you want to change the base?
Changes from all commits
4965f20
d3a4e65
4157525
2d5ffc1
6d2516c
63dbd4a
d182fe5
ab01549
ccc9a60
c2cb68c
91efa3f
b667fa3
a7de5e8
c998e33
31e1319
47d61b2
2bbfffb
38b85d8
50d500c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| # Agent Workflow & Lessons Learned | ||
|
|
||
| This document serves as a living guide for AI agents working on the Terasology project. It captures workflow best practices, platform-specific quirks, and useful commands to ensure efficient collaboration. | ||
|
|
||
| ## Platform: Windows & PowerShell | ||
|
|
||
| General coding on Linux and Mac are well-understood by AI, while Java on Windows with PowerShell is less so, meaning we need extra tips and options here. | ||
|
|
||
| - **Path Separators**: Use forward slashes `/` for Gradle tasks and Java paths where possible, but be aware that Windows system paths use backslashes `\`. | ||
| - **Command Syntax**: PowerShell handles quotes and environment variables differently than Bash. | ||
| - *Env Vars*: `$env:VAR="value"; command` | ||
| - *Chaining*: Use `;` instead of `&&` if you want unconditional execution, or `if ($?) { command }` for conditional. | ||
| - **File Search**: To find files recursively: | ||
| ```powershell | ||
| Get-ChildItem -Path . -Filter filename.txt -Recurse | ||
| ``` | ||
| - **Environment Setup**: | ||
| - **JAVA_HOME**: PowerShell terminals in the IDE may not inherit system variables correctly. Set it explicitly for the session plus update the PATH: | ||
| ```powershell | ||
| $env:JAVA_HOME = "D:\Dev\Java\TemurinJDK17" | ||
| $env:Path = "$env:JAVA_HOME\bin;$env:Path" | ||
| ``` | ||
| - **Path**: You can verify java is accessible with `& "$env:JAVA_HOME\bin\java" -version`. | ||
| ## Search and Navigation | ||
| * **Use Search Tools**: When looking for specific method calls, variable usages, or class definitions across the codebase, try to use `grep_search` or `codebase_search` instead of manually traversing files one by one. This is faster and more exhaustive. | ||
| * **Scoped Search**: Narrow down search scope using `TargetDirectories` or `SearchPath` to reduce noise. | ||
| ## Gradle & Build System | ||
| - **Verbosity**: Gradle output can be overwhelming. | ||
| - Avoid `--info` or `--debug` unless necessary. | ||
| - If output is truncated, check XML reports: `build/test-results/test/TEST-*.xml`. | ||
| - **Running Tests**: | ||
| - Use specific filters: `./gradlew :project:test --tests "package.ClassName"` | ||
| - Example: `./gradlew :engine-tests:test --tests "org.terasology.engine.BuildValidationTest"` | ||
| - **Task Execution**: | ||
| - **Force Run**: To force a test to run without rebuilding the whole project, use `cleanTest` before the test task: | ||
| ` ./gradlew :engine-tests:cleanTest :engine-tests:test --tests "org.terasology.metatesting.MTETwoClientChatTest"` | ||
| - **Nuclear Option**: `--rerun-tasks` will rerun EVERYTHING. Use sparingly. | ||
| - **Clean Builds**: When in doubt (class not found, weird linkage errors), run `./gradlew clean`. | ||
| ## Context Management | ||
| - **Logs**: Do not dump full log files into the chat context. | ||
| - Use `grep` (or `Select-String` in PS) to find relevant lines. | ||
| - Read specific blocks of XML reports. | ||
| - **File Viewing**: Use `view_file` with line ranges to inspect relevant code sections. | ||
| - **Debugging**: When tests fail or timeout, use `System.out.println` *before* assertions or inside `runUntil` loops to dump relevant state (e.g., object counts, flags, current states). This is often faster than attaching a debugger. | ||
| ## Testing Strategy: "Meta-Test Suite" | ||
| We are building a validation suite from the ground up to verify the test infrastructure itself. | ||
| 1. **Build & Classpath**: Verify resources can be loaded. | ||
| 2. **Module Loading**: Verify `ModuleManager` works. | ||
| 3. **DI & Registry**: Verify injection and `CoreRegistry`. | ||
| 4. **Entity System**: Verify `EntityManager` and Events. | ||
| 5. **MTE/Multiplayer**: Verify full game environment. | ||
| ## Common Issues | ||
| - **Context Pollution**: `CoreRegistry` is a deprecated static singleton meant to be removed. Tests running in the same JVM must be careful about cleaning it up or isolating contexts. | ||
| - **Module Permissions**: The `SecurityManager` (via `ModuleSecurityManager`) can block access to classes. Ensure modules have correct dependencies and permissions. | ||
| - **Service vs System**: Distinguish between `Context`/`CoreRegistry` services (global, available via `@In`) and ECS Systems (event-driven, registered with `ComponentSystemManager`). Some functionality (like Chat) relies on ECS systems processing events, not just the service being present. | ||
| ## Conventions | ||
| * Max line length in code files is 150 characters | ||
| * Do not make linting or whitespace-only changes to files unless explicitly requested | ||
| * If edits repeatedly result in corrupted files (large deleted chunks) start solely rewriting the file from scratch | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bug: Documentation and planning files committed to repositorySeveral files containing AI agent instructions ( Additional Locations (2) |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -43,3 +43,21 @@ tasks.javadoc { | |
| // TODO: Temporary until javadoc has been fixed for Java 8 everywhere | ||
| failOnError = false | ||
| } | ||
|
|
||
| apply plugin: 'jacoco' | ||
|
|
||
| jacoco { | ||
| toolVersion = "0.8.13" | ||
| } | ||
|
|
||
| test { | ||
| finalizedBy jacocoTestReport | ||
| } | ||
|
|
||
| jacocoTestReport { | ||
| dependsOn test | ||
| reports { | ||
| xml.required = true | ||
| html.required = true | ||
| } | ||
| } | ||
|
Comment on lines
+46
to
+63
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Did we need to add this here? If my understanding is correct, this will force
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If memory serves the biggest problem with JaCoCo was flooding Jenkins with heavy build reports, causing it to run out of space repeatedly. I'm cautious about re-including it and doubly so how to configure it, for the moment it is largely a local experiment to better figure out where to focus on tests. I was tempted to leave it local-only for the moment but since this branch will get a major cleanup anyway maybe I can test it in Jenkins a bit more this way :-) |
||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There are PMD and CheckStyle warnings in this file reported by Jenkins that I quite agree with. It would be worth fixing those. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| package org.terasology.metatesting; | ||
|
Check warning on line 1 in engine-tests/src/test/java/org/terasology/metatesting/BuildValidationTest.java
|
||
|
|
||
| import org.junit.jupiter.api.Test; | ||
| import static org.junit.jupiter.api.Assertions.assertNotNull; | ||
|
|
||
| import java.net.URL; | ||
| import java.util.Enumeration; | ||
|
|
||
| public class BuildValidationTest { | ||
|
|
||
| @Test | ||
| public void testClasspathSanity() { | ||
| System.out.println("Running BuildValidationTest: Checking classpath sanity..."); | ||
|
Check warning on line 13 in engine-tests/src/test/java/org/terasology/metatesting/BuildValidationTest.java
|
||
|
|
||
| // 1. Check if we can load a standard Java class | ||
| assertNotNull(String.class, "Should be able to load String class"); | ||
|
|
||
| // 2. Check if we can find the TerasologyEngine class | ||
| URL resource = getClass().getResource("/org/terasology/engine/core/TerasologyEngine.class"); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I do not really like the idea of hard-coding paths to arbitrary class files here, even if it is just for a unit test. It makes the test fail if we ever re-name the class or change its package. Could we construct the class file path by using
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Probably! I did notice this as odd vs easier and more generic things to test, but then that's the messy first pass largely from the one-handed-button-mashing-with-kids approach 👍 |
||
|
|
||
| if (resource == null) { | ||
| System.out.println("FATAL: TerasologyEngine class not found!"); | ||
|
Check warning on line 22 in engine-tests/src/test/java/org/terasology/metatesting/BuildValidationTest.java
|
||
| System.out.println("Current ClassLoader: " + getClass().getClassLoader()); | ||
|
Check warning on line 23 in engine-tests/src/test/java/org/terasology/metatesting/BuildValidationTest.java
|
||
| System.out.println("Java Classpath: " + System.getProperty("java.class.path")); | ||
|
Check warning on line 24 in engine-tests/src/test/java/org/terasology/metatesting/BuildValidationTest.java
|
||
| } else { | ||
| System.out.println("Classpath sanity check passed. Found TerasologyEngine at: " + resource); | ||
|
Check warning on line 26 in engine-tests/src/test/java/org/terasology/metatesting/BuildValidationTest.java
|
||
| } | ||
|
|
||
| assertNotNull(resource, "Should be able to find TerasologyEngine class resource"); | ||
|
|
||
| // 3. Check for module.txt | ||
| // We found it at org/terasology/engine/module.txt in the source | ||
| URL moduleTxt = getClass().getResource("/org/terasology/engine/module.txt"); | ||
|
|
||
| if (moduleTxt == null) { | ||
| System.out.println("WARNING: /org/terasology/engine/module.txt not found. Checking for any module.txt..."); | ||
|
Check warning on line 36 in engine-tests/src/test/java/org/terasology/metatesting/BuildValidationTest.java
|
||
| try { | ||
| Enumeration<URL> resources = getClass().getClassLoader().getResources("module.txt"); | ||
| while (resources.hasMoreElements()) { | ||
| URL url = resources.nextElement(); | ||
| System.out.println("Found a module.txt at: " + url); | ||
|
Check warning on line 41 in engine-tests/src/test/java/org/terasology/metatesting/BuildValidationTest.java
|
||
| if (url.toString().contains("engine")) { | ||
| moduleTxt = url; | ||
| } | ||
| } | ||
| } catch (Exception e) { | ||
| e.printStackTrace(); | ||
|
Check warning on line 47 in engine-tests/src/test/java/org/terasology/metatesting/BuildValidationTest.java
|
||
| } | ||
| } else { | ||
| System.out.println("Found engine module.txt at: " + moduleTxt); | ||
|
Check warning on line 50 in engine-tests/src/test/java/org/terasology/metatesting/BuildValidationTest.java
|
||
| } | ||
|
|
||
| assertNotNull(moduleTxt, "Should be able to find module.txt for the engine module"); | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we avoid placing this file in the root directory of the project somehow? Given the lack of human focus, it makes sense to put it somewhere where humans would not immediately look.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, thinking maybe
/configsince it is essentially config for AI