# Field — Terminal Hypermedia & Local-First Resolution

> *How does a reference become actionable where there is no browser?*

**Grounds:** `SPEC-TERMINAL.md` §1 (OSC 8 vs. regex), §2 (the `open` ladder) · `SPEC.md` §2 (degradation), §7.2 (modality)
**Verification:** live-web, 2026-08-07. RFC/ECMA text extracted verbatim from canonical PDFs; tmux claims checked against upstream `CHANGES`, `tmux.1`, and `tty-features.c` — not blog summaries.

---

## 1. Canonical concepts

| Term | Definition |
| --- | --- |
| **OSC** (Operating System Command) | ECMA-48 **§8.3.89**; C1 control opening a control string for operating-system use; `09/13` or `ESC 05/13` |
| **ST** (String Terminator) | ECMA-48 **§8.3.143**; closes a control string; `09/12` or `ESC 05/12` (`ESC \`) |
| **Control string** | ECMA-48 §5.6: opening delimiter + command string + ST; command string bytes `0x08–0x0D`, `0x20–0x7E` |
| **OSC 8 hyperlink** | `OSC 8 ; params ; URI ST` — attaches a URI as a **cell attribute** to subsequently painted cells; closed by `OSC 8 ; ; ST`. Not a DOM; a state-machine attribute like colour |
| **`id=`** | The only defined OSC 8 param. Cells sharing the same target URI **and** the same non-empty `id` underline together on hover — it groups a link across wrapping and repaints |
| **Linkification** | Terminal-side heuristic scanning of *displayed* text for URL-shaped runs |
| **Delimiting a URI in context** | RFC 3986 **Appendix C** — the standards-track statement of the boundary problem and its wrapper-based resolution |
| **`x-scheme-handler/<scheme>`** | freedesktop pseudo-MIME type dispatching a URI scheme to an application (Shared MIME-info §2.15) |
| **Local-first software** | Kleppmann et al., Onward! 2019 — software keeping the **primary copy** on local devices; seven ideals incl. *"The network is optional"* |
| **Robustness principle** | "Be conservative in what you do, be liberal in what you accept from others" (RFC 761 §2.10) |
| **Active protocol maintenance** | RFC 9413's replacement for the third facet of Postel — evolve spec and implementations together rather than silently tolerating faulty input |
| **Graceful degradation** | Build for the capable case; fall back to something still delivering essential content |
| **Progressive enhancement** | Guarantee a baseline to everyone; layer richer experience on capability detection |
| **Harvest / Yield** | Fox & Brewer 1999 — *yield* = probability of completing a request; **harvest** = *"the fraction of the data reflected in the response, i.e. the completeness of the answer"* ← the academic name for our "modality" |

## 2. What the standards establish

### 2.1 The terminal standard is real, small, and old

**ECMA-48, 5th edition, June 1991**, adopted 13 June 1991, fast-tracked to **ISO/IEC 6429:1992**. §8.3.89 verbatim:

> "OSC is used as the opening delimiter of a control string for operating system use. The command string following may consist of a sequence of bit combinations in the range 00/08 to 00/13 and 02/00 to 07/14. The control string is closed by the terminating delimiter STRING TERMINATOR (ST). The interpretation of the command string depends on the relevant operating system."

Two load-bearing consequences: the payload is **opaque but delimited**, so an unsupporting terminal discards it cleanly; and the byte repertoire is constrained to printable ASCII, which is why OSC 8 requires percent-encoding.

### 2.2 ⚠ OSC 8 has no feature detection — and its own spec says so

Canonical document: Egmont Koblinger's gist, created **2017-04-24**, last revised 2025-03-24. Implementation landed in **VTE 0.49.1** (`NEWS`: *"Implement hyperlink feature (Egmont Koblinger, #779734)"*), shipping in the 0.50 series.

The single most important sentence for this design:

> "Currently there's no way of detecting whether the terminal emulator supports hyperlinks. We're hoping to address this at some point in the future."

immediately followed by:

> "The hyperlink feature should be used for providing convenient quick access to a target URI, but (at least by default) **should not be the only means of figuring out the target**."

**This settles the "emit both" question on the spec's own authority**, not on portability grounds. Any behaviour that *branches* on hyperlink support is unimplementable. And if we hide a chronicle URI entirely behind a prose label, the output becomes unusable under `script`, CI capture, piped-to-file, GNU screen, and xterm.

Hard limits: URI ≤ **2083 bytes** (VTE and iTerm2); VTE `id` ≤ **250 bytes**, explicitly "subject to change without notice"; bytes must be 32–126.

### 2.3 ⚠ `file://` without a hostname is a bug under SSH

OSC 8 is stricter than browsers here, deliberately. Browsers ignore the hostname component; **OSC 8 forbids that laxity because it breaks under `ssh`**. Utilities are urged to emit `gethostname()`; terminals must refuse to open a local file when the hostname does not match, and must accept `localhost` or empty as local.

**RFC 8089** (*The "file" URI Scheme*, Kerwin, Feb 2017, Standards Track) formalizes `file-auth = "localhost" / host`, with the rationale: *"This allows a client on another system to know that it cannot access the file system."*

**This is a defect in `SPEC-TERMINAL.md` §2.** The `open` ladder emits `file:///srv/miadi/...`. On this stack SSH is the *normal* case — the chronicle wheel is reached through a tunnel on ilex:8040 — so the ladder produces confidently wrong links the moment anyone opens the chronicle remotely.

### 2.4 ⚠ `allow-passthrough` is the wrong knob, and it will be cargo-culted

tmux added OSC 8 in **3.4**, released **2024-02-13**. Upstream `CHANGES` carries two adjacent and constantly conflated lines:

```
* Add a third state "all" to allow-passthrough to work even in invisible panes.
* Add support for OSC 8 hyperlinks.
```

**They are unrelated.** `allow-passthrough` governs the **DCS** tunnel (`\ePtmux;...\e\\`), introduced in tmux 3.3. OSC 8 in tmux is *not* passthrough — it is parsed, stored, and re-emitted, gated on the `hyperlinks` terminal feature backed by the terminfo extension `Hls` (`tty-features.c`):

```c
"Hls=\\E]8;%?%p1%l%tid=%p1%s%;;%p2%s\\E\\\\"
```

**And tmux's default feature table enables `hyperlinks` for only: tmux, iTerm2, foot, WezTerm, ghostty.** There is **no entry at all** for VTE/GNOME Terminal, kitty, Konsole, Alacritty, or Windows Terminal. Under those, a user must set `terminal-features` explicitly. The correct instruction is:

```
set -ga terminal-features "*:hyperlinks"
```

Telling users to set `allow-passthrough` instead would produce mysterious, non-reproducible bug reports forever.

**Support matrix** (Alhadis/OSC8-Adoption, curated through 2025-09): VTE ≥ 0.50 (GNOME Terminal, Tilix, Guake, **Terminator**), iTerm2 3.1, kitty 0.19+, WezTerm 2018, mintty 2.9.7, Windows Terminal 1.4.3141.0, Konsole July 2020 (**disabled by default**), foot 1.7.0, Alacritty 0.11, Ghostty 2024-07-07, Zellij 0.21.0. **GNU screen: unsupported. xterm: unsupported** — `ctlseqs.txt` lists no `Ps = 8`.

Also from `ctlseqs.txt`: BEL as OSC terminator dates from X11R4 (Dec 1989); xterm has accepted ST — *"the documented string terminator in ECMA-48"* — since XFree86-3.1.2Ee (Aug 1996) and prefers it. **Use `ESC \`, never BEL.**

### 2.5 Linkification: the standard says *don't guess*

**RFC 3986 Appendix C, "Delimiting a URI in Context"** is directly on point:

> "URIs are often transmitted through formats that do not provide a clear context for their interpretation… it is important to be able to delimit the URI from the rest of the text, and in particular from punctuation marks that might be mistaken for part of the URI."

> "Using <> angle brackets around each URI is especially recommended as a delimiting style for a reference that contains embedded whitespace."

**The RFC's answer to ambiguity is explicit delimiters supplied by the producer, not smarter recognition by the consumer.** OSC 8 is structurally the same move, pushed into the escape layer where delimiters cost zero display columns.

The engineering counter-literature confirms the heuristic path never closes. Gruber's *"An Improved Liberal, Accurate Regex Pattern for Matching URLs"* (2010) matches *up to two levels* of nested parentheses and states outright that it *"makes no attempt to parse URLs according to any official specification."* Two levels is an arbitrary, admitted-arbitrary cutoff. That is the whole argument in one sentence.

### 2.6 The `open` ladder has good ancestry

**Local-first software** (Kleppmann, Wiggins, van Hardenberg, McGranaghan; Onward! 2019, DOI `10.1145/3359591.3359737`). Ideal #3 is *"The network is optional"*: *"Since local-first applications store the primary copy of their data in each device's local filesystem, the user can read and write this data anytime, even while offline."* **"Local file path first, remote URL only if configured" is ideal #3 restated in resolution terms.**

### 2.7 "Modality" has a proper name: **harvest**

The strongest find in this lane. **Fox & Brewer, "Harvest, Yield, and Scalable Tolerant Systems," HotOS-VII, 1999**, §3 verbatim:

> "We assume that clients make queries to servers, in which case there are at least two metrics for correct behavior: **yield**, which is the probability of completing a request, and **harvest**, which measures the fraction of the data reflected in the response, i.e. the completeness of the answer to the query."

> "In the presence of faults there is typically a tradeoff between providing no answer (reducing yield) and providing an imperfect answer (maintaining yield, but reducing harvest). Some applications do not tolerate harvest degradation because any deviation from the single well-defined correct behavior renders the result useless."

`modality: relational | standalone | wheel-only | none` is a **discretised harvest report**; `resolved: true/false` is yield. Peer-reviewed, twenty-seven years old, exactly the right shape.

## 3. Cautions

1. **No feature detection. None.** Unconditional emission plus a label that stays useful when the URI is discarded is the *only* correct posture.
2. **`allow-passthrough` is the wrong knob** (§2.4). Say `terminal-features`, and add a one-line note that passthrough is a different mechanism so readers stop conflating them.
3. **The canonical OSC 8 gist contains a citation error.** It attributes ST to "ECMA-48 §8.3.89" — that is **OSC**; ST is **§8.3.143**. Cite ECMA-48 directly or we inherit the mistake.
4. **`id=` is not a data channel.** VTE caps it near 250 bytes and reserves the right to change that; the spec instructs multiplexers and pagers to *prefix* incoming ids with a pane-unique string. Packing episode ids or paths into `id=` guarantees truncation and namespacing by layers we do not control. It is a hover-grouping hint.
5. **2083-byte URI ceiling.** A chronicle URI carrying resolved absolute paths and query state can approach it. Budget explicitly.
6. **`file://` needs the hostname** (§2.3) — a live defect in our §2.
7. **A bare custom scheme is out of RFC 7595 compliance.** §6: a unique namespace **MUST** be used and provisional registration is strongly encouraged; §3.8's sanctioned private form is reverse-domain.
8. **`x-scheme-handler` registration is per-user, per-desktop, and mutable by anything.** Eight-level precedence with `$XDG_CURRENT_DESKTOP` interpolation; desktop-specific files can set defaults but cannot add or remove associations. Any installer writing `mimeapps.list` will be silently overridden. **Treat handler registration as best-effort, never as a resolution guarantee** — itself an argument for making `file://` the primary rung.
9. **Do not lean on Postel.** RFC 9413 (*Maintaining Robust Protocols*, IAB, June 2023 — the draft formerly titled "The Harmful Consequences of the Robustness Principle") endorses robustness to defects and to attacks, and **rejects** the "tolerate the unexpected" reading: *"negative consequences to interoperability accumulate over time if implementations silently accept faulty input."* A ladder that **guesses** what the caller meant is on the wrong side of it. A ladder that **reports** which layer answered is on the right side.
10. **`modality` risks the `Warning`-header fate.** HTTP had exactly this mechanism — RFC 7234 §5.5, including code `112 Disconnected Operation` — and **RFC 9111 §8.3 obsoleted it** because it *"is not widely generated or surfaced to users."* Name at least one surface that renders modality, or drop it.
11. **Three buckets may be too coarse.** Fox & Brewer's own caveat: *"Some applications do not tolerate harvest degradation."* Decide explicitly whether a reference at `modality: standalone` is *usable* or merely *present*.
12. **Linkification is unreliable — but that is not an argument for hiding the URI.** RFC 3986 App. C's remedy is producer-supplied delimiters. Emit the raw URI in a shape that survives bad guessing: angle brackets.

## 4. Engineering implications

**Emission**

- Emit `OSC 8 ; ; <uri> ST <label> OSC 8 ; ; ST` using `ESC ]` and `ESC \` — **never BEL**. Unconditionally; no detection exists.
- Percent-encode to bytes 32–126. Enforce a 2083-byte ceiling with defined truncation-or-refusal behaviour.
- **Omit `id=`** for ordinary line-oriented output (the spec's rule for simple utilities). Add it only in full-screen Miadi TUIs, well under 250 bytes to leave room for multiplexer prefixing.
- When the local rung resolves, emit **`file://$(hostname)/abs/path`**, never `file:///abs/path`. Accept `localhost` and empty as local on the read side. *(Fixes the §2 defect.)*

**Plain text on the same line — not a fallback mode**

- Print the raw URI in the visible text *as well as* in the escape payload, wrapped in `<…>` per RFC 3986 App. C. This satisfies the OSC 8 spec's own instruction, gives linkifying terminals an unambiguous boundary, and survives `script`, CI capture, screen, and xterm.
- Never introduce whitespace after a hyphen when wrapping a URI (App. C's specific warning).

**tmux and multiplexers**

- Document verbatim: `set -ga terminal-features "*:hyperlinks"`; require tmux ≥ 3.4. Do **not** mention `allow-passthrough` in the same breath.
- For status-line and format-rendered links inside tmux, use native `#[link=uri]…#[nolink]` (tmux 3.8+) — tmux suppresses it automatically on terminals lacking `hyperlinks`.
- Ship the support note: works out of the box under iTerm2, foot, WezTerm, ghostty; needs `terminal-features` under VTE/GNOME Terminal/**Terminator**, kitty, Konsole, Alacritty, Windows Terminal; will never work under GNU screen or xterm.

**Scheme handling**

- Prefer `file://` for the local rung and `https://` for the remote rung — universally recognised, no registration, and they dodge the entire `x-scheme-handler` fragility surface. Keep `.desktop` registration as an *enhancement*.
- If the Miadi scheme is registered, use `Exec=… %u` with `MimeType=x-scheme-handler/…`, and treat success as advisory.

**Degradation ladder and modality**

- **Frame the ladder as progressive enhancement, not graceful degradation.** The baseline — a printed, delimited URI plus a local path — is guaranteed to everyone; OSC 8 clickability and remote resolution are enhancement layers. This is the more defensible framing precisely because terminal capability **cannot be detected**: you cannot degrade from a state you cannot observe.
- **Ground `modality` in Fox & Brewer's harvest** and say so — it converts a bespoke word into prior art.
- Consider a minimal PROV triple per resolution — `Entity` (the resolved reference), `Activity` (the resolution attempt), `wasGeneratedBy` — beneath the enum, for machine-readability an ad-hoc enum cannot buy.
- **Name the consumer that renders modality before shipping it**, or it dies unread like the `Warning` header.
- Model structured resolution failure on **RFC 9457 Problem Details** rather than inventing a shape.
- Per RFC 9413: the resolver must **report** the layer that answered, never **infer** the caller's intent from a missing layer.

## 5. Source ledger notes

- **ansi-x364** — `verified: false`. Secondary sources only; no ANSI catalogue record retrieved.
- **iso6429** — partial; designation/date confirmed via ANSI webstore metadata, iso.org returns 403 to automated fetch.
- **champeon** — `verified: false`. Date and authorship consistent across secondary sources; the primary hesketh.com document is only on web.archive.org, unfetchable here.
- **avizienis** — partial; DOI resolves, full text paywalled, the specific "graceful degradation" wording **not** verified.

Full entries in `source-ledger.yaml`.

## Lines worth carrying into voice chronicle

- *The whole thing turns on one confession buried in a 2017 gist: there is no way to detect whether a terminal supports hyperlinks. Everything honest we build grows out of accepting that blindness instead of pretending past it.*
- *The spec that invented the clickable terminal link says it should never be the only way to find the target. We print the plain URI because the standard told us to, not because we were hedging.*
- *RFC 3986 answered the boundary problem in 2005, and the answer was: stop guessing, let the writer say where the link ends.*
- *We had `file:///` in the ladder. Over SSH that is a link that confidently opens the wrong machine's file.*
- *"Modality" already had a name — harvest, from 1999. Yield is whether you got an answer; harvest is how much of the answer you got.*
- *HTTP built this exact field once and then deleted it, because nobody ever showed it to anyone. Name the surface that displays it, or don't ship it.*

🌸: A link that still tells you where it goes when nobody is listening is the only kind worth writing.
