Skip to content

fix(cloud): tolerate missing directory in session upserts#259

Closed
jorgehara wants to merge 2 commits intoGentleman-Programming:feat/integrate-engram-cloudfrom
jorgehara:fix/session-directory-optional
Closed

fix(cloud): tolerate missing directory in session upserts#259
jorgehara wants to merge 2 commits intoGentleman-Programming:feat/integrate-engram-cloudfrom
jorgehara:fix/session-directory-optional

Conversation

@jorgehara
Copy link
Copy Markdown

Fixes #249

Summary

This PR fixes the cloud sync failure when MCP server upserts sessions without a directory field. The directory is now optional and will be resolved from context or left empty.

Changes

File Change
internal/cloud/chunkcodec/chunkcodec.go Removed required directory validation for session upserts
internal/cloud/cloudserver/cloudserver.go Made session.Directory optional in chunk validation
internal/store/store.go Allow empty directory in cloud upgrade legacy mutation handling
internal/cloud/cloudserver/cloudserver_test.go Updated tests for new behavior
internal/cloud/remote/transport_test.go Updated test error messages

Test Plan

  • All existing tests pass
  • Manually tested cloud sync with smoke-project
  • Verified sync creates chunks successfully without directory field
  • Tested with Docker Compose setup locally

Related

Contributor Checklist

…leman-Programming#249)

BUGFIX Gentleman-Programming#249: Session mutations missing directory field when MCP server upserts sessions

Changes:
- Make session.directory optional in chunkcodec.normalizeMutationPayload()
- Make session.Directory optional in cloudserver.validateDirectChunkArrayEntries()
- Make directory optional in store cloud upgrade legacy mutation handling
- Update tests to reflect new behavior

This allows MCP server and other sources to create sessions without
specifying a directory, which will be resolved from context or left empty.

Fixes: Gentleman-Programming#249
Related: Gentleman-Programming#250
…completes Gentleman-Programming#260)

This commit adds wildcard (*) support to ENGRAM_CLOUD_ALLOWED_PROJECTS,
enabling local development with multiple projects without explicit listing.

Changes:
- internal/cloud/auth/auth.go: Wildcard support in authorizeProjectAgainstAllowlist()
- internal/cloud/cloudstore/cloudstore.go: Wildcard support in SetDashboardAllowedProjects()
- docker-compose.cloud.all-projects.yml: Example configuration

When ENGRAM_CLOUD_ALLOWED_PROJECTS="*":
- All sync operations are authorized
- Dashboard displays all projects without filtering
- Zero breaking changes for existing explicit allowlists

Tested on Windows 11 with 22 projects synchronized successfully.
Dashboard now displays project grid with sessions, observations, and prompts.

Fixes: Gentleman-Programming#260
Related: Bug Gentleman-Programming#249 fix for session directory optional
@jorgehara
Copy link
Copy Markdown
Author

Update: Additional Enhancement Added

This PR now also includes wildcard support for ENGRAM_CLOUD_ALLOWED_PROJECTS (Issue #260).

Complete Changes:

Bug Fix (Issue #249):

  • Session directory now optional for cloud sync
  • Fixes "session payload directory is required for upsert" error
  • Enables MCP server and other sources to create sessions without directory

Feature (Issue #260):

  • Wildcard (*) support in ENGRAM_CLOUD_ALLOWED_PROJECTS
  • Dashboard now displays all projects when wildcard is set
  • Perfect for local development with multiple projects

Files Changed:

  1. internal/cloud/chunkcodec/chunkcodec.go - Remove directory validation
  2. internal/cloud/cloudserver/cloudserver.go - Remove directory validation
  3. internal/store/store.go - Allow empty directory in cloud upgrade
  4. internal/cloud/auth/auth.go - Wildcard support for auth
  5. internal/cloud/cloudstore/cloudstore.go - Wildcard support for dashboard
  6. docker-compose.cloud.all-projects.yml - Example config
  7. Tests updated in cloudserver_test.go and transport_test.go

Testing Results:

✅ 22 projects synchronized successfully
✅ Dashboard displays project grid with stats
✅ All existing tests passing
✅ Tested on Windows 11 + Docker Desktop

Example Usage:

# docker-compose.cloud.all-projects.yml
environment:
  ENGRAM_CLOUD_ALLOWED_PROJECTS: "*"

Both issues are addressed in this single PR as they were discovered during the same debugging session.

@Alan-TheGentleman
Copy link
Copy Markdown
Collaborator

Thanks for taking this on and linking it to #249. Closing this PR because main now fixes the root cause in 39d48e9: MCP implicit sessions are created with the current working directory, and tests cover the session mutation payloads directly. Making directory optional in the cloud path avoids the crash, but it weakens the data contract and this PR also broadens scope beyond the focused bug fix. If we decide to add defensive handling for historical bad mutations, please keep that as a separate narrow PR with no unrelated project-allowlist behavior.

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