PersonafileSpecification
On this page1. Core Concept Comparison Matrix2. Architectural Boundary: PFDOM vs. PersonaBrowser3. Security & Lifecycle Rules Learned from Browsers

HTML DOM & Web Browser Concepts → PFDOM & Navigation Runtime Comparison

Status: Working Analysis (US-090, updated by US-091, US-092)
Purpose: Identify the strongest architectural, lifecycle, and security concepts from the HTML DOM, jsdom, and modern Web Browsers—and cleanly separate PFDOM (Personafile Document Object Model) from PersonaBrowser (Browser / Navigation Runtime)—to make Personafile_Renderer_PFOM_Specification_0.1.md implementation-ready.


1. Core Concept Comparison Matrix

HTML DOM / Browser Concept Role in the Web Personafile Architecture Counterpart Target Layer Decision (Adopt / Omit)
Document Tree (DOM) Parsed tree of <head>, <body>, <a>, <form> Parsed personafile-core::Document projected into PFDOM (context_text, links, document_tools) PFDOM (Document) Adopt — keep a typed, structured single-document projection rather than raw string concatenation.
ARIA / Accessibility Tree Projects clean semantic roles & labels for assistive readers Personafile Renderer strips <pf:...> syntax noise and emits clean context_text + typed document_tools PFDOM (Document) Adopt — LLM is an "assistive/semantic reader" that thrives on clean affordances.
Canonical Base URI (document.URL) Post-redirect document URI used to resolve relative links/forms PFDOM.uri from personafile-core::Provenance PFDOM (Document) Adopt — relative <pf:a> and <pf:form action="..."> targets resolve against Provenance.canonical_uri.
Sandboxed <iframe> Isolation Embedded frame cannot inherit top-level permissions or forms <pf:embed> prose enters PFDOM.context_text, but embedded <pf:form> / <pf:api> MUST NOT enter PFDOM.document_tools PFDOM (Document) Adopt — prevents embedded untrusted content from smuggling tools.
Browser Chrome vs. Page Sandbox Untrusted page cannot modify browser address bar, bookmarks, or OS permissions Host system prompt & runtime credentials are strictly isolated from PFDOM (trust="untrusted") Browser Runtime (Shell) Adopt — never promote PERSONAFILE/1.0 content to system instructions.
Mount / Unmount on Navigation Navigating away unmounts the old page's <form> buttons and listeners Navigating or mutating swaps tab.active_pfdom in place and unmounts all previous document_tools Browser Runtime (Shell) Adopt — prevents stale tool calls from earlier views.
SPA history.pushState + Back Single active view + ordered URI history stack tab.history_stack + go_back() (default single-tab mode) Browser Runtime (Shell) Adopt — keeps LLM context small and focused; history belongs to the browser, not the DOM.
Browser Tabs Parallel independent views for multitasking Optional runtime.tabs + active_tab_id (only active tab's active_pfdom.document_tools mounted) Browser Runtime (Shell) Adopt (Optional) — tabs belong to the browser shell; only active tab mounts tools to avoid cross-tab confusion.
HTTP Cache & Revalidation (Cache-Control, Vary) Prevents stale or cross-user cached responses Re-fetch URI on go_back() and session resume; honor PFDOM.cache_policy (private, no-store) & Vary: Cookie Browser Runtime (Shell) Adopt — saved session snapshots are bookmarks, never live truth.
Ambient Credentials (HttpOnly Cookies / jsdom.CookieJar) HttpOnly cookies & auth headers held by browser, invisible to page DOM/JS PersonaBrowser.cookieJar holds cookies, CSRF tokens, and API keys outside PFDOM and LLM context PersonaBrowser (Shell) Adopt (HttpOnly-equivalent) — LLM never sees raw session cookies or CSRF tokens.
Pluggable Network Fetcher (jsdom.ResourceLoader) Centralizes fetches, redirects, caching, and origin/subresource policy PersonaBrowser.resourceLoader handles GET/POST, redirects, Cache-Control, and <pf:embed> SSRF/depth limits PersonaBrowser (Shell) Adopt — keeps network policy and redirect tracking out of PFDOM.
Diagnostic Channel (jsdom.VirtualConsole) Captures non-fatal parser/runtime warnings outside the DOM PersonaBrowser.virtualConsole logs stripped <pf:embed> forms or malformed pref warnings outside PFDOM.context_text PersonaBrowser (Shell) Adopt — avoids polluting LLM prompt context with parser diagnostics.
Execution Policy (jsdom.runScripts → runTools) Environment dial (none / outside-only / dangerously) controlling script execution PersonaBrowser.runTools ("none" | "confirm" | "auto") gates mounting/executing PFDOM.document_tools PersonaBrowser (Shell) Adopt — execution policy belongs on PersonaBrowser, keeping PFDOM purely declarative.
Inline <script> / Client DOM Mutation Arbitrary JS mutating the DOM locally Executable client scripts inside Personafile — Omit — Personafile is declarative; all state transitions occur on the server.
CSS / Visual Layout Tree Pixels, colors, flex/grid boxes Visual styling metadata — Omit — irrelevant to LLM token generation.

2. Architectural Boundary: PFDOM vs. PersonaBrowser

  1. PFDOM (Single-Document Scope, Like document):
    • Models one rendered PERSONAFILE/1.0 document at a point in time (uri, persona_id, name, trust, cache_policy, context_text, links, document_tools).
    • Produced deterministically and statelessly by Personafile Renderer from personafile-core::Document + Provenance.
    • Has no knowledge of tabs, history_stack, go_back(), conversation trail, runTools, or HTTP cookies.
  2. PersonaBrowser (Browser / Navigation Runtime, Like window / JSDOM):
    • Owns session_id, tabs (each holding history_stack and active_pfdom), active_tab_id, trail, navigation_tools (open_persona(url), go_back()), runTools, resourceLoader, cookieJar, and virtualConsole.
    • Computes the active LLM toolset as mounted_tools = navigation_tools + gated(active_tab.active_pfdom.document_tools, runTools).

3. Security & Lifecycle Rules Learned from Browsers

  1. Untrusted-Origin & Embed Isolation (<iframe> Sandbox Equivalent):
    • <pf:embed> content incorporated into PFDOM.context_text MUST be marked as supporting context and MUST NOT mount <pf:form> or <pf:api> tools into PFDOM.document_tools.
  2. Stale-Tool Unmounting (Preventing Replay of Old Affordances):
    • In linear chat transcripts, old tool descriptions linger and confuse the LLM. Every view replacement (open_persona, go_back, or <pf:form> mutation response) MUST replace tab.active_pfdom and recompute mounted_tools from scratch.
    • Server-side state validation (409 Conflict) remains mandatory as defense-in-depth, and a 409 response MUST replace tab.active_pfdom with the server's explanation and fresh navigation links.
  3. Server Re-Fetch on go_back() and Session Resume:
    • Restoring a serialized Browser Runtime snapshot MUST NOT re-mount old document_tools blindly. The runtime MUST re-fetch the active tab's top URI from the server and re-run Personafile Renderer to produce a fresh PFDOM—and MUST NOT persist cookies, CSRF tokens, or passwords inside snapshot files.
  4. Canonical Effective Base URI (Post-Redirect Provenance):
    • Like document.URL after HTTP redirects, relative <pf:a> and <pf:form action="..."> targets MUST resolve against Provenance.canonical_uri when building PFDOM.