implements PLN-0127
Intrepid/Prometeu/Studio/pipeline/pr-master Build started...
JaCoCo Coverage #### Project Overview
No changes detected, that affect the code coverage.
* Line Coverage: 61.95% (17766/28676)
* Branch Coverage: 52.69% (6860/13019)
* Lines of Code: 28676
* Cyclomatic Complexity: 11490
#### Quality Gates Summary
Output truncated.
Test / Build skipped: 15, passed: 648
Intrepid/Prometeu/Studio/pipeline/pr-master Build started...
JaCoCo Coverage #### Project Overview
No changes detected, that affect the code coverage.
* Line Coverage: 61.95% (17766/28676)
* Branch Coverage: 52.69% (6860/13019)
* Lines of Code: 28676
* Cyclomatic Complexity: 11490
#### Quality Gates Summary
Output truncated.
Test / Build skipped: 15, passed: 648
Publish the console ABI authority map: runtime catalogs win, PBS stdlib is delivery. Recut specs 18, 8, and 6.2 and lock them with ConsoleAbiAuthoritySpecTest. Housekeep DSC-0061 with LSN-0064.
This commit is contained in:
+109
@@ -0,0 +1,109 @@
|
||||
package p.studio.compiler.specs;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
|
||||
class ConsoleAbiAuthoritySpecTest {
|
||||
private static final String SPEC_18 =
|
||||
"docs/specs/compiler/18. Standard Library Surface Specification.md";
|
||||
private static final String PBS_SPEC_8 =
|
||||
"docs/specs/compiler-languages/pbs/8. Stdlib Environment Packaging and Loading Specification.md";
|
||||
private static final String PBS_SPEC_6_2 =
|
||||
"docs/specs/compiler-languages/pbs/6.2. Host ABI Binding and Loader Resolution Specification.md";
|
||||
|
||||
@Test
|
||||
void spec18MustTreatStdlibAsDeliveryAndMustNotOwnConsoleAbi() throws IOException {
|
||||
final var content = Files.readString(locateRepoRoot().resolve(SPEC_18));
|
||||
|
||||
assertTrue(
|
||||
content.contains("This document is PBS delivery. It does not own console ABI."),
|
||||
"spec 18 must state that PBS stdlib is delivery, not console ABI");
|
||||
assertTrue(
|
||||
content.contains("This document MUST NOT define numeric syscall identifiers, intrinsic `final_id`"),
|
||||
"spec 18 must forbid defining syscall IDs and intrinsic final IDs");
|
||||
assertTrue(
|
||||
content.contains("or `SyscallMeta`"),
|
||||
"spec 18 must forbid publishing SyscallMeta");
|
||||
assertTrue(
|
||||
content.contains("## 15. Console ABI Non-Ownership"),
|
||||
"spec 18 must contain Console ABI Non-Ownership");
|
||||
assertTrue(
|
||||
content.contains("Reserved project-space path (`@sdk:*` / `@core:*`) MUST NOT imply VM-owned versus host-backed ownership."),
|
||||
"spec 18 must state that @sdk/@core paths do not imply ownership");
|
||||
assertTrue(
|
||||
content.contains("Current stdlib line `1` ships a VM-owned builtin input shell at `@sdk:input`."),
|
||||
"spec 18 must record @sdk:input as the current builtin exception");
|
||||
}
|
||||
|
||||
@Test
|
||||
void spec8MustDocumentCurrentGameStdlibLayout() throws IOException {
|
||||
final var content = Files.readString(locateRepoRoot().resolve(PBS_SPEC_8));
|
||||
final var layoutFence = extractFirstTextFence(content);
|
||||
|
||||
assertTrue(content.contains("game/stdlib/1"), "spec 8 must document game/stdlib/1");
|
||||
assertTrue(content.contains("game/stdlib/1/core/color"), "spec 8 must map @core:color");
|
||||
assertTrue(content.contains("game/stdlib/1/sdk/input"), "spec 8 must map @sdk:input");
|
||||
assertTrue(content.contains("game/stdlib/1/sdk/log"), "spec 8 must map @sdk:log");
|
||||
assertTrue(
|
||||
content.contains("Physical stdlib\npath MUST NOT imply VM-owned versus host-backed ownership."),
|
||||
"spec 8 must state that packaging path does not imply ownership");
|
||||
assertTrue(layoutFence.contains("core/\n color/"), "layout fence must include core/color");
|
||||
assertTrue(layoutFence.contains("input/"), "layout fence must include sdk/input");
|
||||
assertTrue(layoutFence.contains("log/"), "layout fence must include sdk/log");
|
||||
assertFalse(layoutFence.contains("audio/"), "layout fence must not ship audio as a current module");
|
||||
assertFalse(layoutFence.contains("math/"), "layout fence must not ship core/math as a current module");
|
||||
}
|
||||
|
||||
@Test
|
||||
void spec62MustRequirePbsHostShellsToRepeatRuntimeRegistry() throws IOException {
|
||||
final var content = Files.readString(locateRepoRoot().resolve(PBS_SPEC_6_2));
|
||||
|
||||
assertTrue(
|
||||
content.contains("PBS shells MUST repeat identities already published by the runtime registry"),
|
||||
"spec 6.2 must require PBS shells to repeat the runtime registry");
|
||||
assertTrue(
|
||||
content.contains("They MUST NOT invent `(module, name, version)`."),
|
||||
"spec 6.2 must forbid inventing canonical host identity");
|
||||
assertTrue(
|
||||
content.contains("This document MUST NOT publish syscall\nIDs or `SyscallMeta`."),
|
||||
"spec 6.2 must not publish the syscall catalog");
|
||||
assertTrue(
|
||||
content.contains("(\"gfx2d\", \"clear\", 1)"),
|
||||
"spec 6.2 authority example must use a current runtime identity");
|
||||
}
|
||||
|
||||
private static String extractFirstTextFence(final String content) {
|
||||
final var startToken = "```text";
|
||||
final var start = content.indexOf(startToken);
|
||||
if (start < 0) {
|
||||
fail("spec 8 must contain a text layout fence");
|
||||
}
|
||||
final var fenceStart = start + startToken.length();
|
||||
final var end = content.indexOf("```", fenceStart);
|
||||
if (end < 0) {
|
||||
fail("spec 8 layout fence is unclosed");
|
||||
}
|
||||
return content.substring(fenceStart, end);
|
||||
}
|
||||
|
||||
private static Path locateRepoRoot() {
|
||||
var cursor = Path.of(System.getProperty("user.dir")).toAbsolutePath().normalize();
|
||||
while (cursor != null) {
|
||||
final var hasDocs = Files.isDirectory(cursor.resolve("docs/specs/compiler"));
|
||||
final var hasCompiler = Files.isDirectory(cursor.resolve("prometeu-compiler"));
|
||||
if (hasDocs && hasCompiler) {
|
||||
return cursor;
|
||||
}
|
||||
cursor = cursor.getParent();
|
||||
}
|
||||
fail("could not locate repository root from working directory");
|
||||
throw new IllegalStateException("unreachable");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user