Skip to content

test(memory): a GMI over a durable store lists memories of one millisecond by id, on SQLite and PostgreSQL alike - #833

Merged
jddunn merged 4 commits into
masterfrom
test/memory-tiebreak-gmi-e2e
Nov 14, 2026
Merged

jddunn merged 4 commits into
masterfrom
test/memory-tiebreak-gmi-e2e

Conversation

@jddunn

@jddunn jddunn commented Nov 14, 2026 •

Copy link
Copy Markdown
Member

What changed

A test of #831 through the path a host takes: a GMI built with agent({ runtime: 'gmi' }) over a durable store, on a SQLite file and on PostgreSQL. One agent files twelve turns with the clock standing still, so every memory has one filing time, and closes; a second agent built on the same store answers a question. The test checks the memory block the model is sent and the turn's memoryRecall record:

  • every group of equally scored candidates in the record is listed by id in character-code order, and the block lists six equally scored replies in that order;
  • two stores holding the same memories, with different rows written again after filing (PostgreSQL moves an updated row to the end of its table), send the same block and the same record;
  • SQLite and PostgreSQL send the same block and the same record.

The trace ids carry the order they were minted in, and their letters mix cases out of order, so the test fails on the order of filing, its reverse, and a language's collation alike; it checks that its groups tell those orders apart.

gmi-runtime.memory-tiebreak.e2e.test.ts

Issue

Part of #754

Spec, plan and design

None

Docs

  • docs/memory/COGNITIVE_MEMORY.md, "Upgrading from 0.17.3 or earlier": the line now says where a host sees the order (the GMI's memory block and memoryRecall.candidates) and that both engines give the same block. It also corrects what 0.17.3 gave on SQLite: the line said the order the traces were stored, and the red run below shows the newest filed first on this path, so it now says the order followed how the engine read the rows.
  • gmi-runtime.memory-recall.e2e.test.ts: its comment said memories of one millisecond load in an order the engine picks; it now says by id.

Tests

@sourcery-ai

sourcery-ai Bot commented Nov 14, 2026

Copy link
Copy Markdown

Sorry @jddunn, you've used your own review budget of 250,000 diff characters for the last 7 days.

You can request another review in 21 hours and 8 minutes by commenting @sourcery-ai review. Upgrade to get a review now.

@coderabbitai

coderabbitai Bot commented Nov 14, 2026

Copy link
Copy Markdown

Warning

Review limit reached

  • Run on-demand review

This review includes 3 billable files and costs up to $0.75.

  • Ask an admin to make reviews automatic

Open in CodeRabbit

Reviews can continue after your included limit without a manual trigger. An admin must approve usage-based billing.

Or wait 2 minutes for your next included review.

Check out review usage here.

View limit details

Limit details: You’ve used all 4 included reviews currently available.

Learn how review limits work.

Review configuration:

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 3c7780a and b6d0907.

Files selected for processing: 3

  • docs/memory/COGNITIVE_MEMORY.md
  • src/api/__tests__/gmi-runtime.memory-recall.e2e.test.ts
  • src/api/__tests__/gmi-runtime.memory-tiebreak.e2e.test.ts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

@sourcery-ai

sourcery-ai Bot commented Nov 14, 2026

Copy link
Copy Markdown

Reviewer's Guide

Documentation

Clarify where hosts see the memory ordering and how same-millisecond traces previously loaded on SQLite and PostgreSQL.

  • docs/memory/COGNITIVE_MEMORY.md L722

Tests

Add a durable-store GMI end-to-end test that checks same-millisecond tie ordering in recall records and model memory blocks across updated stores and database engines.

  • src/api/__tests__/gmi-runtime.memory-tiebreak.e2e.test.ts L1-313

Update the existing GMI memory-recall test comment to reflect that memories filed in one millisecond are ordered by id.

  • src/api/__tests__/gmi-runtime.memory-recall.e2e.test.ts L24-25

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-14T07:58:19.755456Z b6d0907 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@qodo-free-for-open-source-projects

Copy link
Copy Markdown

PR Summary by Qodo

Test deterministic GMI memory order across SQLite and PostgreSQL

🧪 Tests 📝 Documentation 🕐 20-40 Minutes

Grey Divider

AI Description

• Add end-to-end coverage for same-millisecond memory ordering through a restarted GMI agent.
• Verify tied memories appear by id in recall records and model-visible blocks across both stores.
• Clarify the host-visible ordering guarantee and correct the description of earlier SQLite
 behavior.
Diagram

graph TD
  writer["Writer agent"] --> store[("SQLite / PostgreSQL")] --> reader["Reader agent"] --> recall["Memory recall"] --> block["Memory block"] --> provider["Stub provider"]
  recall --> capture["Recall record"]
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Test only at the memory-store layer
  • ➕ Faster tests with a smaller fixture.
  • ➖ Would not establish that the ordering reaches the GMI prompt and turn-level recall record.
2. Extend the existing recall end-to-end suite
  • ➕ Could reuse its database and provider setup.
  • ➖ Its advancing-clock fixture gives memories distinct filing times, so the tie case needs a separate setup.

Recommendation: Keep the dedicated end-to-end test: fixed-time filing and cross-engine comparisons directly verify the host-visible guarantee without changing the existing recall suite’s timing assumptions.

Files changed (3) +316 / -3

Tests (2) +315 / -2
gmi-runtime.memory-recall.e2e.test.tsCorrect the existing recall test’s ordering comment +2/-2

Correct the existing recall test’s ordering comment

• Updates the fixture comment to state that same-millisecond memories load by id on either engine and points to the new tie-break test.

src/api/tests/gmi-runtime.memory-recall.e2e.test.ts

gmi-runtime.memory-tiebreak.e2e.test.tsExercise deterministic memory ties through the GMI runtime +313/-0

Exercise deterministic memory ties through the GMI runtime

• Adds a fixed-clock, durable-store test that files twelve turns, restarts the agent, and checks tied candidate ids and six replies in the model-visible block. Compares stores with different rows updated, then compares SQLite with PostgreSQL when configured; the ids distinguish character-code order from filing order, its reverse, and language collation.

src/api/tests/gmi-runtime.memory-tiebreak.e2e.test.ts

Documentation (1) +1 / -1
COGNITIVE_MEMORY.mdClarify the host-visible same-millisecond ordering guarantee +1/-1

Clarify the host-visible same-millisecond ordering guarantee

• Explains that equally scored memories filed in one millisecond appear by character-code id order in GMI memory blocks and recall candidates on both engines. Corrects the description of earlier SQLite behavior, which depended on row-read order rather than reliably following filing order.

docs/memory/COGNITIVE_MEMORY.md

@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)

Grey Divider

Great, no issues found!

Qodo reviewed your code and found no material issues that require review

Grey Divider

Tip of the day
💡 Did you know, you can ask Qodo to dismiss a finding you disagree with, with your reason on record

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

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