You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
bug(chat): file_access_log cannot record a dedup reference; it is logged as an upload with a metadata flag #21404
The file_access_log table cannot record a deduplication reference as its own access type. The dedup path logs it as upload and marks it only in the free-form metadata, so an audit query on access_type cannot tell a real upload from a reference to an existing file.
Evidence (origin/main)
autobot-backend/database/schemas/conversation_files_schema.sql:75 - CHECK (access_type IN ('upload', 'download', 'view', 'delete', 'restore')).
autobot-backend/conversation_file_manager.py:683-685 - "upload" with metadata {"deduplication": True, "reference": True}, with a comment that the CHECK has no reference.
Options
Extend the CHECK with reference through a schema migration. Queries become exact; needs a SQLite table rebuild (CHECK cannot be altered in place) and existing rows stay as they are.
Keep the metadata flag and document it as the design. No migration; audit consumers must read access_metadata to separate the cases.
Recommendation
Option 1: the access type is what audit consumers filter on, and the flag workaround hides a real event inside another type. It needs owner approval because it is a schema migration.
Acceptance criteria
Owner picks an option on this issue.
Option 1: a migration extends the CHECK, is idempotent, and preserves existing rows; the dedup path logs reference; a test asserts the logged type.
Option 2: the design is documented next to the schema and the code comment, and a test pins the flag.
Owner decision (2026-11-17): Option 1. A migration extends the access-type CHECK with reference; it is idempotent and preserves existing rows. The dedup path logs reference, and a test asserts the logged type. This goes into PR #21732.
Option 1 implemented in PR #21732: conversation_file_access_type_schema.py (idempotent rebuild keeping rows), called from the manager schema init and migration 001; dedup logs reference.
Closure pass, checked against origin/main at df23644 (PR #21732), by reading code; tests were not run here, CI ran them on the PR.
AC
Evidence on main
Owner picks an option on this issue.
Owner decision 2026-11-17: Option 1.
Option 1: a migration extends the CHECK, is idempotent, and preserves existing rows; the dedup path logs reference; a test asserts the logged type.
CHECK now lists reference (database/schemas/conversation_files_schema.sql:75). Migration conversation_file_access_type_schema.pyensure_access_type_schema (:86): BEGIN IMMEDIATE rebuild, foreign keys off during the copy, orphans and the id counter kept; run from the manager schema init (conversation_file_manager.py:444 via apply_schema_upgrades) and from migration 001 (database/migrations/001_create_conversation_files.py:148). Dedup logs reference (conversation_file_manager.py:683). Tests in conversation_file_access_type_21404_test.py: test_a_duplicate_upload_is_logged_as_a_reference_not_an_upload, test_the_migration_keeps_every_row_and_column_and_is_idempotent, test_an_orphan_row_survives_and_the_foreign_key_setting_is_restored, test_log_ids_of_deleted_rows_are_never_reused, test_an_error_mid_migration_leaves_the_old_table_and_rows_intact, test_a_check_written_in_a_comment_does_not_hide_the_real_old_one.
Option 2: the design is documented next to the schema and the code comment, and a test pins the flag.
Not applicable: Option 1 was chosen; left unticked.
Gate 2: check-issue-close-refs.sh 21404 clear. No frontend or API consumer filters on access_type, so no UI change. The issue stays closed.
Host evidence — local install on main @ df23644 (2026-11-17 22:32 Riga)
Item
Verdict
Evidence
Migration extends the CHECK on the host (Option 1)
PASS
The live file_access_log CREATE statement has CHECK (access_type IN ('upload', 'download', 'view', 'delete', 'restore', 'reference')), so the migration ran on the install.
Existing rows preserved / normal logging still works
PASS (partial)
A new upload after the migration wrote a file_access_log row with access_type 'upload'. Pre-existing row counts were not compared.
Dedup path logs reference on the host
NOT OBSERVED
Only one upload was made, so the dedup path was not triggered on the host. Test coverage is unchanged.
No checkbox changes. The ticked Option 1 AC is code and test evidence, and this comment adds the host-side confirmation of the schema.
Activity
mrveiss commentedon Nov 17, 2026
Owner decision (2026-11-17): Option 1. A migration extends the access-type CHECK with
reference; it is idempotent and preserves existing rows. The dedup path logsreference, and a test asserts the logged type. This goes into PR #21732.fix(chat): log a deduplicated upload as reference and migrate the acc…
mrveiss commentedon Nov 17, 2026
Option 1 implemented in PR #21732:
conversation_file_access_type_schema.py(idempotent rebuild keeping rows), called from the manager schema init and migration 001; dedup logsreference.fix(chat): file_access_log migration keeps orphan rows, takes the wri…
fix(chat): keep the grandfathered files at or under their base size w…
fix(chat): the old-schema migration fixture switches foreign keys off…
fix(chat): detect the access-type CHECK from the clause, not the tabl…
fix(chat): strip SQL comments before reading the access-type CHECK (#…
Merge pull request #21732 from mrveiss/issue-20195
mrveiss commentedon Nov 17, 2026
Closure pass, checked against origin/main at df23644 (PR #21732), by reading code; tests were not run here, CI ran them on the PR.
reference; a test asserts the logged type.reference(database/schemas/conversation_files_schema.sql:75). Migrationconversation_file_access_type_schema.pyensure_access_type_schema(:86):BEGIN IMMEDIATErebuild, foreign keys off during the copy, orphans and the id counter kept; run from the manager schema init (conversation_file_manager.py:444viaapply_schema_upgrades) and from migration 001 (database/migrations/001_create_conversation_files.py:148). Dedup logsreference(conversation_file_manager.py:683). Tests inconversation_file_access_type_21404_test.py:test_a_duplicate_upload_is_logged_as_a_reference_not_an_upload,test_the_migration_keeps_every_row_and_column_and_is_idempotent,test_an_orphan_row_survives_and_the_foreign_key_setting_is_restored,test_log_ids_of_deleted_rows_are_never_reused,test_an_error_mid_migration_leaves_the_old_table_and_rows_intact,test_a_check_written_in_a_comment_does_not_hide_the_real_old_one.Gate 2:
check-issue-close-refs.sh 21404clear. No frontend or API consumer filters onaccess_type, so no UI change. The issue stays closed.github-actions commentedon Nov 17, 2026
Landed in #21732, merge
df23644addmrveiss commentedon Nov 17, 2026
Host evidence — local install on
main@ df23644 (2026-11-17 22:32 Riga)file_access_logCREATE statement hasCHECK (access_type IN ('upload', 'download', 'view', 'delete', 'restore', 'reference')), so the migration ran on the install.file_access_logrow withaccess_type 'upload'. Pre-existing row counts were not compared.referenceon the hostNo checkbox changes. The ticked Option 1 AC is code and test evidence, and this comment adds the host-side confirmation of the schema.