Skip to content

fix(awareness): correct waking cycle schedule (#280)#281

Open
heybeaux wants to merge 118 commits into
productionfrom
staging
Open

fix(awareness): correct waking cycle schedule (#280)#281
heybeaux wants to merge 118 commits into
productionfrom
staging

Conversation

@heybeaux

Copy link
Copy Markdown
Owner

Description

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation
  • Refactor

How Has This Been Tested?

Checklist

  • Code follows the project's style guidelines
  • I've self-reviewed my own code
  • Complex areas are commented
  • Documentation has been updated (if needed)
  • No new warnings introduced
  • Tests added for new functionality
  • All tests pass

Related Issues

beaux-riel and others added 30 commits March 2, 2026 04:47
Architecture watchdog (2026-03-04) detected 10 undocumented modules.
Added: identity (65 files/11k lines), awareness (29 files/6k lines),
anticipatory, cloud-link, cloud-sync, delegation, challenge,
inbound-email, instance, queue, teams, session-indexing.

Also added file/line counts from watchdog for all modules and
noted known large-file candidates for future refactoring.
- 52 modules (was 50): added agent-recall, entity-profile
- Updated file counts and line counts across all modules
- Updated known architecture notes with current large file sizes
- Notable growth: memory (58→63 files), consolidation (24→33 files),
  anticipatory (18→19 files), health (6→9 files)
…raction

- Add v07-backfill.spec.ts: tests for P2002 duplicate handling, memory attribution,
  disconnect-on-error, and agentSession upsert logic
- Add backfill-graph-extraction.spec.ts: tests for parseArgs CLI parsing,
  batch chunking logic, stats accumulation, and dry-run mode
- Covers the scripts module which was the only untested module (55 modules total)

Refs: architecture-watchdog 2026-03-10
…sub-files

Split into:
- topic-keyword-rules.ts (302 lines) — KEYWORD_RULES constant
- topic-definitions-personal.ts (269 lines) — personal/professional topics
- topic-definitions-system.ts (178 lines) — health/identity/agent topics
- topic-helpers.ts (52 lines) — helper functions
- topic-taxonomy.ts (30 lines) — backward-compatible barrel re-export

All 167 prefetch tests passing. No public API changes.
28 tests covering calculateWeight (logarithmic curve), updateWeight
(create/upsert/error paths), applyWeights (topic matching, boost logic,
edge cases), and getWeights. All mocked with jest.

Closes test gap: src/identity/experience-weighted-recall.service.ts
19 tests covering isEnabled, expandQuery (happy path, defaults, validation,
error handling), getRulesInfo, and testExpansion (all strategies, fallback
on failure, result mapping). All mocked with jest.
19 tests covering syncBatchToCloud (header auth, counts, cloudSyncedAt marking,
HTTP error handling for 401/403/429/500, contentHash generation, extraction
payload, resilient prisma update failure) and performSyncWithClient (progress
tracking, abort signal, single batch, auth stop, error accumulation).
These 3 spec files were generated against staging (Prisma v7) patterns and
merged into main which is still on Prisma v6. They cannot compile on main:
- cloud-sync-push.service.spec.ts: uses prisma.memory.update (v7 style)
- entity-semantic.service.spec.ts: missing service file (v7 migration)
- experience-weighted-recall.service.spec.ts: prisma.experienceWeight (v7)

These will be re-added when main is upgraded to Prisma v7.
…ool, auto, anticipatory/feedback, cloud-link controllers + cloud-link-mapping service (#205)
…ck errors (#208)

ROOT CAUSE: runJob() inherits the AsyncLocalStorage context of the triggering
HTTP request via rlsContext. By the time getMemoriesForEnrichment() runs
(after the HTTP response is sent), the RLS Prisma transaction has already
committed and closed. Any DB query in the async callback throws:
  'Transaction already closed: A query cannot be executed on a committed transaction'

FIX: Wrap runJob() call in rlsContext.run(undefined, ...) to explicitly clear
the ALS context before the async job starts. DB calls in the job then use
the raw PrismaService (no closed transaction context).

ALSO:
- Log full error string in job failure handler (pino was dropping Error objects)
- CloudEnsembleEmbedProvider.healthCheck: lazy-init if not available, log
  per-model errors from embedAll response
- Better error message with hint to check API keys and quota
beaux-riel and others added 29 commits May 20, 2026 22:54
- Remove duplicate `const batches` declarations in backfill-graph-extraction.spec.ts (merge artifact)
- Remove duplicate `user` object property and duplicate `data`/`toHaveBeenCalledTimes` in v07-backfill.spec.ts (merge artifact)
- Add `generateForRecall` to mockEmbedding in memory-contradiction and memory-failure specs (service uses generateForRecall, not generate)
- Add overrideGuard(ApiKeyOrJwtGuard) to webhook.controller.spec.ts and anticipatory/feedback/feedback.controller.spec.ts to fix JwtService resolution errors
- Update webhook controller test req mock to use {userId} instead of HTTP headers object

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
ConfigService returns env vars as strings — `embedding.length !== this.dimensions`
evaluated `384 !== "384"` → strict-equality fail → "expected 384, got 384" error →
5 failures → circuit breaker opens → 500s on every embed call.

Coerce via Number() with a positive-integer guard so misconfig fails loudly at
boot instead of silently breaking embeddings at runtime.

Regression tests added (15/15 pass).

Co-authored-by: heybeaux <beaux.walton@gmail.com>
…279)

- dream-cycle-consolidation.stage.spec.ts: add tx.memory.update mock
  (production now calls update to mark searchable:true after embedding write)
- memory-query-context.service.spec.ts: update sessionId filter assertion
  to match new session relation OR clause (id | externalId)
- memory-job-processor.service.spec.ts: replace $transaction assertion with
  $executeRawUnsafe — RLS path now sets app.current_account_id directly
- prisma-postgres.provider.spec.ts: inject EmbeddingWriteService mock and
  update embedding assertions to use writeLegacyInlineEmbedding

Co-authored-by: heybeaux <beaux.walton@gmail.com>
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jun 20, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 1be75c80-ef1d-427e-a68e-2486ccda4d5e

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch staging

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.

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