Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,10 @@ default.

## Consequences

- A burst of events on one work item produces one agent run that absorbs them plus at most one short
follow-up, instead of a full re-run per event.
- A burst of events on one work item produces one agent run that absorbs them plus at most one
queued follow-up, instead of a full re-run per event. The follow-up skips when that run absorbed
it and otherwise does the work in full
([ADR 0120](0120-receipt-the-absorbed-update-under-the-job-token.md)).
- Agents stop posting output computed from state the subject has already moved past.
- A run holds its sandbox until it settles, so a steered run occupies a VM longer and can cost as
much again per absorbed update.
Expand Down
113 changes: 113 additions & 0 deletions docs/ADRs/0120-receipt-the-absorbed-update-under-the-job-token.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
---
title: "120. Receipt the absorbed update under the job token, and let the queued run skip on it"
status: Accepted
relates_to:
- security-threat-model
- flapping-convergence
topics:
- concurrency
- dispatch
- security
---

# 120. Receipt the absorbed update under the job token, and let the queued run skip on it

Date: 2026-09-18

## Status

Accepted

## Context

A run in flight that absorbs an update
([ADR 0113](0113-steer-the-running-agent-on-work-item-updates.md)) leaves the queued follow-up
run holding work already done. Nothing tells it so, and it reviews the same head again, so
steering costs *more* than preserving alone. The skip is what makes steering pay.

An "already handled" claim is read by a run deciding to do *nothing*, and a wrong one drops an
update silently. So the question is who can write such a record.

## Options

### The queued run always redoes the work

No new record and no new trust boundary: every queued run reconciles the item's current state.
It also makes steering a net loss, since the queued run reviews the head the run in flight did.

### A marker on the terminal status comment

The runner already posts that comment, so the marker costs no extra request — but it goes out
under the App identity, the same one the agent's own output is posted under, so the marker
authenticates two public strings rather than the code path that wrote them. An injection can
induce the agent to emit a well-formed marker into its review body, and a post-script shelling
out to `gh` can post one directly, reaching none of the runner's sanitizing paths.

### A receipt posted and read under the GitHub Actions job token

The runner captures `GH_TOKEN` as the action passed it in, before minting swaps in the role
token, and posts the receipt as its own comment under that identity. It costs one request and
one identity resolution per run, and holds only where the platform gives the job an identity of
its own — GitHub Actions, not GitLab.

## Decision

Adopt the job-token receipt. **Authorship is the whole of the authentication: a receipt counts
only when the job token posted it, under the login that token resolves, and its body was never
edited since.** After a successful run that absorbed at least one update, the runner posts a
receipt naming the follow-up runs it consumed; a queued run reads the latest receipt in its
pre-flight, before the start comment and before the pre-script, and exits 0 without starting the
agent when it finds its own run id listed.

Two conditions make that identity mean something, and both are enforced in code rather than
assumed. Minting must actually have swapped the credential — with no mint URL or no role nothing
is swapped, the same token stays in the environment a post-script inherits, and the receipt
credential is empty instead. And the receipt's login and the role's must differ, since the
action's `github_token` is a caller-supplied input that may resolve to the identity the agent
posts under; the check refuses to skip when they match.

A receipt claims the work is done, so it is written only for an outright success, once per run
rather than per steer, naming only what the shipped iteration absorbed — and only when that output
was published, so a run whose agent reported an error and had its post-script withheld writes none,
as do failed, cancelled, skipped and unvalidated runs, runs whose output was never read back, and
runs that absorbed nothing. Both halves fail open in every direction — no receipt, an unreadable
timeline, an unresolvable login, a malformed run id, a failed post — because a false "already
handled" silently drops work while a false "not handled" costs one run, which can be a full review.

The terminal status comment keeps an informational copy of the marker so a reader can see what a
run absorbed. The skip check does not honour it, and no App-authored marker of any shape is a
receipt. Agent-authored text is neutralized in the sticky and tracker comment bodies, and the
status comment carries none beyond a detail field that escapes every `<`, so the copy stays a
report rather than something the agent can compose. Minting swaps the job token out under both
`GH_TOKEN` and `GITHUB_TOKEN`, and a child script's environment drops any entry still holding it,
so a post-script cannot reach it by name or by value. A provider credential expanding
`GH_WORKFLOW_TOKEN` ([ADR 0114](0114-github-packages-via-host-bound-workflow-token-provider.md))
does hand it to a sandbox, where the agent can recover it, and every job shares the login, so no
receipt is honoured while any definition in `.fullsend/providers/` expands it; one fetched by URL
is not inspected. What `consumed` attests differs by runtime: Claude Code acknowledges a delivery
by echoing its text verbatim, while pi acknowledges only the rpc id, so on pi a receipt records
that the runner delivered an update under that id rather than that the operator's words reached
the agent. The acknowledgement record the receipt intersects against is therefore influenced by
the run's own agent on pi — it can change the text an id acknowledges, though not add an id the
runner never delivered — which bounds the claim to delivery rather than content. The mechanics are
in [steering.md](../contributing/steering.md#who-may-write-a-receipt).

A second skip covers a duplicate no receipt can. Two events on one head, such as a pull request
opened and labelled a second apart, each route a review; the run in flight rejects the other as
not fresh and writes no receipt. So a queued review also exits 0 when the review App (exact
logins, the forge's App verdict) reviewed the current head after the queued run was created. A
human `/fs-review`, a manual re-run, an unreadable event and any error run the review.

## Consequences
Comment thread
waynesun09 marked this conversation as resolved.
Resolved

- Steering stops costing *more* than preserving alone, which is the condition for enabling it
anywhere.
- The trust boundary is the repository's own workflows: any job in it posts under the same login
and could write a receipt, which is maintainer-controlled and deliberately not narrowed further.
- Where the workflow-token provider is configured, queued runs do the work until OpenShell
placement stops the token being recoverable; elsewhere a forger needs the runner's credential.
- A caller that passes an App installation token as `github_token` never skips, and is warned
once per run rather than silently trusting the agent's own identity.
- An injected review from the review App can suppress only repeat reviews of the head it names.
- GitLab has no receipt, because its job token can neither post nor read notes, so a queued
pipeline there does the work exactly as it does today.
10 changes: 10 additions & 0 deletions docs/architecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,16 @@ The existing design principle is that [the repo is the coordinator](problems/age
`fullsend run`. Delivery is at-least-once and state-based — an update the run
misses is done by the pending run behind it
([ADR 0119](ADRs/0119-learn-of-later-events-by-listing-run-records.md)).
- A run that absorbed an update posts a **receipt** naming the follow-up runs it
Comment thread
waynesun09 marked this conversation as resolved.
Resolved
consumed, and a queued run that finds its own id in one exits without starting
the agent. The receipt is authenticated by its author alone: the GitHub Actions
job token, captured before minting swaps it out, and honoured only when that
swap happened and its login differs from the agent's. The terminal status
comment keeps an informational copy that the check does not honour. A second
pre-flight skip exits a queued review whose head the review App already
reviewed after the run was created, a duplicate no receipt covers
([ADR 0120](ADRs/0120-receipt-the-absorbed-update-under-the-job-token.md),
mechanics in [steering.md](contributing/steering.md#the-skip-check)).
- Per-repo **polling** complements webhook dispatch: `fullsend poll` uses poll
input drivers to discover work from remote systems (Jira first), coordinates
via source-native write-then-verify locks, and feeds the same dispatch pipeline
Expand Down
6 changes: 4 additions & 2 deletions docs/cli/steer.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@ workstation.
comment fires the repository's fullsend shim like any other event, and the run
already in flight on that item absorbs it instead of being cancelled and
restarted ([ADR 0113](../ADRs/0113-steer-the-running-agent-on-work-item-updates.md)).
Until the run records what it absorbed, the follow-up run it absorbed still runs
and redoes the work.
After a successful run, the runner posts a receipt for the follow-up runs it
absorbed, and each of those runs finds it at start and skips instead of redoing
the work ([ADR 0120](../ADRs/0120-receipt-the-absorbed-update-under-the-job-token.md)).
A run that finds no receipt it can trust does the work anyway.

There is no steer-specific command. The runner accepts a follow-up run on
provenance, never on which words the comment opened with, so the run in flight
Expand Down
114 changes: 114 additions & 0 deletions docs/contributing/steering.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ On this page:
- [The work item's baseline](#the-work-items-baseline)
- [Settle](#settle) — how a steered run ends
- [Ceilings](#ceilings) — token life, cost, and the per-process guards
- [The skip check](#the-skip-check) — the receipt a queued run reads, and who may write one
- [The fleet-agent backstop](#the-fleet-agent-backstop)
- [Configuration](#configuration)
- [Known limits](#known-limits)
Expand Down Expand Up @@ -430,6 +431,119 @@ gantt
run B, one redo on the newest head :done, 00:21, 3m
```

## The skip check

After a successful run that absorbed at least one steer, the runner posts a **receipt** as its
own comment on the work item:

```text
<!-- fullsend:steer consumed=<run_id,...> head=<sha> -->
_The run already working on this item absorbed follow-up run(s) 101, 102, so a run queued for
those events exits without repeating the work._
```

It is a **processing receipt** in the sense of the entity-first evaluation ADR
([fullsend#6956](https://github.com/fullsend-ai/fullsend/pull/6956)): a durable record on the
subject of what a run handled, which is what lets a later run decide whether its own trigger is
already covered. In `fullsend run`'s pre-flight — before the start comment and before the
pre-script, whose side effects are not free — a queued run reads the latest receipt and exits 0
without starting the agent when its own `GITHUB_RUN_ID` is listed.

### Who may write a receipt

**The author is the whole of the authentication, and it must be the job token's.**

The runner captures the GitHub Actions job token — `GH_TOKEN` as the action passed it in —
before minting swaps in the role token, and posts the receipt under that identity. The reader
resolves that login from the token rather than hardcoding it, because it differs between
github.com and GitHub Enterprise Server.

Two conditions have to hold for that identity to mean anything, and both are enforced in code:

- **Minting must actually have happened.** The swap is what puts the job token out of reach: it
replaces both `GH_TOKEN` and `GITHUB_TOKEN` before the sandbox exists, and every child
script's environment — pre-flight, pre-script, post-script and `validation_loop` — drops any
remaining entry whose value is the swapped-away token, so a caller cannot keep it reachable
under a third name. With no mint URL or no role there is no swap,
the same credential stays in the environment a post-script inherits, and a post-script
shelling out to `gh` could sign a receipt. The receipt credential is the job token *only when
a role token was minted*; otherwise it is empty and both the writer and the check turn off.
- **The two identities must differ.** The action's `github_token` input defaults to
`${{ github.token }}` but is an input, so a caller can pass an App installation token. If that
resolves to the login the role token posts under, the agent's own comments carry the trusted
author and the check is inverted. The reader resolves both logins and refuses to skip when
they match, warning as it goes.

With both holding, nothing inside the sandbox can post as the receipt's author. An edited
receipt is ignored: editing keeps the author, and any identity with write access can edit
another's comment, so only a body the job token wrote counts. A manual re-run never skips on a
receipt: it keeps its run id, so the receipt that consumed its first attempt would skip it again.

The exception is a provider that hands the sandbox the job token itself: while any definition in
`.fullsend/providers/` expands `GH_WORKFLOW_TOKEN`
([ADR 0114](../ADRs/0114-github-packages-via-host-bound-workflow-token-provider.md)), for any
harness, the agent can recover it, so the skip check honours no receipt and logs why.

**What the author check proves, exactly:** that the comment came from a workflow job token of
*this repository* — not that it came from this run, or from fullsend. Every job's default
`GITHUB_TOKEN` in a repository posts under the same login, so any other workflow there could
write a comment carrying the marker syntax and it would be honoured. That is a
maintainer-controlled boundary, and it is deliberately not narrowed: checking the named run id
against the Actions API would add nothing, because that id is public.

This is why the receipt is a **separate comment** rather than the marker on the terminal status
comment. That comment is posted by the App, the identity the agent's own output goes out under,
so a marker there authenticates two public strings rather than the code path that wrote them —
an injection can induce the agent to write a well-formed marker into its review body, and the
App then posts it. The runner still writes a copy of the marker into the status comment so a
reader can see what a run absorbed, but **the skip check does not honour it**, and no
App-authored marker of any shape is a receipt.

The boundary this leaves is a credential leaked out of the runner's own process, which is a
compromise of the runner rather than of the sandbox. Reading the Actions API is deliberately not
held to the same bar: those reads prove no authorship, so the watcher uses the job token whether
or not minting swapped it.

One limit is inside the sandbox rather than outside it. What an acknowledgement attests differs by
runtime: pi's carries only the rpc id while Claude Code's carries the message text, and `tail -f`
follows a truncation, so an agent that rewrites a mailbox line under the same id is acked on pi as
though the original text had been read. The run is the same principal on both sides and already
owns its own output, so this changes no trust boundary — but `consumed` on pi means the update was
delivered, not that its words survived. Put precisely: the acknowledgement record the receipt
intersects against is influenced by the agent on pi, which can change the text an id acknowledges
but cannot add an id the runner never delivered.

### Failure directions

The check fails open in every direction: no receipt, an unreadable timeline, an unresolvable
login, a malformed run id. A false "already handled" silently drops the work; a false "not
handled" costs one run, which for review is a full review of the same head. Writing the receipt is best-effort for the same reason — a failed
post costs one queued run that redoes finished work, where failing the run would throw away work
that succeeded.

Only an outright success leaves a receipt, and only one that absorbed something. A failed,
cancelled, skipped or unvalidated run writes none, because a receipt claims the work is done. A
run that absorbed nothing writes none either: the status comment still records the head it
settled on, but a receipt asserting that a queued run may skip has nothing to assert. One
receipt per run, not per steer, and it names only what the iteration whose output shipped
absorbed — an update absorbed by an iteration that then failed validation never reached that
output. A run whose output could not be read back from the sandbox writes none, even when its
post-script exits 0.

**A second skip covers review duplicates no receipt can.** Two events on one head, such as a PR
opened and labelled a second apart, each route a review. The run in flight rejects the other as
not fresh, absorbs nothing and writes no receipt. So a queued review also exits 0 when the review
App reviewed the PR's current head after the queued run was created. The App is matched on its
exact logins and the forge's App verdict. The event kind comes from the normalized event when the
run has one, and otherwise from the event GitHub delivered to the job when it names the same pull
request, since the built-in stages get no normalized event. A human `/fs-review`, a manual re-run
and an unreadable event always run. Any error runs the review. Every run that does not skip logs
which condition failed. The check runs with steering on or off
([ADR 0120](../ADRs/0120-receipt-the-absorbed-update-under-the-job-token.md)).

**On GitLab there is no receipt.** Its job token cannot post or read notes, so the skip check
stays fail-open exactly as it is today: the queued pipeline does the work.

## The fleet-agent backstop

The runner exports `FULLSEND_RUN_HEAD_SHA` and `FULLSEND_RUN_STARTED_AT` into the sandbox
Expand Down
Loading
Loading