Skip to content

feat: InMemoryGraphAdapter (MEM-ADAPTER, v10.7.0)#24

Merged
flyingrobots merged 4 commits intomainfrom
mem-adapter
Feb 11, 2026
Merged

feat: InMemoryGraphAdapter (MEM-ADAPTER, v10.7.0)#24
flyingrobots merged 4 commits intomainfrom
mem-adapter

Conversation

@flyingrobots
Copy link
Member

@flyingrobots flyingrobots commented Feb 11, 2026

Summary

  • InMemoryGraphAdapter: Full in-memory implementation of all 5 ports (Commit, Blob, Tree, Ref, Config) with Git-format SHA-1 hashing. Accepts author and clock injection for deterministic tests.
  • adapterValidation.js: Extracted shared validation (validateOid, validateRef, validateLimit, validateConfigKey) from GitGraphAdapter — both adapters now use identical rules.
  • Adapter conformance suite: ~25 shared behavioral tests run against both Git and in-memory adapters, ensuring parity.
  • createInMemoryRepo() test helper for instant zero-I/O adapter setup.
  • Integration smoke test proves WarpGraph single-writer and multi-writer convergence work end-to-end with the in-memory adapter.

Test plan

  • npm run lint — clean
  • npm run test:local — 3277 tests pass (159 files)
  • Typecheck + TS policy — clean
  • Both adapters pass shared conformance suite
  • Integration smoke test: WarpGraph write + materialize with InMemoryAdapter
  • Multi-writer convergence test with InMemoryAdapter
  • CI (node22 + bun + deno matrix)

Summary by CodeRabbit

  • New Features

    • Added an in-memory persistence adapter and test helper for fast, filesystem-free testing.
  • Refactor

    • Centralized validation logic shared across adapters for consistent input checks.
  • Bug Fixes

    • Rejects malformed tree entries and fixes log-walk ordering/performance to match Git behavior.
  • Tests

    • Added adapter conformance suite plus unit and integration tests validating parity and multi-writer convergence.
  • Chores

    • Bumped release to v10.7.0 and updated changelog/roadmap.

@coderabbitai
Copy link

coderabbitai bot commented Feb 11, 2026

📝 Walkthrough

Walkthrough

Adds a new in-memory GraphPersistencePort implementation, a shared adapter validation module, refactors GitGraphAdapter to use the validators, and introduces a conformance test suite plus helpers and tests; package, changelog, and roadmap updated for v10.7.0.

Changes

Cohort / File(s) Summary
Release
CHANGELOG.md, ROADMAP.md, package.json
Bump to v10.7.0; document MEM-ADAPTER delivery and mark roadmap task DONE.
In-memory Adapter
src/infrastructure/adapters/InMemoryGraphAdapter.js
New full in-memory GraphPersistencePort implementation (commits, blobs, trees, refs, config), SHA-1 helpers, EMPTY_TREE_OID, log walking, ping, and full public persistence API.
Shared Validation
src/infrastructure/adapters/adapterValidation.js
New centralized validators exported: validateOid, validateRef, validateLimit, validateConfigKey.
Git Adapter
src/infrastructure/adapters/GitGraphAdapter.js
Refactored to delegate internal validation to adapterValidation.js; behavior and public API unchanged.
Conformance Tests
test/unit/infrastructure/adapters/AdapterConformance.js
New shared adapter conformance suite (~25 tests) covering Commit/Blob/Tree/Ref/Config and validation error cases.
Test Helpers
test/helpers/warpGraphTestUtils.js
Added createInMemoryRepo() helper that returns an InMemoryGraphAdapter instance and noop cleanup for tests.
Adapter Tests
test/unit/infrastructure/adapters/InMemoryGraphAdapter.test.js, test/unit/infrastructure/adapters/InMemoryGraphAdapter.integration.test.js, test/unit/infrastructure/adapters/GitGraphAdapter.coverage.test.js
Unit and integration tests for InMemoryGraphAdapter (including injected clock/author, validation, malformed entry rejection, ordering, refs), plus running the conformance suite against GitGraphAdapter.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Poem

🐰 I scurry through maps, no disk to bind,
SHAs in my paw, deterministic mind.
Trees and blobs and refs in a row,
Tests nod hello — the adapters grow,
A rabbit hops, "v10.7.0 — delivered!"

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the primary addition (InMemoryGraphAdapter), includes the feature type (feat), and references the roadmap task (MEM-ADAPTER) and release version (v10.7.0).
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch mem-adapter

