Fix project creation overwriting existing documents#6
Draft
cursor[bot] wants to merge 1 commit into
Draft
Conversation
Co-authored-by: g00sifer Development Lab <g00siferdev-py@users.noreply.github.com>
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.
Bug and impact
project_createonly checked_index.jsonfor duplicate project IDs, then unconditionally wroteprojects/{id}/document.md. If an agent/user had already created that document throughproject_writeor workspace files before metadata existed, a laterproject_createsilently replaced the real content with the default stub orinitialDocument, causing data loss.Root cause
Project existence was defined solely by metadata in
workspace/projects/_index.json; the backing document path was not checked before creation wrote to disk.Fix
projects/{id}/document.mdas user data duringcreate_project.initialDocumentis supplied.initialDocumentwhen the document already exists, directing replacement throughproject_writeinstead.Validation
cargo +stable test --locked --manifest-path src-tauri/Cargo.toml projects::tests -- --nocapturecargo +stable test --locked --manifest-path src-tauri/Cargo.tomlnpm run build