Tell operators from participants on every connect request

Merged
JE
2mo ago
+537-82

Ports basecamp-local-agent-connector#57 to basecamp connect.

Opening a project to its members is how a colleague's question reaches the agent at all. But a project's membership is not a list of people whose word should authorize a merge or a deploy. So each "type":"request" line now carries role, with the key and values the local connector emits:

  • "operator": the operator, or someone named with --allow.
  • "participant": a member admitted only by --trust project.

What changes

  • --allow combines with --trust project. connect setup --trust project --allow 111 names operators and opens the agent to the project's members as participants. connect.json keeps trust.mode: "project" with allowlist_ids, and Policy.Validate now accepts that pairing with the same per-id checks as allowlist mode. --allow on its own still implies allowlist. A run that passes --allow replaces the list, a run that passes none keeps it, and --trust operator clears it. --trust operator --allow is refused.
  • Participants trigger by mention, by comment on a followed thread, and by completion. A member's *.completed is admitted as context, with no acknowledgement and role: participant, the same as a followed-thread comment. Assignments were already the operator's alone in every mode, and they still are.
  • The role is settled on everyone whose trust admitted the event. It's the lesser of the performer's role and, for mentioned and subscribed, the author's. So when the operator moves a member's to-do in, the request is still a participant's, and the other way round.
  • Old records fail closed. A record admitted without a role (before this build, inside the one-minute handoff grace), or with an unknown value, is handed off as participant.
  • The skill gets the participant policy, tightened since #57. A participant's request is a request, not authority. It never leads the agent to open a pull request or push a branch for one. Anything irreversible or outward-facing waits for an operator. The agent asks the operator privately, in a ping from the agent's account (POST /circles.json find-or-create, then a line in it), and tells the participant only that it's been passed on. The go-ahead is still an operator's @mention of the agent on the thread, since the connector doesn't watch pings. A line without role gets the participant rules. Setup's phrase table and trust explanation cover the combination. The same wording is in basecamp-local-agent-connector#58.

Not ported

  • --allow-domain. It's email-keyed, and Basecamp masks colleagues' addresses for non-admins, so the domain rule matches nobody unless the operator is an account admin. basecamp connect keys all trust on Person id, and project trust covers the use.
  • --allow-assignments-from-authorized: ported separately, in #847.
  • The local connector's STDERR ignored … by a participant line. A member's assignment is already logged as a "type":"event" line with reason assignment_not_operator, Event lines carry pointers, never names, by design.

Tests

Each of these fails without the change:

  • TestOperatorsAndParticipants (admission): the roles, the combination, a member's completion as participant context, and author-versus-performer.
  • TestTheLineSaysWhoseRequestItIs (handoff): the operator value, the participant value, a missing role, and an unknown role.
  • TestApplyTrust/allow_names_operators_alongside_project_trust and TestConnectSetupNamesOperatorsAlongsideProjectTrust (setup).

The two assignment subtests are regression guards that also pass on main's behavior. make check is green on linux. On darwin, golangci-lint reports two existing issues in driver/proctime_darwin.go, which this PR doesn't touch.


Summary by cubic

Opening a project to its members lets a colleague's question reach the agent, but membership shouldn't authorize merges or deploys. Each request line now carries role — "operator" for the operator and anyone named with --allow, "participant" for a member admitted only by --trust project.

What changes

  • --allow now works with --trust project to name operators beside the project's members; alone it implies allowlist, --trust operator --allow is refused, a run with --allow replaces the list, one without keeps it, and --trust operator clears it.
  • Participants reach the agent by mention, by comment on a followed thread, and by completing something the agent has a stake in — completion is context, not a request, so it's never acknowledged. Assignments stay the operator's alone.
  • The role is the lesser of the performer's and, for mentioned and subscribed, the author's: words a participant wrote stay a participant's request whoever brings them in, and the requester the line names is the person who wrote them.
  • Records admitted without a role, or with a value this build doesn't know, hand off as participant.
  • A participant's request is a request, not authority: it never opens a pull request or pushes a branch (for those, the agent commits locally and asks), and it can't choose a local repo — a mapping in a project document, which any member may edit, counts only when it agrees with the mapping the operator confirmed. Anything irreversible or outward-facing waits for an operator's word: the agent says in the thread what's ready, names the work (the repo, branch and commit, or the action itself), and mentions the operator. Only a role operator, mentioned request whose content is "go" approves — an operator's reply without the mention is context, not the word — and a member-editable AGENTS.md shapes the work without lifting any of these rules. A line without role gets the participant rules.

Not ported: --allow-domain (Basecamp masks colleagues' addresses for non-admins) and --allow-assignments-from-authorized (assignments remain the operator's alone in every mode).