chore: align staging with production (real prod→staging merge)#276
Merged
Conversation
…t constraints (ENG-40) (#172)
… 0, dream cycle fix) (#192)
Resolved conflicts in: - prisma/schema.prisma (5 conflicts — merged new fields from both branches) - src/app.module.ts (2 conflicts — merged module imports) - src/consolidation/dream-cycle.service.ts (1 conflict — merged parallel processing) - src/memory/memory-query.service.ts (7 conflicts — merged feedback, query logging, userId changes) - src/memory/memory.module.ts (1 conflict — merged provider registrations)
The local embed server (/health) can be delayed when inference is running on the same Tokio thread pool. 5s was too tight and caused false 'down' reports during heavy embedding workloads. Root fix is spawn_blocking in engram-embed (separate commit). This is a belt-and-suspenders guard for the Engram side. See: engram-embed main.rs spawn_blocking fix
…agentId API key is sufficient to scope memory access — no caller-supplied agentId needed. The guard already resolves the correct user from the API key + X-AM-User-ID header combination. Changes: - GenerateContextOptions: userId is now preferred; agentId kept for backward compat (dream-cycle internal callers) - GenerateContextService: queries by userId when present, falls back to agentId. Also fixes raw SQL cluster query to use same scope. - ConsolidationController: injects @userid() decorator and passes resolved userId through; agentId in body is now truly optional. This resolves the recurring 0-memory context generation issue where 'clawd-agent-001' (or empty string) didn't match the actual stored agentId 'cmmm09r3t000dc9zkk9xfzc97'. The agentId concept is being phased out in favor of API key + userId scoping.
…requirement Stage 5 (generate-context) no longer requires DREAM_CONTEXT_AGENT_ID env var. It now passes the userId from the current dream-cycle run, which is always present and correctly scopes the memory query. DREAM_CONTEXT_AGENT_ID is kept for backward compat but is no longer a gate — the stage will run as long as DREAM_GENERATE_CONTEXT=true and userId is set.
Rework scope resolution to use accountId as primary key: - accountId (from API key) → queries all users under account - userId (X-AM-User-ID header) → optional narrowing to one user - agentId → legacy fallback only generate-context no longer requires X-AM-User-ID. Callers only need a valid API key. dream-cycle Stage 5 resolves accountId from the current run's userId for correct per-user scoping.
…-user narrowing The guard always resolves a user (falling back to isDefault=true) even when no X-AM-User-ID header is sent. This caused generate-context to silently scope to only the default user's 1,840 memories instead of all account memories (7,277 across beaux + default users). Fix: check raw request header to distinguish explicit userId from guard fallback. Without X-AM-User-ID, pass accountId only so generate-context queries all users under the account.
…d (schema migration) The User model was migrated from agentId-scoped to accountId-scoped in migration 20260313_user_identity_consolidation. The cloud-sync-ingest service was still using the old agentId_externalId unique index for findUnique and the agentId field in user.create — both removed from the schema. Fix: - Resolve accountId from the agent record first - Use accountId_externalId for the findUnique unique constraint - Drop agentId from user.create (no longer in schema) Also fixes stale 4-arg constructor in memory-import-async.spec.ts (RetrievalSignals arg was removed from MemoryBulkController).
…otfix → production) (#217)
True merge of origin/production into staging. Prior back-merges (#273/#275) merged the back-merge branch into itself rather than origin/production, so production was never an ancestor of staging and every staging→production sync PR (#272, #274) kept conflicting on the base side. All 36 conflicts resolved to staging: it carries the dream-cycle ARCHIVAL stage (ENG-123), correct 768D embedding test vectors, current formatting, and newer specs. Production's behavioral hotfixes (dedup always-queue, generate-context userId scoping, X-AM-User-ID header) live in cleanly-merged files and are preserved. Gate: git merge-base --is-ancestor origin/production HEAD must pass. Co-Authored-By: Claude Opus 4 <noreply@anthropic.com>
Contributor
✅ Recall Benchmark ResultsFull outputCommit: 47e93d9 |
This was referenced Jun 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why this PR (and why the last two didn't work)
Every staging→production sync (#272, #274) kept conflicting on the base side:
origin/productionwas never actually an ancestor oforigin/staging. The two prior "back-merges" (#273, #275) merged the back-merge branch into itself (#275's merge commit had #273's commit as its second parent, notorigin/production), so production's 28 divergent commits never genuinely landed in staging.What this does
A real
git merge origin/productioninto a branch offorigin/staging.4c10e73(staging) +185934e(production tip) — the production parent the prior attempts lacked.git merge-base --is-ancestor origin/production HEAD→ PASS.tsc --noEmit→ 0 errors (afterprisma generate).Conflict resolution — all 36 to staging
*.controller.spec.tsdream-cycle*.tsembedding*.ts,local-embed*[0.1,0.2]Production's behavioral hotfixes are preserved — dedup always-queue, generate-context userId scoping, and the X-AM-User-ID header fix all live in files that merged cleanly (not in the conflict set), verified present in the merged tree.
After this merges
Cut a fresh staging→production sync — it will be fast-forwardable, zero conflicts. Close #272 and #274.
🤖 Generated with Claude Code