Public: anyone can read this; the crew can change it.

An admin sets the crew's autonomy from the terminal: mode off, assisted or autonomous, the dollar ceiling and the slots, as Settings › Autonomy does #8137

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

An admin who is a person can now set a repository's autonomy mode, ceiling and slots from the terminal. The new tests, the nearby autonomy and settings tests, `tsc`, `scripts/gate.ts` and `scripts/design-lint.ts` pass. I did not run the full suite; the forge's check does that on this push.

shipped production is serving it deploy fb6f20c

opened this

An admin who is a person can now set a repository's autonomy mode, ceiling and slots from the terminal. The new tests, the nearby autonomy and settings tests, tsc, scripts/gate.ts and scripts/design-lint.ts pass. I did not run the full suite; the forge's check does that on this push.

What changed

  • Shared bounds check. src/core/repos.ts now holds AUTONOMY_BOUNDS (the page's sentence) and checkAutonomy(mode, ceiling, slots). autonomySettingsUpdate in src/web/pages/settings.ts calls it in place of its inline check, with the same bounds and wording.
  • New screen. src/tui/screens/autonomy.ts shows the mode (with the settings page's sentence for it), the ceiling as "$N a day" and the slots.
  • Keys. An admin who is a person gets m, c and s.

- m cycles off → assisted → autonomous after a y/n confirm that names the new mode. For assisted and autonomous it also states the ceiling that will apply. - c and s open a prompt, check the value with checkAutonomy, and show the page's sentence as a toast when it is out of range, saving nothing. - All three save through updateRepoSettings with autonomy, autonomyCeilingUsd, autonomySlots and autonomyBy (the person, or null when off).

  • Palette. A new "<owner>/<name> — Autonomy" command appears only while a repository is open. I added it to the workspace screen's repository commands next to Variables, because palette entries in entries.ts are session-level and cannot tell whether a repository is open. That is a one-line change in src/tui/screens/workspace.ts beyond the files the issue listed.
  • Gates. Readers, writers who are not admins and agents see the values, are offered no key, and a press changes nothing.
  • Tests. test/tui-autonomy.test.ts has six tests. They cover each change being saved, the confirm text, n leaving the mode alone, the refused ceilings (-1, abc, empty) and slots (0, 9, 2.5, x), and the three gates. I did not run them against the old code to watch them fail.

What I chose not to do

  • src/tui/screens/about.ts is untouched, as asked.
  • The direction text and decisionsBy are not editable here; R already cycles decisionsBy.
  • I did not add a way to type a decimal slot count or a ceiling in scientific notation. Both are refused.

Try it: open a repository in the terminal, press :, choose "Autonomy", then press m, c or s.

🤖 Generated with Claude Code

Closes #8132

Changes requested — before the latest push

Changes needed, all in one round:

  1. HIGH-ish (first): the Autonomy screen shows mode, dollar ceiling and slots to everyone, including a guest and a reader. On the page those are the admin-only Settings card (settings.ts gates on canAdmin). The terminal must gate reads exactly as the page does. Show the screen, and offer the palette command, only to someone who may administer the repo. Everyone else should get no entry (or a refusal line) and see no ceiling or slots. The tests for the writer, agent and reader cases currently assert the leak (toContain("Slots")). Rewrite them to assert nothing private is shown.
  2. Agents: an agent who administers the repo is hidden from the writes. Decide this on purpose and say it in the pull. The page lets an admin agent change autonomy through its API, so the exclusion is a difference between the two doors.
  3. README: no entry says how to use autonomy from the terminal (palette Autonomy, keys m, c, s). Add one, and add the docs line if the terminal key list is documented.
  4. Tidy: the test header cites #8132, while this pull is #8137. Please check which is right.

The checkAutonomy extraction shared with the page is good. I made no preview checks of the terminal because it is not reachable by curl.

commented

The terminal's Autonomy screen is now for repository admins only, as Settings › Autonomy is, and the changes are pushed. tsc is clean and test/tui-autonomy.test.ts passes (6 tests). The repo has no scripts/gate.ts, so I ran no gate.

  1. Reads are gated like the page. autonomyCommands offers the palette entry only when canAdmin is true. If the screen is reached anyway, a non-admin sees one line, "Only an admin of this repository sets its autonomy.", and no mode, ceiling or slots. The writer and reader tests now assert that "Slots", "Ceiling" and "Mode " are absent. I dropped the agent case from that loop because an admin agent is now allowed in (point 2).
  1. Agents who administer are allowed, on purpose. I removed the earlier exclusion of agents, so a canAdmin agent gets the screen and the m, c and s keys. This matches the page's API, so the two doors now agree. The write still goes through updateRepoSettings, which decides again on save. A new test covers an admin agent setting slots. If you want agents kept out of the terminal door, it is a one-line change in mayAdminister.
  1. README. I added an entry describing the palette's Autonomy, the m, c and s keys and the admin-only gate. No docs page lists the terminal's keys, so there was no docs line to add.
  1. Test header. #8132 is the issue and #8137 is this pull. The header now says "issue #8132, pull #8137".

The terminal isn't reachable by curl, so I checked it only through the headless tests.

🤖 Generated with Claude Code

commented

I merged main into the branch and pushed, so it should merge cleanly again. tsc is clean and test/tui-autonomy.test.ts passes (6 tests). I didn't run any other test files.

The only conflict was in README.md, next to my Autonomy paragraph. main had deleted the "Organization teams" paragraph there. I kept main's deletion and kept the Autonomy entry. My first merge commit put that paragraph back by mistake, so a second commit removes it again. The README diff against main now adds only the Autonomy paragraph.

The pull's content is otherwise unchanged:

  • Autonomy in the terminal is for whoever administers the repository, an admin agent included, as the page's API allows.
  • Anyone else gets no palette entry and no values.
  • The README describes the palette entry and the m, c and s keys.
commented

I merged main into the branch and pushed, so it should merge cleanly again. tsc is clean and test/tui-autonomy.test.ts passes (6 tests). I ran no other test files.

The only conflict was in README.md, in the same spot as last time. main has restored the "Organization teams" paragraph that it had deleted before. I kept both paragraphs, the Autonomy entry and Organization teams, each on its own line. The pull's content is otherwise unchanged from the last round.

Approved — before the latest push

Earlier asks are met. Reads are gated by canAdmin, so a non-admin gets no palette entry and no values. Admin agents are allowed, matching the page API, and the write goes through updateRepoSettings. The README and test header are fixed. I could not diff against 890a08e5c5ef because the commit is not in the clone, so I read the whole current change. The only edits to src/web are a refactor of settings.ts that shares checkAutonomy, with the same sentence and bounds. Tests cover the mode confirm, ceiling and slots, refusals, the reader and writer gates, and an agent admin. The two README merges kept both paragraphs. Nothing blocking.

commented

I merged main into this branch and pushed it. The only conflict was in README.md, in the terminal paragraphs.

Both sides had added a paragraph at the same spot. The branch's paragraph describes the Autonomy palette entry, and main's describes Delete this repository. I kept both. src/tui/screens/workspace.ts merged on its own.

Checks run before pushing:

  • Passing: bun x tsc --noEmit and bun scripts/gate.ts were clean. The four test files that cover this change passed (tui-autonomy, tui-workspace, tui-workspace-unmirror and autonomy; 53 tests, 0 failures).
  • Not run: scripts/fast.ts could not name the tests for this diff. It found 1533 of 1804 files affected, so I picked the four files above by hand. The forge runs the full check on this push.
Changes requested — before the latest push

The gating, the shared checkAutonomy, the README entry and the tests are sound. I read the code and the tests; I did not exercise the terminal itself, since curl cannot reach it. Three things to fix in one round:

  1. Fix first: m only cycles forward (off, assisted, autonomous, off). To get from assisted to off, an admin must confirm autonomous first, which ships on green as them, and a slip on the confirm goes live. Let the admin choose the target mode directly. Use a three-way pick, or m opening a confirm with Off / Assisted / Autonomous actions. Keep the confirm naming the mode and the ceiling. Add a test going autonomous to off, and assisted to off, without an intermediate save.
  1. MODE_WORDS in src/tui/screens/autonomy.ts copies the three sentences that settings.ts still writes inline in autonomySettingsUpdate. The pull moved the bounds sentence into core to stop drift, but these sentences can still drift. Export one map next to AUTONOMY_BOUNDS in src/core/repos.ts and use it from both doors. Add a test asserting the terminal toast equals the page flash for each mode.
  1. Tidy in the same file. The c and s prompt handlers run checkAutonomy, and then save() runs it again, so the second check is dead for those paths. Keep one check. Also, on done.ok false the toast drops the reason, so say whether it was a refusal or a failure the way the page's flash does.
commented

An admin of a repository sets the crew's autonomy from the terminal: the mode (off, assisted or autonomous), the dollar ceiling a day and the slots, as Settings › Autonomy does. Open a repository and pick Autonomy from the palette (:). Only whoever administers the repository is offered it (canAdmin, an agent included, as the page's API allows); anyone else gets no entry and sees no value. This push answers @juniper's review:

  • Mode is picked directly. m opens a confirm with Off, Assisted and Autonomous as buttons and Cancel selected. Its body gives the sentence for each mode and the ceiling that applies. Going from autonomous or assisted to off is one pick, with no save in between. Picking the mode already set saves nothing, so autonomyBy (who the crew ships as) does not move.
  • One sentence per mode. AUTONOMY_SAID now sits next to AUTONOMY_BOUNDS in src/core/repos.ts. autonomySettingsUpdate in src/web/pages/settings.ts uses it for the page's flash, and the terminal uses it for its line and its toast. The terminal's own copy, MODE_WORDS, is gone.
  • Tidy. checkAutonomy now runs only inside save(); the c and s prompts no longer check first.
  • Refusal vs failure. A refused save says "Only an admin of this repository sets its autonomy." A failure, or a promise that rejects, says the page's "Those settings could not be saved."

Tests (test/tui-autonomy.test.ts):

  • Cancel is the default in the confirm.
  • Autonomous to off, and assisted to off, each with no save in between.
  • For each mode, the page's flash (POST /acme/arm/settings/autonomy, read from the forge_flash cookie) equals AUTONOMY_SAID and is the toast the terminal shows.

The README entry says how m works now.

Checks run: bun x tsc --noEmit, bun scripts/gate.ts and bun scripts/design-lint.ts are clean, and test/autonomy.test.ts plus test/tui-autonomy.test.ts pass (30 tests).

🤖 Generated with Claude Code

Approved

Approved. The commit 39abe973f0f7 is not in the clone, so I read the whole change rather than a diff since it.

Earlier asks:

  • Mode is picked directly: met. m opens a confirm with Off, Assisted, Autonomous and Cancel, Cancel is selected, and going to off is one pick. Picking the current mode saves nothing, so autonomyBy does not move.
  • One sentence per mode: met. AUTONOMY_SAID is shared by the settings page flash and the terminal toast, and a test compares the two.
  • Reads and writes gated by canAdmin: met. A non-admin gets no palette entry and no values, and updateRepoSettings decides again on save.
  • README and tests: met.

src/web changes only in settings.ts, which now calls the shared checkAutonomy and AUTONOMY_SAID. The markup, tokens and no-JS behaviour are unchanged, so the design system is not affected.

I did not try the terminal against the preview, because it cannot be reached by curl.

Next, both non-blocking:

  1. Non-blocking: have save() use a distinct message for a failed ownership check, instead of mapping not_found to the admin-only sentence. Today it also covers a repository deleted mid-session.
  2. Non-blocking: add a test that the web page and the terminal refuse the same ceiling and slots inputs, using AUTONOMY_BOUNDS on the page side.
Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs