garage44.eu/jeroen/cartopolis

logclone: git clone https://garage44.eu/jeroen/cartopolis.git

.. /docs/notes/retired/ticket-workflow.md

raw


topic: retired/ticket-workflow triggers: [ticket, /ticket, file-issue, handover, hand-over, "issue watcher", watcher.ts, kanban, "agent:running", "agent:done", driven, autonomous, "cartopolis-ticket", forgejo.env, "Closes #"] updated: 2026-10-17

Retired: the ticket workflow

Retired 2026-10-17. Work is organised as sessions now, not as Forgejo tickets: no issues, no labels, no kanban board, no issue watcher on the VPS, and no /ticket. /handover survives in another form — from one session to the next, with no label to flip. A session is one agent thread in its own worktree on its own branch, with the maintainer in the conversation; it lands through finish-branch and leaves its reasoning in its commit bodies. The chat digests were retired the same day (agent-context-refs.md). On the VPS the issue watcher's code, state and compose service, the steward that filed tickets on a timer, and the autopilot's expiry timer were removed, archived in /data/agent/backups/ai-tickets-retired-20261017/. docs/workflow.md describes how sessions work.

What follows is the document as it stood when tickets were the unit of work — kept for the reasons behind the parts that survived (the local landing gate and the per-worktree builds) and for what the two lanes learned. Do not re-propose a ticket lane from it without saying what changed.

The agent workflow (as of 2026-10-16)

How work gets from an idea to a branch, across a desktop editor and a headless agent on the VPS, with a Forgejo kanban board as the shared view.

What this is for

One maintainer, several agents, more work in flight than one person can watch. The harness exists to make that safe to leave alone: an agent must be able to work unattended, and you must be able to trust the result without re-reading everything it did.

Five things follow, and every mechanism below is one of them:

  1. Sessions are disposable; tickets are not. A session dies, is killed, or wanders off. State therefore lives in Forgejo labels and a marker file, never in a conversation — States.
  2. How much a session may assume is a decision, not a default. A person in the room costs one sentence to correct; an unattended wrong inference costs a branch nobody asked for. Hence two lanes, and refinement before building — the lane axis.
  3. Reasoning is published, not reconstructed. A diff shows what was done, not what was considered and rejected — so the next agent redoes the rejected thing. Digests go up every turn — Handover.
  4. Nothing may gate on what the agent controls. agent:done means CI agreed, not that the session said so — notes/agent-verification.md.
  5. Standing facts live outside the agent. What constrains all future work goes in docs/notes/, what explains one diff goes in the commit body. Context is the scarce resource, not tokens.

Everything below is driven by Forgejo labels. The board column is a projection of them, never the source — see Why the board cannot be the state store.

The three workflows

Two independent questions, not one. Keeping them apart is the whole point of this section, because every mistake in this document so far came from collapsing them into a single "local vs remote".

Who is driving? — is a person reading each answer and correcting course, or is it running unattended? This decides how much it may assume, and it is what the driven / autonomous labels mean.

Where does it run? — the workstation or the VPS. This decides whether you have to be at your desk, and which machine's checkout, build cache and login the session uses. ② and ③ share all three: same image, same volumes, same clone.

local (workstation)remote (VPS)
driven (person steering)① Zed② claude.ai/code
autonomous (unattended)(nothing — see below)③ issue watcher

So driven/autonomous and local/remote are not two names for the same split. ① and ② share a lane and differ in host; ② and ③ share a host and differ in lane. Everything that follows hangs off which of those two things you are asking about.

① Zed — driven, local

claude-acp in Zed on the workstation. You are in the room, so a wrong direction costs one sentence.

Use it for: work you want to stay in the loop on, and anything whose result you have to look at.

② claude.ai/code — driven, remote

Remote Control into the cartopolis-agent container, reachable from a browser or the phone app. Same lane as Zed, not a variant of the watcher — a person is steering it turn by turn, so it is a full design/spec session that happens not to be at your desk. /ticket, the driven label, the Stop hook and the handover all apply to it unchanged.

Use it for: the same work as ①, from a browser or the phone — thinking, specs, review, changes you can state and verify in text. Often the place a ticket is written before ③ builds it.

③ Issue watcher — autonomous, remote

Headless claude -p in the cartopolis-issue-watcher container, triggered by an issue or a label rather than by you. Nobody sees the intermediate turns, which is why it refines before it builds and why refinement is required to cite the code rather than assume.

