Skip to content

feat: show Claude plan usage in Settings, on the floor and in the CLI - #58

Merged
kalaspuff merged 6 commits into
mainfrom
fctl/23-look-into-https-github-com-hyperstructur
Oct 18, 2026
Merged

kalaspuff merged 6 commits into
mainfrom
fctl/23-look-into-https-github-com-hyperstructur

Conversation

@fctl-sh

@fctl-sh fctl-sh Bot commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

People can now see how much of their Claude plan is left before they start work. Sessions already report Claude's rate_limit_events; fctl now keeps the latest reading of each plan limit per Claude connection and shows it under each connection in Settings → Claude, in one line under the task box on the floor (for the connection new sessions use), and in fctl claude status.

Fixes #6

What happens

  1. Claude reports it. Claude Code writes a rate_limit_event when a limit's status changes. Recent versions also write one whenever the five-hour or weekly window moves by a percent, with rate_limit_info.unifiedWindows (five_hour, seven_day, each with utilization and resetsAt) beside the top-level rateLimitType, status, utilization and resetsAt of the limit closest to stopping requests. I took the shape from the schema in Claude Code 2.1.302. fctl-agent already passes these messages on as events, so hosts and agents don't change.
  2. SessionDO turns each into readings (fctl_domain::usage::readings): one per limit (the five-hour window, the week, a model's own weekly limit), with the share used, when it resets, and Claude's status for the limit it names. Paid extra usage (overage) is not a plan limit, so it is left out. The event comes from the sandbox, so odd values are dropped (names other than [a-z0-9_]{1,40}, shares outside 0 to 10, times that aren't positive), and one event adds at most eight limits.
  3. D1 keeps the latest per credential (claude_usage, migration 0008). Each credential has one row per limit, written for the credential the session runs on now (a resumed session runs on the resumer's). A reading replaces the row only if it arrived later. Removing a connection or deleting the account deletes the rows (ON DELETE CASCADE).
  4. People see it. /auth/me returns the readings on each credential (ClaudeCredentialInfo.usage, a subquery in the query that already loads credentials). FleetDO sends a claude_usage feed message to the owner's open apps, so Settings and the floor update while sessions run.

Readings change only while sessions run, so the apps say when a session last reported them. A window whose reset time has passed shows as started over instead of keeping its old share. A limit counts as close from 80 % or when Claude warns, and as used up at 100 % or when Claude rejects requests.

Why use what sessions report instead of asking Anthropic: it is what the issue asks for, it makes no extra calls with people's tokens, and it works for both kinds of connection (a long-lived token can't read claude.ai's usage endpoint).

Web app

  • Settings → Claude: under each connection, one meter per limit with "42% used · resets at 3:40 PM" (amber when close, pink when used up) and "Reported by a session 3 minutes ago". A connection without readings says it gets them once a session runs on it.
  • The floor: under the task box, "Claude plan · 5-hour 8% · Weekly 37%" with small meters, for the default connection and linking to Settings. When a limit is used up: "Your 5-hour limit is used up. Sessions you start now pause until it resets at 3:40 PM." When it is close: "84% of your 5-hour limit is used. It resets at 3:40 PM."
  • The meters re-render every minute, so a window that resets while the page is open shows it. The feed patches the me query; no new socket.

CLI

fctl claude status prints the limits under each connection; --json now includes usage:

● fake-claude · setup_token · inference only
    5-hour limit  8% used, resets in 4h 50m
    Weekly limit  37% used, resets in 3d 19h
    reported by a session just now

At a limit, the line reads 5-hour limit limit reached, resets in 1m; once the window passes, 5-hour limit started over just now.

Also

  • The account export has a claude_plan_usage section.
  • fake-claude reports usage on every turn except limit and crash, the way Claude Code does. The windows follow the clock, so every session reports the same numbers and cargo xtask dev shows them.
  • Docs: a Plan usage section in architecture.md, plus getting-started.md, cli.md and development.md. ROADMAP ticks Usage view: Claude plan limits per person #6.
  • Privacy: app.fctl.sh now stores plan usage, so docs(legal): say that app.fctl.sh keeps Claude plan usage fctl-site#10 adds it to the privacy policy (what is stored, how long, and that the export includes it). Merge the two together.

Compatibility

  • Additive only: ClaudeCredentialInfo.usage is optional, PlanLimit and LimitStatus are new, and the claude_usage feed message goes only to the web app, whose older tabs ignore it. Hosts and agents need no update.
  • Deploying applies D1 migration 0008_claude_usage.sql (cargo xtask deploy applies migrations first). No Durable Object binding or migration tag changes.

Verification

  • cargo xtask check passes: fmt, generated types, Biome and TypeScript, Clippy (native and wasm), every Rust and web test, and the production web build.
  • New tests: fctl_domain::usage (10): the 2.1.302 shape, the older top-level-only shape, a limit reached without a share, overage and bare statuses ignored, odd values dropped, the eight-limit cap, rows as D1 returns them, labels, standings and merging. web/src/lib/usage.test.ts (5): labels, standings, meter fill, which limit to warn about, reset phrases.
  • End to end with cargo xtask dev:
    • A session's first turn stored five_hour 7 % and seven_day 37 % for its credential, and fctl claude status showed them.
    • limit gave "limit reached, resets in 1m" and paused the session. After the reset, the limit showed "started over".
    • With the floor open in Chromium (Playwright), starting a limit session changed the strip to "used up" and showed the sentence 312 ms later, without a reload.
    • A session on a second credential stored its readings on that one only. Removing the credential deleted its rows (checked in local D1), and the export lists the rest with ISO times.

Screenshots

I took them at 8ef3fd4 against cargo xtask dev with fake-claude, with main (012337e) on the same control plane for the before shots. This session can't attach them: gh pr edit --attach answers "unsupported authentication type" with the GitHub App's token (#40). They are in the session (https://app.fctl.sh/s/ses_01M56GBDBASVNSG4VJ7A671F4K). What they show:

  • Floor, light, before and after. After adds one quiet line under the task box: "Claude plan", then "5-hour" with a short meter and "8%", then "Weekly" with a meter and "37%". Nothing else on the page moves.
  • Floor, dark. The same line in ink-3, readable but quieter than the task box.
  • Floor with the 5-hour limit used up, light and at 390 px dark. The 5-hour meter fills in pink and says "used up". Under it, in pink: "Your 5-hour limit is used up. Sessions you start now pause until it resets at 04:12 AM." At 390 px the line wraps after the 5-hour meter, with the sentence below.
  • Settings → Claude, light, before and after. After adds, under the connection's row and aligned with its name: "5-hour limit", a meter, and "8% used · resets at 09:00 AM"; "Weekly limit", a meter, and "37% used · resets Thu at 12:00 AM"; then "Reported by a session just now". The section's description gains one sentence.
  • Settings → Claude at 390 px, dark. Each limit's detail moves under its meter. The 5-hour window shows "Started over just now" with an empty meter, because its reset had passed.

Session: https://app.fctl.sh/s/ses_01M56GBDBASVNSG4VJ7A671F4K

fctl-sh Bot and others added 6 commits October 18, 2026 04:01
Sessions report rate_limit_event (the five-hour and weekly windows, a
model's weekly limit, utilization and resets). The session Durable Object
turns them into per-limit readings (fctl_domain::usage), keeps the newest
of each limit per Claude credential in D1 (claude_usage), returns them on
each credential in /auth/me, and pushes changes to the owner's feed.
fctl claude status prints them; the data export includes them.

Refs #6

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Settings lists each credential's limits as meters (share used, when the
window resets, when a session last reported it). The floor shows the
default credential's limits under the task box, and says when one is used
up or nearly so. The feed's claude_usage message keeps both live.
fake-claude reports usage on every turn, so cargo xtask dev shows it.

Refs #6

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ps-github-com-hyperstructur

# Conflicts:
#	crates/fctl-control/src/do_session.rs
A rate_limit_event comes from the sandbox, so one adds at most eight
limits. Reading stored usage moves to fctl_domain::usage::from_json, with
a test of the rows D1 returns.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@kalaspuff
kalaspuff merged commit 3b935e5 into main Oct 18, 2026
4 of 5 checks passed
@kalaspuff
kalaspuff deleted the fctl/23-look-into-https-github-com-hyperstructur branch October 18, 2026 11:12
fctl-sh Bot added a commit that referenced this pull request Oct 18, 2026
main added 0008_claude_usage.sql (#58), which has shipped, so this
branch's migration becomes 0009_commit_email.sql. fake-claude's table of
behaviors keeps main's plan usage and this branch's commit trailers.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
kalaspuff pushed a commit to hyperstructure/fctl-site that referenced this pull request Oct 18, 2026
app.fctl.sh now keeps how much of each Claude plan's usage limits is
used, as sessions last report it (hyperstructure/fctl#6). The privacy
policy says so:

- **What we collect**: a Claude connection now includes its plan usage:
for each limit (the five-hour window, the week, a model's weekly limit),
the share used, when it resets and when a session reported it.
- **How long we keep it**: the latest report of each limit, until a
newer report replaces it or the connection is removed (deleting the
account removes connections).
- **Your rights**: the data export includes it.

Nothing new reaches anyone else: the readings come from sessions' own
Claude output, and fctl asks Anthropic for nothing more. `updated` stays
2026-10-18, which is today.

Merge it with hyperstructure/fctl#58, which starts storing the data.

Session: https://app.fctl.sh/s/ses_01M56GBDBASVNSG4VJ7A671F4K

Co-authored-by: fctl-sh[bot] <343971779+fctl-sh[bot]@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <[email protected]>
fctl-sh Bot added a commit that referenced this pull request Oct 18, 2026
Brings in #54, #57 and #58. The conflicts are #57's against #39's:

- The daemon starts by retrying until the runtime lists the sandboxes
  (#57); the background pull of the host's image (#39) starts after
  that, once the runtime answers.
- The hello keeps #57's sandbox limits and #39's resolved image.
- session.rs imports both sides' names.

With #57's timeouts, a `run` that times out no longer counts as a
missing image: it fails at once instead of trying a pull that would hang
on the same runtime for up to 30 minutes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
kalaspuff pushed a commit that referenced this pull request Oct 18, 2026
)

Every host built the default sandbox image itself with `fctl host image
build`, and its Claude Code stayed as old as that build, since fctl
turns off Claude Code's auto-updater. #2 asks for CI to publish the
image instead, for arm64 and amd64, under a stable name with version
tags and labels, rebuilt when Claude Code moves on, with a documented
layout that custom images (#16) can build `FROM`; hosts on the default
image pull the tag of their own version.

The image now lives in a public repository of its own,
[hyperstructure/sandbox](https://github.com/hyperstructure/sandbox) (set
up in hyperstructure/sandbox#1), which publishes it as
`ghcr.io/hyperstructure/sandbox`. This pull request makes hosts pull it
and takes the image out of this repository.

## What changed

**The image moves to hyperstructure/sandbox.** `images/agent` (the
Dockerfile, `provision.sh`, `check.sh`) and the Image workflow leave
this repository; hyperstructure/sandbox#1 adds them there, with a
README, AGENTS.md, skills, lint and title checks. Its Image workflow
keeps what this pull request had built: each architecture builds on a
native runner and is checked with `check.sh`, then both are tagged as
one image.

- `ghcr.io/hyperstructure/sandbox:<version>` for every fctl release,
plus `:<major>.<minor>` and `:latest` when that release is the newest
they cover. Each is the sandbox's `main` with that release of fctl and
the newest Claude Code.
- It looks for new fctl releases on fctl.sh every hour, rebuilds the
newest release's image as soon as a change to the image merges there,
and every day when Claude Code has a newer release or the image is a
week old. Only its `main` publishes; its pull requests build and check
both architectures.
- Labels and index annotations as before: `sh.fctl.version`,
`sh.fctl.claude-code.version`, and the commit and date it was built
from, which the workflow reads back to decide whether an image is
current.

The Release workflow no longer starts an image build: its token can't
start workflows in another repository, so the sandbox's hourly run
notices the release. Why a separate repository: [ADR
0012](docs/adr/0012-the-sandbox-image-lives-in-its-own-public-repository.md)
(the image has to be public, and it has a cadence of its own). It's 0012
because #55 adds 0011.

**Hosts: `crates/fctl-host`, `crates/fctl`**

- `image` in `host.toml` is optional. Unset, sessions start from
`ghcr.io/hyperstructure/sandbox:<the host's version>`, so upgrading a
host moves its new sessions to the new version's image.
`fctl-agent:latest`, which every host installed so far has in its
`host.toml`, also means the default, in `host.toml` and in project
settings.
- The daemon pulls the host's image in the background when it starts and
the image is missing. A session pulls a missing image itself. Nothing
pulls over an image that is already there, so a local build is kept.
- When the version's image can't be pulled (the hour between a release
and its image, or a development build), a session on the default image
starts from `:latest` and says so in its log. A failure that isn't about
the image (the image is there but `run` fails) no longer tries a pull.
- Apple's `container image pull` gets `--platform linux/<the host's
architecture>`. Without it, Apple's CLI downloads every platform of a
multi-arch image (`DefaultPlatform.resolve` in apple/container).
- `fctl host image build` downloads an archive of the sandbox's `main`
from GitHub and builds its Dockerfile with the host's driver, under the
host's image name so sessions use the build, or gives the Lima VM its
`provision.sh`. `--source DIR` builds from a checkout instead, to try
changes to the image with fctl. The binary no longer carries the files.
- CLI: `fctl host image pull` (new, `--json`) pulls the host's image
again, for a newer build of its tag. `install` says which image sessions
start from, `status` (and `--json`) shows it, `doctor` says whether it's
there, and `install --image ""` goes back to the default.
- A sandbox without fctl now says in its log that the default image has
one, instead of suggesting `fctl host image build`.

**Docs:** `docs/sandbox-images.md` (new) covers the image, its tags and
labels, how hosts get it, and its layout as an interface for images
built `FROM` it: the `agent` user (uid 1000, passwordless sudo),
`~/.local/bin`, `~/.cargo/bin`, `~/.bun/bin` and `/opt/fctl/bin` first
on the PATH, and the tools. It's the "Sandbox images" page #16 asks for,
which #16 can extend; the image's README in hyperstructure/sandbox lists
the versions. Getting started, the CLI, self-hosting, security,
architecture, development and the top-level README say that hosts pull
the image instead of building it. AGENTS.md lists hyperstructure/sandbox
among the other repositories (what the host relies on there, and that
its Rust follows `rust-toolchain.toml`), and the release and issues
skills point to it. The roadmap item is ticked.

**Web:** the runner dialog drops step 3 ("Build the sandbox image"), and
the project's image field shows `ghcr.io/hyperstructure/sandbox` as its
placeholder instead of `fctl-agent:latest`.

## For a person

0.3.0 shipped without this pull request, so the next release (0.4.0) is
the first whose hosts pull the image.

1. **Merge hyperstructure/sandbox#1.** Its Image workflow then publishes
`ghcr.io/hyperstructure/sandbox:0.3.0`, `:0.3` and `:latest` from the
sandbox's `main`, which creates the package.
2. **Make hyperstructure/sandbox public** and apply its settings: the
commands are in hyperstructure/sandbox#1.
3. **Make the package public**: the organization's Packages → sandbox →
Package settings → Change visibility. A package starts private even when
its repository is public, and hosts pull without signing in. The
organization's settings must allow public packages. Until then, sessions
on hosts of 0.4.0 fail with "ghcr.io/hyperstructure/sandbox:0.4.0 is not
on this host and can't be pulled (`fctl host image build` builds it
here)".
4. **Merge this pull request**, then hyperstructure/fctl-site#7 once
fctl's CI has pinned fctl.sh past it (`gh pr update-branch 7 -R
hyperstructure/fctl-site`).

## Compatibility

- No protocol or control-plane change. `HostHello.image`, already
optional, now carries the image the host actually uses. Hosts pick up
the new behavior with the release that includes it; hosts of 0.3.0 and
earlier keep building `fctl-agent:latest` from the files in their
binary.
- `image = "fctl-agent:latest"` in `host.toml` now means the published
image. A host that ran a modified image under that name should rename it
and set `image`, or rebuild it with `fctl host image build`, which tags
it with the default name.
- `fctl host image build` needs to reach github.com, as its build
already needed Debian's mirrors and the tools' installers.
- Hosts keep the images of earlier versions until someone removes them
(`docker image rm …`), as they kept the images `fctl host image build`
replaced. Removing them automatically, and refreshing a tag when its
image is rebuilt, is #47.

## Verification

- **The sandbox's Image workflow** ran on hyperstructure/sandbox#1: both
architectures built natively (amd64 in 2m56s, arm64 in 2m20s) and
`check.sh` passed in each with fctl 0.3.0 and Claude Code 2.1.302
([run](https://github.com/hyperstructure/sandbox/actions/runs/39123588178)).
Its lint (ShellCheck, actionlint) and title checks pass too.
- **Its planning step**, run locally against stubbed fctl.sh,
downloads.claude.ai and registry responses, decides correctly in 19
cases: a pull request; hourly with no image (build), a current image
with an older Claude Code (skip: hourly runs ignore Claude Code), an
image built from the last change to the image (skip) and one from before
it (build), an index without annotations (build); daily with an older
Claude Code or a week-old image (build) and a current one (skip); a push
after a change (build); dispatches of 0.2.0 (no `:0.2`: 0.2.1 exists),
v0.2.1 (`:0.2`), a current image with an older Claude Code (build), a
forced rebuild, another branch (build without publishing), a version
fctl.sh doesn't have and a malformed one (errors); and odd answers from
fctl.sh and downloads.claude.ai (errors).
- **`fctl host image build`** with a stand-in `docker`: `--source` with
a checkout builds it with `FCTL_VERSION=0.3.0` and
`FCTL_DOWNLOAD=https://fctl.sh/releases`. The download path, pointed at
a `git archive` of the sandbox served locally (GitHub's format, with its
pax header), unpacks it, builds `…/sandbox-main` and removes the
temporary directory; pointed at a real GitHub archive of a public
repository, it follows the redirect, unpacks it and says the result has
no `provision.sh`; against the real URL while the repository is still
private, it fails with HTTP 404. Unit tests cover unpacking a
GitHub-style archive and refusing a checkout without `provision.sh`.
- **End to end with the stand-in:** an old `host.toml` with
`fctl-agent:latest` resolves to `ghcr.io/hyperstructure/sandbox:0.3.0`
in `status` and `status --json`; `doctor` reports it "not here yet",
then ✓ after `fctl host image pull --json`.
- **Unit tests:** the config tests cover unset, empty and old-default
images, a custom image and saving. The driver tests use a stand-in
`docker`/`container` CLI with an image store and a registry: an image
already there, a pull, Apple's `--platform`, falling back to `:latest`,
both images missing (with and without a fallback), and a `run` failure
that isn't about the image.
- `cargo xtask check --quick` passes locally on the move and on the
merges with `main` (#48, #50, #52, then #54, #57, #58), and CI's full
`cargo xtask check` passes. The merge with #57 keeps its startup retry
loop and starts the background pull once the runtime answers; a `run`
that times out under #57's limits now fails at once instead of being
taken for a missing image and trying a pull.
- hyperstructure/fctl-site#7, with its `main` merged, builds against
this branch's docs: 8 pages, Sandbox images among them, linking to
hyperstructure/sandbox.
- Earlier on this pull request, before the move: the publish step's
commands against a local registry (one OCI index for both architectures
that all three tags point to, with the annotations) and `fctl host
install --driver docker` with a stand-in, which writes no `image` and
says which image sessions start from.
- **Not verified here:** pushing to GHCR with the sandbox workflow's
token, creating the package and its visibility. They need `packages:
write` on the sandbox's `main`, so merging hyperstructure/sandbox#1 is
their test, well before a release depends on them.

## Screenshots

Sessions can't attach screenshots yet (#40), so here is what they show.
Taken at 7771600 with Playwright against `cargo xtask dev` (before:
`main` from a worktree), in both themes and at 390 px:

- **Runner dialog, "Bring studio mac online":** before, three numbered
steps: 1. Install fctl, 2. Register it as a runner and start the
service, 3. Build the sandbox image (once, a few minutes) with `fctl
host image build`. After, steps 1 and 2 only, and the note under them
reads "It shows up here as online within seconds and pulls the sandbox
image in the background. With Lima, prepare the base VM once with `fctl
host image build`. `fctl host doctor` checks everything, including
whether the Mac is set to never sleep." Both themes and the phone width
wrap cleanly.
- **Project → Settings → Sandbox:** the Image field's placeholder reads
`ghcr.io/hyperstructure/sandbox` (at 7771600 it read
`ghcr.io/hyperstructure/fctl-agent`; `main` has `fctl-agent:latest`).
Nothing else in the section changes. The move changed only this
placeholder's text, which wasn't screenshotted again.

Refs #2

Sessions: https://app.fctl.sh/s/ses_01M56C4589JCHJ2W8TXC8V2S4P,
https://app.fctl.sh/s/ses_01M56FZDD6WY8J56E3TA0SEMZX for merging #45 and
v0.3.0, and https://app.fctl.sh/s/ses_01M57B991V0YYBRJFN0WKEW118 for
moving the image to hyperstructure/sandbox

---------

Co-authored-by: fctl-sh[bot] <fctl-sh[bot]@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <[email protected]>
kalaspuff pushed a commit that referenced this pull request Oct 18, 2026
Commits from sessions credited the GitHub App's bot and Claude, never
the person who started the session. People can now choose a commit email
in Settings → Profile (or with `fctl account set --commit-email`), and
the commits in the sessions they start end with a `Co-authored-by`
trailer with their name and that address, so GitHub links the commits to
their account. Without one nothing changes, and the sign-in email never
goes into a commit. Each project chooses who its commits credit, with a
switch for the person and one for Claude.

Refs #15. The privacy policy change it asks for is
hyperstructure/fctl-site#9.

## What changed

- **A commit email people choose** (the issue's proposal). Settings →
Profile has a "Commit email" field whose hint says what it does and who
sees it, and links GitHub's email settings for the noreply address. From
the CLI: `fctl account set --commit-email ADDRESS` (`""` removes it,
`--json` prints `Me`), and `fctl whoami` shows it. It is stored on the
user row (migration `0009_commit_email.sql`), returned in `Me` but not
in `User`, which admins also get, included in the data export, and
cleared when the account is deleted. `validate::commit_email` keeps its
case (GitHub matches it against accounts) and allows only a plain
dot-atom before the `@`, so it can't break a trailer.
- **Projects choose who their commits credit**, with two switches in the
project's settings (Agents), both on by default: **Credit people in
commits** (`credit_people`) and **Credit Claude in commits**
(`credit_claude`). From the CLI: `fctl projects set --credit-people
on|off --credit-claude on|off`, a new command that changes what it's
given and sends the other settings back as they are (an update replaces
all settings). Without people, the control plane doesn't look up the
starter's commit email, so it never reaches the sandbox. Without Claude,
fctl-agent leaves Claude's trailer out of `attribution.commit` (the
person's trailer alone, or an empty string for none) and sets
`attribution.sessionUrl: false`, so Remote Control sessions leave out
the claude.ai session link too (that key came in Claude Code 2.1.183;
fctl-agent writes it only when Claude is off). An update that leaves
either field out keeps its stored value, as for `claude_ai_connectors`,
so a tab opened before the deploy or an older CLI can't turn crediting
back on. The Profile hint says a project can turn it off.
- **A new spec field, `co_authored_by`**, which `creator()` fills with
the starter's name and commit email, only when they chose one. The issue
planned to reuse `co_authors`, but every control plane so far fills that
with the sign-in email, so a new agent reading it would publish the
sign-in email whenever it runs against an older control plane: a host
updated between the Release workflow publishing archives and redeploying
app.fctl.sh, or a self-hosted instance that lags. `co_authors` stays in
the spec, empty, because older agents require it.
- **fctl-agent sets Claude Code's `attribution.commit`** in Claude's
user settings when there is someone to credit:

  ```
  Co-authored-by: Claude <[email protected]>
  Co-authored-by: Ada Lovelace <[email protected]>
  ```

This replaces Claude Code's default trailer, which names the model in
use. fctl-agent writes the settings before Claude starts, so it says
`Claude`, as Claude Code itself does when it can't tell the model's
version. Names lose control characters and angle brackets, and an
address with spaces or brackets is skipped, so each trailer stays one
line. `attribution.commit` came in Claude Code 2.0.62 together with
`attribution.pr`, which fctl already writes, so it can't make an older
Claude Code skip the file. With nobody to credit, the settings are as
before.
- **Pull requests stay plain** (`attribution.pr` stays empty, #23).
GitHub's squash merges carry the `Co-authored-by` trailers of the
squashed commits into the commit on `main`: #48's description has none,
its commits have Claude's, and its squash commit ca134aa ends with it.
So the credit reaches `main` without naming people in descriptions.
- **fake-claude** ends the commit `write <name>` makes as Claude Code
does: with `attribution.commit` from `~/.claude/settings.json`, nothing
when that is empty, or Claude's trailer when it is unset. So `cargo
xtask dev` shows every combination.
- **Docs**: architecture.md (Sessions → Commits), security.md (a Commits
section, and retention), cli.md, getting-started.md, development.md, and
[ADR
0011](docs/adr/0011-commits-credit-people-with-an-address-they-choose.md),
which records the decision and the alternatives the issue weighed (git
hooks, rewriting commits).

## Left as they were

- Only the starter is credited. The issue's open question, whether
people who message a session become co-authors too, is a person's call;
`co_authored_by` can carry more people.
- Commits a script makes get no trailer, and a repository's own Claude
settings (`attribution`) or a CLAUDE.md rule against attribution take
precedence (Claude Code 2.1.269 and later). As the issue suggests, this
starts with the setting to see whether it is reliable enough.
- Sessions take a changed address or project setting when they next
start or resume.

## Compatibility

- The API and protocol changes are additive and optional:
`Me.commit_email`, `UpdateMeRequest.commit_email`,
`SessionSpec.co_authored_by`, and `ProjectSettings.credit_people` and
`credit_claude` (on when absent; an update without them keeps the stored
values).
- Turning Claude's credit off needs hosts from this release: older
agents ignore `credit_claude` and keep Claude's trailer. Turning
people's credit off works with any agent, since the control plane then
sends nobody.
- Older agents ignore `co_authored_by` and add no trailers. Newer agents
ignore `co_authors`, so with an older control plane they add none
either.
- Deploying applies D1 migration `0009_commit_email.sql`, which adds a
nullable column.
- **Privacy policy**: hyperstructure/fctl-site#9 updated fctl.sh's
policy (what is stored, who receives it, how long, where to change it).
It was merged on 2026-10-18 and is live on fctl.sh/privacy, ahead of
this pull request: until this ships, the policy describes an opt-in
setting app.fctl.sh doesn't have yet.

## Verification

- `cargo xtask check --quick` passes: fmt, generated types, Biome and
TypeScript, Clippy (native and wasm), all Rust and web tests.
- New tests: commit email validation (`fctl-domain`); the spec in both
directions of version skew (`fctl-proto`); the settings fctl-agent
writes, and one-line trailers (`fctl-agent`).
- `cargo xtask dev` (process driver, fake-claude), driven with the CLI:
- Without a commit email, the sandbox's `~/.claude/settings.json` has
`"attribution": {"pr": ""}` only, so Claude Code's own trailer stays and
nobody else is credited, and the sign-in email appears nowhere in the
sandbox's data.
- `fctl account set --commit-email "
[email protected] "` stores it trimmed with its
case; `fctl whoami` shows it; `fctl admin users --json` doesn't contain
it; `fctl account export` has it as `account.commit_email`. `Dev
<[email protected]>`, `dev@example` and `"dev"@example.com` are refused
with "Enter a valid email address".
- A new session's commit ends with both trailers; `git log
--format='%(trailers:key=Co-authored-by,valueonly)'` reads both, and
`fctl logs` shows them in the commit's output.
- A session started before the address was set takes it when stopped and
resumed.
- `--commit-email ""` removes it, and the next session's commit has no
trailer for the person.
- Settings → Profile in Chromium against the dev stack: saving an
address (it comes back trimmed and survives a reload), the server's
error under the field for `dev@example`, both themes, 390 px.
- After merging `main` (4b94afa; #58 had taken migration number 0008, so
this one is now 0009): `cargo xtask check --quick` passes again, and on
fresh dev state the migrations apply in order (`0008_claude_usage.sql`,
`0009_commit_email.sql`) and a session's commit ends with both trailers.
- The project's switches, with the dev owner's commit email set, one
session each (the trailers its commit ended with, and Claude's
`attribution` setting):
  - both on: Claude's and the person's trailers;
  - people only: the person's trailer, with `sessionUrl: false`;
- Claude only: `attribution.commit` unset, so fake-claude, like Claude
Code, adds Claude's own trailer;
- both off: `attribution.commit: ""` and `sessionUrl: false`, and no
trailers.

With people off, the address appeared nowhere in the sandbox. A `PATCH`
whose settings leave both fields out, as an older client sends them,
kept both off, and `fctl projects set --credit-claude on` changed only
that one. In Chromium, each switch saved, and the API read back the
value.
- Not tried: real Claude Code following `attribution.commit` (the dev
stack runs fake-claude, and this sandbox can't start another Claude),
and GitHub crediting a noreply address.

## Screenshots

At 1c69f94, in Chromium against `cargo xtask dev`, with `main` (012337e
for Profile, 9587c2b for the project) against the same control plane as
the before. This session can't attach images (#40), so in words:

**Settings → Profile**

- **Before**, light and dark: the section reads "How you appear in
sessions and to your team." and has first and last name, Avatar URL and
Save.
- **After**, light and dark: the description reads "How you appear in
sessions, in commits and to your team." A "Commit email" field follows
Avatar URL, styled like it, with the placeholder "None: commits don't
credit you" and the hint "Commits in the sessions you start credit you
as a co-author with this address, which anyone who can read the
repository sees; a project can turn this off. Use one your GitHub
account has, such as your noreply address, so GitHub links the commits
to you." ("noreply address" links to github.com/settings/emails,
underlined in the accent color).
- **The server's error**: with `dev@example` saved, "Enter a valid email
address" replaces the hint in the danger color, as the other fields'
errors do.
- **Dark, 390 px, with an address saved**: the fields stack,
`[email protected]` fits the field, and the hint
wraps.

**The project's settings → Agents**

- **Before**, light and dark: three switches, "Open a pull request when
done", "Remote Control" and "claude.ai connectors".
- **After**, light and dark: two more switches below them, on by default
and styled like them: "Credit people in commits" ("Commits name the
person who started the session as a co-author, with the commit email in
their profile.") and "Credit Claude in commits" ("Commits name Claude as
a co-author, Claude Code's default. Off: they leave out its trailer and
the claude.ai session link.").
- **Dark, 390 px, with Credit Claude in commits switched off and
saved**: that switch shows off, the text wraps beside each switch like
the others', and "Settings saved" shows.

Session: https://app.fctl.sh/s/ses_01M56GAEEHP8WBMTPQ9ZY9VVA0

---------

Co-authored-by: fctl-sh[bot] <343971779+fctl-sh[bot]@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <[email protected]>
Co-authored-by: fctl-sh[bot] <fctl-sh[bot]@users.noreply.github.com>
kalaspuff pushed a commit that referenced this pull request Oct 18, 2026
fake-claude hits its usage limit whenever a turn says `limit`. When a
pause ends, fctl-agent continues the session with "The usage limit has
reset. Continue where you left off." (`on_tick` in
`crates/fctl-agent/src/supervisor.rs`), and that sentence says `limit`
too. So in `cargo xtask dev` a `limit` session hit the limit again each
time it resumed and paused for another 50 seconds, until someone stopped
it. Since #58, each of those reports also flipped the credential's
five-hour reading to "used up".

Now a turn asks for the limit only when it says `limit` but not `reset`.
The agent's message gets the usual answer, so a `limit` session pauses
once, resumes after the reset and answers. The rule is written in
fake-claude's module docs and in `docs/development.md`. Nothing that
ships to hosts or the control plane changes.

I matched on `reset` rather than on the agent's exact sentence so that
rewording the sentence doesn't bring the loop back, as long as it still
says the limit has reset. A message you type with both `limit` and
`reset` in it now gets a normal answer too; the docs say so.

## Verification

- `cargo test -p fake-claude`: a new test covers the rule (`limit` hits
it in any case; the agent's sentence and a turn without `limit` don't).
- `cargo xtask check` passes.
- `cargo xtask dev`, then `fctl run -p playground "limit"`. From `fctl
logs playground#1 --json`:

  ```
  13:10:01 user_message "limit"
  13:10:01 rate_limit_event rejected five_hour
  13:10:01 status paused "Waiting for the usage limit to reset"
  13:10:01 result error_during_execution
  13:10:51 status running "Resuming after the usage limit reset"
  13:10:51 rate_limit_event allowed five_hour 72%, seven_day 40%
13:10:52 assistant "I'll take a look at that. You asked: \"The usage
limit has reset. …"
  13:10:52 assistant tool_use Bash "ls -la"
  13:10:52 result success
  13:10:52 status idle "Waiting for a message"
  ```

It didn't pause again in the two minutes that followed (before the fix
it paused again within the same second it resumed, as the issue's
transcript shows). `fctl claude status` showed "5-hour limit 72% used",
reported by the turn that resumed.
- `fctl send playground#1 "limit again"` then paused the session again,
so `limit` still works later in a session. "hello while paused", sent
during that pause, got its answer after the reset.

That last run also showed the session going idle before fake-claude
answered the waiting message. fake-claude doesn't report
`queued_turn_count` in its `result`, and fctl-agent reads that field to
keep a session running. I opened #63 for it; it's left out of this
change.

Fixes #59

Session: https://app.fctl.sh/s/ses_01M57HNYYJMEMYHPRKXVQPDN13

Co-authored-by: fctl-sh[bot] <343971779+fctl-sh[bot]@users.noreply.github.com>
kalaspuff pushed a commit that referenced this pull request Oct 31, 2026
## Summary

A session with many pull requests listed them in the order its agent
found them, so the row in session lists, which cuts off what doesn't
fit, could show only merged ones, and the rail's Pull requests section
put the open ones at the bottom. Now open, draft and queued pull
requests come first, then those whose state nobody has looked up yet,
then merged and closed ones. Each group keeps the order the agent found
them in. The session header's list of links uses the same order, since
all three take it from the same function.

I added a unit test for the order, ran `npm run check`, and looked at a
dev session with ten pull requests in mixed states, staged in its
SQLite, against `main`'s web app and this branch's.

## Screenshots

At 8051709, dark theme. The row in the project's session list, before
and after:

![Before: the row shows merged playground#72, #58, #59 and
#60](https://app.fctl.sh/api/v1/published/6LEmb7ECkKM3Hzk64T0ez4PHCQDWxyk9qkFeD9HAze6/before-row.png)

![After: the row shows open #74, draft #75, queued #73 and #76, whose
state isn't known
yet](https://app.fctl.sh/api/v1/published/TklVAQfGRDRnVTnvFkn7At2OTeveure74E26S8YFHzD/after-row.png)

The session page's Pull requests section:

| Before | After |
|---|---|
| ![Before: six merged and closed pull requests above the open, draft
and queued
ones](https://app.fctl.sh/api/v1/published/crf3daCylMT0PsXwM8As9nzWvj6kie5kCOQRSKUQ3yq/before-rail.png)
| ![After: open, draft and queued at the top, merged and closed at the
bottom](https://app.fctl.sh/api/v1/published/MUktZKgORZgWnAZD2zhYsOHUAJZSGcEQk2EunjMehgC/after-rail.png)
|

## Worth confirming

- **Decision:** Pull requests whose state fctl doesn't know yet (nobody
has looked them up on GitHub) come after open, draft and queued ones and
before merged and closed ones, because they are usually new and so
likely still open.
- **Decision:** Within each group the order stays the one the agent
found them in, not most recent first.

[fctl session](https://app.fctl.sh/s/ses_01M67MYGPFQBTW30B1AYNJ5R2Q)

<!-- FCTL_REVIEW_SUMMARY -->
---

> [!NOTE]
> **Low risk.** It only changes the order in which the web app lists a
session's pull requests, with a unit test; no data or API changes.
>
> **What it does.** `pullRequests` now lists a session's open, draft and
queued pull requests first, then those not yet looked up, then merged
and closed ones, each group in the order the agent found them. Sessions
with many pull requests therefore keep the ones still under way visible
when a list cuts off its end.
>
> <sub>[fctl
review](https://app.fctl.sh/s/ses_01M67NF732Z1C722BJ2SRBWNJB)'s first
look at
[`8051709`](8051709)
· 2 files, +32 −3 · [Review agent
settings](https://app.fctl.sh/p/fctl?tab=reviews)</sub>

<!-- /FCTL_REVIEW_SUMMARY -->

Co-authored-by: fctl-sh[bot] <fctl-sh[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Usage view: Claude plan limits per person

1 participant