Skip to content
Merged
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
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,13 @@ forge install --ssh USER@HOST
```

Replace `USER@HOST` with your server's SSH address or alias. The CLI asks for the
factory name, GitHub owner, repositories and coding account, then prepares the
server. It handles SSH and file transfers.
factory name and GitHub owner, then lists repositories and coding accounts to
choose from. Review the summary, edit anything you need, and confirm installation.
Forge handles SSH and file transfers. Your approval is required before project
merges by default; customization is under **Advanced**.

Approve the Tailscale and GitHub browser prompts. Keep the terminal open until
setup gives you the web address. From there, **Installation progress** shows the
setup says **You can close this terminal**. From there, **Installation progress** shows the
current step, anything waiting for you, and the first merge test. Codex sign-in
can continue in the web app; other provider setup may require the CLI.

Expand Down
28 changes: 21 additions & 7 deletions docs/cli-fresh-host.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,22 @@ Install [uv](https://docs.astral.sh/uv/getting-started/installation/) first if n
If your shell cannot find `forge`, run `uv tool update-shell` and open a new terminal.
`anvil` is an example of an SSH alias; a `user@hostname` destination also works.

The interview records the factory name, GitHub owner and operators, repositories,
merge policies, provider logins and smoke target. It resolves the Forge revision
once. All selected repositories must belong to the chosen GitHub owner. A new
SSH fingerprint must be verified against the VM provider before use.
Review the preflight findings and confirm Apply once.
The default interview asks for the factory name, GitHub owner, repositories and
coding account, plus SSH host identity. Choose repositories and providers by
number; you can also type a repository name if it is not listed. All selected
repositories must belong to the chosen GitHub owner.

Review one editable summary before preflight. Defaults are your GitHub account
as operator, Codex browser sign-in, approval before project merges, workflow
edits off, and a private repository for the first-merge test. **Advanced** offers
additional operators, network hostname, merge policies, explicit workflow-write
permission, other login methods and a different test repository. No passwords
or tokens belong in this interview.

For an unfamiliar SSH host, verify its ED25519 fingerprint with your VM provider
before entering it. Leaving it blank uses your existing trusted SSH keys; it does
not trust a newly discovered host. Preflight checks the plan before the final
Apply confirmation. The deterministic intent-file interface is unchanged.

The default smoke target creates two private repositories under the selected
owner: one for the smoke issue, one for signed-publication qualification. Their
Expand All @@ -47,13 +58,16 @@ any independent operator holds still apply.
After preflight passes, the CLI prepares these GitHub targets, installs the host,
and configures private HTTPS, the App and operator identity. It then opens
**Installation progress** in Forge and hands the approved plan to the server.
You can close the terminal. The server prepares the worker environment while
Only after the CLI says **You can close this terminal** is the handoff confirmed.
The server prepares the worker environment while
checking up to three repositories in parallel and waiting for Codex sign-in.
Publication checks and the first-merge test start after their prerequisites pass.

### Browser steps

The CLI prints the exact browser actions as they become available:
The CLI prints the exact browser actions as they become available. Host and
network preparation still run before GitHub App consent; this is not an
all-consent-before-installation flow:

1. Approve the VM joining Tailscale if it needs authorization.
2. Open the local GitHub handoff, create the single Forge App, and install it on
Expand Down
16 changes: 11 additions & 5 deletions docs/onboarding-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

Detailed setup and repository protection reference. For the everyday walkthrough, see [Getting set up](onboarding.md).

`bin/forge setup` prepares the host and connects coding accounts in the terminal
(see [installation](installation.md)). Then open /onboarding on the trusted private
dashboard address. It has three steps: GitHub, Repository and Start.
Use the [guided installer](onboarding.md) for a new factory. It opens the web
installation page after bootstrap. Existing manual installations can continue
at `/onboarding`, with three steps: GitHub, Repository and Start.

1. **GitHub.** Register and install one Forge App through the guided flow.
Select the repositories it may access, then refresh access in Forge.
Expand Down Expand Up @@ -108,10 +108,16 @@ Guided setup allows up to four Build, two Review, one Audit and one Recovery wor
These are ceilings: how many actually run depends on available memory (see
[factory runtime](factory-runtime.md)), so a small host needs no tuning.

Connect or reconnect a harness from the VM terminal with
Connect or reconnect Codex in **Settings → Connections → Coding accounts**.
Choose Connect, open the OpenAI sign-in page and enter the displayed code. Forge
finishes sign-in and verifies Codex automatically. Closing the dialog does not
stop the login; return to the same page to resume it or request a fresh code
after expiry.

Other providers and API-key/token modes currently use the CLI. Connect from the VM terminal with
`bin/forge setup login codex --root <runtime>` or
`bin/forge setup login claude --root <runtime>`, then `bin/forge setup check` with
the same root. The UI shows connection status and terminal instructions.
the same root. The UI labels those modes as CLI instructions before you open them.
Forge preserves refreshed installation-owned logins across runner cleanup; an
older runner cannot overwrite a newer login. External imported files remain untouched.
See [installation](installation.md) for API keys, model rotation and fresh VM setup.
Expand Down
23 changes: 23 additions & 0 deletions docs/onboarding-release-audit.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,29 @@ merge. Operator actions and time spent waiting for a prompt are separate measure
| Where are settings? | Five categories compete for attention. Capacity and reset appear alongside normal operation. | General, Repositories, Connections. Fold capacity/reset; preserve deep links and unsaved edits. |
| What should I do first? | Installation tests itself, but the README buried the path to real issue work. | Explain `ready`, planning groups, approval and Activity. Validate this handover in Group C. |

## Implementation follow-up

The next integrated change implements the shorter default CLI interview, numbered
repository/provider choices and editable summary. Advanced choices retain workflow
permission and host identity consent. The browser handoff is announced only after
the server confirms that it accepted the setup plan; otherwise the CLI provides
its resume action.

Codex browser connect, reconnect and verification now have a post-install web
path using the existing durable device-login lifecycle. Other provider/browser
adapters and API-key/token web entry remain separate work. The original findings
below describe the audit baseline; these two improvements address most of A/B.

Remaining release work:

- Move the remaining GitHub consent earlier; host/network preparation still comes
first. Do not claim all approvals happen before installation starts.
- Verify the integrated account-recovery changes on the deployed factory.
- Run Group C on a disposable supported Ubuntu x86-64 host. Record command-start
time separately because the historical saved timer begins after the interview.
- Keep additional provider modes explicit rather than presenting unsupported web
sign-in actions. New adapters and Mac-host support remain outside this release.

## Delivery groups, in order

### A — Finish the default installation path (release blocker)
Expand Down
6 changes: 5 additions & 1 deletion docs/onboarding.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,11 @@ time to first merge when the run completes.
## Configuration and recovery

For an active factory, use **Settings** to manage repository access, accounts and
configuration. **Settings → GitHub access → Add repository** checks access and
configuration. Codex browser sign-in and reconnect are available under
**Settings → Connections → Coding accounts**. Other providers and API-key/token
modes currently use the CLI and are labeled accordingly.

**Settings → Repositories → Add repository** checks access and
rules before **Enable automation**. Checking or discovering a repository alone
does not enable it. Refresh expired checks when prompted.

Expand Down
115 changes: 115 additions & 0 deletions forge/account_web.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
"""Operator account recovery using the installation's owned device-login lifecycle."""
import time
import uuid

from forge_client.contracts import fields, require
from .installation_accounts import DeviceAccount
from .host_setup import LoginBusy
from .onboarding import Onboarding
from .settings import Settings
from .sqlite_identity import audit_in, identity_effect_lock
from .store.configuration import Configuration
from .store.runtime import required


class AccountWeb:
def __init__(self, root, *, setup=None, clock=time.time, device=None):
self.root, self.clock = root, clock
self.setup = setup or Onboarding(root, clock=clock)
self.store = required(root)
self.configuration = Configuration(self.store, clock=clock)
self.device = device or DeviceAccount(root, setup=self.setup, clock=clock)

def saved(self, generation):
return self.configuration.get('account_web', generation)

def view(self):
data = self.setup.read()
saved = self.saved(data['generation'])
record = data.get('device_logins', {}).get('codex')
account = {'provider': 'codex', 'status': 'idle'}
if record:
try:
result = self.device.call('codex', generation=data['generation'], setup_id=record['setup_id'])
account = {key: result[key] for key in ('provider', 'status', 'url', 'code', 'expires_at') if key in result}
except (ValueError, RuntimeError, OSError):
account['status'] = 'account_unavailable'
operation = saved['settings'] if saved else {}
return {'generation': data['generation'], 'revision': saved['revision'] if saved else 0,
'setup_revision': self.setup.revision(data), 'account': account,
'operation': {key: operation[key] for key in ('status', 'updated_at', 'error', 'verification') if key in operation},
'browser_providers': ['codex'], 'active': data['phase'] == 'active'}

def request(self, value, *, actor_id):
fields(value, ('generation', 'revision', 'setup_revision', 'provider', 'action'))
require(value['provider'] == 'codex', 'device_login_unsupported')
require(value['action'] in ('connect', 'reconnect', 'retry', 'verify'), 'invalid_action')
with identity_effect_lock(self.store):
data = self.setup.read(); generation = data['generation']
require(generation == value['generation'] and data['phase'] == 'active', 'setup_changed')
require(not Settings(self.root).paused(), 'factory_paused')
saved = self.saved(generation)
require(value['revision'] == (saved['revision'] if saved else 0)
and value['setup_revision'] == self.setup.revision(data), 'account_changed')
record = data.get('device_logins', {}).get('codex')
expired_retry = (saved and saved['settings']['status'] == 'connecting'
and value['action'] in ('retry', 'reconnect') and record
and self.clock() >= record['expires_at'])
if saved and saved['settings']['status'] in ('queued', 'connecting', 'verifying') and not expired_retry:
return self.view()
require(not data.get('operation'), 'setup_busy')
connected = next(row['connected'] for row in self.setup.harnesses(data) if row['id'] == 'codex')
require(value['action'] != 'verify' or connected, 'account_not_connected')
require(value['action'] != 'connect' or not connected, 'account_already_connected')
record = data.get('device_logins', {}).get('codex')
operation = {'status': 'queued', 'action': value['action'], 'updated_at': self.clock(),
'setup_id': record['setup_id'] if record else uuid.uuid4().hex,
'previous_session': record['id'] if record else None}
with self.store.write() as db:
self.configuration.replace_in(db, 'account_web', operation, subject=generation,
expected_revision=saved['revision'] if saved else 0)
audit_in(db, self.clock, 'account_operation_requested', details={
'actor_id': actor_id, 'provider': 'codex', 'action': value['action'], 'generation': generation})
return self.view()

def tick(self):
with identity_effect_lock(self.store):
data = self.setup.read(); generation = data['generation']; saved = self.saved(generation)
if data['phase'] != 'active' or Settings(self.root).paused() or not saved:
return
operation = saved['settings']
if operation['status'] not in ('queued', 'connecting', 'verifying'):
return
following = dict(operation)
try:
if operation['status'] == 'verifying':
if data.get('operation'): return
harness = next(row for row in self.setup.harnesses(data) if row['id'] == 'codex')
passed = harness['models'] and all(row['status'] == 'passed' for row in harness['models'])
following['status'] = 'complete' if passed else 'failed'
if not passed: following['error'] = 'Codex verification did not pass. Try again.'
else:
if data.get('operation'): return
if operation['action'] == 'verify':
result = {'status': 'connected'}
else:
record = data.get('device_logins', {}).get('codex')
original = (record['id'] if record else None) == operation['previous_session']
restart = original and operation['action'] in ('retry', 'reconnect')
if restart and record and record['phase'] not in ('failed', 'complete') and self.clock() < record['expires_at']:
observed = self.device.call('codex', generation=generation, setup_id=operation['setup_id'])
restart = observed['status'] == 'account_login_failed'
result = self.device.call('codex', generation=generation, setup_id=operation['setup_id'], apply=True,
retry=restart, reconnect=restart and operation['action'] == 'reconnect')
if result['status'] == 'connected':
self.setup.queue('harness_check', self.setup.revision(self.setup.read()), harness='codex')
following.update(status='verifying', verification=True)
else:
following['status'] = 'failed' if result['status'] in ('account_login_failed', 'write_unconfirmed') else 'connecting'
except LoginBusy:
return
except (ValueError, RuntimeError, OSError):
following.update(status='failed', error='Account connection stopped. Retry or check the factory status.')
if following != operation:
following['updated_at'] = self.clock()
self.configuration.replace('account_web', following, subject=generation, expected_revision=saved['revision'])
6 changes: 5 additions & 1 deletion forge/host_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,13 +110,17 @@ def update(root, bind=None, assume_yes=False):
check(root)


class LoginBusy(ValueError):
"""Another caller owns this provider login; retry observation later."""


@contextmanager
def login_lock(root, provider):
with open(root / ('state-login-' + provider + '.lock'), 'a') as stream:
try:
fcntl.flock(stream, fcntl.LOCK_EX | fcntl.LOCK_NB)
except BlockingIOError:
raise ValueError('Another terminal is already connecting this harness') from None
raise LoginBusy('Another terminal is already connecting this harness') from None
yield


Expand Down
Loading
Loading