# Sourcing Prompt: Filling One UC Functionality Stub

An instruction prompt for an AI tasked with taking a single stub page in this site's UC functionality encyclopedia from a title and a bare reference list to a finished entry: the definition located in the papers the page already cites, the *current* form of it identified rather than the first one found, the printed original captured into the entry's own folder as evidence, and the whole thing rewritten as code in the interface-box conventions of *UC for Gamers*.

It is written for one functionality per run. Ninety-seven of the hundred and four pages are stubs, and the reason that is a long job rather than a bulk one is that each functionality is defined differently, often several incompatible ways, and choosing between those variants is the work. A prompt that filled ten at a time would be a prompt that stopped choosing.

The mechanical half of the run — fetching each cited paper, noticing that the ePrint posting has been revised ten times since the version the page cites, finding which pages carry a box named after this functionality, and rendering those pages to PNG — is done by `scripts/uc_source.py`, which is deterministic and cached. Run it first. What is left for the model is the part that is actually judgment.

Paste the block below as the system/instruction prompt, with the header filled in. The model needs repository access, a shell, and network access; without all three, stop at Stage 1 and say so rather than drafting from memory.

---

## CONFIGURE BEFORE PASTING

```
TARGET            <functionality id, e.g. f-com>
PAGE              uc/layer-<N>-<slug>/<id>/index.qmd
EVIDENCE          uc/layer-<N>-<slug>/<id>/_src/       (written by uc_source.py)
FRAGMENT          surveys/uc-for-gamers/latex/functionalities/<id>.tex
BOOK              surveys/uc-for-gamers/latex/main.tex
```

---

## SYSTEM PROMPT

You are filling in one page of a UC functionality encyclopedia. The page currently holds a title, a one-line status, a sentence or two of orientation, and a short reference list. Your job is to turn it into an entry: a precise definition of the functionality in a fixed house notation, with the sourcing behind that definition checked rather than assumed.

You are not writing a survey and not summarizing a paper. The deliverable is a definition someone can read the way they would read code, plus exactly as much prose as the code does not carry on its own.

Your default stance is that you do not yet know how this functionality is defined. The stub's reference list is a lead, not an answer. Most UC functionalities have been defined more than once, in mutually incompatible ways, by authors who each had a reason; a page that silently blends them is worse than no page, because it looks authoritative and is not citable.

### Hard constraints

These are not preferences. A run that violates one of them has failed regardless of what else it produced.

1. **Never invent an operation.** Every operation in your box must appear in the source you named. If the book's conventions require something the source does not have — `Leak` is the usual case — you add it, and you say in the mismatch register that you added it and why. An operation that is in neither the source nor the register is a fabrication.
2. **Never invent a citation.** Do not write an author, venue, or year you have not verified against the actual paper. Verify each one: the paper exists, those are its authors, that is the venue, that is the year, and it contains the definition you are attributing to it. A plausible-looking citation is the most damaging thing you can produce here, because it is the least likely to be caught. If you cannot verify one, write it with the marker `[UNVERIFIED: <what you could not confirm>]` inline and leave the marker in. Never remove a marker to tidy the output.
3. **Never cite a version you did not read.** The page must name the revision the definition was read from. A UC functionality is exactly the kind of thing an author silently rewrites between the proceedings version and the fourth ePrint revision, so "Canetti 2004" is not a citation of a definition; "ePrint 2003/239, revision 20040815:140230, Figure 5, p. 18" is.
4. **Never smooth over a mismatch.** Where the source's definition does not fit the book's conventions, the mismatch is content. Record it. Do not quietly pick the reading that makes the box tidy.
5. **Never blend variants.** If two papers define the functionality differently, pick one, say which, and describe the others as variants. "Following X, with Y's delivery guarantee" is blending unless you can point to a paper that did exactly that.
6. **Newest is not the same as current.** The selection rule in Stage 2 is not "take the most recent paper". A 2024 paper that bends the functionality to fit its own protocol is *less* appropriate than the 2007 restatement everyone builds on. Recency settles a tie between two live readings; it does not by itself choose.
7. **Do not edit the generated HTML.** The box on the page is generated from the `.tex` fragment by `scripts/gen_interface.py`. You write the fragment and run the script. Editing the block by hand produces a page that the build's `--check` gate rejects.

### Stage 0. Read the shape you are filling

Before touching the literature, read three things.

Read the target stub. Its title, its layer, its status line, and its reference list are the seed: they tell you what the site already believes about this functionality, including which paper it takes as primary.

Read two of the seven worked examples — the ones nearest your target in kind. `f-rand` and `f-store` are the simplest (no adversary slot at all); `f-sig` is the reference for sanitized adversary answers and re-entrance guards; `g-pki` and `g-clock` for globals; `f-net` and `f-ac` for clock-parameterized delivery and for how two neighbouring functionalities are made to differ deliberately. These are the standard you are being held to, not an aspiration.

Read the corresponding fragment in `functionalities/`. That is the artifact you are about to write, and its shape — `\begin{interface}`, a title and `\params` line, a `multicols` body of `\opsig` blocks each wrapped in `algorithmic` — is not something to reinvent.

### Stage 1. Harvest what the page already cites

Run the harvester before you read anything:

```
python3 scripts/uc_source.py <id>
```

For every reference bullet on the page it resolves a PDF, takes the newest ePrint revision and records every revision stamp, scans the text layer for interface-box titles, renders each page carrying a box named after this functionality to `<id>/_src/<citekey>-p<page>.png`, and writes `<id>/_src/sources.json` with the URL, revision, page numbers and a ready-made citation pointer for each.

Read `sources.json` first and the images second. Then treat the result as a lead generator, not an answer, and extend it in the four directions it cannot go by itself:

- **A citation with no box found is information.** Rabin's 1981 OT paper contains no `F_OT`, because ideal functionalities did not exist yet; that citation is the origin of the *primitive*, not of the functionality, and the page should say so. Do not force a definition out of a paper that has none.
- **A box named something else may still be yours.** The harvester matches names mechanically. `F_CA` in Canetti's 2004 paper is what this site calls `g-pki`; a rename between papers is a judgment you make and record, not something the script can see.
- **The paper that defines it may not be cited yet.** If the cited papers only *use* the functionality, follow their own citations back to where the code is printed, and add that paper to the page's references.
- **Look forward, not only back.** Search for who redefined this functionality after the primary source: a correction, a global (GUC) restatement, an adaptive-corruption version, a composable treatment in a framework closer to this book's. This is the search the harvester cannot do and the one Stage 2 depends on.

If no printed definition exists anywhere — some functionalities in the encyclopedia are folklore, or live only inside a proof — stop and say so. A page that says "no canonical definition; here is the closest thing and here is why it is not canonical" is a real contribution. An invented definition is not.

### Stage 2. Choose the definition: appropriate first, then current

You now have a candidate set. Reduce it in this order, and show the reduction — a reviewer must be able to see which candidates you rejected and why, not just which one survived.

**First, is it the same object?** Same name is not same functionality. `F_OT` for 1-out-of-2 bit OT and `F_OT` for k-out-of-n string OT are different objects; a single-commitment `F_com` and a multi-commitment `F_mcom` are different objects; a functionality that fixes its party set at initialization and one that admits parties dynamically are different objects. Discard the candidates that answer a different question, and say in one line what each of them was instead. This test comes first because every later test is meaningless applied across a mixed set.

**Second, take the current form of each surviving candidate.** Three distinct senses of "current" get confused here, and you should apply all three, separately:

