# GitHub egress check, 2026-11-23

Base: main `f623151c`. Branch: `github/egress-check`.

The command `equipo check-github` runs before configuration, database, mail
and serving. It sends one unauthenticated GET to
`https://api.github.com/meta`, directly, with a five-second overall timeout.
It refuses redirects, verifies TLS, bounds response headers to 16 KiB and
reads no response body. It has no configurable target, credentials, cookies,
environment proxy or retry. No production command has been run by this branch.

Output contains only verified TLS reachability, numeric HTTP status, elapsed
time and the connected TLS peer's IP and port. Status is zero without an HTTP
response; peer is `-` without a verified TLS connection. Reachability means a
response over verified TLS, including a refused redirect or HTTP failure.
Exit zero additionally requires HTTP 2xx and successful output. All other
outcomes exit one, without printing raw errors, headers or body text.

## Run after the controller deploys this version

```sh
carlos run --app equipo --account oficina \
  --console https://console.carloku.com \
  --instance equipo.bds.oncarlos.com --timeout 15s -- check-github
```

The values are `APP`, `ACCOUNT`, `CONSOLE` and `HOST` in
`scripts/upgrade-thin.sh:47`. `carlos run --help` confirms that `--instance`
takes the instance host and arguments following `--` go to the app binary.
The public alias is not used as the instance identifier. The separate staging
values live in `scripts/staging-thin.py:48` (app `equipo-staging`, account
`bds`, host `equipo-staging.bds.oncarlos.com`). This branch neither deploys
nor claims that CARLOS egress has passed; the controller records that result.

## Tests and mutations

Tests were written before implementation. Against compiling empty stubs,
`TestCheckGitHubCommand`, `TestCheckGitHubRefusesRedirect`,
`TestCheckGitHubDoesNotReadBody` and `TestCheckGitHubRequiresVerifiedTLS`
failed at runtime. The entry-point test first failed with the normal missing
instance-key boot refusal, then passed with command dispatch before boot.

Commands use `GOTOOLCHAIN=go1.26.11 CGO_ENABLED=0`. Each mutation is applied
alone, run with `go test ./cmd/equipo -run '^<test>$' -count=1 -timeout=20s`,
and restored. Compilation failures do not count.

| Mutation | Killing test |
| --- | --- |
| Match `serve` instead of `check-github` | `TestCheckGitHubCommand` |
| Change the fixed path to `/zen` | `TestCheckGitHubCommand` |
| Send POST instead of GET | `TestCheckGitHubCommand` |
| Follow redirects | `TestCheckGitHubRefusesRedirect` |
| Copy the response body to output | `TestCheckGitHubCommand` |
| Drain the response body | `TestCheckGitHubDoesNotReadBody` |
| Remove the overall timeout | `TestCheckGitHubFailureIsBoundedAndPrivate` |
| Use the environment proxy | `TestCheckGitHubFailureIsBoundedAndPrivate` |
| Remove the response-header bound | `TestCheckGitHubFailureIsBoundedAndPrivate` |
| Accept a TLS response without a verified chain | `TestCheckGitHubUnverifiedPeerAndHTTPFailure` |
| Report an unverified TLS peer | `TestCheckGitHubUnverifiedPeerAndHTTPFailure` |
| Omit the resolved peer | `TestCheckGitHubCommand` |
| Accept HTTP 503 as success | `TestCheckGitHubUnverifiedPeerAndHTTPFailure` |
| Ignore failed output | `TestCheckGitHubOutputFailure` |
| Run boot before the diagnostic | `TestCheckGitHubBypassesBoot` |

Fake servers bind loopback and use generated test TLS certificates. No real
GitHub App, key or token is used. The tests also check absent authorization
and cookies, one request, one output line, no header/body sentinel, TLS
certificate rejection, cancellation and the exact command argument boundary.

## Copy

Only `CopyGitHubEgress` is new:

```text
GitHub reachable: %t; status: %d; latency: %s; TLS peer: %s\n
```

It was marked pending with `scripts/copy-status.py pending`. The controller
returned Luna's verdict in message `08a0554d-dcc7-4ef9-8aa6-0121e13a9a88`:

> Luna: APPROVED as is. Mark it `// COPY ACCEPTED BY DELEGATION (Luna, 2026-11-23)`, then carry on.

The exact accepted value, inventory row and bounded release-test key reflect
that verdict. The `accept` command was not invoked.

## Gates

Results are recorded below before handoff. No device routes, OpenAPI changes,
wire fields, protocol changes, migrations or connector behavior are added.
Only measured size ceilings change: equipo 22109 to 22112 source lines for
copy; plan3test 11899 to 11900 test lines for the accepted key. No time budget
changes. Existing test assertions and names are unchanged.

- All 15 mutations above failed at runtime; restored tests passed.
- `make fmt-check budget migration-check copy-release-check lanes-check spacing`: passed.
- `make gitleaks`: passed on base history; repeated after committing below.
- `go test -tags testbuild ./cmd/equipo ./internal/equipo ./internal/equipo/chat ./internal/thintest -count=1`: passed (1.210s, 31.465s, 5.717s, 171.974s).
- `go test -tags testbuild ./internal/plan3test -run 'TestPersonAPI|TestPlan3Release' -count=1`: passed (12.877s).
- `go test ./internal/testci -run TestBudgetRecordsAreShort -count=1`: passed.
- `go vet ./cmd/equipo` and pinned staticcheck v0.7.0 for that package: passed.
- `python3 native/scripts/check-fixtures.py`: passed (11 API fixtures, 3586 Markdown fixtures, 32000 seeded differential cases).
- Post-commit reference scan, committed-history secret scan and Linux CI are reported with the pushed SHA in the handoff.
