The ultimate harness for coding agents and beyond. All your agents. All your machines. One command center. Start with code, then follow your curiosity and build across disciplines: CAD, circuits, robots, games and music.
Desktop test flavor Implementation Plan
For agentic workers: this plan is implemented by its Engineer task by task, test first, by the project's instructions (test-driven-development; one independent review on the pull request). Steps use checkbox (
- [ ]) syntax for tracking.
Goal: One command builds a pull request's Desktop and CLI and starts them as "Harness Test" beside the installed
app, with its own home, port, daemon, tmux server, Keychain item and sign-in, and stop removes all of it.
Architecture: A Python tool (desktop/tool/test_flavor.py, like tool/native_benchmark/isolation.py) builds the
PR's CLI bundle into a mktemp -d test home, builds Desktop with one new define (HARNESS_DAEMON_PORT), copies the app
under the bundle id ai.autonomous.harness.test without the harness:// scheme, and starts it with an environment that
moves every per-user resource Desktop and the CLI use (design, How it is kept apart). The test sign-in and computer id
live in ~/.harness-test, reused across runs; a guard refuses the Mac owner's own account.
Tech Stack: Python 3 (stdlib only, unittest), Dart/Flutter 3.47.2 (one const in desktop/lib/core/config.dart), the
PR's own CLI bundle (cli/build-bundle.mjs, BUNDLE_OUT_DIR), PlistBuddy and codesign.
Spec: docs/plans/2026-11-03-desktop-test-flavor-design.md
Global Constraints
- Bundle id
ai.autonomous.harness.test, name and executable "Harness Test"; noCFBundleURLTypes. - Installed app unchanged:
HARNESS_DAEMON_PORTdefaults to 18473; no new setting, no change to Info.plist or xcconfigs. - Environment of the test flavor (exact names):
HOME,PORT,TMUX_TMPDIR,CLAUDE_CONFIG_DIR,CLAUDE_SECURESTORAGE_CONFIG_DIR,CODEX_HOME,HARNESS_AUTH_DIR,ADAPTER_COMPUTER_ID_FILE,ADAPTER_UPDATE_DISABLE=1. - Test home:
mktemp -d(tempfile.mkdtemp(prefix='harness-test-flavor.')); shared test state:~/.harness-test/(auth/,computer-id); run state:desktop/build/test-flavor/state.json. - Never run the person's CLI; read
~/.harness/auth/session.jsononly for its account identity; print no token. - Stop only pids recorded in the run state; never by name or pattern.
- Same-account refusal copy: "The test copy signed in as this Mac's own account. Sign it in with the test account instead."
- macOS only; refuses elsewhere with "The Desktop test flavor runs on macOS."
Review Focus
- The person's CLI is mid-refresh when the guard reads
session.json: the guard must read without taking the CLI's lock and treat an unreadable file as "unknown", refusing to proceed rather than guessing (task 4 test). - A previous run crashed and left a test daemon and a state file:
startmust refuse to start a second copy on that state, andstopmust still clean it (task 5 test). - The chosen port is taken between
startchoosing it and the daemon binding it: the run fails with a plain message and cleans up, never falls back to 18473 (task 5 test). - The person runs the test copy's "Sign out": it must reach only
~/.harness-test/auth(task 3 proof coverslogout). - A
PORTalready set in the person's shell: the test environment overrides it, and the installed app never readsPORT(task 1 test: Desktop's port comes only from the define).
Task 1: Desktop's daemon port comes from one build-time define
Files:
- Modify:
desktop/lib/core/config.dart - Test:
desktop/test/config_daemon_port_test.dart
Interfaces:
Produces:
const int localDaemonPort = int.fromEnvironment('HARNESS_DAEMON_PORT', defaultValue: 18473);;AppConfig's defaultlocalCliBaseUrlis'http://127.0.0.1:$localDaemonPort'(a const default cannot call a function, and a helper only tests would use is dead code by ENGINEERING.md §2).Step 1: Write the failing test. Without the define,
localDaemonPort == 18473andAppConfig.dev.localCliBaseUrl == 'http://127.0.0.1:18473'; under--dart-define=HARNESS_DAEMON_PORT=18999the base URL follows it; a source check thatdesktop/libhas no other literal18473.Step 2: Run
flutter test test/config_daemon_port_test.dart→ FAIL (localDaemonPortnot defined).Step 3: Implement the two declarations in
config.dartand use them for the default.Step 4: Run the test → PASS; run
flutter analyze lib/core/config.dart.Step 5: Commit (test first, then code).
Task 2: The test flavor's environment and app identity
Files:
- Create:
desktop/tool/test_flavor.py - Test:
desktop/tool/test_test_flavor.py
Interfaces:
Produces:
TEST_ID = 'ai.autonomous.harness.test',TEST_NAME = 'Harness Test'flavor_env(base: dict, test_home: Path, shared: Path, port: int) -> dict, which returnsbasewith every Global Constraints variable set (HOME=test_home,TMUX_TMPDIR=test_home/'tmux', both Claude dirstest_home/'.claude',CODEX_HOME=test_home/'.codex',HARNESS_AUTH_DIR=shared/'auth',ADAPTER_COMPUTER_ID_FILE=shared/'computer-id',PORT=str(port),ADAPTER_UPDATE_DISABLE='1')patch_info(info: dict) -> dict: bundle id,CFBundleName,CFBundleDisplayNameandCFBundleExecutableset,CFBundleURLTypesremovedclaude_keychain_service(env: dict) -> str: mirrorscli/src/lib/agentCredentials.tsclaudeKeychainService
Step 1: Write the failing tests:
flavor_envsets each variable to the exact value, overrides an existingPORT, and never returns a path inside the baseHOME's.harness;patch_infoon the repo'sdesktop/macos/Runner/Info.plistgivesTEST_IDwith noCFBundleURLTypes;claude_keychain_service(flavor_env(...))is not'Claude Code-credentials', and equals'Claude Code-credentials-' + sha256(str(test_home/'.claude'))[:8].
Step 2: Run
python3 -m unittest desktop/tool/test_test_flavor.py→ FAIL (module missing).Step 3: Implement the three functions and the constants.
Step 4: Run → PASS.
Step 5: Commit.
Task 3: Proof: the PR's real CLI in the test environment leaves the real home untouched
Files:
- Create:
desktop/tool/test_test_flavor_isolation.py
Interfaces:
Consumes:
flavor_env(task 2).Produces:
install_cli(cli_dir: Path, test_home: Path, node: Path) -> Path, added totest_flavor.py. It runsnpm run bundlewithBUNDLE_OUT_DIR=test_home/.harness/cli, links node attest_home/.harness/runtime/node, writes that path toruntime/current-node, and returns thecli.jspath.Step 1: Write the failing test. It runs in a
mktemp -droot and never uses the realHOME:- Setup:
- a fake real home holds
.harness/auth/session.json(account[email protected]),.harness/desktop-app-v2/state.jsonandLibrary/LaunchAgents/ai.autonomous.harness.harnessd.plist, and is set asHOMEfor the test; - fake
launchctl,securityandopenon PATH append their argv to a log.
- a fake real home holds
- Run the PR's CLI with
flavor_envon a free port and a closed backend URL (BACKEND_WS_URL=ws://127.0.0.1:1):start,auth status --json,logout,stop. - Assert:
- every fake-real-home file is byte-identical (sha256 before and after);
- the launchctl log is empty;
- no
securitycall namesClaude Code-credentialswithout a suffix; - the daemon's pid file and socket are under the test home;
- nothing listens on the test port after
stop.
- Setup:
Step 2: Run
python3 -m unittest desktop/tool/test_test_flavor_isolation.py→ FAIL (install_climissing).Step 3: Implement
install_cli.Step 4: Run → PASS. Record the run in the PR.
Step 5: Commit.
Task 4: The same-account guard
Files:
- Modify:
desktop/tool/test_flavor.py - Test:
desktop/tool/test_test_flavor.py
Interfaces:
Produces:
session_account(path: Path) -> str | None, which reads the account id from a CLIsession.json(signInAcct; for an older session without it, the access token'ssub, decoded in memory and never printed or returned), or None when the file is missing or unreadable. Alsocheck_not_owner(real: str | None, test: str | None) -> None, which raisesSameAccountwith the Global Constraints copy when they are equal or whentestis None.Step 1: Write the failing tests:
- the same account id →
SameAccountwith the exact copy; - different ids pass;
- an unreadable test session raises;
- a missing real session (the person is not signed in) passes;
session_accountreturnssignInAcct, else the token'ssub, and never any token text.
- the same account id →
Step 2: Run → FAIL.
Step 3: Implement both, reading the field names the CLI writes (
cli/src/lib/authSession.tsAuthSession).Step 4: Run → PASS.
Step 5: Commit.
Task 5: start, status, stop and forget
Files:
- Modify:
desktop/tool/test_flavor.py - Test:
desktop/tool/test_test_flavor.py
Interfaces:
Consumes: tasks 2–4.
Produces:
main(argv: list[str], runner: Runner | None = None, paths: Paths | None = None, installer=install_cli) -> intwith subcommandsstart,status,stopandforget(no--dry-run: a Tester never needs one, and tests injectrunner, ENGINEERING.md §1), plus a run state{testHome, port, appPid, app}indesktop/build/test-flavor/state.json.Runnerhasrun(argv, env=None, interactive=False, check=True),launch(argv, env) -> int,alive(pid) -> bool,terminate(pid)andport_free(port) -> bool.Pathsholdsrepo,shared(~/.harness-test) andperson_home(~).start:- refuses if a state file exists ("A test copy is already running; run stop first");
- picks a free port;
- builds the CLI into a new test home (
install_cli); - signs in with
login --codewhen~/.harness-test/authhas no session (before the build, so a wrong account fails fast); - runs
check_not_owner; on refusal it signs the test session out and removes~/.harness-test/auth; - runs
desktop/scripts/build-macos-debug.sh --no-pub --dart-define=HARNESS_DAEMON_PORT=<port>; - copies the app to
desktop/build/test-flavor/Harness Test.app, appliespatch_info, renames the executable, and re-signs; - launches
Contents/MacOS/Harness Testwithflavor_env; - writes the state.
stop:- quits the recorded pid;
- runs
harness stopin the test environment; - runs
tmux -S <test home>/tmux/tmux-<uid>/default kill-server; - removes the test home, the app copy and the state file;
- reports each step that failed.
Step 1: Write the failing tests.
start,statusandstoprun with an injectedRunnerthat records commands:- the build command carries
--dart-define=HARNESS_DAEMON_PORT=<port>, not 18473; - the launch environment equals
flavor_env; - a second
startwith a state file refuses; stopon a crashed run's state (pid not alive) still removes the home and state and exits 0;- a port taken after it was chosen fails
startwith "Portwas taken; run start again", and the new home is removed;
stopnever kills anything but the recorded pid;- the same account at sign-in refuses, removes the test sign-in and launches nothing;
statuswarns when the test session is now the person's account (Desktop's own sign-in button can sign it in again).
- the build command carries
Step 2: Run → FAIL.
Step 3: Implement
mainand the subcommands;forgetsigns the test account out in a throwaway test home and removes~/.harness-test. That Mac's one test machine stays in the test account until removed in its Machines list.Step 4: Run all tool tests → PASS; run
python3 scripts/check-ui-style.py --only desktop/lib/super_tabs.Step 5: Commit.
Task 6: A Tester uses it once on a real PR
- A Tester in a person's own account on a Mac with Xcode, routed by the instructions, runs
starton this PR's branch. It signs in with the test account, opens the Swarm screen, signs out, and runsstop. It shows the installed app's~/.harnesshash andharness auth statusbefore and after, unchanged, with screenshots of "Harness Test" beside "Harness".