Short answer: keep every fetched travel page as an immutable, content-addressed version, and let retrieval return the cited version rather than the latest row. That choice makes a changed rail timetable or visa page visible to the planner instead of silently changing an already grounded answer.
I treat this as an architecture decision record, not a vector-store shopping list. The system watches web pages, records a diff, and alerts the itinerary service; only then does a retrieval job update the evidence set used by a response. In a payment ledger I would never overwrite a posted entry, and the same exactly-once mindset belongs here: a citation must be reproducible after a source changes.
Invariants and failure boundaries
The invariant is simple: (source URL, observed content hash) identifies one document version. A version has the fetch timestamp, canonical URL, HTTP validators when available, normalized text, and a stable set of chunk identifiers. An itinerary answer stores the version IDs it used. Deleting or replacing that evidence is an audit failure, even if the new page looks equivalent. I've found that this is the line teams skip when a product manager asks for a “current” answer: current is a query policy, not permission to erase history. Keep the old version queryable, give the planner a freshness budget, and record the policy decision alongside the citation so a reviewer can distinguish an intentionally accepted stale source from an accidental one.
There are two different boundaries. A fetch can succeed while parsing produces an empty page, and a parser can succeed while the page's meaning has changed under the same URL. Neither event should rewrite prior evidence. Emit an alert with the old and new hashes, mark the new version pending review, and let a policy decide whether it enters retrieval.
Exactly once matters here.
My first implementation compared rendered HTML strings. A cookie banner changed every hour, so the alert stream became useless. The fix was to strip boilerplate, preserve headings and tables, then hash normalized text plus selected metadata. I still keep the raw response for audit; normalization is a retrieval aid, not proof of what the publisher served.
How should a travel itinerary planner version documents for grounded retrieval?
Use a small relational ledger beside the index. The ledger owns lineage and state; the search index owns candidate ranking. A chunk row points to version_id, its character offsets, and a checksum. Retrieval is therefore a join from a semantic hit to an immutable citation, rather than a guess based on a mutable document ID.
| Option | Strength | Failure boundary | Suitable use |
|---|---|---|---|
| Overwrite one document | Easy writes | Old answers cannot be reconstructed | Ephemeral search suggestions |
| Append immutable versions | Auditable and replayable | Storage and retention grow | Itinerary answers and alerts |
| Keep only a diff | Compact | A citation may need missing context | Change dashboards, not final evidence |
The critical path below is deliberately boring. The unique key makes a repeated webhook harmless, and the transaction commits the version before a worker publishes chunks. A queue retry can happen; a second version cannot be minted for the same observed hash.
package versioning
import (
"context"
"crypto/sha256"
"encoding/hex"
"fmt"
)
type Page struct {
URL string
Normalized string
FetchedAtUTC string
}
type Store interface {
InsertVersion(ctx context.Context, url, hash, text, fetchedAt string) (created bool, versionID string, err error)
EnqueueIndex(ctx context.Context, versionID string) error
}
func Observe(ctx context.Context, store Store, page Page) (string, error) {
digest := sha256.Sum256([]byte(page.Normalized))
hash := hex.EncodeToString(digest[:])
created, id, err := store.InsertVersion(ctx, page.URL, hash, page.Normalized, page.FetchedAtUTC)
if err != nil {
return "", err
}
if !created {
return id, nil // duplicate observation: exactly-once effect
}
if err := store.EnqueueIndex(ctx, id); err != nil {
return "", fmt.Errorf("queue version %s: %w", id, err)
}
return id, nil
}
The worker chunks by headings and keeps offsets into the normalized text. It attaches source URL, version ID, heading, and fetch time to every search result. The answer generator may quote only those results; if a result has no citation metadata, it is rejected before generation. This is grounding as an enforceable data contract, not a prompt suggestion. In practical terms, a train timetable hit carries the exact table heading and character offsets, while a visa-policy hit carries the publication date and the prior hash used for the diff. The planner can then say “this restriction came from version 7,” and an operator can retrieve that text even after the publisher edits the page. Without this join, a reranker may return a plausible chunk from a newer embedding, and the generated itinerary will look well sourced while pointing at evidence the user never saw.
Choosing freshness, alerts, and retention
A page's importance should determine its polling interval. A same-day train cancellation deserves a short interval; a museum description can tolerate a long one. Schedule by source policy, then record both requested and actual fetch times so an operator can explain an alert that arrived late.
Diffs need thresholds. Ignore whitespace-only changes, but never ignore a changed date, price, restriction, or table cell in a travel source. A useful alert includes a compact diff and links to both versions. Do not send the model only the diff: it lacks unchanged context and can turn a deletion into an invented sentence.
Retention is a compliance decision. Keep evidence for the period in which itinerary decisions may be disputed, hash sensitive request metadata, and restrict raw responses if they contain personal data. I am not sure one retention window fits every jurisdiction; legal review and the publisher's terms should resolve that uncertainty before launch.
The rejected option and its valid use case
We rejected “latest document plus a change log.” It appears cheaper, but a replay must reconstruct text from a sequence of patches, and one missing patch makes a citation unverifiable. It is reasonable for an internal activity feed where users need to see that something changed, not for a grounded answer that must show exactly what the planner saw.
A vector index is also not the source of truth. Embeddings can be rebuilt, models can change, and approximate nearest-neighbor results are not a lineage system. Keep the index disposable, pin the embedding model in job metadata, and test replay from the ledger into a fresh index before each migration.
The catch is operational weight: immutable storage, parser tests, and review queues cost more attention than overwriting a row. This design is not suitable when the product only offers unquoted, best-effort suggestions; stick with a simpler cache there. For an itinerary that cites visa rules or transport times, the extra boundary is the part that prevents a polished answer from becoming a stale one.
Before shipping, I verify that a repeated fetch creates no duplicate version, a changed heading yields a new chunk lineage, and an answer can be regenerated from its recorded version IDs while the live page has moved on. I also inject a parser-empty result, a queue retry, and a clock skew into tests. The expected behavior is an explicit alert or delayed indexing, never silent replacement.
That is the practical comparison: immutable versions maximize auditability and grounded citations; overwrite models maximize simplicity; diff-only models maximize compact change views. Choose according to whether a human must later prove which travel fact shaped an itinerary.
Top comments (0)