@remits/remits-cli 0.1.110 → 0.1.113

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -21,7 +21,15 @@ description: Use remits-cli for fast branch-scoped component staging, test execu
21
21
  - [Big Picture: How remits-cli State Is Organized](#big-picture-how-remits-cli-state-is-organized)
22
22
  - [Support Ticket Mental Model](#support-ticket-mental-model)
23
23
  - [You are an agent, and you register yourself](#you-are-an-agent-and-you-register-yourself)
24
- - [The loop](#the-loop)
24
+ - [Autonomous: one ticket, one process](#autonomous-one-ticket-one-process)
25
+ - [If you are the worker](#if-you-are-the-worker)
26
+ - [Before you edit anything: where you are, and whether you may](#before-you-edit-anything-where-you-are-and-whether-you-may)
27
+ - [Your account's process is binding, and it is already in your brief](#your-accounts-process-is-binding-and-it-is-already-in-your-brief)
28
+ - [Seeing the queue as a human does](#seeing-the-queue-as-a-human-does)
29
+ - [Agent components are workers too](#agent-components-are-workers-too)
30
+ - [Moving a ticket through its lifecycle](#moving-a-ticket-through-its-lifecycle)
31
+ - [When a worker needs a decision from a human](#when-a-worker-needs-a-decision-from-a-human)
32
+ - [The manual loop](#the-manual-loop)
25
33
  - [Efficiency Rules](#efficiency-rules)
26
34
  - [Account Repository Index](#account-repository-index)
27
35
  - [Two Workflows](#two-workflows)
@@ -109,8 +117,10 @@ description: Use remits-cli for fast branch-scoped component staging, test execu
109
117
  - [Multi-Session Support](#multi-session-support)
110
118
  - [Registering This Session As An Agent](#registering-this-session-as-an-agent)
111
119
  - [What registration actually does](#what-registration-actually-does)
120
+ - [What `serve` adds](#what-serve-adds)
112
121
  - [Resolving which agent a command means](#resolving-which-agent-a-command-means)
113
122
  - [Which agent gets a ticket](#which-agent-gets-a-ticket)
123
+ - [Why a routed ticket might not have started](#why-a-routed-ticket-might-not-have-started)
114
124
  - [Background Service and Control Center](#background-service-and-control-center)
115
125
  - [Control Center](#control-center)
116
126
  - [Configuring the Preferred Agent](#configuring-the-preferred-agent)
@@ -291,8 +301,8 @@ every live component present at its real id, and nothing extra.
291
301
  | Command | What it touches | Danger |
292
302
  |---|---|---|
293
303
  | `remits-cli components stage` (alias: deprecated `push`) | **Redis staging cache only.** Never mutates the DB or git. The safe iteration surface. | none |
294
- | `remits-cli components status` | Reads the local branch/user staging scope and branch resolution. | none |
295
- | `remits-cli components clear` | Clears the local branch/user staging cache without changing DB or git. | none |
304
+ | `remits-cli components status` | Reads this lane's staging scope (account/user/branch/workspace) and branch resolution, and lists every other lane on the branch. | none |
305
+ | `remits-cli components clear` | Clears THIS lane's staging cache without changing DB or git. Never touches another workspace lane. | none |
296
306
  | `remits-cli components sync` **on trunk** | **Server-side git→DB reconcile of the whole account** (create/update/**delete**/rename). Reads the pushed remote; ignores local files. | **high** |
297
307
  | `remits-cli components sync` **on a variant branch** | Writes `ComponentVariant` overlays for that branch only. Never touches trunk rows or the account's trunk branch. When the checkout identifies a subscribing account, the branch-local `account-info.json` is refreshed for that subscriber; `--dry-run` reports the plan without writes. | medium (a missing file becomes a **tombstone** that hides the component from subscribers) |
298
308
  | `remits-cli components commit` | **One shot:** `git add -A` + commit + `git push` + **`components sync`** + `git pull --ff-only`. Blindly stages the *entire* working tree (including any drift) and reconciles it into prod. Inherits the danger of whichever sync mode the branch selects. | **highest on trunk** |
@@ -306,7 +316,7 @@ Key implications:
306
316
  - **`components sync` acts on the pushed remote**, so local edits are invisible to it until committed **and
307
317
  pushed**, and a drifted **remote** is dangerous even when your local tree looks fine.
308
318
  - After a successful non-dry-run `components sync` / `components commit`, the server clears the full
309
- branch/user staging scope. This is the expected clean state: old Redis aliases should not keep shadowing
319
+ staging scope for that lane (account/user/branch/workspace). This is the expected clean state: old Redis aliases should not keep shadowing
310
320
  the newly synced DB rows. `components sync --dry-run` intentionally leaves staging untouched.
311
321
 
312
322
  ### Intended workflows
@@ -462,17 +472,21 @@ workflows, and never one product's view of it.
462
472
 
463
473
  ### You are an agent, and you register yourself
464
474
 
465
- **If the user says anything like "register to become a support agent", run exactly this and nothing
466
- else first:**
475
+ **If the user says anything like "register to become a support agent", or "work support tickets",
476
+ run exactly this and nothing else first:**
467
477
 
468
478
  ```bash
469
- remits-cli agent register
479
+ remits-cli agent serve
470
480
  ```
471
481
 
472
482
  No flags, no setup, **no need to be in an account repo** — run it from wherever the session started.
473
483
  It registers this terminal for every account repo indexed on this machine that your user can reach,
474
- against the production platform and the production lane, and prints the accounts it was accepted for.
475
- It also prints the support loop; follow it.
484
+ against the production platform and the production lane, and then **starts working tickets on its
485
+ own**. It returns immediately; a background supervisor does the rest.
486
+
487
+ Use `remits-cli agent register` instead **only** when the user wants presence without autonomy — a
488
+ human, or you in this very tab, will work the tickets by hand. Registering alone starts nothing: it
489
+ makes the session routable and then waits to be asked.
476
490
 
477
491
  Three tabs running an agent are three agents. Each is independently routable, each reports its own
478
492
  activity, and each stops receiving work when its tab closes — a heartbeat anchored to the session dies
@@ -487,27 +501,67 @@ Two facts about a ticket are separate and must stay separate:
487
501
  | Fact | Field | Means |
488
502
  |---|---|---|
489
503
  | **Routed** | `routedAgentId` | which agent session should pick this up — delivery |
504
+ | **Claimed** | `claimedAgentId` | a worker process is running on it *right now* |
490
505
  | **Owned** | `assignedTo` | who has claimed it — accountability |
491
506
  | **Status** | `status` | where it is in the workflow |
492
507
 
493
508
  A ticket routed to you is not yet yours. Claim it with `accept`, and the queue then shows it owned.
494
509
 
495
- ### The loop
510
+ The **claim** is the supervisor's, not yours — it exists so two workers never start on one ticket,
511
+ and it expires on its own so a killed worker cannot park a ticket forever. You do not manage it.
512
+
513
+ ### Autonomous: one ticket, one process
514
+
515
+ ```bash
516
+ remits-cli agent serve # workers are whichever agent THIS session is
517
+ remits-cli agent serve --worker-agent codex --max-concurrent 2
518
+ remits-cli agent serve --mode investigate # read-only workers: no file edits
519
+ remits-cli agent workers # what is running right now
520
+ remits-cli agent release # stop serving, go offline
521
+ ```
522
+
523
+ **Run it in a plain terminal tab.** That tab becomes the agent host: `serve` returns immediately, a
524
+ detached supervisor is anchored to the tab's shell, and closing the tab stops the agent. Nothing in
525
+ that tab is an AI session — the AI only ever appears as the worker processes the supervisor spawns.
526
+
527
+ Starting it from inside an AI session works too and self-detects the worker kind, but it is the
528
+ lesser setup: it parks an interactive session as a heartbeat holder while its workers do the work.
529
+
530
+ When a ticket is routed to this session, the supervisor launches **a fresh headless agent process
531
+ for that ticket**, in that account's repo, with a brief the platform generates. That process exits
532
+ when the ticket is done.
533
+
534
+ **One ticket = one process is the point, and it is why nothing here ever needs `/clear`.** Context
535
+ grooming cannot be a discipline: `/clear` and `/new` are commands a *human types into a TUI*, and no
536
+ model can invoke them — so a long-lived session working ticket after ticket has no way to reset
537
+ itself. A process that exits has nothing to reset. Do not try to solve context growth by being tidy
538
+ inside one session; let the session end.
539
+
540
+ **`serve` returns immediately, and that is correct.** Do not follow it with a wait, a poll, or a
541
+ loop. The supervisor is detached precisely so this tab is free. Report that you are serving and
542
+ stop; you have not left the job half done.
543
+
544
+ What the supervisor handles for you, so you do not have to think about any of it: collecting routed
545
+ work, claiming each ticket so no second worker starts on it, renewing that claim while the worker
546
+ runs, reporting the worker's activity to the dashboard, dropping the claim when it exits, retrying a
547
+ failed ticket once, and releasing a ticket back to the queue when it has failed too often. Closing
548
+ the terminal stops everything and hands any in-flight work back.
549
+
550
+ ### The manual loop
496
551
 
497
- After `register`, **no agent command needs a flag** — they reuse the platform, lane and identity this
498
- session registered with.
552
+ Only when the session registered with `agent register` rather than `agent serve`.
499
553
 
500
554
  ```bash
501
555
  remits-cli agent work --wait 600 # returns as soon as work arrives
502
556
  remits-cli agent status --state working --ticket 22454 --activity "reproducing the upload failure"
503
557
  # ... investigate, fix, verify — keep `status` current as what you are doing changes ...
504
- # ... close the ticket lifecycle through mcp_support_ticket (accept -> update_status -> complete) ...
558
+ # ... close the ticket lifecycle through remits-cli ticket (accept -> status -> complete, ask, or release) ...
505
559
  remits-cli agent status --state idle # then ask for work again
506
560
  ```
507
561
 
508
- **Stay on duty.** When `agent work` returns nothing, ask again — do not stop and wait to be
509
- re-prompted. Registration persists for the life of the session (the heartbeat keeps you visible and
510
- routable even while you are not polling), but collecting work is something you have to do.
562
+ **Nothing wakes this tab.** A routed ticket sits there until someone in this session asks for it, so
563
+ if you are working the manual loop you have to keep asking. If you find yourself wishing you could
564
+ be woken up, that is what `agent serve` is.
511
565
 
512
566
  **Report what you are doing.** `agent status` is how an operator watching the dashboard, or another
513
567
  agent, knows this session is alive and what it is on. It costs one command and it is the difference
@@ -519,10 +573,82 @@ timer.
519
573
  local directory through `~/.remits-cli/account-repos.json` and `cd` there before making changes. You
520
574
  registered from anywhere; you do not fix anything from anywhere.
521
575
 
522
- **Lane note:** `register` defaults to the production lane because a support agent works real tickets.
576
+ **Capacity is real, not advisory.** A serving session tells the platform how many workers it can run
577
+ (`--max-concurrent`, default 1), and the router will not send it more than that. So a session at
578
+ capacity is skipped in favour of one that is free, rather than accumulating tickets it will never
579
+ start.
580
+
581
+ **Lane note:** `register` and `serve` default to the production lane because a support agent works real tickets.
523
582
  `--data-mode test` registers a fixture agent instead, which will never be routed a production ticket —
524
583
  use it only when you are deliberately testing the routing itself.
525
584
 
585
+ ### If you are the worker
586
+
587
+ You know you are one when `REMITS_SUPPORT_TICKET_ID` is set in your environment. Your whole job is
588
+ that one ticket, and your brief is your prompt — follow it. Two things it says that are worth
589
+ repeating: **report progress** with `remits-cli agent status --ticket <id> --activity "..."` (a
590
+ headless run is invisible otherwise), and **end in a terminal state** — `complete` with a real
591
+ resolution, or `update_status` with what you established and what the next agent should try. Exiting
592
+ quietly leaves a ticket that looks in-flight forever.
593
+
594
+ ### Before you edit anything: where you are, and whether you may
595
+
596
+ Presence answers *who*. Two more facts answer *whether you may edit*, and with git worktrees and
597
+ workspace lanes an account id no longer identifies a working tree — so an agent that does not ask these
598
+ is assuming, and the assumption it makes when it guesses wrong is "this is my repository to edit".
599
+
600
+ ```bash
601
+ remits-cli ticket where --ticket 22454 # repo account, checkout, branch, staging lane, lease, claim, YOUR phase
602
+ remits-cli agent map # every repository, who holds each lease, and where each agent is working
603
+ ```
604
+
605
+ **Reading, reproducing and investigating are parallel-safe and unrestricted. Editing one account's
606
+ repository is exclusive**, enforced by a lease held per repository account per data lane:
607
+
608
+ ```bash
609
+ remits-cli ticket lease --ticket 22454 # take it when you started read-only and reached an actual edit
610
+ remits-cli ticket unlease --ticket 22454 # complete / ask / release already do this for you
611
+ ```
612
+
613
+ Four things are worth knowing and are not obvious:
614
+
615
+ - **A refusal is not an error.** The run continues read-only, and the message names who holds the lease
616
+ **and where they are working**, so you can tell a real conflict from a holder in a different worktree.
617
+ **Do not wait for a lease and do not poll for one** — investigation is most of the work on most
618
+ tickets, and a ticket that turns out to need an edit hands off with `ticket progress --next-step`
619
+ saying exactly what change is needed. A lock people queue on turns one stuck worker into a stalled
620
+ fleet.
621
+ - **A staging workspace does not replace the lease.** Separate lanes stop two runs *resolving* each
622
+ other's staged code; they do nothing about two processes writing the same files or pushing the same
623
+ branch, which is what actually destroys work.
624
+ - **One editing worker per repository account per lane — worktrees do not change this.** Two worktrees
625
+ of one repo push to the same branch on the same remote, so per-directory leases would trade file
626
+ conflicts for non-fast-forward push conflicts, which surface later and are worse.
627
+ - **A spawned ticket worker already has its own staging lane** (`REMITS_WORKSPACE=ticket-<id>`). You do
628
+ not set it, and your brief states it. Say which lane you staged into when you report what you verified
629
+ — somebody looking at the shared lane will not see your changes.
630
+
631
+ `unlease` returns **your own** lease and deliberately cannot touch anybody else's. Breaking a stale one
632
+ is a separate, human verb: `remits-cli ticket force-unlease --ticket ID --reason "..."`.
633
+
634
+ ### Your account's process is binding, and it is already in your brief
635
+
636
+ An account declares how its work is done as Prompts with purpose `OPERATIONS`, selected per the ticket's
637
+ `workstream` (`support`, `sdlc`, `incident`, `release`, or whatever that organization calls its
638
+ processes) via `Prompt.category`, with an uncategorised one as the catch-all. The matching text is
639
+ **inlined verbatim into the brief** of every agent that works one of that account's tickets and is
640
+ binding on it — follow it even where it differs from how you would normally proceed, and if it conflicts
641
+ with the brief, follow the process and say so on the ticket.
642
+
643
+ You do not fetch it: if the brief has a "The process that governs this ticket" section, that is it. If
644
+ it says the account documents no process, the likely cause is that the prompt is **staged but not
645
+ committed** — an autonomous worker resolves the committed one, so it is never bound by a procedure
646
+ nobody has reviewed. The repo root also carries a generated `OPERATIONS.md`; that file is generated
647
+ from the prompt, so **edit the prompt, not the file**.
648
+
649
+ `workstream` is not `type`: a type classifies the request, a workstream names the procedure, and they
650
+ cross — a `defect` handled by incident response out of hours goes through the SDLC in the morning.
651
+
526
652
  ### Seeing the queue as a human does
527
653
 
528
654
  `remits-cli start` opens a browser control center showing the same facts you are acting on: which
@@ -530,7 +656,147 @@ agents are registered and what each is doing, which tickets are open, and which
530
656
  to. An operator can route a ticket to a specific agent from there. It is a view, not a second system —
531
657
  what it shows and what `remits-cli agent work` returns come from the same records.
532
658
 
533
- Use `mcp_support_ticket` to manage lifecycle:Use `mcp_support_ticket` to manage lifecycle:
659
+ ### Agent components are workers too
660
+
661
+ An Agent component that works support tickets must register itself in the same presence registry as
662
+ CLI sessions. That makes it visible in `cliAgents()` and `remits-cli agent map`, and lets
663
+ `dispatch(...)` / `ticket route` target it by the same `agentId` field:
664
+
665
+ ```groovy
666
+ def me = workerId() // component:Agent:34
667
+ registerWorker([agentId: me, label: 'Support Triage Agent'])
668
+ def work = workerWork([agentId: me, runId: threadGroupingId()])
669
+ workerStatus([agentId: me, ticketId: work.tickets[0]?.id, activity: 'investigating'])
670
+ ```
671
+
672
+ `workerWork(...)` is the component-side analogue of `remits-cli agent work` — the same code runs behind
673
+ both, so a component and a terminal session get the same answer to the same question. It reads tickets
674
+ routed to that worker, claims what it may start, sweeps eligible unrouted work when it is idle (reported
675
+ separately as `sweptTicketIds`), takes the repository edit lease when available, and returns `phase`,
676
+ `brief`, `briefFacts`, and `editLease`. `phase:'editing'` means the component may edit and stage;
677
+ `phase:'investigating'` means another worker holds the repo lease and the component must stay read-only.
678
+ When a component reaches a resting point, pass `agentId` to `complete(...)`, `ask(...)`, or
679
+ `release(...)` so the ticket verb frees the edit lease and drops its claim.
680
+
681
+ Route to a component by its **id** (`component:Agent:34`) — that is what `workerId()` returns and what
682
+ the component polls on. `ticket route --agent component:Agent:MyAgent` also works: the name is resolved
683
+ and the id form is what gets stored.
684
+
685
+ ### Moving a ticket through its lifecycle
686
+
687
+ **`remits-cli ticket` is the platform surface, and it is what you should reach for.** It reads and
688
+ writes the platform's own ticket record, so the same commands work on every Remits platform.
689
+
690
+ ```bash
691
+ remits-cli ticket read --ticket 22454 # the full record
692
+ remits-cli ticket accept --ticket 22454 # claim it before changing anything
693
+ remits-cli ticket progress --ticket 22454 --summary "Traced it to the posting Action" --category investigation
694
+ remits-cli ticket status --ticket 22454 --status in_progress
695
+ remits-cli ticket complete --ticket 22454 --resolution "What you found and did"
696
+ remits-cli ticket ask --ticket 22454 --question "Re-issue or skip?" --context "412 affected"
697
+ remits-cli ticket answer --ticket 22454 --message "Skip them." # alias: reply
698
+ remits-cli ticket message --ticket 22454 --message "We reproduced it; a fix is staged."
699
+ remits-cli ticket planning --ticket 22454 --board-stage ready_for_qa --blocked-by CAB-112
700
+ remits-cli ticket release --ticket 22454 # hand it back to the queue
701
+ ```
702
+
703
+ **See the whole queue before deciding your ticket is unique.** Alert-raised tickets arrive in
704
+ clusters, and the same root cause routinely appears under several different account names — so the
705
+ first useful question is usually "how many of these are one fix?", and you cannot ask it from a single
706
+ ticket.
707
+
708
+ ```bash
709
+ remits-cli ticket queue --account-id 49 # triage order, most urgent first
710
+ remits-cli ticket queue --account-id 49 --unrouted --status open
711
+ remits-cli ticket queue --account-id 49 --search "firestore index"
712
+ ```
713
+
714
+ The `repo` column is the account the **edit lease** excludes on, so it also tells you which of these
715
+ could be worked at the same time and which will serialize behind one another.
716
+
717
+ Found a second, unrelated problem while working yours? **File it rather than widening the ticket you
718
+ were given** — a ticket that describes two things cannot be closed by either fix.
719
+
720
+ ```bash
721
+ remits-cli ticket create --account-id 49 --subject "Vendor name lost on re-normalization" \
722
+ --type defect --priority medium --reference-id vendor-name-lost
723
+ ```
724
+
725
+ `--reference-id` makes it get-or-create, so a re-run — or another worker reaching the same conclusion
726
+ — reconciles onto the same ticket instead of filing a duplicate.
727
+
728
+ Marking and evidence, so the next reader does not repeat your work:
729
+
730
+ ```bash
731
+ remits-cli ticket tag --ticket 22454 --tags firestore-index,cluster-aug
732
+ remits-cli ticket artifact --ticket 22454 --type log --label "Failing query" --content "..."
733
+ remits-cli ticket note --ticket 22454 --message "Internal: same cause as 23465"
734
+ remits-cli ticket field --ticket 22454 --key customerReference --value CR-9182
735
+ ```
736
+
737
+ `note` is internal — the next worker and a reviewer see it, the requester does not. Use `message` for
738
+ anything the requester should read. `field` writes your **organization's own** field, outside the
739
+ platform's bounded planning slots.
740
+
741
+ **`message`, `answer` and `note` are separated by who reads the result, not by tone.** They are easy to
742
+ confuse and they do different things to the ticket:
743
+
744
+ | Command | Who reads it | What it does to the ticket |
745
+ |---|---|---|
746
+ | `ticket message --message "..."` | the requester | appends a public entry. **Does not send anything** |
747
+ | `ticket note --message "..."` | the next worker, a reviewer | appends an internal entry |
748
+ | `ticket answer --message "..."` | whoever asked | answers the open question and **re-routes**, so a fresh worker resumes |
749
+
750
+ `ticket reply` is an **alias of `answer`** — kept because every existing brief says it. Do not read it as
751
+ "reply to the customer"; that is `message`. (Some account tools spell the conversational verb `reply`,
752
+ which is exactly why this surface teaches `answer`.)
753
+
754
+ **Appending a message is not emailing anyone.** The record is deliberately vendor-agnostic; the account
755
+ owns the transport. To ask for something to actually go out:
756
+
757
+ ```bash
758
+ remits-cli ticket deliver --ticket 22454 --channel email --to ops@acme.test \
759
+ --subject "Waiting on you" --idempotency-key waiting-22454
760
+ remits-cli ticket deliveries --ticket 22454 # what is queued, and what already went
761
+ ```
762
+
763
+ That records an outbox request. An account-owned Rule or scheduled Action sends it and marks the result
764
+ (`ticket delivered --delivery-id ...` / `ticket delivery-failed --delivery-id ... --reason "..."`). Use
765
+ this when a ticket is waiting on somebody who is not watching the queue.
766
+
767
+ ### When a worker needs a decision from a human
768
+
769
+ There are **three** ways a run can end, not two, and the third is what stops an agent guessing:
770
+
771
+ | Outcome | Verb | Means |
772
+ |---|---|---|
773
+ | Done | `ticket complete --resolution` | finished, here is what I did |
774
+ | **Blocked on a choice** | `ticket ask --question` | I understand the work; the DECISION is not mine |
775
+
776
+ | Could not finish | `ticket status --status pending_review` + `ticket progress` | stuck, here is the hand-off |
777
+
778
+ `ask` puts the question on the ticket as an outbound message and parks it. The queue then shows it as
779
+ **awaiting a response** — distinct from "done, review me", which `pending_review` alone cannot express.
780
+
781
+ Someone answers with `remits-cli ticket answer --message "..."` (`reply` is an alias), or through an
782
+ operator Embeddable.
783
+ That **re-routes the ticket by default**, so the supervisor's next poll starts a **fresh worker whose
784
+ brief already contains the exchange**. Resumption costs nothing because a worker is one process per
785
+ ticket — there is no session to restore.
786
+
787
+ Ask when the choice is genuinely not yours: which of two behaviours is wanted, whether to touch live
788
+ data, an ambiguity in the request. Do not ask for reassurance about something you can determine
789
+ yourself, and ask **once**, with the options laid out.
790
+
791
+ Inside an autonomous worker `--ticket` defaults to the ticket that worker was launched for.
792
+
793
+ A refusal is an **answer**: "accept it first", "already assigned to someone else", "reopen it
794
+ first". Act on the sentence — do not go looking for another tool that lets you skip the step.
795
+
796
+ **`mcp_support_ticket` is an account convention, not a platform guarantee.** It belongs to one
797
+ particular System Account: it may not exist on the platform you are on, it scopes to its own
798
+ account, and it will refuse a ticket owned by a different one. Use it only when you are working in
799
+ that account and want its product-specific workflow on top of the record. It offers:
534
800
  - `read` — always start here to load current state
535
801
  - `accept` — claim the ticket so other agents do not work it concurrently
536
802
  - `update_status` — move to `in_progress` or `pending_review`
@@ -548,8 +814,9 @@ Ticket-routing context:
548
814
  - For defect investigations, start from the owning ticket account, then move to the platform/product context if the root cause is in shared components.
549
815
 
550
816
  Sandbox note:
551
- - `remits-cli` commands that call the Remits service (`auth`, `tools`, `tool`, `components`, `test`, `token`) require outbound network access.
552
- - In Codex or similar sandboxed agent environments, `ENOTFOUND`, `EAI_AGAIN`, `ECONNREFUSED`, `EPERM`, or similar network errors usually mean the command must be retried with escalated permissions or outside the sandbox.
817
+ - Every `remits-cli` command that reaches the Remits service (`auth`, `tools`, `tool`, `components`, `test`, `token`, and all of `ticket` / `agent`) needs outbound network access.
818
+ - **Inside an autonomous ticket worker this is already arranged** — the supervisor launches the worker with network enabled, in both the editing and the investigating phase. An investigating worker is restricted from *writing the repository*, never from *talking to the platform*: reading its ticket, running a diagnostic and recording a finding are the whole of what investigating means.
819
+ - Elsewhere, `ENOTFOUND`, `EAI_AGAIN`, `ECONNREFUSED`, `EPERM` or a bare exit 6 / `HTTP:000` from a sandboxed session means the command needs escalated permissions or must run outside the sandbox. Do not read it as "the platform is down" — check a second command before concluding anything about the service.
553
820
 
554
821
  Use the same repo/context rules as other tools:
555
822
  - If the ticket targets a `CLIENT` account, do not assume that client's repo is the implementation repo. Confirm the parent `PLATFORM` / `PRODUCT` relationship first.
@@ -839,6 +1106,43 @@ remits-cli tool --name "mcp_run_action" --input '{"accountId":49,"actionId":200,
839
1106
 
840
1107
  Every tool response is saved to `./.remits-cli/tool-responses/<callId>.json`.
841
1108
 
1109
+ ### Hierarchy-scoped tool reads
1110
+
1111
+ For read/discovery tools, the account resolved from the checkout/session is the **scope root**, not proof
1112
+ that the business record is owned by that account. This closes the common support loop where you know a
1113
+ precise document, object, event, or indexed source id but do not yet know which child account owns it.
1114
+
1115
+ Use the tool flags rather than editing JSON by hand:
1116
+
1117
+ ```bash
1118
+ remits-cli tool --name mcp_firestore_search \
1119
+ --input '{"collection":"statements","documentId":"1234"}' \
1120
+ --scope children --data-mode prod
1121
+ ```
1122
+
1123
+ Available flags:
1124
+
1125
+ | Flag | Meaning |
1126
+ |---|---|
1127
+ | `--scope self|children|hierarchy` | Expand from the repo/session account for read/discovery. Exact-id lookups usually default to `children`; broad searches default to `self` unless widened. |
1128
+ | `--target-account-id ID` | Exact owner/execution account when already known. Required by mutating tools. |
1129
+ | `--account-ids 1,2,3` | Explicit bounded owner list. The platform verifies every id against the scope root. |
1130
+ | `--anchor-account-id ID` | Path-disambiguation anchor for multi-parent account relationships. |
1131
+
1132
+ The CLI merges these into `--input`; a value already present in `--input` wins. Tool responses echo
1133
+ `scopeRootAccountId`, `scope`, `accountIds`, and, when an exact owner is discovered,
1134
+ `resolvedTargetAccountId`. Feed that returned owner to `mcp_firestore_patch`, action/test runs, and browser
1135
+ tokens. Mutating tools do not infer or fan out writes.
1136
+
1137
+ The implicit account ceiling is intentionally different by shape: broad searches stay capped at 100 accounts
1138
+ unless the tool says otherwise, while exact-id discovery may span up to 1000 accounts by default. If a broad
1139
+ tool returns `scopeTooBroad`, narrow with `--target-account-id`, `--account-ids`, or a smaller `--scope`.
1140
+
1141
+ `mcp_firestore_search` handles exact Firestore document ids. `mcp_index_search` handles fuzzy/semantic
1142
+ lookup through Vertex. `mcp_bigquery_query` handles warehouse lookup/query with server-resolved
1143
+ `{table_current}`/`{table}` placeholders and the scoped `{account_filter}` predicate. BigQuery is a prod
1144
+ analytics surface, so use `--data-mode prod` when you intend to query it.
1145
+
842
1146
  Poll a CLI-transport async call (mechanism 2) by call id:
843
1147
 
844
1148
  ```bash
@@ -1071,7 +1375,7 @@ If verification reveals issues, repeat the loop: **edit → stage → run**. Eve
1071
1375
  Don't ask the user for permission to re-iterate — just do it. Only stop to ask if you're stuck or unsure about the intended behavior.
1072
1376
 
1073
1377
  If the work is tied to a support ticket:
1074
- - Use `mcp_support_ticket` to mark the ticket `in_progress` once you have started substantive work.
1378
+ - Use `remits-cli ticket status --status in_progress` once you have started substantive work.
1075
1379
  - If a new reply arrives, re-read the ticket and incorporate the reply into your current plan.
1076
1380
 
1077
1381
  #### Step 6: Update Documentation
@@ -1151,8 +1455,8 @@ unexpectedly, stop and inspect the repo-local session log before running any mut
1151
1455
  If the request came from a support ticket, the task is not complete until you update the ticket lifecycle yourself:
1152
1456
 
1153
1457
  1. Re-read the ticket if needed to confirm the latest state and replies.
1154
- 2. If the work is done and verified, call `mcp_support_ticket` with `complete` and include a concise resolution summary.
1155
- 3. If you cannot finish, use `update_status` or `release` with clear notes so the next agent can continue.
1458
+ 2. If the work is done and verified, call `remits-cli ticket complete` and include a concise resolution summary.
1459
+ 3. If you cannot finish, use `remits-cli ticket status` or `remits-cli ticket release` with clear notes so the next agent can continue.
1156
1460
  4. Do this automatically. The human user should not need to instruct you to update the ticket.
1157
1461
 
1158
1462
  Options:
@@ -1203,10 +1507,17 @@ Plus the compile cache:
1203
1507
  ### Staging cache key format
1204
1508
 
1205
1509
  ```
1510
+ # default lane (no workspace)
1206
1511
  account:<accountId>:cli:<cliUserId>:components:<branch>:<family>:id:<componentId>
1207
1512
  account:<accountId>:cli:<cliUserId>:components:<branch>:<family>:name:<normalizedName>
1513
+
1514
+ # workspace lane
1515
+ account:<accountId>:cli:<cliUserId>:components:<branch>:ws:<workspace>:<family>:id:<componentId>
1208
1516
  ```
1209
1517
 
1518
+ The staging scope is therefore **account + cli user + branch + workspace**. `workspace` is optional and
1519
+ absent by default; see "Working alongside other agents: the staging WORKSPACE" above.
1520
+
1210
1521
  `<family>` is the lowercased component family (`reader`, `action`, `test`, `embeddable`, ...). Both an
1211
1522
  `id:` and a `name:` key are written per stage. The entry value carries: `kind` (the family), `type` (the
1212
1523
  component's OWN type enum such as `ObjectType`/`RuleType`, or absent — **never** the family), `hash`,
@@ -1284,15 +1595,51 @@ TestMode still uses the committed DB source. Staging remains a dev/verification
1284
1595
  `No enum constant ObjectType.reader`).
1285
1596
  - **Confirm the DB version:** `mcp_component_view` reads the live DB source directly (no staging, no compile
1286
1597
  cache), so it is the source of truth for "what was committed."
1287
- - **Ask the CLI what is staged:** `remits-cli components status` lists the current branch/user staged entries,
1598
+ - **Ask the CLI what is staged:** `remits-cli components status` lists this lane's staged entries,
1288
1599
  including staged fields, aliases, hashes, and TTLs. The default terminal output is concise; pass `--json` or
1289
1600
  `--verbose` when you need the full staged-entry payload. `remits-cli components clear` removes those entries
1290
1601
  when you intentionally want to fall back to DB source.
1291
1602
 
1603
+ ### Working alongside other agents: the staging WORKSPACE
1604
+
1605
+ Staging is scoped by `(account, cli user, branch, workspace)`. Account and user are fixed for a repo, so
1606
+ **without a workspace the git branch is the only isolation axis** — and `components stage` uploads the
1607
+ ENTIRE repo and REPLACES the lane rather than merging into it. Two agents on one branch therefore
1608
+ overwrite each other, and a `components commit` clears the lane out from under the other one.
1609
+
1610
+ If more than one agent is working on the same branch, give each its own workspace:
1611
+
1612
+ ```bash
1613
+ git worktree add ../repo-agent-a forked # one checkout per agent, same branch
1614
+ cd ../repo-agent-a
1615
+ remits-cli workspace use --auto # names the lane after this directory
1616
+ remits-cli components stage # isolated: nobody else sees it, nobody overwrites it
1617
+ remits-cli test run --test 42
1618
+ remits-cli token --path /page/whatever
1619
+ ```
1620
+
1621
+ A workspace narrows STAGING and nothing else. A commit still targets the same branch and the same owner
1622
+ account, and the run still resolves whatever committed variant branch the account subscribes to — so it
1623
+ does **not** have the side effects of inventing a throwaway git branch per agent (which would make a
1624
+ commit write `ComponentVariant` overlays for a branch nobody subscribes to).
1625
+
1626
+ - `.remits-cli/workspace` is per-checkout and gitignored, so each worktree keeps its own lane.
1627
+ - Precedence: `--workspace NAME` > `REMITS_WORKSPACE` > `.remits-cli/workspace` > shared default lane.
1628
+ - `--no-workspace` targets the shared lane for one command without clearing the file.
1629
+ - Every stage / test run / token / clear prints its `Staging lane:` — if a change seems to have had no
1630
+ effect, check that line FIRST. A mismatched lane resolves committed source, which looks identical to
1631
+ "the stage did not work".
1632
+ - `remits-cli components status` lists every lane staged on the branch, so you can see whether another
1633
+ agent is working alongside you.
1634
+ - `remits-cli components clear --all` is scoped to YOUR lane and never touches another agent's.
1635
+
1292
1636
  ### Stage / sync / clear with remits-cli
1293
1637
 
1294
1638
  - `remits-cli components stage` writes local file changes into the Redis staging cache for the current
1295
- branch/user scope. This is the normal edit/test loop.
1639
+ branch/user/workspace scope. This is the normal edit/test loop.
1640
+ - `remits-cli components stage --changed-only` stages just the components this working tree edited. It
1641
+ does NOT reconcile, so entries for components it did not mention are left alone rather than deleted.
1642
+ Useful on a large repo; a full stage is still the default and the safest.
1296
1643
  - `remits-cli components status` shows which branch/variant world the checkout resolves, plus staged entries,
1297
1644
  staged fields, aliases, hashes, and TTLs. Use `--json` or `--verbose` for the full staged-entry payload.
1298
1645
  - **A full `stage` makes the `.meta.yml` AUTHORITATIVE.** Staging layers a payload over what is already
@@ -2729,8 +3076,11 @@ ticket with `mcp_support_ticket read` before lifecycle work and honor `mirrorOnl
2729
3076
  | `priorities` / `types` / `sources` / `tags` | no | Additional filters |
2730
3077
  | `assignedTo` / `unassigned` | no | Assignment filters |
2731
3078
  | `implementationAccountId` | no | Filter by owning `PLATFORM`/`PRODUCT` account |
2732
- | `search` | no | Case-insensitive across subject, description, account, affected component, sender, tags |
2733
- | `sortBy` / `sortDirection` | no | `triage` (default-style: critical/high unassigned first), `updated`, `priority`, `status`, `account` |
3079
+ | `workstream` / `plannedIn` / `boardStage` / `size` / `blockedBy` | no | SDLC-agnostic planning filters; exact matches on compact queue fields |
3080
+ | `rank` / `minRank` / `maxRank` | no | Exact or inclusive range filters for numeric planning rank |
3081
+ | `search` | no | Case-insensitive across subject, description, account, affected component, sender, tags, workstream, and planning fields |
3082
+ | `sortBy` | no | `triage` (default-style: critical/high unassigned first), `updated`, `priority`, `status`, `account`, `plannedIn`, `boardStage`, `rank`, `size` |
3083
+ | `sortDirection` | no | `asc` / `desc`, and it means the same thing on every axis. Natural order is `desc` for `triage`/`updated`/`priority` and `asc` for `status`/`account`/`rank`/`plannedIn`/`boardStage`/`size`, so pass it only to invert one |
2734
3084
  | `limit` / `offset` / `scanLimitPerAccount` | no | Paging and scan bounds |
2735
3085
  | `dataMode` | no | Normal agent work uses the **prod** ticket queue |
2736
3086
 
@@ -2771,13 +3121,18 @@ so in its own output; when a test run genuinely needs prod data, pass the flag.
2771
3121
  independent of everything else — no background service is required, and every tab is its own agent.
2772
3122
 
2773
3123
  ```bash
2774
- remits-cli agent register # this session is now routable — no flags, any directory
2775
- remits-cli agent work --wait 300 # ask for tickets routed here
2776
- remits-cli agent status --state working --ticket 22454 --activity "reproducing"
3124
+ remits-cli agent serve # routable AND autonomously working tickets — the usual choice
3125
+ remits-cli agent workers # what this session is running right now
2777
3126
  remits-cli agent list # who else is available across the accounts you cover
2778
- remits-cli agent release # stop receiving tickets right now
3127
+ remits-cli agent release # stop serving and stop receiving tickets right now
3128
+
3129
+ remits-cli agent register # presence ONLY — nothing starts on its own
3130
+ remits-cli agent work --wait 300 # ask for tickets routed here (manual loop)
3131
+ remits-cli agent status --state working --ticket 22454 --activity "reproducing"
2779
3132
  ```
2780
3133
 
3134
+ `serve` is `register` plus a supervisor. Everything below about registration applies to both.
3135
+
2781
3136
  **Defaults exist so the user does not have to type them.** With no flags, `register` targets the
2782
3137
  production platform (`REMITS_BASE_URL` when set) and the **prod** lane, and claims every account repo
2783
3138
  indexed on this machine. That is a deliberate exception to the CLI's test-first default: registering
@@ -2798,6 +3153,48 @@ platform, lane and identity it registered with.
2798
3153
  minutes. Closing the tab is a valid way to go offline; `agent release` just makes it immediate.
2799
3154
  - Registers in the session's **data lane**. A `test`-lane run only ever reaches a `test`-lane agent,
2800
3155
  which is what keeps fixture traffic away from a production terminal.
3156
+ - Declares **capacity** — how many tickets this session can genuinely run at once (`--max-concurrent`,
3157
+ default 1). The router will not exceed it.
3158
+
3159
+ ### What `serve` adds
3160
+
3161
+ The same detached process that maintains presence also polls for work. On each poll it publishes the
3162
+ tickets it currently has running, renews their claims, and takes at most enough new ones to fill its
3163
+ capacity. For each new ticket it launches a headless worker:
3164
+
3165
+ | | headless invocation | edit mode | investigate mode |
3166
+ |---|---|---|---|
3167
+ | `codex` | `codex exec --cd <repo>` | `--sandbox workspace-write` | `--sandbox read-only` |
3168
+ | `claude` | `claude -p --add-dir <repo>` | `--permission-mode acceptEdits` | `--permission-mode plan` |
3169
+ | `gemini` | `gemini -p` in `<repo>` | `--approval-mode auto_edit` | `--approval-mode plan` |
3170
+
3171
+ **Which of the three it launches:** `--worker-agent` if you pass it, otherwise **whatever agent this
3172
+ session is** (detected from the process the agent anchored to — which finds nothing in a plain tab),
3173
+ otherwise `~/.remits-cli/config.json`'s `agent` (set it with `remits-cli config set --agent NAME`),
3174
+ otherwise `claude`. **It prints which it chose and why on startup**, because in the intended
3175
+ plain-tab setup the choice comes from a config file you may have set months ago. So running `agent serve` inside a Codex tab gives you Codex workers
3176
+ without a flag, and the label the operator sees (`codex@repo`) is resolved the same way — the label
3177
+ and the worker are one answer, not two.
3178
+
3179
+ The brief always arrives on **stdin**, never in argv — it is a page of prose and argv has a hard
3180
+ length limit, so an argv brief would fail on exactly the detailed tickets that most need the detail.
3181
+ The brief itself is generated by the platform, so all three worker types are told the same thing.
3182
+
3183
+ **Following a run.** `remits-cli start`'s control center lists every worker; **Follow live** streams
3184
+ that run's transcript into the page, rendering commands with their exit codes, file edits, and the
3185
+ agent's own messages as distinct things. It keeps working after the worker exits — a finished run is
3186
+ usually the one worth reading. For a terminal instead, each worker prints a `tail -f` for its log in
3187
+ `~/.remits-cli/workers/`.
3188
+
3189
+ **There is no terminal to attach to, by design.** A worker is spawned with pipes and runs
3190
+ non-interactively (`codex exec`, `claude -p`), so there is no tty and no prompt to type at — the
3191
+ whole point is that it needs no supervision. Following the transcript is the way to watch, and it is
3192
+ strictly better than a terminal would be: the output is structured, so it can be read as events
3193
+ rather than scraped back out of ANSI text.
3194
+
3195
+ **No worker ever commits.** The brief forbids `git commit`/`git push` and nothing in the supervisor
3196
+ runs git — a worker leaves its changes in the working tree and says so on the ticket, for a human to
3197
+ review.
2801
3198
 
2802
3199
  ### Resolving which agent a command means
2803
3200
 
@@ -2812,7 +3209,22 @@ usually fixed in the platform repo above it), then the ticket's own account, the
2812
3209
  `PLATFORM`/`PRODUCT` ancestors — and takes the first account with an available agent. Among those it
2813
3210
  prefers an **idle** agent, then the one that has waited longest, so work spreads across your tabs
2814
3211
  instead of piling onto whichever one most recently ran a command. A `paused` agent stays visible and
2815
- is never routed to.
3212
+ is never routed to, and so is one **at capacity** — those are different facts and stay separate:
3213
+ `paused` means a human stopped this session, at-capacity means its workers are all busy.
3214
+
3215
+ ### Why a routed ticket might not have started
3216
+
3217
+ In order of likelihood:
3218
+
3219
+ 1. **The session registered but never served.** `agent register` starts nothing. `agent workers`
3220
+ showing none while a ticket is routed here is this.
3221
+ 2. **At capacity.** Check `agent workers`; the ticket starts when one finishes.
3222
+ 3. **Another session is running it.** A claim held by a different agent blocks it until that claim is
3223
+ dropped or expires.
3224
+ 4. **No local checkout.** The worker still starts, and its brief tells it to locate the repo rather
3225
+ than guess — but if the account genuinely is not on this machine it will say so and stop.
3226
+ 5. **It failed twice already** and was released back to the queue. The transcripts in
3227
+ `~/.remits-cli/workers/` say why.
2816
3228
 
2817
3229
  ## Background Service and Control Center
2818
3230
 
@@ -2926,18 +3338,39 @@ Reading rules:
2926
3338
  remits-cli auth [--base-url URL] [--account-id ID] [--data-mode test|prod]
2927
3339
  remits-cli sessions [list|remove] [--account-id ID]
2928
3340
  remits-cli config [set] [--agent claude|codex|gemini]
2929
- remits-cli agent register [--label NAME] [--data-mode test|prod] [--account-id ID]
3341
+ remits-cli agent serve [--worker-agent claude|codex|gemini] [--max-concurrent N] [--mode edit|investigate] [--label NAME] [--data-mode test|prod]
3342
+ remits-cli agent workers [--json]
3343
+ remits-cli agent register [--label NAME] [--data-mode test|prod] [--account-id ID] [--max-concurrent N]
2930
3344
  remits-cli agent work [--wait SECONDS] [--json]
2931
3345
  remits-cli agent status [--state idle|working|paused] [--ticket ID] [--activity "..."] [--step "..."]
2932
3346
  remits-cli agent list [--account-id ID] [--json]
3347
+ remits-cli agent map [--account-ids 1,4] [--json] # who is EDITING which repository, from which checkout/branch/staging lane
2933
3348
  remits-cli agent release
3349
+ remits-cli ticket read|accept|status|progress|complete|release|reopen|assign|planning --ticket ID [--status S] [--resolution "..."] [--summary "..."] [--category C] [--assignee EMAIL] [--workstream VALUE] [--planned-in VALUE] [--board-stage VALUE] [--rank N] [--size VALUE] [--blocked-by VALUE] [--notes "..."]
3350
+ remits-cli ticket lease|unlease|force-unlease --ticket ID [--reason "..."] # force-unlease breaks SOMEBODY ELSE'S lease; operator only
3351
+ remits-cli ticket where --ticket ID # WHERE this work is: repo account, checkout, branch, staging lane, live lease + holder's location, claim, your phase
3352
+ remits-cli ticket ask --ticket ID --question "..." [--context "..."] [--to WHO] # park on a human decision
3353
+ remits-cli ticket answer --ticket ID --message "..." [--route false] # answer it (alias: reply); re-routes by default
3354
+ remits-cli ticket message --ticket ID --message "..." [--to a@x,b@y] [--subject "..."] [--channel email] # PUBLIC — the requester reads it
3355
+ remits-cli ticket note --ticket ID --message "..." # INTERNAL — the next worker and a reviewer read it
3356
+ remits-cli ticket deliver --ticket ID --channel email --to a@x [--template T] [--subject "..."] [--idempotency-key K] # ask for it to be SENT
3357
+ remits-cli ticket deliveries --ticket ID [--channel email] # what is queued to go out, and what already went
3358
+ remits-cli ticket delivered --ticket ID --delivery-id ID | ticket delivery-failed --ticket ID --delivery-id ID --reason "..."
3359
+ remits-cli ticket tag --ticket ID --tags a,b # make a cluster of near-identical tickets visible as one
3360
+ remits-cli ticket artifact --ticket ID --type TYPE --label "..." [--url U | --content "..."]
3361
+ remits-cli ticket participant --ticket ID --email E [--role watcher|requester|agent]
3362
+ remits-cli ticket field --ticket ID --key K --value V # the ORGANIZATION's own field, outside the planning slots
3363
+ remits-cli ticket reclaim [--ticket ID | --account-id ID] [--stale-hours 24] [--apply] # OPERATOR: take back an agent's abandoned ticket
3364
+ remits-cli ticket queue --account-id ID [--status ...] [--unrouted] [--unassigned] [--awaiting-response] [--workstream W] [--board-stage S] [--planned-in P] [--search "..."] [--sort-by ...] [--json]
3365
+ remits-cli ticket create --account-id ID --subject "..." --type defect|question|task|incident|enhancement [--priority P] [--description "..."] [--tags a,b] [--workstream W] [--affected-component C] [--implementation-account-id ID] [--reference-id KEY]
2934
3366
  remits-cli start [--foreground true] [--port 8787]
2935
3367
  remits-cli stop
2936
3368
  remits-cli status [--base-url URL] [--account-id ID] [--data-mode test|prod] [--json]
2937
3369
  remits-cli whoami [--base-url URL] [--account-id ID] [--data-mode test|prod] [--json]
2938
3370
  remits-cli listen [stop|status] [--foreground true] # compatibility alias
2939
3371
  remits-cli data-mode [set test|prod]
2940
- remits-cli components stage [--branch <name>] [--data-mode test|prod] [--json|--verbose]
3372
+ remits-cli components stage [--branch <name>] [--workspace <name>] [--changed-only] [--data-mode test|prod] [--json|--verbose]
3373
+ remits-cli workspace [show | use <name> | use --auto | clear]
2941
3374
  remits-cli components status [--branch <name>] [--component-type <type>] [--component-id <id>] [--json|--verbose]
2942
3375
  remits-cli components clear [--branch <name>] [--component-type <type>] [--component-id <id>] [--all] [--json|--verbose] # id alone scopes to one component when unambiguous (ids are type-local; add --component-type if the same id is staged in multiple families); no filter clears the whole branch scope; --all forces the full wipe
2943
3376
  remits-cli components sync [--branch <name>] [--data-mode test|prod] [--force-tombstones] [--dry-run] [--summary] [--changed-only [--changed-since <ref>]] # gated; on trunk = full repo->DB reconcile, on a variant branch = ComponentVariant overlays only