oficina / equipo Public

Clone
git clone https://amadan.net/oficina/equipo

Plain git — no account needed to clone.

Download

Download this file

Equipo connects to GitHub, and knows its projects up front (spec, 2026-11-22)

Status: APPROVED by Paul on 2026-11-22 with every recommendation (G1 to G12). Not implemented. Author: Claude (claude-fable-5-2), from main 3ef3ec85. File and line references are to that commit.

Why

Paul, 2026-11-22: "Tito is on GitHub. I guess we probably need a GitHub connector too if we expect anyone to use this." And: "we need a more streamlined way of making the agent aware about actual projects." The Coordinator found oficina/home only because it guessed the hub name from a conversation.

Today every code operation assumes the Amadan hub. A repository is the string amadan.net/<namespace>/<name>, the runner on docs-t1 holds one standing agent credential in amadan.json, and the Coordinator learns what exists from a move-in turn and its notebook, not from a list.

This spec does two things. It gives Equipo a second forge, GitHub, behind the seam the runner already has. And it gives every forge one Projects list that people and the Coordinator both read.

What a person sees

  1. Connect. An owner opens Settings, then Connections, and taps "Connect GitHub". GitHub shows "Create GitHub App for <team>"; they confirm, pick the account (Tito), choose "Only select repositories", and come back to Equipo, which shows "Connect tito: 3 repositories" with one Connect button. That tap makes it live. This is done on the web; the native apps show the connection's state and a link to set it up.
  2. Projects. One Projects list. Your starred projects first, then the team's other projects, then "Can add": every repository Equipo reaches on each connected forge that is not a project yet, grouped as "Amadan" and "GitHub, tito". Each row has a title, the repository, and one line saying what it is. An owner adds a project with one tap. Anyone stars their own.
  3. Names resolve. "Fix the invoice total in Tito" goes to Tito without a question. When a name fits two projects or none, the Coordinator asks once with the existing "Where should this go?" card, starred projects first. Equipo remembers the name you used, for you.
  4. Work on a GitHub project. The task card reads as it does today. Its branch link becomes "Pull request #214". Engineering pushes a branch equipo/<task> to the repository and opens a draft pull request. GitHub's own checks show on the card as they finish.
  5. Merge. The merge card is the same card. Merge sends GitHub the merge for the exact commit that was judged. If GitHub will not merge it, the card says why in GitHub's terms ("GitHub needs an approving review", "GitHub's required checks have not finished") with a link to the pull request. A person who merges on GitHub instead sees the task finish on its own.
  6. Not reachable. Asked about a GitHub repository outside the connection, the Coordinator shows a card with "Choose repositories on GitHub", which opens the App's settings on GitHub. No request is filed on anyone's behalf.
  7. Disconnect. An owner taps Disconnect, or a GitHub admin uninstalls the App. Either one stops all GitHub work at once. Projects stay listed, marked "GitHub is not connected".

How (the parts, in order)

1. The forge seam today

The runner already has an interface, thin.Forge (internal/runner/thin/forge.go:31-53), with one implementation, fileForge, and two optional extras (HostedCI, AccessForge). The hub is assumed in the shape of the repository key and in a fixed host, not only behind the interface.

| What | Where it assumes the hub | | --- | --- | | 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). | | 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. | | 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). | | 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). | | 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). | | 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). | | 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). | | 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. | | 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. | | 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). | | 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). | | Prompts | Display names strip the hub prefix: thin/claude.go:870,939, thin/engineer.go:596, thin/judge.go:981. | | 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). | | 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. | | 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. |

The smallest interface. Keep thin.Forge. Change three things.

