---
title: "Discussion on \"The Steps Ran in Order. Generation Still Read the Wrong Document.\" | Hashnode"
description: "Discussion on \"The Steps Ran in Order. Generation Still Read the Wrong Document.\". raju_dandigam left a comment on my retrieval piece that stuck with me. The order check I had in place only proves the steps ran in sequence. It cannot tell me whether generation actually used what ret"
url: "https://hashnode.com/posts/the-steps-ran-in-order-generation-still-read-the-wrong-document/6b01106d937f3f6d0d47f1a9"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [The Steps Ran in Order. Generation Still Read the Wrong Document.](https://aheadkit.hashnode.dev/the-steps-ran-in-order-generation-still-read-the-wrong-document?utm_source=hashnode&utm_medium=feed)

raju\_dandigam left a comment on my retrieval piece that stuck with me. The order check I had in place only proves the steps ran in sequence. It cannot tell me whether generation actually used what ret

5d ago · 6 min read · aheadkit.hashnode.dev  
Read the article

-   [#ai](https://hashnode.com/tag/ai)
-   [#rag](https://hashnode.com/tag/rag)
-   [#testing](https://hashnode.com/tag/testing)
-   [#programming](https://hashnode.com/tag/programming)

## Written by

[Abdus Salam](https://hashnode.com/@aheadkit)

@aheadkit

  
[View profile](https://hashnode.com/@aheadkit)

## Responses 6

Markdown supported · ⌘↵ to post

[Ascendra Ventures](https://hashnode.com/@ascendra-ventures)

[4d ago](https://hashnode.com/posts/the-steps-ran-in-order-generation-still-read-the-wrong-document/6b01106d937f3f6d0d47f1a9/comment/6b0256c0591e5f2622c40dbd)

"An order check only proves the steps ran in sequence" is a useful thing to have written down, and comparing the retrieval ID with the ID generation actually received is such a cheap assertion that it is surprising it is not standard.

At Ascendra Ventures we built a research assistant for a global nonprofit that tests a theory of change against published evidence before committing money. It fans a query out across sources such as Google Scholar and the World Bank, builds an editable evidence library, and drafts an impact pathway with documents tagged to each branch. Keeping each document attached to the branch it supports is what lets the researcher stay in charge: they prune subtopics, add documents, fire follow up queries and regenerate with RAG, and they can always see which source sits behind which part of the answer.

The superseded 30 day refund policy is a perfect test document. Has the ID comparison caught anything in a real system yet, or only in the setup you built for it?

[Abdus Salam](https://hashnode.com/@aheadkit)

[4d ago](https://hashnode.com/posts/the-steps-ran-in-order-generation-still-read-the-wrong-document/6b01106d937f3f6d0d47f1a9/comment/6b0256c0591e5f2622c40dbd#reply-6b027151211152c8f1d41f63)

Only in the setup so far, honest answer — the 4 out of 4 was my little six-document rig, not a real system. Your research assistant sounds like the shape where it'd actually matter though, documents tagged to branches is basically the ID check done by hand. Do the branches ever share a slot like that, or does each one carry its own documents from the start?

[Ahmet Özel](https://hashnode.com/@ahmetozel)

[4d ago](https://hashnode.com/posts/the-steps-ran-in-order-generation-still-read-the-wrong-document/6b01106d937f3f6d0d47f1a9/comment/6b0256c0591e5f2622c40dbd#reply-6b02b886fa93654d053060d2)

They solve different halves of the problem. An immutable bundle prevents in-place overwrites between steps, so concurrent requests or shared references cannot silently mutate the document while generation is waiting to run.

The ID check is still worth keeping as a boundary assertion even with immutable objects, because it catches wiring mistakes—like a retry loop or response cache pairing the wrong immutable bundle with the current request ID. Prevention and verification work best together.

[Abdus Salam](https://hashnode.com/@aheadkit)

[4d ago](https://hashnode.com/posts/the-steps-ran-in-order-generation-still-read-the-wrong-document/6b01106d937f3f6d0d47f1a9/comment/6b0256c0591e5f2622c40dbd#reply-6b02c8a296f52ad21778f9d2)

Prevention and verification together is the honest answer — I was treating them as either-or and they're not. The response cache pairing the wrong bundle is the concrete one, that's a wiring mistake no freeze can see. Have you actually watched a cache do that, or is it the failure you're guarding against?

[Ahmet Özel](https://hashnode.com/@ahmetozel)

[5d ago](https://hashnode.com/posts/the-steps-ran-in-order-generation-still-read-the-wrong-document/6b01106d937f3f6d0d47f1a9/comment/6b0174eb50945b7d534e4355)

Having four out of eight queries silently answer with the wrong document while every timestamp assertion stays green is a great demonstration of why ordering logs are not provenance. In concurrent web workers, module-level caches or request-scoped globals repurposed across async hops create this exact overwrite hazard.

Passing an immutable retrieval bundle by value directly into generation removes the shared slot completely, and comparing the retrieved document ID against the consumed ID at the boundary turns any accidental mutation into a hard test failure rather than a plausible-looking wrong answer.

[Abdus Salam](https://hashnode.com/@aheadkit)

[5d ago](https://hashnode.com/posts/the-steps-ran-in-order-generation-still-read-the-wrong-document/6b01106d937f3f6d0d47f1a9/comment/6b0174eb50945b7d534e4355#reply-6b01a36f2c27664fcdcfc63c)

The ID comparison is already in the piece, it caught 4 out of 4 while the timing check stayed green on all of them — so that half of your fix is proven. The by-value bundle is the part I haven't tried, my third version just hands generation the object instead of the slot, and the swaps stop mattering. Going to run the by-value version against a mutation between the steps and see if it buys anything over holding the object. In your setup, is the bundle doing the work, or is the ID check?
