# Certify My Replication Dataset

Instructions for an AI assistant. The author may hand you `CERTIFY_INTAKE.txt` as a file or
paste its text into the conversation, with three answers (the replication folder, the Dataverse
installation's web address, and an existing draft or the collection for a new one) and three
boxes (do not change files; publish without asking; the data are confidential), or give you no
form at all. Anything
missing you ask for, one short question at a time. Everything else you work out from the
folder, the installation and the author's Dataverse account. Follow this document exactly.
Where it says stop, stop and ask the author.

The protocol is King, Xu and Yang, *Replication Certification at Publication: Checkable by
Anyone, Anywhere, in Seconds, Forever* (2026). You run two fixed programs on the author's
behalf: the author's program, whose command is `certify`, and, through the network, the
installation's certification service, which holds the archive. Written 22 September 2026 for
the author's program (version 0.2.0 since 18 October 2026); the command sequence below is what
its own tests run. Confidential data (the form's third box) added 6 October 2026, for the paper's
Section 3.5.

## What you are doing, and what you must not do

- The archive recognizes the author's program by the fingerprint of its installed files and
  refuses any other build. **Never rewrite the program, patch it, or substitute your own code
  for any step it performs** (closing, the practice runs, packing, the certified run, the
  certificate). If a step fails, report it; do not work around it.
- The program adds fixed capture code to a copy of the author's scripts; the check later
  confirms that each script is the original plus exactly that text. **Never edit the closed
  copy or the working folder the program writes.**
- **Never modify the author's original folder.** Work in copies. If a repair is approved, make
  it in a separate prepared copy and record it there.
- **The author's Dataverse API token passes through this conversation once, and nowhere else.**
  Ask for it in the chat only when Step 3 needs it, pipe it straight into `certify register`,
  and never write it into a file, a command line, or a later message. The service uses it once
  and forgets it (or, without an account of its own, keeps it until publication), and the author
  recreates the token afterwards; the registration's answer says which. The uploader secret the
  service hands back is different: `certify register` puts it in one file that only the author's
  account can read, because the program reads it from there.
- **Never publish without the author saying "publish"** in this conversation, unless the
  form's publish box is checked. Publishing is irreversible.
- Do not install system software or use administrator rights. Installing the author's program
  into a Python environment of its own is allowed, and reported.
- **Ask the author only for what you cannot find.** Work out the rest from the folder, the
  program's own analysis and the author's Dataverse account, and show the author what you found
  before acting on it.

## How to talk to the author

**Missing answers.** Three things cannot be worked out and must come from the author: the
replication folder, the repository's web address (a Dataverse installation), and where the
replication dataset goes in the repository (an existing draft's identifier, or the collection for
a new one). If any of them is blank in the form, or there is no form, or an answer does not work
(the folder does not exist, the address does not answer), ask for that one thing in one short
sentence, wait for the answer, then move to the next. One question at a time, never a list of
questions, never a guess. The certification service's address is not one of the three: it is
looked up (Step 0, item 3), and asked for only when the lookup fails and the form does not name
it.

**Your own safety rules.** Until the service has its Harvard name, its address is a bare server
number, and your own safety check may refuse a command that sends files to it or publishes there
(`certify deposit`, `certify submit`, `certify publish`, sometimes `certify register`). When that
happens, do not try to get around it and do not stop the certification. Say in one line what was
refused and why it is expected, show the exact command in a code block for the author to run (the
Run button beside it, or their terminal), say that it reads its secret from a file and shows nothing
secret, and continue from what the author pastes back. Never ask for the token again: the registration
is done once, and the other commands never need it.

**Progress.** The author is watching a chat window, so keep one progress line current. Print it
when a step starts and again when it ends, with the bar, the step count, the step's name and,
for steps that run the author's code, a time estimate:

```
Certification  [████░░░░░░]  4/10  Practice runs · about 2 min
```

The ten steps, in order: 1 folder, tools and service checked; 2 run order approved; 3 smoke
test done, with repairs if any; 4 draft registered; 5 closed, grade known; 6 deposited, receipt
and seed received; 7 certified run done, certificate written; 8 submitted, fields on the draft;
9 sealed, report shown, waiting for "publish"; 10 published and checked. Fill one block per
finished step. While a long command runs, run it in the background if your host allows and keep
the line updated; otherwise print the line before and after. Between progress lines, write one
short line per event, and details only where the author must decide. Never go more than about
three minutes without a line.

## Step 0. Read the form and check the ground

1. Confirm the replication folder exists and list its top level. Work out the languages from
   the file names: `.R`/`.r` is R, `.py` is Python, `.do` is Stata. Read the README and any
   paper draft (`.pdf`, `.tex`, `.md`, `.docx`) for the title, the authors and the description;
   you will need them in Step 3.
2. Check the runtimes the code needs are installed: `Rscript --version` and `python3 --version`.
   A missing runtime stops certification: the program's preflight refuses it, and the analysis
   must run on this machine. The author's program needs Python 3.12 or newer for its own
   environment (item 4); if `python3` is older, use `python3.12` or newer (from python.org or
   Homebrew) there, and keep the author's own Python, of any version, for the analysis, named
   with `--interpreter python=<path>` where the commands below take it. Version 0.2.0 runs R and Python; a replication dataset with Stata
   scripts cannot be certified yet. Stop and tell the author if the folder has `.do` files. The
   add-on libraries the scripts load (R packages, Python distributions) must be installed here
   too; Step 2b copies them into the prepared copy, where the runs look for them.
3. Find the certification service and check it answers. If the form names the service's
   address, use it. Otherwise ask the installation for its public tool list,
   `curl -s <dataverse address>/api/externalTools`, and take the `toolUrl` of the tool whose
   `toolName` is `certify`; the service address is that URL without its final `/tool`. If the
   list has no such tool either, ask the author for the service address (the installation's team
   gives it out). Then `curl -s <service address>/health` must answer `{"ok": true, ...}`. If
   not, stop; there is no offline mode.
4. Check the author's program is installed: `certify --version` answers `certify 0.2.0`. If the
   command is missing, install it into an environment of its own, and first check that what you
   download is the certification team's. Make the work folder of item 5 now. The form's install
   line names the requirements file, `<site>/dist/requirements.txt`; `<site>` is that address
   without `/dist/requirements.txt`.
   1. The checksum list is published twice, on the site and on its mirror at GitHub,
      `https://iqss-research.github.io/certify/SHA256SUMS`. Fetch both and compare:
      `curl -fsS <site>/SHA256SUMS -o <work>/SHA256SUMS` and
      `curl -fsS https://iqss-research.github.io/certify/SHA256SUMS | diff - <work>/SHA256SUMS`.
      If either is missing or they differ, stop and tell the author; install nothing.
   2. Fetch the requirements file and these instructions as files, and check both against the
      list: `curl -fsS <site>/dist/requirements.txt -o <work>/dist/requirements.txt --create-dirs`,
      `curl -fsS <site>/CERTIFY_PROMPT.md -o <work>/CERTIFY_PROMPT.md`, then
      `cd <work> && grep -E ' (dist/requirements.txt|CERTIFY_PROMPT.md)$' SHA256SUMS | shasum -a 256 -c`.
      Both lines must say `OK`; otherwise stop and tell the author.
   3. Install from the checked file:
      `python3 -m venv <work>/env && <work>/env/bin/pip install --require-hashes --only-binary :all: -r <work>/dist/requirements.txt`.
      pip then refuses any file, of the program or of a package it uses, whose checksum is not
      in the requirements file.
   Without an install line, install from the folder or link the certification team gives out
   (two packages, `core` and `author`; in a test kit, its own `core/` and `author/` folders):
   `python3 -m venv <work>/env && <work>/env/bin/python -m pip install <given>/core <given>/author`.
   Either way, use that environment's `certify` everywhere below. Report what was installed. The
   program trusts the computer's own root certificates itself; should some other Python command
   of yours fail with a certificate error on a Mac whose Python came from python.org, export them
   once and set `SSL_CERT_FILE`:
   `security find-certificate -a -p /System/Library/Keychains/SystemRootCertificates.keychain > <work>/roots.pem`
   and prefix that command with `SSL_CERT_FILE=<work>/roots.pem`.
   On Windows (since 19 October 2026, built for it and awaiting its first tester): `python3` is usually a
   store shortcut, not an interpreter, so make the program's environment with `py -3.12 -m venv <work>\env`
   (or the python.org `python.exe`), and the environment's commands live in `<work>\env\Scripts\`
   (`pip.exe`, `certify.exe`); check a download with `certutil -hashfile <file> SHA256` or PowerShell's
   `Get-FileHash` against the list; Windows does not put R on the path, so name it,
   `--interpreter R="C:\Program Files\R\R-4.x.x\bin\Rscript.exe"`, wherever a command below takes it,
   and the analysis Python likewise with `--interpreter python=<path to python.exe>`; for the smoke
   test's time limit, PowerShell's `Start-Process -Wait` with a timeout, or no limit.
   How the runs are denied the network depends on the platform, and the certificate records which
   (`network_isolation`): a Mac's sandbox, with this computer's own addresses still reachable; on
   Linux a network namespace, which on Ubuntu 24.04 and later an ordinary user may make but not give
   a loopback, so the runs there reach not even this computer's own addresses and parallel workers
   over local sockets (R's `makeCluster()`, future's multisession) must be forked ones instead
   (`mclapply`, `makeForkCluster`, future's multicore) or run sequentially; where no namespace can be
   made, a kernel syscall filter that refuses every socket but a local pipe; and on Windows, which
   has none of these, proxy settings alone, which a program that ignores proxy settings can get past.
   `certify targets` prints a Note when the runs here deny local addresses too, or rely on proxy
   settings alone, and closing repeats it among its warnings.
5. Make a work folder outside the replication folder: the one the form names, or, when that line
   is blank, `~/certification/<folder name>-<date>/`. Say which folder you are about to make in
   your first progress line, so the author can name another with one word. Everything you produce
   goes there.
6. If the form's confidential-data box is ticked (or the README says the data are restricted,
   licensed, or in a secure facility), ask one question: which of the three kinds, by who may
   hold the data. (a) **Restricted**: the repository may hold the data but not publish them.
   (b) **Licensed**: the author holds them under terms that forbid depositing them with a third
   party. (c) **In a secure facility**: a research data center where data may be analyzed but
   not copied out. Record the answer; Step 2a applies it. A folder may have both (a) and (b)
   or both (a) and (c).

## Step 1. Propose the run order

Ask the program, without running anything:

```bash
certify targets <replication folder>
```

It prints the languages it found, then the entry scripts it would run and their order (the
scripts nothing else calls, in path order), or the reasons closing would stop (a runtime not
found, a file name that differs from another only in letter case, a symbolic link, an empty
folder). It also prints `Note:` lines for code that cannot work under certification (a package
installed while a script runs; a call that needs a person at the keyboard or RStudio, such as
`View()`, `rstudioapi`, `readline()`, `input()`) and for folders that are an installation rather
than the analysis (`renv/`, `.venv/`, `__MACOSX/`); each is a repair to propose in Step 2 (take
the line or the folder out of the prepared copy), and the scripts of such folders are never
proposed as targets. Name a runtime with `--interpreter R=<path to Rscript>` or `--interpreter
python=<path to python3>` when the one on the path is not the one the author uses.

It also proposes folders to be packed as one entry (Step 4, `--packed`): any folder of ten
thousand files or more, and, when the folder has more than a hundred thousand files in all, the
folders that bring the count under that ceiling, which otherwise stops closing. It leaves out a
script declared for an item computation (Step 2c), which is never a target.

Only `.R`, `.r` and `.py` scripts can be targets. A notebook or a document with code in it
(`.Rmd`, `.qmd`, `.ipynb`) is not run: the code must be in a script to be certified. If the
analysis lives in one, propose to the author, as a repair in Step 2, a script made from it
(`knitr::purl("x.Rmd")` for R Markdown; `jupyter nbconvert --to script x.ipynb` for a notebook)
and wait for a yes; the notebook stays in the folder as a document.

Show the author the list in plain words ("I would run A, then B, because B reads a file A
writes") and wait for a yes. If the README describes another order, or more than one order is
plausible, say so and ask. Record the approved order; you will pass it explicitly with
`--target`, one per script, in that order, so nothing is left to a default.

A package may hold scripts the README calls optional or slow (simulations that take hours, a
data build) whose results are already saved in the folder. Then there are two things the author
could certify, and the choice is theirs: present both, and say plainly what each certificate
would cover. Certifying the shorter path alone certifies what it makes from the saved results;
the slow scripts stay uncertified, their saved outputs count as data, and the certificate lists
exactly which scripts ran. Certifying everything costs three runs of the slow scripts: the two
practice runs at closing and the certified run. Do not recommend the shorter path because it is
shorter; the time is the author's to spend.

## Step 1b. Tidy the package first, if the author wants it (optional)

A folder that is hard to run or to read (no entry point, stale files, absolute paths, no
README) can be put in order before certification with Yusaku Horiuchi's public guide for AI
agents, "AI-Assisted Research Project Management and Replication Guide", at
https://yhoriuchi.github.io/replication-package-guide/ (its copy button gives the agent's
instructions; only their Step 2, "Build the Replication Package", applies here). Offer it when
Step 1 or the README suggests the need; do it only if the author says yes, and only in the
prepared copy. Follow the guide for the structure, the single entry point (`master.R` for R), the
README, the figure and table crosswalk, the hygiene and the manifest, with these certification
rules on top, which win where they differ:

- **No clock in the logs or the outputs.** Leave the "Started" and "Ended" lines and every other
  time stamp out of the guide's logging helper: the certified run records its own times, and a
  file that carries the clock differs between the two practice runs and lowers the grade.
- **Nothing installs or reaches the network at run time.** No `renv::restore()` or
  `renv::activate()`, no `install.packages()`, no project `.Rprofile` that activates renv (remove
  it in the prepared copy; keep `renv.lock` as documentation if the author likes). The runs refuse
  the network by design, and Step 2b copies the add-on libraries in instead.
- **The master script is the single target** of Step 4 (`--target master.R`); the scripts it
  calls are run through it. Step 1's order becomes the order inside the master script.
- **Confidential data follow Step 2a**, not the guide's public-subset advice, where they differ.
- **Every change is an approved repair:** list each in `CERTIFICATION-NOTES.txt` as Step 2 says
  (the guide's own change report may be kept beside it). The original folder stays untouched.

Then continue with Step 2: the smoke test runs the tidied copy's entry point.

## Step 2. Smoke test, then repairs only with approval

In a scratch copy of the original folder, run each target once with its own runner (`Rscript
X.R`, `python3 X.py`), from the folder's root, with a time limit. macOS has no `timeout`
command; `perl -e 'alarm shift; exec @ARGV' 600 Rscript X.R` gives a 600-second limit. Record
exit codes and the last lines of output, then delete the scratch copy. Repeat the smoke test after
every repair, until every target completes: a script often fails a second time further down.
Every run starts in the folder's root, whatever folder the script is in: a path written from the
script's own folder (`../data/x.csv`; `source("helpers.R")` from inside `code/`) fails with
`cannot open the connection` or `No such file`, and a `setwd()` or `chdir()` that climbs above the
root is refused as an outside reference; the repair is to spell the path from the root. Figures
draw to files only (`MPLBACKEND=Agg`), so `plt.show()` returns at once and needs no repair, and the
ids inside an SVG figure are fixed (`svg.hashsalt`), so two runs agree on it; a script that begins
with a byte-order mark loses it in the closed copy, nothing else changes.

If a script fails:

- If the form's "Do not change any file" box is checked: stop, show the error, and end here
  with the report.
- Otherwise propose the smallest repair that makes the script run without changing any
  computation, seed, data value or output: typically a removed argument, an obsolete function
  call, a path spelled for another computer. Show the author the exact before and after lines
  and wait for approval.
- Apply approved repairs to a **prepared copy** of the folder (never the original), and write
  every repair into `CERTIFICATION-NOTES.txt` inside the prepared copy: the replication dataset
  and its version, date, who approved, and each change in one sentence. The prepared copy is what
  gets certified.

Note each target's running time from the smoke test. During the two practice runs of Step 4 each
script may take up to an hour; one that needs longer stops closing with `TF`. For such a script
pass `--timeout-ms <milliseconds>` to `certify close`, one cap for every script (for example
`--timeout-ms 10800000` for three hours; the runs under the program's sampling take longer than
the smoke test did). After closing, the certified run allows each script three times its longer
practice run, never under an hour, so a cap is needed only at closing.

Scripts written to be run one after another in one R or Python session may rely on an object an
earlier script left behind, or on a package attached by hand; each target runs as its own
process, so such a script fails on its own. Propose the smallest repair that names the missing
piece (the defining lines copied in; a call written `package::function`). A script that cannot
run on the deposited data without changing the analysis is left out of the targets, said so in
`CERTIFICATION-NOTES.txt`, and reported to the author as a replication failure of the package.

If the smoke test shows that the code reads files outside the folder, show the author which
ones and ask: add them to the prepared copy, or declare them the way the program expects: one
line per file in `.certified/deps.txt` inside the prepared copy, spelled
`<path under .certified/deps/> <web address> <sha256>`, with the code reading the file at that
path; declared outside files are fetched at closing and recorded in the certificate for the
reader to see. Undeclared outside files stop closing.

## Step 2a. Confidential data: prepare the copy (only if Step 0, item 6 applies)

All of this happens in the prepared copy, before closing, and nothing here changes a
computation. Explain each command to the author in one sentence before running it.

**Restricted data (kind a).** Make the deposit restricted:

```bash
certify restrict <prepared copy>
```

This adds a salt file (`certified_salt.bin`, 32 random bytes) to the copy. From now on every
fingerprint the certificate publishes is mixed with it, so nobody can confirm a guess about a
file from the public record. Run this before declaring any outside file, and never remove or
replace the salt file. Tell the author: the packed files and the run's evidence will be stored
in Dataverse as restricted files; readers request access and the author approves; the
certificate itself is public.

**Licensed data (kind b).** For each file the author may not deposit, the code must read it
under the dependency root, `.certified/deps/<path>`; adjust the prepared copy's reading line (a
path change only, shown to the author like any repair). Then declare it from the author's copy:

```bash
certify declare <prepared copy> <path> --held <the file on this computer> --custodian author \
  --source "<the data's provider or name>" --version "<the release or year>"
```

This writes the declaration line (the file's fingerprint, salted under a second salt file) into
the copy and makes the salt file `<prepared copy>-held-salt.bin` beside the copy. The data never
enter the copy. Tell the author to keep that salt file with the data; a reader with the same
licence needs it to check them. Step 4 and Step 6 place the file for the runs with `--held
<path>=<the file>`. A whole folder of licensed files (a corpus of documents) is declared as one
entry: give its declared path with a trailing slash, `certify declare <prepared copy>
licensed/corpus/ --held <the folder on this computer> ...`, and place it with `--held
licensed/corpus/=<the folder>`.

**A secure facility (kind c).** The author's program and this whole sequence run inside the
facility, on a machine that can reach the data; closing and the certified run need no network,
only `certify deposit`, `certify submit` and `certify status` do, so the working folder is
carried out for them (it holds the packed copy, the receipt and the certificate, never the
held data). Declare each held file as for licensed data, with `--custodian <the facility's name
as the archive's key log lists it>`. Before Step 7 the facility's staff run the checker over the
held files and sign a custodian statement; ask them for it as a JSON file (`statement`,
`signature`) and pass it to `certify submit --custody <file>`. Without it the archive refuses
the certificate.

## Step 2b. Vendor the add-on libraries into the prepared copy

The runs load add-on libraries from the dataset's own library root, `.certified/lib/`, and from
nowhere else, so that the deposit carries what the analysis needs and a reader's re-run has it
(the paper's S2.3). Since 19 October 2026 this is enforced: each run's Python is a private copy
over the author's interpreter with no installed packages, R's own library paths point nowhere, the
run's home folder is private and empty, and the network is denied (this computer's own addresses
excepted, so local workers talk). A library the tree does not carry fails at closing with
`No module named ...` (Python) or `there is no package called ...` (R), and a library the run
reached by any other route stops closing with `(i) undeclared external reference: ... loaded ...
outside the deposited files`. `certify targets` names the libraries the scripts load that are
not there yet. Copy them in, with their dependencies, from the author's installation:

```bash
certify vendor <prepared copy> --target <first script> --target <second script> ... [--timeout-ms <ms>] [--interpreter R=<path>] [--interpreter python=<path>] [--held <path>=<file> ...] [--packed <folder> ...]
```

Since 19 October 2026 the command first runs the scripts once, in the approved order, against
this computer's own libraries, with the network denied, and copies what they actually loaded
(`Running the scripts loaded N libraries from this computer's installation (...): ...`); a
scan of the code is the hint only, so a comma import, a `pacman::p_load`, a library loaded
through a variable or by another library, and a library kept in a folder named in `~/.Renviron`
are all found. The run takes about as long as the smoke test did; give the approved order with
`--target` and, for a long script, `--timeout-ms` as in Step 4. A name the code mentions that
the run never loaded is reported as a note, not an error. If the run does not complete, the
command says so, copies what the scan found, and asks you to fix the script (Step 2) and vendor
again; `--no-run` skips the run and copies what the scan names alone.

It prints what it copied and the size. R's base and recommended packages and Python's standard
library are the runtime's own and are never copied. A library the runtime does not have is
named: the author installs it where the scripts expect it (that is theirs to do, not yours), then
you vendor again. Vendor again after any repair that adds a library call. The copies count toward
the one-gigabyte limit: the program measures the libraries before copying and, when the folder
with them would pass the limit, copies nothing and says so (exit status 1). An analysis whose
libraries do not fit needs a container image instead (`certify close --image <image>`; the archive
stores the image, and the tree then carries no library root). A single data file over the limit
cannot be deposited either; it can be declared instead (Step 2 for a public address, Step 2a for a
held file), and `certify targets` names the largest files when the folder is too big. A data
file over the limit that has neither a public address nor a custodian cannot be certified in this
version: the limit is the paper's, not the program's. Say so to the author plainly and stop.

## Step 2c. Results that cannot be rerun, and calls to outside services (only if they apply)

Two kinds of computation cannot simply be run again at certification: a call to an outside
service, such as a language model, and a computation too long to run three times. The protocol
checks each on a random sample drawn from the archive's seed, which nobody knew when the file
was fixed. Both are set up in the prepared copy, before closing; explain each command to the
author in one sentence before running it.

**Calls to an outside service.** If a script sends requests to a web service through `requests`,
`httpx` or `urllib.request` in Python, or `httr2`, `httr` or `curl` in R, record one live run
first:

```bash
printf '%s\n' '<the key>' | certify record <prepared copy> --target <first script> --target <second script> ... --env-stdin <VARIABLE>
```

The scripts run once with the service reachable; every request and its answer are written, with
credentials removed, into `.certified/service-recording.jsonl` inside the copy. Ask the author
for the key in the chat and pipe it in as shown; `--env-stdin <VARIABLE>` names the environment
variable the scripts read it from (`OPENAI_API_KEY`, for example), and the value is set for that
one run and written nowhere. Leave `--env-stdin` out when the scripts hold no key. From then on
every run, the two at closing, the certified run and any later re-execution, answers those
requests from the recording and sends nothing to the service, so the certified result does not
change when the service changes its models or closes. A request the recording does not hold
stops the step: if the author changes a prompt or asks a new question, record again. Two things
the scripts must tolerate, shown to the author as repairs if needed: the key is absent in every
later run (read it with a default, `os.environ.get("OPENAI_API_KEY", "")` or
`Sys.getenv("OPENAI_API_KEY")`, and give a client library a placeholder), and a request sent by
other means (a shell command, a library not listed) reaches the service live and is not recorded.

**A computation too long to rerun.** If the author saved per-item results (a classification of
each document, say) in a file inside the copy and the analysis reads that file, declare it as
an item computation:

```bash
certify declare <prepared copy> <saved file> --items <the column naming each item> --script <script> --seed <seed>
```

The saved file is a CSV with a header line, or JSON lines, one row per item; `--seed` is the
seed the results were computed under; `--script` names a script in the copy that recomputes
any listed items: it reads the identifiers from the environment variable `CERTIFIED_ITEMS` (a
JSON list), recomputes those items from the copy's files, and writes one JSON object per item,
in order, to the path in `CERTIFIED_ITEMS_OUT`. Usually the author's original script needs a
small wrapper for this; write it with the author's approval, as a repair, and keep it out of the
run order (an item script is never a target; `certify targets` leaves it out). At closing and
after the certified run the program recomputes 100 sampled items (or all, when there are fewer)
under the declared seed, seated as the author seats one, and compares them with the saved rows,
numbers to four significant figures and text exactly; any difference stops certification, so the
author can fix the cause before depositing.

## Step 3. Register the replication dataset with the certification service

**The button route.** If the author pressed **Certify** on their draft's page in Dataverse (Edit
Dataset, Configure Options), the page that opened gave them two lines, `archive address:` and
`uploader secret:`, and they paste them into this conversation. Then there is nothing to register
and no token to ask for: write the secret, and nothing else, into `<work>/uploader-secret` with
`chmod 600` (on Windows there is no chmod: a file in the work folder under the author's own profile is
already theirs alone), use the address as the service address everywhere `<service address>` or
`<archive_url>` appears, and take the dataset's identifier from that page's first line
("Replication dataset doi:..."). Dataverse gave the service a time-limited permission for that one
draft, so the service's account appears on no Permissions page and `certify publish` is not
available on this route: at Step 10 the author presses **Publish Dataset** on the dataset's own page
instead, and tell the author not to recreate their API token while the certification is under way,
since Dataverse ties the permission to it (pressing Certify again renews it). Go on to Step 4.
Everything below this paragraph is the token route.

Registration binds the author's Dataverse account and one draft replication dataset to the
uploader secret the later commands present. It needs the author's API token once. Ask for it in
this conversation, in one message that says what happens to it: the program sends it to the
certification service over an encrypted connection and keeps no copy; the service uses it once,
to create (or open) the draft and to let the service's own Dataverse account work on that draft,
and then forgets it; the author recreates their token right after (their name, API Token,
Recreate Token), which makes the pasted copy useless. Say also that it must not go into the form
or any file, and that you will not repeat it. (A service without an account of its own keeps the
token until the version is published; the registration's answer says which case applies and
what the author should do.)

The body you write names no token: the program adds the token itself when it sends the body, so
the file never holds it. If the author gave an existing draft, write the body with the draft's
identifier:

```json
{"dataset_pid": "doi:..."}
```

If the author gave a collection instead (its short name is the part of its page's address after
`/dataverse/`; if the author gave the address or the full name, take the short name from the
address or ask), draft the replication dataset's details from the folder:
the title as "Replication Data for: <paper title>", the authors from the paper or README, a
one-paragraph description from the README, and a subject from Dataverse's list (Social Sciences
unless the README says otherwise). The contact name and email come from the author's Dataverse
account automatically, and the new dataset gets Dataverse's default Terms of Use, CC0, under which
anyone may reuse the files; an author who wants other terms changes them on the dataset's page
(Terms tab, Edit) before publishing, and the program leaves that choice alone. Show the author the
title, authors, description and subject and wait for a yes, then write the body:

```json
{"collection": "<alias>",
 "dataset_metadata": {"title": "...", "authors": ["...", "..."], "description": "...", "subjects": ["..."]}}
```

Write it to `<work>/register-body.json`. An author who wants no email at the seal adds
`"notify": false`. Then register, piping the token in on standard input (never on the command
line, never into a file; the program refuses a body file that holds a token):

```bash
printf '%s' '<the token the author pasted>' | <work>/env/bin/certify register --service <service address> --body <work>/register-body.json --secret-file <work>/uploader-secret --answer <work>/register-answer.json
```

The program writes the uploader secret to `<work>/uploader-secret`, readable by the author's
account alone, and the rest of the answer to `<work>/register-answer.json`: `archive_url`,
`dataset_pid`, `dataset_url`, `dataset_created`, `pseudonym`, `login_kind`, `token_kept`,
`token_advice`, and `notices` when the service will email the author at the seal. `archive_url`
is the address for every `certify` command below (it is the service's own address). Tell the
author the draft's address, that the archive knows them only by the pseudonym, and the token
advice word for word: with `token_kept` false, they recreate the token now; with `token_kept`
true, after publishing. Say also, in your own words, what the advice says about the curator role:
the service's own Dataverse account is now a curator of the draft, which is how it stores the
packed file, writes the certificate fields and publishes when the author says so, and the author
can remove that role on the dataset's Permissions page once the version is published. If the program printed `The service refused the registration: ...`,
report the sentence. `Dataverse did not accept this API token` means the token is expired or
mistyped: ask for a fresh one. `Dataverse could not be asked who holds this token` means the
repository was unreachable for a moment and the token was not judged: wait a few minutes and run
the same command again with the same token.

## Step 4. Close: the two practice runs and the grade

```bash
certify close <prepared copy> --work <work>/certified --archive <archive_url> \
  --target <first script> --target <second script> ... [--interpreter R=<path>] [--interpreter python=<path>]
```

The program copies the folder, adds its capture code, freezes the settings that make runs
differ, runs the whole analysis twice under a fixed seed, compares every file the runs wrote,
grades the agreement, writes the closure report and packs the closed copy. It prints
`Closed. Tier <grade>; <n> target(s): ...`, the fingerprint `H(P*)` of the packed copy, and the
working folder. It takes about twice as long as one run of the analysis, plus the time closing
takes to ask CRAN and PyPI which vendored files are theirs (a minute or two for a few dozen
packages). For each held file
(Step 2a) add `--held <path>=<the file on this computer>`; the program checks the file against
its declaration, places it for the runs and never packs it. Add `--packed <folder>` for a folder
of many small files (`certify targets` proposes any with ten thousand files or more): it is
hashed as one entry, and a run may not write under it. Add `--gpu` when the analysis uses a
graphics processor; the environment record then names the processor, its driver and its
numerical software, and the certified run must use the same. If Step 2c applies, closing also
recomputes the sampled items (`Closing stopped. (spot) ...` names the item and the fields that
differ) and answers the recorded service calls without touching the network. A restricted deposit's closing also
prints the file names and dependency locators the certificate will publish: show them to the
author, who must rename anything that could name a person, an organization or a dataset before
depositing, since those names are part of the disclosure review. Any `Warning:` line (a number
that looks like a clock reading; workers that may share one random stream) is shown to the
author too.

Report the grade in the paper's terms: T0, every output byte-for-byte identical; T0-meta,
identical once generation noise such as an embedded timestamp is removed; T1, every number equal
within one part in a billion; T1-reported, equal to the four significant figures a paper
reports; T2, a numeric or structural difference that is not cosmetic. The program stops at T2
on the ordinary route (`Closing stopped. (ii) ...`), naming the outputs that differed and leaving
the two runs' report in `<work>/certified/closure-report.json` (each output's two hashes and
gaps): report which outputs differed and, where you can see it, why (the usual causes are an
unpinned seed, a timestamp written into a data output, or parallel computation left on; a date
written by stargazer, xtable or a PDF device is ignored by the comparison since 18 October 2026,
so a stop now means a real difference). The author may
fix the cause and close again, or take the disclosed route with `--disclose-t2`, which marks the
certificate `disclosed-T2`; journals' default look-up refuses marked certificates, so ask before
using it. A run that did not complete (`TF`) stops closing; go back to Step 2.

## Step 5. Deposit: the receipt and the seed

```bash
certify deposit --work <work>/certified --archive <archive_url> --secret-file <work>/uploader-secret
```

The archive fingerprints the packed copy itself, reads the public random value, signs the receipt
with the seed and appends its ledger line; the service stores the same bytes in the draft
replication dataset as one file. The program prints `Receipt received. Seed <n>.` and the
receipt's fingerprint. Tell the author what the dataset's page now shows and why: one file,
`replication-package.pack`, which holds their code and data exactly as certified, in one plain
uncompressed file; their individual files are inside it, not uploaded one by one, and the
certificate names that file by its fingerprint. The file's description on the page says the same
and lists what it holds. A packed copy of a hundred megabytes or more can take minutes to send and
to store (under a minute on a fast connection); wait for the answer. The program waits five
minutes plus a second per megabyte sent; if it still prints `Cannot reach the archive: ... did
not answer within ...`, the archive may have finished the work after the program stopped waiting:
run the same command again, and a deposit the archive already recorded is answered again, not
made twice. `(replayed: these bytes were deposited before)` means the author has
certified these exact files before; the earlier receipt is reused, which is right.

If your own safety check blocks this command as a possible data leak (a large upload to an
address it does not know), do not try to
get around it. Tell the author that the address is the one the form or the installation named,
show the exact command, and ask them to run it themselves (the Run button beside it, or their
terminal); it reads the uploader secret from its file and shows nothing secret. Then continue
from the result. The same may happen at Step 7 and Step 10, and the answer is the same.

Check the service: `curl -s <service>/status/<dataset_pid>` lists the deposit with its receipt
fingerprint and the packed file's fingerprint, and `restricted` and `held` when they apply.

For a restricted deposit the service stored the packed file as a restricted file and wrote the
draft's Terms of Access. For held data (Step 2a, kinds b and c) the deposit also carried the
author's held salt file, and the service stored it in the draft as a second restricted file,
`held-salt.bin`, so a reader who holds the same data under the same terms can request it and
check the declaration; the program says so, and `held_salt_file_id` on the status names it.

## Step 6. The certified run

```bash
certify run --work <work>/certified [--interpreter R=<path>] [--interpreter python=<path>]
```

One recorded run under the archive's seed, on this machine: every step's inputs and outputs,
transcript and captured estimates. It prints `Certified run complete: <n> step(s), <m>
output(s). Certificate fingerprint <hash>.` It takes as long as one run of the analysis. If it
prints `The certified run stopped: ...`, report the reason and stop. Held files are placed from
the copies closing recorded; pass `--held <path>=<file>` again only if they moved. If Step 2c
declared item computations, the sampled items are recomputed again, now under the archive's
seed. If Step 2c recorded service calls, the program re-sends a sample of them (100, or all) to
the live service after the run and reports how many were answered the same and how many went
unanswered; those counts go on the certificate as a disclosure, never a refusal. For that it
needs the author's key once more: ask for it in the chat and pipe the header in,

```bash
printf '%s\n' 'Authorization: Bearer <the key>' | certify run --work <work>/certified --credential-stdin
```

with the header name and form the service expects; the value is sent to the service alone and
written nowhere. For a restricted deposit or held files the re-sending is skipped and reported
as skipped, since it would send restricted data to a third party.

## Step 7. Submit: the archive checks and signs

For a restricted deposit, first the author's disclosure review. List every estimate the run
captured:

```bash
certify estimates --work <work>/certified
```

Show the numbered list to the author and ask which may be published beside the certificate:
every value is a candidate, including estimates the paper never reports, and the author must
judge that no published number identifies a person or an organization in the restricted data.
The author answers all, none, or names values to withhold. Then submit with the decision:
`--publish-estimates` (all), `--no-public-estimates` (none), or `--withhold N` for a whole
record and `--withhold N:coefficients/<name>` (or `standard_errors/<name>`, `sample_size`) for
one value, repeatable; withheld values are published as hiding commitments a reader with the full
record can check. A restricted deposit cannot be submitted without one of the three. For data in
a secure facility add `--custody <the facility's statement file>`.

```bash
certify submit --work <work>/certified --archive <archive_url> --secret-file <work>/uploader-secret [--publish-estimates | --withhold ... | --no-public-estimates] [--custody <file>]
```

The archive runs the protocol's checks on the certificate and the evidence. One of three
sentences comes back:

- `The certificate is received; the archive is waiting for the receipt's public timestamp
  before it signs.` This is the normal case: the archive signs only once the receipt's public
  timestamp has confirmed, which takes hours (see Step 8). The certificate fields are already
  on the draft, with the state `submitted`.
- `Sealed: the archive signed the witness. ...` The timestamp had already confirmed.
- `The archive refused the certificate: <reason>` (exit status 1). Report the reason and stop;
  do not try to change files to get around it. A second certificate for the same receipt is
  refused: one certificate per deposit.

Then check `curl -s <service>/status/<dataset_pid>`: the deposit's `metadata_written` must be
`true`. If it is `false`, report `metadata_error` and stop. On an installation without the
certificate block, the service records the certificate in fields every Dataverse has (an "Other
Identifier" entry named "Replication Certificate", a paragraph in "Notes", and a file
`replication-certificate.json` in the draft); `metadata_written` is still the flag to check, and
`curl -s <service>/health` says which of the two ways is in use (`certificate_fields`).

## Step 8. Wait for the seal

The archive's later pass gathers the timestamp's confirmation and then signs the witness; the
service rewrites the draft's fields to the state `sealed` with the witness's ledger line. Check:

```bash
certify status --work <work>/certified --archive <archive_url>
```

Until it prints `Sealed: ...`, nothing can be published; the gate refuses an unsealed
certificate by design. Tell the author how long this usually takes (one to a few hours) and
that they can close this conversation and come back: the service keeps working, and the
Certify page `<service>/tool?datasetPid=<dataset_pid>` shows the checklist. If the registration's
answer carried `notices`, tell the author the service will email their Dataverse account's
address when the certificate is sealed (or if a later check fails); the email carries the
citation of Step 9, and `<service>/status/<dataset_pid>` carries it too. When the author returns,
run the status command and continue here. Do not poll more often than once a minute.

## Step 9. Show the author, then wait

Report, in plain words and in this order: the scripts run and their order; the grade; any
repairs made; the receipt's ledger line and the seed the archive issued; the certificate's
fingerprint and the witness's ledger line; the replication dataset's draft address and the
certificate fields now on it (`<service>/status/<dataset_pid>` shows them as the service knows
them; the replication dataset's page shows them as Dataverse holds them); where the working folder
is. When the state is `sealed`, the answer to `submit` (its `dataverse.citation` part) or
`<service>/status/<dataset_pid>` (its `citation` part) carries the replication dataset's formal
citation, with "Certified" at the end, and a sentence for the paper. On the button route neither
carries one, since the permission Dataverse gave covers no citation read: tell the author to take the
citation from the Cite Dataset button on the dataset's page once it is published and to add "Certified"
at its end, and give the sentence with that citation. Show both, word for word, and
add: "Put this sentence in your paper or in its acknowledgments footnote, and add the citation to
your references. Most authors also list the replication dataset on their CV, in a data section or
under the published article, and link to it from their website." For confidential data add which
files are restricted in the draft (the packed files, the run's evidence once sealed, the
licensed data's salt file), that the author approves access requests in Dataverse, and which
estimates were published, withheld or kept back. Then, on the token route: "Say 'publish' to publish
this version in Dataverse. Publishing is irreversible." On the button route (Step 3): "Press Publish
Dataset on your dataset's page in Dataverse when you are ready. Publishing is irreversible; the service
records the publication within about an hour."

Do not publish until the author says "publish", unless the form's publish box is checked.

## Step 10. Publish

On the button route (Step 3), do not run `certify publish`: once the Certify page's checklist shows
"Ready to publish" (`curl -s <service>/status/<dataset_pid>` shows the deposit `sealed` or `confirmed`
with `metadata_written` true), tell the author to press **Publish Dataset** on the dataset's own
page; where the installation runs the service's workflows the publish check runs then, and the
status answer gains `published_version` within a minute of the release. Without the workflows the
service notices the release on its own within about an hour, and the status answer gains it then.

On the token route, only on the author's word "publish" in this conversation (or the form's box):

```bash
certify publish --archive <archive_url> --secret-file <work>/uploader-secret
```

The service publishes the draft as a major version with its own Dataverse account (or the token
it kept). It refuses while the certificate is unsealed, and it first runs the publish check
itself, the same check the installation's workflow makes (the file in the version is exactly the
certified one, and the fields name it), refusing with the reason when it fails. Dataverse then
releases the version within a few seconds; where the installation runs the service's workflows,
they check once more and tell the service, and either way the service records the archive's
publication line. Watch `curl -s <service>/status/<dataset_pid>`: `published_version` and
`publication_line` appear on the deposit once the version is released (within a minute), or a
`gate` part carries the reason when the publish check refused it and the version stayed a
draft. The usual cause of a refusal is a file changed after sealing, which means a new
certification of the changed files. If the service answers that the dataset's collection has
not been published, the author publishes the collection from its page first (one click), then
says "publish" again. Poll no more often than every ten seconds, for at most a few minutes. If
the registration's answer said the token was kept, now remind the author to recreate it.

Whichever route, the version publishes under the Terms of Use the draft carries: CC0 when the program
created the dataset, otherwise whatever the author set in Dataverse. The program never changes them;
an author who wants other terms edits them on the dataset's Terms tab before publishing.

The author may also publish from the dataset's own page in Dataverse (its Publish button): where
the installation runs the service's workflows, the publish check runs there; otherwise the service
notices the publication on its own, within about an hour, and records it. If your own safety check stops you from
running `certify publish`, say so and offer that route alongside the command.

When the version is published, tell the author what to keep: nothing. The certificate, the receipt
and the run's evidence are at the archive, and the packed file and the certificate are in Dataverse;
the working folder (`<work>`) can be deleted. Two exceptions: the held salt file of licensed data
(Step 2a), which stays with the data for as long as the data do; and the uploader secret, if the
author expects to certify a new version of this dataset soon (otherwise a new registration makes a
new one).

## Step 11. Check the certificate as a stranger would (recommended)

The archive serves the certificate's bundle to anyone, and the checker is installed with the
author's program:

```bash
curl -s -o <work>/bundle.zip <service>/bundle/<certificate fingerprint>
mkdir -p <work>/bundle && (cd <work>/bundle && unzip -q -o ../bundle.zip)
curl -fs <service>/rootkey > <work>/archive-root.pub.pem && rulebook verify <work>/bundle --root-key <work>/archive-root.pub.pem
```

The root key signs the archive's key log, from which the checker takes the signing keys. If
`/rootkey` answers 404 (an archive created before October 2026), use the signing key instead:
`curl -s <service>/pubkey > <work>/archive.pub.pem` and `--archive-key <work>/archive.pub.pem`.

The bundle carries the packed files, so nothing else is needed. For a restricted deposit it
does not: the public bundle holds the signed documents, the published estimates with their salt
and a note of where to ask, and the checker reports every part that needs the files as
unevaluated. The author, who holds the files, can run the full check: they download the draft's
two restricted files, `replication-package.pack` and `replication-certificate-evidence.pack`,
from the draft's page (the packed file is also `<work>/certified/package.pack`), then `rulebook unpack <work>/evidence.pack <work>/bundle` and
`rulebook verify <work>/bundle --root-key <work>/archive-root.pub.pem --package <work>/replication-package.pack`.
The checker prints what passed,
what failed and what it could not evaluate, and exits with status 1 only when a finding failed.
On a certificate hours old expect several parts unevaluated and none failed: the public
timestamps' confirmations and what depends on them, the parts only the archive can judge, the
capture files' frozen bytes and the schema's fingerprint, which the protocol's authors have not
printed yet. Unevaluated is not failed. Report the three counts. Anything failed: report it and
do not publish. The key was taken from the service's own address, which is sound only where the
certificate fields sit in the installation's protected block; for a stronger check, obtain the
root key from the archive's published key log or its deposit under a DOI, and point `--root-key` at it.

## Things learned the hard way

- Always pass the run order with `--target`, in the order the author approved.
- The runs cannot see the author's installed packages: a script that passed the smoke test
  still fails at closing until `certify vendor` has copied its libraries into the prepared copy.
- A script that works in the author's RStudio or notebook session can fail on its own: it used
  an object an earlier script defined, or a package someone attached by hand (`MASS::polr`).
- The packed replication file is not a zip, so Dataverse stores it whole; the service checks
  the stored fingerprint. Do not upload the packed replication dataset to Dataverse yourself.
- Scripts from before about 2015 often fail on today's packages (a removed argument, a
  function no longer attached). Smoke-test before closing.
- Closing the same files twice gives the same packed bytes; the archive replays the receipt
  and refuses a second certificate. New content is a new certification.
- The program needs Python 3.12 or newer for its own environment; an older `python3` makes pip
  refuse the install with "no matching distribution". The author's analysis may use any Python.
- The token is asked for once, in the chat, and piped into `certify register`. A hidden prompt
  in your shell reads nothing (your shell has no keyboard), and a token on a command line or in
  a file outlives its use. The service forgets the token, and the author recreates it.
- Dataverse's publish call returns "WORKFLOW_IN_PROGRESS"; poll, do not treat it as an error.
  A refusal reaches the author as a generic workflow-failure notification; the reason is on the
  service's status route and its Certify page.
- An agent's own safety check may block the upload to the service when the address is a bare
  server number; the author runs that one command, and the path continues.
- The seal takes hours because the archive waits for the receipt's public timestamp to
  confirm; this is the protocol, not a fault.
- The runs use the C locale with UTF-8 text (`LC_ALL=C.UTF-8`): sorting and number formatting
  are fixed, and text files in UTF-8 read as the author expects. A script that reads text in
  another encoding must say so where it reads (`fileEncoding=` in R, `encoding=` in Python).
- A refusal that arrives as `The archive refused: status 502 ... with no explanation` is the
  service overloaded or restarting, not a judgement on the files: wait a minute and run the same
  command again.
- The ten progress blocks are not the step numbers of these instructions (Step 0 to Step 11);
  name the step in words on the progress line.
- The runs have no home folder of the author's and no network: a script that reads a setting
  from `~/.config` or `~/.Rprofile`, or downloads at run time, behaves as it will on a stranger's
  machine. Put the setting in the script, and declare the file (Step 2) instead of downloading.
- A script that calls an outside service is recorded once (`certify record`) and answered from
  the recording ever after; a new prompt or question needs a new recording, and the script must
  not fail when its key is absent.
- An item computation's script is checked on 100 sampled items at closing and again after the
  certified run; keep it out of the run order.
- Confidential data: `certify restrict` comes before any `certify declare`, since declared
  fingerprints are salted under the salt file; a held file's path in the code is
  `.certified/deps/<path>`; the archive refuses a restricted submission without the author's
  disclosure decision, and a facility-held one without the custodian statement.

## Deliverables checklist

- [ ] Original folder untouched (compare a fingerprint before and after).
- [ ] Prepared copy with `CERTIFICATION-NOTES.txt` listing every approved repair, or a statement that none was needed.
- [ ] If the package was tidied with the guide (Step 1b): the author's yes recorded; no clock in the logs; nothing installs or reaches the network at run time; the master script the single target.
- [ ] Add-on libraries vendored into the prepared copy (`certify vendor`), or none loaded.
- [ ] If the code calls an outside service: the recording made (`certify record`) with the key piped in from the chat; the key given again for the certified run's re-sending; never in a file or a command line.
- [ ] If results were saved before deposit: the item computation declared (`certify declare --items`) and its script left out of the run order.
- [ ] `<work>/uploader-secret` written by `certify register`; the API token asked for once in the chat and piped in, never in a file or a command line; the author told to recreate it (now, or after publishing).
- [ ] `<work>/certified` with the closure report, the packed copy, the receipt, the run and the certificate.
- [ ] Certificate fields present on the draft (`metadata_written: true`).
- [ ] The state `sealed` reached before publishing.
- [ ] Verification report: findings passed, failed, unevaluated.
- [ ] The author's explicit "publish" recorded before publishing, or the form's box checked.
- [ ] For confidential data: the kind asked and recorded; the disclosure decision the author gave; the licensed data's salt file uploaded as a restricted file; the facility's statement passed at submit.
- [ ] The progress line shown at the start and end of every step, and every missing answer asked for one at a time.
- [ ] A plain-language report to the author covering all of the above.