type Forge interface {
	Host() string                 // "amadan.net" or "github.com"
	Repos() []string
	Reachable(ctx) []string
	Recheck()
	Agent() string
	Remote(ctx, repo string, use Use) (workspace.Remote, error) // Use: read or push
	Exists(ctx, repo string) (bool, error)
	CreateIn(ctx) []string
	Create(ctx, repo string) error
	Propose(ctx, Proposal) (ProposalRef, error)                 // new
	Merge(ctx, repo, branch string, req forge.MergeRequest) (forge.MergeResult, error)
}
  • HubMergeRequest and HubMergeResult lose "Hub" from their names. Their fields already fit both forges (the judged SHA, message, strategy; merged, SHA, into, reason, CI state, sentence).
  • Propose is new. After a push, the forge says where a person looks at the change. The hub answers with the branch page and does nothing else. GitHub opens or updates the draft pull request.
  • workspace.Remote gains a user name (GitHub's is x-access-token).

HostedCI and AccessForge keep their shape. A router, Forges, implements Forge by sending each call to the forge whose Host() the key names. One package, wire/forgekey, owns the key: parse, validate and display for a closed list of hosts. Every regexp and prefix in the table above calls it. A bare ns/name still means the hub.

A GitHub key is github.com/<owner>/<name> in GitHub's own spelling, compared without case. The project also stores GitHub's numeric repository id, so a rename or transfer updates the key instead of orphaning the project.

2. GitHub auth

| | GitHub App | OAuth app | Personal access token | | --- | --- | --- | --- | | Acts as | Its own bot, named in every commit, pull request and merge | The person | The person | | Reach | The repositories an org admin selects | Every repository the person can see | Selected repositories (fine-grained) or all (classic) | | Token life | 1 hour, minted on demand, can be narrowed to one repository | Long, until revoked | Up to a year | | Revoke | Uninstall or suspend on GitHub, or Disconnect in Equipo | The person, per app | The person, per token | | A person leaves | Nothing breaks | Their work stops | Their work stops |

Recommended: a GitHub App. The other two put a person's credential behind an agent, which Equipo's design rules out (design section 6.2: "never a person's credential") and the suite doctrine forbids (a write names its real actor).

One private App per connected GitHub account, made from the team's own instance with GitHub's App manifest flow. The App belongs to the account it serves (the tito org), can be installed only there, and shows in that org's own settings where its admins can audit or delete it. No secret is shared between teams and nothing central has to be run. A team with two accounts connects twice.

Who does what:

  • An Equipo owner starts the connection. Their session, a single-use state value and a 10 minute limit bind both GitHub redirects.
  • A GitHub org owner (or the person, for a personal account) creates and installs the App and selects the repositories. A member who is not an org owner can only request it; GitHub asks the org's owners.
  • Back in Equipo, the instance reads the installation from GitHub with the App's own key (never trusting the id in the redirect), shows the account and the repository count, and waits for the owner's tap on Connect.

Permissions asked for: metadata read; contents read and write; pull requests read and write; checks, commit statuses and actions read. Not asked for: workflows and administration. So GitHub itself refuses a push that edits .github/workflows, which is the class the merge gate already treats as sensitive (mergegate/sensitive.go:34), and Equipo cannot create repositories, change settings or touch branch protection.

Where secrets live. The App's private key is the only long-lived secret. The instance keeps it, sealed at rest under a key derived from EQUIPO_INSTANCE_KEY, and it never appears in a response, a frame, a log or an audit row. The manifest's webhook and client secrets are discarded. The runner holds nothing long-lived for GitHub. It gets tokens:

  • A read token for one active GitHub project: contents, pull requests, checks, statuses and actions, all read. Given to the person's primary runner when it asks (a step's start, the index, the merge watch), kept in memory until shortly before it expires.
  • A write token for exactly one repository: contents and pull requests write. Minted only in the answer to a lease check for a publication or a merge (wire.LeaseCheck, wire/frames.go:405-427), sealed to the runner's seal key with sealbox, bound to the step, attempt and repository, used for that one operation, then revoked by the runner (DELETE /installation/token) and dropped.

So a write on GitHub needs a decision the instance made a moment ago. On the hub the runner's standing credential could write without one. A runner that is taken over holds at most an hour of access to one repository. Mac workers hold no forge credential, as today.

Revocation. Disconnect in Equipo stops minting in the same transaction and is audited. Uninstalling, suspending or deselecting a repository on GitHub makes the next mint fail, and every operation needs a fresh mint, so GitHub's answer is final whether or not Equipo has noticed yet. Equipo notices at the next list (every 55 seconds while in use) and marks the connection or project.

3. Work on GitHub

Branches on the repository, no forks. The App pushes equipo/<task> to the repository itself, as on the hub. A bot has no namespace to fork into, and forks only matter for repositories the team does not own.

Clone, fetch, push. Unchanged code, a different remote: the URL is the key with https://, the token goes in the same header git already takes from the environment, never argv or a file. Pushes go out with an installation token, so GitHub Actions run on them.

A draft pull request is the proposal. After the first push, Propose opens a draft pull request from the task branch into the default branch, or updates the one it opened. A plan that cannot use drafts gets an ordinary one. The runner reports its number and URL. The instance accepts the URL only as https://github.com/<the project's key>/pull/<n> and stores it on the task; BranchURL returns it.

The title and body are built by code: the task's title, a link back to the task, the candidate SHA, and where checks and review stand. The model's summary goes in as a marked section after deterministic checks: bounded length, the secret scan previews use, @name mentions made inert so nobody is notified, and closing keywords ("fixes #12") made inert so model text cannot close an issue. Equipo reads no pull request comments in this version. A comment telling it to merge does nothing.

When the task reaches Ready to merge, the runner marks the pull request ready for review. That is when GitHub notifies code owners.

Checks. The certificate is unchanged: the repository's own gate, taken from the base commit, run in the runner's sandbox with no network (injection defences, H1). GitHub Actions run workflow definitions from the candidate branch, so they are hosted CI in the existing sense. HostedCI on GitHub reads the candidate SHA's check runs and commit statuses in one snapshot and maps them onto forge.CIStatus: all finished and passing is success; any failed, cancelled or timed out is failure; none at all after a short wait is skipped. The binding carries GitHub's run ids. On failure the failing job names and a bounded log tail go to the fix round, quoted under a source label. A hosted pass is asked about, never merged on its own (checks_sandbox = hosted, as today).

In practice a GitHub project whose checks need the network merges on a person's tap until its gate runs in the sandbox. That is the same rule the hub has.

Merge. authorizeMerge stays the one door, with its policy, audit row and card. Only the last request differs.

| Today, on the hub | On GitHub | | --- | --- | | Lease check merge_request right before the request | The same check; its answer carries the write token | | POST .../branches/<b>/merge with expect_sha | PUT /repos/<o>/<r>/pulls/<n>/merge with sha set to the judged commit | | merged, with the merge commit | The same, merge_source: forge | | moved | GitHub's 409 on a head that moved: branch_moved | | conflicts | Not mergeable, conflicting: merge_conflict, and the fix round | | ci_not_green, pending | Required checks pending: github_checks_pending, deferred and asked again for up to 10 minutes, each time through the lease | | ci_not_green, failed | Required checks failed: github_checks_failed | | (none) | An approving review is required: github_review_required. The card links the pull request; a person approves on GitHub, then Merge works | | (none) | Branch must be up to date: github_branch_behind, handled as a conflict (bring it up to date, judge again) | | (none) | A merge queue is required: github_merge_queue. A person merges on GitHub; the watch reports the landing | | Forbidden | 403: merge_forbidden |

Equipo uses a merge commit when the repository allows one, so the receipt and Undo work exactly as today. If the repository allows only squash or rebase, Equipo uses that, the task is done, and the receipt offers no Undo in this version.

Branch protection. Equipo reads it and never changes or bypasses it. It has no administration permission and does not ask to be on a bypass list. GitHub's rules and Equipo's gate both have to pass. A person who merges or closes the pull request on GitHub is seen by the merge watch (a landing) or the next read of the pull request (closed: the task holds and says so).

Not in this version. Creating GitHub repositories, GitHub Enterprise Server, forks, issues, reading review comments into fix rounds, webhooks.

4. Projects up front

One list of what Equipo reaches. The hub's entries come from the runner's hello, as today. GitHub's come from the instance, which lists each connected installation's repositories itself (name, description, default branch, private or public, archived, last push) every 55 seconds while in use and hourly otherwise, with ETags. So the GitHub half of the list works with the runner offline. The runner clones and indexes only GitHub repositories that are projects, not everything reachable.

The Projects page (web, at the existing /projects): "Your projects", starred first; then "Can add", grouped by connection, with a filter box. Each row: title, a forge mark and owner/name, one line of description, what is in flight. Owners see Add, and "Connect GitHub" or "Choose repositories on GitHub".

Descriptions and names. A project already has a title and a description (wire.Project, wire/api.go:299-325). It gains names: what people call it. Three sources, kept apart:

  • typed by an owner on the project page (the team's, trusted as a person's words);
  • learned for one person when they answer a placement card (theirs alone);
  • read from the repository (README, manifests, GitHub's description): untrusted, shown and searched, never decisive on their own.

Resolution is code. namedProject (chat/stars.go:239) becomes the one resolver for stars, placement and find: exact match on title, a trusted name or the repository, across both forges. One match is the answer. None or several is the existing placement card, with choices built by code from the list, starred first. The person's tap picks a repository from that list, and the word they typed is saved as their name for it. They are asked once.

The Coordinator sees the list every turn. Each person turn carries a short block built by the instance, not by the notebook: the person's starred projects, then the most recently active, up to 30 lines, each with title, key, trusted names and, quoted under its source, the description. The rest is one find away. find searches both forges and says which is which.

Native apps. Both read GET /api/v1/projects, which gains the connections and the "Can add" entries with descriptions (the old allowed list stays for old clients), and a device route for stars.

  • iPhone: a Projects tab. The list as above; a row opens the project: title, description, repositories with their forge mark, star, tasks in flight, and "New request".
  • Mac: Projects in the sidebar, the list in the middle column, the project in the detail pane, the same actions.
  • Picking a project when starting work. The composer still has no picker (design 13.4). "New request" on a project opens the composer with that project shown as a removable chip, and the message carries project_id. That is the person naming the project, so no question follows. From the plain conversation, names resolve as above and the task card's chip still corrects a wrong guess.
  • Connecting GitHub opens the web. The apps show each connection's state.

5. Security and authority

Per AGENTS.md, "Model text and authority":

  1. Model text never authorises. The Coordinator cannot connect a forge, choose an installation, or widen what is reachable. add_project still grants nothing: what Equipo may write to was chosen by an admin on GitHub and confirmed by an owner's tap. Names learned from the repository never decide placement. Approvals and comments on GitHub are not read as authority.
  2. A change never authorises its own merge. GitHub Actions results are candidate-controlled and stay feedback. The token for a merge is minted only after authorizeMerge says act.
  3. Untrusted text is quoted and labelled. Repository descriptions, check names, log tails and GitHub's error sentences enter prompts only quoted under a source label, bounded and redacted.
  4. Writes that leave the system. A branch push and a draft pull request on a private repository rest on a standing setting people chose: the repository selected on GitHub plus the owner's Connect. On a public repository a pull request is public, so it needs the person's tap on the task card unless an owner turned on "Open pull requests without asking" for that project. Merge needs the person's tap or the project's merge policy, as today. Deterministic checks guard every one: the forge's push checks, the pull request body's checks, the merge gate.
  5. No secret reaches a prompt or a log. The key stays on the instance, sealed. Tokens travel sealed, live in the runner's memory, reach git through an environment header and the API with redirects refused, and are added to the redactor and the secret scan by shape. GitHub's answers are redacted before they are reported.
  6. The sandbox has no network and never holds a token. Pushes are made by the runner from its private repository, outside the sandbox, as today.

Data rules: connections are team records; only owners connect, disconnect and add; the roster is checked inside each write transaction; each of create, connect, disconnect, add, write-token mint, pull request and merge appends an audit event in its transaction with no credential in it. Migrations are additive.

6. Migration

Existing hub projects keep working unchanged. Keys, amadan.json, the access request flow, hosted CI, merge and the reasons amadan_ci_* stay as they are; fileForge becomes the hub's Forge behind the router with no behaviour change, and the first slice proves that with the existing tests. New tables only: forge connections, reachable GitHub repositories, project names; new optional columns for a task's proposal. GitHub work needs a runner at a new protocol number. An older runner is refused GitHub steps with "your runner needs an update", never downgraded.

Decisions for Paul

| | Decision | Recommendation | | --- | --- | --- | | 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. | | 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. | | 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. | | 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. | | G5 | Branches or forks | Branches equipo/<task> on the repository. No forks in this version. | | 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. | | 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. | | 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. | | 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. | | 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. | | 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). | | 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. |

Gates

  • Probe first, against a scratch GitHub org, recorded beside this spec. It confirms each GitHub behaviour relied on here before anything is built: the manifest flow under an org; tokens narrowed by repository and permission, and their revocation; a workflow-file push refused without the workflows permission; Actions running on an App's push; the merge call's answers for each row of the merge table; draft and ready; that the instance on CARLOS reaches api.github.com.
  • Tests first, each guard broken on purpose and seen to fail (AGENTS.md).
  • The seam slice changes no hub behaviour: the existing forge, merge, hosted CI and access tests pass untouched.
  • Contract tests for the new wire fields at the new protocol, with an older runner refused. The device API's OpenAPI document covers the new routes.
  • A fake GitHub (forgetest) for every answer in the merge table, a token that never appears in logs, reports, frames or prompts (searched for by value), and a stale or replayed sealed token refused.
  • A live run on a scratch repository: connect, add, a task to a draft pull request, checks shown, merge on tap, disconnect.
  • Copy review for every new string (copy.go), then one review (Fable, or Codex Astra while Fable is limited). Paul lands each branch.

Order

  1. Probe (no product code).
  2. The forge key and the seam: forgekey, the router, the renames. Hub only.
  3. Projects up front on the hub: the list, names, the resolver, the turn's project block, the device routes, then the native Projects screens.
  4. Connect GitHub: the App, the installation, Connect, the reachable list, read tokens. GitHub repositories can be added, read and asked about.
  5. Work on GitHub: push, the draft pull request, GitHub's checks on the card.
  6. Merge on GitHub on a person's tap, then under the existing merge policy.