On this page
1. Design Goal & Terminology2. Deterministic Rendering & Runtime Pipeline3. PFDOM Schema (Single Document Only)4. PersonaBrowser Runtime Schema, Subsystems & Rules5. End-to-End Walkthrough (Book #42 → borrow() → Loan #1 → go_back())Personafile
Renderer, PFDOM & PersonaBrowser Specification
Status: Proposed specification — Working Draft
0.1
Maturity: Experimental; client-side runtime companion
to Personafile Format specification
Informed by: HTML_DOM_to_PFOM_Comparison.md
(US-090, updated by US-091,
US-092) and Agentic_MVC_Personafile_View_Conformance_0.1.md
Scope: Deterministic client-side rendering of a
validated PERSONAFILE/1.0 document into
PFDOM (Personafile Document Object Model), plus the
PersonaBrowser runtime shell
(tabs, history_stack,
open_persona, go_back, trail,
runTools, ResourceLoader,
CookieJar, VirtualConsole, and safe re-fetch
rules)—without modifying PFS 1.0 wire syntax.
1. Design Goal & Terminology
- Personafile (PFS 1.0): The server-rendered,
content-recognized UTF-8 wire format
(
PERSONAFILE/1.0). - Personafile Renderer: A deterministic, stateless
client-side engine (analogous to a browser's HTML/DOM parser) that
consumes a single validated
personafile-core::Document+Provenanceand projects it into a PFDOM (context_text+document_tools+links), stripping raw markup clutter and emitting non-fatal diagnostics toVirtualConsole. - PFDOM (Personafile Document Object Model): The
structured model of a single rendered document
(
uri,persona_id,name,trust,cache_policy,context_text,links,document_tools). Like HTML'sdocument, PFDOM does not own tabs, navigation history, execution policy, or conversation trail. PersonaBrowser(Browser / Navigation Runtime): The stateful client-side host (analogous towindow/JSDOM) that managessession_id,tabs,active_tab_id, per-tabhistory_stack,trail,runToolspolicy,ResourceLoader,CookieJar,VirtualConsole, andnavigation_tools(open_persona(url),go_back()), holding oneactive_pfdomper tab.
Core Invariant: Raw
PERSONAFILE/1.0parsing, validation, and<pf:embed>composition MUST be performed deterministically bypersonafile-corebefore Personafile Renderer constructs aPFDOM. An LLM MUST NOT be used as the raw security/syntax parser.
2. Deterministic Rendering & Runtime Pipeline
- Fetch (
PersonaBrowser.resourceLoader+cookieJar):ResourceLoaderretrieves bytes from a URI (following redirects to establishcanonical_uri, honoringCache-Control/Vary, and keeping cookies, CSRF tokens, and API credentials inCookieJaroutsidePFDOMand LLM context). - Parse & Compose
(
personafile-core): Validates thePERSONAFILE/1.0envelope, resolves the post-redirect canonical URI inProvenance, and composes any<pf:embed>blocks underResourceLoadercycle/depth/SSRF limits. - Project (
Personafile Renderer→PFDOM):- Identity & Prose →
PFDOM.context_text: EmitsPersona-ID,Name, canonicaluri,trust="untrusted", and clean tag-free prose (replacing<pf:a>inline labels with readable link references and omitting raw<pf:form>XML boilerplate). <pf:a pref="...">→PFDOM.links: Resolves relativepreftargets against the host document'sProvenance.canonical_uri—except inside<pf:embed>, where relative<pf:a pref="...">targets MUST resolve against the embedded document's ownProvenance.canonical_uri.<pf:form>(top-level only) →PFDOM.document_tools: Compiles each declared<pf:form>into a typed callable Tool bound to(method, resolved_action, params). Embedded<pf:form>and<pf:api>elements inside<pf:embed>MUST NOT enterPFDOM.document_toolsand are logged toVirtualConsole.
- Identity & Prose →
- Mount & Inject (
PersonaBrowser):- Places the new
PFDOMintoactive_tab.active_pfdomand assigns a freshactive_tab.mount_id. - Applies the
runToolspolicy ("none"|"confirm"|"auto") to computemounted_tools = runtime.navigation_tools + gated(active_tab.active_pfdom.document_tools, runTools). - Passes
[System Rules] + [active_tab.active_pfdom.context_text] + [runtime.trail]andtools = mounted_toolsto the LLM. Document-derived prose (context_text),document_toolsdescriptions, andtrailsummaries MUST all be treated as untrusted model input, never promoted toSystem Rules.
- Places the new
3. PFDOM Schema (Single Document Only)
A PFDOM instance represents one
rendered PERSONAFILE/1.0 document and has no browsing or
history fields:
{
"uri": "string (canonical post-redirect URI)",
"persona_id": "string",
"name": "string",
"trust": "untrusted",
"cache_policy": "string | null",
"context_text": "string",
"links": [
{ "label": "string", "url": "string" }
],
"document_tools": [
{
"name": "string",
"description": "string",
"method": "GET | POST | LOCAL",
"action": "string | null",
"params": {}
}
]
}4.
PersonaBrowser Runtime Schema, Subsystems & Rules
PersonaBrowser wraps PFDOM with browsing,
tab, history, execution policy, and session state:
{
"session_id": "string",
"run_tools": "none | confirm | auto",
"active_tab_id": "string",
"tabs": {
"tab-1": {
"mount_id": "string",
"history_stack": ["string"],
"active_pfdom": "<PFDOM>"
}
},
"navigation_tools": ["open_persona(url)", "go_back()"],
"trail": ["string"]
}4.1
PersonaBrowser Subsystems
(jsdom-Inspired)
runTools("none" | "confirm" | "auto"): Environment-level tool execution policy enforced at dispatch (analogous tojsdom.runScripts)."none"(Read-Only / Inspect):PFDOMis still rendered, butdocument_toolsexecution is blocked (not mounted or dispatched)."confirm"(Supervised Default): Approves a specific(tab_id, mount_id, tool_name, resolved_action, params)call; immediately before dispatch,PersonaBrowserMUST recheck(tab_id, mount_id)."auto"(Autonomous): Skips interactive approval while still enforcingResourceLoaderorigin/SSRF rules,CookieJarisolation,(tab_id, mount_id)currency, and server409checks.LOCALAction Classification: Tools withmethod: "LOCAL"are non-network host/client actions (never dispatched viaResourceLoaderand never carryingCookieJarcredentials); they remain bound to(tab_id, mount_id)and gated byrunTools.
ResourceLoader: Single pluggable fetch layer forGET/POST, redirect tracking (canonical_uri),Cache-Control/Varyhandling, and<pf:embed>SSRF/depth/cycle enforcement.CookieJar: Stores session cookies, CSRF tokens, and API credentials completely outsidePFDOM, LLM prompts, and.pfnav.jsonsnapshots (HttpOnly-equivalent).VirtualConsole: Captures non-fatal parser/renderer warnings (e.g. stripped<pf:form>inside<pf:embed>, unresolved relativepref) without pollutingPFDOM.context_text.
4.2 Navigation, Snapshot & Conflict Rules
- Single-Tab Baseline & Optional Multi-Tab Mode:
- Single-tab mode (
tabscontaining one default tab, e.g."tab-1") is the required baseline so LLM context stays focused. - A Runtime MAY support multiple
tabsandactive_tab_id. When multi-tab mode is active, ONLYtabs[active_tab_id].active_pfdom.document_tools(plusnavigation_tools) MUST be mounted for the LLM so background tabs cannot be triggered unintentionally.
- Single-tab mode (
- SPA-Style In-Place Replacement & Mount-Bound
Dispatch:
- Every
open_persona(url)or<pf:form>mutation response MUST replacetabs[active_tab_id].active_pfdomin place, mint a newmount_id, and recomputemounted_toolsfrom scratch, unmounting alldocument_toolsfrom the previous document. - Every pending tool call MUST bind to its originating
(tab_id, mount_id). Both(tab_id, mount_id)MUST be rechecked after confirmation and immediately before dispatch; if either changed (e.g., navigation occurred while confirmation was open), the call MUST be aborted with no HTTP request sent. If an in-flight response arrives aftermount_idhas changed, it MUST be discarded and MUST NOT replace the neweractive_pfdom. runtime.trailretains compact user/assistant/action summaries (marked untrusted) and MUST NOT retain oldPERSONAFILE/1.0bodies or old unmounted tool schemas.
- Every
- Atomic History Commits,
go_back(), and304Revalidation:- History mutations (
pushon navigation,popongo_back()) MUST commit atomically with the newly renderedPFDOM. - Calling
go_back()MUST fetch and validate the previous URI before poppingtabs[active_tab_id].history_stack; if fetch or validation fails,history_stackremains unchanged. ResourceLoaderMAY send conditional revalidation (If-None-Match/If-Modified-Since) and accept304 Not Modifiedongo_back()only whenPersonaBrowserholds the validated cached response for that URI (and MUST still re-run Personafile Renderer / re-mount from scratch).
- History mutations (
- Snapshots & Resume (
.pfnav.json/ Session Snapshot):- A Runtime MAY serialize session state (
session_id,active_tab_id,history_stack,trail) to a snapshot file for pause/resume and auditability. - Snapshot files MUST NOT store session cookies, CSRF tokens, or
credentials (
HttpOnly-equivalent separation). - On resume,
PersonaBrowserMUST fetch a fresh200response body from the server (304is not permitted without an in-memory validated cache) and render a freshPFDOMbefore mounting any tools.
- A Runtime MAY serialize session state (
- Error & Conflict View Updates (
401/403/409):- On
401or403,active_pfdomMUST NOT disclose private state or mount privilegeddocument_tools. - On
409 Conflict(e.g., stale borrow or renewal blocked by a waiting reservation), the Runtime replacestabs[active_tab_id].active_pfdomwith a newly renderedPFDOMcontaining the server's explanation and any recoverylinks(such as returning to the current entity view).
- On
5.
End-to-End Walkthrough (Book #42 → borrow() →
Loan #1 → go_back())
Step 1 —
open_persona("/books/42/")
- Browser Runtime:
tabs["tab-1"].history_stack:["/library/", "/books/42/"]mounted_tools:[ open_persona(url), go_back(), borrow() ]
tabs["tab-1"].active_pfdom(Document):uri:"/books/42/",persona_id:"library:book:42"context_text:"1 of 1 copies currently available..."document_tools:[ borrow() ]
Step
2 — borrow() (POST /books/42/borrow/ →
201 Created, Location: /loans/1/ →
GET /loans/1/)
- Browser Runtime (
PersonaBrowser):- Renders
Loan #1from theGET /loans/1/response, swapsactive_pfdom(mount_id: "m-2"), and then pushes"/loans/1/"ontotabs["tab-1"].history_stack:["/library/", "/books/42/", "/loans/1/"] mounted_tools:[ open_persona(url), go_back(), renew(), return_loan() ](borrow()is unmounted!)
- Renders
tabs["tab-1"].active_pfdom(Document):uri:"/loans/1/",persona_id:"library:loan:1"context_text:"Status: active. Due date: 2026-12-02..."document_tools:[ renew(), return_loan() ]
Step
3 — go_back() (fetches & validates
"/books/42/" before popping "/loans/1/")
- Browser Runtime (
PersonaBrowser):- Fetches
GET /books/42/(or revalidates304against validated cache), rendersPFDOM, swapsactive_pfdom(mount_id: "m-3"), and pops"/loans/1/":tabs["tab-1"].history_stack:["/library/", "/books/42/"] mounted_tools:[ open_persona(url), go_back() ](borrow()is absent because 0 copies remain!)
- Fetches
tabs["tab-1"].active_pfdom(Document):uri:"/books/42/",persona_id:"library:book:42"context_text:"0 of 1 copies currently available..."document_tools:[]
5.1 Conformance Test — Stale Confirmation After Navigation
- Under
runTools: "confirm", requestborrow()onBook #42(tab-1,mount_id: "m-1"). - While the confirmation prompt is open, navigate away
(
open_persona("/library/")), advancingtab-1tomount_id: "m-2". - Approve the pending
borrow()confirmation. - Expected:
PersonaBrowserdetectsm-1 != m-2before dispatch, aborts the call, and sends noPOST /books/42/borrow/.