Repository navigation
harness: owner commands for approval requests - #7208
Conversation
The approval card's buttons send /allow <id>, /reject <id> and /ban <id>, which the head answered as unknown commands. The Tlon adapter, which owns the requests and the policy, now reads these in every message before admission, as OpenClaw's plugin handles them before dispatch, so the head never sees one and no turn starts. Only the owner's command acts, where their other messages are admitted, and it is answered there with OpenClaw's texts. Anyone else's is dropped: no effect, no reply and no request. The id is found as OpenClaw finds it: exactly, else as the one id it begins, else with none the newest request, after expired requests are removed. Allow saves the request's place grant through +configure, so cutoffs, cancellation, closing requests and accepting a pending DM invitation behave as for a save from settings. Reject closes the request and declines a DM request's pending invitation. Ban asks %chat for the native block and, once it is acknowledged, closes all the ship's requests, takes back its DM grant and declines its pending invitation; a refused block leaves the request open and tells the owner, as OpenClaw does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Replace the sentence saying the card's buttons get "Unknown command" with what /allow, /reject and /ban do: who may use them and where, how the id is matched, their effect on a DM and on a channel request, the replies, the audit notes, and that another ship's command is dropped unanswered. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The owner's first post in the DM the bot's card opened makes %chat add a join message with the id [our now] in the same event (+di-post-notice). A reply to an approval command stamped now took that id and was dropped from the bot's own copy of the DM. Stamp replies from now plus one. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Two live scripts, with the bot and two ships taking turns as its owner and as the ship that asks: the owner's tap on Allow gives a DM request DM access, accepts the invitation and answers the next message; a typed /allow gives a channel request that channel only; /reject typed in the channel is answered there and leaves the ship unanswered; another ship's command, with access or without, changes nothing and gets no reply; no command text reaches the model. They run in the three-ship block beside the shared channel script, apart from each other because of the denial limit. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The branch below reports a rejected card, decline or full-queue notice through telemetry; the approval command reply now does too. The comment on the expiry before an id is looked up now says why it is needed after every event expires what is due: +abet runs that expiry only after the event. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…nnel check The branch below declines a first DM the denial limit drops. The guest DMs the bot minutes after asking in the channel, so its invitation is declined at once and the check never saw it pending. Wait for the guest's own copy of the DM instead, and check the invitation is neither accepted nor left pending. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ll-through The guest's command in a channel where it has no access was sent after its DM request, so a command that fell through to the normal path hit the five-minute denial limit and opened nothing either way. It now comes first, while the guest still has its turn under the limit, and the check asserts no request opened and no attempt recorded. With the interception removed, the check fails on the request it opens. The checks that the owner's command stays out of the model now say what they check: it starts no turn and is not in the owner's next turn. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A command is not passed to the model as a message, but like any channel post it can appear as thread context later. A ship's first DM reaches the hand only as an invitation and is handled as one. The commands need an owner that is a different ship from the bot. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d1d3e3d9c0
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| ?: (blocked:messenger who.approval) (banned who.approval id to) | ||
| :: The ban is carried out once %chat has the block, so a refused block | ||
| :: leaves the request open. | ||
| =/ =wire /approval-ban/(scot %p who.approval)/[id]/(scot %uv (jam to)) | ||
| (emit (block:messenger wire who.approval)) |
There was a problem hiding this comment.
Deduplicate in-flight ban commands
When the owner sends the same /ban twice before the first %chat acknowledgment—for example, by double-tapping Block—both events can observe the ship as unblocked and emit a block poke. %chat installs the first block but rejects the second as already blocked, so the first acknowledgment closes the request and sends success while the second sets the adapter error, records approval-ban-failed, and incorrectly tells the owner that the request remains pending. Track the request as in flight or otherwise coalesce duplicate ban commands so this single-user double-submit produces one outcome.
AGENTS.md reference: AGENTS.md:L218-L223
Useful? React with 👍 / 👎.
…mmands # Conflicts: # packages/harness/docs-refs/tlon.md
…mmands # Conflicts: # packages/harness/docs-refs/tlon.md
patosullivan
left a comment
There was a problem hiding this comment.
The grant itself is narrow and right: /allow adds only the request's DM or channel grant, the cutoffs keep earlier messages out, and for an honestly attributed message every path reaches the owner check before admission. But this is the PR that admits someone, and three things let a request be allowed that the owner did not mean to allow. Reviewed at 1b9b92361f against #7207's branch.
1. Take the commands in the owner's DM only. approval-order reads the author of a channel post from the event, and carry-order trusts it. A DM's author is authenticated by the network. A channel post's author is whatever the channel's host reports, so in a channel hosted by another ship the owner check trusts that host. We already accept that for a turn in such a channel; here it would become a durable grant. The card arrives in the owner's DM and its buttons post there, so nothing is lost by refusing the commands elsewhere.
2. A bare /allow should not pick for the owner. With no id it acts on the newest request. A ship without access controls when its request opens, so it can open one just after the request the owner is reading, and the bare command admits it. The reply names who was allowed, but after the grant. OpenClaw does the same; I'd still refuse a bare /allow when more than one request is open and list them.
3. A stale card's button can act on another ship's request. Ids are reused once a request closes, and the lookup falls back to a unique prefix even for the full id a button sends. So an old card's Allow can match a later request with the same id, or a longer id it prefixes; the description says a stale button gets the unknown-id reply, which holds only while nothing has reused or extended that id. The chance is small (four hex digits, at most 100 open), but it grants access to a ship the owner never saw. Ids that are never reused, or a button that also names the ship and is checked against the request, would close it; buttons should match exactly either way.
4. Two /ban taps disagree. Both see the ship unblocked and both poke %chat; the first ack reports the ban and closes the requests, the second is refused as already blocked, and the owner is then told the ban failed and the request stays pending. The bot's thread has this. Treat a refusal as success when the ship is blocked by then, or hold one ban per ship at a time.
Smaller, not blocking:
- A command inside inline code or a blockquote still runs. For commands that grant access I would not take quoted text as consent, whatever the other slash commands do.
- The non-owner tests cover a DM post and a channel post. A reply, a trusted ship that is not the owner, and a recycled or prefixed id are not pinned.
…mmands # Conflicts: # packages/harness/docs-refs/tlon.md
A channel post's author is whatever the channel's host reports, so a host could post /allow as the owner and get a durable grant. A DM's author is authenticated by the network. In a channel the text of an approval command is now an ordinary message, from anyone. Drops the channel path from +approval-order, and the second expiry in +carry-order, which the event's own expiry already did. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
With several open, /allow, /reject or /ban without an id acted on the newest, which may not be the request the owner meant. It now acts on none and lists the open requests, asking for an id. Unlike OpenClaw. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Ids are reused once a request closes and match by prefix, so a stale card's button could act on another request. The buttons now send /allow <id> ~ship; with a ship, only the exact id of that ship's request matches. A typed command without a ship keeps the prefix match. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Two taps on Block both see the ship unblocked and both poke %chat; the second is refused as already blocked, and the owner was told the ban failed while the request stayed pending. A refused block of a ship that is on %chat's block list by then now takes the success path. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A command shown as inline code, in a code block or quoted is talked about, not given. Only the three approval commands; the other slash commands are read as before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Pushed 1. Owner's DM only. 2. Bare command. Acts only when exactly one request is open. With more it changes nothing and replies with the open requests (id, ship, place), oldest first ( 3. Stale buttons. Buttons now send 4. Double Smaller:
Hoon 69 files and JS 9 scripts pass at this head. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3b8a2e8959
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| =/ who=@p (slav %p i.t.wire) | ||
| =/ id i.t.t.wire | ||
| =/ to ;;(destination:t (cue (slav %uv i.t.t.t.wire))) | ||
| ?~ p.sign (banned who id to) |
There was a problem hiding this comment.
Clear the adapter error after a successful ban retry
If %chat rejects the first block without adding the ship, the failure path sets the adapter error and explicitly tells the owner to retry. When that retry later succeeds, this branch calls banned, but neither path clears error unless the target happened to have a DM grant and configure changes the policy; for a typical pending request with no grant, status therefore continues reporting Messenger rejected a block after the owner has received the successful Blocked confirmation. Clear the operation error once the retry succeeds.
Useful? React with 👍 / 👎.
Ids are reused once a request closes, and the ship alone did not tell a later request of the same ship in another place from the one the card was made for, so a stale card's Allow could grant that other place. The buttons now send /allow <id> <token>, the token a hash of the request's id, ship, place and opening time, recomputed from the stored request and compared exactly. A typed command keeps the short id. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A reload catches up on Activity without the expiry every other event runs first, so an owner command waiting there could allow a request past its 48 hours. The lookup now leaves out every request past its lifetime. It expires nothing itself: an expiry mid catch-up could send a DM decline after an accept the same event already sent. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
+quoted looked for inline code only in prose, so an owner DM whose heading or list item held `/allow c0001` as inline code flattened into the command. It now walks every block and inline, headings, lists and tasks included. The code block test is replaced by one that fails without the check: flattening fences a code block, so a command inside one never parsed as a command anyway. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Follow-up, pushed
Hoon 50 files and JS 5 scripts pass at this head. Three small trade-offs are added to the description. |
patosullivan
left a comment
There was a problem hiding this comment.
All four points are resolved. I'll approve at the renumbered head; reviewed at f3c8946974.
1. Owner's DM only. approval-order takes only a DM post or reply whose other party is a ship, with the author from the message id, which %chat checks against the sending ship. A club, a channel, the bot's own post and a forwarded or cited post can't carry a command.
2. Bare command. One open request acts; several are listed. The count and the lookup read the same live view.
3. Buttons. The token hashes the id with the stored ship, place and opening time, a lookup with a token is exact, and a malformed token becomes part of the id and matches nothing. That closes the stale button, including the same ship asking again in another place.
4. Double /ban. %chat crashes on a block of a ship already blocked, and the refused ack now reads the block list and takes the success path.
Three notes, none blocking:
- The bot's open thread is real. A refused block sets
error. A retry that succeeds reachesbanned, which clears it only when the ship had a DM grant. Otherwise status keeps "Messenger rejected a block" after the owner was told "Blocked". Clearing it inbannedfixes it. - Typed commands. A typed id still falls back to a unique prefix, and a bare command acts on the one live request. Either can land on a request other than the card the owner is reading, once that card's request has closed (expired, answered from another device, DM accepted). The reply names the ship and place, but after the grant. This is OpenClaw's behavior and the description says so, and I'm fine with it. If it ever bites, exact match for a typed id is the small change.
- Tests. A DM reply from a ship that is not the owner isn't pinned. The same owner check covers it in the source.
#7199 is on develop now, so this needs the renumber with the rest of the stack; details on #7193.
…mmands The approval tests this branch added name the hand's state as state-7, its version after the renumbering. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…s out of the model Turn context from develop gives each channel turn the channel's recent posts, so the mention a guest asked with now reaches the model as reference material on its next turn. The script checks that next mention instead. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
A block that %chat refused sets the hand's error. A retry that took left it there unless the ship had a DM grant, so status kept reporting the refusal after the owner was told the ship is blocked. Also pin that a DM reply from a ship that is not the owner carries no command. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Summary
The owner of a Harness bot can now act on an approval request:
/allow,/rejectand/ban, typed or sent by the buttons on the approval card. This is the PR that lets the approval flow admit someone.Stacked on the approval limits PR (TLON-7346), which is stacked on #7194. Review those first; this PR's base is the limits branch.
Linear: TLON-7341.
Changes
/allow <id>. Grants the ship access in the request's place through the normal settings save: a DM grant, or a grant for that one channel. A pending DM invitation is accepted. Noteapproval-allowed./reject <id>. Closes the request and declines a pending DM invitation. Noteapproval-rejected. The ship may ask again./ban <id>. Asks%chatto block the ship. Only after%chatacknowledges: closes all of the ship's requests, removes its DM grant, declines its invitation. Noteapproval-banned. A refused block of a ship that is already on%chat's block list counts as a ban (two taps on Block). If the block is otherwise refused the request stays open, a noteapproval-ban-failedis recorded and the owner is told "Could not block … Request stays pending, try again."/allow <id> 0v…: a hash of the id and the stored request (ship, place, opening time). With a token the id must match exactly and the token must equal the one recomputed from the stored request, otherwise the unknown-id reply. Ids are reused after a request closes, so this keeps a stale card from acting on a later request, also one by the same ship in another place. No saved-state change.now, because%chat's "joined the chat" notice takes the id[our now]when the owner's first DM message is the command.tlon-approval-commands-dm-conformance.mjsandtlon-approval-commands-channel-conformance.mjs.docs-refs/tlon.md./helpin the head does not list these commands.How did I test?
Run on fake ships, by pattern, from
packages/harness, starting from fresh ships.On the final commit (after merging the last limits fixes):
just test-hoon harness-tlon-approval: 2 files pass (13 and 55 tests).One merge earlier (the final merge then brought in a small removal in the limits code, its tests and docs):
just test-hoon 'harness-tlon|harness-upgrade': 48 files pass;just test-js tlon-approval-commands: both scripts pass.Before those merges, by the implementing agent:
just test-js 'tlon-approval-commands|tlon-approval-channel|tlon-denial|tlon-place-grants': 5 scripts pass.The live check that a non-owner's command is dropped was shown to fail when the interception is removed.
After merging harness: limit and expire approval requests #7207's branch (state
%6) and the review changes, at3b8a2e8959, fromjust test --stop:just test-hoon 'harness-tlon|harness-upgrade|harness-peer|harness-hand|harness-browser|harness-schedule|harness-js', 69 files pass (approvals 60, approval 14);UPGRADE_BASE=origin/develop just test-js 'modules|upgrade-conformance|tlon-place-grants-conformance|tlon-permissions-conformance|tlon-denial-conformance|tlon-approval', 9 scripts pass. New Hoon cases: the owner's command in a channel, a command as a DM thread reply, a trusted ship that is not the owner, a bare command with one and with several requests, a button with a recycled id and with an id a longer id extends, a double/ban, and a command in inline code, a blockquote and a code block. The channel script now shows the owner's channel/allowgrants nothing.Not run: the full Hoon and JS suites, the shared bot E2E, tlonbot E2E.
f3c8946974:just test-hoon 'harness-tlon|harness-upgrade', 50 files pass (approvals 65, approval 14);just test-js 'modules|tlon-approval|tlon-denial', 5 scripts pass. Shown to fail without their rule: the stale-button, reload, heading, list, inline-code, blockquote and beside-code-block tests.Reviewed with Codex (
gpt-6.2-sol, high effort): two rounds before the review changes, one on them. That round found three problems, fixed inf310bf4eeb(button token),d40d6b0a92(overdue lookup) andf3c8946974(quoted text in headings and lists).Risks and impact
Accepted trade-offs:
/allow `c1`cannot run as a bare/allow.Rollback plan
Revert the PR.
Screenshots / videos
None.
🤖 Generated with Claude Code