Skip to content

officers: approve an officer's task from the phone; a hand-off may name its target - #1237

Draft
ZacxDev wants to merge 3 commits into
mainfrom
officer-task-phone-approve
Draft

ZacxDev wants to merge 3 commits into
mainfrom
officer-task-phone-approve

Conversation

@ZacxDev

@ZacxDev ZacxDev commented Dec 4, 2026 •

Copy link
Copy Markdown
Owner

What this changes

An officer's capture task can wait hours on an approval card that its owner only hears about through a notification with no buttons, and only after a chief turn that repeats what the officer already decided. This PR implements two owner decisions that cut the owner's part down to the decision itself.

1. Phone buttons, for officer tasks only

  • An approval card for an agent start on a task that a built-in officer filed (heldDetail.OfficerTask) now reaches the paired phone with exactly two signed buttons: Approve and start and Don't start. Each is an ask_answer per option, confirmed with the phone's step-up key. There is no inline Answer, no Dismiss and no suggestion (new push.Payload.AskOptionsOnly, internal/push/service.go). This uses the existing action ids, so no app change is needed: the app already draws the buttons actions names.
  • The expanded body has four lines: Task #<id>: <title>, On: <where>, Repo: <repo>, and the brief's first line (or the officer's reason for a hand-off). The title is Start an agent? · <officer>. The challenge's confirms carries the same text, so the step-up prompt shows what the tap decides. Tapping the body still opens the whole card.
  • The answer path accepts only those two answers from the device door (approvalSurfaceRefusal → phoneAnswerable, internal/api/dispatch_approval.go). completeHeld treats them as a tap (phoneApprovable, internal/api/host_dispatch.go).
  • Every other approval card still refuses the phone, as in Chief in the agent view, phase 2: succession through a one-tap proposal card, and the view follows the successor #546: the chief's card on an ordinary task, a team's card, a repository card and a clone card.
  • The start stays bound to the hold's hash. A completing call whose brief changed is refused as changed.

2. The officer names the target

  • officer_task_handoff takes optional target (pod/claude-code, or host/<host>/claude with repo) and repo (internal/api/officer_task_handoff.go).

  • The target is checked against what the owner has now (handoffTargetRefusal). The call is refused in plain words, with the owner's current targets listed, for:

    • an unknown host or a host that can't start that runtime
    • a blank, such as host/?/claude
    • a runtime that needs a model (.../opencode, pod/gateway)
    • an unknown pod kind
    • a host target with no repo
    • repo given without a target

    Nothing is picked in the target's place. A refused target records nothing, so neither the task's single hand-off nor the day's 3 is spent.

  • With a target, muster files the held dispatch and the owner's approval card itself, with no chief turn. It does this by calling agent_dispatch as the chief (fileHandoffCard). That runs the same guards: the owner's opt-in, the chief caps, and the 6-cards-an-hour cap.

  • muster writes the brief itself (handoffBrief): which officer handed the task off, and the officer's reason. The brief carries no task text. The task's title and body reach the agent after the brief through the kickoff rule (taskKickoffText), as on every start on a task. The task-text seam ledger enforces this.

  • The card says the officer handed the task off, shows the brief in full, and shows the task's title and body (the body cut at 1,500 characters; the whole task is on the board). The hand-off row is stamped delivered before the card is filed, so the sweep never passes it to the chief. If the card can't be filed (hourly cap, repository not connected, task too long), the hand-off is undone (builtin.DeleteHandoff).

  • muster completes the owner's answer itself, with no chief turn and whether or not the chief is running (completeHandoffCard, called from deliverAnswer in internal/api/attention_delivery.go). It calls agent_dispatch again as the chief, with the arguments rebuilt from the hold and the task. That means completeHeld judges the stored rows exactly as it would for the chief's own call: single use, hash-bound, every guard of a start. "Change repo" and the clone card work the same way. "Don't start" starts nothing and leaves the task on the board.

  • Approving a changed task is refused. The card binds the task's title and body with a hash (handoffCard.TaskHash). If either changed after the card was filed, Approve and start is refused on every door before anything is recorded, and the card stays open (handoffCardRefusal). A change that lands between the answer and the start is refused when muster completes the answer (completeHandoffCard).

  • With no target, the hand-off behaves as before (a chief turn).

  • officerPushDispatchCard is a new decision row in officerPushes. The push ledger records the new call sites (officerCardFiled and dispatchCardFiled).

