Skip to content

fix: include inherited attachments in library session pages - #5990

Merged
Sinity merged 1 commit into
masterfrom
codex/attachment-library-lineage
Oct 5, 2026
Merged

Sinity merged 1 commit into
masterfrom
codex/attachment-library-lineage

Conversation

@Sinity

@Sinity Sinity commented Oct 5, 2026

Copy link
Copy Markdown
Owner

Summary

Include inherited prefix attachment references in session-filtered library pages, preserving physical ownership and the branch cut.

Problem

Original polylogue-5gj19 42.F117 (PR #5454 discussion 4078842400) reports /api/attachments?session=<child> omitting an attachment on an inherited parent message although the child's session read shows it. Both current library readers filter physical r.session_id, selecting only the child's retained tail.

Solution

Use the existing sync composed transcript plan and async lineage segments under their existing pinned snapshot owners. One shared SQL selection joins segment metadata to coordinate-bounded messages and their physical attachment refs before LIMIT/OFFSET. Preserve reference/session/message/native attribution and the existing newest-session/transcript/attachment/reference ordering. The pinned HTTP reader now uses that same SQL instead of its predecessor lexical order.

Refuse incomplete lineage through the existing typed DatabaseError boundary, preserving canonical cycle, dangling branch-point and content-witness decisions. Missing profiles remain readable. No message IDs or full sessions are materialized to filter the page; no writer, acquired Raw ref or durable schema changes.

Verification

  • agentctl job start polylogue pytest_focused --workspace /home/sinity/.codex/worktrees/attachment-coordinate-evidence/polylogue -- tests/unit/storage/test_attachment_library_lineage.py tests/unit/api/test_attachment_library_page.py tests/unit/daemon/test_http_attachment_library.py tests/unit/storage/test_attachment_first_class_ids.py: job 9065 SUCCESS0, 20 passed / 20 collected, receipt 20261005T023847Z-focused-test-2025061-673e4d51. Real API, daemon renderer and pinned HTTP read owner qualify inherited-before-cut, excluded-after-cut/foreign, physical ownership, limit-one offsets, zero-profile readability and missing/content-skew refusal.
  • agentctl job start polylogue verify_quick --workspace /home/sinity/.codex/worktrees/attachment-coordinate-evidence/polylogue: job 9067 SUCCESS0, all 12 gates passed, receipt 20261005T024055Z-quick-2028261-5b0303e4. Initial 9066 failed only test object-field typing; final delta adds identity-preserving casts, leaving production and assertions unchanged.
  • devtools schema closure polylogue/storage/sqlite/queries/attachment_records.py: IN. Land before reconvergence; no live rebuild.
  • Initial 9062:8/9 passed; content-skew fixture violated the actual 32-byte witness CHECK before the read. Corrected to an admitted 32-byte mismatched witness; original receipt 20261005T023540Z-focused-test-2017013-16737746 preserved.

Self-review

Reviewed the coherent six-path delta once, then the annotation-only correction. The initial correlated membership predicate was replaced before final qualification by the direct canonical segment/message/ref join.

  1. ✓ Siblings/owners: sync/async library consumers share SQL and existing lineage/snapshot owners.
  2. ✓ Fix: bound arguments, conditional relation and matching cuts reviewed; 20 production controls pass.
  3. ✓ Memory/limits: segment metadata and selected rows only; no new cap or full message-ID collection.
  4. ✓ Cost: scoped SQL starts from segments; no per-reference lookup or archive-wide hydrated filter.
  5. ✓ Interruption: existing read snapshot/context cleanup remains the owner; no writes or cursor advancement.
  6. ✓ Ordering/races: plan and selected window share snapshot; common deterministic reference order.
  7. ✓ Failure classification: incomplete canonical lineage reaches typed DatabaseError, not empty success.
  8. ✓ Outcomes: complete page only after membership; missing profile stays readable; missing witness refuses.
  9. ✓ Cleanup: existing owned snapshot/connection and context-managed selected cursor retained.
  10. N/A identity/keys: physical durable keys unchanged; derived closure membership recorded.
  11. ✓ Lossless transforms: original owning session/message/native refs preserved; no deduplication.
  12. ✓ Degenerate inputs: exhausted page, absent profiles and missing/skew witness controlled.
  13. ✓ Consumers: repository snapshot boundary and pinned HTTP owner updated; duplicate SQL retired, docs current.
  14. ✓ Tests/stubs: actual stored writer facts, API, daemon renderer and pinned reader; neutral synthetic fixtures.
  15. ✓ Trust: bound SQL operands; no private archive/receipt content tracked.

Residuals

Broader polylogue-5gj19 remains open. Existing canonical planning retains metadata proportional to lineage depth and can count session messages; SQL sorting/offset work can scale with the selected relation. This does not claim constant-time pages. No live rebuild, model/fresh-agent trials, acquired-reference writes or shared Native/Runtime worktree edits.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for security reviews. Please try again later.

@Sinity
Sinity enabled auto-merge (squash) October 5, 2026 02:43
@Sinity
Sinity merged commit 3d940ee into master Oct 5, 2026
3 checks passed
@Sinity
Sinity deleted the codex/attachment-library-lineage branch October 5, 2026 02:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant