Skip to content

fix(core): preserve repeated default project selection - #1273

Merged
phernandez merged 1 commit into
mainfrom
codex-default-project-reset
Aug 17, 2026
Merged

fix(core): preserve repeated default project selection#1273
phernandez merged 1 commit into
mainfrom
codex-default-project-reset

Conversation

@phernandez

Copy link
Copy Markdown
Member

Why

Repeatedly choosing the project that is already the default can leave a workspace with no default project. The API still returns success, but subsequent project discovery and every project-scoped MCP tool fail because no default can be resolved.

A production read-only investigation found repeated successful set-default requests followed by a database state where every project row had is_default = NULL.

What Changed

  • Make ProjectRepository.set_as_default idempotent when the selected project is already the default.
  • Add a regression test that verifies the committed state from a new database session.

Implementation Details

  • Validate and load the selected project before changing any default flags.
  • Clear the default flag only from other project rows.
  • Preserve the selected row so SQLAlchemy cannot lose the update when its identity-map value was already True before the bulk update.
  • Keep the existing repository and API contracts unchanged; no schema migration is required.

Testing

Automated:

  • uv run pytest -q tests/repository/test_project_repository.py::test_set_as_default_keeps_existing_default — reproduced the failure before the fix and passes after it.
  • uv run pytest -q tests/repository/test_project_repository.py — 14 passed with SQLite.
  • BASIC_MEMORY_TEST_POSTGRES=1 uv run pytest -q tests/repository/test_project_repository.py::test_set_as_default_keeps_existing_default — passed with PostgreSQL.
  • just fast-check — passed (Ruff formatting/lint and type checking).

Manual:

  • Correlated repeated successful set-default requests with the missing-default database state using production read-only telemetry and database inspection.

Risks / Follow-ups

  • The change is limited to default-project metadata and has no migration or public API impact.
  • Basic Memory Cloud must update its Core revision after this PR merges before hosted behavior changes.
  • Existing affected workspaces require a separate recovery action; this PR does not mutate production data.

Signed-off-by: phernandez <paul@basicmachines.co>
@phernandez
phernandez merged commit 47126fb into main Aug 17, 2026
25 checks passed
@phernandez
phernandez deleted the codex-default-project-reset branch August 17, 2026 23:28
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.

1 participant