Skip to content

fix(memory): the guarded fetch's deadline covers decoding, and a network refusal names no resolver detail - #280

Merged
jddunn merged 1 commit into
masterfrom
fix/guarded-fetch-review
Oct 11, 2026
Merged

jddunn merged 1 commit into
masterfrom
fix/guarded-fetch-review

Conversation

@jddunn

@jddunn jddunn commented Oct 11, 2026 •

Copy link
Copy Markdown
Member

Summary

Three follow-ups to the guarded fetch from a cold review of its merged change. The deadline and a caller's abort now end the body's decoding too: readBody takes the combined signal, destroys the response and the decoder when it fires, and the success path checks the signal before returning, so a compressed body whose decoding outlives the deadline is refused as deadline rather than returned late. A network refusal carries a fixed sentence instead of the resolver's own message. Four new tests refuse literal internal addresses (loopback, the metadata address, an IPv4-mapped IPv6 literal and a hexadecimal IPv4 spelling) through guardedFetch itself, before any resolver call or connection, and two hold a gzip body's decoding past the deadline and past a caller's abort.

Linked issues

Follow-up to #249.

Verification

CI on this branch. Nothing was run locally.

Checklist

  • Tests exercise the real path and fail without the change
  • The docs page gained the sentence the change needs

Summary by Sourcery

Ensure guarded fetch cancellation covers decoding and consistently protects internal network details.

Bug Fixes:

  • Extend guarded-fetch deadlines and caller aborts through response-body decoding, preventing late success after compressed-body decoding continues past cancellation.
  • Return a fixed network-refusal message without exposing resolver error details.
  • Reject literal internal addresses, including loopback, metadata, IPv4-mapped IPv6, and hexadecimal IPv4 forms, before resolver or connection attempts.

Documentation:

  • Document that address and network refusals should use the same visitor-facing message.

Tests:

  • Add guarded-fetch coverage for literal internal-address rejection, sanitized network errors, and cancellation during delayed gzip decoding.

…after the wire closes, a network refusal names no resolver detail, and literal internal addresses are refused in tests
@coderabbitai

coderabbitai Bot commented Oct 11, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

  • Run on-demand review

This review includes 3 billable files and costs up to $0.75.

  • Ask an admin to make reviews automatic

Open in CodeRabbit

Reviews can continue after your included limit without a manual trigger. An admin must approve usage-based billing.

Or wait 5 minutes for your next included review.

Check out review usage here.

View limit details

Limit details: You’ve used all 4 included reviews currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: Repository: framerslab/agentos/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Team
  • Run ID: 36398d0b-3cfb-434c-8588-a97edfff2769

📥 Commits

Reviewing files that changed from the base of the PR and between d4d3c6d and 297b6ae.


📒 Files selected for processing (3)
  • docs/memory/MEMORY_DOCUMENT_INGESTION.md
  • src/cognition/memory/io/ingestion/__tests__/guardedFetch.test.ts
  • src/cognition/memory/io/ingestion/guardedFetch.ts

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

@sourcery-ai

sourcery-ai Bot commented Oct 11, 2026

Copy link
Copy Markdown

Reviewer's Guide

The PR makes guarded-fetch deadlines and caller aborts cover the full response lifecycle, including post-connection decoding, ensures network refusals expose only a fixed message, and adds regression tests for internal-address literals and cancellation/error-message behavior.

Sequence diagram for guarded fetch cancellation during decoding

sequenceDiagram
    participant Caller
    participant guardedFetch
    participant readBody
    participant Response
    participant Decoder
    participant failureOf

    Caller->>guardedFetch: guardedFetch(address, options)
    guardedFetch->>readBody: readBody(response, maxBytes, signal)
    readBody->>Response: pipeline(response, decoder)
    readBody->>Decoder: decode body
    alt deadline or caller signal aborts during decoding
        readBody->>Response: destroy()
        readBody->>Decoder: destroy()
        readBody-->>guardedFetch: aborted read
        guardedFetch->>failureOf: failureOf(error, callerSignal, deadline)
        failureOf-->>Caller: deadline or caller abort reason
    else decoding completes
        readBody-->>guardedFetch: Buffer
        guardedFetch->>guardedFetch: signal.throwIfAborted()
        guardedFetch-->>Caller: response with body
    end
Loading

Flow diagram for guarded fetch network refusal sanitization

flowchart TD
    A[guardedFetch receives address] --> B{Literal internal address}
    B -->|yes| C[address refusal]
    B -->|no| D[Resolver and connection]
    D --> E{Network read fails}
    E --> F[network refusal]
    C --> G[Caller shows shared refusal message]
    F --> G
Loading

File-Level Changes

Change Details Files
Extend guarded-fetch cancellation through compressed-body decoding and prevent late successful returns.
  • Pass the combined deadline/caller signal into body reading.
  • Destroy the response and decoder on abort, including after the connection closes.
  • Recheck the signal after decoding so deadline and abort outcomes cannot return a body late.
src/cognition/memory/io/ingestion/guardedFetch.ts
Sanitize network refusal messages while preserving the refusal category.
  • Replace resolver or transport error text with a fixed public network message.
  • Document the shared visitor-facing handling for address and network refusals.