Use it for: work that should happen while you are not at a keyboard. Not for: anything visual, or anything you cannot state precisely.

A fourth lane, the autopilot (viberfox-autopilot, tools/autopilot.ts), filed tickets and landed finished ones with nobody steering. It was stopped on 2026-09-11 for filing tickets the maintainer judged invented, and its code was removed on 2026-10-11; notes/retired/autopilot.md has what it was and why it went. A ticket the watcher finishes now waits for a person to land it.

The lane axis — how much it may assume

A spec written with you in the room is reviewed as it is written. The same ticket handed to the watcher raw has to be inferred from whatever the issue says, and a confidently wrong inference costs a 45-minute session plus a branch someone has to read to discover it went sideways. That is why the driven lane is the default for real work, and why the autonomous one refines before it builds.

Each lane has a label, and which one is load-bearing depends on how much you want running unattended:

LabelSaysLoad-bearing when
drivenhands off, a person owns thisAGENT_NEW_ISSUE_MODE=refine — the watcher acts by default, so tickets opt out
autonomoustake this: refine it, then build itAGENT_NEW_ISSUE_MODE=off — nothing runs unless a ticket opts in

Neither is redundant in the other's mode. With the watcher acting by default, autonomous is still the only way to hand it a ticket it has already passed — its cursor only ever moves forward, so an issue that sat in Backlog for a week will never be picked up on its own.

autonomous differs from the bare agent label in how much it asks for: autonomous runs the full pipeline (refine, then implement), agent means "I have decided this is actionable, skip the spec". autonomous on a ticket whose branch already exists skips refinement too — rewriting the spec of half-built work is not an improvement.

driven names the lane, not the machine. It means "a person is driving this ticket; the watcher must not touch it" — true of a claude.ai/code session on the VPS just as much as a Zed session on the workstation. It replaced local, which was a misnomer for exactly that reason; local is still accepted as an alias so nothing in flight breaks.

The host axis — where the work happens

local and remote say nothing about how a session behaves; ① and ② follow the same rules throughout this document. What the host decides is practical:

The fourth cell of the matrix is empty simply because no autonomous runner is installed on the workstation. Nothing prevents one.

Walkthroughs

Three ways an idea becomes a branch, and what the board shows at each step. The column is always a projection of the labels — see States for the full mapping.

A and B are both "an idea from the couch". The difference is not where you are, it is whether you want to think it through now:

Reach for B when the idea might be wrong, or might be bigger than it looks. Reach for A when it is obviously worth doing and you simply are not going to write it up now.

C is not a third way of filing a ticket, it is a different amount of involvement. An agent writes the code in all three; what changes is how long you stay in the conversation:

Spec written byBuilt byYou are present
Athe autonomous agent, alonethe autonomous agentnot at all
Byou and an interactive agentthe autonomous agentuntil the spec is settled
Cyou and an interactive agentthe same interactive agentthroughout

So B and C start identically and diverge at the handoff. Stay in C when the implementation needs judgement rather than execution, or when the result has to be looked at — that is the only lane where cargo shots runs.

The example

All three use the same idea, so the paths can be compared:

"Warn me when I'm driving over the speed limit."

It is a good example because it sounds like an afternoon and is not. Driver mode already shows current speed in a pill (driver.rs:958). What it has no access to is the limit: TravelMode::max_speed_ms (routing.rs:145) is the A* heuristic bound per travel mode — documented to err upward on purpose — not a posted limit, and the Shortbread tiles carry only kind, oneway, surface and bicycle. There is no speed limit anywhere in the data.

So the honest answer is a question: where should the limit come from? That is exactly the thing a one-line ticket cannot say and a confident agent would invent.

A. Straight into Forgejo — the agent decides

#What happensBoard
1You open an issue titled "Warn me when I'm speeding", body: "Driver mode should tell me when I'm over the limit." No labels.not on the board
2Within 30 s: agent:refining, plus a comment saying it has been picked upBacklog
3A read-only session reads driver.rs, routing.rs and the tile schema. No branch, no commits.Backlog

It finds the gap above, so it does not write a spec:

#What happensBoard
4agent:needs-input. The description is rewritten with what it found — the speed pill at driver.rs:958, max_speed_ms being a heuristic bound, the tile layers that exist — and ends in Open questions: derive a default per road kind? add maxspeed to the tile pipeline? query Overpass live? Each with its cost.Backlog

Nothing is built. That is the point: three plausible answers, and picking wrong costs a 45-minute session plus a branch you have to read to discover it went the wrong way.

#What happensBoard
5You reply: "@agent refine — defaults per road kind for now, table in routing.rs, no new data source"Backlog
6It rewrites the spec against that decision: agent:refinedTo Do
7Queued until a slot frees, then agent:runningIn Progress
8Branch feat/23-warn-driving-speed-limit pushed, agent:done, waiting for your reviewDone

B. claude.ai/code — spec with an agent, build with the autonomous one

Same idea, but you want to know whether it is any good before committing to it — and once you do, you want to stop thinking about it.

Two agents, and that is the whole shape of this path: an interactive one writes the spec with you, then the autonomous one builds it unattended.

#What happensBoard
1You open a session and say "can we warn when speeding in driver mode?"—
2It reads the same code and tells you, in the conversation, that there is no maxspeed in the tiles — the same finding as A3, but in a minute and with you there to react—
3You settle it together: defaults per road kind, amber pill over the limit, no new data source. Two messages, not a design round.—
4/ticket --label agent files it with the agreed spec and a Branch: lineTo Do (queued)
5The watcher picks it up: agent:runningIn Progress
6Branch pushed, agent:doneDone

No refinement pass — agent means "I have decided this is actionable", and you just did, live, with the code in front of you. The difference from A is not the outcome but when the question got asked: step 2 instead of a round trip through the issue tracker.

After step 4 you are done. Steps 5 and 6 happen whether you are watching or not, which is what you traded the conversation for.

C. Zed — spec and build with the same local agent

Changing — see The sync model.

Same idea, at your desk. The local agent builds it too — you are not typing the code, you are steering it turn by turn, the same way you steered the spec in B.

The difference from B is not who writes the code but how far the conversation goes: B hands off after the spec, C keeps the same session through the implementation. Choose C when the implementation itself needs judgement rather than just execution, or when you need to look at the result — this is the only place cargo shots runs, and an amber pill is a thing you check with your eyes.

#What happensBoard
1/ticket files it with the spec, labelled driven, and moves you from main onto feat/23-warn-driving-speed-limit — created, checked out, no naming decision to makeBacklog (seeded once)
2You and the session work through it, correcting course as it goes. Every turn the Stop hook publishes the chat digest and pushes the branch.Backlog — the watcher never moves a driven card

C1 — it gets finished. Merge with finish-branch, close the issue.

#What happensBoard
3Issue closedDone

C2 — you get pulled away. Remove the driven label, and the autonomous agent continues from where the local one stopped.

#What happensBoard
3The watcher reads Branch: `feat/23-warn-driving-speed-limit` , finds it on origin, and takes it over instead of cutting a fresh branch from mainTo Do
4It fetches refs/agent-context/feat/23-warn-driving-speed-limit and reads every session digest, oldest firstIn Progress
5Continues from your commits, pushes, agent:doneDone

Step 4 is where the digest earns its keep. The diff shows a kind→speed table appearing in routing.rs. It does not show that you considered adding maxspeed to the tile pipeline and rejected it as too much for this ticket — so without the digest the next agent is free to "improve" the work by doing exactly the thing you already decided against.

Only committed work survives step 3; see Handover.

The driven lane in practice

Identical in ① and ②.

File the ticket

Use the /ticket skill. It writes a spec — problem, approach, acceptance criteria, verification, out of scope — shows it to you before filing, then creates the issue with the driven label.

.claude/skills/ticket/file-issue --title "..." < /tmp/spec.md

The card appears in Backlog within 30 s. Neither driven context places it itself; the watcher does, so the bot's board password stays in one place instead of being copied to a laptop and a container.

Credentials are ~/.config/cartopolis/forgejo.env (0600, scope write:issue) in whichever context you are in — the workstation and the container each hold their own token. Both author issues as you, not as the bot: a person is driving, and it keeps the @agent comment path working, since the watcher ignores comments authored by cartopolis-agent as a loop-breaker.

You never name a branch, and never notice one being named. Filing a ticket puts you on the right branch:

The number only exists once the issue does, which is why this happens on filing rather than when you cut a branch. Pass --branch <type>/<slug> to override the derived name; the number is still injected for you.

The watcher names branches the same way when a ticket has no Branch: line of its own. A refinement session proposes the name — it has read the code, so it knows whether the change is a fix or a feat and which area it touches — and the watcher validates the shape and injects the number: fix/23-routing-speeding-pill. With no refinement to ask, it derives one from the title ("Map is slow when zooming out" → perf/25-map-slow-zooming-out). Either way the branch matches the repo's commit convention, so a branch name and the commits on it agree about what the change is.

That name is then written into the issue body as a Branch: line, which is not decoration — see Handover.

Work

Ordinary sessions on an ordinary branch. Two things happen automatically from the Stop hook in ~/.claude/hooks/agent-context-push:

  1. a mechanical digest of the session is published to refs/agent-context/<branch> in the private context repo
  2. the branch is pushed to origin, if it has commits

This runs at the end of every turn, not when the session ends. Measured on this branch: one session, eight publications. Each one rewrites the same <session-id>.md with the transcript so far, so the digest is never more than a turn stale and a session that is killed, crashes or is simply abandoned still leaves its reasoning behind. Several sessions on one branch means several files on the ref, which is why they are read oldest-first.

The hook is scoped by remote URL, not by where it is installed: it lives in the global settings and exits silently in any repo whose origin is not cartopolis. Without that guard it would publish chat digests into every other project on the workstation.

The same script runs in both driven contexts — ~/.claude/hooks/ on the workstation and /home/agent/.claude/hooks/ on the agent_claude volume. They must stay byte-identical; md5sum both after touching either. They drifted once already, and the symptom was silent: claude.ai/code sessions published their digest but never pushed their branch, so a handover got the reasoning and none of the code.

Each claude.ai/code session gets its own worktree (--spawn worktree) on its own branch, so the digest is per-branch there exactly as on the workstation. The worktree directories are named bridge-cse_*, but the branches are ordinary feat/… / fix/… names — which is what the hook keys on.

Never work on main. The Stop hook skips it, so nothing is published and nothing is pushed; commits there are rejected by branch protection only once the work is done. All three fail silently, which is why /ticket moves you off main rather than warning you about it.

Commit before you walk away. The reasoning is safe either way — it is republished every turn. The code is not: only committed work is pushed, so uncommitted changes do not survive a handover. The digest header records the file count (uncommitted at stop: 7 file(s)) so the next agent knows something existed, but nothing can recover it.

The autonomous lane in practice

A new issue with no driven label is refined before anything is built.

Refinement

Read-only: a detached worktree, no branch, no commits. The session reads the code and rewrites the issue description as a spec. Two rules make it useful rather than confident:

It ends with one of two statuses:

A refinement that returns no status line at all is treated as needs-input. An unclear signal must not start a build.

Implementation

A worktree on the issue's branch, cut from origin/main unless it is a takeover. Verify with cargo check -p <crate> and cargo test -p cartopolis_geo && cargo test -p cartopolis, commit in Conventional Commits style, push the branch. main is protected: direct pushes are whitelisted to jeroen, so the bot cannot push to it. It can open and merge a PR through the API — the protection sets no merge whitelist, no required approvals and no status checks — but that is a thing to do when asked, not a lane the bot drives itself into.

Not --bin cartopolis. That was the command here until 2026-08-06, and since the lib+shim split (client-build-cost.md) it runs 0 of cartopolis's 207 tests — main.rs is a nine-line shim with none in it — and exits 0. The autonomous lane's only test gate was passing unconditionally. cartopolis_geo goes first because it fails in ~2 s on a geodata regression, before the client's codegen.

agent:done means a branch is waiting for review, not shipped.

Landing it: the driven lane verifies its own branch and pushes (2026-08-30)

In the driven lane you are in the room, so the review has already happened in conversation. Saying "merge to main" is the instruction to land it, and the session does it rather than handing back a branch for you to PR by hand:

.claude/skills/finish-branch/merge-to-main

It rebases onto origin/main, runs CI's gate locally, pushes the branch, fast-forwards main to it and closes the ticket. There is no pull request.

