Repository navigation
Description
This was generated by AI during triage.
Spec C of four from the #1142 grilling (grilling, Q2.1 (c), ADR 0026). It's built on Spec A, the Console API (#1753), and absorbs #952 (a readable and writable User config in the Console). Spec B, the Fleet in the Console (#1142), runs alongside. Adding these controls to the Fleet view is a follow-up blocked by both Specs.
Problem Statement
After #1753, a Console's API and page can read everything and Stop or dismiss, but they can't start anything or change the machine. To start a Ticket run, run a Pass now instead of waiting for cron, kick off a Custom process, change a User config setting or update thirdshift, the Day shift still needs a shell on that machine. From a phone that's impractical. Across the Fleet it means an SSH session per machine. The User config can only be changed by editing the file or re-running setup, and there's no config command at all (#952).
Solution
The run and admin scopes from #1753 get their endpoints. With run, a client can start any Command the CLI can start: a Ticket run or Spec run on an issue with the shared options, an Architect run, Pickup run, Security run or Review run, a Custom process, a skill run, a Scoring run and the like. Each behaves exactly like the typed command, starts detached, and is recorded as started by the person or token that asked. With admin, a client can read and change the User config through a new thirdshift config command and its twins, and run update. The Console page gets matching controls for a signed-in person with those scopes: a "Start" form, "Run now" on each Pass, a User config page, and an "Update thirdshift" action. Issuing tokens, the sign-in list, address scopes, console install and setup stay CLI-only (ADR 0026).
User Stories
- As the Day shift, I want to start a Ticket run on an issue through the API, with the same shared options as the CLI (merge, email, harness, model, effort, base-fix, security review and fix), so that I can start work from anywhere.
- As the Day shift, I want an issue with sub-issues to start a Spec run through the API, as the CLI does, so that the API never behaves differently.
- As the Day shift, I want to run an Architect run, Pickup run or Security run now through the API, with their own options (base branch, focus, plan-only, order), so that I don't wait for cron.
- As the Day shift, I want a Pass started through the API to be skipped for the same reasons as one started by cron, Command limit included, so that the API can't pile up work cron wouldn't.
- As the Day shift, I want a Ticket run started through the API on an Issue URL always to run, as a typed command does, so that the API is a person's command, not a Pass.
- As the Day shift, I want to start a Review run on a pull request, or by author, through the API, so that reviews start remotely too.
- As the Day shift, I want to start a Custom process by name, with an issue or pull request, through the API, so that my own Processes are startable too.
- As the Day shift, I want to run a skill, a Scoring run, a triage of a Report (sent as text, not a file path), and the other Command-starting CLI commands through the API, so that nothing that starts work is CLI-only.
- As the Day shift, I want a started Command to run detached from the Console with a login environment, so that a Console restart or
updatedoesn't end it. - As the Day shift, I want the start call to return the new Command's name once its Command record exists, or the skip outcome if it was skipped first, so that I know at once what happened.
- As the Day shift, I want the started Command to appear in the Inbox like any other, so that I follow it the usual way.
- As the Day shift, I want the Activity log's start line to name who started it, for example "by from the Console on " or "by token ", so that remote starts are traceable.
- As the Day shift, I want every start written to the Console log, so that starts are audited with the other changes.
- As the machine's owner, I want a start to run only in one of this machine's known Launch directories, so that a token holder can't point thirdshift at an arbitrary folder.
- As the machine's owner, I want the known Launch directories to be those my thirdshift cron jobs already use, plus any I list in the User config, so that the usual repositories work with no setup.
- As a client, I want to name the repository (owner/name), and have the machine find its Launch directory, so that I don't need to know the machine's paths.
- As a client, I want the list of startable repositories and their Launch directories through the API, so that a start form can offer them.
- As a client, I want a start refused with a clear error when the repository has no known Launch directory, so that I know what to fix.
- As the Day shift, I want a "Start" form on the Console page, for a person with
run, to start a Ticket run on an issue number or URL with the shared options, so that I can start work from my phone. - As the Day shift, I want "Run now" next to each Pass on the cron jobs page, for a person with
run, so that I can bring a Pass forward. - As the Day shift, I want a confirm step before any start from the page, so that a stray tap doesn't spend a Harness subscription.
- As the Day shift, I want start controls hidden for a person without
run, so that I'm never offered what will be refused. - As the Day shift, I want a
thirdshift configcommand that shows every User config setting with its value and default, so that I can read the config without opening the file (make user config readable and writeable on thirdshift console web ui #952). - As the Day shift, I want
thirdshift config <key>to show one setting andthirdshift config <key> <value>to set it, validated assetupvalidates, so that I can change one setting safely. - As the Day shift, I want
thirdshift config --jsonand its API twin, so that clients can read the config. - As the Day shift, I want setting a value to keep the file's comments and layout, as
setupand theconsolesettings commands do, so that the file stays readable. - As the machine's owner, I want
configrefused for the Console sign-in list and address scopes, so that the API can't widen anyone's access (ADR 0026). - As the machine's owner, I want a secret never to appear in
configoutput, so that the config page leaks nothing (the User config holds no secrets, and the Credentials stay unreadable through it). - As the Day shift, I want a User config page in the Console, for a person with
admin, that shows every setting and lets me change one, so that make user config readable and writeable on thirdshift console web ui #952 is done. - As the Day shift, I want the User config page read-only for a person with
readbut notadmin, so that make user config readable and writeable on thirdshift console web ui #952's read/write split holds. - As the Day shift, I want every config change written to the Console log with old and new values, so that I can see who changed what.
- As the Day shift, I want
updatethrough the API, foradmin, so that I can update a machine without a shell. - As the Day shift, I want the update call to answer before the Console re-executes itself, then the Console to come back on the new version, so that the client isn't left hanging.
- As the Day shift, I want an "Update thirdshift" action on the page showing the current and latest versions, for a person with
admin, so that I can see and act on updates. - As the Day shift, I want a Theme imported through the API as JSON content, not a file path, so that
console theme importhas a twin. - As the machine's owner, I want any CLI command that takes a local path to accept its content in the request instead, or stay CLI-only when it writes to a local path (such as
logs --export), so that the API never reads or writes arbitrary files. - As the machine's owner, I want
console install,setup, tokens, the sign-in list and address scopes to have no API endpoint, so that the machine's shell stays the root of trust. - As a client author, I want every new endpoint in the OpenAPI description with its scope and CLI twin, so that the API stays discoverable.
- As an agent working in this repository, I want the parity test to fail when a Command-starting or machine-changing CLI command has neither an API twin nor a listed exclusion, so that "everything the CLI can do" stays true as commands are added.
Implementation Decisions
-
Scopes. Every CLI command that starts a Command or a Harness session, or writes to GitHub, is
run. Every one that changes the machine (the User config,update, Theme import, Eval data management) isadmin. The route table declares each one, as Spec: the Console API, /api/v1 behind scoped tokens #1753 set up. -
Exclusions are explicit. The parity test walks every CLI command. Each must have an API twin or appear on a short, reasoned exclusion list: token management, the sign-in list, address scopes,
console install,setup,console password, and commands that write to a local path (logs --export). A new CLI command with neither fails the test. -
Starting a Command. The endpoint takes the CLI command's arguments as structured JSON, with the repository named as owner/name in place of the current directory. The Console resolves the repository to a known Launch directory, then spawns the same thirdshift binary with those arguments in that directory: detached in its own session, with the account's login environment, output appended to the same log cron uses, so it outlives the Console. The response waits briefly (bounded, e.g. 30 seconds) for the Command record to appear, or for the process to exit with a skip, and returns the Command's name or the skip outcome. The Command decides everything else itself, exactly as when typed.
-
Who started it. The spawned Command is given the requester's identity (person and machine, or token holder) through its environment. Its Activity log start line names them alongside today's wording. A Command started from cron or a terminal is unchanged.
-
Known Launch directories. These are the directories this account's thirdshift cron jobs
cdinto, plus alaunch_directorieslist in the User config, each resolved to its repository through itsoriginremote. An endpoint lists them. A start for any other repository is refused. -
thirdshift config. This is a new CLI command (config,config <key>,config <key> <value>,--json) built on the existing User config document editing thatsetupand theconsolesettings commands use, with the same validation and comment-preserving writes. It refuses the sign-in list and address scopes. Its API twins are a GET for the whole config and one setting, and a POST to set one setting. -
update. The API twin runs the same update. It responds once the new binary is in place, then the Console re-executes itself as it already does after an update. -
Content instead of paths.
triage --filetakes the Report's text, andconsole theme importtakes the Theme's JSON, in the request body. -
Page controls.
- A Start form on the Inbox: repository (from the known list), issue number or URL, and the shared options, with a confirm step.
- "Run now" for each Pass on the cron jobs page.
- A User config page: every setting, its value and its default, editable with
adminand read-only otherwise. - Update: current and latest version, and an Update action.
All of these are hidden without the scope they need.
-
Auditing. Starts, config changes (with old and new values) and updates go in the Console log with who asked.
-
Docs.
docs/guide.mddocuments starting work and administering a machine through the API and the page, plusthirdshift config. The hand-written site pages say the Console can start work where they say it can't (they echo ADR 0016's old "never starts work").
Testing Decisions
-
Good tests exercise external behaviour: the binary, HTTP, fake
ghand fake Harnesses onPATH, fixture clones. Nothing reaches into the spawner or the config writer. -
Seam 1, the Console over HTTP (
tests/console.rs, with the repository's fakeghand fake Harness binaries). With aruntoken:- start a Ticket run in a fixture clone named by a fixture cron job, and see its Command record appear with the Activity log line naming the token holder;
- start a Pass that's skipped for its Command limit and get the skip outcome;
- see a repository with no known Launch directory refused;
- see the started Command survive a Console restart.
With an
admintoken:- read and set a User config value, with comments preserved, and see the sign-in list refused;
- run
updateagainst the existing update test fixtures.
Scope refusals for
readandacttokens. Prior art:tests/console/stop.rs, the fakes used by the Run and Spec run tests, and the update and packaging tests. -
Seam 2, the route-table parity test, extended to walk every CLI command and require an API twin or a listed exclusion (with a should-panic twin).
-
thirdshift configis tested through the binary, astests/user_config.rsdoes. -
Site browser tests cover the Start form's confirm step and the User config page being read-only for a
readperson.
Out of Scope
- Start and admin controls on other machines' rows in the Fleet view. That's a follow-up Ticket blocked by Spec: the Fleet in the Console #1142 and this Spec.
- Scheduling: the API starts a Command now, and never schedules one (ADR 0009). Editing cron jobs through the API is out too.
- Token management, the sign-in list, address scopes,
console install,setupandconsole password, permanently (ADR 0026). - Commands that write to a local path.
- Streaming a started Command's output through the API. The client follows it through the existing views.
Further Notes
- Known Launch directories (from cron jobs, plus a User config list) is a decision this Spec makes and the grilling didn't cover. It keeps a
runtoken from aiming thirdshift at an arbitrary folder. - Closing make user config readable and writeable on thirdshift console web ui #952 in favour of this Spec. Its "which users have read and write access" question is answered by address scopes (Console API: address scopes and naming a person #1757).
Activity