Skip to content

Add unit tests for core GEP modules#63

Merged
autogame-17 merged 2 commits intoEvoMap:mainfrom
voidborne-d:add-unit-tests
Feb 22, 2026
Merged

Add unit tests for core GEP modules#63
autogame-17 merged 2 commits intoEvoMap:mainfrom
voidborne-d:add-unit-tests

Conversation

@voidborne-d
Copy link
Contributor

@voidborne-d voidborne-d commented Feb 21, 2026

Hey! I have been reading through the codebase and noticed there are no unit tests yet for the core modules. Figured I would put together a starter test suite.

What this adds

  • 61 tests covering 4 core modules:

    • contentHash — canonicalize, computeAssetId, verifyAssetId, tamper detection
    • a2aProtocol — all 6 message builders, validation, asset unwrapping
    • mutation — category selection logic, safety downgrades, personality constraints
    • selector — gene scoring, capsule matching, drift intensity
  • npm test script in package.json

Details

  • Uses Node.js built-in node:test + node:assert (no external dependencies)
  • Works with Node 22+ (matches the project requirement)
  • All 61 tests pass

Happy to adjust scope or style if needed.


Note

Low Risk
Test-only additions plus a new npm test script; no production logic changes beyond enabling a test command.

Overview
Adds a Node built-in (node:test) unit test suite covering core GEP modules: contentHash (canonicalization + asset ID hashing/verification), a2aProtocol (message builders/validation and publish asset unwrapping), mutation (category/risk selection and personality safety constraints), and selector (gene/capsule selection, drift intensity, and memory preference behavior).

Updates package.json to expose npm test via node --test test/*.test.js (no new dependencies).

Written by Cursor Bugbot for commit b76cb18. This will update automatically on new commits. Configure here.

Add test suite using Node.js built-in test runner (node:test) covering:
- contentHash: canonicalize, computeAssetId, verifyAssetId
- a2aProtocol: message builders, validation, asset unwrapping
- mutation: buildMutation, category selection, safety downgrades
- selector: gene selection, capsule matching, drift intensity

61 tests, zero external dependencies.

Run with: npm test
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.


it('returns 0 for non-finite input', () => {
assert.equal(clamp01(NaN), 0);
assert.equal(clamp01(Infinity), 0);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test asserts wrong expected value for clamp01(Infinity)

Low Severity

The test asserts clamp01(Infinity) returns 0, but a function named clamp01 (clamp to [0, 1]) would correctly return 1 for Infinity, since Infinity > 1. The source code treats all non-finite values uniformly as 0, which is correct for NaN and undefined but incorrect for positive infinity. Grouping Infinity together with NaN/undefined as "returns 0" cements this inconsistency — clamp01(1e308) returns 1 but clamp01(Infinity) returns 0, a surprising discontinuity. This test codifies that potentially incorrect behavior.

Fix in Cursor Fix in Web

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. The test is intentionally documenting the current behavior — clamp01 rejects all non-finite values early via Number.isFinite(), so Infinity returns 0 rather than being clamped to 1.

Whether that's the right behavior is a fair question (mathematically clamp(Inf, 0, 1) should be 1), but changing it would be a separate fix in the source. Happy to open a follow-up issue if the maintainers want to revisit it.

@autogame-17 autogame-17 merged commit 1610739 into EvoMap:main Feb 22, 2026
1 check passed
fmw666 pushed a commit that referenced this pull request Mar 11, 2026
- PR #68 (hendrixAIDev): guard performMaintenance with IS_DRY_RUN
- PR #26 (onthebigtree): hash hostname in env fingerprint, portable validation paths
- PR #63 (voidborne-d): add 61 unit tests for core GEP modules
- PR #21 (LKCY33): add dotenv path rewrite for public build
- PR #25 (onthebigtree): already applied (currentSleepMs, matchPatternToSignals, max_files)
- Update public.manifest.json: include test/*.test.js, add index.js dotenv rewrite

Co-authored-by: Cursor <cursoragent@cursor.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants