CedarCopilot wants to merge 1 commit into main from staging
Not deployed
Libra has no production signal for this change yet because it has not deployed. Libra checks hourly for 3 days after each deploy.
This PR consolidates execution staleness handling, document addressing and scope resolution, and subagent identity/ownership around shared implementations.
The PR should not merge until existing user-scoped contact documents are migrated to the new organization scope so contact history remains readable and singular.
The new contact scope fixes future reads and writes but does not repair the known production row stored with a non-null user ID, leaving it unreachable and allowing later writes to create a second profile.
Files Needing Attention: apps/server/src/services/documents/index.ts; apps/server/src/services/documents/virtual-paths.ts
| Filename | Overview |
|---|---|
| apps/server/src/services/documents/index.ts | Centralizes write scoping and adds UUID-to-path resolution, but leaves known legacy contact rows outside the new canonical scope. |
| apps/server/src/services/documents/virtual-paths.ts | Adds organization-scoped contact paths and centralizes user-scope selection across supported path prefixes. |
| apps/server/src/services/agent-action-queue/executions.ts | Aligns reactive staleness handling with the reaper and measures execution age from the latest valid write. |
| apps/server/src/services/playbook/reference-resolver.ts | Introduces canonical metadata-first subagent identity and returns document identity with parsed instructions. |
| apps/server/src/services/aop/field-ownership.ts | Resolves live field owners from enabled user and organization subagent documents instead of the legacy agent table. |
| apps/server/src/db/migrations/scripts/playbook-health/heal-subagent-agent-ids.ts | Validates canonical UUIDs and replaces full-document upserts with guarded frontmatter patches. |
### Issue 1
apps/server/src/services/documents/index.ts:408
**Legacy contact scope remains split**
When the known contact document with a non-null `user_id` is read or updated, the new organization-scoped lookup cannot find that row, causing the existing profile to remain inaccessible and a subsequent write to create a second profile instead of updating its accumulated context.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.
Reviews (1): Last reviewed commit: "Merge pull request #2569 from CedarCopil..." | Re-trigger Greptile
Greptile also left 1 inline comment on this PR.
Libra has not measured any production surfaces for this change yet.