| 1 | # Equipo connects to GitHub, and knows its projects up front (spec, 2026-11-22) |
| 2 | |
| 3 | Status: APPROVED by Paul on 2026-11-22 with every recommendation (G1 to G12). |
| 4 | Not implemented. Author: Claude (`claude-fable-5-2`), from main 3ef3ec85. File |
| 5 | and line references are to that commit. |
| 6 | |
| 7 | ## Why |
| 8 | |
| 9 | Paul, 2026-11-22: "Tito is on GitHub. I guess we probably need a GitHub |
| 10 | connector too if we expect anyone to use this." And: "we need a more |
| 11 | streamlined way of making the agent aware about actual projects." The |
| 12 | Coordinator found `oficina/home` only because it guessed the hub name from a |
| 13 | conversation. |
| 14 | |
| 15 | Today every code operation assumes the Amadan hub. A repository is the string |
| 16 | `amadan.net/<namespace>/<name>`, the runner on docs-t1 holds one standing agent |
| 17 | credential in `amadan.json`, and the Coordinator learns what exists from a |
| 18 | move-in turn and its notebook, not from a list. |
| 19 | |
| 20 | This spec does two things. It gives Equipo a second forge, GitHub, behind the |
| 21 | seam the runner already has. And it gives every forge one Projects list that |
| 22 | people and the Coordinator both read. |
| 23 | |
| 24 | ## What a person sees |
| 25 | |
| 26 | 1. **Connect.** An owner opens Settings, then Connections, and taps "Connect |
| 27 | GitHub". GitHub shows "Create GitHub App for <team>"; they confirm, pick the |
| 28 | account (Tito), choose "Only select repositories", and come back to Equipo, |
| 29 | which shows "Connect tito: 3 repositories" with one Connect button. That tap |
| 30 | makes it live. This is done on the web; the native apps show the |
| 31 | connection's state and a link to set it up. |
| 32 | 2. **Projects.** One Projects list. Your starred projects first, then the |
| 33 | team's other projects, then "Can add": every repository Equipo reaches on |
| 34 | each connected forge that is not a project yet, grouped as "Amadan" and |
| 35 | "GitHub, tito". Each row has a title, the repository, and one line saying |
| 36 | what it is. An owner adds a project with one tap. Anyone stars their own. |
| 37 | 3. **Names resolve.** "Fix the invoice total in Tito" goes to Tito without a |
| 38 | question. When a name fits two projects or none, the Coordinator asks once |
| 39 | with the existing "Where should this go?" card, starred projects first. |
| 40 | Equipo remembers the name you used, for you. |
| 41 | 4. **Work on a GitHub project.** The task card reads as it does today. Its |
| 42 | branch link becomes "Pull request #214". Engineering pushes a branch |
| 43 | `equipo/<task>` to the repository and opens a draft pull request. GitHub's |
| 44 | own checks show on the card as they finish. |
| 45 | 5. **Merge.** The merge card is the same card. Merge sends GitHub the merge for |
| 46 | the exact commit that was judged. If GitHub will not merge it, the card says |
| 47 | why in GitHub's terms ("GitHub needs an approving review", "GitHub's |
| 48 | required checks have not finished") with a link to the pull request. A |
| 49 | person who merges on GitHub instead sees the task finish on its own. |
| 50 | 6. **Not reachable.** Asked about a GitHub repository outside the connection, |
| 51 | the Coordinator shows a card with "Choose repositories on GitHub", which |
| 52 | opens the App's settings on GitHub. No request is filed on anyone's behalf. |
| 53 | 7. **Disconnect.** An owner taps Disconnect, or a GitHub admin uninstalls the |
| 54 | App. Either one stops all GitHub work at once. Projects stay listed, marked |
| 55 | "GitHub is not connected". |
| 56 | |
| 57 | ## How (the parts, in order) |
| 58 | |
| 59 | ### 1. The forge seam today |
| 60 | |
| 61 | The runner already has an interface, `thin.Forge` |
| 62 | (`internal/runner/thin/forge.go:31-53`), with one implementation, `fileForge`, |
| 63 | and two optional extras (`HostedCI`, `AccessForge`). The hub is assumed in the |
| 64 | shape of the repository key and in a fixed host, not only behind the |
| 65 | interface. |
| 66 | |
| 67 | | What | Where it assumes the hub | |
| 68 | | --- | --- | |
| 69 | | Repository key | `amadan.net/<ns>/<name>` by regexp or prefix: `thin/forge.go:68-70`, `forge/publisher.go:59,420`, `forge/credential_file.go:78`, `thin/research.go:62`; on the instance `chat/tools.go:168`, `chat/projects.go:237-248` (`ProjectName`, `NormalizeRepo`), `chat/projects.go:453`, `chat/tools.go:951`, `setup/projects.go:96-103`. The remote URL is `"https://" + key` (`thin/forge.go:174`). | |
| 70 | | Credential files | `EQUIPO_AMADAN_CREDENTIAL_PATH` names `amadan.json` (`runner/config.go:24,79`): one agent entry `{agent, api, git}` and optional per-repository entries (`forge/credential_file.go:14-23`). It is standing, long-lived, and hidden from sandboxes (`workspace/workspace.go:38,52`). `EQUIPO_AMADAN_PATH` is the `amadan` CLI (`runner/config.go:25,91-93`). Wired at `thin/run.go:197`, hub fixed at `thin/forge.go:110`. | |
| 71 | | Clone and fetch | `Remote` and `remoteCredential` (`thin/forge.go:157-177`), `Clones.fetch` (`:406-461`), the password in a Basic header as user `x` (`:486-502`), `DefaultBranch` (`:626-653`), `readRemote` (`thin/access_catalog.go:91-99`). | |
| 72 | | What is reachable | `GET /api/v1/repos` every 55 seconds with an ETag (`thin/forge.go:182-228`), read grants checked one by one (`thin/access_catalog.go:17-69`), then a shallow clone of each into the catalog, at most 100 (`thin/index.go:36-52,121,176`; `wire/frames.go:347-382`). The runner's hello carries `repos`, `create_in`, `home`, `agent` and `catalog` (`thin/run.go:334`, `wire/frames.go:318-329`). | |
| 73 | | Branch push | `forge.PushBranch` from `thin/engineer.go:423-431` (`forge/branch.go:36,216`). Branches are `equipo/...`, never the default (`thin/forge.go:656`, `wire/tasks.go:627`). The lease is confirmed right before the write (`thin/engineer.go:487`). | |
| 74 | | CI status | `HubCIHosted`, `HubCIStatus` (`forge/ci.go:64-95`), through `thin/forge.go:329-364` into `thin/judge_hosted.go:32-103` and `thin/judge.go:247-259`. Hosted CI is feedback, never a certificate (injection defences, H1). | |
| 75 | | Merge | `mergeStep` (`thin/mergestep.go:43-166`) calls `forge.MergeBranch` (`forge/merge.go:353`), which sends one `HubMergeRequest` with `expect_sha` (`forge/merge.go:109-115,153`) through `fileForge.Merge` (`thin/forge.go:315-325`). Reasons `amadan_ci_pending` and `amadan_ci_failed` (`thin/mergestep.go:153-156`, `wire/tasks.go:1022-1023`). The merge watch that notices a landing is plain git (`thin/merge.go:15-23`). | |
| 76 | | Create a repository | `create_project` in `thin/bridge.go:83-139`, `POST /api/v1/repos` in `thin/forge.go:274-304`, first commit in `:538-623`. | |
| 77 | | Project add and star | `POST /projects` (`chat/http.go:86,499-515`, `chat/projects.go:551-572`) and `add_project` (`chat/tools.go:545-551,753-783`) take only repositories on the person's runner allowlist, hub keys only (`chat/projects.go:444-506`). `star_project` resolves a name by exact title or repository (`chat/stars.go:216-259`); the web star is `app.go:328`. The device API has no star route. | |
| 78 | | Access requests ("I'll request access") | `request_access` (`chat/access_request.go:12`) and the card `find` raises when nothing matches (`chat/tools.go:1008-1076`). The runner files `POST /api/v1/agents/access-requests` and polls it (`thin/access_forge.go:28-51`). The approve link must be on amadan.net (`wire/access.go:58-64`). The grant hint is an `amadan agent grant` command (`templates/chat.html:23`, `chat_page.go:177-179`). | |
| 79 | | Links | `BranchURL` is `https://<key>?branch=` (`chat/tasks.go:405-408`), the repository link `work_pages.go:220`, and a merge reference must be on amadan.net (`task_merge.go:12-15`). | |
| 80 | | Prompts | Display names strip the hub prefix: `thin/claude.go:870,939`, `thin/engineer.go:596`, `thin/judge.go:981`. | |
| 81 | | Audit | Publication receipts name provider `amadan` (`forge/publisher.go:376`, `runnerproto/report_validation.go:68`). `chat_merge_audit` records every merge decision (merge authority spec, section 8). | |
| 82 | | Previews | No forge in them. A preview is built from the runner's own tree and served by the devbox or Carloku (`thin/preview.go:351-355`, `thin/preview_devbox.go`). Nothing changes. | |
| 83 | | Old engine | `forge/publisher.go` and branch descriptions (`forge/description.go:34`, `forge/description_transport.go:72-81`) serve only the pre-thin workflow (`runner/runtime_workflow.go:147`). It stays hub only and is not extended. | |
| 84 | |
| 85 | **The smallest interface.** Keep `thin.Forge`. Change three things. |
| 86 | |
| 87 | ```go |
| 88 | type Forge interface { |
| 89 | Host() string // "amadan.net" or "github.com" |
| 90 | Repos() []string |
| 91 | Reachable(ctx) []string |
| 92 | Recheck() |
| 93 | Agent() string |
| 94 | Remote(ctx, repo string, use Use) (workspace.Remote, error) // Use: read or push |
| 95 | Exists(ctx, repo string) (bool, error) |
| 96 | CreateIn(ctx) []string |
| 97 | Create(ctx, repo string) error |
| 98 | Propose(ctx, Proposal) (ProposalRef, error) // new |
| 99 | Merge(ctx, repo, branch string, req forge.MergeRequest) (forge.MergeResult, error) |
| 100 | } |
| 101 | ``` |
| 102 | |
| 103 | - `HubMergeRequest` and `HubMergeResult` lose "Hub" from their names. Their |
| 104 | fields already fit both forges (the judged SHA, message, strategy; merged, |
| 105 | SHA, into, reason, CI state, sentence). |
| 106 | - `Propose` is new. After a push, the forge says where a person looks at the |
| 107 | change. The hub answers with the branch page and does nothing else. GitHub |
| 108 | opens or updates the draft pull request. |
| 109 | - `workspace.Remote` gains a user name (GitHub's is `x-access-token`). |
| 110 | |
| 111 | `HostedCI` and `AccessForge` keep their shape. A router, `Forges`, implements |
| 112 | `Forge` by sending each call to the forge whose `Host()` the key names. One |
| 113 | package, `wire/forgekey`, owns the key: parse, validate and display for a |
| 114 | closed list of hosts. Every regexp and prefix in the table above calls it. A |
| 115 | bare `ns/name` still means the hub. |
| 116 | |
| 117 | A GitHub key is `github.com/<owner>/<name>` in GitHub's own spelling, compared |
| 118 | without case. The project also stores GitHub's numeric repository id, so a |
| 119 | rename or transfer updates the key instead of orphaning the project. |
| 120 | |
| 121 | ### 2. GitHub auth |
| 122 | |
| 123 | | | GitHub App | OAuth app | Personal access token | |
| 124 | | --- | --- | --- | --- | |
| 125 | | Acts as | Its own bot, named in every commit, pull request and merge | The person | The person | |
| 126 | | Reach | The repositories an org admin selects | Every repository the person can see | Selected repositories (fine-grained) or all (classic) | |
| 127 | | Token life | 1 hour, minted on demand, can be narrowed to one repository | Long, until revoked | Up to a year | |
| 128 | | Revoke | Uninstall or suspend on GitHub, or Disconnect in Equipo | The person, per app | The person, per token | |
| 129 | | A person leaves | Nothing breaks | Their work stops | Their work stops | |
| 130 | |
| 131 | **Recommended: a GitHub App.** The other two put a person's credential behind |
| 132 | an agent, which Equipo's design rules out (design section 6.2: "never a |
| 133 | person's credential") and the suite doctrine forbids (a write names its real |
| 134 | actor). |
| 135 | |
| 136 | **One private App per connected GitHub account, made from the team's own |
| 137 | instance** with GitHub's App manifest flow. The App belongs to the account it |
| 138 | serves (the tito org), can be installed only there, and shows in that org's |
| 139 | own settings where its admins can audit or delete it. No secret is shared |
| 140 | between teams and nothing central has to be run. A team with two accounts |
| 141 | connects twice. |
| 142 | |
| 143 | Who does what: |
| 144 | |
| 145 | - An Equipo **owner** starts the connection. Their session, a single-use state |
| 146 | value and a 10 minute limit bind both GitHub redirects. |
| 147 | - A GitHub **org owner** (or the person, for a personal account) creates and |
| 148 | installs the App and selects the repositories. A member who is not an org |
| 149 | owner can only request it; GitHub asks the org's owners. |
| 150 | - Back in Equipo, the instance reads the installation from GitHub with the |
| 151 | App's own key (never trusting the id in the redirect), shows the account and |
| 152 | the repository count, and waits for the owner's tap on Connect. |
| 153 | |
| 154 | Permissions asked for: metadata read; contents read and write; pull requests |
| 155 | read and write; checks, commit statuses and actions read. Not asked for: |
| 156 | workflows and administration. So GitHub itself refuses a push that edits |
| 157 | `.github/workflows`, which is the class the merge gate already treats as |
| 158 | sensitive (`mergegate/sensitive.go:34`), and Equipo cannot create repositories, |
| 159 | change settings or touch branch protection. |
| 160 | |
| 161 | **Where secrets live.** The App's private key is the only long-lived secret. |
| 162 | The instance keeps it, sealed at rest under a key derived from |
| 163 | `EQUIPO_INSTANCE_KEY`, and it never appears in a response, a frame, a log or |
| 164 | an audit row. The manifest's webhook and client secrets are discarded. The |
| 165 | runner holds nothing long-lived for GitHub. It gets tokens: |
| 166 | |
| 167 | - **A read token** for one active GitHub project: contents, pull requests, |
| 168 | checks, statuses and actions, all read. Given to the person's primary runner |
| 169 | when it asks (a step's start, the index, the merge watch), kept in memory |
| 170 | until shortly before it expires. |
| 171 | - **A write token** for exactly one repository: contents and pull requests |
| 172 | write. Minted only in the answer to a lease check for a publication or a |
| 173 | merge (`wire.LeaseCheck`, `wire/frames.go:405-427`), sealed to the runner's |
| 174 | seal key with `sealbox`, bound to the step, attempt and repository, used for |
| 175 | that one operation, then revoked by the runner (`DELETE /installation/token`) |
| 176 | and dropped. |
| 177 | |
| 178 | So a write on GitHub needs a decision the instance made a moment ago. On the |
| 179 | hub the runner's standing credential could write without one. A runner that is |
| 180 | taken over holds at most an hour of access to one repository. Mac workers hold |
| 181 | no forge credential, as today. |
| 182 | |
| 183 | **Revocation.** Disconnect in Equipo stops minting in the same transaction and |
| 184 | is audited. Uninstalling, suspending or deselecting a repository on GitHub |
| 185 | makes the next mint fail, and every operation needs a fresh mint, so GitHub's |
| 186 | answer is final whether or not Equipo has noticed yet. Equipo notices at the |
| 187 | next list (every 55 seconds while in use) and marks the connection or project. |
| 188 | |
| 189 | ### 3. Work on GitHub |
| 190 | |
| 191 | **Branches on the repository, no forks.** The App pushes `equipo/<task>` to the |
| 192 | repository itself, as on the hub. A bot has no namespace to fork into, and |
| 193 | forks only matter for repositories the team does not own. |
| 194 | |
| 195 | **Clone, fetch, push.** Unchanged code, a different remote: the URL is the key |
| 196 | with `https://`, the token goes in the same header git already takes from the |
| 197 | environment, never argv or a file. Pushes go out with an installation token, |
| 198 | so GitHub Actions run on them. |
| 199 | |
| 200 | **A draft pull request is the proposal.** After the first push, `Propose` |
| 201 | opens a draft pull request from the task branch into the default branch, or |
| 202 | updates the one it opened. A plan that cannot use drafts gets an ordinary one. |
| 203 | The runner reports its number and URL. The instance accepts the URL only as |
| 204 | `https://github.com/<the project's key>/pull/<n>` and stores it on the task; |
| 205 | `BranchURL` returns it. |
| 206 | |
| 207 | The title and body are built by code: the task's title, a link back to the |
| 208 | task, the candidate SHA, and where checks and review stand. The model's summary |
| 209 | goes in as a marked section after deterministic checks: bounded length, the |
| 210 | secret scan previews use, `@name` mentions made inert so nobody is notified, |
| 211 | and closing keywords ("fixes #12") made inert so model text cannot close an |
| 212 | issue. Equipo reads no pull request comments in this version. A comment |
| 213 | telling it to merge does nothing. |
| 214 | |
| 215 | When the task reaches Ready to merge, the runner marks the pull request ready |
| 216 | for review. That is when GitHub notifies code owners. |
| 217 | |
| 218 | **Checks.** The certificate is unchanged: the repository's own gate, taken from |
| 219 | the base commit, run in the runner's sandbox with no network (injection |
| 220 | defences, H1). GitHub Actions run workflow definitions from the candidate |
| 221 | branch, so they are hosted CI in the existing sense. `HostedCI` on GitHub reads |
| 222 | the candidate SHA's check runs and commit statuses in one snapshot and maps |
| 223 | them onto `forge.CIStatus`: all finished and passing is `success`; any failed, |
| 224 | cancelled or timed out is `failure`; none at all after a short wait is |
| 225 | `skipped`. The binding carries GitHub's run ids. On failure the failing job |
| 226 | names and a bounded log tail go to the fix round, quoted under a source label. |
| 227 | A hosted pass is asked about, never merged on its own |
| 228 | (`checks_sandbox = hosted`, as today). |
| 229 | |
| 230 | In practice a GitHub project whose checks need the network merges on a person's |
| 231 | tap until its gate runs in the sandbox. That is the same rule the hub has. |
| 232 | |
| 233 | **Merge.** `authorizeMerge` stays the one door, with its policy, audit row and |
| 234 | card. Only the last request differs. |
| 235 | |
| 236 | | Today, on the hub | On GitHub | |
| 237 | | --- | --- | |
| 238 | | Lease check `merge_request` right before the request | The same check; its answer carries the write token | |
| 239 | | `POST .../branches/<b>/merge` with `expect_sha` | `PUT /repos/<o>/<r>/pulls/<n>/merge` with `sha` set to the judged commit | |
| 240 | | `merged`, with the merge commit | The same, `merge_source: forge` | |
| 241 | | `moved` | GitHub's 409 on a head that moved: `branch_moved` | |
| 242 | | `conflicts` | Not mergeable, conflicting: `merge_conflict`, and the fix round | |
| 243 | | `ci_not_green`, pending | Required checks pending: `github_checks_pending`, deferred and asked again for up to 10 minutes, each time through the lease | |
| 244 | | `ci_not_green`, failed | Required checks failed: `github_checks_failed` | |
| 245 | | (none) | An approving review is required: `github_review_required`. The card links the pull request; a person approves on GitHub, then Merge works | |
| 246 | | (none) | Branch must be up to date: `github_branch_behind`, handled as a conflict (bring it up to date, judge again) | |
| 247 | | (none) | A merge queue is required: `github_merge_queue`. A person merges on GitHub; the watch reports the landing | |
| 248 | | Forbidden | 403: `merge_forbidden` | |
| 249 | |
| 250 | Equipo uses a merge commit when the repository allows one, so the receipt and |
| 251 | Undo work exactly as today. If the repository allows only squash or rebase, |
| 252 | Equipo uses that, the task is done, and the receipt offers no Undo in this |
| 253 | version. |
| 254 | |
| 255 | **Branch protection.** Equipo reads it and never changes or bypasses it. It has |
| 256 | no administration permission and does not ask to be on a bypass list. GitHub's |
| 257 | rules and Equipo's gate both have to pass. A person who merges or closes the |
| 258 | pull request on GitHub is seen by the merge watch (a landing) or the next read |
| 259 | of the pull request (closed: the task holds and says so). |
| 260 | |
| 261 | **Not in this version.** Creating GitHub repositories, GitHub Enterprise |
| 262 | Server, forks, issues, reading review comments into fix rounds, webhooks. |
| 263 | |
| 264 | ### 4. Projects up front |
| 265 | |
| 266 | **One list of what Equipo reaches.** The hub's entries come from the runner's |
| 267 | hello, as today. GitHub's come from the instance, which lists each connected |
| 268 | installation's repositories itself (name, description, default branch, |
| 269 | private or public, archived, last push) every 55 seconds while in use and |
| 270 | hourly otherwise, with ETags. So the GitHub half of the list works with the |
| 271 | runner offline. The runner clones and indexes only GitHub repositories that |
| 272 | are projects, not everything reachable. |
| 273 | |
| 274 | **The Projects page** (web, at the existing `/projects`): "Your projects", |
| 275 | starred first; then "Can add", grouped by connection, with a filter box. Each |
| 276 | row: title, a forge mark and `owner/name`, one line of description, what is in |
| 277 | flight. Owners see Add, and "Connect GitHub" or "Choose repositories on |
| 278 | GitHub". |
| 279 | |
| 280 | **Descriptions and names.** A project already has a title and a description |
| 281 | (`wire.Project`, `wire/api.go:299-325`). It gains **names**: what people call |
| 282 | it. Three sources, kept apart: |
| 283 | |
| 284 | - typed by an owner on the project page (the team's, trusted as a person's |
| 285 | words); |
| 286 | - learned for one person when they answer a placement card (theirs alone); |
| 287 | - read from the repository (README, manifests, GitHub's description): |
| 288 | untrusted, shown and searched, never decisive on their own. |
| 289 | |
| 290 | **Resolution is code.** `namedProject` (`chat/stars.go:239`) becomes the one |
| 291 | resolver for stars, placement and `find`: exact match on title, a trusted name |
| 292 | or the repository, across both forges. One match is the answer. None or |
| 293 | several is the existing placement card, with choices built by code from the |
| 294 | list, starred first. The person's tap picks a repository from that list, and |
| 295 | the word they typed is saved as their name for it. They are asked once. |
| 296 | |
| 297 | **The Coordinator sees the list every turn.** Each person turn carries a short |
| 298 | block built by the instance, not by the notebook: the person's starred |
| 299 | projects, then the most recently active, up to 30 lines, each with title, key, |
| 300 | trusted names and, quoted under its source, the description. The rest is one |
| 301 | `find` away. `find` searches both forges and says which is which. |
| 302 | |
| 303 | **Native apps.** Both read `GET /api/v1/projects`, which gains the connections |
| 304 | and the "Can add" entries with descriptions (the old `allowed` list stays for |
| 305 | old clients), and a device route for stars. |
| 306 | |
| 307 | - **iPhone:** a Projects tab. The list as above; a row opens the project: |
| 308 | title, description, repositories with their forge mark, star, tasks in |
| 309 | flight, and "New request". |
| 310 | - **Mac:** Projects in the sidebar, the list in the middle column, the project |
| 311 | in the detail pane, the same actions. |
| 312 | - **Picking a project when starting work.** The composer still has no picker |
| 313 | (design 13.4). "New request" on a project opens the composer with that |
| 314 | project shown as a removable chip, and the message carries `project_id`. |
| 315 | That is the person naming the project, so no question follows. From the |
| 316 | plain conversation, names resolve as above and the task card's chip still |
| 317 | corrects a wrong guess. |
| 318 | - Connecting GitHub opens the web. The apps show each connection's state. |
| 319 | |
| 320 | ### 5. Security and authority |
| 321 | |
| 322 | Per AGENTS.md, "Model text and authority": |
| 323 | |
| 324 | 1. **Model text never authorises.** The Coordinator cannot connect a forge, |
| 325 | choose an installation, or widen what is reachable. `add_project` still |
| 326 | grants nothing: what Equipo may write to was chosen by an admin on GitHub |
| 327 | and confirmed by an owner's tap. Names learned from the repository never |
| 328 | decide placement. Approvals and comments on GitHub are not read as |
| 329 | authority. |
| 330 | 2. **A change never authorises its own merge.** GitHub Actions results are |
| 331 | candidate-controlled and stay feedback. The token for a merge is minted |
| 332 | only after `authorizeMerge` says act. |
| 333 | 3. **Untrusted text is quoted and labelled.** Repository descriptions, check |
| 334 | names, log tails and GitHub's error sentences enter prompts only quoted |
| 335 | under a source label, bounded and redacted. |
| 336 | 4. **Writes that leave the system.** A branch push and a draft pull request |
| 337 | on a private repository rest on a standing setting people chose: the |
| 338 | repository selected on GitHub plus the owner's Connect. On a public |
| 339 | repository a pull request is public, so it needs the person's tap on the |
| 340 | task card unless an owner turned on "Open pull requests without asking" for |
| 341 | that project. Merge needs the person's tap or the project's merge policy, |
| 342 | as today. Deterministic checks guard every one: the forge's push checks, |
| 343 | the pull request body's checks, the merge gate. |
| 344 | 5. **No secret reaches a prompt or a log.** The key stays on the instance, |
| 345 | sealed. Tokens travel sealed, live in the runner's memory, reach git through |
| 346 | an environment header and the API with redirects refused, and are added to |
| 347 | the redactor and the secret scan by shape. GitHub's answers are redacted |
| 348 | before they are reported. |
| 349 | 6. **The sandbox has no network** and never holds a token. Pushes are made by |
| 350 | the runner from its private repository, outside the sandbox, as today. |
| 351 | |
| 352 | Data rules: connections are team records; only owners connect, disconnect and |
| 353 | add; the roster is checked inside each write transaction; each of create, |
| 354 | connect, disconnect, add, write-token mint, pull request and merge appends an |
| 355 | audit event in its transaction with no credential in it. Migrations are |
| 356 | additive. |
| 357 | |
| 358 | ### 6. Migration |
| 359 | |
| 360 | Existing hub projects keep working unchanged. Keys, `amadan.json`, the access |
| 361 | request flow, hosted CI, merge and the reasons `amadan_ci_*` stay as they are; |
| 362 | `fileForge` becomes the hub's `Forge` behind the router with no behaviour |
| 363 | change, and the first slice proves that with the existing tests. New tables |
| 364 | only: forge connections, reachable GitHub repositories, project names; new |
| 365 | optional columns for a task's proposal. GitHub work needs a runner at a new |
| 366 | protocol number. An older runner is refused GitHub steps with "your runner |
| 367 | needs an update", never downgraded. |
| 368 | |
| 369 | ## Decisions for Paul |
| 370 | |
| 371 | | | Decision | Recommendation | |
| 372 | | --- | --- | --- | |
| 373 | | G1 | How Equipo signs in to GitHub | A GitHub App. Not OAuth and not personal tokens: both act as a person, live long and reach too much. | |
| 374 | | G2 | Whose App it is | One private App per connected GitHub account, created from the team's own instance by GitHub's manifest flow. No shared secret and no central service. The alternative, one Oficina-wide App, saves one click per team and needs a broker holding a key that reaches every team's repositories. | |
| 375 | | G3 | Where the App's key lives | On the instance, sealed, with one-hour, one-repository tokens handed to the runner inside a lease. Nothing long-lived on the runner, and no write without a fresh decision. The alternative, the key on the runner like `amadan.json`, keeps the instance free of secrets but puts a standing key on the machine that runs agent-chosen code. | |
| 376 | | G4 | What the App may do | Contents and pull requests write; checks, statuses and actions read. No workflows and no administration, so Equipo cannot edit GitHub Actions workflows, create repositories or change protection. A task that needs a workflow change ends with a branch a person finishes. | |
| 377 | | G5 | Branches or forks | Branches `equipo/<task>` on the repository. No forks in this version. | |
| 378 | | G6 | When a pull request opens | A draft at the first push, without asking, on private repositories. On public repositories, on the person's tap, unless an owner turns on "Open pull requests without asking" for the project. | |
| 379 | | G7 | How Equipo merges on GitHub | The pull request merge API with the judged SHA. A merge commit when the repository allows it (Undo works as today); otherwise the method it allows, with no Undo yet. | |
| 380 | | G8 | Do GitHub Actions count as checks | As feedback and as GitHub's own gate, never as Equipo's certificate. Automatic merge still needs the base-run gate to pass in the sandbox, the rule the hub has. Until then GitHub projects merge on your tap. | |
| 381 | | G9 | Webhooks | None in this version. Polling, as the hub does. Every write needs a fresh token, so a revocation on GitHub holds at once without them. Add them later for speed. | |
| 382 | | G10 | Names the Coordinator learns | A name you use when answering "Where should this go?" is saved for you alone. Names for the whole team are typed by an owner on the project. | |
| 383 | | G11 | Starting from a project in the apps | A Projects tab on iPhone and a sidebar item on the Mac. "New request" on a project carries the project as a chip. The composer itself keeps no picker (your ruling, design 13.4). | |
| 384 | | G12 | What ships first | Projects up front for the hub (parts 1 and 4), before any GitHub work. It fixes the guessing today and GitHub then appears in a list that already exists. | |
| 385 | |
| 386 | ## Gates |
| 387 | |
| 388 | - **Probe first**, against a scratch GitHub org, recorded beside this spec. |
| 389 | It confirms each GitHub behaviour relied on here before anything is built: |
| 390 | the manifest flow under an org; tokens narrowed by repository and |
| 391 | permission, and their revocation; a workflow-file push refused without the |
| 392 | workflows permission; Actions running on an App's push; the merge call's |
| 393 | answers for each row of the merge table; draft and ready; that the instance |
| 394 | on CARLOS reaches `api.github.com`. |
| 395 | - Tests first, each guard broken on purpose and seen to fail (AGENTS.md). |
| 396 | - The seam slice changes no hub behaviour: the existing forge, merge, hosted |
| 397 | CI and access tests pass untouched. |
| 398 | - Contract tests for the new wire fields at the new protocol, with an older |
| 399 | runner refused. The device API's OpenAPI document covers the new routes. |
| 400 | - A fake GitHub (`forgetest`) for every answer in the merge table, a token |
| 401 | that never appears in logs, reports, frames or prompts (searched for by |
| 402 | value), and a stale or replayed sealed token refused. |
| 403 | - A live run on a scratch repository: connect, add, a task to a draft pull |
| 404 | request, checks shown, merge on tap, disconnect. |
| 405 | - Copy review for every new string (`copy.go`), then one review (Fable, or |
| 406 | Codex Astra while Fable is limited). Paul lands each branch. |
| 407 | |
| 408 | ## Order |
| 409 | |
| 410 | 1. Probe (no product code). |
| 411 | 2. The forge key and the seam: `forgekey`, the router, the renames. Hub only. |
| 412 | 3. Projects up front on the hub: the list, names, the resolver, the turn's |
| 413 | project block, the device routes, then the native Projects screens. |
| 414 | 4. Connect GitHub: the App, the installation, Connect, the reachable list, |
| 415 | read tokens. GitHub repositories can be added, read and asked about. |
| 416 | 5. Work on GitHub: push, the draft pull request, GitHub's checks on the card. |
| 417 | 6. Merge on GitHub on a person's tap, then under the existing merge policy. |
| 418 | |