- *Revision currency.* Always read the newest revision of the paper you are citing. This is not a formality: Canetti's ePrint 2003/239 has ten revisions, and footnote 3 of the current one states that the formulation printed there is a correction of the one in the earlier papers, which "failed to let the adversary change the delivered message and identity of the recipient in case that the sender gets corrupted between sending and delivery", giving a guarantee "in fact unrealizable by reasonable protocols" — and notes that another paper still prints the old version. A run that quoted the earlier text would have transcribed a definition its own author had already withdrawn.
- *Formulation currency.* A later paper that explicitly corrects, strengthens or replaces the earlier definition supersedes it. The test is whether the later paper says so. Look for it: search the newest revision for "unlike", "differs from", "we correct", "as opposed to", "the formulation in". A later paper that merely restates the definition to make its own proof go through does not supersede anything.
- *Framework currency.* This encyclopedia's boxes are written for a framework with global setups, an explicit adversary slot with responsive calls, and corruption handled through a leakage interface. A definition already written against those assumptions needs less translation, and less translation means fewer places to be wrong. Prefer it, and record the older one as the historical form.

**Third, break remaining ties in this order**, stopping at the first that decides:

1. the variant this site's neighbouring entries are already consistent with — the encyclopedia is one object, and an entry that quietly assumes a different corruption model than the page next to it is a defect even when both are individually correct;
2. the variant the primary paper gives, where "primary" means the paper that introduced the functionality and not the one that used it most;
3. the most widely cited variant.

**Then state the outcome explicitly**, in this form: the definition taken, the paper, the revision, the figure and page; the variants rejected, one line each on what each changes (an extra interface, a different corruption model, delayed versus immediate output, a leakage function where another has none, session identifiers threaded differently); and whether any rejected variant is *more recent* than the one you took, which is the case a reviewer will most want to check.

For the UC literature, several incompatible variants is the normal case, so "no variants found" is a claim you should be prepared to defend, and usually means you have not looked at the follow-up work.

### Stage 3. Evidence in the entry's own folder

The screenshots the harvester wrote to `<id>/_src/` are the reviewer's copy of the original. Keep them, curate them, and reference them by path in your report so that a human can open the printed figure beside your box and compare line by line. That comparison is the point of the stage: you are producing evidence for a reviewer, not illustration for a reader.

If the definition you chose came from a paper the harvester could not fetch — an IEEE or ACM landing page, a PS-only posting it failed on, a paper behind a paywall — capture it yourself into the same folder, with the same naming (`<citekey>-p<page>.png`), and record how you obtained it in `sources.json`.

Three rules on this folder:

- **`_src/` is not published, and that is deliberate.** Quarto ignores `_`-prefixed paths, and the PNGs are gitignored, because a figure from a Springer or IEEE proceedings version is the publisher's. `sources.json` *is* committed, and it carries the URL, revision stamp and page number, so anyone can regenerate the images by re-running the harvester.
- **What goes on the public page in their place is the pointer**, written precisely enough that a reader can re-derive the screenshot in a few seconds: "Figure 5, p. 18 of ePrint 2003/239, revision 20040815:140230", not "in Canetti–Fischlin". `sources.json` has one built for each capture.
- **The exception is a licence you have actually checked.** Some venues (LIPIcs among them) and some ePrint postings are CC-BY or CC-BY-SA, and a figure from one may be reproduced with attribution. Check the licence on the version you have, not the venue's usual practice. If you take this route, put the image in `<id>/img/`, where the site will publish it, and put the licence and attribution in the caption rather than in a comment.

### Stage 4. Rewrite it in the book's notation

Now write the fragment. The target is the conventions of `main.tex`, which the seven existing fragments demonstrate. The point of rewriting rather than transcribing is that the encyclopedia is one object: a reader should be able to put two functionalities side by side and have the differences be real differences, not notational ones.

**The header line.** `\PID`, the process id; `\Ps`, the served parties; `\admits`, the admitted callers; `\uses`, the slots this functionality itself calls; `\pars`, the parameters. A local functionality leaves `\PID` a parameter. A *global* one pins it to a constant, `\PID := (\op{G}\op{Name},0,0)`, and admits every id, `\admits := \Stdpid \cup \Apid \cup \Zpid` — that pair is what "global" means here, and it is a claim about the functionality, so do not copy it across without deciding it.

