Upgrading to PsyNet 14
**********************

This checklist migrates an existing experiment onto PsyNet 14: in-
place timeline transitions, recruiter and leave APIs, changed
defaults, setup and deployment files, participant failure, groups,
assets, async jobs and exports. Work through the steps in order; each
lists what to search for. Frontend patterns and full examples are in
Custom front ends.

The Cursor skill "/upgrade-to-psynet-14" is a thin wrapper that points
agents here. Agents read this page with "psynet docs show
whats_new/upgrading_to_psynet_14", which works without a PsyNet source
checkout.

Also see: PsyNet 14, Configuration.


0. Orient
=========

1. Run under the default "inplace_timeline_transitions = true".

2. If one page is temporarily blocked, pass
   "requires_full_page_reload=True" to that page's constructor.

3. If many pages are blocked, set "inplace_timeline_transitions =
   false" only as a short-term experiment-wide opt-out, then keep
   migrating so you can remove it.

4. Work page by page.

5. Even with no custom frontend, continue through steps 10–20
   (recruiters, Leave and error pages, changed defaults, setup,
   deployment files, participant failure, responses, groups, assets,
   exports, and validation).

To find pages that can't load in place, run "psynet debug local" /
"psynet test local" and read the traceback. Incompatible pages raise
one short message that lists **error codes** in parentheses; use the
glossary below to map each code to a checklist step.


1. Find and migrate custom page templates
=========================================

Search for "template_path=", "template_str=", and "{% extends
"timeline-page.html" %}".

A complete template extends "timeline-page.html" and overrides blocks
such as "main_body":

   {% extends "timeline-page.html" %}

   {% block main_body %}
       <p>Custom page content</p>
   {% endblock %}

This style works only with the legacy full-page reload path, where
"inplace_timeline_transitions = false" is set explicitly.

Convert complete templates to fragments ("template_fragment_path" /
"template_fragment_str") and supply assets via page arguments. See
Custom front ends (Custom page templates).


2. Migrate CSS
==============

Search author-owned templates for "<style>" and "<link
rel="stylesheet">".

* Stylesheet links → "css_links" / "get_css_links()"

* Authored reusable styles → "static/*.css" + "css_links"

* Tiny generated snippets → "css" / "get_css()"

See the same tutorial section for details.


3. Find deprecated page JavaScript APIs
=======================================

Search for "js_links=", "scripts=", and "<script>" tags in author-
owned templates or component "external_template" files. Classify each
script before moving it (load-once library vs per-page behavior vs
short inline).

Converting the HTML template alone is not enough: leftover "scripts="
/ "js_links=" still force a full-page reload and raise
"legacy_scripts" / "legacy_js_links" unless you also pass
"requires_full_page_reload=True". These deprecated arguments keep
classic linked and inline script semantics, which is why they cannot
use in-place transitions.

Framework macros may still embed classic "<script>" tags, which PsyNet
replays across in-place transitions (see Page rendering and
lifecycle). Author-owned external templates should contain only
markup. Embedded "<script type="module">" tags are not supported.

PsyNet now serves jQuery 4.0.0 and jQuery UI 1.14.1. Search your
JavaScript for jQuery utilities that jQuery 4 removed, such as
"$.trim", "$.isArray", "$.isFunction", "$.parseJSON", "$.type",
"$.isNumeric" and "$.now". Replace them with native JavaScript, for
example "text.trim()", "Array.isArray(value)" and "JSON.parse(text)".
".css()" also no longer adds "px" to bare numbers for most properties
(sizes, margins, padding, border widths and positions still get it),
so pass other values with units, for example ""16px"". Replace links
to "/static/scripts/jquery-3.7.1.min.js" with "jquery-4.0.0.min.js";
timeline pages already load jQuery, so they don't need their own link.
Upgrade bundled jQuery plugins to versions that support jQuery 4. See
the jQuery 4.0 upgrade guide.


4. Migrate load-once libraries
==============================

Move load-once classic libraries to "js_dependencies" /
"get_js_dependencies()". Do not put per-page initialization there. See
Custom front ends (Managing JavaScript lifecycles).

Timeline pages load SurveyJS only when they contain a
"SurveyJSControl". Pages that use "SurveyJSControl",
"MultiRatingControl" or "RatingControl" need no change. If a custom
page builds a survey with "new Survey.Model(...)" instead, add
"/static/scripts/survey-jquery/survey.jquery.min.js" to its
"js_dependencies".


5. Migrate per-page behavior
============================

Rewrite classic top-level scripts as ES modules that export
"activate", wired with "js_page_modules" / "get_js_page_modules()".
Short snippets may use "js_page_code" / "get_js_page_code()" instead.

See Custom front ends for "activate(context)" examples and cleanup
guidance.


6. Migrate page variables to "psynet.var"
=========================================

Replace legacy "window" reads of "js_vars" keys with "psynet.var".
Optionally set "legacy_js_var_globals = error" while testing.

Earlier versions copied each "js_vars" key onto "window". This global
access is deprecated because in-place timeline transitions reuse the
same browser window across pages. "legacy_js_var_globals" controls the
compatibility behavior:

* "warn" (default) keeps legacy access working and warns once for each
  key.

* "error" throws a "ReferenceError" that identifies the key and
  recommends the corresponding "psynet.var" expression.

* "off" does not install legacy global properties.

In "error" mode the compatibility property remains present so that
reads and writes can produce the informative error. Consequently,
"typeof legacy_name" also throws and ""legacy_name" in window" remains
true. Test availability with ""name" in psynet.var" instead. In "warn"
mode, assigning the legacy global changes only the mirrored value; it
does not update "psynet.var".

The compatibility accessors are installed only for keys on the active
page, and PsyNet removes them on the next page. If another script
replaces and locks a compatibility accessor, PsyNet leaves that
property alone and continues the page transition.

PsyNet does **not** install a legacy "window.<key>" accessor when that
name already exists on "window". In the default "warn" mode a
colliding key (for example "name", "status", "event", "history")
silently keeps the browser's value; the page data is still available
on "psynet.var". Page construction warns for these common collisions
so they show up in "psynet test local" / "psynet debug local". See
Custom front ends and Configuration.


7. Migrate JsPsych timelines
============================

"JsPsychPage" takes a JavaScript module URL exporting
"buildTimeline(context)", not an HTML/Jinja template. See
"demos/experiments/jspsych".


8. Fix timing that assumed document load
========================================

* Page setup → "activate()" / "js_page_code" (not "DOMContentLoaded")

* Timing gates → "pageReady" / "trialConstruct"

Details: Custom front ends.


9. Migrate trial-selection hooks
================================

Search custom trial makers for "find_networks", "find_node",
"prioritize_networks", "custom_network_filter",
"balance_across_nodes", "balance_across_chains", "choose_block_order",
"should_finish_block", "set_block_state" and "module_state.block".

* "ChainTrialMaker" subclasses now discover, filter, and select chains
  with "find_chains", "custom_chain_filter", and "select_chain".
  PsyNet resolves the selected chain to "chain.head".

* "StaticTrialMaker" subclasses use the node-specific "find_nodes",
  "custom_node_filter", and "select_node" hooks instead.

* "custom_network_filter" is still honoured, but construction emits a
  "DeprecationWarning". Replace it with "custom_chain_filter" on chain
  trial makers or "custom_node_filter" on static trial makers.

* Selection hooks may return their selected value directly or wrap it
  in "Selection" to pass request-local context to "on_trial_created".
  Returning "None" from "select_chain" or "select_node" raises
  "TypeError". Return the selected object from the supplied "chains"
  or "nodes" list; a newly queried copy with the same id raises
  "ValueError". "find_chains" and "find_nodes" must return a list,
  ""wait"", or ""exit""; "None" raises "TypeError".

* "select_chain" and "select_node" replace ranking in
  "prioritize_networks". They receive a nonempty eligible list and
  cannot return "None", "[]", ""wait"", or ""exit"". Logic that
  emptied the candidate set or chose to wait belongs in "find_chains"
  or "find_nodes": call "super()", then filter or return ""wait"" /
  ""exit"".

* "get_trial_class" must return a concrete trial class. Remove
  unavailable chains or nodes in the corresponding custom filter
  instead of returning "None". Synchronized follower trials reuse the
  leader's concrete trial class without calling "get_trial_class"
  again.

* "CreateAndRateTrialMakerMixin.get_non_failed_creations" has been
  removed. Classify nodes with "get_creation_phases()" and load
  finalized creations with "get_finished_creations()".

* Create-and-rate experiments with fixed creator and rater groups
  should override "get_participant_role()". The mixin then uses that
  role for both chain eligibility and the final phase check. Do not
  override "get_trial_class" from participant role alone. Creators
  only receive heads that still need creators. Raters receive heads
  that are ready for raters, and they wait or finish the block on
  heads whose creator slots are filled but not yet finalized. Heads
  that still need creators are not rater-eligible. A selected head
  that later becomes incompatible waits or exits instead of assigning
  the opposite role's trial class.

* "position" is now stored when the trial is created and counts across
  all concrete trial classes in a participant's trial maker.
  Previously it was calculated within each concrete trial class.
  Trials constructed outside a trial-maker state may have
  "position=None"; code that performs arithmetic with "position"
  should handle that case explicitly.

* Blocks are now strict: a participant only receives nodes or chains
  from their current block, and stays in it until
  "max_trials_per_block" or "should_finish_block" ends it, or until it
  has nothing more to give them. Previously a participant whose block
  was busy could receive a trial from a later block. When every
  candidate in the block is busy, "wait_for_networks=True" waits;
  "False" finishes the block early. An empty list from "find_chains"
  or "find_nodes" now finishes the block; ""exit"" still leaves the
  trial maker.

* "balance_across_nodes" and "balance_across_chains" have been
  removed. Replace "True" with "node_order="balanced"" /
  "chain_order="balanced"" and "False" with ""random"". "node_order"
  already defaults to ""balanced"" and "chain_order" to ""random"", as
  before. See Trial order for planned orders such as ""listed"" and
  functions, which replace hacks like a "select_node" that walks a
  fixed list.

* Replace a "choose_block_order" override with the "block_order"
  argument: a list, ""listed"", or a function of "participant",
  "experiment" and "blocks". Passing "block_order" while also
  overriding "choose_block_order" raises "TypeError".

* "should_finish_block" now takes "(participant, block)". Read trial
  counts from "participant.module_state.n_participant_trials_in_block"
  and "participant.module_state.n_participant_trials_in_trial_maker".