No actionable comments were generated in the recent review. 🎉

🧹 Recent nitpick comments
src/infrastructure/adapters/InMemoryGraphAdapter.js (2)

297-307: Minor: logNodes ignores the format string's content when truthy.

When format (aliased as _format) is truthy, the method always uses _formatCommitRecord regardless of what format string was passed. This is documented in the comment (lines 301-302) as intentional for port compatibility, but callers passing a custom format string may be surprised. If this is the accepted contract, consider a brief JSDoc note on the format param explaining this.


390-396: configSet validates value type but not length.

configSet correctly rejects non-string values. However, there's no upper bound on value length, unlike validateConfigKey which caps keys at 256 chars. If very large config values are a concern, consider adding a max-length check, though this may be out of scope for an in-memory test adapter.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link

Release Preflight

  • package version: 10.7.0
  • prerelease: false
  • npm dist-tag on release: latest
  • npm pack dry-run: passed
  • jsr publish dry-run: passed

If you tag this commit as v10.7.0, release workflow will publish.

@flyingrobots
Copy link
Member Author

@coderabbitai review please

@coderabbitai
Copy link

coderabbitai bot commented Feb 11, 2026

@flyingrobots: I'll review the PR now. This looks like a substantial feature addition with the InMemoryGraphAdapter implementation, shared validation extraction, and comprehensive conformance testing. Let me analyze the changes in detail.

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@github-actions
Copy link

Release Preflight

  • package version: 10.7.0
  • prerelease: false
  • npm dist-tag on release: latest
  • npm pack dry-run: passed
  • jsr publish dry-run: passed

If you tag this commit as v10.7.0, release workflow will publish.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@src/infrastructure/adapters/InMemoryGraphAdapter.js`:
- Around line 446-475: The _walkLog implementation currently uses BFS which can
produce non-chronological order for DAGs with merge commits; update _walkLog (in
InMemoryGraphAdapter.js) to ensure returned entries are in reverse chronological
order by sorting the collected result by the commit date (commit.date)
descending before returning, or alternatively add a conformance test
(logNodesStream in AdapterConformance.js) that constructs a merge commit DAG and
asserts reverse-chronological ordering to catch mismatches across adapters; pick
one approach—either sort result by date descending in _walkLog or add the
merge-commit test in AdapterConformance.js to validate behavior across adapters.
🧹 Nitpick comments (1)
src/infrastructure/adapters/InMemoryGraphAdapter.js (1)

345-348: Subtle: || vs ?? for readRef return.

Line 347 uses || null, which would coerce a stored empty-string value to null. This is safe because updateRef validates the OID (which can't be empty), but it's inconsistent with configGet (line 382) which correctly uses ?? null. Consider aligning for consistency and resilience against future changes.

♻️ Align with `configGet` pattern
   async readRef(ref) {
     validateRef(ref);
-    return this._refs.get(ref) || null;
+    return this._refs.get(ref) ?? null;
   }

@flyingrobots
Copy link
Member Author

@coderabbitai review please

@coderabbitai
Copy link

coderabbitai bot commented Feb 11, 2026

@flyingrobots: I'll review the PR changes now. This is a substantial feature addition with the InMemoryGraphAdapter implementation, shared validation extraction, and comprehensive conformance testing.

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@github-actions
Copy link

Release Preflight

  • package version: 10.7.0
  • prerelease: false
  • npm dist-tag on release: latest
  • npm pack dry-run: passed
  • jsr publish dry-run: passed

If you tag this commit as v10.7.0, release workflow will publish.

@flyingrobots
Copy link
Member Author

@coderabbitai review please

@coderabbitai
Copy link

coderabbitai bot commented Feb 11, 2026

@flyingrobots: I'll review the PR changes now. This is a substantial feature addition with the InMemoryGraphAdapter implementation, shared validation extraction, and comprehensive conformance testing.

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@flyingrobots
Copy link
Member Author

@coderabbitai review please

@coderabbitai
Copy link

coderabbitai bot commented Feb 11, 2026

@flyingrobots: I'll review the PR changes now. This is a substantial feature addition with the InMemoryGraphAdapter implementation, shared validation extraction, and comprehensive conformance testing.

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@flyingrobots flyingrobots merged commit 7b35e90 into main Feb 11, 2026
7 checks passed
@flyingrobots flyingrobots deleted the mem-adapter branch February 11, 2026 21:30
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.

1 participant