Skip to content

fix(memory): load GotchasMemory named export (#517) - #668

Merged
rafaelscosta merged 4 commits into
mainfrom
fix/issue-517-gotchas-memory-import-20260507
May 7, 2026
Merged

fix(memory): load GotchasMemory named export (#517)#668
rafaelscosta merged 4 commits into
mainfrom
fix/issue-517-gotchas-memory-import-20260507

Conversation

@rafaelscosta

@rafaelscosta rafaelscosta commented May 7, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Fixes GotchasMemory imports in ideation/execution consumers to use the named export from gotchas-memory.js.
  • Adds a regression test that instantiates IdeationEngine, ContextInjector, and SubagentDispatcher and verifies each receives a real GotchasMemory instance.
  • Bumps @aiox-squads/core to 5.1.8 and records Story 123.12.

Validation

  • node -c .aiox-core/core/ideation/ideation-engine.js && node -c .aiox-core/core/execution/context-injector.js && node -c .aiox-core/core/execution/subagent-dispatcher.js
  • constructor smoke for IdeationEngine, ContextInjector, SubagentDispatcher
  • npm test -- tests/core/gotchas-memory-imports.test.js --runInBand
  • npm test -- tests/core/gotchas-memory-imports.test.js tests/core/context-injector.test.js tests/core/subagent-dispatcher.test.js --runInBand (69 tests passed)
  • npm run validate:manifest
  • npm run validate:publish
  • npm run lint -- --quiet
  • npm run typecheck
  • npm run test:ci (315 suites passed, 7838 tests passed, 149 skipped)
  • git diff --check

Refs #517.
Supersedes #521.

Summary by CodeRabbit

  • Bug Fixes

    • Improved handling of an optional memory dependency: load/validation failures are now captured, exposed for inspection, and conditionally logged when debug is enabled; components continue operating without the optional memory.
  • Tests

    • Added regression tests for normal and failure import scenarios and for load-error reporting.
  • Documentation

    • Added story documenting the named-export behavior and acceptance criteria.
  • Chores

    • Version bumped to 5.1.8 and refreshed generated manifests/metadata.

@vercel

vercel Bot commented May 7, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
aiox-core Ready Ready Preview, Comment May 7, 2026 2:33pm

Request Review

@coderabbitai

coderabbitai Bot commented May 7, 2026

Copy link
Copy Markdown

Review Change Stack
No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: f04e56d7-4847-4422-9f41-ba2c5d39c6cb

📥 Commits

Reviewing files that changed from the base of the PR and between 9886fd3 and 7f126b6.

📒 Files selected for processing (6)
  • .aiox-core/core/execution/context-injector.js
  • .aiox-core/core/execution/subagent-dispatcher.js
  • .aiox-core/core/ideation/ideation-engine.js
  • .aiox-core/data/entity-registry.yaml
  • .aiox-core/install-manifest.yaml
  • tests/core/gotchas-memory-imports.test.js
✅ Files skipped from review due to trivial changes (1)
  • .aiox-core/install-manifest.yaml
🚧 Files skipped from review as they are similar to previous changes (4)
  • .aiox-core/core/execution/context-injector.js
  • .aiox-core/core/execution/subagent-dispatcher.js
  • tests/core/gotchas-memory-imports.test.js
  • .aiox-core/data/entity-registry.yaml

Walkthrough

Three execution modules adopt a defensive import pattern for GotchasMemory (destructured try/catch), regression tests cover success and failure paths, package version is bumped to 5.1.8, and registry/manifest/story docs are updated.

Changes

GotchasMemory Named Export Fix

Layer / File(s) Summary
Destructuring Import Pattern
.aiox-core/core/execution/context-injector.js, .aiox-core/core/execution/subagent-dispatcher.js, .aiox-core/core/ideation/ideation-engine.js
ContextInjector, SubagentDispatcher, and IdeationEngine now import GotchasMemory via object destructuring with try/catch fallback, validating a constructible named export, recording any load/validation error to gotchasMemoryLoadError, conditionally logging when AIOX_DEBUG is set, and leaving GotchasMemory null if unavailable; gotchasMemoryLoadError is exported.
Regression Test
tests/core/gotchas-memory-imports.test.js
New Jest test suite with success and two failure-path tests verifying that IdeationEngine, ContextInjector, and SubagentDispatcher either instantiate gotchasMemory or expose a gotchasMemoryLoadError when the named export is missing or invalid.
Version Bump
package.json
Package version incremented from 5.1.7 to 5.1.8.
Registry & Manifest Updates
.aiox-core/data/entity-registry.yaml, .aiox-core/install-manifest.yaml
Entity registry metadata timestamp updated; module checksums, lastVerified, and dependencies for modified modules refreshed (replacing gotchas-memory with memory-query and ai-providers where applicable); install manifest updated to 5.1.8 with refreshed SHA256 hashes and sizes for affected files.
Story Documentation
docs/stories/epic-123/STORY-123.12-gotchas-memory-named-export.md
Story documents the named-export issue, acceptance criteria, performed tasks, dev notes, and list of affected files for STORY-123.12.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Suggested labels

area: core, type: test, area: docs

Suggested reviewers

  • Pedrovaleriolopez
  • oalanicolas
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely summarizes the primary fix: loading GotchasMemory as a named export across three modules, which directly addresses issue #517.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/issue-517-gotchas-memory-import-20260507

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 github-actions Bot added area: agents Agent system related area: workflows Workflow system related squad mcp type: test Test coverage and quality area: core Core framework (.aios-core/core/) area: installer Installer and setup (packages/installer/) area: synapse SYNAPSE context engine area: cli CLI tools (bin/, packages/aios-pro-cli/) area: pro Pro features (pro/) area: health-check Health check system area: docs Documentation (docs/) area: devops CI/CD, GitHub Actions (.github/) labels May 7, 2026
@github-actions

github-actions Bot commented May 7, 2026

Copy link
Copy Markdown
Contributor

📊 Coverage Report

Coverage report not available

📈 Full coverage report available in Codecov


Generated by PR Automation (Story 6.1)

coderabbitai[bot]
coderabbitai Bot previously requested changes May 7, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 4

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.aiox-core/core/execution/context-injector.js:
- Around line 23-27: The try/catch around the dynamic require for GotchasMemory
silently swallows any import error; update the catch to capture the thrown error
(e.g., "err") and surface minimal debug context instead of swallowing it — keep
the fallback assignment GotchasMemory = null but log or debug the error with a
short message including the module name and the caught error (reference the
existing require('../memory/gotchas-memory') block and the GotchasMemory symbol)
so future regressions are visible during debugging.

In @.aiox-core/core/execution/subagent-dispatcher.js:
- Around line 30-34: The catch block that falls back when requiring
'../memory/gotchas-memory' currently swallows errors; change it to catch the
error (e.g., catch (err)) and log minimal context before setting GotchasMemory =
null so missing/corrupt memory modules are diagnosable — include the module path
('../memory/gotchas-memory') and the error.message or error.stack in the log
(use console.error or the module's logger if available) while keeping the
fallback assignment to GotchasMemory unchanged.

In @.aiox-core/core/ideation/ideation-engine.js:
- Around line 15-19: The require fallback for GotchasMemory currently swallows
errors; update the try/catch around require('../memory/gotchas-memory') so the
catch captures the error (e.g., catch (err)) and surfaces lightweight
diagnostics: log or warn including the error message/stack (use console.warn or
the module's logger) and set GotchasMemory = null, and also attach the error to
a module-level symbol (e.g., exports.gotchasMemoryLoadError or
module.gotchasMemoryLoadError) so callers can observe degradation; modify the
block around GotchasMemory to implement this behavior.

In `@tests/core/gotchas-memory-imports.test.js`:
- Around line 3-6: Replace the relative require imports with the project's
absolute import paths: locate the requires for IdeationEngine, ContextInjector,
SubagentDispatcher, and GotchasMemory in
tests/core/gotchas-memory-imports.test.js and change them from
'../../.aiox-core/core/...' to the repository's absolute module paths used
elsewhere (importing the modules by their package-root absolute identifiers) so
the test uses absolute imports consistent with the project's convention.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 4545a569-418a-4efb-85ba-2549183a8562

📥 Commits

Reviewing files that changed from the base of the PR and between 29fc469 and 5fe98c3.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (8)
  • .aiox-core/core/execution/context-injector.js
  • .aiox-core/core/execution/subagent-dispatcher.js
  • .aiox-core/core/ideation/ideation-engine.js
  • .aiox-core/data/entity-registry.yaml
  • .aiox-core/install-manifest.yaml
  • docs/stories/epic-123/STORY-123.12-gotchas-memory-named-export.md
  • package.json
  • tests/core/gotchas-memory-imports.test.js

Comment thread .aiox-core/core/execution/subagent-dispatcher.js
Comment thread tests/core/gotchas-memory-imports.test.js Outdated
coderabbitai[bot]
coderabbitai Bot previously requested changes May 7, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.aiox-core/core/execution/context-injector.js:
- Around line 24-34: The try/catch can miss the case where
require('../memory/gotchas-memory') succeeds but doesn't export GotchasMemory,
leaving GotchasMemory undefined and gotchasMemoryLoadError null; after the
destructuring in the try block (where GotchasMemory is assigned), add a guard
that checks if GotchasMemory is undefined and, if so, set gotchasMemoryLoadError
to a new Error describing the missing named export and emit the same debug
warning as in the catch when process.env.AIOX_DEBUG is set so callers can detect
the failed export; reference the GotchasMemory binding, gotchasMemoryLoadError
variable, and the require('../memory/gotchas-memory') call in
context-injector.js.

In @.aiox-core/core/ideation/ideation-engine.js:
- Around line 16-26: The current destructuring of ({ GotchasMemory } =
require('../memory/gotchas-memory')) can yield GotchasMemory = undefined without
throwing, leaving gotchasMemoryLoadError null and silently disabling
IdeationEngine.gotchasMemory; update the try/catch to first require the module
into a temp (e.g., const mod = require('../memory/gotchas-memory')), then if
(!mod || typeof mod.GotchasMemory === 'undefined') set gotchasMemoryLoadError to
a new Error describing the missing export and (when AIOX_DEBUG) log a clear
warning including that error; otherwise assign GotchasMemory = mod.GotchasMemory
so ideate() and IdeationEngine.gotchasMemory behave correctly.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 6ba5a70b-fbe3-42d6-8d0d-0ed8e6012e2c

📥 Commits

Reviewing files that changed from the base of the PR and between 5fe98c3 and bf2bc81.

📒 Files selected for processing (6)
  • .aiox-core/core/execution/context-injector.js
  • .aiox-core/core/execution/subagent-dispatcher.js
  • .aiox-core/core/ideation/ideation-engine.js
  • .aiox-core/data/entity-registry.yaml
  • .aiox-core/install-manifest.yaml
  • tests/core/gotchas-memory-imports.test.js
✅ Files skipped from review due to trivial changes (1)
  • .aiox-core/install-manifest.yaml
🚧 Files skipped from review as they are similar to previous changes (3)
  • tests/core/gotchas-memory-imports.test.js
  • .aiox-core/core/execution/subagent-dispatcher.js
  • .aiox-core/data/entity-registry.yaml

Comment thread .aiox-core/core/execution/context-injector.js
Comment thread .aiox-core/core/ideation/ideation-engine.js Outdated
@rafaelscosta
rafaelscosta dismissed stale reviews from coderabbitai[bot] and coderabbitai[bot] May 7, 2026 14:28

Addressed in later commits on this PR. HEAD 9886fd3 fixes the GotchasMemory diagnostics, missing named export guard, and adds regression coverage; CI is green.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.aiox-core/core/ideation/ideation-engine.js:
- Around line 29-33: The code only checks that gotchasMemoryModule.GotchasMemory
is not undefined but doesn't verify it's constructible; update the guard around
gotchasMemoryModule/GotchasMemory so it confirms GotchasMemory is a
function/class (e.g., typeof GotchasMemory === 'function') or otherwise
constructible before assigning and attempting new GotchasMemory(); if the check
fails, throw a clear Error that includes GOTCHAS_MEMORY_MODULE and the actual
typeof value to preserve context for the surrounding try/catch that handles
optional dependency loading.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 43f5e4f2-fe3c-42e3-b696-f8d73d1ad62d

📥 Commits

Reviewing files that changed from the base of the PR and between bf2bc81 and 9886fd3.

📒 Files selected for processing (6)
  • .aiox-core/core/execution/context-injector.js
  • .aiox-core/core/execution/subagent-dispatcher.js
  • .aiox-core/core/ideation/ideation-engine.js
  • .aiox-core/data/entity-registry.yaml
  • .aiox-core/install-manifest.yaml
  • tests/core/gotchas-memory-imports.test.js
✅ Files skipped from review due to trivial changes (1)
  • .aiox-core/install-manifest.yaml
🚧 Files skipped from review as they are similar to previous changes (3)
  • .aiox-core/core/execution/subagent-dispatcher.js
  • .aiox-core/data/entity-registry.yaml
  • .aiox-core/core/execution/context-injector.js

Comment thread .aiox-core/core/ideation/ideation-engine.js
@rafaelscosta
rafaelscosta merged commit 524c12c into main May 7, 2026
40 checks passed
@rafaelscosta
rafaelscosta deleted the fix/issue-517-gotchas-memory-import-20260507 branch May 7, 2026 14:39
tuanmedeiros pushed a commit to tuanmedeiros/aios-core-synkraay that referenced this pull request Jun 2, 2026
…#668)

* fix: load gotchas memory named export (SynkraAI#517)

* fix: surface gotchas memory load diagnostics (SynkraAI#517)

* fix: guard gotchas memory named export (SynkraAI#517)

* fix: require constructible gotchas memory export (SynkraAI#517)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: agents Agent system related area: cli CLI tools (bin/, packages/aios-pro-cli/) area: core Core framework (.aios-core/core/) area: devops CI/CD, GitHub Actions (.github/) area: docs Documentation (docs/) area: health-check Health check system area: installer Installer and setup (packages/installer/) area: pro Pro features (pro/) area: synapse SYNAPSE context engine area: workflows Workflow system related mcp squad type: test Test coverage and quality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant