Skip to content
/ Lonca
Documentation contents

Orchestration

E2E runner and sign-in

Lonca's own E2E runner: the app on the task's port, signed in through the repository's sign-in script, a workspace's named sign-ins, and the services an app reaches.

The E2E environment is Lonca's. In a handed-off task, Lonca starts the app on the task's own port, waits for it to answer, signs in through the repository's sign-in script (or a sign-in its workspace shares), and runs the E2E scenarios itself, with the Playwright and Chromium it ships. The scenarios are written by the test scenario writer from the acceptance criteria; Lonca's results, not a model's word, decide whether they passed. The E2E runner agent starts only when a result needs judgement. The same runner drives a web app, an API, or an Electron app.

How the E2E stage goes

  1. The scenarios are written. The test scenario writer writes each scenario as a small module, from the task's acceptance criteria. Lonca keeps them in the task's context directory, not in the repository. A later round returns only new or changed scenarios, by id.
  2. This round's fix set first. Lonca runs its e2e-fix job: the scenarios written or changed this round and those that failed last time. The set runs to its end, so one round sends back every scenario that fails. Only three failures in a row that look the same (the same error on the same page: the app down, the session lost) stop it; the rest runs first next round.
  3. Then the regression set. Only if those pass does it run e2e-regression: the other scenarios whose covers match a file changed since the last E2E pass. A scenario that passed, and whose covered files did not change, stays out, and the round's plan says why.
  4. The E2E runner agent, only if needed. When every planned scenario passed, Lonca writes the report itself and no agent starts. A scenario that did not pass, a job that could not run or finish, or results that do not settle it start the E2E runner agent, which goes on from Lonca's results.
  5. The final check. The final check holds the criteria against the code and the E2E evidence.
  6. Once more, at the gate. A repository with a pre-PR gate runs every scenario once, after the gate's commands (beside them with gate.e2e_parallel). After a gate has passed and only light rounds came back, it runs only the scenarios that cover what changed since. See E2E at the gate.

The E2E runner agent always runs the round for an Electron app, for a runner with instructions of your own (its prompt_file), and when you wrote to it. It reports what it saw, with its evidence. It may correct a scenario whose own step is wrong, run the set again, and say so. Its "pass" over a planned scenario that the results show failed, timed out or never ran is a fail. A repository without an e2e: block skips the scenario and runner steps.

The e2e block

The Configurator writes the block from the repository and verifies the launch with a bounded run in a throwaway clone, so the repository itself is never built in. When the app cannot be started without touching real data, it writes no e2e: block and reports the change to the repository that would allow one. The block gives the repository's tasks their E2E stage; with nothing else to say it is e2e: {}.

config.yaml
repos:
  - path: ~/Projects/sales-mfe
    run: pnpm dev
    run_ports:
      PORT: 3000-3004
    e2e:
      ready_timeout_seconds: 120       # 5–900
      health_path: /                   # a status below 500 counts as up
      scenario_timeout_seconds: 180    # one scenario's limit, 10–1800
ready_timeout_seconds
How long the app may take to answer before the E2E step stops. Under consultant or autopilot Lonca tries again by itself first, then asks.
health_path
The path Lonca polls on the app’s port before a run.
scenario_timeout_seconds
Each scenario runs in a fresh browser context with this limit.

Without the block, the repository's tasks skip the E2E steps and new criteria get no E2E Check box. Before 11.0.0 the block also held an E2E routine (prompt, prompt_file) and the text of its button (label); the button went with the task's own agent session, and the Configurator removes those keys after the update.

The app and its port

Before an orchestrated E2E run, Lonca starts the app with the repository's run: line, on a slot of its run_ports:, and polls http://localhost:<port><health_path> until it answers.

  • run_ports is the only source of ports. One pool per environment variable: a range (3000-3004), a list, or { start: 3000, count: 5 }. The pools line up slot by slot, so they are the same size. The first variable is the app's own address, and the app must read its port from it. Lonca never takes a port from the worktree's .env.
  • A busy port is a wait. With every slot taken, the E2E step waits in the repository's line and goes on when its turn comes. The task names each holder and its place in line. After orchestration.resource_wait_minutes (default 30) it asks you once.
  • e2e.fixed_port is for an app that hard-codes its port. Lonca treats it as a pool of one slot, so the repository's apps run one at a time on it. Never beside run_ports.
  • A web or API app needs one of the two: a repository with neither stops to ask for one. An Electron block needs neither.
  • An app the task already runs, also one started outside Lonca from the task's worktree on a pool port, is used as it is. An app Lonca started whose run session ends before it answers is reported after a 10-second grace, so a run: line keeps the app in the foreground.
  • A broken app is restarted before you are asked. When the app Lonca started quits, or answers only server errors (5xx), Lonca restarts it, once per preparation, and the decision log says so. Only then does it ask, saying what it saw: the last status and, when it can read it, the end of the app's terminal. An app that never answered is not restarted, nor is an app you started.
  • Other settings for a scenario need nothing from you. When a scenario needs the app with other environment variables, the E2E runner agent asks Lonca with node "$LONCA_JOB" --app NAME=value ..., and Lonca restarts the app it started with them; --app alone starts it again as its run: line does. A value may be an http or https address, to point the app at a service; it may not carry a user, a password, a quote or a space. No agent starts, stops or restarts a server itself. While your own app serves the worktree (Run App, or one started outside Lonca), Lonca does not restart it: you are asked to stop it, and Lonca then starts its own.
  • Lonca stops the app it started once the test stage is over, or, with a gate, once the gate's E2E run is. With a gate whose E2E run follows its commands, it also stops the app before the commands, since a build there would change what the app serves; the gate's E2E run starts it again. An app you started yourself stays up.

Seeing the app

Show the app during E2E, in the task's menu (the header's ⋯, or the row's ⋯ or right-click) and on the hand-off card, per task and off by default, launches the browser with its window and keeps an Electron app's windows visible. Off, the browser runs headless and an Electron app is launched with LONCA_E2E_HIDDEN=1. The pre-PR gate always runs hidden.

  • An app that reads LONCA_E2E_HIDDEN, as Lonca itself does, starts with no Dock icon and its windows invisible from the first one, and never takes the focus from the app you are using. On macOS that is app.setActivationPolicy('accessory') before ready, and windows shown with showInactive(), unfocusable.
  • An app that does not read it is hidden right after its launch instead, so its Dock icon may still flash once per scenario.
  • The runner sets the flag last: a block's e2e.electron.env can neither set nor clear it. A repository with an e2e: block needs nothing. A test runner's own routine (its prompt_file) that launches an Electron app gets the flag from the Configurator after the update; one kept in a repository is reported to you with the lines to add (see After every update).

Web and API scenarios

A scenario is a module with three comment lines and one function:

a scenario
// title: Saves the filter the user picked
// criteria: AC-1
// covers: apps/sales/src/filter-bar/**, apps/sales/src/api/filters.ts
export default async function run({ page, url, step }) {
  await step('open the sales list', () => page.goto(url('/sales')));
  await page.getByText('Saved').waitFor();
}
criteria
The criteria it proves. Every criterion with an E2E check must be named by at least one scenario; a writer that leaves one out is sent back once with the ids.
covers
The source files whose screens or hooks it exercises, as repository-relative globs: how the regression set is chosen. A scenario with no valid covers runs again after every change. At most 50 globs per scenario and 50 scenarios per task.
request
Playwright’s API request context bound to the app, for an API server or a check behind a screen: await request.get('/api/health').
session
With a sign-in, session.env holds what the sign-in script left (a token), and await session.refresh() signs in again when a step lands on the sign-in page.
services
The address of each service the repository reaches directly (services['catalog-dev'].url), never a header: the runner adds the sign-in’s headers to calls to that address itself.

Electron apps

For an Electron app, the runner launches the app once per scenario from a clean folder. No port or URL is needed. The scenario runs as run({ app, page, step, tmp, session }): page is the app's first window, app Playwright's Electron application, for a check in the main process.

config.yaml
e2e:
  electron:
    build: [pnpm, build]                       # once per E2E run, before the first scenario
    app: .                                     # the folder Electron opens
    args: ['--user-data-dir={{tmp}}/profile']
    env: { HOME: '{{tmp}}/home' }
    seed: [node, scripts/e2e-seed.mjs]         # before each launch
    cleanup: [tmux, -L, 'lonca-e2e-{{run}}', kill-server]   # after each scenario
  • {{tmp}} is the scenario's own folder, deleted after; {{run}} is its id. They are the only placeholders.
  • Every command is an argument list, never a shell. ELECTRON_RUN_AS_NODE, NODE_OPTIONS, DYLD_* and LD_* are refused in env.
  • build, seed, cleanup and the launch are confirmed in a system dialog when the config is saved.
  • Leave needs_running_app out (default false). Set to true, Lonca starts the repository's run: for the run instead of the runner launching the app from a clean folder, and that run: works on your real data. For a web app or an API it changes nothing.

Scenarios follow the criteria

Lonca keeps the criteria the scenarios were written from. When the writer runs again, it is told which criteria were added, reworded, given or relieved of an E2E check, or dropped since, and which scenarios name each one.

  • A scenario whose every criterion was dropped stays on disk but no longer runs.
  • A round sent back by review, the gate, the PR or the E2E run runs the scenarios already written, as long as the criteria read exactly as they did and the issue did not change. A round sent back by the final check writes them again.
  • A gap left after the writer's second try does not stop the task: the run goes on, and the final check finds it, where you can accept the criterion without its E2E check.

Results

For each scenario Lonca records its status, steps, console errors, failed requests and, on failure, a screenshot and the page's address (origin and path only). A failing scenario is tried once more; a second failure is deterministic. At the gate, a scenario that fails is run alone once: passing alone, it is a flake; failing again, a blocker.

When Lonca runs the scenarios, their results tick the criteria, and no model can overrule them. When the final check passes and the only open boxes are E2E checks of criteria whose code is verified, the task asks you: accept them without E2E (the PR names them), or tick the boxes in the AC tab and run the final check again.

Missing data, and checks the environment blocks

The scenario writer finds or creates the data each criterion needs, and never fakes it. When the data cannot be had, the test runner says so, and the task lead, then the Workspace Lead, is asked for a way to get it. They can only answer with a way to get the data, never by removing the check. Asked a second time, or with no task lead, the question is yours.

A scenario can name the calls behind its criterion. When it fails on a service, Lonca asks that service again: the app’s own call, the same call for another record, and the same call a little later. Only GET and HEAD are sent, for at most a minute. The criterion counts as blocked by the environment only when the app’s request and at least two of these hit the same operation of a contract fetched into the task, at the same origin and path, and fail the same way: a 5xx, 408, 409, 423, 429, or no answer. A 400, 401, 403, 404 or 422 never counts. Every other scenario naming the criterion must have passed or show the same block.

  • The final check then proposes closing the criterion without its E2E check, with the reason and the evidence file (see Acceptance criteria).
  • A block holds for the code it was seen on. After a code change, the scenario runs again.
  • The record keeps the first line of each error, with query values taken out. The app’s session goes only to the app’s own origin, and nothing it sends is written down.

Per-repository sign-in

A repository whose app needs a signed-in session has a sign_in: block and a sign-in script, both written by the Configurator, or names a sign-in its workspace shares (below). You test them with your credentials in the conversation before you apply them. The script knows how to sign in; Lonca decides when.

config.yaml
repos:
  - path: ~/Projects/sales-mfe
    sign_in:
      file: prompts/sign-in/sales-mfe.mjs
      secrets: [username, password]     # 1–8 names the script reads
      # url: http://localhost:{{port}}  # the script's baseUrl; {{port}} is each task's own app
prompts/sign-in/sales-mfe.mjs
export async function signIn({ page, request, secrets, baseUrl, SignInRejected }) {
  // a form, a two-step form, POST /auth/login, a TOTP code from secrets.totp_secret…
  return {
    env: { API_TOKEN: '…' },                // for scenarios and agents: session.env
    headers: { Authorization: 'Bearer …' }, // sent with the scenarios' API requests to the app
    expiresAt: '2026-10-14T18:00:00Z',
  }; // each optional
}
export async function check({ request, session }) { /* optional: is the saved session still good? */ }
  • Lonca runs the script with the Playwright it ships, on the repository's own browser profile, with the credentials on its standard input, never in an environment variable or an argument. It masks every value in what the script prints.
  • The session (cookies and local storage, with the script's env, headers and expiresAt) is kept per repository under ~/.config/lonca/sessions/. A value that holds one of the credentials, as it is or encoded, is dropped from env and headers.
  • headers (at most 10) go with every request call a web scenario makes to the app's own address, and nowhere else: not to another address, not from a browser page. Each E2E result names the headers its calls carried, never their values.
  • A call that carries them never follows a redirect to another origin. Lonca's runner follows a redirect on the same origin itself (at most 5), and hands any other back to the scenario as it came, the 3xx and its Location, for the scenario to call that address itself, with no sign-in header. Before 12.0.0 such a call followed it and dropped only Authorization.
  • One sign-in may take 60 seconds; a network or browser failure is tried once more.

Credentials in Settings → Workspaces

The credentials never go in config.yaml. Enter them per repository under Settings → Workspaces, or once per named sign-in under its workspace's Sign-ins: one field per name in secrets.

  • Every value is masked and never shown again, except one whose name only says who signs in: username, user, user_name, email, login, account, tenant, realm, organization, domain, client_id. A secret is at least 4 characters.
  • They are kept in sign-in-credentials.bin beside the config, encrypted with the macOS Keychain. No agent, the Configurator included, ever sees them.
  • Save keeps them (a saved field left empty keeps its value), Sign in now runs the script now and shows the result, and Clear removes them.
  • A repository without a sign-in offers Set it up, which closes Settings and opens the Configurator on Set up authentication for it.

Named sign-ins

Most repositories sign in as themselves, with a sign_in: block of their own. Some need an identity that is not theirs: an app that passes the caller's token on to a service that takes only its own clients' tokens, or two repositories that sign in as one account. A workspace keeps those once, by name, in sign_ins, and a repository names one instead of its block.

config.yaml
workspaces:
  - id: shop
    sign_ins:
      catalog-dev:
        file: prompts/sign-in/catalog-dev.mjs     # its script, the same contract as a repository's
        secrets: [client_id, client_secret]       # entered in Settings, never here
        url: https://idp.dev.example.com          # optional: the script's baseUrl; never {{port}}
        service: https://catalog.dev.example.com  # optional: the service its token is for
    repos:
      - id: booking
        path: ~/Projects/booking
        sign_in: catalog-dev                       # signs in as the named sign-in
      - id: admin
        path: ~/Projects/admin
        sign_in:                                   # its own, as before
          file: prompts/sign-in/admin.mjs
          secrets: [username, password]
  • One sign-in, one set of credentials. Every repository that names it shares its session and its credentials, signed in to once. The same name in two workspaces is two sign-ins: a repository listed in both signs in with its task's workspace's.
  • The keys. The name is lowercase ([a-z][a-z0-9-]*), unique in its workspace; a workspace holds at most 20. A flat repos: list keeps them at the top level. url is a fixed address, never {{port}}: a named sign-in has no app of its own. Each named sign-in's script, address and service, and every sign_in: <name>, are confirmed when the file is saved.
  • Where the credentials go. Under Settings → Workspaces, the workspace's Sign-ins, once for every repository that names it. They are kept under the workspace and the name: renaming either asks for them again. They can also be entered in the Sign-in test card beside a Configurator offer, and in the card of a task's sign-in question.
  • After a restart. Lonca reads config.yaml when it starts. A named sign-in saved since then is tested in the offer's own card, but appears in Settings and signs in for tasks only after a restart.

Services

A repository lists the services its app and its scenarios reach that need a sign-in of their own (services, at most 8), each a named sign-in of its workspace, and how that sign-in's token goes:

config.yaml
    repos:
      - id: booking
        path: ~/Projects/booking
        sign_in: web-user                            # the app's own identity
        services:
          - sign_in: catalog-dev
            direct: true                             # scenarios may call its service with its headers
            app_headers: { X-Catalog-Token: authorization }   # on calls to booking: its authorization header, as X-Catalog-Token
            app_env: [ CATALOG_TOKEN ]               # into the environment of the booking app Lonca starts
direct: true
A scenario calls the service itself, to seed data or check its state. Its request calls to the sign-in’s service address carry the sign-in’s headers, and no other call does. A scenario learns the address, never a header.
app_headers
The app takes the service’s token in a header of its own, beside the caller’s. On every call to the app, the runner adds a header of the sign-in’s result under the app’s name for it (at most 10). Authorization, Cookie, Host, Content-* and X-Forwarded-* are refused.
app_env
The app reads a ready-made token from its environment at start. These names from the env the sign-in’s script returns (at most 10) go, with their values, into the app Lonca starts with run:, and to no other process. The repository needs run:. A client secret the app exchanges itself is a project variable instead.
  • Confirmed when saved. A new or changed entry asks you one line per delivery, naming the repository, the sign-in and where its token goes.
  • When it signs in. On demand: before an E2E run of a task of the repository, the gate's included, and when the runner asks again. With app_env, also when Lonca starts the repository's app. A service's session is never given to a stage agent.
  • Redirects and renewal. A call carrying a service's headers follows the same redirect rule as the app's. A 401 makes the runner ask for a fresh session once and send the call again; a 401 that stays, or a 403, is recorded as the service's refusal.
  • A refusal is the account's to fix, not the code's. The question's card offers Fix with the Configurator on that sign-in.
  • A renewed sign-in. The pipeline's own app is restarted before its next E2E run, once, with the new value. An app you started with Run App is not restarted: its Run control says The app is running with an older sign-in. with Restart.
  • Masked. A service's token is masked in job logs, E2E results, notifications and the PR text. Results, logs and the facts beside a question name headers and services, never values.
  • Services are not yet supported for Electron apps. Settings lists a repository's services on its card, under Services.

Key sign-ins

Some services take a fixed key and mint no token. A named sign-in with the key in secrets, no url, and a one-line script that returns it as a header delivers it as it is, when repositories list it only in services, never in sign_in. Its session then reaches only the E2E runner. The save confirms that it sends the key itself, not a token, and Sign in now says the key is ready; the service's answer comes with the first scenario that calls it.

Set up authentication

Set up authentication, a starter on the Configurator's Request step (the icon in the title bar), sets up one project's sign-in, or one named sign-in. Every plan has it. Setting up a whole new repository writes its sign-in the same way, with the rest of its entry (Set up a repository).

  1. Choose the workspace and the project, or one of its named sign-ins, and say what you already know of how it signs in (a token endpoint, the login page). Never a password.
  2. The agent reads the project (for a named sign-in, the projects that use it) and offers the sign-in and its script. On a project it may change that project's sign_in, a named sign-in only that project uses, or turn its own block into a named sign-in only it uses. On a named sign-in it changes only that sign-in and its script. Lonca refuses any other change.
  3. In the Sign-in test card, enter the credentials the script names and press Save and test. Lonca runs the offered script, not yet saved, on a profile and session of its own, so the project's real session is untouched. A named sign-in signs in at its own url. A project's sign-in signs in to an app of the project that is already up, to the sign-in's own address when that is not on this machine, or to an app it starts for the test in a temporary worktree. When Lonca cannot start one, give the address of one you started.
  4. The masked result goes into the conversation. A failure goes to the agent, which fixes the script, at most three times in a row before it waits for you. Refused credentials do not go to the agent: they are yours to correct.
  5. Apply saves the config and the script, after the system dialog. It is offered before a passing test too, marked Not tested yet.

The same Sign-in test card shows whenever the Configurator offers a sign-in it wrote, a repository's or a named one: at the first setup, after an update, in a check, in a repository's set-up or in a chat request. See The Configurator.

When Lonca signs in, and renewal

WhenWhat happens
Before an E2E runThe session is made usable before the browser starts.
Every five minutes while a stage agent of a task in the repository is upThe session is checked and kept fresh. For a sign-in to the task’s own app, while that app is on its port too. A running app with no agent up is not kept.
When a page lands on the sign-in pageAn agent runs node "$LONCA_SESSION_REFRESH"; a scenario calls session.refresh().
  • An unexpired session is used as it is, after the script's check when it has one. A session that ends within two minutes is renewed.
  • Agents get the session through LONCA_SESSION, LONCA_SESSION_PROFILE, LONCA_SESSION_REPO and LONCA_SESSION_REFRESH.

When signing in fails

  • A failure is answered from memory for a minute, so a broken sign-in is not retried in a burst.
  • Missing credentials, or a refused password, which stops Lonca sending it, make the task ask you, in words that start Signing in to <repo>…. It never goes back to the implementer: nothing in the code failed.
  • The question's card takes the credentials where it is shown, with its own Sign in now. When the script itself broke, it offers Fix with the Configurator instead, which opens Set up authentication on that sign-in with the failure filled in, and starts nothing until you press Start.
  • Saving the credentials, or a passing Sign in now, here or in Settings, answers the waiting tasks, and they go on by themselves. A named sign-in answers the waiting tasks of every repository that signs in as it.
  • A scenario Lonca could not sign in for is marked as such in the results, apart from a scenario that failed on the app.

What runs with your rights

Lonca's runner drives the browser with its own Playwright, headless unless you chose to show the app. The E2E runner agent never drives one itself, and may not use Claude in Chrome, which would act in your own browser with your sign-ins. It may curl its own app's address and run the repository's tools, but not read the worktree's source or its git history: finding a cause is the implementer's work. The scenario plan and results are Lonca's: no terminal stage agent may edit them. See Data, privacy and security.