fix(8.0): vfs.rename() issues a metadata-only update (port of the 7.31.7 fix)

rename() spread the entire fetched entity into brain.update(), forwarding a
vector field that failed dimension validation when the entity was fetched
without vectors. A rename is a path/metadata change: the update is now
metadata-only — no vector forwarded, no re-embedding, no vector-index touch.
Regression suite ported from the 7.x line (verbatim consumer repro,
cross-directory move, EEXIST). The companion rollback fix from 7.31.7 was
already present on this branch via the pre-RC1 sweep.
This commit is contained in:
David Snelling 2026-06-11 15:05:12 -07:00
parent 1f7e365a4e
commit f4c5d9749f
2 changed files with 80 additions and 14 deletions

View file

@ -1670,17 +1670,6 @@ export class VirtualFileSystem implements IVirtualFileSystem {
if (err.code !== VFSErrorCode.ENOENT) throw err
}
// Update entity metadata
const updatedEntity = {
...entity,
metadata: {
...entity.metadata,
path: newPath,
name: this.getBasename(newPath),
modified: Date.now()
}
}
// Update parent relationships if needed
const oldParentPath = this.getParentPath(oldPath)
const newParentPath = this.getParentPath(newPath)
@ -1706,10 +1695,19 @@ export class VirtualFileSystem implements IVirtualFileSystem {
}
}
// Update the entity
// A rename is a path/metadata change, never a content change — issue a
// metadata-only update. Spreading the whole entity here used to forward
// its vector field into update(), which failed dimension validation when
// the entity was fetched without vectors (and would needlessly touch the
// vector index when it wasn't).
await this.brain.update({
...updatedEntity,
id: entityId
id: entityId,
metadata: {
...entity.metadata,
path: newPath,
name: this.getBasename(newPath),
modified: Date.now()
}
})
// Update path cache