Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 19 additions & 23 deletions tests/aspect_test.affine
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
// SPDX-License-Identifier: MPL-2.0
// Ported via Harvard Engine mechanical processor
// Ported via Harvard Engine (Semantic pass)

module aspect_test;

// TODO: Complete semantic implementation

/* === ORIGINAL TYPESCRIPT CONTEXT ===
// SPDX-License-Identifier: MPL-2.0
// Copyright (c) 2026 Jonathan D.A. Jewell (hyperpolymath) <j.d.a.jewell@open.ac.uk>
//
Expand All @@ -22,13 +19,13 @@ import {
assertMatch,
} from "jsr:@std/assert@^1";

const REPO_ROOT = new URL("../", import.meta.url).pathname;
let REPO_ROOT = new URL("../", import.meta.url).pathname;

async function readFile(relPath: string): Promise<string | null> {
async fn readFile(relPath: string): string | null {
return Deno.readTextFile(REPO_ROOT + relPath).catch(() => null);
}

async function pathExists(relPath: string): Promise<boolean> {
async fn pathExists(relPath: string): boolean {
return Deno.stat(REPO_ROOT + relPath).then(() => true).catch(() => false);
}

Expand All @@ -41,10 +38,10 @@ Deno.test("aspect/security: SECURITY.md exists", async () => {
});

Deno.test("aspect/security: SECURITY.md mentions vulnerability disclosure", async () => {
const content = await readFile("SECURITY.md");
let content = await readFile("SECURITY.md");
assertNotEquals(content, null);
const lc = content!.toLowerCase();
const hasDisclosure =
let lc = content!.toLowerCase();
let hasDisclosure =
lc.includes("vulnerabilit") ||
lc.includes("disclosure") ||
lc.includes("report") ||
Expand All @@ -58,15 +55,15 @@ Deno.test("aspect/security: .well-known/security.txt exists", async () => {

Deno.test("aspect/security: no .env files in repo", async () => {
// Checks common secret leak patterns
const exists = await pathExists(".env");
let exists = await pathExists(".env");
assertEquals(exists, false, ".env file must not be committed");
});

Deno.test("aspect/security: no plaintext secrets patterns in README", async () => {
const content = await readFile("README.adoc");
let content = await readFile("README.adoc");
assertNotEquals(content, null);
// Check for obvious secret patterns (API_KEY=, PASSWORD=, TOKEN=)
const hasSecretLeak = /(?:api_key|password|secret|token)\s*=/i.test(content!);
let hasSecretLeak = /(?:api_key|password|secret|token)\s*=/i.test(content!);
assertEquals(hasSecretLeak, false, "README.adoc must not contain hardcoded secrets");
});

Expand All @@ -79,7 +76,7 @@ Deno.test("aspect/community: CODE_OF_CONDUCT.md exists", async () => {
});

Deno.test("aspect/community: CODE_OF_CONDUCT.md is non-trivial", async () => {
const content = await readFile("CODE_OF_CONDUCT.md");
let content = await readFile("CODE_OF_CONDUCT.md");
assertNotEquals(content, null);
assertEquals(content!.length > 100, true, "CODE_OF_CONDUCT.md should have meaningful content");
});
Expand All @@ -93,13 +90,13 @@ Deno.test("aspect/formatting: .editorconfig exists", async () => {
});

Deno.test("aspect/formatting: .editorconfig has root = true", async () => {
const content = await readFile(".editorconfig");
let content = await readFile(".editorconfig");
assertNotEquals(content, null);
assertMatch(content!, /root\s*=\s*true/i);
});

Deno.test("aspect/formatting: .editorconfig defines indent_style", async () => {
const content = await readFile(".editorconfig");
let content = await readFile(".editorconfig");
assertNotEquals(content, null);
assertMatch(content!, /indent_style\s*=/);
});
Expand All @@ -108,7 +105,7 @@ Deno.test("aspect/formatting: .editorconfig defines indent_style", async () => {
// Aspect: No banned file patterns
// ---------------------------------------------------------------------------

const BANNED_FILES = [
let BANNED_FILES = [
"package.json", // Node/npm — banned
"package-lock.json",
"yarn.lock",
Expand All @@ -120,7 +117,7 @@ const BANNED_FILES = [

for (const f of BANNED_FILES) {
Deno.test(`aspect/policy: banned file must not exist — ${f}`, async () => {
const exists = await pathExists(f);
let exists = await pathExists(f);
assertEquals(exists, false, `Banned file/directory present: ${f}`);
});
}
Expand All @@ -137,7 +134,7 @@ Deno.test("aspect/language: no tsconfig.json (TS only via Deno, not tsc)", async
// Aspect: Documentation is accessible (all .adoc files are non-empty)
// ---------------------------------------------------------------------------

const DOCS = [
let DOCS = [
"README.adoc",
"EXPLAINME.adoc",
"CONTRIBUTING.md",
Expand All @@ -146,7 +143,7 @@ const DOCS = [

for (const doc of DOCS) {
Deno.test(`aspect/docs: documentation file is non-empty — ${doc}`, async () => {
const content = await readFile(doc);
let content = await readFile(doc);
assertNotEquals(content, null, `Doc missing: ${doc}`);
assertEquals(content!.trim().length > 50, true, `Doc is too short: ${doc}`);
});
Expand All @@ -157,10 +154,10 @@ for (const doc of DOCS) {
// ---------------------------------------------------------------------------

Deno.test("aspect/tests: all non-bench .ts files in tests/ use Deno.test", async () => {
const testsDir = REPO_ROOT + "tests";
let testsDir = REPO_ROOT + "tests";
for await (const entry of Deno.readDir(testsDir)) {
if (entry.isFile && entry.name.endsWith(".ts") && !entry.name.includes("bench")) {
const content = await Deno.readTextFile(`${testsDir}/${entry.name}`);
let content = await Deno.readTextFile(`${testsDir}/${entry.name}`);
assertMatch(
content,
/Deno\.test\s*\(/,
Expand All @@ -170,4 +167,3 @@ Deno.test("aspect/tests: all non-bench .ts files in tests/ use Deno.test", async
}
});

==================================== */
12 changes: 4 additions & 8 deletions tests/bench_test.affine
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
// SPDX-License-Identifier: MPL-2.0
// Ported via Harvard Engine mechanical processor
// Ported via Harvard Engine (Semantic pass)