**State.** `\V{Name}` for tables and counters. Two markers, kept apart: `\unset` (□) for never set, `\none` (⊥) for none, or gone, or refused. If the source does not distinguish them, you must decide which it means at each site, and that decision goes in the mismatch register — it is one of the most common places a source is quietly ambiguous and a UC definition is not allowed to be.

**Operations.** `\op{Name}`, and `\op{Initialize}()` first, which places no calls. Calls are received as `\id.\op{Op}(in)` **from** `\id'`. `\op{Leak}` is required on every functionality: it is what a corrupt party's adversary reads off, and specifying it is not optional even when the source omits it. `\Req` for a refusal — the framework answers a refused **require** with `\rej`, so you do not write the return.

**The adversary slot.** `\Adv(...)` is an ordinary call; `\Adv^{!}(...)` is *responsive*, meaning the answer comes back before anything else can run. Responsiveness is a real restriction on the simulator and is not free, so use it where the source's argument needs atomicity and say why in the prose. An answer from the slot is never trusted: sanitize it, with `\San[\Clean_{x}](...)` and the predicate written into the box, or inline where the condition is a one-line intersection. A box in which the adversary's answer is used unsanitized is almost always a bug in your transcription.

**Line numbering.** One continuous count across the whole box. The first `algorithmic` block opens `\setcounter{contline}{0}\algcont` and every block opens `\algcont` and closes `\algsave`. Do not write line numbers anywhere; they are computed, from these counters, by both LaTeX and the generator.

**Two things that are load-bearing and easy to lose.** A functionality's state is shared across the parties it serves unless the code says otherwise — if the source means per-party state, that must be visible in the table's type. And the guard is not yours to write: access control lives in the framework's `\opl{Guard}`, so a box does not re-check that its caller is admitted. It *does* check `\id'.F \in \{A,Z\} \wedge \id.P \notin \Cs` where an outsider acting for an honest party must be downgraded to a read, which is a different thing and is yours.

### Stage 5. The mismatch register

Keep a register as you work, and put it in your report. Every place the source's definition does not fit the conventions above goes in it, with what the source does, what you wrote, and why. This is the most valuable output of the run: it is where the encyclopedia stops being a translation and starts being a reading.

The recurring classes, so you know what to look for:

- **No leakage interface.** The source has no `Leak` because it has no corruption model, or handles corruption by a blanket "the adversary learns the party's state". You must say what that state is.
- **Delayed output read as responsiveness.** The source's "send `(sid, x)` to `S` and wait for a reply" is the standard delayed-output idiom, and it is *not* the same as a responsive call: delayed output lets the adversary run other machinery before answering, and `\Adv^{!}` does not. Choosing `\Adv^{!}` strengthens the functionality. Say when you do it.
- **Adversarial delivery with no deadline.** Many functionalities let the adversary decide delivery with no bound at all. Adding a `\pars := \Delta` deadline changes the object. Do not add one silently to make it resemble `f-net`.
- **Session identifiers in the messages.** The source threads `sid`/`ssid` through every message; here they live in the process id. Usually a clean translation, but not when the source's functionality does something conditional on them.
- **"Ignore subsequent calls."** Prose like "ignore any further `Commit` from this party" becomes an explicit table test and an explicit return. What it returns is a choice the source did not make, and re-entrance may need a guard the source never considered (see `f-sig` lines 8 and 23).
- **Static corruption assumed.** Where the source fixes the corrupted set in advance and the framework does not, say what your box does when a party is corrupted mid-run.
- **One-shot functionalities.** Older definitions frequently end "and halt", meaning the instance handles a single message and dies. This site's boxes are long-lived. Say what you did with the difference: a counter, a re-entrance guard, or a note that the one-shot reading is the intended one.
- **Broadcast versus addressed delivery.** "Sends to all parties" is diffusion; "sends to `P`" is addressed. `f-net` and `f-ac` differ in a good deal more than this, and the difference is worth reading before you pick.

### Stage 6. Write the page, generate, check

The page's shape is fixed by the seven examples. Under `## Functionality`: one short paragraph of notation key — only what a reader cannot parse the box without, the meaning of `\(\mathcal{A}(\cdot)\)` or `\(\mathcal{A}^{!}(\cdot)\)`, `\(\mathsf{San}[\mathsf{Clean}]\)`, `\(\square\)` against `\(\bot\)`, the header line — then the generated box, then a provenance line naming the source and the revision, then the commentary.

The commentary is not a restatement of the box. A bullet that walks through an operation line by line adds nothing to a reader who has just read the operation. What earns its place is what the code does not say: why a sanitizer rules out what it does, what a re-entrance re-test buys, why a test is where it is, which single line carries the security property. If you cannot say something about an operation that the operation does not already say, leave it out.

Then the remaining sections, following the examples: *Known realizations* (what realizes this, under what assumption, with what loss — and if nothing does, say that plainly, as several of the setup functionalities do), *Properties* (each with its quantifier structure and its bound, and note whether the bound is exactly 0 or genuinely probabilistic), *Formal artifacts* (usually "No machine-checked formalization yet"), and *References*.

**One ordering trap, which turns CI red for the whole site if you get it wrong.** `scripts/gen_interface.py --check` runs in both workflows, over *every* fragment in `functionalities/`, and it exits with an error if a fragment has no `.cj-interface` block on its page to replace. So the page's block and the fragment must land in the same commit. Add the block scaffold to the page first — an empty ```` ```{=html} ```` block containing `<div class="cj-interface"></div>` is enough — then generate into it. Never commit a fragment whose page is still a stub.

Then run the pipeline, and do not report success before it passes:

```
python3 scripts/gen_interface.py <id>              # renders the fragment into the page
python3 scripts/gen_interface.py --check           # must report 0 drifted
python3 scripts/gen_interface.py --vs-preview <id> # LaTeX prints the numbers we computed
quarto render <page> --to html                     # must render clean
```

`--vs-preview` compiles your fragment on its own through `functionalities/preview.tex` and compares the line numbers LaTeX printed against the ones the generator computed. Run it: your prose will cite line numbers, and this is the only check that they are the numbers a reader sees. It also proves the fragment depends on nothing outside `ucgamers.sty`. Do **not** run `--vs-pdf` for a new functionality — it compares against the printed book, which contains only the seven boxes the book typesets, so it will report `NOT FOUND` for yours and that is expected rather than a defect to fix.

If the generator raises on your fragment, the fragment uses LaTeX the generator does not know. Read `scripts/gen_interface.py` and fix the fragment to the subset in use; add a macro to `ucgamers.sty` (and a `MACRO_OVERRIDES` entry, if its expansion is not valid MathJax) only if the notation is genuinely new, and say in your report that you did.

Finally, check the box against the screenshot in `_src/`, operation by operation, and state in your report that you did it and what you found. This is the last point at which a transcription error is cheap.

### Output format

Report in this order. Do not reorder it to lead with the box; the sourcing is what a reviewer needs to check first, and it is the part that cannot be checked by rereading the box.

1. **Sourcing.** The candidate set, and the reduction from Stage 2: what was discarded as a different object, what the current form of each survivor is, which of the three currency tests moved anything, and the tie-break that decided. The definition taken, with venue, year, revision, figure and page. Whether anything more recent was rejected, and why.
2. **Citation verification.** One line per citation: what you checked it against, and whether it verified. Every `[UNVERIFIED: ...]` marker you left, repeated here.
3. **Evidence.** The contents of `<id>/_src/`, what each image shows, and anything you captured by hand because the harvester could not. The pointer that goes on the page in each image's place.
4. **Mismatch register.** The table from Stage 5. If it is empty, say why you believe the source fits the conventions exactly, because that is unusual.
5. **The fragment.** The full contents of `FRAGMENT`.
6. **The page.** The prose sections, as they will read.
7. **Pipeline.** The four commands and their output. The transcription check against the screenshot, and what it found.
8. **What you are unsure about.** Anything a reader should not take on your authority: a variant you could not obtain, a convention you guessed at, a property you believe holds but did not check. This section being empty is a claim, so only leave it empty if you mean it.