Docs

  • docs/officers-builtin.md: new sections "Naming the target: a card with no chief turn" and "Approving an officer's task from the phone".
  • docs/push.md: payload v2, and the officer table.
  • docs/chief.md: the approval card's one exception.
  • docs/officers.md: the tool row.
  • docs/schema.md: what chief_turn_at means for a target hand-off.
  • The officer kickoff sentence, with its golden file and test.

How it was tested

Local runs, each once and at low priority, against a throwaway Postgres (MUSTER_TEST_REQUIRE_DB=1):

  • the 9 new tests in internal/api/officer_card_pg_test.go and TestAnOptionsOnlyAskOffersItsOptionsAlone in internal/push;
  • the existing tests of every touched area, 172 tests, all passing: dispatch_approval*, officer_task_handoff_pg_test.go, team_dispatch*, device_actions*, stepup_gate_test.go, officer_push*, host_dispatch*, attention_delivery*, hold_lapse*, clone_choice* and the succession ledger;
  • go test ./internal/push/ ./internal/officers/;
  • tests/leakscan.py (clean) and tests/features_config_test.py (OK).

The whole suite, e2e and the other gates are CI's.

Red/green matrix

On origin/main (d6bc8b1) the new test files do not compile: the tool's target/repo, heldDetail.Handoff, AskOptionsOnly and the new helpers don't exist there. That makes a compile failure the only red main can show. To show behavioural red, each new test was also run against a mutant that puts back main's behaviour for exactly one piece. M0 is the unmutated tree, and every test in it was green. Each mutant was applied in place, run once and reverted, and a checksum of the tree was compared before and after.

