Skip to content

fix(read): bound three unbounded read and queue paths - #5706

Merged
Sinity merged 3 commits into
masterfrom
claude/bugsweep-readbounds
Sep 28, 2026
Merged

Sinity merged 3 commits into
masterfrom
claude/bugsweep-readbounds

Conversation

@Sinity

@Sinity Sinity commented Sep 28, 2026

Copy link
Copy Markdown
Owner

Summary

Bounds three read/queue paths from the read-bounds bug family: yooge, buuxr, 1gxyu.

Problem

  • yooge: DeferredEffectQueue stored a receipt per effect:staleness_key for the process lifetime. The key embeds the batch's session ids, so it grew with every distinct ingest batch in a long-running daemon. No production code reads those receipts.
  • buuxr: a full-scope insight rebuild ran list_summaries(limit=1_000_000) and built four archive-sized collections (manifest JSON, targets, target refs) per prepare, twice per mutation. apply ignores them for the full scope. On an archive past the plan's target ceiling, build_plan refused to plan the rebuild at all.
  • 1gxyu: attachment availability on every session read called BlobStore.verify, which streams and SHA-256s the whole blob, so reading a session with large attachments cost their full size every time.

Solution

  • yooge: the queue keeps only the in-flight key set (for de-duplication) and drops settled deliveries; failures are still reported by archive.write_effect.failed. The unused receipt API is removed.
  • buuxr: a full-scope plan carries no per-session targets; its manifest digest is the scope identity (scope, index path, materializer version). Explicit scopes still name their sessions.
  • 1gxyu: read paths use BlobStore.verify_for_read, which hash-verifies once and then trusts the result while the blob file keeps the same device, inode, size and nanosecond mtime; any change forces a full re-hash. The memo is a pacing bound (eviction only re-hashes). verify/verify_all stay uncached integrity checks.

Already fixed on master, recorded on the beads: fvsjn (per-session bounds, #5381) and 0bn4p (facet scope bound with a named facet_scope_truncated gap and shared cancellation).

Verification

  • devtools test over the three new test files plus test_mutation_actuators.py and test_blob_store.py: all passed except TestSessionExcisionActuator::test_prepare_and_apply_expose_marker_carrier_terminal_evidence, which fails with UnclassifiedSessionCarrierError: raw_existence_changes — a table added on master by fix(storage): bound live frontier admission with journals #5657 without an excision carrier declaration, not touched here.
  • devtools schema closure: all five production files are IN; this must land before the fresh build.

Residuals

  • 2fguj (per-row text materialized before truncation) and gzmd4 (several unbounded storage reads) need a query-contract change and stay open.
  • verify_for_read does not detect an in-place rewrite that restores the same size and nanosecond mtime.

🤖 Generated with Claude Code

https://claude.ai/code/session_013Vn4qhKjhyaVBG4aPiqNW4

@chatgpt-codex-connector

Copy link
Copy Markdown

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

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 28, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-28T07:43:34.899780Z f9af111 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 94ebe018d6

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread polylogue/storage/blob_store.py Resolved
Comment thread polylogue/archive/write_effects.py Resolved
@Sinity
Sinity enabled auto-merge (squash) September 28, 2026 00:34

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6650b5dd57

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread polylogue/archive/write_effects.py Resolved
Comment thread polylogue/archive/write_effects.py Resolved
Comment thread polylogue/storage/blob_store.py Resolved
Sinity and others added 3 commits September 28, 2026 09:28
The deferred write-effect queue kept a receipt for every distinct ingest
batch for the process lifetime; nothing read them, so only in-flight keys
are now retained (yooge). A full insight rebuild enumerated every session
id into four archive-sized collections per prepare, and past the plan's
target ceiling refused to plan at all; the full scope is now identified by
scope, generation and recipe (buuxr). Session reads re-hashed every
attachment blob on every read; read-path verification now re-hashes only
when the blob file's identity changed (1gxyu).

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_013Vn4qhKjhyaVBG4aPiqNW4
… ctime

A failed deferred write effect is kept as a retry obligation and retried
at the next enqueue, with its staleness key reported, instead of being
dropped. The read-verification memo includes ctime, so a permission,
owner or content change forces a re-hash, and an unreadable blob reads as
unavailable rather than raising.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_013Vn4qhKjhyaVBG4aPiqNW4
…shing

Three findings on the deferred effect queue and read verification:

- An enqueue that ran between a worker recording a failure and releasing
  its pending key cleared the failure, and the resubmit was rejected as
  still pending, so the obligation was lost. Failure recording and the
  pending release now share one critical section, and a retry moves from
  failed to pending in another.
- During a sustained outage every failed batch was retained and
  resubmitted at each enqueue. Failures now coalesce per effect and
  database into one obligation over the union of session IDs, so retained
  state is bounded by the sessions owed, and the insight invalidation
  binds that union in chunks.
- Concurrent cold reads of one blob each streamed a full hash. A per-
  identity in-flight future now makes later readers wait for and reuse
  the first result.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01P8nGdByCWAzpk78ko2xza6
@Sinity
Sinity force-pushed the claude/bugsweep-readbounds branch from 6650b5d to f9af111 Compare September 28, 2026 07:40
@Sinity
Sinity merged commit 986e0aa into master Sep 28, 2026
3 checks passed
@Sinity
Sinity deleted the claude/bugsweep-readbounds branch September 28, 2026 07: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