5. Site format
A site is a tree of folders. Each folder is described by one short text file, its list, in the format lns-links/1. The record pins the root list, and every list pins what it contains.
Describes lns-links/1 as parsed by Names Browser core 0.3.6 (links.rs) and by the shared parser in logic.mjs, which the gateway and lns publish import. The two parsers are kept in step and tested against each other.
5.1 Overview
A list is a UTF-8 text file. Its first line names the format. Each other line names one file or one subfolder of that folder, with the Logos Storage content ID (CID) where its bytes are, and the SHA-256 of those bytes. A subfolder's line points at the subfolder's own list.
Because each list holds the hash of everything below it, a change to one file changes its folder's list, then that list's parent, and so on up to the root. The root list's hash goes in the record. Folders that did not change keep the same bytes, hash and CID, so a publisher can reuse them.
A tree for a site with a home page, a stylesheet and one page in a folder:
record cid = CIDrootlist cid.sha256 = 46e9b706…
└ / root list
├ docs/ CIDdocslist 46340f14…
│ └ intro.html CIDintrohtml 8986a160…
├ index.html CIDindexhtml a9976790…
└ style.css CIDstylecss e78baba7…
Appendix C has the full lists and the real hashes for this tree.
5.2 Encoding and size
- A list is UTF-8 text. Lines end with LF. A CR before the LF is ignored.
- Leading and trailing whitespace on a line is ignored. Empty lines are ignored.
- A list is at most 2 MiB (2,097,152 bytes) and holds at most 10,000 entries.
- It contains no control characters other than TAB, CR and LF.
- The media type is
text/vnd.logos.lns-links. An on-chain root list is stored with the content typetext/vnd.logos.lns-links; version=1. In Logos Storage,lns publishuploads lists astext/plain. A client identifies a list by the record (cid.type=links) or by its first line (section 5.9).
A client MUST reject a list larger than 2 MiB, with more than 10,000 entries, or containing a control character other than TAB, CR or LF.
Enforced inlinks.rs parse_links_list and logic.mjs parseLinksList.
5.3 Header
The first line, after trimming, is exactly:
# lns-links/1
A client MUST reject a list whose first line is not # lns-links/1.
parse_links_list and parseLinksList.
5.4 Directives and comments
A line that starts with # is a directive or a comment. Spaces after the # are allowed.
| Line | Meaning |
|---|---|
# index <name> | The file shown when the folder itself is requested. Default index.html. The value follows the name rules in 5.5. At most one per list. |
# title <text> | A title for the folder, shown in the browser's interface. Capped at 200 characters. The Names Browser removes BiDi and control characters before showing it. |
any other # line | A comment. Ignored. |
A client MUST reject a list with two # index lines, or with an # index value that is not a valid name.
parse_links_list and parseLinksList.
5.5 Entries
Every other non-empty line is an entry. Its fields are separated by one or more spaces or tabs.
<name> <cid> <sha256> a file
<name>/ <cid> <sha256> a subfolder (its list)
| Field | Rule |
|---|---|
| name | One path segment: 1 to 255 bytes of UTF-8. Not . or ... No whitespace, no control or BiDi characters, and none of / \ ? # < > " '. A trailing / marks a folder and is not part of the name. |
| cid | 8 to 128 ASCII letters and digits. Only the format is checked (see 6.2). |
| sha256 | 64 hex digits, the SHA-256 of the bytes the CID names. Either case is accepted; it is compared in lower case. |
Names are compared byte for byte. There is no case folding, so About.html and about.html are different entries.
A client MUST reject the whole list if a line has fewer than two or more than three fields, a name breaks the rules above, a CID or hash is malformed, or two entries share a name. A file and a folder with the same name count as a duplicate.
Enforced inparse_links_list and parseLinksList.
5.5.1 Entries without a hash
The grammar still accepts an entry with two fields, a name and a CID, from an earlier form of the format. No current client will fetch one.
A publisher MUST write a SHA-256 on every entry.
A client MUST NOT fetch or show a file or folder whose entry has no SHA-256.
The Names Browser skips such entries with "Unverified file skipped" (Main.qml). The gateway resolves with requireSha256: true and answers 502 (serve.mjs). lns publish always writes the hash (publish.mjs publishDir).
5.6 Canonical form
The bytes of a list are hashed, so the same folder should always produce the same bytes. lns publish writes this form (formatLinksList in logic.mjs, format_links_list in links.rs):
- The header line.
# title <text>, on the root list only, when a title is set.# index index.html, when the folder has anindex.html.- One line per entry, sorted by the UTF-8 bytes of the name in ascending order (the folder
/is not part of the sort key), with single spaces and the hash in lower case. - LF after every line, including the last. No blank lines and no comments.
A publisher SHOULD write lists in canonical form, so that an unchanged folder keeps its hash and CID.
Not a client requirement: both parsers accept entries in any order and sort them after parsing.The root list of the example tree, as lns publish writes it:
# lns-links/1
# title Alice
# index index.html
docs/ CIDdocslist 46340f143bb7c2c8…dbc6647d
index.html CIDindexhtml a997679004baf5f6…7313c1b9
style.css CIDstylecss e78baba75d251d30…b5557574
Hashes are shortened here to fit the page. Appendix C has them in full.
5.7 Paths and resolution
A client turns the path of an lns:// address into an entry like this.
5.7.1 Normalising the path
- Refuse a path with control characters.
- Cut off the fragment (from the first
#), then the query (from the first?). The query plays no part in resolution. - Note whether the path ends with
/. An empty path counts as/. - Split on
/. Drop empty segments and.. A..removes the segment before it, and never climbs above the root.
5.7.2 Walking the lists
- Start at the root list, at the first segment.
- Look the segment up by name in the current list. If there is no entry, the path is not found.
- If the entry is a folder, fetch its list, check its hash (section 6), parse it, and continue with the next segment in that list.
- If the entry is a file, it must be the last segment and the path must not end with
/. Otherwise the path is not found. - When the segments run out on a folder, return that folder's index entry (
# index, defaultindex.html). If it is missing or is a folder, the path is not found.
So /docs and /docs/ both resolve to the index of docs. The canonical address of a folder ends with /.
A client MUST stop and report an error when folder nesting along a path exceeds 32.
Enforced inresolve_links_tree (MAX_LINKS_DEPTH) and in the gateway's resolveLinksTree.
Encoding. The Names Browser compares segments as written, with no percent-decoding. The gateway accepts only the canonical percent-encoding of each segment and answers any other spelling with 404 (section 8.3). Names with spaces or quotes cannot occur, because the name rules forbid them.
5.8 Pinning the root
There are two ways to pin the root list.
5.8.1 In Logos Storage (the usual way)
Upload the root list to Logos Storage and set three text entries in the record:
| Entry | Value |
|---|---|
cid | The root list's CID. |
cid.sha256 | The SHA-256 of the root list's bytes. |
cid.type | links |
Changing a site of any size is then one record update (section 9.6).
5.8.2 On chain
Store the root list itself as the name's on-chain page, with the content type text/vnd.logos.lns-links; version=1. Subfolders and files still come from Logos Storage. The record then needs no cid entry, and the root list is read with the record through the RPC.
An on-chain root list MUST be smaller than 10,240 bytes. A client MUST refuse one of 10,240 bytes or more.
Enforced inMain.qml (MAX_ONCHAIN_LINKS_BYTES), serve.mjs loadSiteRoot and publish.mjs.
The Names Browser needs Basecamp's Storage module to follow an on-chain root list into Storage.
5.9 Other root forms
Clients still read two older forms. lns publish writes neither.
- A single HTML file. The record's
cidnames one HTML file, which is the whole site.cid.typeissingleor absent. The gateway accepts such a root only if it is HTML or plain text. - A JSON manifest. A JSON object with
"kind": "lns-site-manifest","version": 1, anindexpath and afilesmap from site path tocid,sha256,sizeandcontentType.cid.typeismanifest. The gateway ignores the manifest'scontentType.
A client decides which form a root is from cid.type, and otherwise from the bytes: a first line of # lns-links/1 means a list, a parseable manifest means a manifest, and anything else is a single file.
5.10 Limits
| Limit | Value |
|---|---|
| List size | 2 MiB (2,097,152 bytes) |
| Entries per list | 10,000 |
| Folder depth along a path | 32 |
| Name (segment) length | 255 bytes |
| CID length | 8 to 128 characters |
| Folder title | 200 characters |
| On-chain root list | under 10,240 bytes |
Site size in lns publish | 2,000 files, 200 MiB in all, 100 MiB per file (defaults, configurable) |
Previous tree read by lns publish when diffing | 50,000 files and 50,000 folders |
Appendix B lists every limit across the browser, the gateway and the publisher.
5.11 Logos Storage
Site files and folder lists live on Logos Storage, a peer-to-peer content-addressed network. This section describes how LNS web uses it today.
- What a node is. A Logos Storage node (currently v0.5.3 on
logos.test) stores blobs by CID, exchanges them with peers, and serves a local HTTP REST API under/api/storage/v1(POST /datato upload,GET /data/<cid>for local reads,GET /data/<cid>/network/streamto fetch over the peer network, andGET /debug/infofor node identity). Basecamp bundles a built-instorage_modulenode; users and publishers can also point at an external Storage node (never port8080, which belongs to the Logos Blockchain node). - Uploading.
lns publishchecks/debug/infofirst and refuses local mock stubs (STANDIN_SEED_PEER_ID), so a publish never succeeds against a node nobody else can reach. It uploads each new or changed file and folder list with a bare MIME type (no; charset=…parameter, which real nodes reject with HTTP 422) and falls back toapplication/octet-streamon HTTP 422 or 415 (storage.mjs,storage.rs). A node's default block TTL is 30 days, so long-lived hosts set an explicit long--block-ttl(never0, which in v0.5.3 expires new blocks immediately). - Who keeps files available. There is no storage rent or marketplace yet. A file stays reachable only while at least one reachable Storage node holds it. Today, a Storage node we run (with a long block TTL and a 40 GiB quota) holds the sites we publish and backs both the gateway and the browser's built-in seed peer. Anyone publishing their own site needs a Storage node of their own (or another peer) to keep holding its files.
- The built-in seed peer. On a fresh install with no custom peers configured, the Names Browser connects to one built-in seed peer (the Storage node we run) so sites load immediately. It is on by default, can be turned off or replaced in Settings, is refreshed at most every 5 minutes, and stays off if Settings cannot be read (section 2.7.1).
- When files go missing.
- Names Browser: retries up to 6 times with exponential backoff (2 s up to 30 s; 60 s timeout on the first root attempt, 30 s on retries, 25 s on subresources;
logic.mjs). If the bytes still cannot be fetched, it shows an error page with peer connection counts and the last error — or, if an older verified version of that site is in local cache, keeps showing the older version with a banner (section 6.5). - Gateway: answers 504 on a Storage timeout (and puts that CID in a 30-second cooldown) and 502 when Storage reports not found or another fetch failure (section 8.4).
- Names Browser: retries up to 6 times with exponential backoff (2 s up to 30 s; 60 s timeout on the first root attempt, 30 s on retries, 25 s on subresources;
- Peer discovery (upstream issue #1556). Because peer discovery on Logos Storage can be slow or fail to locate files, three workarounds are in use: inside Basecamp, a patched
storage_modulefix for #1556 is used rather than falling back to the HTTPS gateway; the Names Browser lets users configure explicit Storage peers (and ships the built-in seed peer); and the gateway's Storage client useslocalFirstmode, trying local/data/<cid>(2 s timeout) before/data/<cid>/network/stream(10 s timeout).