PersonafileSpecification
On this page1. Purpose2. <pf:asset> Element3. <pf:area> Element (Optional Child of <pf:asset>)4. Validation & Security Rules5. PFDOM Node Model & Deterministic Serialization6. Renderer & Client Projections7. Backward Compatibility

Personafile Media Assets and Semantic Areas Specification


1. Purpose

Real-world personas (restaurants, shops, museums, venues, products, manuals) rely on visual media — menus, floorplans, product photos, brochures, and short videos. Standard Markdown (![alt](url)) cannot represent video, MIME types, placement roles, or structured knowledge anchored to parts of a graphic.

This specification defines two composable, HTML-inspired body elements:

Visual-First, Zero-RAG Knowledge

By storing pre-extracted text inside <pf:area> at authoring time (e.g., when a business uploads a menu graphic and marks regions), any client can simultaneously:

  1. Display the publisher's original graphic with interactive overlays to humans, and
  2. Feed the exact extracted region text straight into the LLM via PFRenderer in realtime — with zero RAG pipeline, zero vector database, and zero per-query vision-model inference cost.

Separation of concerns: <pf:area> carries purely semantic data (coordinates, label, link, extracted text). Visual presentation behaviors such as focus, zoom, background blur, or bottom-sheet inspection are client UX choices, not spec attributes.


2. <pf:asset> Element

<pf:asset id="menu-main" type="image/jpeg" src="assets/menu.jpg" role="welcome" alt="Bistro Lumière Menu">
  Daily printed menu photographed each morning.
</pf:asset>

<pf:asset id="kitchen-tour" type="video/mp4" src="assets/tour.mp4" poster="assets/tour-thumb.jpg" role="gallery" alt="Kitchen tour" />

2.1 Attributes

Attribute Required Description
src MUST URI reference to the media resource (resolved against canonical base URI per RFC 3986).
type SHOULD IANA MIME type (e.g., image/jpeg, image/png, image/webp, video/mp4, audio/mpeg, application/pdf).
alt SHOULD Short accessible description and fallback label for text-only clients/LLMs.
id Optional Stable identifier within the document for caching, deep linking, or tool references.
role Optional Semantic placement hint: welcome (featured in empty-chat/landing welcome media), gallery (default; shown in persona details/media viewer), or reference (background knowledge asset).
poster Optional Preview thumbnail URI reference for video or document assets (resolved per RFC 3986).
mask Optional URI reference (or lossless raster base64 data URI) to a lossless color-ID segmentation mask image (e.g., PNG generated by Segment Anything / SAM) sharing the aspect ratio of src. #000000 or transparent (alpha = 0) pixels represent unmapped background.
Inner text Optional Human- and LLM-readable caption or summary (text outside <pf:area> children).

3. <pf:area> Element (Optional Child of <pf:asset>)

Echoing HTML <area> without legacy <map>/usemap indirection or brittle pixel coordinates, <pf:area> nests directly inside <pf:asset> using resolution-independent normalized coordinates in [0.0, 1.0].

<pf:asset id="menu-main" type="image/jpeg" src="assets/menu.jpg" role="welcome" alt="Bistro Lumière Menu">
  <pf:area id="starters" x="0.05" y="0.10" w="0.42" h="0.40" label="Starters">
    French Onion Soup — €9. Roasted Beet Salad (V) — €11.
  </pf:area>
  <pf:area id="mains" x="0.52" y="0.10" w="0.43" h="0.55" label="Mains">
    Duck Confit — €22. Mushroom Risotto (V, GF) — €18.
  </pf:area>
  <pf:area id="wine" x="0.05" y="0.55" label="Wine List" pref="/wine-sommelier/" />
</pf:asset>

Video example with temporal range:

<pf:asset id="tour" type="video/mp4" src="assets/tour.mp4" poster="assets/tour.jpg" alt="Bakery tour">
  <pf:area id="oven" x="0.30" y="0.40" w="0.25" h="0.30" t="12.5" t_end="18.0" label="Wood-fired oven">
    Sourdough baked at 260°C every morning at 5am.
  </pf:area>
</pf:asset>

Real-world photo example with a pixel-accurate segmentation mask (e.g., generated by SAM — no x/y/w/h required):

<pf:asset id="living-room" type="image/jpeg" src="assets/room.jpg" mask="assets/room-mask.png" alt="Living Room">
  <pf:area id="lamp" mask="#E6194B" label="Arc Lamp" pref="/products/arc-lamp.pf">
    Brushed brass floor lamp — €290.
  </pf:area>
  <pf:area id="sofa" mask="#3CB44B" label="Linen Sofa" pref="/products/linen-sofa.pf">
    3-seat oatmeal linen sofa — €1,450.
  </pf:area>
</pf:asset>

3.1 Attributes

