(defcomp
  ()
  (~docs/page
    :title "Content-Addressed Computation"
    (p
      (~tw :tokens "text-stone-500 text-sm italic mb-8")
      "A computation is a value. A value has a hash. The hash is the address. "
      "Same state, same address, forever.")
    (~docs/section
      :title "The idea"
      :id "idea"
      (p
        "Freeze a scope to SX. Hash the SX text. The hash is a content identifier (CID). "
        "Store the frozen SX keyed by CID. Later, look up the CID, thaw, resume.")
      (p
        "The critical property: "
        (strong "same state always produces the same CID")
        ". "
        "Two machines freezing identical signal values get identical CIDs. "
        "The address IS the content."))
    (~docs/section
      :title "How it works"
      :id "how"
      (~docs/code
        :src (highlight
          ";; Freeze a scope → hash → CID\n(freeze-to-cid \"widget\")\n;; => \"d9eea67b\"\n\n;; The frozen SX is stored by CID\n(content-get \"d9eea67b\")\n;; => {:name \"widget\" :signals {:count 42 :name \"hello\"}}\n\n;; Thaw from CID → signals restored\n(thaw-from-cid \"d9eea67b\")\n;; Signals reset to frozen values"
          "lisp"))
      (p
        "The hash is djb2 for now — deterministic and fast. "
        "Real deployment uses SHA-256 / multihash for IPFS compatibility."))
    (~docs/section
      :title "Why it matters"
      :id "why"
      (ul
        (~tw :tokens "list-disc pl-6 mb-4 space-y-2 text-stone-600")
        (li
          (strong "Sharing")
          " — send a CID, not a blob. "
          "The receiver looks up the CID and gets the exact state.")
        (li
          (strong "Deduplication")
          " — same state = same CID. "
          "Store once, reference many times.")
        (li
          (strong "Verification")
          " — re-freeze, compare CIDs. "
          "If they match, the state is identical. No diffing needed.")
        (li
          (strong "History")
          " — each CID is a snapshot. "
          "A sequence of CIDs is a complete undo history.")
        (li
          (strong "Distribution")
          " — CIDs on IPFS are global. "
          "Pin a widget state, anyone can thaw it. "
          "No server, no API, no account.")))
    (~docs/section
      :title "Live demo"
      :id "demo"
      (p
        "Change the counter and name. Click "
        (strong "Content-address")
        " to freeze and hash. "
        "The CID appears below. Change the values, then click any CID in the history "
        "or paste one into the input to restore.")
      (~geography/cek/content-address-demo))
    (~docs/section
      :title "The path to IPFS"
      :id "ipfs"
      (p "The content store is currently in-memory. The next steps:")
      (ul
        (~tw :tokens "list-disc pl-6 mb-4 space-y-1 text-stone-600")
        (li "Replace djb2 with SHA-256 (browser SubtleCrypto)")
        (li "Wrap in multihash + CIDv1 format")
        (li "Store to IPFS via the Art DAG L2 registry")
        (li "Pin CIDs attributed to " (code "sx-web.org"))
        (li "Anyone can pin, fork, extend"))
      (p
        "The frozen SX is the content. The CID is the address. "
        "IPFS is the network. The widget state becomes a permanent, "
        "verifiable, shareable artifact — not trapped in a database, "
        "not behind an API, not owned by anyone."))))