* "module_state.block" is now derived from "block_order" and
  "block_position" and cannot be set; "set_block_state" has been
  removed. "ChainTrialMakerState.remaining_blocks" and
  "go_to_next_block" have also been removed: read
  "block_order[block_position:]" for the remaining blocks, and end a
  block with "should_finish_block" instead of advancing it yourself.

* "ChainTrialMaker.check_participant_groups" now receives the
  participant group names of the start nodes instead of a list of
  networks.

* To keep a participant on one chain until it is finished, pass
  "interleave_chains=False" instead of giving each chain its own
  block. "GeometricStaircaseTrialMaker" now does this by default.

* "target_trials_per_node" (and the dense trial maker's
  "target_trials_per_condition") only drives
  "recruit_mode="n_trials"". Static nodes no longer stop being
  selected once they reach it, so a node can end up with a few more
  trials than its target. "node_order="balanced"" still spreads trials
  evenly and, unless node selection runs in Python or "node_priority"
  is defined, gives participants who ask at the same moment different
  nodes where possible. To stop offering nodes once they have enough
  trials, filter them by trial count in "filter_nodes_query";
  simultaneous requests can still go slightly over. Chain
  "trials_per_node" is still a hard limit.

* Pass "recruit_mode" explicitly whenever you set a recruitment
  target. "target_n_participants" needs
  "recruit_mode="n_participants"", and "target_trials_per_node" /
  "target_trials_per_condition" need "recruit_mode="n_trials"". A
  target with "None" or the other built-in mode raises "ValueError",
  as does a misspelt mode. Chain-based trial makers, including
  staircase and graph trial makers, used to default to
  ""n_participants"" and now default to "None" like static trial
  makers. "n_participants_completion="trial_maker"" likewise needs
  "recruit_mode="n_participants"":

     StaticTrialMaker(
         ...,
         recruit_mode="n_participants",
         target_n_participants=30,
     )

PsyNet raises an actionable "TypeError" when a removed or wrong-
paradigm hook is still overridden.


10. Recruiter configuration
===========================

Search "config.txt" (and experiment "config" dicts) for "recruiter =
mturk", "recruiter = bots", "recruiter = multi", and Dallinger
"recruiters =". PsyNet rejects those nicknames, including subclasses.
Deploy with "prolific", "generic", "hotair", "lucid-recruiter", or a
lab recruiter instead. PsyNet's own bot-based test commands still
work; they are not a "recruiter = bots" deployment.

Amazon closed MTurk on September 30, 2026, so a study configured for
MTurk needs another platform. See PsyNet 14.

For Prolific, search for "prolific_enable_screen_out" and
"prolific_screen_out_slots":

* Prolific now pays participants who fail or hit an error a fixed
  amount ("prolific_unsuccessful_base_payment", default 0.25) plus a
  bonus up to their accumulated reward. This is on by default
  ("prolific_pay_unsuccessful = true").

* While it is on, set "prolific_screen_out_slots", which caps how many
  participants can be paid this way; deployment fails without it. See
  Prolific.

* Set "prolific_pay_unsuccessful = false" to keep the old return-for-
  bonus behaviour, for example if the Prolific workspace rejects the
  screen-out completion code.

* Remove "prolific_enable_screen_out"; it is no longer a valid key.


11. Leave, ads, and error recovery
==================================

Search for "show_abort_button", "show_termination_button",
"ad_requirements", "ad_payment_information", "error_page_content",
"error_page_content__prolific", "approve_assignment",
"reject_assignment", and "ExecuteFrontEndJS(".

* Config and page flags: "show_early_exit_button" and
  "min_reward_for_paid_early_exit". The old page arguments still work
  with a "FutureWarning".

* DOM and routes: "#early-exit-button", "/execute_early_exit_plan/".

* Participant field: "Participant.early_exited".

* Remove "Experiment.ad_requirements" and
  "Experiment.ad_payment_information". Customize "templates/ad.html"
  instead; see The ad page.

* Replace "error_page_content" with recruiter
  "error_page_presentation". A custom recruiter that shows recovery UI
  must also override "shows_error_recovery_page"; a button in the
  presentation is not enough. Handoff controls are armed only while
  the recovery plan is still prepared:

     from psynet.exit import ExitContext

     def shows_error_recovery_page(self, plan):
         return plan.context is ExitContext.ERROR_RECOVERY

  See Configuration.

* Rename "approve_assignment" to "submit_assignment" and Prolific
  "reject_assignment" to "request_return_for_bonus".

* "ExecuteFrontEndJS" no longer takes "message". It shows a spinner:

     ExecuteFrontEndJS("psynet.finishAndGoToExit()")

Stale overrides fail a pre-deployment check or fail when used, with
migration instructions in the error.


12. Changed defaults and option markup
======================================

Two changes affect code in almost any experiment, so check them first.
Search for "var.get(" and "conditional(".

* "participant.var.get(name)" (and "var.get" on "experiment.var",
  nodes, networks and trials) returns "None" for a missing variable,
  like "dict.get", instead of raising "KeyError". Where the error was
  wanted, for example inside "try" / "except KeyError", read
  "participant.var.name" instead, or check
  "participant.var.has(name)":

     # Before: relied on the KeyError
     try:
         score = participant.var.get("score")
     except KeyError:
         score = 0
     # After
     score = participant.var.score if participant.var.has("score") else 0

