Skip to content

Latest commit

 

History

History
671 lines (498 loc) · 28.2 KB

development.md

File metadata and controls

671 lines (498 loc) · 28.2 KB

Develop isocan

This guide explains how to set up a development environment for the isocan repository, run the app locally, and make changes to it.

It covers two starting points, one for each developer currently working on the project:

  • A new machine, with nothing installed. This is Paul's setup. See Set up a new machine.
  • An existing setup from before the multi-user work: a local daemon that serves pages, and canvases created before homes existed. This is Dion's setup. See Upgrade an existing setup.

Read the section that matches your machine, then read Development practices and Troubleshooting, which apply to both.

This guide is about working on isocan. To start a project on a canvas, see Starting a project on a canvas.

Before you begin

Install:

  • Node.js 24 — the exact version is in .nvmrc, which CI reads too; fnm use or nvm use in the checkout picks it up
  • Git

In this guide, isocan refers to the CLI in your checkout:

node packages/cli/bin/isocan.js

To shorten the commands, create an alias for your current shell session:

alias isocan="node $PWD/packages/cli/bin/isocan.js"

Caution: Don't add this alias to your shell profile, and don't rely on a globally installed isocan. A global install can be a different build than the code you're editing. When the two differ, your changes appear to have no effect.

Key concepts

Term Meaning
Canvas The unit of work. Each canvas has exactly one home.
Home The daemon or server that owns a canvas and orders its writes.
Marker .isocan/project.json in a working directory. Records the canvas ID and, optionally, its home address.
Birth default The home where new canvases created on this machine are born. Set with isocan home <url>. On a machine that has never held a canvas, an INSTALLED isocan setup now writes https://isocan.io here for you (phase 14) — a checkout does not, which is why the steps below have you set it by hand.
Replica A daemon that holds a copy of a canvas whose home is elsewhere.

A single daemon can be the home of some canvases and a replica for others at the same time.

A marker with no home address means the local daemon is that canvas's home. The daemon records each canvas's home in ~/.isocan/homes.json. A canvas with no entry in that file is local.

Set up a new machine

1. Clone and install

git clone https://github.com/dglazkov/isocan.git
cd isocan
npm install
npm run build

npm run build builds the web app into packages/web/dist, which the daemon serves.

Note: npm install might modify package-lock.json. To discard those changes, run git checkout package-lock.json.

2. Create your identity

isocan identity --home --name "Paul"

The --home flag identifies you as the owner of the machine.

If this machine already has a person and isocan setup <pass> admitted you as someone else ("admitted but not made default"), make that actor the machine's person instead of naming a new one:

isocan identity --home --as <actorId>

It folds nothing and is reversible — the confirmation names the previous person, and --home --as <their id> switches back. The home refuses an actor this machine's badge was never handed.

Note: Without --home, the command tries to identify the agent running it and fails if no agent is configured. Inside a Claude Code or Codex session, --session is implied. In that case, running isocan identity in an unbound directory also creates a canvas named after that directory.

3. Create a local canvas

isocan canvas create "Acme Scratch"

This canvas is local, because you haven't set a birth default yet. Use it to develop the web UI.

Important: Create this canvas before you set a birth default in step 5. A daemon that has a birth default and no local canvases serves no pages. If you set the birth default first, http://localhost:4441/ and all /p/<id> paths return 404, and you have nowhere to run the web UI.

4. Start the development servers

npm run dev

This starts the daemon on port 4441 and Vite on port 5173 with hot reload.

Open http://localhost:5173.

Caution: Use localhost, not 127.0.0.1. Vite binds the hostname, which resolves to ::1, so http://127.0.0.1:5173 doesn't respond. The daemon answers on both addresses, so the numeric form works everywhere except here.

To open a specific canvas, run isocan open. It prints and opens the correct address for that canvas.

5. Create a canvas at dev.isocan.io

dev.isocan.io is the shared development home. Set it as your birth default, then create a canvas there:

isocan home https://dev.isocan.io
isocan canvas create "Widget Redesign"
isocan --canvas "Widget Redesign" share

The share command prints the canvas address:

address  https://dev.isocan.io/p/prj_mj246fKBrV
link     on — anyone with the address can enter (granted 2026-08-24)

Open that address in a browser. Writes from your terminal go through your local daemon to dev:

isocan --canvas "Widget Redesign" add notes.md --title "Acme spec"

6. Verify your setup

isocan home

The output lists every canvas and its home:

role           home of 1 canvas; replica of https://dev.isocan.io (1); new canvases → https://dev.isocan.io
birth default  https://dev.isocan.io — a canvas born here is born there; nothing already here moved
answering      yes — https://dev.isocan.io is up

