An app profile writes drafts and asks HEY to send, which waits for you

Merged
JE
14d ago
+1528-43

Context

  • On a profile whose endpoint is the HEY app (#646), every write is refused: an agent can read the Imbox, the Screener and the drafts, but can't screen a sender, write a draft or ask for one to go.
  • The door serves screener.decide, draft.write, draft.reply and message.send; a send never goes on its own, it waits in HEY's window for the person to press Send.
  • Second of three: reads were #646; this is the writes and the wait; setup and the skill come after. Stacked on #646 (base app-endpoint).

Change

  • Under HEY_EXPERIMENTAL=app, on an app profile:
  • hey screener approve|deny <sender id or address> runs screener.decide. An address is looked up in the app's own Screener, waiting and decided, any case; nobody there is exit 2. The answer is the server's shape (a list of the decided) with meta.id_kind: "sender".
  • hey compose --draft --to --subject -m runs draft.write; hey reply <thread> --draft -m runs draft.reply (<thread> is topic_id from hey box view imbox). Both answer the draft under hey draft list's field names, say nothing has been sent, and suggest hey -P <profile> draft send <id> where HEY would send it.
  • hey draft send <id> runs message.send: it answers meta.status: "pending" with the confirmation and snapshot, says "Waiting in HEY for the person to press Send: nothing has been sent", and exits 9. Any other answer is exit 7, never read as a send.
  • compose and reply without --draft, bulk-reply send and forward are refused before anything happens (exit 1), pointing at --draft and then hey draft send.
  • Flags the door has no field for are refused, not dropped: --cc, --bcc, --attach, --message-html, --from, --no-name-tag and --thread-id on compose; --to, --cc, --bcc, --replace-recipients, --from, --attach, --message-html and --dry-run on reply; --box, --seen, --spam and more than one sender on the Screener.
  • The door's write refusals say what to do: not_an_address, not_saved, not_a_sender, disabled and an id it does not hold (with the ids it would take); saved_not_listed and session_ended are worded as "may have been done", never as refused.
  • hey help exit-codes lists 9 under the gate only.
  • On every profile: hey screener approve|deny also take a sender's email address, looked up among the clearances waiting and then those decided (help, docs/cli.md and the skill say so).
  • Where this follows #646 over the routing design (routing-design.md, 11-11): the switch is the profile's endpoint: app under HEY_EXPERIMENTAL=app, not --local/HEY_LOCAL under HEY_EXPERIMENTAL=local; envelopes name meta.endpoint: "app", not meta.transport: "local"; the Screener's ids are named by meta.id_kind: "sender", not a contact_id/clearance_id field; the refusal points at --draft in the app's words, not "local mode"; a breadcrumb names -P <profile> where #640's named --socket.

Verification

  • internal/cmd/app_writes_test.go (21 tests) and four in screener_test.go, against #646's fake door and a server that fails the test if reached.
  • Each behaviour red first against #646's head (cfd5879), 18 of 21 new app tests and all 4 server ones; the 3 flag-refusal tests already held there, since #646 refuses every write, and stay as guards.
  • TestAppWritesNeverReachHEYsServer sets HEY_TOKEN, so a fall-through would reach the server, and runs every verb above, answered and refused by the app; shown red by removing draft send's app branch (2 requests reached the server).
  • make check green; .surface unchanged; GOOS=darwin, windows, linux build.
  • A fresh review in its own context: no High; two Mediums and four Lows. Fixed in the second commit, each red first: an id the app doesn't hold is exit 2 (was 1); a capped address lookup is exit 7, not "not found"; a send cut off by the session's end says nothing has been sent without you; a disabled send with no arg hints the draft. Declined: the Markdown and --ids-only points below. A second review of those fixes found one Medium and one Low in them (the draft named on every send refusal; the cap read from the cursor), fixed in the third commit, each red first; a third review of that fix found no High or Medium.
  • Bot review (cubic, Copilot): 9 threads, 6 fixed (one already by 6724516), 3 declined, 1 in part, with reasons in their threads; fixes in 9154df1, five tests red first.
  • Unrun: a check against a running HEY Linux app with its door open.

Alternatives

  • Turning a send into a draft quietly on the app: rejected, the word send would mean two things.
  • Several senders per screening on the app: refused instead; the door decides one at a time, and a loop would need its own partial-failure report.
  • compose --thread-id --draft mapped to draft.reply: refused, pointing at hey reply <thread> --draft, so a reply has one route.
  • The server's address lookup reads the waiting list and, only if needed, the decided list, each up to 100 pages; an address past that is not found.
  • Breadcrumbs on a server profile keep no -P: unchanged here; only the app's carry it, since an app draft id run on a server profile could name a draft HEY would send at once.
  • -m reaches the door as written, though it is Markdown on the server: the door takes plain text, and converting through htmlutil.ToText drops every link's URL, changing the words the person is asked to send. Written as is, they read every character in HEY's window before pressing Send.
  • --ids-only on a pending send prints the confirmation id, which may be a number: kept, as it is the one id a pending answer has; exit 9 and the stderr line say it waits.
  • A pending send's envelope is ok: true with meta.status: "pending" and exit 9, not an error envelope: nothing failed, and a script tells it apart by the exit code or meta.status, never by ok alone.