* "conditional()" now converts its condition's result with "bool()",
  so a condition may return any value. Before, a value other than
  "True", "False", "1" or "0", such as "None", "2" or a list, raised
  an error; now "None" and an empty list choose "logic_if_false", and
  other values "logic_if_true". A condition that relied on the error
  to catch a bug should return a "bool" explicitly.

     # Before, this raised an error, because the condition returns a list;
     # now a non-empty list chooses the first branch
     conditional("has_answers", lambda participant: participant.var.answers, ...)

* Phones and tablets are allowed by default. Set "allow_mobile_devices
  = false" to keep a study desktop-only.

* "force_google_chrome" now defaults to "false" and is deprecated, so
  Chrome, Edge, Firefox and Safari are admitted. Every experiment
  rejects browsers without CSS ":has()" support (Chrome < 105, Firefox
  < 121, Safari < 15.4), and "min_browser_version" has been removed:
  delete it from "config.txt" and "~/.dallingerconfig", because PsyNet
  refuses to start with unknown config keys. Declare required features
  such as "{"microphone"}" in "Experiment.browser_capabilities"
  instead; see Configuration.

* Leaving "show_reward" unset means the recruiter decides: Prolific
  and lab show it, generic/local do not, Lucid hides it. Set
  "show_reward = true" to show it anyway where the recruiter allows.

* Radio and checkbox options are full-width "label.psynet-option"
  rows. Restyle ".psynet-option" / ".psynet-option-label" instead of
  bare "label" / "input" elements; see Theming.

* The Next and Reset buttons sit in ".psynet-actions". Rules that
  selected them as direct children of "#trial-stage" should target
  ".psynet-actions" instead.

* "psynet translate" uses ChatGPT only. Remove "default_translator =
  google_translate", which raises an error;
  "google_translate_json_path" and "google_translate_project_id" are
  ignored. See Internationalization.

* The default translation model is "gpt-6-luna" instead of "gpt-4o",
  and "openai_default_temperature" is no longer set. "gpt-6-luna"
  ignores "openai_default_temperature"; set it only together with a
  model that accepts it, for example "openai_default_model = gpt-4o".

* Participant pages escape HTML in plain strings. Search for
  "labels=", "choices=", "Button(", "WaitPage(", "KeyboardPage(" and
  "template_arg=" with HTML tags in the text, and wrap HTML that you
  wrote in "markupsafe.Markup", for example "labels=[Markup("Yes
  <kbd>Y</kbd>")]". Never wrap participant-provided text in "Markup";
  to mix it into HTML, write "Markup("<b>{}</b>").format(answer)",
  which escapes "answer". In custom templates, write values inside
  "<script>" with "{{ value | tojson }}". See Writing pages.

* "AudioPrompt" "controls" labels are escaped too, so wrap HTML labels
  in "Markup".

* Custom dashboard tabs that render "dashboard_custom.html" or the
  card macros in "macros/dashboard.html", and pages that render
  "custom_html.html", escape plain strings. Pass "html", card bodies
  and list items as "Markup"; for a "dominate" tag,
  "Markup(tag.render())".

* PsyNet now requires dominate 3.1, which renders "a", "span" and
  "sup" inline: it no longer starts a new line before them, so the
  space that used to appear before each of these tags is gone. This
  affects a tag that follows text as well as tags placed side by side.
  Search for dominate "span", "a" and "sup" tags, and add the space
  where you want one:

     tags.p("Click", tags.a("here", href=url))  # now shows "Clickhere"
     tags.p("Click ", tags.a("here", href=url))  # shows "Click here"
     tags.div(tags.span("A"), tags.span("B"))  # now shows "AB"
     tags.div(tags.span("A"), " ", tags.span("B"))  # shows "A B"

  Attributes set to "0", such as "value=0", are now rendered instead
  of dropped.

* "KeyboardPage" now requires "prompt".

* A "REPPVolumeCalibration" subclass whose "what_are_we_playing"
  returns HTML must return "Markup".

* Custom templates that call "AudioMeterControl.to_json" must write
  "{{ params.to_json() | tojson }}".


13. Set up the experiment environment
=====================================

"uv pip install psynet" now installs only a small command-line tool.
In the experiment directory, create and activate a virtual
environment, install PsyNet into it, and run "psynet setup":

   uv venv --python 3.14
   source .venv/bin/activate
   uv pip install "psynet==14.0.0rc4"
   psynet setup

"psynet setup" installs the full PsyNet runtime from
"constraints.txt", adds the boilerplate files, and starts a Git
repository if the experiment lacks its own. PsyNet needs Python 3.11
or later and recommends 3.14.

* "psynet setup --docker" is removed; run "psynet setup", then "psynet
  debug local --docker".

* "psynet services ensure" starts PostgreSQL and Redis in Docker. It
  runs PostgreSQL 18, which can't open the data of the PostgreSQL 12
  "dallinger_postgres" container that earlier versions started. It,
  and "psynet debug local" and "psynet test local", offer to replace
  that container ("psynet services ensure --yes" replaces it without
  asking), and your local database then starts empty. The old data
  stays in the "dallinger_postgres" volume.

* The PsyNet runtime no longer installs "pytest-mock", "pytest-
  timeout", "pytest-dependency", "progress" or "python-gettext". If
  the experiment's tests use "mocker", "@pytest.mark.timeout" or
  "@pytest.mark.dependency", or its code imports "progress" or
  "pythongettext", add that package to "requirements.txt".

* The "psynet[slack]" extra is removed, because the runtime already
  includes "slack-sdk". Drop "slack" from "requirements.txt" and from
  install commands.