module bench_test;

// TODO: Complete semantic implementation

/* === ORIGINAL TYPESCRIPT CONTEXT ===
// SPDX-License-Identifier: MPL-2.0
// Copyright (c) 2026 Jonathan D.A. Jewell (hyperpolymath) <j.d.a.jewell@open.ac.uk>
//
Expand All @@ -18,7 +15,7 @@ module bench_test;
//
// Run with: deno bench tests/bench_test.ts

const REPO_ROOT = new URL("../", import.meta.url).pathname;
let REPO_ROOT = new URL("../", import.meta.url).pathname;

// ---------------------------------------------------------------------------
// Bench: file reading throughput
Expand Down Expand Up @@ -53,7 +50,7 @@ Deno.bench({
// Bench: SPDX regex matching
// ---------------------------------------------------------------------------

const sampleContent = `# SPDX-License-Identifier: MPL-2.0
let sampleContent = `# SPDX-License-Identifier: MPL-2.0
# Copyright (c) 2026 Jonathan D.A. Jewell

[metadata]
Expand Down Expand Up @@ -111,7 +108,7 @@ Deno.bench({
// Bench: JSON parse (proxy for metadata parsing workload)
// ---------------------------------------------------------------------------

const jsonSample = JSON.stringify({
let jsonSample = JSON.stringify({
project: "thunderbird-template-reloaded",
version: "0.1.0",
crg_grade: "C",
Expand Down Expand Up @@ -139,4 +136,3 @@ Deno.bench({
},
});

==================================== */
32 changes: 14 additions & 18 deletions tests/contract_test.affine
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
// SPDX-License-Identifier: MPL-2.0
// Ported via Harvard Engine mechanical processor
// Ported via Harvard Engine (Semantic pass)

module contract_test;

// TODO: Complete semantic implementation

/* === ORIGINAL TYPESCRIPT CONTEXT ===
// SPDX-License-Identifier: MPL-2.0
// Copyright (c) 2026 Jonathan D.A. Jewell (hyperpolymath) <j.d.a.jewell@open.ac.uk>
//
// Contract tests for thunderbird-template-reloaded.
//
// Contract tests verify the repo fulfils its stated obligations to consumers
// and integrators: RSR (Rhodium Standard Repository) compliance, Hypatia CI
// contract, and the gitbot-fleet interface contract.
// contract, and the gitbot-fleet struct contract.
// Run with: deno test tests/contract_test.ts

import {
Expand All @@ -23,13 +20,13 @@ import {
assertStringIncludes,
} from "jsr:@std/assert@^1";

const REPO_ROOT = new URL("../", import.meta.url).pathname;
let REPO_ROOT = new URL("../", import.meta.url).pathname;

async function readFile(relPath: string): Promise<string | null> {
async fn readFile(relPath: string): string | null {
return Deno.readTextFile(REPO_ROOT + relPath).catch(() => null);
}

async function pathExists(relPath: string): Promise<boolean> {
async fn pathExists(relPath: string): boolean {
return Deno.stat(REPO_ROOT + relPath).then(() => true).catch(() => false);
}

Expand All @@ -54,18 +51,18 @@ Deno.test("contract/RSR: AGENTIC.a2ml exists in .machine_readable/6a2/", async (
});

Deno.test("contract/RSR: no SCM checkpoint files in repo root", async () => {
const bannedRootFiles = ["STATE.scm", "META.scm", "ECOSYSTEM.scm", "AGENTIC.scm"];
let bannedRootFiles = ["STATE.scm", "META.scm", "ECOSYSTEM.scm", "AGENTIC.scm"];
for (const f of bannedRootFiles) {
const exists = await pathExists(f);
let exists = await pathExists(f);
assertEquals(exists, false, `SCM checkpoint file must NOT be in repo root: ${f}`);
}
});

Deno.test("contract/RSR: no SCM checkpoint files exist anywhere", async () => {
// RSR invariant: .machine_readable/ must use .a2ml, never .scm
const bannedNames = ["STATE.scm", "META.scm", "ECOSYSTEM.scm", "AGENTIC.scm"];
let bannedNames = ["STATE.scm", "META.scm", "ECOSYSTEM.scm", "AGENTIC.scm"];
for (const f of bannedNames) {
const exists = await pathExists(`.machine_readable/${f}`);
let exists = await pathExists(`.machine_readable/${f}`);
assertEquals(exists, false, `SCM file found in .machine_readable/ — must use .a2ml: ${f}`);
}
});
Expand All @@ -83,7 +80,7 @@ Deno.test("contract/RSR: ABI-FFI-README.md is present", async () => {
// ---------------------------------------------------------------------------

Deno.test("contract/license: LICENSE file uses PMPL", async () => {
const content = await readFile("LICENSE");
let content = await readFile("LICENSE");
assertNotEquals(content, null, "LICENSE must exist");
// PMPL license text contains "Palimpsest"
assertStringIncludes(
Expand All @@ -98,7 +95,7 @@ Deno.test("contract/license: LICENSES/MPL-2.0.txt present", async () => {
});

Deno.test("contract/license: README.adoc has SPDX header", async () => {
const content = await readFile("README.adoc");
let content = await readFile("README.adoc");
assertNotEquals(content, null);
assertMatch(content!, /SPDX-License-Identifier:/);
});
Expand All @@ -120,10 +117,10 @@ Deno.test("contract/hypatia: .hypatia/last-visit.json exists", async () => {
// ---------------------------------------------------------------------------

Deno.test("contract/author: MAINTAINERS.adoc references Jonathan D.A. Jewell", async () => {
const content = await readFile("MAINTAINERS.adoc");
let content = await readFile("MAINTAINERS.adoc");
assertNotEquals(content, null, "MAINTAINERS.adoc must exist");
// Should contain the canonical author name or hyperpolymath handle
const hasAuthor = content!.includes("Jonathan") || content!.includes("hyperpolymath");
let hasAuthor = content!.includes("Jonathan") || content!.includes("hyperpolymath");
assertEquals(hasAuthor, true, "MAINTAINERS.adoc should reference the author");
});

Expand All @@ -136,7 +133,7 @@ Deno.test("contract/stapeln: stapeln.toml exists", async () => {
});

Deno.test("contract/stapeln: stapeln.toml is non-empty", async () => {
const content = await readFile("stapeln.toml");
let content = await readFile("stapeln.toml");
assertNotEquals(content, null);
assertNotEquals(content!.trim(), "");
});
Expand All @@ -153,4 +150,3 @@ Deno.test("contract/contractiles: MUST.contractile exists in .machine_readable/"
assertEquals(await pathExists(".machine_readable/MUST.contractile"), true);
});

==================================== */
Loading
Loading