canvases
CANVAS           ID              HOME
Acme Scratch     prj_lGBWI…      here — this daemon is its home
Widget Redesign  prj_mj246…      https://dev.isocan.io

You now have one daemon serving two canvases with different homes. Use the local canvas to develop the web UI. Use the dev canvas to test changes against a real home, which exercises Firestore, a load balancer, and network latency that loopback connections don't reproduce.

Requesting the dev-homed canvas from your local daemon returns a signpost instead of the canvas:

$ curl -i http://127.0.0.1:4441/p/prj_mj246fKBrV
HTTP/1.1 404 Not Found
x-isocan-home: https://dev.isocan.io

this canvas lives at https://dev.isocan.io — open it there

This is expected. Each canvas has exactly one address. The web app performs the same check before mounting, so a link to a canvas that lives elsewhere renders a signpost page instead of opening a connection.

7. Verify the round trip

To confirm that writes reach the home, read them back from a separate machine that has only ever contacted the home:

isocan --canvas "Widget Redesign" pass
cd /some/empty/dir
npm --prefix ~/src/isocan run dev:replica -- setup 'https://dev.isocan.io/p/<id>#<pass>'
npm --prefix ~/src/isocan run dev:replica -- --canvas "Widget" ls

The item you added appears on a scratch machine with its own state directory, its own credentials, and no access to your disk.

Upgrade an existing setup

This section is for a machine that ran isocan before the multi-user work landed: a daemon on port 4441, canvases created on that machine, and markers that contain a canvas ID and title but no address.

You don't need to do anything

Your existing canvases continue to work:

  • They open in a browser at http://127.0.0.1:4441/p/<id>.
  • isocan add still writes to them.
  • isocan open still opens them.

A marker with no address means the local daemon is that canvas's home, so those canvases need no entry in ~/.isocan/homes.json.

Running isocan home on an unchanged setup lists every canvas as local:

$ isocan home
role           home — this daemon holds the canvases and serves the app at http://127.0.0.1:4441
birth default  here — a canvas born here stays here

canvases
CANVAS             ID              HOME
Acme Sprint Board  prj_J6Zl-7hUYu  here — this daemon is its home
Widget Redesign    prj_LhBFoZ_0Dq  here — this daemon is its home

The report lists the canvases the daemon holds, not the entries in homes.json. On this setup that file is empty ({}), because a canvas with no entry is local.

Note: Phase 6 stopped local daemons from serving pages. Phase 10.3 restored this for the canvases a daemon is the home of. A daemon serves the app for its own canvases and returns a signpost for canvases hosted elsewhere.

What changed in isocan home

isocan home <url> no longer re-points your machine. It sets the birth default, which affects only canvases created from that point on. Canvases you already have stay where they are.

Without arguments, isocan home reports the home of each canvas:

$ isocan home
role           home of 2 canvases; replica of https://dev.isocan.io (1); new canvases → https://dev.isocan.io
birth default  https://dev.isocan.io — a canvas born here is born there; nothing already here moved
answering      yes — https://dev.isocan.io is up

canvases
CANVAS           ID              HOME
Acme Sprint      prj_Le8Xz…      here — this daemon is its home
Widget Redesign  prj_mj246…      https://dev.isocan.io

Note: If your config.json already contained a home value from an earlier version, the first upgraded daemon records your existing canvases as living at that home. This preserves the behavior you had before the upgrade.

Limitation: you can't move a canvas to a home

You can create new canvases at a home, and you can share a home-hosted canvas with another of your machines using isocan pass.

You can't move an existing local canvas to a home. That operation is adoption, it's planned for phase 13, and it doesn't exist yet. There's no command, flag, or supported manual edit.

To get local work onto a hosted home today, create a new canvas at that home and copy the content across.

Use the scratch replica

npm run dev:replica starts a daemon with an isolated state directory (.dev-replica/, git-ignored) and no stored credentials.

Use it when you're working on the home, on grants, or on anything where credentials accumulated on your main machine could mask a bug.

npm run dev:replica                                 # scratch replica of dev, on port 4442
npm run dev:replica -- ls                           # run any CLI command against it
npm run dev:replica -- setup <home>/p/<id>#<pass>   # add a canvas to it

The replica starts with no canvases. It receives only the canvases it's granted access to.

Caution: Don't run the setup command from a directory that's already bound to a canvas, such as the repository root. The command redeems the pass before it detects the conflict, so the pass is consumed and you need a new one. Run it from an empty directory:

npm --prefix <checkout> run dev:replica -- setup <home>/p/<id>#<pass>

Development practices

Open the app before you believe it

The suite reads source. That is good at one thing — this decision is still written down — and blind to this screen is broken. On 30 August four bugs shipped or nearly shipped through a fully green suite: a card that never scrolled into view, ⌘Enter that appeared to add nothing, a panel header collapsed to display: block, and a reducer that stopped stamping the canvas — that last mutation passed all 2,300 tests.

node scripts/journeys.mjs is the answer: for each journey it boots a daemon on its own port in its own temp home, with a browser of its own, drives the built app through that headless browser, and walks the journeys a person actually takes. .agents/personas/journeys.md owns it, and journeys.yml walks it weekly rather than per push — ninety seconds against a suite that answers in one, for a class of bug that does not need catching within the minute.

Two rules keep it honest, and both were learned the same afternoon.

Never assert that an animation ran. A headless page throttles requestAnimationFrame and background timers, so smooth scrolling is a no-op and a 90ms interval fires at ~400ms. Assert on state — what is in the DOM, what the server holds.

Drive real input. A synthetic PointerEvent is untrusted and creates no active pointer, so setPointerCapture throws NotFoundError — which reads exactly like a crash in the app. The first Pen journey failed that way and passed the moment it used Chrome's own input pipeline. When a journey fails, ask whether the harness caused it before reporting a bug.

Share the structure, and count the copies

The Personas panel shipped with its icon on top of its own title. Five dock panels each hand-rolled a <header>; four carried a private CSS rule to lay it out, byte-identical to each other. Personas was the fifth and never got a copy.

Nothing could have caught that by reading the Personas panel, because nothing there was wrong. What was wrong was four copies elsewhere, none of which can notice a missing fifth — and each copy was correct on the day it was made, which is why review does not catch this and a month later the panel ships broken.

Three practices come out of it, in the order they are worth applying.

1. A shared component cannot half-arrive. When two surfaces render the same shape, the frame goes in one component and the differences become slots. A copy is not cheaper; it is a second thing to keep true, and there is nothing anywhere that notices when it stops being.

2. Prefer a derived guard to a listed one. panelhead.test.ts does not list the dock panels — it finds them by reading which components render dock-panel, then requires each to use PanelHead. A panel added next month is covered by a test written today, with nobody remembering to update it. A guard that lists what it checks protects exactly the cases somebody already thought of, which are the cases least likely to break.

3. Count the copying, not the omission. node scripts/measure.mjs copied-rules reports CSS rule bodies that already exist word for word elsewhere in the sheet, and it is a ratchet on the reviewer persona: it may fall and never rise. Run against the sheet before the fix it reported 48; after, 45 — the three redundant copies of the header rule, seen directly. The bug never appears where the breakage is, so the number has to describe the shape that produces it.

A rise in copied-rules is a question, not a verdict. It counts value-coincidence, which is evidence of copying and not proof. styles.css holds the opposite case explicitly — two rules whose values agree because the things they style happen to want the same treatment, where "a selector list spanning both would be one rule pretending two different elements are the same element." Four identical panel headers were one thing written four times, and merging them was right; a lens roster agreeing with a 404 page's action row is two things that agree, and merging those would be the mistake. When it is the second kind, raise the bound and write down which it was.

A ratchet only works from zero. This is the practice that keeps the rest working, and it is the one that had lapsed. A standing miss and a fresh regression print the same line, so once one bound has been over for a week every reading looks like that week — and the report becomes wallpaper. With the board at zero misses, the next red can only mean this push did that, which is a thing somebody will actually act on.

So a miss is fixed or re-baselined the day it appears, never left standing. Lowering a bound after real work is the ratchet doing its job; raising one to silence a report is how it stops being one.

What a guard cannot do is be unread. These bounds are reported by scripts/ratchet.mjs on every push and gate nothing on purpose — a check that goes red on hygiene gets turned off in a week. The cost is that news nobody opens is not a guard: unused-exports and undocumented-exports were over their bounds before any of this work, and had been for some time. When you see a miss, either fix it or move the baseline with the reason written down. Silently re-baselining upward is the one move that turns a ratchet back into a number.

Don't export ISOCAN_* variables

Use isocan home to configure the daemon. Don't export ISOCAN_* variables in your shell.

ISOCAN_HOME_URL takes precedence over config.json and is inherited by any daemon the CLI starts. A shell with this variable set disagrees with the configuration file for as long as that shell exists.

isocan home <url> refuses to write the configuration file while the variable is set:

error: ISOCAN_HOME_URL=… is set in this shell and wins over the config file —
unset it first (`unset ISOCAN_HOME_URL`), then run this again

