Skip to main content

CitationOrigin

@forge/monorepo


@forge/monorepo / backend/src / CitationOrigin

Type Alias: CitationOrigin

CitationOrigin = { chunkId: string; chunkIndex: number; kind: "retrieval"; locator?: string; sourceId: string; sourceType: "file" | "artifact" | "message" | "external"; } | { kind: "web"; title?: string; url: string; }

Defined in: backend/src/core/content-parts.ts:180

Where a cited passage came from (#137).

A closed union with exactly two arms, and one shape for both is AC-6: the frontend renders one thing whether a claim came from an indexed document or from the web. Two part types would mean two renderers, two schemas, and eventually two behaviours for "click the citation".

The arms differ in what resolving means — a chunk id resolves inside this platform, a URL resolves outside it — and that difference is real, so it is a discriminant rather than a pile of optional fields.

Union Members

Type Literal

{ chunkId: string; chunkIndex: number; kind: "retrieval"; locator?: string; sourceId: string; sourceType: "file" | "artifact" | "message" | "external"; }

chunkId

readonly chunkId: string

The chunk, which is what makes AC-2's "specific passage" resolvable rather than aspirational.

chunkIndex

readonly chunkIndex: number

kind

readonly kind: "retrieval"

locator?

readonly optional locator?: string

The heading path the chunker found, when there was one.

sourceId

readonly sourceId: string

sourceType

readonly sourceType: "file" | "artifact" | "message" | "external"


Type Literal

{ kind: "web"; title?: string; url: string; }

kind

readonly kind: "web"

title?

readonly optional title?: string

url

readonly url: string

The URL that was actually read, after redirects — not the one requested.

A citation must open what was read. ShareFlow's safefetch exists because the two differ: a public URL can redirect somewhere else entirely, and citing the request would cite a page nobody looked at.