* "Notifier.python_dependencies" and
  "Experiment.check_python_dependencies()" are removed. If a custom
  notifier listed packages in "python_dependencies", add them to
  "requirements.txt" instead; deploys no longer check for them.

See Install and Starting from a demo or an existing experiment.


14. Deployment files
====================

Look for ".dockerignore" and a "docker/" folder of helper scripts in
the experiment directory.

"deploy.toml" now decides which files are deployed; ".gitignore" and
".dockerignore" no longer do, so Git-ignored files under "static/" are
deployed. PsyNet creates "deploy.toml" when it is missing. If your
".gitignore" ignores files that "deploy.toml" does not exclude, the
next debug, test or deploy command stops once and lists them.

* Move any custom ".dockerignore" entries into "deploy.toml"'s
  "[exclude]" table, then delete ".dockerignore". PsyNet removes
  generated copies itself.

* Review the list with "dallinger deployment-files list".

* Commit your changes before a remote deployment; PsyNet records the
  commit instead of packaging the source code.

See Migrating deployment file selection.

A docker-ssh server set up by Dallinger 13.0 or earlier keeps
PostgreSQL 12 until "dallinger docker-ssh servers upgrade" moves it to
PostgreSQL 18. That upgrade stops every classic app on the server
while it copies the databases, and afterwards no one may deploy to the
server with PsyNet 13 or earlier or with PsyNet 14.0.0rc1 to rc3. A
Cloudflare-ingress app deployed with Dallinger 13.0 or earlier keeps
PostgreSQL 12 when you update it with "--update". Read Moving to
PostgreSQL 18 before you upgrade a server.


15. Failing participants and trial maker arguments
==================================================

Search for "def fail_participant", "data_check_failed",
"attention_check_failed" and positional arguments to "TrialMaker(" or
"NetworkTrialMaker(".

* Overriding "Experiment.fail_participant" raises an error. Call
  "participant.fail()", or register a "ParticipantFailRoutine" for
  code that must run when a participant fails.

* Dallinger's "data_check_failed" and "attention_check_failed" only
  log a warning; they no longer fail the participant.

* "TrialMaker" and "NetworkTrialMaker" take keyword arguments only,
  like the other trial makers.

* The "fail_trials_on_premature_exit" argument is ignored: when a
  participant leaves or fails, their unfinished trials always fail and
  their submitted trials are kept.

See Handling failed participants and trials.


16. Response processing and rendering
=====================================

Search for "def process_response", "response_approved",
"render_partial_timeline_payload", "session.commit(",
"session.rollback(", "accumulate_answers", and code in "render()" or
templates that changes the database.

* With "accumulate_answers=True", "participant.answer" is now a dict
  from the start of the page maker or trial, and each page adds its
  answer when it is submitted. Code that reads "participant.answer"
  during such a trial now gets the current trial's answers so far, not
  the previous trial's answer. Answers from nested accumulating page
  makers now go into the same dict instead of being lost.

* Experiment code that runs while a participant moves through the
  timeline must not call "db.session.commit()" or
  "db.session.rollback()"; PsyNet now raises "RuntimeError" if it
  does. This covers code blocks, page makers, page methods
  ("format_answer", "validate", "on_complete", "pre_render"), trial
  methods and trial maker hooks. Delete these calls: PsyNet commits
  for you. Use "db.session.flush()" where you need a new object's
  "id". Custom POST routes still commit themselves. See Saving
  changes.

* "participant.answer", "save_answer" variables and "on_complete" are
  now updated only after "validate" accepts the response. A custom
  "format_answer", "validate" or "process_response" that reads
  "participant.answer" now sees the previous answer; use the "answer"
  argument instead.

* Pages now render in a read-only transaction. Move database writes
  from "render()" or templates to "pre_render()".

* An override of "Experiment.process_response" must return a
  "ResponseResult" ("from psynet.experiment import ResponseResult")
  and accept "**kwargs".

* "Experiment.response_approved" is removed; customize approved
  responses through "process_response" or the page-rendering hooks.

* Push buttons, dropdowns, radio buttons and checkboxes now save the
  picked element of "choices" with its original type, not the
  browser's text. Search for these controls with numeric "choices",
  for example "PushButtonControl([1, 2, 3])", and compare their
  answers to numbers: "answer == 3", not "answer == "3"".
  "int(answer)" keeps working. Fixed bot answers, from "bot_response"
  or a "get_bot_response" method that returns a plain value, are not
  converted, and an answer that is not one of the choices is rejected
  (see the next item), so give them as numbers too: "bot_response=3",
  not "bot_response="3"".

* These controls now reject an answer that is not one of their
  "choices". Search for "def format_answer" on these controls and on
  pages that use them; if it saves something other than a choice, such
  as a dictionary with a reaction time, set "restrict_to_choices =
  False" on the control class or pass "restrict_to_choices=False" to
  the control. Also search for "random." in "PageMaker" functions and
  "show_trial": the page is built again when the response arrives, so
  random choices must be picked once (for example in
  "finalize_definition" or "participant.var"). See "OptionControl".

* "NumberControl" now saves a number ("78.5" or "100"), not the
  browser's text. Search for "NumberControl" and compare its answers
  to numbers: "answer == 100", not "answer == "100"". "float(answer)"
  keeps working. Default bots save numbers too. A fixed bot answer,
  from "bot_response" or a "get_bot_response" method that returns a
  plain value, is saved as given, so give it as a number:
  "bot_response=25", not "bot_response="25"", which now fails
  validation. The typed text is lost ("02139" is saved as "2139"), so
  use "TextControl" for codes such as postcodes or IDs where the exact
  text matters. Text with "_", such as "1_000", fails validation. A
  "NumberControl" page that overrides "format_answer" must now return
  a number: call "super().format_answer(raw_answer, **kwargs)" or
  convert the text yourself, since returned text fails validation.

* Default bot answers now go through the page's or control's
  "format_answer", as participants' answers do. Search for "def
  format_answer" on pages that bots answer without "bot_response" and
  on subclasses of the controls listed in the next item, and check
  that it accepts what the browser sends. For example, a "TextControl"
  page whose "format_answer" returns "int(raw_answer)" used to be
  skipped for bots, but now fails on the default answer ""Hello, I am
  a bot!"": pass "bot_response=" with a suitable answer, or let
  "format_answer" accept the default. Whole-number floats in any
  "BotResponse(raw_answer=...)", including your own, are now submitted
  as ints, as the browser's JSON does: a rating scale given as
  "{"low": 0.0, "high": 1.0}" saves "1", not "1.0".

* The built-in "get_bot_response" methods of "NumberControl",
  "TextControl", "MonitorControl", "SliderControl",
  "FrameSliderControl", "MultiRatingControl" (and so "RatingControl")
  and "GraphicControl" now return a "BotResponse" holding the
  browser's raw answer, rather than a plain value. Search for
  "get_bot_response" in subclasses of these controls: code that calls
  "super().get_bot_response(...)" should read ".raw_answer" from the
  result. This is the browser's text for "NumberControl" (""57"") and
  SurveyJS JSON text for "MultiRatingControl" and "RatingControl"
  ("json.loads(raw_answer)" gives "{"rating": 3}"). Return
  "BotResponse(raw_answer=...)" in the same form, so that the answer
  still goes through "format_answer"; a plain return value is saved as
  given. For example:

     class OneMoreNumberControl(NumberControl):
         def get_bot_response(self, experiment, bot, page, prompt):
             response = super().get_bot_response(experiment, bot, page, prompt)
             return BotResponse(raw_answer=str(int(response.raw_answer) + 1))

* "LanguageVocabularyTrial" answers are now screen positions (""1"" to
  ""4"") rather than ""correct"". A custom subclass that compares an
  answer with ""correct"" should compare it with
  "definition["correct_answer"]" instead. A subclass that overrides
  "finalize_definition" must call "super()" or set
  "definition["correct_answer"]" (the 1-based position) itself.


17. Groups and barriers
=======================

Search for code that changes "SyncGroup.participants", custom
"Barrier" subclasses, "get_waiting_participants(", "SimpleGrouper(",
"waiting_logic=", ".sync_group" on trials and
"ParticipantFailRoutine".

* Change group membership with "SyncGroup.add_participant()" and
  "SyncGroup.remove_participant(participant, reason=...)", which needs
  a reason such as ""removed_by_experimenter"".
  "SyncGroup.participants" is read-only and lists only active members.

* Custom barriers implement "check_waiting_participants()" and
  "choose_who_to_release()" instead of overriding "check()". Barrier
  state is saved as data, so custom release state must be JSON-
  compatible values, importable classes or functions, or database
  objects.

* "Barrier.get_waiting_participants()" takes the participant as its
  first argument; pass "for_update" as a keyword.
  "get_waiting_participants_from_barrier_id" is removed.

* "SimpleGrouper" IDs now include the group size. Pass the same "id_"
  to two groupers that should share a waiting pool.

* "SimpleGrouper(min_group_size=...)" is now "quorum=...": how many
  active members a group needs to keep going. The old name still works
  with a "FutureWarning". A grouper for groups of three or more
  without "quorum" warns: pass "quorum=initial_group_size" to keep
  failing a group as soon as one member leaves, or a smaller number if
  your code handles smaller groups. A "quorum" below
  "initial_group_size" also needs "below_quorum="fail"" (the old
  behavior) or "below_quorum="continue_without_group"". Participants
  failed because their group fell below its quorum now get the failure
  tag "sync group below quorum" instead of "sync group below minimum
  size"; update analysis code that filters on it.

* "SimpleGrouper(join_existing_groups=True)" now warns unless you say
  when newcomers start taking part: pass "use_admission_points=False"
  to keep the old behavior, or "use_admission_points=True" to admit
  them only at admission points (see Admission points).

* A "quorum" (or "min_group_size") larger than "max_group_size" now
  raises a "ValueError", because such a group could never reach it.
  Lower the quorum, or raise "max_group_size":

     # Before: accepted, but a group of at most 3 can never have 4 members
     SimpleGrouper("team", initial_group_size=2, max_group_size=3,
                   min_group_size=4, join_existing_groups=True)
     # After
     SimpleGrouper("team", initial_group_size=2, max_group_size=3,
                   quorum=2, join_existing_groups=True,
                   use_admission_points=False)