Two components set these variables for a single child process, which is supported: scripts/dev-replica.mjs and the test suite.

If you're about to type export ISOCAN_, use isocan home, the --port flag, or npm run dev:replica instead.

Understand the deploy pipeline

The repository uses three branches:

Branch Contents Written by
main Source. You
green The most recent commit that passed CI. CI
release The published CLI. CI

Edit main only. CI generates green and release.

On every push to main, release.yml runs four complete-suite shards and the typecheck/other checks in parallel. If all pass, it fast-forwards green to that commit before installing the CLI publication toolchain. Cloud Build deploys dev.isocan.io from green.

Verification also runs concurrently across commits. Only the publish job holds the release concurrency group, after its own full gate passes. Ready publishers queue without canceling a running writer (GitHub's queue: max, up to 100 waiting jobs). The runner pool can still impose a capacity queue; this removes the workflow's own wait behind another commit's tests. It uses more runners concurrently rather than skipping older suites.

Completion order is not commit order. Under the publication lock, release-order.sh fetches current main, green and release refs and compares source ancestry. An older passing run cannot replace a newer tested or released CLI. An already-green commit can retry failed CLI publication; an already-released commit can still advance green without rebuilding. A newer untested commit on main does not prevent the current passing commit from shipping. Divergent histories or unreadable remote refs fail the job. A missing optional ref bootstraps the first release.

This needs more than the final plain pushes: each generated release has the previous release as its first parent and its source as its last parent, so a fast-forward can still ship an older source tree. Source ancestry is the guard against that rollback; the lock prevents two publishers racing it.

npm run test:ci is vitest run with every anti-skip switch set — the list lives in scripts/switches.mjs and nowhere else, so release.yml and pr.yml cannot come to disagree about what CI tests. Three suites here can decide at runtime that they cannot run: the cloud suites without a Firestore emulator, the bundle budget without a built packages/web/dist, and the deep lane, which npm test leaves out on a laptop. Locally each one skips and says what it didn't check. On this run each one is a failure, because it is the run that decides what gets released.

Run npm run test:deep before a push — the whole file set, about four minutes. The alternative is finding out from CI on a commit that has already moved green, which happened three times in the week the lane was built, every time in a file the change did not name.

npm run test:ci is stricter still and worth running when your machine can: it needs a 21+ JRE and a built dist, and without them it fails rather than skips. On a machine with neither, those two thirds of the gate are CI's.

The fast-forward uses git push without --force. If green already points at a commit that yours doesn't descend from, the push fails, CI logs a warning, and the deployed home stays where it is.

Note: Since 2026-08-24, pushing to main doesn't deploy on its own. Expect a delay of roughly one CI run, and no deployment at all if CI fails. Check gh run list --workflow=release.yml before the build history.

Test timings and shard balance

Ordinary CLI integration tests run a fresh bundle made by the release builder once per Vitest run, shared by that run's workers. It lives in a unique .isocan/test-cli-* directory and is removed after the run, so another run and test/cli-bundle.test.ts cannot overwrite it. A build failure fails the run; an earlier bundle is never reused. Watch mode uses the source launcher so edits are visible on every rerun.

Use runCli or spawnCli from packages/cli/test/cli.ts. Tests about the source loader or hooks that patch source-module instances must request source: true; pass.test.ts selects sourceCliBin for its IPC hooks. The agent-help checks still exercise the source launcher, and a parity check compares its version, full guide and module registration with the bundle. Both launch real processes against real daemons; the manifest still chooses the executable for daemon children, and the isolated-install bundle tests still exercise the release layout separately.

npm run timings summarizes local runs; npm run timings -- --ci 10 reports the last ten releases, separating initial queue time, elapsed execution and the completed green step. Per-step durations overlap and are not added to claim a wall-clock total. A completed green step can decline a stale ref; it does not prove the downstream deployment has completed.

CI partitions the files Vitest discovers by their measured durations, then runs longer files first. Every runner reads the same committed test/shard-weights.json; a missing measurement gets a default cost, never an exclusion. Local unsharded runs retain Vitest's ordinary failed-first ordering and existing worker limits.

Every test run writes .isocan/test-profile.json with file durations, shard, worker count, Node/platform, revision and whether the checkout was dirty. CI uploads it as test-profile-N, including on failures. To refresh the weights, download all four artifacts from one successful full CI run:

gh run download RUN_ID --pattern 'test-profile-*' --dir /tmp/isocan-profiles-RUN_ID
node scripts/update-shard-weights.mjs /tmp/isocan-profiles-RUN_ID/test-profile-*/test-profile.json

Review and commit the snapshot. The refresh refuses missing shards, mixed runs, filtered runs, dirty trees and failures. Do not restore mutable timing caches independently on the runners: different estimates could give them different partitions. The initial snapshot came from release run 36963426667, where shard 4 took 553 seconds while the others took 289–305.

Repoint the deploy trigger

If you need to change which branch Cloud Build watches, note the following:

  • infra/provision.sh d can't modify an existing trigger. The script exits when a trigger is already present.
  • gcloud builds triggers update github returns INVALID_ARGUMENT for this trigger, because it was created through the GitHub App and identifies its repository as github.owner/name rather than as a repository resource.

Use gcloud builds triggers import with the full resource definition, and keep the id field so the trigger updates in place instead of creating a second one.

Caution: Quote the _DEPLOY value as "yes" in the import file. Unquoted, yes is a YAML boolean. cloudbuild.yaml tests [ "${_DEPLOY}" != "yes" ], so an unquoted value produces a pipeline that builds, pushes, reports success, and deploys nothing. Verify with --format=json, because the YAML output prints yes for both the string and the boolean.

Provisioning access

Dimitri administers the isocan-io-dev Google Cloud project, which belongs to the glazkov.com organization. Steps in infra/ and in planning documents are marked ⚑ provision when they create or modify cloud resources. Those steps require his approval before they run.

There's no second operator, which is why infra/ contains idempotent shell scripts rather than Terraform. See infra/README.md for the reasoning and infra/provision.sh to run a stage. The "what needs a human" table in that README lists the steps no script can perform, including billing, DNS, GitHub OAuth consent, and certificate provisioning.

Troubleshooting

A daemon points at dev unexpectedly

Cause: ISOCAN_HOME_URL is exported in your shell. It overrides config.json and is inherited by the daemon.

Fix: Run unset ISOCAN_HOME_URL, then verify with isocan home. Each local canvas should show here — this daemon is its home.

A health check reports a live home as down

Cause: The check requests /healthz. Google's frontend intercepts that exact path on *.run.app hosts and returns its own 404, so the request never reaches the container.

Fix: Use /api/healthz, which returns the same response on a path that Google forwards. The uptime check and the Cloud Run smoke test use it.

Note: Measured on 2026-08-24, https://dev.isocan.io/healthz returns 200 through the load balancer, so the interception isn't visible at that address. Use /api/healthz anyway: a home's address is configurable, a bare Cloud Run URL is valid, and a health path must work for every address.

scripts/new-project.sh doesn't exist

Cause: new-project.md, README.md, and AGENTS.md reference this script, but it isn't in the repository or its history.

Fix: Follow the manual steps in new-project.md, which are correct and complete. Dion owns this script; don't recreate it.

The web UI doesn't load at 127.0.0.1:5173

Cause: Vite binds localhost, which resolves to ::1. The daemon answers on both addresses, so only Vite is affected.

Fix: Use http://localhost:5173.

A second checkout can't serve its own web UI

Cause: Vite proxies /api to a hardcoded 127.0.0.1:4441 in packages/web/vite.config.ts. The --port flag moves the CLI and daemon but not the proxy.

Fix: Edit vite.config.ts, or work in a single checkout.

isocan identity --name returns an error

Cause: Without --home or a harness session, the command can't determine which agent is running it.

Fix: Use --home to identify yourself as a person, or --session with a session ID for an agent.

isocan home reports role unknown

Cause: No daemon is running. isocan home doesn't start one.

Fix: This is expected behavior, not a broken installation. Start a daemon with npm run dev or any other isocan command.

A canvas created from the web UI doesn't appear in the list

Cause: On a machine with a birth default and local canvases, the web UI creates the canvas at the birth default. The list shows only canvases the local daemon hosts.

Fix: Open the canvas at its home address. This is a known issue, recorded as an open finding in phase 10.3.

A dev-homed canvas shows a signpost instead of the canvas

Cause: The local daemon isn't that canvas's home, so it doesn't serve its pages.

Fix: This is expected. Open the canvas at its home address. Keep at least one local canvas for web UI development.

Related documentation

Document Contents
AGENTS.md House rules, and the checklist that keeps the CLI and web app in sync.
README.md What the product is and does.
architecture.md What runs where — one map, all projects.
projects/ One directory per body of work: its journey, its phases, its designs.
projects/multiuser/phases.md The plan for the hosted, multi-user build: phases, status, and findings.
projects/multiuser/journey.md The target experience, written as scenarios.
reviews/lessons.md Failure modes this codebase has produced, with the guard for each.
new-project.md How to start a project on a canvas.
isocan --agent-help The collaboration protocol, shipped with the CLI.