Skip to content

harness: owner commands for approval requests - #7208

Merged
mikolajpp merged 23 commits into
mp/harness-approval-limitsfrom
mp/harness-approval-commands
Nov 27, 2026
Merged

mikolajpp merged 23 commits into
mp/harness-approval-limitsfrom
mp/harness-approval-commands

Conversation

@mikolajpp

@mikolajpp mikolajpp commented Nov 24, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

The owner of a Harness bot can now act on an approval request: /allow, /reject and /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

  • Where the commands are handled. In the Tlon adapter, before admission, so the text never starts a turn and is not passed to the model as a message. This is where OpenClaw handles them.
  • /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. Note approval-allowed.
  • /reject <id>. Closes the request and declines a pending DM invitation. Note approval-rejected. The ship may ask again.
  • /ban <id>. Asks %chat to block the ship. Only after %chat acknowledges: closes all of the ship's requests, removes its DM grant, declines its invitation. Note approval-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 note approval-ban-failed is recorded and the owner is told "Could not block … Request stays pending, try again."
  • Ids. A typed id matches exactly, else as a unique prefix, case-sensitive. With no id the 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. OpenClaw picks the newest; a ship without access could time its request to be that one.
  • Buttons. A card's buttons send a token with the id, /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.
  • Overdue requests. The command lookup ignores a request past its 48 hours, so a command that arrives on a path that has not run expiry yet (catch-up after a load) cannot act on it.
  • Quoted text. A message containing inline code, a code block or a blockquote anywhere, including inside a heading or a list, is not an approval command. Harness's other slash commands are unchanged.
  • Who. The explicit owner, or a sibling moon where sibling moons count as owners. In a DM a command from any other ship is dropped: no change, no reply, no turn, no request. The owner must be a different ship from the bot.
  • Where. Only in the owner's DM with the bot, where the network authenticates the author. A channel post's author is what the channel's host reports, so a command in a channel is not a command: it is an ordinary message. From the owner it reaches the head, which answers "Unknown command. Send /help for the available commands." as for any slash text it does not know; nothing is granted.
  • Reply timing. Replies are stamped one tick after now, because %chat's "joined the chat" notice takes the id [our now] when the owner's first DM message is the command.
  • Tests. Hoon unit and integration tests; two live scripts between three ships, tlon-approval-commands-dm-conformance.mjs and tlon-approval-commands-channel-conformance.mjs.
  • Docs. docs-refs/tlon.md. /help in 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, at 3b8a2e8959, from just 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 /allow grants nothing.

Not run: the full Hoon and JS suites, the shared bot E2E, tlonbot E2E.

  • After the Codex fixes, at 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 in f310bf4eeb (button token), d40d6b0a92 (overdue lookup) and f3c8946974 (quoted text in headings and lists).

Risks and impact

  • Safe to rollback without consulting PR author? Yes. No saved-state change in this PR.
  • Affects important code area:
    • Onboarding
    • State / providers
    • Message sync
    • Channel display
    • Notifications
    • Other: Harness Tlon adapter admission and permissions

Accepted trade-offs:

  • A message with code or a blockquote anywhere is not an approval command, even when the command sits outside the quoted part, so that /allow `c1` cannot run as a bare /allow.
  • A bot that is its own owner cannot use the commands: the adapter handles no message from its own ship.
  • The message that opens a new DM with the bot arrives as an invitation and is handled as one, whatever its text.
  • Command text posted in a channel is an ordinary message there, and can appear as thread context.
  • Request ids are unique only among open requests. A typed id (no token) can therefore match a later request that reused it; a button cannot.
  • If the owner allows a channel request while the bot is out of that channel, the grant is stored and applies when the bot rejoins.
  • If one event both expires a ship's DM request and bans that already blocked ship through another open request, two declines are sent for the one invitation.
  • Two taps on Block produce two success notes and two replies.

Rollback plan

Revert the PR.

Screenshots / videos

None.

🤖 Generated with Claude Code

mikolajpp and others added 9 commits November 24, 2026 13:44
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>
@linear-code

linear-code Bot commented Nov 24, 2026

Copy link
Copy Markdown

TLON-7341

@mikolajpp
mikolajpp marked this pull request as ready for review November 24, 2026 23:51
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-26T05:40:57.859435Z 548c230 New commits
🔒 Security Review ✅ Completed 2026-11-26T05:47:46.456888Z 548c230 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment on lines +2743 to +2747
?: (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))

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 patosullivan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

mikolajpp and others added 6 commits November 25, 2026 05:52
…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>
@mikolajpp

Copy link
Copy Markdown
Collaborator Author

Pushed 3b8a2e8959 (merged up with #7207, state %6). All four points and both smaller ones are changed.

1. Owner's DM only. +approval-order reads only DM posts and DM replies; the channel path is removed, not guarded (121c688a9f). A command in a channel is an ordinary message. From the owner it reaches the head, which answers "Unknown command. Send /help…" as for any slash text it does not know; nothing is granted.

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 (c512ff13db).

3. Stale buttons. Buttons now send /allow <id> ~ship. With a ship the id must match exactly and the request must be that ship's; otherwise the unknown-id reply (3cf4d745db). Ids are still reused, so a typed id without a ship keeps the prefix lookup and can match a later request; the description says so.

4. Double /ban. A refused block of a ship already on %chat's block list takes the success path, which is idempotent (112ef0bf98). This is also the bot's P2 finding.

Smaller:

  • A message with inline code, a code block or a blockquote anywhere is not an approval command (3b8a2e8959). Other slash commands are unchanged.
  • Tests added: the owner's command in a channel, a DM thread reply, a trusted ship that is not the owner, a bare command with one and several requests, a recycled id and an extended id from a button, a double /ban, quoted commands.

Hoon 69 files and JS 9 scripts pass at this head.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

mikolajpp and others added 3 commits November 25, 2026 07:52
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>
@mikolajpp

Copy link
Copy Markdown
Collaborator Author

Follow-up, pushed f3c8946974. A Codex round on the review changes found three problems, now fixed; this corrects my note on point 3 above.

  • Buttons (point 3). Checking the ship was not enough: a later request by the same ship in another place can reuse the id. Buttons now send /allow <id> 0v…, a hash of the id and the stored request (ship, place, opening time), compared exactly (f310bf4eeb). No saved-state change.
  • Overdue requests. Catch-up after a load does not run expiry first, so a queued command could act on a request past its 48 hours. The command lookup now ignores overdue requests (d40d6b0a92).
  • Quoted text. The check skipped headings and lists; it now walks the whole message, and the fenced-code test that passed without its rule is replaced (f3c8946974).

Hoon 50 files and JS 5 scripts pass at this head. Three small trade-offs are added to the description.

@patosullivan patosullivan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 reaches banned, 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 in banned fixes 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.

mikolajpp and others added 3 commits November 26, 2026 00:05
…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>
@mikolajpp
mikolajpp merged commit 1f69c06 into mp/harness-approval-limits Nov 27, 2026
17 checks passed
@mikolajpp
mikolajpp deleted the mp/harness-approval-commands branch November 27, 2026 02:23
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.

2 participants