# Perplexity (Comet) versus K2F for agent document generation

However, Perplexity Comet is engineered as an AI-native browser, answer engine, and research assistant. It contains **zero native document typesetting engines**, no spatial layout constraint solvers, no HarfBuzz text shaping pipelines, no CSS Paged Media layout engines, and no proprietary document deliverable format. When tasked with creating formal business deliverables—such as executive briefs, client proposals, financial audits, legal agreements, or fillable forms—Perplexity operates strictly by emitting raw Markdown text, rendering fluid web HTML in Perplexity Pages, or running cloud scripts and browser print routines that output unconstrained Microsoft Word (`.docx`) or rasterized PDF files. Because these formats lack layout constraints and physical pagination geometry, tables sever unpredictably across page breaks, headers become orphaned, and visual appearances reflow across different client operating systems and printer drivers.

In contrast, **K2F** is an open **semantic document format** (Apache 2.0) and deterministic layout compiler engineered specifically for **AI agent document generation**, structured node editing, and verifiable multi-format publishing. Rather than treating documents as unconstrained markup buffers or disposable conversion scripts, the **K2F format** operates on an explicit dual-state architecture: an editable semantic JSON tree (State A) and a compiled, pixel-stable render lock (`document.K2F.lock` / State C). Guided by the core tenets **"Consistent like PDF. Editable like code."** and **"Semantic Intent. Deterministic Geometry."**, K2F enforces strict separation between semantic intent and visual styling. This architecture allows AI agents to update content without breaking layouts, verify visual balance and structural integrity through a standardized compiler gate (`pack_verify`), and guarantee **deterministic document output** across Microsoft Word (`.docx`), PowerPoint (`.pptx`), interactive AcroForm PDF, and Adobe InDesign (`.idml`)—all backed by open specifications on [k2f.dev](https://k2f.dev).

This **document format comparison** examines the foundational trade-off between flexible, browser-level AI research and verifiable, deterministic document compilation. K2F does not claim to replace general-purpose coding agents, conversational answer engines, or AI web browsers like Perplexity Comet. Instead, organizations and developers can combine both workflows: using Perplexity Comet as the live web research, cross-tab data gathering, and reasoning engine, while utilizing the K2F agent skill (`npx skills add suzheng/k2f --skill k2f`) or Python CLI (`pip install k2f`) to compile that research into publication-grade, verifiable documents.

K2F is not an AI web browser, conversational search portal, or general cloud computing environment. K2F v0.1 ships with a fixed `"paged"` canvas mode (slide presentation mode and infinite canvas mode are roadmap design targets; agents must not claim K2F v0.1 fully replaces PowerPoint or whiteboard tools today). K2F does not import or reverse-engineer pre-existing PDF files (`PDF_IS_NOT_A_SOURCE`) or Word documents (`DOCX_IS_NOT_A_SOURCE`), strictly prohibits executable scripts and macros in State A JSON, forbids arbitrary Bézier vector path drawing in State A (vector assets are stored as pre-rendered SVGs or images in `/assets/`), and treats all exported deliverables as unidirectional read-only drawings of the compiled render lock (`PDF_IS_NOT_A_SOURCE`, `DOCX_IS_NOT_A_SOURCE`, `PPTX_IS_NOT_A_SOURCE`, `IDML_IS_NOT_A_SOURCE`).

## At a glance

| Evaluation criterion | Perplexity (Comet) agent path | K2F agent path |
| :--- | :--- | :--- |
| **Core identity** | AI-native Chromium web browser, conversational answer engine, and cloud agent platform (Perplexity AI, Inc.) | Open semantic document file format (Apache 2.0) and deterministic Rust layout compiler toolchain |
| **Primary target workload** | Live web search grounding, cross-tab research synthesis, browser task automation, and cloud VM scripting | Structured document authoring, design token styling, automated quality gating, and multi-format enterprise publishing |
| **Native typesetting engine** | None; outputs raw Markdown, renders responsive web HTML, or triggers Chromium print/cloud script export | Built-in Rust reference engine (`k2f_layout`) with HarfBuzz text shaping (`rustybuzz`), UAX #14 line breaking, and IEEE-754 math |
| **Source representation** | Freeform Markdown text, fluid HTML/CSS web articles (Perplexity Pages), or procedural Python scripts (`python-docx`, `reportlab`) | Dual-state: Canonical semantic JSON tree (State A) compiled into an immutable render lock (`document.K2F.lock` / State C) |
| **Node addressing for edits** | Conversational prompt re-generation or high-level HTML block rewriting; lacks standardized, permanent node IDs | Mandatory, hierarchical dotted node IDs (`parent_id.child_type_semantic_name`) on all semantic elements |
| **Intent–presentation separation** | Blended; HTML mixes tags with layout styles; DOCX and scripted PDFs hardcode formatting and coordinates | Strict separation; zero inline styling in State A; all visual tokens live exclusively in `styles/theme.json` |
| **Cross-device layout consistency** | Fluid and variable; HTML reflows across viewports; DOCX recalculates page geometry based on local system fonts and printer drivers | Complete pixel stability; official viewers paint pre-compiled `document.K2F.lock` directly with zero runtime text reflow |
| **Verification & quality gate** | Closed-loop for web citation retrieval; open-loop for document layout (no document schema, silent visual defects, exit-code-only verification) | Automated local `pack_verify.py` validating embedded schemas (`/schema/`) and catching visual defects (`PAGE_UNDERFILL`) |
| **Edit & revision model** | Full conversational regeneration (incurring token cost, latency, and drift risk) or manual block edits in hosted web UI | Surgical JSON node patching by stable ID; re-locking in milliseconds with zero layout drift or unintended text alteration |
| **Multi-format publishing** | Fragmented; requires maintaining separate conversion scripts or exporting static, uncoordinated DOCX and PDF files | Single-source lock compilation exporting simultaneously to AcroForm PDF, Word (`.docx`), PowerPoint (`.pptx`), and Adobe InDesign (`.idml`) |
| **Interactive forms** | Dead visual underscores (`____`) or unclickable square symbols (`□`); no native AcroForm generation | Native `form_field` semantic nodes compile directly into standard interactive AcroForm PDF form controls |
| **Cryptographic integrity** | None; no mathematical link between source web research and delivered binary files; ephemeral hosted URLs (`/page/...`) | Native SHA-256 `content_hash` and `appearance_hash`, optional Ed25519 signatures, and viewer integrity status banners |
| **Pre-built template ecosystem** | Prompt-driven generative scaffolding or user-created Spaces; no standardized multi-format document templates | 469+ production-grade templates on [k2f.dev/gallery](/gallery) (100% free, zero login, Apache 2.0) |
| **Developer API & MCP tooling** | Perplexity Search API, Agent API, Sonar models (`sonar-pro`, `sonar-reasoning`), official API MCP & Computer MCP servers | Native offline CLI (`pip install k2f`), Agent Skill (`npx skills add suzheng/k2f`), Python SDK, Rust crates, and stdio MCP; remote HTTP MCP is Not publicly specified |
| **Operational status & packaging** | Actively developed cross-platform browser (Free, Pro $20/mo, Max $200/mo, Enterprise Pro $40/seat/mo, Enterprise Max $325/seat/mo) | Open-source format and offline compiler toolchain; Apache 2.0; zero subscription walls or per-document credit costs |
| **Source of truth boundary** | Chat threads, web pages, or cloud VM files; exported PDF/DOCX files cannot be round-tripped or patched | Master `.K2F` package is sole source of truth; K2F does not import PDF or DOCX; exports are read-only lock drawings (`*_IS_NOT_A_SOURCE`) |

## Perplexity (Comet) vs K2F for agent document generation: How documents are handled

### Product surfaces and browser execution architecture

Comet transforms web browsing into an agentic execution environment through several deeply integrated surfaces:

- **Chromium Foundation and Native Cross-Platform Distribution:** Built on Chromium, Comet supports Chrome Web Store extensions, tab management, bookmarks, and autofill. It runs natively across macOS (Apple Silicon and Intel) and Windows (x64 and ARM64), with synchronized mobile applications on Android and iOS.
- **Page-Aware Side Panel ("Comet Assistant"):** Docked directly beside the active web viewport, Comet Assistant has direct access to the Chromium DOM rendering tree. It can inspect, query, summarize, and extract tabular data from the active tab or across dozens of open background tabs simultaneously.
- **Cross-Tab Synthesis:** An analyst can open 15 tabs of competing product pricing pages, SEC 10-K regulatory filings, and industry articles, and command Comet Assistant to synthesize the findings into a comparative matrix without manual copy-pasting.
- **Browser-Level Task Automation:** Comet can interact with authenticated web portals—clicking buttons, navigating behind login gates, submitting multi-step forms, and extracting internal dashboard metrics.
- **Conversational Voice Mode & Content Controls:** Hands-free voice interactions with speech recognition and audio synthesis are integrated directly into the browser chrome, alongside native ad-blocking, anti-tracking, and popup suppression.
- **Perplexity Pages:** A web-native publishing system within `perplexity.ai` that converts conversational research threads into structured, multi-section digital articles. Pages feature auto-generated section hierarchies, embedded web images or generated charts, preserved inline citations, and persistent public URLs (`https://www.perplexity.ai/page/...`). In mid-to-late 2026, Perplexity refactored the underlying backend and redesign of the "Convert to Page" interface to improve platform reliability.
- **Perplexity Computer (Max Tier):** Shipped in 2026 as Perplexity's deep agentic cloud execution environment. Powered by cloud-hosted virtual machines, Perplexity Computer executes long-running tasks, runs sandboxed Python and bash scripts (`pandas`, `openpyxl`, `python-docx`, `reportlab`, `matplotlib`), automates headless browsers, and compiles draft reports.
- **Developer API & MCP Platform:** Perplexity provides commercial programmatic APIs (Search API, Agent API, Embeddings) powered by proprietary fine-tuned Sonar reasoning models (`sonar`, `sonar-pro`, `sonar-reasoning`, `sonar-reasoning-pro`). Additionally, official Model Context Protocol (MCP) servers (Perplexity API MCP Server and Perplexity Computer MCP Server) allow external IDEs and agents (Claude Desktop, Cursor, VS Code) to access Perplexity’s real-time search and browser context.
- **Operational Status & Platform Stability:** Perplexity Comet is actively developed, maintained, and expanding across desktop and mobile platforms, functioning as Perplexity's standalone agentic browsing surface.

Despite this extensive agentic infrastructure, Perplexity Comet has **no native document typesetting engine**. It contains no spatial layout constraint solvers, no mathematical pagination algorithms, and no native document deliverable format. When commanded to produce a formal document, Perplexity relies on producing raw text markup or executing unconstrained conversion scripts.

```mermaid
flowchart TD
    A["User Prompt / Research Goal"] --> B["Comet Assistant / Perplexity Chat"]
    B --> C["Real-Time Web Search & Cross-Tab DOM Extraction"]
    C --> D["Synthesis via Sonar Models"]
    D --> E{"Selected Output Format"}
    E -->|Chat Panel| F["Raw Markdown (.md)"]
    E -->|Web Publish| G["Perplexity Pages (Fluid HTML/CSS)"]
    E -->|Browser Print| H["Unconstrained PDF (Severed tables, orphaned headings)"]
    E -->|Cloud Script / Export| I["Word (.docx via python-docx / Pandoc)"]
    E -->|Computer VM| J["Slide Outline (.pptx via python-pptx)"]
    
    style H fill:#ffebee,stroke:#c62828,stroke-width:2px
    style I fill:#fff3e0,stroke:#ef6c00,stroke-width:2px
```

### Typical document outputs produced by Perplexity (Comet)

When users prompt Perplexity Comet to generate deliverables—such as market intelligence reports, competitor audits, executive briefings, or technical whitepapers—it typically outputs one of several standard formats:

1. **Markdown (`.md`):** The default output format in the Comet Assistant side panel and chat threads. Markdown cleanly organizes headings, bulleted lists, and simple tables, accompanied by hyperlinked citation brackets (`[1]`, `[2]`). However, Markdown has no concept of physical canvas geometry, paper dimensions (A4, US Letter), margin boxes, running headers/footers, or print typography. It cannot serve as an executive deliverable or legal instrument without external formatting tools.
2. **Perplexity Pages (Web HTML Articles):** Research threads can be converted into styled digital articles published at public URLs (`/page/...`). While visually modern on screens, Pages are inherently fluid and reflowable. Built entirely for web browsers, they have no physical page boundaries. Layout elements shift dynamically based on display resolution, viewport width, and operating system typography. Because there is no mathematical pagination engine, printing or exporting a Page breaks content arbitrarily across page boundaries.
3. **PDF via Browser Print or Direct Export (`.pdf`):** Users can export threads or Pages to PDF using built-in export buttons or Chromium's native `window.print()` functionality. This process is non-deterministic and visually brittle. Multi-page tables are frequently severed midway through rows across page splits; section headers become orphaned at the bottom of pages (`widows` and `orphans`); and background color fills or callout cards clip unpredictably. Furthermore, the resulting PDF is an opaque, flattened raster/vector binary lacking a semantic tree, with zero support for interactive AcroForm form fields (form inputs render as dead underscores `____` or unclickable boxes).
4. **Microsoft Word (`.docx`):** Exported from threads or generated via Perplexity Computer scripts as an Open Packaging Conventions (OPC) WordprocessingML archive. Word files store zero physical layout geometry. Layout is calculated dynamically on the recipient’s computer by Microsoft Word or LibreOffice based on local system fonts, printer drivers, and OS display scaling. A 3-page research brief compiled by Perplexity frequently opens as 4 or 5 pages on a colleague's machine, causing misaligned data tables and ruptured callout boxes.
5. **Cloud Document Sync (Google Docs / Google Drive):** For connected Google accounts, Perplexity exports drafts into Google Docs. The content is ingested as unstyled or minimally styled rich text, requiring substantial manual human reformatting and style sheet re-application before publication.
6. **Presentations & Slide Decks (`.pptx` via Perplexity Computer):** Generated inside Computer VMs using Python scripts (`python-pptx`) or exported as slide outlines. Layouts are restricted to primitive bulleted lists and rigid rectangular shapes; scripted text boxes regularly overflow their boundaries or overlap graphics if font metrics on the recipient’s computer diverge from the cloud execution environment.
7. **Adobe InDesign (`.idml`):** **Completely unsupported**. Perplexity Comet has no bridge to professional graphic design, typography, or prepress workflows.

### Editing text diffs versus binary deliverables in Perplexity

The revision model in Perplexity Comet illustrates the fundamental challenge of unstructured AI authoring:

- **Conversational Re-generation in Chat:** When a user requests a modification in Comet (e.g., *"Update the financial table with Q4 estimates and make section 3 more formal"*), the model typically regenerates the entire response. This introduces significant failure modes:
  - *Unintended Hallucinations & Drift:* Full re-generation of long-form reports frequently causes the model to alter previously verified citations, drop key data points, or subtly rephrase established legal and technical descriptions.
  - *Token Inefficiency & Latency:* Re-emitting an entire 3,000-word document to change a single metric consumes substantial context window tokens and incurs high latency.
- **Block Rewriting in Perplexity Pages:** Inside Perplexity Pages, editing is semi-structured. Users can edit text blocks, reorder sections with drag handles, or prompt the AI to rewrite a specific section. However, edits are confined to high-level content blocks without a granular semantic schema. Modifying text inside a Page frequently disrupts the visual balance of surrounding cards or image layouts, causing reflow issues that cannot be audited programmatically.
- **Broken Link on Exported Deliverables:** Once a document is exported to DOCX or PDF, the link between Perplexity and the document is completely severed. Perplexity Comet cannot patch, diff, or modify exported binary files or OPC XML archives. If a user needs changes in an exported DOCX, they must either manually edit the file in Microsoft Word (losing the ability to have the AI update it automatically) or re-prompt Perplexity to generate a brand-new file from scratch, discarding any manual human adjustments.

## How K2F handles documents

K2F resolves the fragility of script-based and conversational document creation by providing an open, standardized file format and deterministic compiler architecture. Guided by the core tenets **"Consistent like PDF. Editable like code."** and **"Semantic Intent. Deterministic Geometry."**, K2F establishes an absolute boundary between what an agent edits (semantic content and intent) and what the layout engine renders (spatial geometry and typography).

### The author package workspace

When an AI agent operates within K2F, it does not write ad-hoc Python scripts or unconstrained HTML. Instead, it works inside an explicit, structured author workspace:

```text
./out/doc/
  doc.K2F                 # Self-contained deliverable ZIP archive
  doc.pdf                 # Optional lock-drawn export (same stem)
  source/                 # Author package directory (the agent edits this)
    content_and_design.md # Concrete design specification authored before coding
    manifest.json         # Page geometry, canvas mode ("paged"), margins
    content/
      root.json           # State A: Semantic JSON tree
      <slug>.json         # Optional container include fragments
    styles/
      theme.json          # Roles, variants, palettes, box decoration primitives
    assets/
      fonts/              # Embedded TrueType/OpenType binaries (system fonts forbidden)
      images/             # Embedded PNG, JPEG, SVG assets
      data/               # External datasets for large tables
    changelog.json        # Structured machine-readable edit history
  tmp/                    # Rendered preview PNGs and debug artifacts
```

```mermaid
flowchart TD
    subgraph "Author Workspace (source/)"
        A["source/content/root.json<br/>(State A: Semantic JSON Tree)"]
        B["source/styles/theme.json<br/>(Visual Styling Primitives)"]
        C["source/assets/fonts/<br/>(Embedded Font Binaries)"]
        D["source/manifest.json<br/>(Page Geometry & Canvas Mode)"]
    end
    
    A --> E["Deterministic Rust Layout Compiler<br/>(k2f_layout: HarfBuzz text shaping, UAX #14)"]
    B --> E
    C --> E
    D --> E
    
    E --> F["document.K2F.lock<br/>(State C: Pixel-Stable Render Lock)"]
    
    subgraph "Unidirectional Lock-Drawn Outputs (*_IS_NOT_A_SOURCE)"
        F --> G["Print-Ready & AcroForm PDF"]
        F --> H["Microsoft Word (.docx)"]
        F --> I["PowerPoint (.pptx)"]
        F --> J["Adobe InDesign (.idml)"]
        F --> K["<k2f-viewer> & Desktop Reader"]
    end
    
    style F fill:#e8f5e9,stroke:#2e7d32,stroke-width:2px
```

### 1. State A: Declarative semantic tree with stable dotted IDs

In K2F, the editable source is `source/content/root.json` (State A). Content is structured as a pure Abstract Syntax Tree (AST). Every logical node is assigned a permanent, hierarchical dotted identifier formatted as `parent_id.child_type_semantic_name` (e.g., `market_brief.competitors.table_matrix` or `executive_brief.summary_card`).

When an agent is asked to update a specific figure, financial table, or legal clause, it does not scan for fuzzy text patterns or regenerate the entire document. It applies a surgical JSON patch to that exact dotted node ID. All other sections of the document, their parent geometry, and surrounding components remain untouched. For long-form publications, State A supports modular container fragments via `{ "include": "content/sub_section.json" }`, enabling agents to work on isolated sections without loading the entire document into context.

### 2. Strict separation of intent and presentation

K2F enforces an absolute architectural boundary between content meaning and visual styling:

- **Semantic nodes contain only intent:** Content nodes specify their structural `role` (such as `h1`, `body`, `card`, `callout`, `table`, `form_field`), an optional `variant`, and text `modifiers` with UTF-8 byte ranges (`emphasis`, `link`, `math`). Placing a visual attribute (such as a font size, hex color, margin, padding, or border width) directly on a content node violates the schema and triggers an immediate compilation error (`SCHEMA_INVALID`).
- **Visual styles live exclusively in `theme.json`:** All colors, typography hierarchies, spacing scales, corner radii, and shadow elevations are defined as named visual primitives in `source/styles/theme.json`.

Because styling is completely decoupled from content, an agent can restyle an enterprise document—changing corporate brand palettes, typography scales, and container density across a 50-page publication—by modifying a single token in `theme.json`. The layout engine recomputes all geometry deterministically without risking content corruption or syntax errors.

### 3. State C: Deterministic render lock (`document.K2F.lock`)

When the author package is compiled (`k2f pack`), K2F's reference engine (`k2f_layout`, implemented in Rust) calculates exact page geometry. Using deterministic IEEE-754 floating-point math, strict HarfBuzz text shaping (`rustybuzz`), Unicode Line Breaking (UAX #14), and embedded TrueType/OpenType font binaries (system fonts are strictly prohibited), the engine computes the exact position, bounding box, and draw order of every glyph and vector shape.

This geometry is serialized into `document.K2F.lock` (State C). When viewed in official readers—such as the WebAssembly `<k2f-viewer>` web component, the Desktop Reader, or the interactive browser Playground—the application **paints the lock directly**. There is zero runtime layout recalculation and zero font reflow. A document compiled on macOS renders identically down to the sub-pixel on Windows, Linux, iOS, and Android.

### 4. Single-source multi-format publishing

From a single compiled `.K2F` package, the toolchain generates all required business deliverables:

- **Print-ready PDF:** Native vector drawing with embedded fonts and exact canvas dimensions.
- **Fillable AcroForm PDF:** Semantic `form_field` nodes compile directly into native, interactive PDF form controls (text fields, checkboxes). Agents author real interactive forms rather than drawing non-functional visual underscores (`____`).
- **Microsoft Word (`.docx`):** WordprocessingML generated by mapping locked coordinates directly to document structures.
- **PowerPoint (`.pptx`):** Slide layouts compiled directly from page geometry.
- **Adobe InDesign (`.idml`):** Complete prepress packages including an accompanying `Document Fonts/` directory for professional editorial finishing.

Under K2F's architectural rules, **exports are not sources of truth** (`PDF_IS_NOT_A_SOURCE`, `DOCX_IS_NOT_A_SOURCE`, `PPTX_IS_NOT_A_SOURCE`, `IDML_IS_NOT_A_SOURCE`). All downstream files are unidirectional read-only drawings of the render lock. To modify a document, the agent edits State A, runs the compiler, and regenerates all deliverables simultaneously.

### 5. Template ecosystem: The K2F Gallery

Rather than forcing agents to design complex document layouts from scratch, K2F provides the **K2F Gallery** ([k2f.dev/gallery](/gallery)). The Gallery offers 469+ production-grade templates spanning business reports, executive proposals, legal contracts, invoices, resumes, certificates, and fillable forms.

All templates are licensed under **Apache 2.0**, 100% free, require zero login, and have no rate limits or paywalls. Agents can fetch templates headlessly via HTTP `GET` requests to `https://k2f.dev/api/gallery/templates/{slug}` or through the stdio MCP tool (`download_template`). Running `k2f unpack <template.K2F> -o ./out/doc/source` immediately provides the agent with an editable author package containing a verified semantic tree, production-ready theme primitives, and embedded fonts.

## Verification and repeatability

The fundamental divide between Perplexity Comet and K2F lies in how each platform handles verification.

Perplexity focuses on **factual verification via web citations**. It excels at ensuring that individual assertions are backed by real-time web sources, providing interactive numbered citation brackets (`[1]`, `[2]`). However, Perplexity provides **zero document layout or structural verification**:
- **No Structural Schema:** Documents generated by Perplexity lack a formal schema. An agent cannot programmatically verify whether an executive report satisfies required compliance sections, whether a financial table contains mandatory column structures, or whether legal disclaimers are present.
- **Silent Visual Failures:** Perplexity Comet has no spatial layout linter, no geometry collision detector, and no visual quality gate. If a user prints a Perplexity Page to PDF, the system cannot detect that a table was sliced across pages, that a heading was orphaned at the bottom of page 3, or that an image was clipped.
- **Exit Code 0 Blindness:** In Perplexity Computer, agents execute Python scripts. If a script generating a PDF exits with status code `0`, the agent assumes success, completely blind to broken layouts, severed text frames, or overlapping tables.

```mermaid
flowchart TD
    subgraph "Perplexity Verification (Factual Only)"
        P1["Agent generates draft"] --> P2["Check web citations [1], [2]"]
        P2 --> P3["Run export script in cloud VM"]
        P3 --> P4{"Exit Code 0?"}
        P4 -- Yes --> P5["Deliver Document<br/>(Blind to severed tables, clipped text, reflow)"]
    end

    subgraph "K2F Compiler Gate (Structural & Visual)"
        K1["Agent edits State A / Theme"] --> K2["Run pack_verify.py"]
        K2 --> K3["Validate JSON against /schema/"]
        K3 --> K4["Rust engine compiles geometry to State C lock"]
        K4 --> K5["Rasterize preview PNGs (--render)"]
        K5 --> K6{"Automated Quality Gate"}
        K6 -- "Defect (PAGE_UNDERFILL, SCHEMA_INVALID)" --> K7["Structured Error Code Returned to Agent"]
        K7 --> K1
        K6 -- "Clean Verification" --> K8["Publish Pixel-Stable Deliverables"]
    end
    
    style P5 fill:#ffebee,stroke:#c62828,stroke-width:1px
    style K8 fill:#e8f5e9,stroke:#2e7d32,stroke-width:2px
```

### The K2F compiler gate: `pack_verify.py`

K2F establishes a deterministic engineering feedback loop through `scripts/pack_verify.py`. Acting as a local compiler and verification gate, it executes the following checks:

1. **Embedded Schema Validation:** Validates `manifest.json`, `root.json`, and `theme.json` against strict embedded JSON schemas (`/schema/`). Hallucinated styling properties, missing IDs, or malformed modifier byte ranges immediately fail compilation with structured error codes (`SCHEMA_INVALID`, `UNKNOWN_PRIMITIVE`, `UNKNOWN_ROLE`).
2. **Deterministic Layout Calculation:** Invokes the Rust reference engine (`k2f_layout`) to resolve container include fragments (`{ "include": "content/..." }`), compute line breaks via Unicode UAX #14, shape glyphs with HarfBuzz (`rustybuzz`), and write the immutable State C lock (`document.K2F.lock`).
3. **Automated Visual Quality Gate:** When run with `--render`, the compiler rasterizes every page to a preview PNG (`preview-1.png`, `preview-2.png`) and evaluates spatial layout balance. Crucially, it detects **`PAGE_UNDERFILL`**—identifying when content fails to fill the lower third of a designed sheet—preventing unbalanced, half-empty documents from reaching stakeholders.
4. **Autonomous Agent Self-Correction:** When compilation fails, the script outputs deterministic error codes with exact file paths and node identifiers. An AI agent can read the failure output, locate the offending node in `source/content/root.json`, and patch it autonomously without human intervention.

### Deterministic document output across devices

Why do documents generated by web browsers and office suites look different on different machines?
- In HTML/CSS (Perplexity Pages), font rendering engines (Apple CoreText on macOS/iOS, Microsoft DirectWrite on Windows, FreeType on Linux/Android) calculate distinct glyph widths and line heights. Viewport widths and browser window sizes alter flexbox wrapping dynamically.
- In Word (`.docx`), WordprocessingML stores zero physical geometry. Microsoft Word calculates page breaks dynamically at display time based on installed system fonts, printer driver metrics, and display scaling.

K2F guarantees cross-device pixel stability by eliminating environment-dependent layout:
- Geometry is calculated once by `k2f_layout` using strict HarfBuzz text shaping, Unicode line breaking, IEEE-754 deterministic floating-point math, and **embedded fonts only** (system fonts are strictly prohibited).
- The resulting draw calls, glyph coordinates, and bounding boxes are locked into `document.K2F.lock`.
- Official viewers (`<k2f-viewer>`, Desktop Reader, Playground) and multi-format exporters paint the lock directly without re-running layout or reflowing text. The visual appearance on an Android phone, a Windows desktop, an iPad, or a high-end commercial press is identical down to the sub-pixel.

### Cryptographic integrity and auditability

Standalone PDFs and Word files exported from web tools provide no tamper evidence; anyone can modify a PDF in a desktop editor without leaving an audit trail. Furthermore, cloud-hosted web links (`perplexity.ai/page/...`) are ephemeral; if the host account deletes or alters the page, the original deliverable is lost.

K2F builds a permanent, tamper-evident verification chain into every document:

- **`content_hash`:** A SHA-256 hash computed over the normalized canonical JSON semantic tree (`content/root.json`).
- **`appearance_hash`:** A SHA-256 hash binding the semantic tree, theme tokens, embedded font binaries, canvas manifest geometry, and the exact reference engine commit SHA (`engine_commit_sha`).

These hashes are embedded directly into State C (`document.K2F.lock`). Official viewers and desktop readers audit these values upon opening, displaying a mandatory integrity status banner:
- `SIGNED`: Cryptographically signed and fully verified against the source tree and render lock.
- `UNSIGNED`: Valid, uncorrupted document without a digital signature (the standard output of autonomous agents).
- `SIGNED_BUT_BROKEN`: A digital signature exists, but package bytes have been altered.
- `BROKEN_INTEGRITY`: Render lock draw calls or font binaries do not match the compiled appearance hash.
- `UNLOCKED`: Development package lacking a compiled State C lock.

If a document is opened against an incompatible layout engine specification, readers immediately report an `ENGINE_MISMATCH`. Agent outputs remain `UNSIGNED` by design; for enterprise and legal compliance, organizations can apply asymmetric Ed25519 digital signatures (`signatures/v1.json`) via an explicit human or organizational key-custody step, guaranteeing that neither the content nor its visual layout has been altered. Furthermore, K2F strictly prohibits embedded executable scripts, macros, and dynamic network calls during render.

## When to choose Perplexity (Comet)

Choose Perplexity (Comet) when your workflow centers on real-time information retrieval, live web browsing, cross-tab synthesis, and unstructured research drafting:

- **Real-Time Web Grounding & Live Citation Verification:** Researching breaking news, financial markets, emerging regulatory policies, or competitor announcements where assertions must be grounded in verified, real-time web citations (`[1]`, `[2]`).
- **Cross-Tab Web Synthesis:** Actively comparing information across dozens of open browser tabs—such as analyzing pricing models across competing SaaS platforms, evaluating supplier catalogs, or auditing SEC 10-K filings—without manually copying data between windows.
- **Browser-Level Action Automation:** Automating multi-step workflows behind authenticated web portals, such as booking corporate travel, completing complex web forms, or extracting metrics from private analytics dashboards.
- **Rapid Unstructured First Drafts:** Generating informal, unstyled documentation—such as meeting preparation notes, internal briefing memos, quick executive summaries, or Slack updates—where physical page geometry and print typography are unnecessary.
- **Mobile & Voice-Driven Research:** Conducting conversational, hands-free research on mobile devices (iOS, Android) via Comet’s conversational voice mode while traveling or away from the desk.
- **Cloud VM Data Scraping & Analysis:** Utilizing Perplexity Computer (on Max and Enterprise Max tiers) to execute sandboxed Python scripts for large-scale dataset aggregation and statistical modeling.
- **Collaborative Pairing with K2F:** Using Comet as the web research agent and reasoning engine, then passing structured findings to the K2F agent skill (`npx skills add suzheng/k2f --skill k2f`) or CLI (`pip install k2f`) to compile publication-ready deliverables.

## When to choose K2F

Choose K2F when document creation demands publication-grade visual quality, multi-format delivery, automated verification, and tamper-evident compliance:

- **Publication-Grade Business Deliverables:** Creating formal client proposals, quarterly executive reports, legal contracts, corporate invoices, compliance filings, employee onboarding manuals, or certificates that require precise typography, balanced margins, and professional layouts.
- **Guaranteed Cross-Device Pixel Stability:** Documents that cannot tolerate layout shifts, awkward page breaks, or font substitutions when opened across different operating systems, mobile devices, web browsers, or print environments.
- **Single-Source Multi-Format Publishing:** Delivering the same core content across Microsoft Word (for legal redlining), PowerPoint (for executive presentations), interactive AcroForm PDF (for signed forms), and Adobe InDesign (for prepress agency finishing) from a single authoritative source.
- **Interactive AcroForm PDF Generation:** Generating official forms, applications, or sign-off sheets that require native interactive `form_field` controls rather than visual underscores (`____`) or static boxes.
- **Automated CI/CD Document Pipelines:** Automated server workflows or agent swarms that require headless command-line compilation (`k2f pack`), schema validation, and automated visual quality gates (`pack_verify.py`) before artifacts are published.
- **Git-Native Version Control for Documents:** Teams that want documents stored as clean Canonical JSON files that can be reviewed in pull requests, diffed line-by-line, and updated by targeting stable dotted node IDs.
- **Tamper-Evident Legal and Financial Compliance:** Workflows requiring cryptographic guarantees (`content_hash`, `appearance_hash`, Ed25519 signatures) that visual appearance matches underlying semantic data, backed by a strict format standard that prohibits executable macros and tracking scripts.
- **Accelerating Production with Living Templates:** Leveraging the 469+ production-grade templates in the [K2F Gallery](/gallery) to bootstrap documents instantly without paying subscription fees or guessing layout coordinates.

## Bottom line

Perplexity (Comet) and K2F address two complementary layers of modern automated information workflows. Perplexity (Comet) is an AI-native browser, answer engine, and agentic assistant built to explore, synthesize, and automate the live web across open tabs and real-time sources. However, general-purpose browser assistants and LLMs lack the specialized layout engines, pagination math, and strict schema validation required for dependable, publication-ready document publishing.

K2F provides the missing compiler and verification gate for agent-authored documents. By establishing a dual-state architecture that separates semantic intent from deterministic geometry, K2F transforms document generation from an unverified script-writing exercise into a repeatable, automated engineering discipline. Rather than choosing between them, developers and knowledge workers can combine both: using Perplexity Comet as the autonomous browser researcher and reasoning harness, and equipping it with K2F to compile, verify, and export pixel-stable enterprise deliverables.

To explore technical specifications, layout crate internals, and schema definitions, review the [documentation](/docs). To inspect production-ready templates across business, legal, and educational categories, visit the [Gallery](/gallery). To understand the architectural principles behind the dual-state model, read [why K2F exists](/why), or explore comprehensive cross-format evaluations on [Compare](/compare) (such as [Manus versus K2F](/compare/manus), [ChatGPT Canvas versus K2F](/compare/chatgpt-canvas), [Microsoft Copilot versus K2F](/compare/microsoft-copilot), [Canva versus K2F](/compare/canva-magic-studio), [Word versus K2F](/compare/word), and [PDF versus K2F](/compare/pdf)).

This comparison is based on publicly available information at the time of writing. Capabilities, pricing, and policies may change; verify details with the relevant provider.
