-
Notifications
You must be signed in to change notification settings - Fork 2
fix: profile, delegation and storage reds from the 2026-09-05 corpus #4692
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
f852566
7d16279
1c94a83
f047650
3654aec
a66edc8
5ee7064
cd37e20
c0b7790
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3769,6 +3769,11 @@ def _write_attachments( | |
| attachment_id = _attachment_id(session_id, attachment) | ||
| message_id = resolved_message_ids.get(id(attachment)) | ||
| if message_id is None: | ||
| # The owner is ambiguous, so no ref may be guessed, but the | ||
| # attachment's identity and bytes are still evidence. The row is | ||
| # written unreferenced and kept out of the ref-count sweep, which | ||
| # exists to collect rows whose refs went away. | ||
| _write_attachment_row(conn, attachment_id, attachment, preacquired_blobs) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When an ambiguous-owner AGENTS.md reference: AGENTS.md:L175-L179 Useful? React with 👍 / 👎.
Comment on lines
+3772
to
+3776
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
On a full replacement where this attachment was previously resolved but the new message set makes its owner ambiguous, AGENTS.md reference: AGENTS.md:L175-L179 Useful? React with 👍 / 👎. |
||
| continue | ||
| direction, producer_ref = _attachment_provenance( | ||
| attachment, owning_messages.get(message_id), resolved_message_id=message_id | ||
|
|
@@ -3781,33 +3786,7 @@ def _write_attachments( | |
| f"attachment_id={attachment.provider_attachment_id!r}" | ||
| ) | ||
| touched_attachment_ids.add(attachment_id) | ||
| acquired_blob = (preacquired_blobs or {}).get(id(attachment)) | ||
| blob_hash, byte_count, acquisition_status = ( | ||
| acquired_blob if acquired_blob is not None else _acquire_attachment_blob(conn, attachment) | ||
| ) | ||
| conn.execute( | ||
| """ | ||
| INSERT INTO attachments ( | ||
| attachment_id, display_name, media_type, byte_count, blob_hash, acquisition_status, ref_count | ||
| ) VALUES (?, ?, ?, ?, ?, ?, 0) | ||
| ON CONFLICT(attachment_id) DO UPDATE SET | ||
| display_name = COALESCE(excluded.display_name, attachments.display_name), | ||
| media_type = COALESCE(excluded.media_type, attachments.media_type), | ||
| byte_count = excluded.byte_count, | ||
| blob_hash = COALESCE(excluded.blob_hash, attachments.blob_hash), | ||
| acquisition_status = | ||
| CASE WHEN excluded.acquisition_status = 'acquired' | ||
| THEN 'acquired' ELSE attachments.acquisition_status END | ||
| """, | ||
| ( | ||
| attachment_id, | ||
| _sqlite_text(attachment.name), | ||
| _sqlite_text(attachment.mime_type), | ||
| byte_count, | ||
| blob_hash, | ||
| acquisition_status, | ||
| ), | ||
| ) | ||
| _write_attachment_row(conn, attachment_id, attachment, preacquired_blobs) | ||
| ref_position = attachment_positions[id(attachment)] | ||
| ref_id = f"{message_id}:attachment:{ref_position}" | ||
| # Bulk rebuilds may suspend FK enforcement. Mirror REPLACE's cascade | ||
|
|
@@ -3866,6 +3845,42 @@ def _write_attachments( | |
| refresh_and_sweep_attachment_rows(conn, affected_attachment_ids) | ||
|
|
||
|
|
||
| def _write_attachment_row( | ||
| conn: sqlite3.Connection, | ||
| attachment_id: str, | ||
| attachment: ParsedAttachment, | ||
| preacquired_blobs: dict[int, tuple[bytes | None, int, str]] | None, | ||
| ) -> None: | ||
| """Upsert the attachment's identity and bytes, leaving refs to the caller.""" | ||
| acquired_blob = (preacquired_blobs or {}).get(id(attachment)) | ||
| blob_hash, byte_count, acquisition_status = ( | ||
| acquired_blob if acquired_blob is not None else _acquire_attachment_blob(conn, attachment) | ||
| ) | ||
| conn.execute( | ||
| """ | ||
| INSERT INTO attachments ( | ||
| attachment_id, display_name, media_type, byte_count, blob_hash, acquisition_status, ref_count | ||
| ) VALUES (?, ?, ?, ?, ?, ?, 0) | ||
| ON CONFLICT(attachment_id) DO UPDATE SET | ||
| display_name = COALESCE(excluded.display_name, attachments.display_name), | ||
| media_type = COALESCE(excluded.media_type, attachments.media_type), | ||
| byte_count = excluded.byte_count, | ||
| blob_hash = COALESCE(excluded.blob_hash, attachments.blob_hash), | ||
| acquisition_status = | ||
| CASE WHEN excluded.acquisition_status = 'acquired' | ||
| THEN 'acquired' ELSE attachments.acquisition_status END | ||
| """, | ||
| ( | ||
| attachment_id, | ||
| _sqlite_text(attachment.name), | ||
| _sqlite_text(attachment.mime_type), | ||
| byte_count, | ||
| blob_hash, | ||
| acquisition_status, | ||
| ), | ||
| ) | ||
|
|
||
|
|
||
| def refresh_and_sweep_attachment_rows(conn: sqlite3.Connection, attachment_ids: set[str]) -> None: | ||
| """Recompute ``attachments.ref_count`` from live refs and sweep zero-ref rows. | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding only
sp.input_row_countmakesArchiveStore.get_session_profile_recordstop raising, but the returnedSessionProfileRecordstill never receivessp.input_content_hash: this query does not select it and_session_profile_record_from_archive_rowtherefore leaves the field at itsNonedefault. For any materialized profile with a non-null content binding, the publicPolylogue.get_session_profile_recordroute now reportsinput_content_hash=None, defeating the provenance-based content comparison this method promises. Select and map the content hash alongside the row count.AGENTS.md reference: AGENTS.md:L175-L179
Useful? React with 👍 / 👎.