| 1 | # Brief: amadan git transport needs a PAT via Basic auth, not the agent bearer |
| 2 | |
| 3 | Branch `forge-git-auth` from main e99d178 (deployed). Observed on |
| 4 | amadan.net today: |
| 5 | - Agent bearer token (minted by `amadan agent token create`) works for |
| 6 | the hub API with `Authorization: Bearer` (GET |
| 7 | /api/v1/repos/oficina/equipo/branches/main/description → 200). |
| 8 | - Git smart HTTP (`https://amadan.net/oficina/equipo`) rejects |
| 9 | `Authorization: Bearer <agent token>` (git asks for a username) and |
| 10 | rejects Basic with the agent token as password ("Authentication |
| 11 | failed"). It ACCEPTS Basic with a PAT as password, any username |
| 12 | (`amadan tokens create`, run as the agent via AMADAN_HOME, says |
| 13 | "Use it as your git password ... username is ignored"). |
| 14 | Equipo's runner sends `http.extraHeader=Authorization: Bearer <token>` |
| 15 | for git fetch/push (internal/runner/workspace/workspace.go ~250, |
| 16 | internal/runner/forge/publisher.go), so every real task would fail at |
| 17 | fetch. |
| 18 | |
| 19 | Fix: |
| 20 | - Credential file (EQUIPO_AMADAN_CREDENTIAL_PATH, forgeCredentialFile |
| 21 | in internal/runner/runtime_workflow.go): add a per-repository git |
| 22 | password (PAT) alongside the API bearer, e.g. |
| 23 | {"agent": "...", "repositories": {"amadan.net/ns/repo": {"api": "<bearer>", |
| 24 | "git": "<pat>"}}}; keep reading the old string form as API-only and |
| 25 | refuse git without a PAT with a clear config issue. |
| 26 | - Git transport uses `Authorization: Basic base64("x:"+pat)` via the |
| 27 | same GIT_CONFIG_* env mechanism (never on the command line, never |
| 28 | logged); API calls keep Bearer. Update forge.Credential/workspace.Remote |
| 29 | types, validation, tests (including no leak into argv, logs, journal, |
| 30 | provider sandboxes; the credential file stays a protected path). |
| 31 | - Docs: how to mint both for an agent (agent token create; then |
| 32 | AMADAN_HOME=<agent home> amadan tokens create) in docs/live-gate.md or |
| 33 | README runner section (copy accepted for now; plain). |
| 34 | Live check allowed: read-only `git ls-remote`/fetch of |
| 35 | amadan.net/oficina/equipo through the runner's workspace code path using |
| 36 | the existing file on docs-t1 after the controller converts it (do NOT |
| 37 | read or print token values; the controller will convert the file). Write |
| 38 | the exact conversion steps for the controller (a python snippet that |
| 39 | reads ~/.local/share/equipo-runner/amadan.json and |
| 40 | ~/.local/share/equipo-runner/amadan-agent-home/git-pat and writes the new |
| 41 | format atomically, 0600, printing nothing secret). Targeted tests, ONE |
| 42 | full `make -k ci` (rerun at most twice). Commit subject < 80, body |
| 43 | `Co-Authored-By: Astra <noreply@openai.com>`, push. |
| 44 | CONTROLLER-REPORT-forge-git-auth.md. No deploys, no pushes to other |
| 45 | repos, no provider launches. Scratch removed; no copy-review server. |
| 46 | Print a five-line summary. |
| 47 | |