Why the pull request went. ci.yml has no push trigger on branches, so opening a PR was the only way to start a run at all. That made the cost of landing anything two full runs of a 15-25 minute workflow, on a runner with capacity 3 shared with nominatim and overpass, for one tree — once on the pull-request ref and once on the merge commit. And the first of the two was increasingly not read: of the eight merges before this change, five went from "PR opened" to "PR merged" in under six seconds. A pull request that exists for six seconds is not a review, it is a way to start a build and walk away from it.

So the verdict moved to where the code already is:

.claude/skills/finish-branch/verify-branch

which runs the same commands out of the same workflow file — cargo fmt --check, cargo test --locked --workspace --exclude cartopolis_android, and, when the diff can change a frame, the two headless smokes and the wasm and android target checks. It scopes itself with ci.yml's own deny-list (a commit touching only docs/, crates/simulator/, .forgejo/, .claude/ and *.md cannot change a frame) and it names on stdout everything it skipped, because a gate that quietly narrows itself reads as a pass over ground nobody covered.

Four properties are deliberate:

There are no pull requests left anywhere. The autopilot used to open one, and it was never a review either — it existed to start a build, since ci.yml has no push trigger on branches. The gate above replaced it for the driven lane, and the autopilot itself was removed on 2026-10-11 (notes/retired/autopilot.md), so every landing now goes through merge-to-main.

The verdict is still CI's, and it now arrives afterwards

CI has not been switched off. The push to main runs it, and on main it runs more than a pull request ever did: the two render smokes and both cross-target lanes are main-only. What changed is when the answer lands.

That is a real weakening and is worth stating plainly rather than dressing up. The old rule was that only CI's verdict on the pushed head may end a ticket, because an evaluator the agent can influence is not an evaluator. The local gate runs the same commands, but it runs them on the machine the agent is on, and it cannot reproduce a clean checkout or a cold cache. What is kept of the rule: the invocations are fixed in a checked-in script, the pass is recorded against a sha, and the independent run still happens — a red main is fixed forward, and tools/deploy-main still refuses to publish a commit whose CI never went green, which is the gate that actually protects strangers.

The autonomous lane's own gate is unchanged: a session that pushes commits gets agent:ci, and the watcher resolves it from Forgejo's commit status for the pushed head — green → agent:done, any failing check → agent:failed with the job named in a comment. Four details there are load-bearing:

Note that Deploy web runs only on main, so an agent branch is judged by the CI workflow alone. If that ever gains a branch trigger, every agent ticket inherits its result — which matters, because the web deploy has been failing on main since at least 2026-08-06.

Talking to it

Only users in AGENT_ALLOWED_USERS (currently jeroen) can start work by comment. Labelling is already restricted to users with write access, so the label triggers need no allowlist.

Handover

The driven lane stalls; the watcher picks it up. Remove the driven label (or comment @agent).

Three things have to line up, and each one used to fail silently:

The branch. The watcher reads Branch: `feat/x` from the issue body. The two lanes name branches differently — local uses feat/…, the watcher used to derive its own — so without that line a takeover would cut a fresh branch from main and ignore every local commit. main in that line is ignored.

The work. A branch already on origin means a takeover: the worktree is checked out where the branch is, and freshenWorktree is skipped. It resets to origin/main when a tree is clean and has no commits of its own, which is right for a retry and catastrophic here — a fresh worktree also has no commits of its own.

The reasoning. refs/agent-context/<branch> carries a digest of the session(s) that built the branch: what was decided, what was rejected, what was left unfinished. The watcher fetches it into the worktree and the takeover prompt points at it; the branch-context skill documents what to pull out. Read every session file, oldest first — the earliest usually holds the design decision and the later ones only execute it.

If no digest exists, the agent is told to say so rather than invent intent.

