Short answer: enforce trip membership, document visibility, and source freshness inside retrieval, before ranking or generation. For a travel itinerary planner that watches health-advisory pages and alerts travelers when the text changes, each chunk should carry an immutable source version plus the access attributes needed to reject it. A model should never get a chunk the caller could not open directly.
This is the boring boundary I would protect first in a one-person SaaS. It keeps the weekly shipping loop focused on itinerary features instead of scattered permission patches. Retrieval-augmented generation can ground generated text in retrieved documents, but the application still owns authorization and freshness.
Small rule. Big consequence.
The constraint that changed the build
A travel planner mixes data with very different audiences. A public health notice can be readable by everyone. A family itinerary may be visible through a share grant. A corporate trip can belong to one workspace, while a draft note remains private to its owner. The same search phrase, such as yellow fever clinic, can match all four. Relevance does not decide permission.
The ingestion side adds a second problem. The system watches a web page, detects a change, splits the new representation into chunks, and makes those chunks searchable. If an old chunk and its replacement can both appear, an alert may quote withdrawn guidance. If chunks from two page versions are mixed in one answer, the citations look plausible while the answer describes no real version of the page. Freshness is therefore part of the retrieval contract, not a cleanup job after generation.
I use three checks because each has a separate owner: identity decides who is asking, the itinerary store decides which trip or workspace the caller can enter, and the ingestion catalog decides which source version is current. Combining them into one opaque allowed flag would ship faster for a week, then make revocation and debugging harder. The catch is extra metadata on every chunk. For a tiny public-only guide, that cost is pointless; plain search with no user documents is the better fit. Once private trips or shared links exist, the boundary earns its keep.
HTTP conditional requests help the watcher avoid treating an unchanged representation as a new version. A server can return 304 Not Modified when a conditional request shows that the selected representation has not changed. An ETag is one validator available for that job. A page that supplies neither validator can still be hashed after a successful fetch, but the polling interval and source terms remain product decisions. I'm not sure one interval works across government advisories and clinic pages; change history per source is the evidence needed to tune it.
How should a travel itinerary planner enforce access rules during retrieval?
Push authorization into the search query. Don't fetch the top 50 chunks, hand them to application code, remove 47, and ask the model to answer from three. That pattern wastes ranking capacity, makes result counts misleading, and creates more places where logs or traces can capture forbidden text. Deny-by-default authorization and permission checks on every request apply to the retrieval call too.
Filter first.
The three checks are concrete:
- Trip scope: the caller must own the trip, belong to its workspace, or present a valid share grant for that trip.
- Document visibility: a private note requires its owner; a workspace document requires membership; a public advisory permits anonymous reading.
- Current source version: watched-page chunks must match the active version recorded for that source. Revoked documents are excluded as well.
The first two checks answer "may this principal read this document?" The third answers "is this still the document we mean?" Keep them separate in storage even if the search backend compiles them into one filter. Revoking a member should change membership once, not trigger a rewrite of every chunk they once could read. Activating a new page version, by contrast, should be one atomic catalog update after all its chunks are indexed.
A shared-link token deserves the same discipline. Store a digest, trip scope, expiry, and allowed operation; don't turn possession of a link into access to every document owned by its creator. If the link grants itinerary viewing but not private notes, the retrieval filter must express that distinction. A 403 at the itinerary endpoint cannot repair text already placed in a model prompt.
No exceptions.
The smallest working implementation
The core can stay behind two interfaces. That lets a solo operator outsource the undifferentiated search machinery without outsourcing the access policy. The search adapter must accept a structured filter; a backend that only accepts a free-form query string is not suitable for private itinerary retrieval.
type Principal = { userId?: string; workspaceIds: string[]; sharedTripIds: string[]; }; type RetrievalFilter = { anyOf: Array< | { visibility: "public" } | { visibility: "owner"; ownerId: string } | { visibility: "workspace"; workspaceIds: string[] } | { tripId: string; shared: true } >; activeOnly: true; }; type Hit = { chunkId: string; sourceId: string; sourceVersion: string; text: string; score: number; }; interface SearchIndex { search(input: { query: string; filter: RetrievalFilter; limit: number; }): Promise<Hit[]>; } interface SourceCatalog { activeVersion(sourceId: string): Promise<string | undefined>; } function accessFilter(principal: Principal): RetrievalFilter { const anyOf: RetrievalFilter["anyOf"] = [{ visibility: "public" }]; if (principal.userId) { anyOf.push({ visibility: "owner", ownerId: principal.userId }); } if (principal.workspaceIds.length > 0) { anyOf.push({ visibility: "workspace", workspaceIds: principal.workspaceIds, }); } for (const tripId of principal.sharedTripIds) { anyOf.push({ tripId, shared: true }); } return { anyOf, activeOnly: true }; } The anyOf branches grant document visibility; the activeOnly clause is mandatory and maps to the catalog's active source version. The exact query language belongs in the adapter, where it can be tested without a model. Empty identity data still produces a public-only filter. Deny by default survives a missing session.
Retrieval then verifies the version again before prompt assembly. This second check is cheap defense against a catalog switch occurring between the search query and prompt construction. It does not replace the index filter.
async function retrieveAllowed( query: string, principal: Principal, index: SearchIndex, catalog: SourceCatalog, ): Promise<Hit[]> { const hits = await index.search({ query, filter: accessFilter(principal), limit: 12, }); const checked = await Promise.all( hits.map(async (hit) => { const active = await catalog.activeVersion(hit.sourceId); return active === hit.sourceVersion ? hit : undefined; }), ); return checked.filter((hit): hit is Hit => hit !== undefined); } Twelve is an example limit, not a universal retrieval target. Measure recall and prompt use on representative itinerary questions before changing it. More candidates can raise compute and latency while still failing to recover a badly split address or warning.
For the page watcher, create a version identifier from the normalized fetched representation, then chunk within that version. Preserve headings with their following prose, keep tables intact where practical, and attach the source URL and version to every chunk. Don't silently join the end of one advisory section to the beginning of another. The useful chunk is the smallest unit that can answer a question and retain its qualification, such as which travelers a warning applies to. Fixed character windows are easy, but they can detach "not recommended for children" from the recommendation it limits.
Publication order matters. Fetch successfully, normalize, compute the version, build every chunk, index them as inactive, and then switch the catalog's active version. Alert generation starts after that switch and compares two complete versions. If indexing stops before activation, readers continue to retrieve the prior complete version; no mixed document becomes current.
What I would change at scale
The first upgrade isn't a larger model. It is a policy decision point shared by direct document reads and retrieval, with decision logs that record principal ID, policy version, source IDs, and allow or deny outcomes without recording chunk text. This makes the key invariant testable: for the same principal and document, direct access and retrieval access agree.
Next, replace per-hit catalog lookups with a batch read or a version snapshot attached to the retrieval request. Keep the verification step. At higher update rates, use an outbox from the source catalog so version activation and the event that triggers alerts cannot drift apart. None of this changes the public behavior; it reduces coordination overhead.
Chunking should become source-aware only after evaluation shows where the generic splitter loses meaning. Health notices benefit from heading and table boundaries. Hotel policy pages may need list items kept with their introductory sentence. The trade-off is operational surface area: every special parser needs fixtures, change detection, and ownership. Shipping weekly means adding one only when failed retrieval cases pay for it in fewer support hours or better conversion, not because custom parsing feels sophisticated.
At this stage I would also test four negative cases on every deployment: an anonymous caller searching private notes, a removed workspace member repeating an old query, an expired share grant, and a query whose best semantic match belongs to an inactive page version. Each must return zero forbidden chunks before any prompt is built. Then test the positive twin of each case so a restrictive filter does not quietly erase valid results. 401 means authentication is required; 403 means the authenticated principal is not allowed. Search should not reveal forbidden titles, snippets, counts, or timing-sensitive details in either path.
Trade-offs and the ship decision
This design favors a clear security boundary and coherent source versions over maximum recall from a loosely filtered global index. It is suitable for private, shared, and workspace itineraries where watched health guidance can change. It is not suitable when access depends on arbitrary per-sentence policies that the index cannot express; stick with a database-backed candidate set or a policy-aware search system in that case. Likewise, a public static travel guide doesn't need membership joins or share grants.
There is latency in the second version check, metadata cost in the index, and work in testing revocation. Accept those costs before adding generation. A retrieval system that occasionally returns no answer is recoverable. One that gives a traveler another user's medical note is not.
My ship rule is plain: release when every retrieved chunk can be traced to one active source version and one explicit grant path, and when revocation tests pass without relying on the model. Then watch denial rate, empty-result rate, watcher lag, and the age of the active version. Those signals tell a solo builder where an hour will buy reliability. Model prompt tweaks come later.
References and Further reading
- Retrieval-Augmented Generation research paper: https://arxiv.org/abs/2005.11401
- RFC 9110, HTTP Semantics: https://www.rfc-editor.org/rfc/rfc9110
- MDN, ETag header: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/ETag
- OWASP Authorization Cheat Sheet: https://cheatsheetseries.owasp.org/cheatsheets/Authorization_Cheat_Sheet.html
- OWASP REST Security Cheat Sheet: https://cheatsheetseries.owasp.org/cheatsheets/REST_Security_Cheat_Sheet.html
- RFC 9111, HTTP Caching: https://www.rfc-editor.org/rfc/rfc9111