* Pages shown from a barrier's "waiting_logic", such as filler trials,
  now end when the barrier releases the participant, "release_grace"
  seconds (3 by default) after the browser notices, instead of running
  to their end. The page saves an empty response with ""interrupted":
  True" in its metadata, and its trial, any trial that the rest of
  that pass of "waiting_logic" reaches, and one the trial maker
  prepared for its next pass are failed with
  "failed_reason="interrupted_by_release"". These failed trials still
  count towards "n_created_trials" (so later trials' "position" skips
  them) and "max_trials_per_block", but not towards completed-trial
  targets, so count played filler trials with "n_completed_trials" or
  "complete". The interrupted page calls "Experiment.process_response"
  with "interrupted=True", which is why an override must accept
  "**kwargs" (see step 16). Pass "release_grace=None" to keep letting
  each waiting page run to its end:

     # Before: the filler page always ran to its end
     GroupBarrier(id_="ready", group_type="team", waiting_logic=filler)
     # After, to keep that behavior
     GroupBarrier(id_="ready", group_type="team", waiting_logic=filler,
                  release_grace=None)

* "Trial.sync_group" now returns the group the trial was played in
  ("trial.sync_group_id"), also after the participant has left it,
  instead of the participant's current group of the trial maker's
  type. Code that wants the current group should look it up on the
  participant:

     # Before: the participant's current group, or None once they left
     group = trial.sync_group
     # After, for a trial maker with sync_group_type="team"
     group = participant.active_sync_groups.get("team")

* A member failed by a "GroupBarrier" for being late
  ("late_action="fail"") or for waiting too long
  ("max_wait_action="fail"", the default), including at a synchronized
  trial maker's barriers, now leaves all their groups before being
  failed, and a member failed because their group dissolved
  ("below_quorum="fail"") first leaves that group. So a
  "ParticipantFailRoutine" no longer finds those groups in
  "participant.active_sync_groups". Other failures, such as returning
  the study, still run the routines while the participant is in their
  groups. Read the group they left with
  "participant.latest_sync_group()":

     # Before
     def record_team(participant):
         participant.var.team_id = participant.active_sync_groups["team"].id
     # After
     def record_team(participant):
         team = participant.latest_sync_group("team")
         participant.var.team_id = None if team is None else team.id

     ParticipantFailRoutine("record_team", record_team)

* A trial maker's "sync_group_max_wait_time" without "sync_group_type"
  has no effect and now warns; remove it or set "sync_group_type".

* In bot tests, "advance_past_wait_pages(bots, max_iterations=...)" is
  deprecated; pass "timeout=" (seconds) instead.

If you used a PsyNet 14.0 release candidate, also make these changes.
The old options of barriers, groupers and trial makers raise an error
naming the replacement:

* "GroupBarrier(notify_arrivals=False)" becomes
  "GroupBarrier(on_arrival_message=None)". Drop
  "notify_arrivals=True".

* "GroupBarrier"'s "timeout_between_barriers_time" and
  "timeout_between_barriers_action" were renamed "late_after" and
  "late_action"; on trial makers,
  "sync_group_timeout_between_barriers_time" and
  "sync_group_timeout_between_barriers_action" were renamed
  "sync_group_late_after" and "sync_group_late_action". "late_action"
  no longer defaults to ""fail"", so pass it whenever you pass
  "late_after", and write ""leave_group"" for ""kick"". Remove
  "max_wait_time" (or "sync_group_max_wait_time") where you pass
  "late_after": it now defaults to no limit there, and a limit raises
  an error.

* "content=" on "wait_while", "AsyncCodeBlock", barriers and groupers
  becomes "waiting_message=", and trial makers'
  "sync_group_wait_content" becomes "sync_group_waiting_message".

* "fail_participants_below_min_size=False" becomes
  "below_quorum="continue_without_group"", and
  "fail_participants_below_min_size=True" becomes
  "below_quorum="fail"".
  "SimpleSyncGroup.dissolve_if_below_min_size()" was renamed
  "dissolve_if_below_quorum()".

* Synchronized trial makers no longer have an "{id}__init_participant"
  barrier; look for "{id}__prepare_trial" instead.

See Groups and barriers in detail.


18. Assets and stimuli
======================

Search for "ExperimentAsset", "CachedAsset", "CachedFunctionAsset",
"personal=", "cache=", "compile_nodes_from_directory", "on-demand-
asset" and ".deposited".

* Rename "ExperimentAsset" and "CachedAsset" to "FileAsset", and
  "CachedFunctionAsset" to "GeneratedAsset". The old names still work
  but warn, and "asset(..., cache=...)" no longer has an effect.

* Remove "personal="; it now raises an error. Treat exported media as
  potentially identifying.

* "compile_nodes_from_directory" reads media from "static/": move the
  files there from "data/", replace "asset_label" with "url_key", and
  pass "self.definition["url"]" to prompts.

* Ready-made stimuli can live in "static/" and be referenced with
  "psynet.media.static_url_for"; see Using stimuli and media.

* "/on-demand-asset?id=…" URLs no longer work. Use the asset's "url"
  attribute instead, which has the form "/asset/<access_token>".

* With the default local asset storage and in-place navigation, audio
  and video recordings now upload after the page is submitted. A later
  page that plays back or processes a recording must wait for it and
  handle a missing one. Replace a "wait_while" on ".deposited"
  followed by playback with:

     from psynet.page import InfoPage, wait_for_recording

     wait_for_recording(lambda participant: participant.assets["recording"]),
     PageMaker(
         lambda participant: playback(participant)
         if participant.assets["recording"].deposited
         else InfoPage("Recording unavailable. Please continue.", time_estimate=5),
         time_estimate=5,
     ),

  Trial analysis such as "analyze_recording" and trial feedback
  already wait.


19. Async jobs
==============

Search for "psynet.process", "AsyncProcess", "WorkerAsyncProcess",
"LocalAsyncProcess", "async_processes" and "process_id".

* Async processes are now called async jobs, and live in
  "psynet.async_job": "AsyncJob", "WorkerAsyncJob" and
  "LocalAsyncJob".

* Creating a job no longer runs it. Call ".enqueue()", which launches
  the job once the transaction commits:

     from psynet.async_job import WorkerAsyncJob

     WorkerAsyncJob(function=analyse, arguments={"trial": trial}).enqueue()

  PsyNet logs a warning when a job is created but never enqueued.

* The old names still work but warn. "WorkerAsyncProcess(...)" and
  "LocalAsyncProcess(...)" create and enqueue the job, and
  "AsyncJob.get_process" calls "get_async_job". A subclass of
  "WorkerAsyncProcess" or "LocalAsyncProcess" becomes a subclass of
  the new class, so call ".enqueue()" on its jobs.

* "async_processes" on participants, trials, nodes, networks,
  responses and assets is now "async_jobs".

* An override of "Experiment.handle_error" that reads "process="
  should read "async_job="; "ErrorRecord.process_id" is now
  "async_job_id".

* In exports, "database/process.csv" is now "database/async_job.csv",
  and its "type" column holds names such as
  "psynet.async_job.WorkerAsyncJob". "error.csv" has "async_job_id"
  instead of "process_id", and "participant.csv" has
  "awaited_async_code_block_job_id".

See Async jobs.


20. Exports and analysis scripts
================================

Search scripts and notes for "--assets all", "--legacy", "--
anonymize", "psynet.zip", "database.zip", "extra_var" and
"export_classes_to_skip".

* "psynet export" writes one archive to "exports/latest/" and keeps
  earlier exports under "exports/history/". Table CSVs are in a flat
  "database/" folder, with pseudonymous participant IDs; recruiter IDs
  are in "participant_identifiers.csv".

* "--assets" takes "collected" (the default: files created during the
  study) or "none". "--assets all", "--legacy" and "--anonymize" are
  removed, and stimuli declared in the timeline are not exported.

* Empty tables have no CSV; check "table_row_counts" in
  "manifest.json" before reading one.

* Yes/no columns contain "True" and "False" rather than "t" and "f",
  and the "type" column of "assets/manifest.csv" uses the new asset
  class names.

* "extra_var" is removed; read variables from the "vars" column with
  "psynet.export.unpack_json_column".

* Search experiment code for "copy_expert", "copy_from", "copy_to" and
  "COPY". In a web request or background job, PostgreSQL "COPY" must
  run inside "psynet.db.blocking_psycopg()", or psycopg2 raises
  "ProgrammingError".

* "LanguageVocabularyTest" answers are now screen positions (""1"" to
  ""4"") rather than image names. Find the asset key of the chosen
  image with
  "LanguageVocabularyTrial.image_keys[definition["order"][int(answer)
  - 1]]"; the correct image is ""image_correct"".

* An unfinished trial, abandoned or still running at export time, can
  now have an "answer": the answer so far, copied from its pages
  before "format_answer" runs. Filter on "complete" as well as
  "failed" when analysing answers.

See What an export contains.


21. Validate
============

From a complete experiment directory. At minimum you typically need:

* "experiment.py", "test.py", "constraints.txt"

* "config.txt", "requirements.txt"

* ".gitignore", "deploy.toml", and ".python-version"

If you are scaffolding from scratch, see Starting from a demo or an
existing experiment or run "psynet scripts update" to generate the
standard support files.

   psynet test local

Before the bots run, "psynet test local" checks static timeline pages
against the in-place page requirements, so migration errors appear
directly in the test failure. Pages created by a "PageMaker" are
checked when they are first rendered.

Confirm the default in-place mode works (opt-out removed if possible),
page modules activate without console errors, cleanup runs for
persistent listeners, and "config.txt" no longer uses "mturk", "bots",
or "multi".


Error codes
===========

With the default "inplace_timeline_transitions = true", PsyNet raises
an error if a custom page uses a complete template or if author-
provided template content includes patterns that are incompatible with
the in-place lifecycle. With "inplace_timeline_transitions = false",
PsyNet keeps legacy templates working but may warn about patterns that
should be migrated. The check covers only author-provided template
content, not PsyNet's own timeline shell or assets supplied through
supported page arguments. A page that fails it may still work in
legacy reload mode.

The error message for a page that can't load in place lists codes such
as "(error codes: complete_template, style_tag)". Use them to jump to
the relevant step:

* "complete_template" → step 1

* "style_tag", "stylesheet_link" → step 2

* "embedded_script" → steps 3–5

* "legacy_js_links", "legacy_scripts" → steps 3–5 (also force a
  reload; pass "requires_full_page_reload=True" to silence while
  migrating)

* "embedded_module" → step 5 (use "js_page_modules", not "<script
  type="module">" in HTML)

* "dom_content_loaded", "window_listener_no_cleanup" → steps 5 and 8.
  For "window_listener_no_cleanup", PsyNet only recognizes cleanup as
  "return () => { ... }", "return function cleanup() { ... }",
  "psynet.addPageCleanupCallback(...)", or
  "psynet.addPageEventListener(...)". Returning another function
  reference (for example "return teardown") is not detected.

* "jspsych_html_timeline" → step 7