test red under green at HEAD
TestAnOfficersTaskCardsPushHasItsTwoButtons (two buttons on an officer card; control: no buttons on an ordinary card) M1: the officer card is pushed as a proposal (main) ✅
TestAPhoneApprovesOnlyAnOfficersTaskCard (device approve of an officer card starts it; device approve of a non-officer card refused; device Change repo refused) M2: the answer path refuses the phone (main, #546); M3: completeHeld refuses a device answer (main) ✅
TestAPhoneApprovalOfAChangedBriefIsRefused (changed brief refused after a phone approve; a changed hand-off task's phone approve refused with the card left open; control: an unchanged one starts) M2, M3, M4 (no stale-brief check), M5 (target ignored, i.e. main) ✅
TestAPhonesDontStartLeavesTheOfficersTaskOnTheBoard (device Don't start, on the chief's card and on a hand-off card; task stays open; no chief turn) M2, M3, M5, M6 (no delivery intercept), M7 (decline not special-cased) ✅
TestAHandOffWithATargetFilesTheCardWithNoChiefTurn (pod and host: card filed directly, no chief turn, an in-app tap starts it with no chief turn; the spawned agent gets the brief and then the task) M5, M6 ✅
TestAHandOffTaskChangedAfterTheAnswerIsNotStarted (task edited between the recorded answer and muster's completion: not started; control: unchanged, started) M3, M5, M11 (no task check at completion) ✅
TestAHandOffToATargetTheOwnerLacksIsRefused (unknown, offline, needs-model, blank, no-repo and unknown-pod targets refused; nothing recorded; control: a real target then works) M5, M9 (target check skipped) ✅
TestNoPathStartsAHandedOffTaskWithoutTheOwnersApproval (always-card rule: the chief completing the request, a typed owner_asked, completing the open card: nothing starts; the approval starts exactly one; a capped card undoes the hand-off) M5, M8 (an open card accepted: killed by the owner-door check that backs the waiting check), M10 (no undo) ✅
TestAHandOffWithoutATargetStillStartsAChiefTurn invariant guard: green on main's behaviour too (no mutant reddens it); kept to pin the unchanged path ✅
TestAnOptionsOnlyAskOffersItsOptionsAlone (push package: two buttons only, also after the 4 KiB refit; control: an ordinary ask keeps Answer and Dismiss) P1 (AskOptionsOnly ignored), P2 (refit puts the buttons back) ✅

What I could not do, and decisions to check

  • No live phone test. The Android app's handling was read from its source (AskPush.buttons() draws exactly what actions lists), not exercised on a device.
  • The binding on the phone is the hold's hash plus the task-hash check. The phone's signature covers the answer and the ask, not the brief's hash, because that would need a new action id and an app release. The brief is shown in full on the card. The notification shows its first line.
  • When a hand-off card's 24-hour hold lapses, the lapse note goes to the chief's chat, as it does for every dispatch card.
  • A team officer's target hand-off files a team card (browser only, operator, fresh sign-in). This path is not tested separately.
  • If muster can't make a start when completing a hand-off card (a cap reached since filing, the opt-in withdrawn), the card's delivery is settled unconfirmed and the reason is shown to the owner. The officer is not told.

Checklist

  • Tests cover the change, and a new test was seen to fail before the fix (mutation matrix above; main itself does not compile them).
  • make leakscan passes (ran tests/leakscan.py).
  • Docs are updated in this pull request (no new environment variable).
  • The branch is up to date with main (main merged in at 217a792).

CI round 1 failed one test, TestEveryTaskTextReaderIsClassifiedAndEveryKickoffIsFenced: the first version copied the task text into the brief. That is fixed in 2469922 as described above, and the mutation battery was re-run after the fix.

🤖 Generated with Claude Code

ZacxDev and others added 3 commits December 4, 2026 08:39
…me its target

Two changes take the owner out of every step of an officer's hand-off but
the decision itself.

Phone buttons, officer tasks only. The approval card of an agent start on
a task a built-in officer filed is pushed to the paired phone with exactly
two signed buttons, Approve and start and Don't start (ask_answer per
option; no inline answer, no Dismiss: push.Payload.AskOptionsOnly), and an
expanded body naming the task, where it runs, the repository and the
brief's first line. The answer path takes exactly those two answers from
the device door (approvalSurfaceRefusal, phoneAnswerable) and completeHeld
takes them as a tap (phoneApprovable); every other approval card keeps
refusing the phone. The start stays bound to the hold's hash.

The officer names the target. officer_task_handoff takes optional target
(pod/claude-code, or host/<host>/claude with repo) and repo, checked against
the owner's targets now (unknown or unavailable host, a blank, a runtime
that needs a model: refused, nothing picked in its place, nothing recorded).
With a target, muster files the held dispatch and the owner's card itself
(agent_dispatch as the chief, a brief built from the task, no chief turn),
and completes the owner's answer from its delivery (completeHandoffCard):
agent_dispatch again with the arguments rebuilt from the hold, so every
guard of a start runs. An approval of a hand-off card whose task changed
since is refused on every door before it is recorded. A card muster cannot
file undoes the hand-off. Without a target the chief's turn is unchanged.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
… task

The task-text seam ledger (task_kickoff_ledger_test.go) caught handoffBrief
copying the task's title and body into the agent's brief, outside the
kickoff rule that every start on a task goes through. The brief is now
muster's words and the officer's one line only; the task's title and text
reach the agent after it through taskKickoffText, as on every start.

The hand-off card shows the task's title and text instead (the first 1,500
characters; the whole task is on the board) and binds them with a hash of
the task (handoffCard.TaskHash): an approval of a card whose task changed
since is refused on every door before it is recorded, and the completion
refuses a change that lands between the answer and the start. Both readers
are ledgered as never reaching an agent.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant