@@ -727,6 +727,9 @@ async function resolveClaimableChatUploadRow(
727727 * Allocates a collision-free `displayName` (the partial unique index on
728728 * (chat_id, display_name) WHERE context='mothership' enforces this) and returns it
729729 * so callers can surface the same name to the model in the VFS read hint.
730+ * This is a metadata-only operation: it preserves any content provenance already
731+ * attached to the uploaded bytes. Direct user uploads use the established
732+ * exact-empty/legacy classification and do not need a chat-time reclassification.
730733 */
731734export async function trackChatUpload (
732735 workspaceId : string ,
@@ -793,10 +796,7 @@ export async function trackChatUpload(
793796 or ( isNull ( workspaceFiles . chatId ) , eq ( workspaceFiles . chatId , chatId ) )
794797 )
795798 )
796- . returning ( {
797- id : workspaceFiles . id ,
798- contentUpdatedAt : workspaceFiles . contentUpdatedAt ,
799- } )
799+ . returning ( { id : workspaceFiles . id } )
800800
801801 if ( updated . length === 0 ) {
802802 // The ownership lookup is a separate statement, so re-assert every
@@ -807,13 +807,6 @@ export async function trackChatUpload(
807807 // to the chat-delete cascade.
808808 throw new WorkspaceFileKeyOwnershipError ( s3Key )
809809 }
810-
811- await replaceWorkspaceFileSecretProvenanceInTx (
812- tx ,
813- updated [ 0 ] . id ,
814- updated [ 0 ] . contentUpdatedAt ,
815- EXACT_EMPTY_WORKSPACE_FILE_SECRET_PROVENANCE
816- )
817810 } )
818811
819812 logger . info (
@@ -840,20 +833,11 @@ export async function trackChatUpload(
840833 contentType,
841834 size,
842835 } )
843- . returning ( {
844- id : workspaceFiles . id ,
845- contentUpdatedAt : workspaceFiles . contentUpdatedAt ,
846- } )
836+ . returning ( { id : workspaceFiles . id } )
847837
848838 if ( ! inserted ) {
849839 throw new Error ( `Failed to track chat upload for key: ${ s3Key } ` )
850840 }
851- await replaceWorkspaceFileSecretProvenanceInTx (
852- tx ,
853- inserted . id ,
854- inserted . contentUpdatedAt ,
855- EXACT_EMPTY_WORKSPACE_FILE_SECRET_PROVENANCE
856- )
857841 } )
858842
859843 logger . info ( `Tracked chat upload: ${ fileName } (display: ${ candidate } ) for chat ${ chatId } ` )
0 commit comments