# Step 1: Project Creation And Invitation

This step creates a new Rho-backed GitHub repo and admits a collaborator with the streamlined CLI flow.

Example users:

- Owner: `madhavajay`
- Collaborator: `madhavajay-test`
- Repo: `rho-live-clean-test-20260616-codex1`

## 1. Owner Creates The Project

```sh
./rho --profile madhavajay repo create madhavajay/rho-live-clean-test-20260616-codex1 --public --yes
```

Under the hood:

- Switches `gh` to the `madhavajay` account if needed.
- Resolves `--profile madhavajay` to `github/madhavajay`.
- Creates the local checkout at:

```text
~/rho/madhavajay/projects/rho-live-clean-test-20260616-codex1
```

- Runs `git init`.
- Runs `rho repo init`.
- Adds the owner participant identity.
- Protects the owner inbox path:

```text
rho/messages/inbox/id/github/madhavajay/**
```

- Installs the `rho-crypt` Git filters.
- Signs governance files.
- Runs `rho repo doctor`.
- Creates the GitHub repo.
- Commits and pushes the initial Rho project.

Project URL:

```text
https://github.com/madhavajay/rho-live-clean-test-20260616-codex1
```

## 2. Collaborator Requests Access

```sh
./rho --profile madhavajay-test repo join madhavajay/rho-live-clean-test-20260616-codex1 --pr
```

Under the hood:

- Switches `gh` to the `madhavajay-test` account if needed.
- Resolves `--profile madhavajay-test` to `github/madhavajay-test`.
- Forks the owner repo if needed.
- Creates or reuses the collaborator checkout at:

```text
~/rho/madhavajay-test/projects/rho-live-clean-test-20260616-codex1
```

- Configures remotes:

```text
upstream -> git@github.com:madhavajay/rho-live-clean-test-20260616-codex1.git
origin   -> git@github.com:madhavajay-test/rho-live-clean-test-20260616-codex1.git
```

- Auto-detects the correct SSH key for `madhavajay-test` and stores it in repo-local Git config.
- Syncs from upstream.
- Creates a branch like:

```text
madhavajay-test/join-rho
```

- Adds the collaborator participant file.
- Commits as `madhavajay-test`.
- Pushes to the collaborator fork.
- Opens a join PR against the owner repo.

Example PR:

```text
https://github.com/madhavajay/rho-live-clean-test-20260616-codex1/pull/1
```

## 3. Owner Admits The Collaborator On The Same PR

```sh
./rho --profile madhavajay repo admit-pr 1 \
  --root ~/rho/madhavajay/projects/rho-live-clean-test-20260616-codex1 \
  --pr
```

Under the hood:

- Switches `gh` back to `madhavajay` if needed.
- Checks out PR `#1`.
- Imports participant identities.
- Reads the PR author, here `madhavajay-test`.
- Verifies `github/madhavajay-test`.
- Adds `madhavajay-test` as an admitted Rho participant.
- Protects the collaborator inbox path:

```text
rho/messages/inbox/id/github/madhavajay-test/**
```

- Updates permissions and governance signatures.
- Runs `rho repo doctor`.
- Commits the owner admission changes directly onto the existing PR branch.
- Pushes back to the PR branch when maintainer edits are allowed.

This keeps the whole invitation flow in one PR instead of creating a second owner/admin PR.

## 4. Owner Merges The Join PR

```sh
./rho --profile madhavajay repo merge-pr 1 \
  --root ~/rho/madhavajay/projects/rho-live-clean-test-20260616-codex1 \
  --merge \
  --delete-branch
```

Under the hood:

- Uses `gh pr merge` through the Rho wrapper.
- Merges the join/admission PR.
- Deletes the PR branch.
- Fast-forwards the owner checkout to the updated `main`.

## 5. Collaborator Syncs After Admission

```sh
./rho --profile madhavajay-test repo sync madhavajay/rho-live-clean-test-20260616-codex1
```

Under the hood:

- Uses `upstream` as the read remote.
- Uses `origin` as the collaborator write remote.
- Pulls the merged `main`.
- Reinstalls Rho filters.
- Imports current participants.

After this, both users have a project checkout under their own profile path:

```text
~/rho/madhavajay/projects/rho-live-clean-test-20260616-codex1
~/rho/madhavajay-test/projects/rho-live-clean-test-20260616-codex1
```

The collaborator is now admitted and can submit encrypted Rho requests.