The digests live in a separate, private repo — jeroen/cartopolis-agent-context, not in cartopolis, which is public. Measured: an anonymous clone plus an explicit +refs/agent-context/* refspec retrieved every digest from a public repo, no account needed. A namespace outside refs/heads/* keeps transcripts out of a routine clone; it was never an access control.

The digest keeps user and assistant prose verbatim and one line per tool call; it drops tool results, thinking, and slash-command plumbing. Because a transcript is not reviewed before it is published, the filter also redacts values after password=, token:, Authorization: and vendor-prefixed keys. The digest is kept after the branch lands. It used to be destroyed at merge time, which only made sense while digests sat in the public repo; a private one removes the reason, and the reasoning is worth more than the branch. Deleting one is now a manual escape hatch — see notes/agent-context-refs.md and the finish-branch skill.

States

The labels are the state machine. The column follows.

LabelColumnMeaning
driven (or local)Backlog¹A person owns it. The watcher never touches it.
agent:skipBacklog¹Nobody acts on it.
(none)BacklogNew. Refinement starts on the next poll, unless AGENT_NEW_ISSUE_MODE=off.
autonomousBacklogOpt in: refine, then implement. Works on any issue, however old.
agent:refiningBacklogReading the code, writing a spec. Read-only.
agent:needs-inputBacklogRefined, but blocking questions. Parked.
agent:refinedTo DoSpec agreed. Queued for implementation.
agentTo DoExplicit "implement this now" — skips refinement. Also the takeover gesture.
(any, issue closed)DoneForgejo does not do this itself; the watcher moves cards it placed.
agent:runningIn ProgressA session is running right now.
agent:ciIn ProgressSession over, branch pushed, waiting for CI's verdict.
agent:doneDoneBranch pushed and CI passed, waiting for review.
agent:failedTo DoNeeds a human.

¹ Seeded once, then never moved again. A card the agent did not place is one you dragged, and it stays where you put it — the watcher only ever moves cards it put there itself.

To Do means queued, not merely eligible: a ticket enters it the moment it is enqueued, and leaves for In Progress when a concurrency slot frees (AGENT_MAX_CONCURRENT, currently 2). Before this was wired up a ticket handed straight to the agent sat off the board entirely and then appeared in In Progress, which made To Do a column that never meant anything.

Closing an issue moves its card to Done. Forgejo has no such behaviour of its own — checked in its source — so without this a ticket you finished by hand kept its old column and the board slowly filled with shipped work.

In Progress means a session is live, which is what makes a crashed one visible: a session killed mid-run leaves the issue stuck on agent:running on purpose. Silently retrying an unknown half-finished state is worse than a visible stall.

Why the board cannot be the state store

Forgejo 16.0.1 has no REST API for projects. Nothing matching project or column appears in swagger.v1.json, and neither Issue nor EditIssueOption carries a project field. The board is reachable only through two web routes, and those use session authentication — an API token is rejected outright.

So board.ts logs in with the bot's password and keeps the cookie. That works because Forgejo 16 removed CSRF tokens entirely in favour of Go's header-based CrossOriginProtection, which passes any request with no Origin and no Sec-Fetch-Site — every non-browser client. Three things about it are load-bearing:

Because that path is a password session against un-versioned web routes, a Forgejo upgrade can break it. Every board call is therefore failure-tolerant: it logs a warning and the work proceeds. Labels remain correct; only the card position goes stale.

The sync model

How issues, local Zed sessions and the remote agent stay in step. Built and exercised; the walkthroughs above still describe the older branch-switching flow and are rewritten next.

The picture

flowchart TB
    Z["Zed thread\ndetached worktree · marker 23"]
    I["issue #23\nlabels = lock · board follows"]
    G["origin\nfeat/23-slug"]
    X["context repo\nfeat-23-slug/"]
    W["watcher\nworktree per issue"]

    Z -->|"/ticket · /handover"| I
    Z -->|"push HEAD · per turn"| G
    Z -->|"digest · per turn"| X
    I -->|"poll 30 s"| W
    G <-->|"fetch · push"| W
    X <-->|"read · write"| W
    W -->|"done / needs-input"| I
    G -.->|"take-back"| Z

One key: the issue number

A unit of work exists in four places. Every one derives from the issue number, so nothing is kept in sync by hand:

HolderFormDerived how
Forgejo issue#23the source
Remote branchfeat/23-warn-driving-speed-limit, origin onlynumber + slug
Context dirfeat-23-warn-driving-speed-limit/remote branch, /→-
Session binding.git/cartopolis-ticket containing 23written by /ticket

The Stop hook keys on the marker file, not the branch name. That closes the silent hole hit three times (main, worktree-*, detached HEAD): a ticketed session publishes no matter where its checkout points. A session with no marker is exploratory and publishes nothing — by choice, not by accident.

Branches live only on origin

Git needs a named ref to receive code; that is all a branch is here. Locally there are none: every worktree stays detached (Zed's default), and code travels by git push origin HEAD:feat/23-…, the name derived from the marker. You never create, name, switch or push a branch — the hook does, invisibly.

Context repo: plain files on main

cartopolis-agent-context loses the ref namespace (invisible in Forgejo, needs a fetch incantation, existed only to be deletable — digests are kept now):

feat-23-warn-driving-speed-limit/
    <session-id>.md          one file per session — local and remote alike

Ownership is a lock

The labels already are one; stated as the rule it is:

LabelLocked by
drivenyou
agent:runningthe watcher, right now — touch nothing
agent / autonomous / agent:refinedqueued for the watcher
agent:needs-input / (none)free — claim before working

The whole local interface: two commands

/ticketStart of every session, by hand. Files the issue from the conversation, driven label, writes the marker. No branch creation, no checkout switching — where you sit is Zed's business.
/ticket 23Same binding, existing issue: claims it (driven), writes the marker, detaches the worktree onto origin/feat/23-… if it exists. Refuses while agent:running.
/handoverSweeps leftovers into a wip: commit, pushes HEAD to the ticket's remote branch, verifies this session's digest is in the context repo, driven→agent, comments on the issue. Refuses without a marker — ticket first.

Take-back (remote→local) is not a command: wait until not agent:running, then /ticket 23 in a fresh worktree — it fetches and detaches onto the ticket's remote branch.

Parallel sessions in Zed

Remote side: symmetry

The watcher writes the same marker into its worktrees; the same Stop hook publishes the same way; fetchAgentContext becomes "read the ticket's directory". No second mechanism.

Sync summary

WhatChannelWhen
Codeticket branch on origin, pushed as HEAD:per turn if commits exist; /handover sweeps WIP
Reasoningticket dir in context repoper turn, both sides
Ownershipissue labels/ticket, /handover, watcher
Boardcolumnswatcher, from labels — unchanged

Verified

Still unproven

Setup

① Zed — the workstation

WhatWhere
Stop hook + jq filter~/.claude/hooks/agent-context-push, agent-context.jq
Hook registration~/.claude/settings.json → hooks.Stop
Forgejo token (write:issue)~/.config/cartopolis/forgejo.env, 0600
Digest destinationjeroen/cartopolis-agent-context (private), over SSH. Override with CARTO_AGENT_CONTEXT_REMOTE

② claude.ai/code — the cartopolis-agent container

WhatWhere
Same Stop hook + jq filter/home/agent/.claude/hooks/ on the agent_claude volume
Hook registration/home/agent/.claude/settings.json → hooks.Stop
Forgejo token (write:issue)/home/agent/.config/cartopolis/forgejo.env, 0600

③ Issue watcher — the cartopolis-issue-watcher container (/data/agent/, docs in README.md there)

WhatWhere
Watcher + board driverissue-watcher/watcher.ts, issue-watcher/board.ts
Token, bot passwordwatcher.env, 0600
Modes, labels, column idsdocker-compose.yml → environment:
CI gateAGENT_CI_GATE (default on), AGENT_CI_TIMEOUT_MIN (45)

The Stop hook exists in two places on purpose — ① and ② are separate environments — but it is the same script. md5sum both after editing either; see the warning under Work for what drift looks like. ③ needs no hook: it publishes nothing, because the watcher already reports on the issue itself.

AGENT_NEW_ISSUE_MODE chooses what a new issue gets: refine (default), implement, or off.

env_file is read when a container is created, not started. Adding a variable needs docker compose up -d --force-recreate; a restart keeps the old environment, which reads as "the new code does nothing".

When it goes wrong

A card is in the wrong column. Cosmetic. Check the labels — they are the truth. docker logs cartopolis-issue-watcher will have a [board] line saying what failed.

Cards stopped moving entirely. The bot's session or password. The watcher logs board: DISABLED at startup if FORGEJO_BOT_PASSWORD is unset — which is what a restart instead of a --force-recreate looks like.

An issue is stuck on agent:running. A session died. This is deliberate, not a bug. Read /data/agent/state/logs/issue-<n>.log, then remove the label and apply agent to requeue.

A takeover ignored the local work. The issue body had no Branch: line, or the branch was never pushed. Check git ls-remote origin <branch>.

A refinement built the wrong thing anyway. @agent refine with the correction, or take it local. If this happens more than occasionally, the issue arrived too raw — file it from /ticket instead.

The digest is missing for a branch. The session was killed before Stop fired, or it predates the hook. Nothing recovers it; work from the commits.