Skip to content
Toolkit

006-collaboration — routine prompt

The prompt block below is this track's live driver: the CS-Hourly routine reads ROADMAP's front track and follows that track's ROUTINE.md, so this file is the prompt and edits here take effect on the next firing without touching the trigger.

It inherits 008's protocol wholesale, which was 007's, which was 005's, 004's, 003's and 002's — batch loop, atomic claim refs, read / verify / output budgets, worktree rule, track handoff. Each was earned by a recorded failure and is not re-derived here. What changes is the claim namespace (claim/006-*), the read budget's file, the scoreboard, the WORK shapes — 006's six phases — and one addition this track earns on its own: two browser contexts, always.


Advance collaboration (006) by a BATCH of items, then stop.

BATCH LOOP: repeat {claim → build → verify → PR → merge → update
SESSION.md} item by item — one item per PR (revertible slices), each fully
merged before the next is claimed. Continue until the FIRST of:
- 4 items landed this run;
- the next item is a phase-scale block (a whole phase, one slice per PR
  notwithstanding) — do its first shippable slice as one item, then stop;
- the next item is blocked → one line in SESSION.md, stop;
- no unclaimed item remains, or remaining context is too small to land
  another item cleanly (never start what you cannot merge).
Read budgets are paid ONCE per run; between items re-read nothing — only
`git fetch` + the claim check for the next item.

READ BUDGET (hard): read .station/jobs/006-collaboration/SESSION.md
from the top through the end of "Next", once per run, and stop there. Open
the charter, the product gap assessment, 001's plans/05-collaboration.md or
an ADR only when the claimed item names it. Trust SESSION.md's scoreboard
line; re-run a gate only after a diff that moves it. Re-deriving settled
context is the run's largest cost — spend it on the diff.

CI POLICY (settled — spend zero words on it): GitHub Actions here is
noise; the merge gate is local `npm run verify` exit 0, plus
`cd apps/api && go vet ./... && go test ./...` only if apps/api changed.
Green locally → merge the PR. Never re-run, mention, or "fix" Actions.
Canonical: ROADMAP.md "Standing policy".

CLAIM, THEN BUILD (002's protocol — the open-PR gate alone raced 8 times):
1. `git fetch origin` · list open PRs · `git ls-remote origin 'refs/heads/claim/*'`.
   - An open 006 PR exists → resume and land THAT PR as the batch's first
     item, then continue the loop.
   - Else take the top item under "Next" whose `claim/006-<item-slug>` ref
     is absent OR stale. Ref deletion returns 403 in the remote
     environment, so claim refs accumulate: a claim ref with no open PR
     and no branch commit newer than 3 hours is stale — treat it as free
     and re-claim over it. A slug SESSION.md's Completed already records
     is done, not in flight.
2. Claim atomically BEFORE writing any code:
     git push origin origin/main:refs/heads/claim/006-<item-slug>
   Rejected push = claimed between your list and your push → return to 1.
   Only a successful push is a claim; a SESSION.md line is not.
3. When your PR merges, attempt to delete branch and claim ref once; a
   403 is expected there, not a failure — move on.
Take ADR numbers only after `git fetch`, from origin/main's docs/decisions/.

WORK: fan out where the item is an enumeration, solo where it is not.
- Phase 00 mints the canonical channel helper AND the realtime ledger with
  its gate BEFORE any publisher lands, for 004/007/008's reason: a
  scoreboard minted after the work measures nothing — and here the helper
  is load bearing, because the channel key is the only thing separating
  tenants on a shared bus. Both existing call sites move onto it in the
  same slice (handlers/realtime.go's subscribe, internal_notifications'
  publish). One ledger row per surface this track adds, all `unwired`,
  naming channel, publisher, consumer and isolation test.
- Phase 01 is measurement, not code: its deliverable is
  reports/TRANSPORT-MEASUREMENT.md with numbers and a recommendation. A
  recommendation to DEFER live cursors is a passing outcome and lands as
  the ledger's `deferred-by-measurement` row — never as a silent omission
  and never as an excuse to build them anyway.
- Phases 02–05 each add ONE publisher and ONE consumer, keyed through the
  helper, with its ledger row flipping in the same commit that adds the
  reader. Presence is ephemeral — Redis when configured, in-process
  otherwise, NEVER the database. Comments take the next free migration
  number with its .down.sql and route notifications through the EXISTING
  internal-notifications path, never a new one. The activity feed
  assembles what is already recorded and adds no logging system.
- CROSS-WORKSPACE ISOLATION IS A SECURITY TEST, not a feature assertion:
  an event published to workspace A is never delivered to a subscriber of
  workspace B. It runs at Go and UI level, it is never skipped, and its
  evidence lives in evidence/isolation-test.md so it is findable without
  reading a feature report.
- TWO BROWSER CONTEXTS, ALWAYS. A collaboration feature proved with one
  context is not proved — its failures are timing-dependent and invisible
  in a single-session test. Live specs assert a database read, not
  rendered text. Redis-down degraded mode is proved, not assumed.
- The overview's three open questions — AI-agent members, document version
  history, backups — are OWNER DECISIONS (charter Blockers 1–3), as is
  whether comments are plan-gated (Blocker 4). Build every phase around
  them; a phase that starts answering one has left the charter.
- A new or widened gate is watched FAILING once on a deliberately broken
  input, and the run that widened it records that in evidence/.
- TRACK HANDOFF: when every charter phase is closed and verified, write
  reports/CLOSE.md, then the next run's single item is to charter 009 —
  URL lifecycle — from ROADMAP's table under docs/guides/workstream.md
  — README, ROUTINE.md (inherit this protocol), SESSION.md —
  scoped from ROADMAP's 009 section and the assessment's §Card view and
  URL lifecycle / §Address; where that section says chartering collects
  owner decisions (the archive domain, subdomain rollout, retention
  windows), the charter names each as a Blocker with options and a
  recommendation — never invents the answer. Then mark 006 DONE on
  ROADMAP, and subsequent runs work the new track. Tracks follow
  ROADMAP's "last stretch" order; when the last one closes, drain
  ROADMAP's "Standing repairs" the same way, then report completion and
  recommend disabling the routine — do not invent scope.
Integrate and verify results yourself; never merge on an agent's word.
Any agent that writes ANYTHING runs in its own `git worktree`, never the
run's tree (an in-tree reviewer destroyed an uncommitted fix on 002); if
worktree tests resolve workspace packages, relink node_modules first — a
symlink into the run's tree reads the wrong files and false-passes.

VERIFY ONCE: while iterating, run only the touched tests
(`npx vitest run <files>`, `go test ./internal/<pkg>/...`) or the one gate
the item moves. Run `npm run verify` exactly once, when the diff is final,
immediately before the PR, plus `go vet ./... && go test ./...` in apps/api
if apps/api changed; if it fails, fix and re-run — never as a baseline,
progress check, or "before and after".

RULES THAT STAND: migrations at the next free number with .down.sql,
applied manually, never renumbered; handler → repository → database
layering, no business logic in handlers; APIResponse envelope; breaking
API changes under /api/v2/, never in place; frontend uses Studio
primitives and tokens only — nothing new in components/ui, no raw
colours; product vocabulary from docs/GLOSSARY.md; strings behind `t()`
with the key in the `en` bundle (005 closed; a new surface does not
reopen it); Redis is optional (AGENTS.md §4) and every phase works
degraded without it; no adjacent cleanup — one SESSION.md row instead.
Nothing user-visible merges wired to nothing, and a published event with
no consumer is exactly that. Consequential product calls become ADRs,
never silent choices.

OUTPUT BUDGET (hard — the run's meaning is its diff, not its prose):
- New ADR only for a decision that constrains future work, ≤ 120 lines.
- SESSION.md Completed entries ≤ 8 lines, linking the ADR/PR.
- ≤ 3 new open-item rows per run, ≤ 3 lines each; a one-line fix in a
  file already touched is fixed, not recorded.
- PR body ≤ 20 lines. Final report: one line per item landed (item, merge
  commit, scoreboard before → after) + one line for what is next.

Close out per item: SESSION.md Completed entry + refresh "Next"; tick
ROADMAP.md's 006 row only when verification proved it. Conventional
Commit, PR to main, merge on local green.

Shape notes

  • Inherited, not re-derived. The protocol above is 008's, which was 007's, 005's, 004's, 003's and 002's. The history behind each rule lives in 002's ROUTINE.md shape notes; a run that wants to change a rule reads that first, because each one is a fix for something that actually went wrong.
  • The scoreboard is one number from one script, so it cannot drift: wired over surfaces, printed by scripts/check-realtime-parity.mjs and committed beside it. It only rises, and it rises in the commit that adds the publisher and its consumer — never in the commit that adds the row. A deferred-by-measurement row (live cursors, if phase 01 says so) counts as neither: it is the ledger saying so out loud, which is 008's redirect-by-design one concept over.
  • The helper before the publishers, and for a sharper reason than the usual one. On the other tracks a ledger minted late merely measured nothing; here the canonical channel key is the tenant boundary, so a hand-built key is a cross-workspace leak waiting for its first publisher. Phase 00 moves both existing call sites onto the helper while there are only two.
  • The riskiest thing this track can ship is an event delivered to the wrong workspace. That is why isolation is a security test with its own evidence file rather than a line in a feature report. The second riskiest is a feature that works in one browser: collaboration failures are timing-dependent, multi-client, and invisible to a single-context spec — hence two contexts, always, with no exception granted per phase.
  • A deferral is a deliverable. Phase 01 exists so that "add WebSockets" and "ship cursors" are findings rather than defaults. If the measurement says the transport does not carry cursors, recording that is the phase's output, and the ledger row says so where anyone can see it.

Source: .station/jobs/006-collaboration/ROUTINE.md

Library