src/cognition/memory/io/ingestion/guardedFetch.ts
docs/memory/MEMORY_DOCUMENT_INGESTION.md
Add end-to-end regression coverage for literal internal addresses, sanitized network errors, and cancellation during gzip decoding.
  • Verify loopback, metadata, IPv4-mapped IPv6, and hexadecimal IPv4 literals are rejected before DNS or socket connection.
  • Verify resolver details are absent from network refusal messages.
  • Hold gzip decoder completion to assert deadline and caller abort destroy both streams and produce the correct outcome.
src/cognition/memory/io/ingestion/__tests__/guardedFetch.test.ts

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@jddunn
jddunn marked this pull request as ready for review October 11, 2026 00:44
@jddunn
jddunn requested a review from Victor-Evogor as a code owner October 11, 2026 00:44
@sourcery-ai

sourcery-ai Bot commented Oct 11, 2026

Copy link
Copy Markdown

Sorry @jddunn, you've used your own review budget of 250,000 diff characters for the last 7 days.

You can request another review in 1 hour and 19 minutes by commenting @sourcery-ai review. Upgrade to get a review now.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 11, 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-10-11T00:46:13.812927Z 297b6ae Draft marked ready
ℹ️ 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.

@qodo-free-for-open-source-projects

Copy link
Copy Markdown

PR Summary by Qodo

Fix guarded-fetch decoding cancellation and sanitize resolver errors

🐞 Bug fix 🧪 Tests 📝 Documentation 🕐 20-40 Minutes

Grey Divider

AI Description

• Extend deadlines and caller aborts through body decoding to prevent late successful reads.
• Replace resolver-derived network errors with a fixed message that reveals no resolver details.
• Test literal internal-address rejection and delayed gzip cancellation; document visitor-facing
 refusal handling.
Diagram

graph TD
  A["Guarded fetch"] --> B{"Address allowed?"} -->|Yes| C["HTTP response"] --> D["Body decoder"] --> E{"Signal active?"} -->|Yes| F["Decoded body"]
  B -->|No| G["Refusal or abort"]
  E -->|No| G
  A --> H["Combined signal"]
  H -->|Cancel| C
  H -->|Cancel| D
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Use an abort-aware stream pipeline
  • ➕ Could delegate response and decoder destruction to Node's pipeline cancellation.
  • ➖ Would require coordinating pipeline completion with the existing decoded-byte cap and async iteration, broadening a focused fix.

Recommendation: Keep the targeted stream-destruction approach: it covers decoding after the socket closes without restructuring size-limited reads. The abort-aware pipeline is worth considering only if this stream handling is refactored more broadly.

Files changed (3) +131 / -20

Bug fix (1) +31 / -14
guardedFetch.tsCarry cancellation through decoding and sanitize resolver-derived failures +31/-14

Carry cancellation through decoding and sanitize resolver-derived failures

• Passes the combined signal into body reading, destroys the response and decoder on abort, and checks for cancellation before returning success. Replaces the underlying error text in converted network failures with a fixed message.

src/cognition/memory/io/ingestion/guardedFetch.ts

Tests (1) +98 / -6
guardedFetch.test.tsCover literal-address rejection, resolver privacy, and decoding cancellation +98/-6

Cover literal-address rejection, resolver privacy, and decoding cancellation

• Adds end-to-end guarded-fetch cases for four internal-address literal forms and a resolver failure containing private details. Holds gzip decoding after the connection closes to verify that both deadline and caller abort destroy the streams and reject appropriately.

src/cognition/memory/io/ingestion/tests/guardedFetch.test.ts

Documentation (1) +2 / -0
MEMORY_DOCUMENT_INGESTION.mdDocument indistinguishable visitor-facing address and network refusals +2/-0

Document indistinguishable visitor-facing address and network refusals

• Advises callers to show the same message for address and network refusals so visitors cannot infer whether an internal name resolves.

docs/memory/MEMORY_DOCUMENT_INGESTION.md

@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)

Grey Divider

Great, no issues found!

Qodo reviewed your code and found no material issues that require review

Grey Divider

Tip of the day
💡 Did you know, you can tweak Display settings with a live preview to see your comment before it ships

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

@jddunn
jddunn merged commit 7d8bc9e into master Oct 11, 2026
8 checks passed
@jddunn
jddunn deleted the fix/guarded-fetch-review branch October 11, 2026 00:49
github-actions Bot pushed a commit that referenced this pull request Oct 11, 2026
## [0.13.40](v0.13.39...v0.13.40) (2026-10-11)

### feat

* **auth:** OAuth for a web server: a redirect flow, sealed secrets and a sealed token store (#242) ([59a20d1](59a20d1))
* **voice-pipeline:** build a speech-to-text chain from provider entries (#176) ([29046f2](29046f2))

### fix

* **images:** a local A1111 edit reports the checkpoint the server rendered with (#279) ([3744044](3744044))
* **images:** the untrusted image fetch closes six gaps a security review found (#278) ([b99ecbc](b99ecbc))
* **memory:** the guarded fetch's deadline covers decoding, and a network refusal names no resolver detail (#280) ([7d8bc9e](7d8bc9e))

### docs

* eleventh round of audit follow-ups (two pages published, the agent() and gmi() guides aligned) (#264) ([d4d3c6d](d4d3c6d))
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