Attribute Required Description
mask Optional 6-digit hex color key (#RRGGBB, case-insensitive, normalized to uppercase #RRGGBB) identifying the entity's exact pixels inside the parent <pf:asset mask="..."> image. When mask is present, the area's shape is "mask" and x, y, w, h are not required.
x, y MUST (unless mask is set) Normalized origin coordinates in [0.0, 1.0] (top-left (0, 0) to bottom-right (1, 1)).
w, h Optional Normalized width and height in (0.0, 1.0]. When both w and h are present (and mask is absent), the area is a rectangular region. When both are omitted (and mask is absent), the area is a point / pin marker. Specifying only one of w or h is invalid and emits a diagnostic.
label SHOULD Short title for the region, mask entity, or pin.
id Optional Stable semantic identifier within the parent <pf:asset> (used for PFDOM queries and LLM focus references).
t, t_end Optional Video/audio timestamp and optional end time in seconds (t >= 0, t_end >= t).
pref Optional Navigable link to another Personafile (resolved per RFC 3986 using the exact same rules as <pf:a pref="...">).
Inner text Optional Pre-extracted grounded text describing the region's content for realtime LLM context and user inspection.

4. Validation & Security Rules

  1. URL sanitization: src, poster, mask (on <pf:asset>), and pref MUST be resolved against the document's canonical base URI per RFC 3986 and restricted to safe schemes (https:// and relative references; http:// only when allowInsecureHttp is enabled). For self-contained single-file Personafiles, src, poster, and <pf:asset mask> MAY also use raster-only base64 data URIs (data:image/(png|jpeg|jpg|webp|gif);base64,<payload>; lossless image/png or image/webp SHOULD be used for masks). Unsafe schemes (javascript:, file:, vbscript:, data:image/svg+xml, data:text/html) MUST be rejected with a diagnostic (UNSAFE_ASSET_SRC, UNSAFE_ASSET_MASK), and data: URIs MUST NOT be permitted on <pf:area pref>.
  2. Coordinate & mask bounds:
    • When mask is absent on <pf:area>: x and y MUST be finite numbers in [0.0, 1.0]. When present, w and h MUST be finite numbers in (0.0, 1.0]. If x + w > 1.0 or y + h > 1.0, parsers MUST emit a diagnostic warning and clamp the effective bounds to 1.0.
    • When mask is present on <pf:area>: its value MUST match #RRGGBB (6 hexadecimal digits; invalid values emit INVALID_AREA_MASK_COLOR). If the parent <pf:asset> has no valid mask URI, parsers SHOULD emit MISSING_ASSET_MASK.
    • Lossless & nearest-neighbor requirement: Mask images MUST be encoded without lossy compression (use PNG or lossless WebP; avoid JPEG). Clients sampling or rendering masks MUST use nearest-neighbor sampling (no bilinear interpolation or anti-aliasing) to preserve exact color-ID boundaries, and SHOULD cap decoded mask resolution (e.g., <= 640px max side) for low memory and fast O(1) pixel hit-testing.
    • When present, t MUST be >= 0.0, and t_end (if present) MUST be >= t.
  3. Untrusted provenance: All captions, alt text, label values, and <pf:area> inner text inherit the document's untrusted provenance and MUST be treated as untrusted data (never privileged system instructions).
  4. Embedded assets: <pf:asset> elements inside <pf:embed> MUST resolve src, poster, mask, and pref against the embedded document's canonical base URI, not the parent document's URI.

5. PFDOM Node Model & Deterministic Serialization

Conformant PFDOM libraries (pfdom-js, pfdom-kt) implementing this extension MUST expose:


6. Renderer & Client Projections

Consumer Recommended Projection
PFRenderer (LLM) Projects each asset's alt/caption and its <pf:area> labels + extracted text into structured prompt context (e.g., [Asset: Menu (image/jpeg)] followed by - Starters: French Onion Soup — €9...), and surfaces <pf:area pref="..."> as [Personafile: Label](url) links. Inline data: base64 payloads and mask URIs/hex colors MUST NOT be dumped into LLM prompts (emit inline for data: sources). Enables realtime grounded answers with zero RAG.
MarkdownRenderer Renders image assets as Markdown images (![alt](src)), video/file assets as descriptive links, and <pf:area> items as a structured bullet list beneath the asset.
HTMLRenderer / Web Client Renders <img> / <video poster="..."> wrapped in a responsive container with percentage-positioned interactive overlays for rect/point areas, and optional canvas pixel-mask hit-testing / silhouette highlight for mask areas (data-pf-mask + data-pf-mask-color).
Mobile Client Maps <pf:asset role="welcome"> into empty-chat welcome media, all assets into PersonaDetailsActivity, and <pf:area> into native focus-region / point-marker / pixel-mask silhouette spotlight views (e.g., FocusedImagePreviewView).

7. Backward Compatibility

Minimal PERSONAFILE/1.0 parsers that do not implement this extension MUST continue to parse the document without fatal errors, ignoring unknown <pf:asset> and <pf:area> tags or degrading gracefully to their inner text.