# GitHub App connection: implementation evidence

Branch `github/connect-app`, based on main `eff421c7`.
The controller approved the step-4 plan and assigned branch A on 2026-11-23.
Implementation and local verification are complete. Linux CI is the final
runner gate; its fixed commit and verdict are reported with the branch handoff.

## Scope and order

1. Token/key shape redaction and generated-key fake GitHub HTTP contract.
2. Primary-database forge connection lifecycle, sealed App key, additive schema,
   owner checks, single-use callbacks and same-transaction audit records.
3. Owner-only Settings section and manifest CSP, disabled by default.
4. Lifetime, concurrency, value-search, browser and copy-rendering regressions.
5. Individual guard mutations, local gates, commit, reference scan, push, CI.

The controller's final implementation rulings supersede the plan where needed:
only one pending setup per team; Start replaces it regardless of account,
except an already-connected account leaves it untouched. Any current owner
may Check again, Connect, supersede or Disconnect. More than 1000 repositories
means an unknown snapshot with no Connect action until Check again obtains a
complete count within the limit. Branch B renders down Projects groups with
`github.group` plus `github.not_connected` or `github.suspended` and tests them.

## Test-first evidence

- `GOTOOLCHAIN=go1.26.11 CGO_ENABLED=0 go test ./internal/runnerproto -run TestGitHubSecretShapes -count=1`
  failed first for all four GitHub token prefixes and all full/truncated PEM
  forms, then passed after shape redaction was implemented. The test supplies
  no known-secret list and checks nested JSON as well as plain text.

## Mutation evidence

Each mutation below was applied separately, the named test failed at runtime,
and the source was restored. The final restored test passed.

| Guard removed | Killing test |
| --- | --- |
| ghs_ recognition | TestGitHubSecretShapes/ghs_ |
| ghu_ recognition | TestGitHubSecretShapes/ghu_ |
| gho_ recognition | TestGitHubSecretShapes/gho_ |
| ghr_ recognition | TestGitHubSecretShapes/ghr_ |
| PEM block redaction | TestGitHubSecretShapes, full and truncated key cases |

## Copy

Use only the 39 keys and exact Luna-reviewed values in
[the copy brief](2026-11-23-github-connect-copy.md). Runtime inventory and
release acceptance list only keys actually introduced by this branch.

## App API contract, first pass

`GOTOOLCHAIN=go1.26.11 CGO_ENABLED=0 go test ./internal/equipo/github -count=1`
first failed at runtime against the API stubs, then passed (2.292s). Tests
cover conversion with generated RSA keys, signed App JWTs, installation reads,
selected/all modes, metadata-only token requests and memory reuse/revocation,
redirect refusal, status classification including 403 rate limits, bounded
responses and complete inventories of 0, 100, 101, 1000 and 1001 repositories.
The later guards and HTTP value-search tests below complete the malformed-scope,
concurrency and sink coverage.

## Key sealing evidence

`go test ./internal/equipo/github -run TestAppKeySealing -count=1` failed
against the stub, then passed. Six separate mutations were killed: omit the
origin binding, omit connection binding, omit App ID binding, use a fixed
instance key, reuse the device-result purpose, and clear the random nonce.
The restored test passed. The test also refuses corrupt ciphertext and checks
that encoding alone cannot hide the plaintext.

## Lifecycle and API mutation run

Each command uses the pinned toolchain: `go test ./internal/equipo/github -run <test> -count=1`.

| Guard mutation | Killing test | Result |
| --- | --- | --- |
| owner in write | `TestForgeRosterAndAuditGuards` | killed |
| flag | `TestForgeFlagAndOwner` | SURVIVED |
| audit save | `TestForgeRosterAndAuditGuards` | killed |
| supersede key erasure | `TestForgeStartSinglePending` | killed |
| already connected preserves pending | `TestForgeAlreadyConnectedPreservesPending` | killed |
| disconnect erasure | `TestForgeConnectionLifecycle` | killed |
| callback owner | `TestForgeCallbacksBound` | SURVIVED |
| callback session | `TestForgeCallbacksBound` | killed |
| callback origin | `TestForgeCallbacksBound` | killed |
| callback expiry | `TestForgeCallbacksBound` | killed |
| manifest single use | `TestForgeCallbacksBound\|TestForgeClaimAcrossProcesses` | killed |
| installation single use | `TestForgeInstallationCallback` | killed |
| late conversion generation | `TestForgeLateResults/convert/disconnect` | SURVIVED |
| pending lifetime | `TestForgePendingAndUninstallDeadlines` | killed |
| uninstall lifetime | `TestForgePendingAndUninstallDeadlines` | killed |
| uninstall first seen | `TestForgePendingAndUninstallDeadlines` | killed |
| reinstall no new Connect | `TestForgePendingAndUninstallDeadlines` | killed |
| late check generation | `TestForgeLateResults/check/disconnect` | killed |
| suspension | `TestForgeRecheckSuspensionAndRateLimit` | killed |
| unknown count Connect | `TestForgeConnectUnknownCount` | killed |
| unreadable key reconnect | `TestForgeUnreadableKey` | killed |
| API app identity | `TestAppResponseGuards/app_id` | killed |
| API owner identity | `TestAppResponseGuards/account_id` | killed |
| API owner type | `TestAppResponseGuards/account_type` | killed |
| API exact permissions | `TestAppResponseGuards/permissions` | killed |
| API no webhook events | `TestAppResponseGuards/events` | killed |
| API installation App | `TestAppResponseGuards/installation_app` | killed |
| API installation account | `TestAppResponseGuards/installation_account` | killed |
| API installation permissions | `TestAppResponseGuards/installation_permissions` | killed |
| API token exact permissions | `TestAppResponseGuards/token_permissions\|TestAppResponseGuards/token_missing_permissions` | killed |
| API token expiry | `TestAppResponseGuards/token_expired` | killed |
| API token one hour | `TestAppResponseGuards/token_long_expiry` | killed |
| API metadata-only request | `TestAppAPIContract` | killed |
| API inventory bound | `TestAppInventoryBound/1001` | killed |
| API inventory completeness | `TestAppResponseGuards/partial_inventory` | killed |
| API duplicate repository | `TestAppResponseGuards/duplicate_repository` | killed |
| API repository owner | `TestAppResponseGuards/repository_account` | killed |

## Branch A copy inventory

31 runtime keys use the exact reviewed values and Luna 2026-11-23 markers.
`copy-status.py pending` ran first; acceptance was recorded from the controller's verdict, without invoking `accept`. The bounded `acceptedGitHubApp` list
contains exactly these keys; the remaining eight belong to B, C and native.

`github.title`, `github.connect`, `github.account`, `github.account_type`, `github.organization`, `github.personal_account`, `github.create_app`, `github.create_hint`, `github.confirm_account`, `github.repository_count`, `github.confirm`, `github.connected`, `github.already_connected`, `github.disconnect`, `github.disconnect_hint`, `github.pending`, `github.pending_hint`, `github.pending_approval`, `github.check_again`, `github.redirect_expired`, `github.pending_expired`, `github.setup_failed`, `github.app_remains`, `github.app_settings`, `github.reconnect`, `github.reconnect_hint`, `github.check_failed`, `github.not_connected`, `github.suspended`, `github.too_many`, `github.choose_repositories`.
| API redirect refusal | `TestAppRedirectAndDeadline` | INVALID |
| API 403 rate limit | `TestAppAPIRefusals/rate403\|TestAppAPIRefusals/secondary403` | killed |
| API token cache lifetime | `TestAppTokenLifetime` | killed |
| API token invalidation | `TestInventoryConditionalScope` | killed |

## Strengthened and surface mutation run

The initial survivors above motivated independent fixtures. A looping redirect
mutant was terminated; its fixture now follows at most one redirect before a
finite response. These reruns must fail at runtime, not compilation.

| Guard mutation | Package / killing test | Result |
| --- | --- | --- |
| outer flag, strengthened | `./internal/equipo/github -run TestForgeFlagBeforeTransaction` | killed |
| callback owner, strengthened | `./internal/equipo/github -run TestForgeOwnerBindingIndependentOfSession` | killed |
| conversion generation, strengthened | `./internal/equipo/github -run TestForgeConversionGeneration` | killed |
| verify conversion with JWT | `./internal/equipo/github -run TestForgeConversionVerification` | killed |
| redirect, finite follow-up response | `./internal/equipo/github -run TestAppRedirectAndDeadline` | killed |
| explicit empty events | `./internal/equipo/github -run TestAppResponseGuards/missing_events` | killed |
| unknown inventory rows | `./internal/equipo/github -run TestAppResponseGuards/missing_rows` | killed |
| idle metadata eviction | `./internal/equipo/github -run TestMetadataMemoryDeadline` | INVALID |
| ETag generation | `./internal/equipo/github -run TestInventoryConditionalScope` | killed |
| active account uniqueness | `./internal/equipo/github -run TestForgeUniqueAppAndNewNames` | killed |
| App name randomness | `./internal/equipo/github -run TestForgeUniqueAppAndNewNames` | killed |
| manifest private | `./internal/equipotest -run TestGitHubHTTPFlowAndValues` | killed |
| manifest permissions | `./internal/equipotest -run TestGitHubHTTPFlowAndValues` | killed |
| manifest expiry copy | `./internal/equipo -run TestGitHubStateCopy/manifest_expired` | killed |
| installation expiry copy | `./internal/equipo -run TestGitHubStateCopy/installation_expired` | killed |
| unmapped lifecycle copy | `./internal/equipo -run TestGitHubStateCopy/live` | killed |
| manifest CSP browser | `./internal/equipotest -run TestBrowserGitHubManifestCSP` | killed |
| CSP exception isolation | `./internal/equipotest -run TestGitHubHTTPFlowAndValues` | killed |
| scanner ghs_ | `./internal/runner/thin -run TestGitHubSecretScan/ghs_` | killed |
| scanner ghu_ | `./internal/runner/thin -run TestGitHubSecretScan/ghu_` | killed |
| scanner gho_ | `./internal/runner/thin -run TestGitHubSecretScan/gho_` | killed |
| scanner ghr_ | `./internal/runner/thin -run TestGitHubSecretScan/ghr_` | killed |
| scanner PEM | `./internal/runner/thin -run TestGitHubSecretScan/PEM` | killed |

## Final focused mutations

| Guard | Killing test | Result |
| --- | --- | --- |
| idle metadata eviction corrected | `TestMetadataMemoryDeadline` | killed |
| primary reads | `TestForgeReadsUsePrimary` | killed |
| intended account login | `TestForgeAccountAndStageBinding/login` | killed |
| intended account type | `TestForgeAccountAndStageBinding/type` | killed |
| bounded read | `TestAppBodyBound` | killed |
| oversized valid JSON | `TestAppBodyBound` | killed |
| Disconnect while a pending/down key is held | `TestGitHubDisconnectHeldKey` | killed |
| Custom default RoundTripper | `TestAppCustomDefaultTransport` | killed |
| callback session epoch | `TestGitHubCallbackSessionRevokedDuringConversion` | killed |
| check session epoch | `TestGitHubInventorySessionRevoked/check` | killed |
| Connect session epoch | `TestGitHubInventorySessionRevoked/confirm` | killed |
| App identity survives slug rename | `TestForgeSameAppRename` | killed |
| verified renamed cleanup link | `TestForgeSameAppRename` | killed |

## Final implementation

- `internal/equipo/github` owns the GitHub API contract, primary-database
  lifecycle and memory-only metadata credentials. It has no runner dependency.
- `internal/equipo` supplies current-owner/session checks, transactional audit,
  configuration, Settings rendering, callback handlers and background expiry.
  `EQUIPO_GITHUB=1` is required; the default is off.
- Additive migration 0102 and the schema snapshot add `forge_connections` and
  `forge_pending`. Existing migrations, project rows and device wire stay unchanged.
- `forgetest` supplies generated RSA keys, signed-JWT verification, single-use
  conversion, installation identity/permission replies, conditional inventory
  pages, metadata-only minting and revocation. No real credentials were read.
- `runnerproto` redacts the four GitHub token shapes and full/truncated PEM;
  the runner's production gitleaks configuration scans the same shapes.
  The new test imports the already-pinned Viper dependency directly, with no
  dependency-version change.

Owner browser routes are `GET /conversation/settings/github`, POST
`/github/connect/start`, `/github/connect/check`, `/github/connect/confirm`,
`/github/connect/disconnect`, and the two GET callbacks
`/github/connect/manifest` and `/github/connect/installation`. Browser forms
retain CSRF protection. The callbacks authenticate independently so every
outcome can redirect to a clean URL without echoing a code or state.
Only the manifest page expands `form-action` to GitHub; a real Chromium
contract exercises its POST and redirects and proves ordinary pages still
block an external form.

The original owner's session, origin, account, attempt and stage bind each
single-use redirect. Both use the original absolute ten-minute deadline.
After creation, any current owner can act: pending keys last 24 hours;
uninstalled keys last seven days from the first observed uninstall. Same-App
reinstall preserves the existing Connect decision only for the same numeric
account identity. A verified slug rename updates the cleanup URL without
changing App identity. Unknown and over-limit inventory counts cannot Connect.

Every lifecycle write checks the current roster and appends audit in its own
transaction. The integration also carries the verified session epoch through
GitHub calls: revoking a browser session during conversion, Check or Connect
prevents the late result from committing. State claims, refresh claims and
reads use the primary; generation fences stop stale responses after a new
Start, Disconnect or another completed action. All API errors have safe types;
upstream bodies never become user-facing text.

The instance decrypts the App key only for an active API operation. An
in-flight handler can retain its local plaintext until its bounded request
returns; post-response roster, session and generation checks prevent it from
restoring erased authority. The database keeps only authenticated ciphertext,
bound to the purpose, instance origin, connection and numeric App ID.
Disposable client/webhook secrets are discarded. Metadata tokens are held
only in instance memory, revoked/dropped on invalidation and evicted shortly
before expiry; they cannot read contents. ETags are scoped to that token and
connection generation and discarded on a token change. No credential reaches
a runner in A. The spec's compromised-runner read-token residual belongs to C.

`TestGitHubHTTPFlowAndValues` searches the actual response/log and persisted
report, frame, prompt and audit surfaces for generated key/token/client secret,
webhook secret, code and state values. Initial manifest state and the verified
installation redirect are the necessary browser exchange, explicitly excluded
from the post-exchange clean-response assertion. The sanitized live inventory
report is included verbatim beside the spec; it confirms the fake's per-token
ETags, missing `repositories` field, all-false item permissions and 401 after
revocation.

A adds no device routes, protocol fields or runner content-reading authority;
there is therefore no OpenAPI wire delta. B will render the recorded down-group
rows and add project/reachability behavior. The native fixtures still pass.
All existing test names/assertions are preserved except the bounded release
copy-key acceptance list. No additional copy review is needed.

## Verification and mutation total

84 separate mutations were killed by runtime assertions: the 73 `killed`
rows above, five initial redaction mutations and six key-sealing mutations.
Three initial survivors are retained in the evidence table and have explicit
strengthened killing reruns. Two invalid attempts are retained and excluded
from the count; corrected versions failed at runtime. Every source was restored.
The final same-App rename regression also failed with the old slug-identity
comparison before the correction.

Pinned environment for all checks: `GOTOOLCHAIN=go1.26.11 CGO_ENABLED=0`, pinned
GOROOT/bin first on PATH and physical TMPDIR (macOS /var is a symlink).

Passed locally:

- `make fmt-check budget migration-check copy-release-check lanes-check`.
  Size exceptions were raised only to measured values with feature reasons:
  equipo 22503 source, equipotest 12468 test, plan3test 11901 test,
  runner/thin 28456 source and 22660 test lines.
- `python3 native/scripts/check-fixtures.py`: 11 device fixtures, 3586 markdown
  fixtures and 32000 differential cases.
- Full equipo, chat, thintest and runner/forge suites, and all new github tests.
  Full equipotest passes with only the two acknowledged release/Python cases
  excluded; all new GitHub HTTP tests were rerun after the session-epoch fix.
- `go test ./internal/plan3test -run TestPersonAPI -count=1`.
- The real browser `TestBrowserGitHubManifestCSP`, restored after mutation.
- Targeted vet and pinned staticcheck v0.7.0 on the touched server/fake/redactor
  packages (the whole tree's toolproxy package is Linux-only).

The requested unfiltered run was also made:
`go test ./internal/equipo/... ./internal/equipotest ./internal/thintest ./internal/runner/... -count=1 -timeout=12m`.
It exposed two branch defects, both fixed and rerun: the schema snapshot needed
both new tables, and the client constructor must accept a custom default
RoundTripper. Remaining Mac failures are Linux sandbox/provider checks and
the release tests `TestRunnerReleaseContractPackaging` and
`TestReleasePinsAndProvenance`, whose fixed /usr/bin Python lacks
`hashlib.file_digest`. The runner/thin suite reaches its 12-minute timeout in
sandbox-dependent sign-in tests. An additional full runnerproto attempt fails
`TestCheckPolicyNoRedundantRunner`, whose fixture requires /usr/bin/bwrap,
absent on this Mac; the remainder and new redaction tests are checked separately.
Linux CI, not a skipped local test, decides the final runner verdict.

Post-commit requirements are run against the committed branch: gitleaks,
`python3 scripts/runner-dead-references.py`, helper push, then Linux CI.
The final handoff records their result and SHA without rewriting this commit.

## Post-commit integration correction

Reviewing the production Check path while CI ran found that App verification
preserved the key but discarded the connection generation. The new
`TestForgeVerifiedInventoryScope` first failed through two real Store Checks,
then passed when Verify retained that internal generation. Removing the
propagation again killed the test. Explicit owner Checks create a fresh claim
and therefore refetch inventory; same-generation reads can use conditional
ETags. The metadata token remains reused until its expiry margin.

| Guard | Killing test | Result |
| --- | --- | --- |
| verified App retains inventory generation | `TestForgeVerifiedInventoryScope` | killed |

After the initial commit, the reference scan passed (2696 text files, 3210
matches, zero failures) and gitleaks scanned 1127 commits with no leaks.
Both scans are repeated after this correction commit.

## Tagged CI correction

CI on 25d44365 failed only shard 26: tagged staticcheck ST1013 found two
literal 303 redirect codes in the browser fixture. Both now use
`http.StatusSeeOther`; no behavior, assertion, copy or guard changed.
The controller confirmed the two test flakes passed on retry.

`make staticcheck` with its `browser,perf,testbuild` tags reaches only the
known macOS `internal/toolproxy` O_PATH compile failure. The same pinned
v0.7.0 checker, built as a host binary and run with `GOOS=linux GOARCH=amd64`
and those tags over `./...`, passes. Setting GOOS directly on `go run` cannot
run the resulting Linux checker binary on macOS, so the host binary is needed.
The real browser CSP test passes again (8.936s). No new mutation is needed
for a spelling-only status constant substitution; the 84 killing mutations
and runtime behavior are unchanged.

## Review fixes (Fable, 2026-11-23)

Fable's review at 25d44365 (aec3228d added only the perf-lane fix). The
original implementer was out of usage, so these fixes were made on
`fix/connect-app` from `origin/github/connect-app` and pushed back to that
branch. Every command used `GOTOOLCHAIN=go1.26.11 CGO_ENABLED=0` with the
pinned GOROOT/bin first on PATH. New tests live in
`internal/equipo/github/review_fixes_test.go`,
`internal/equipotest/github_review_test.go`,
`internal/equipo/github_view_test.go` and the rewritten value search in
`internal/equipotest/github_app_test.go`.

### Test-first

- `go test ./internal/equipo/github -count=1` with the new tests, after only
  the typed-state names, `ErrBusy` and a stub `Retryable` were added so it
  compiled: runtime failures in `TestForgeAbandonedStarts` (start-back-start,
  converted-then-superseded, three-abandoned, latest-per-account),
  `TestForgeReinstallClearsUninstallClock` (suspended, too_many,
  rate_limited), `TestForgeBusyCheckIsRetryable`, `TestForgeStuckConversion`
  (both), `TestForgeManifestCodeShape` (all eight malformed codes spent the
  state; the dotted code was refused) and
  `TestMetadataLockNotHeldAcrossNetwork` (Forget blocked for 2s). The new
  P3-2 guard tests passed against the old code, as expected for existing
  guards; they are proved by mutation below.
- The new HTTP tests were run against the original source with the source
  changes stashed: `TestGitHubAbandonedStartsPage` failed ("start-back-start
  claimed an App remains") and `TestGitHubBusyCheckNotice` failed (redirect
  to `?failed=1`). `TestGitHubHTTPFlowAndValues` and `TestGitHubSettingsNav`
  passed, since there was no leak and the nav guard existed; both are proved
  by planting and mutation.
- The rendering contract tests (`TestGitHubStateCopy`,
  `TestGitHubRenderedKeys`, `TestGitHubSweepLog`) were written against the
  new signatures, so the old code could not compile them. They are proved by
  the P3-6 and P3-7 mutations.

### Findings

**P2-1, value search.** The search now looks for single-line fragments that
survive JSON, slog and HTML escaping: a PEM body line, and the standard
base64 of the key's DER. It also looks for the client secret, webhook
secret, token, code and both states. Each sink is labelled, and the search
checks both the raw sink and its HTML-unescaped form. All tables are dumped
after conversion, after Connect and after Disconnect. Plants were killed:
PEM in `app_name` at conversion ("PEM body line escaped into table
forge_connections after conversion"); PEM in an slog line ("into log"); PEM
rendered in the page HTML through the login heading, with the row restored
before the next dump ("into page").

**P2-2, abandoned starts and dead rows.** A typed `abandoned` state is used
for a start whose manifest callback never arrived. Start (supersede) and
Disconnect use it, it is never rendered, and Start returns `Superseded`
only for an attempt GitHub called back. `List` returns every live or pending
connection. For dead attempts it returns only the latest per account (login
and type), only if it is not `abandoned`, and only while that account has no
active connection.

Ruling as applied: an App is known to exist once GitHub redirected with a
manifest code (state reached `converting`). GitHub creates the App before
that redirect. This keeps the brief's `manifest_expired` and failed-
conversion rows, both of which show `app_remains`, and drops every attempt
that never reached GitHub.

Tests: start-back-start shows no notice (store and page);
converted-then-superseded shows exactly one (store, Start response and
page); three abandoned starts leave one row (the current start) and no
notice; disconnect-before-callback lists nothing; latest per account, hidden
once that account is connected again.

**P3-1, uninstall clock.** When the JWT's installation list and the
installation read see a matching installation, in any state (live,
suspended, over the limit, or with a failed inventory), Check clears
`UninstalledAt`. The expiry check still runs first. Test: uninstall, wait 3
days, reinstall suspended / 1001 repositories / 503 inventory, wait 5 more
days, sweep: the key is kept.

**P3-2, guard tests.** Connect's own transaction rechecks the roster: the
owner is removed inside Check's committed transaction, and Connect must not
confirm. `InstallationURL` checks the owner, the session and the deadline.
Duplicate matching installations: the twin is listed first, so the mutant
would pick the genuine one and reach `ready`. Disconnect revokes and drops
the metadata token. The Settings nav hides GitHub from members and when the
flag is off (`data-settings-link="github"`).

**P3-3, busy Check.** `github.Retryable` covers `ErrBusy` (a held claim,
or a lost generation/claim fence in Check or Connect), `ErrUnavailable`,
`ErrRateLimit` and context deadline/cancel. The handlers and callbacks
redirect those to `?failed=check`, which renders `github.check_failed`. Any
other non-refusal error still goes to `?failed=1`, which renders
`github.setup_failed`. Test: a double-tapped Check on a live connection shows
check_failed, not setup_failed, and the connected state is kept.

**P3-4, stuck conversion.** Conversion now records the App id and slug in
its own fenced transaction (`forge.convert_app`) as soon as GitHub returns
an App for the intended account, before verification. Sweep moves any
`converting` row whose last write is older than 2 minutes to `failed`,
erases its hashes and frees the pending slot. It then renders
`setup_failed` + `app_remains` with the link. The link uses the slug when
the App id was recorded, otherwise the account's Apps list, per the brief.
Tests: a claimed callback with no conversion (a lost process), and a failed
final transaction with the App id recorded; each is not swept at 1 minute
and is swept at 3.

**P3-5, metadata lock.** `metadata()` holds the mutex only to read or swap
the cache. `Forget` advances a per-App epoch, so a token minted across a
Forget is revoked and refused instead of being stored. A token displaced by
a concurrent mint is revoked. Test: a blocking fake on `access_tokens`;
Forget returns within 2s, the late token is revoked once and the map is
empty.

**P3-6, rendering contract.** `github.State` is a typed string with 19
constants in `github.States`. `githubStateKeys` switches over them with no
default: an unknown state returns an error, and `abandoned` returns a
hidden-state error. The handlers turn either into the unavailable page.
`TestGitHubStateCopy` requires an explicit fixture for every typed state.
`TestGitHubRenderedKeys` takes the union of every row's rendered keys
(lines and action labels) over every state, both account types and both
count shapes, the two notices and the template's literal `copy "github.*"`
keys. It asserts that the union equals exactly the brief's 31 branch-A keys.

**P3-7, sweep log.** `logGitHubSweep` logs `copyGitHubSweep` ("Could not
clear expired GitHub setups.") with `err_type` (`%T`) and `kind`
(access/busy/unavailable/timeout/other) only, never the error text. The
controller approved the constant on 2026-11-23. Like its unmarked siblings
`copyAuthSweep` and `copyNonceSweep`, it has no acceptance marker. Luna
review queued for 11-25. `make copy-release-check` passes.

**P3-8, manifest code.** `ValidCode` (`^[A-Za-z0-9._-]{1,256}$`, and not
`.` or `..`, which would be path dot-segments) is checked before the state
is claimed, and again in `API.Convert`. Tests: empty, `/`, space, `%2F`,
`?`, `.`, `..` and 257 characters are each refused, the state is unspent,
and the same state then converts. A dotted 208-character code converts.

**Left for branch B:** every Check bumps the generation, so cached
inventory pages are always discarded (`store.go` save, `inventory_cache.go`
generation compare). Unchanged here.

### Mutations

Each mutation was applied by a scratch runner that backs up the file,
replaces one exact span, runs the named test, classifies the result as
killed (a runtime `--- FAIL`) or survived/invalid, and restores the file.
The final restored tests pass.

| Guard mutation | Killing test | Result |
| --- | --- | --- |
| PEM stored in app_name at conversion | `TestGitHubHTTPFlowAndValues` | killed |
| PEM planted in a log line | `TestGitHubHTTPFlowAndValues` | killed |
| PEM planted in page HTML | `TestGitHubHTTPFlowAndValues` | killed |
| supersede ignores callback | `TestForgeAbandonedStarts`, `TestGitHubAbandonedStartsPage` | killed |
| List shows every dead row | `TestForgeAbandonedStarts` | killed |
| List keeps notice after reconnection | `TestForgeAbandonedStarts` | killed |
| List shows every dead attempt per account | `TestForgeAbandonedStarts` | killed |
| List shows abandoned rows | `TestForgeAbandonedStarts` | killed |
| Disconnect before callback claims an App | `TestForgeAbandonedStarts` | killed |
| reinstall keeps uninstall clock | `TestForgeReinstallClearsUninstallClock` | killed (first form unused-variable INVALID, rerun with `&& false`) |
| Connect transaction skips owner check | `TestForgeConnectOwnerInOwnTransaction` | killed |
| InstallationURL owner | `TestForgeInstallationURLBinding/owner` | killed |
| InstallationURL session | `TestForgeInstallationURLBinding/session` | killed |
| InstallationURL deadline | `TestForgeInstallationURLBinding/deadline` | killed |
| duplicate installations | `TestForgeDuplicateInstallations` | killed (first run died on the fake's unexpected route; twin reordered so the test's own assertion kills it) |
| Disconnect keeps metadata token | `TestForgeDisconnectDropsToken` | killed |
| nav shows GitHub to members | `TestGitHubSettingsNav/member` | killed |
| nav shows GitHub with flag off | `TestGitHubSettingsNav/flag-off` | killed |
| retryable maps to setup_failed | `TestGitHubBusyCheckNotice` | killed |
| busy claim is ErrAccess | `TestForgeBusyCheckIsRetryable` | killed |
| Retryable omits rate limit | `TestForgeBusyCheckIsRetryable` | killed |
| no stuck-conversion sweep | `TestForgeStuckConversion` | killed |
| sweep ignores the 2-minute bound | `TestForgeStuckConversion` | killed |
| App id not recorded before verify | `TestForgeStuckConversion/app-id` | killed |
| lock held across token mint | `TestMetadataLockNotHeldAcrossNetwork` | killed |
| token kept across Forget | `TestMetadataLockNotHeldAcrossNetwork` | killed (first form unused-variable INVALID, rerun with `&& false`) |
| remove too_many mapping | `TestGitHubStateCopy`, `TestGitHubRenderedKeys` | killed |
| unknown state falls through silently | `TestGitHubStateCopy` | killed |
| exchange the two redirect-expiry mappings | `TestGitHubStateCopy` | killed |
| hidden state rendered | `TestGitHubStateCopy` | killed |
| extra key outside the brief | `TestGitHubRenderedKeys` | killed |
| sweep log carries error text | `TestGitHubSweepLog` | killed |
| sweep log uses a UI string | `TestGitHubSweepLog` | killed |
| code checked after state spent | `TestForgeManifestCodeShape` | killed |
| dot refused | `TestForgeManifestCodeShape/dotted` | killed |
| dot segment allowed | `TestForgeManifestCodeShape/..` | killed |
| code length unbounded | `TestForgeManifestCodeShape` | killed |

37 mutations killed by runtime assertions. The two INVALID first attempts
are excluded from the count and their corrected forms are counted.

### Gates

- `make fmt-check migration-check copy-release-check lanes-check`: pass.
- `go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget size`: 92
  directories within budget, after raising `internal/equipo` to its
  measured 22577 source lines and `internal/equipotest` to 12626 test lines,
  with extended reasons (each under the 200-byte record limit checked by
  `TestBudgetRecordsAreShort`). CI on aec3228d had already failed equipotest at 12472.
- Pinned staticcheck v0.7.0 built as a host binary and run with
  `GOOS=linux GOARCH=amd64 -tags browser,perf,testbuild ./...`: clean.
  Linux-target vet on the touched packages: clean.
- `go test ./internal/equipo/... -count=1`: everything passes except
  `internal/equipo/team` `TestPublishCoreAuthorizationContract` ("team:
  invalid"), which fails the same way on untouched aec3228d on this Mac.
- `go test ./internal/equipotest -count=1` (skipping the two system-Python
  release tests): 282.8s, everything passes except
  `TestExecutionStartupClosed`, `TestExecutionHibernateWitness`,
  `TestExecutionStartupReconciliation` and `TestExecutionCarlosMarkerLayout`.
  All four fail identically on untouched aec3228d on this Mac. Linux CI decides.
- Perf lane `go test -tags perf,testbuild -run 'TestPerfScreens$' ./internal/equipotest`: pass.
- Post-commit on 7bf6afe3: `python3 scripts/runner-dead-references.py`
  (2698 text files, 3210 matches, 0 failures); `make gitleaks` (1131
  commits, no leaks).

### CI correction

CI on 7bf6afe3 failed two shards, both on records rather than behavior.
Shard 17: `TestBudgetRecordsAreShort`, because the equipotest budget reason
was 255 bytes, over the 200-byte limit. Both touched reasons are now
shortened. Shard 16: `TestPlan3ReleaseBoundaries/inventory`, because the new
`copyGitHubSweep` constant had no row in the Plan 3 copy inventory. The row
is added beside the GitHub rows with status `COPY REVIEW REQUIRED` (Luna
review queued for 11-25). `make copy-release-check` reads only copy.go and
still passes. The CI failure is itself the killing evidence for the
inventory guard. Locally, `TestBudgetRecordsAreShort`,
`TestPlan3ReleaseBoundaries`, `make copy-release-check` and `budget size`
pass. `plan3test` `TestCoordinatorAcceptance3B` fails on this Mac
(`provider_uncertain`, runner journal) but passed in CI shard 16 on 7bf6afe3.

## Re-review fixes (Fable, 2026-11-25)

Fable re-reviewed d0f321d0 and confirmed every earlier finding fixed. One P2
(the release gate) and five P3s remained. These were fixed on a fresh
`fix/connect-app` from `origin/github/connect-app`, with the same pinned
toolchain. Then origin/main 927a031a (paused work, protocol 29) was merged in.

**P2, release gate.** On d0f321d0, `python3 scripts/plan3-copy-check.py`
exited 1 because the `copyGitHubSweep` inventory row said
`COPY REVIEW REQUIRED`. Luna approved the string unchanged on 2026-11-25. The
row now reads `COPY ACCEPTED BY DELEGATION (Luna, 2026-11-25)`, and
`plan3_release_test.go` gains an `acceptedGitHubSweep` rule for exactly that
key and marker. The constant stays unmarked in copy.go, like its siblings,
because the check does not need a marker there. `plan3-copy-check.py` now
exits 0. Mutation: disabling the rule failed the inventory test ("entry has
no copy review status or applicable acceptance copyGitHubSweep"). The first
form of that mutation was INVALID (unused variable) and was replaced.

**P3-1, BLOB columns.** The table dump turns `[]byte` values into strings
before `json.Marshal`, which would otherwise base64 them. Plant: the PEM
written into `app_name` with `CAST(? AS BLOB)` just before the
after-conversion dump, then restored. It was killed ("PEM body line escaped
into table forge_connections after conversion"). Control: the same plant
with the conversion disabled SURVIVED, which proves the old dump could not
see a BLOB key. The first control run was caught later only because
Disconnect rewrote the planted `app_name` as TEXT, so both plants now
restore the column straight after the dump.

**P3-2, lost fences.** `TestForgeCheckLostFenceIsBusy`: a Check is blocked
mid-inventory past its 30-second claim; another owner's Check takes over;
the first must return `ErrBusy` (Retryable). `TestForgeConnectLostFenceIsBusy`:
the generation moves inside Connect's own transaction; Connect must return
`ErrBusy` and must not confirm. Reverting either line to `ErrAccess` was
killed.

**P3-3, sweep log wiring.** `TestGitHubSweepFailureLogged` builds the real
router, drops `forge_connections`, and calls `equipo.Configure`, which
starts the serving loops. The minute loop's first pass must log "Could not
clear expired GitHub setups." with `kind=other` and `err_type`, and no
table name or UI string. Killed: the loop logging the old UI string, and
the loop dropping the sweep error.

**P3-4, expired starts.** `List` hides a `manifest` row once its
`RedirectUntil` has passed. Nothing is erased, so a late callback still
gets `manifest_expired`, and that row is then listed with its cleanup link.
`TestForgeExpiredManifestStartHidden` failed first (the start was still
listed at 10 minutes), then passed. Killed: the hide removed, and a hide
that erases the manifest hash ("late callback lost its answer").

**P3-5, surviving guards.** `TestForgeInstallationURLRoster`: a removed
owner gets no installation handoff; removing `InstallationURL`'s own Owner
check was killed. `TestMetadataDisplacedTokenRevoked`: two concurrent
mints, where the first store displaces the second token, which must be
revoked; skipping that revoke was killed.

**Merge of origin/main 927a031a** (merge commit, no rebase). Conflicts:
- `schema.sql` keeps the 0102 forge tables before main's 0104-0106
  statements. The migration numbers don't collide (branch 0102, main
  0103-0106).
- The Plan 3 inventory keeps both the GitHub rows and the paused-work
  rows.
- The release test's acceptance condition keeps `acceptedGitHubApp`,
  `acceptedGitHubSweep`, `acceptedPaused` and `acceptedNewTeamCard`. The
  rest of the condition was identical on both sides, which the resolution
  asserted.
- Budgets were re-measured: `internal/equipo` 23029, `internal/equipotest`
  0/12683, `internal/plan3test` 11912, `internal/runner/thin` 28488/22754.
  `internal/wire` stays at main's 6946. Every reason is under 200 bytes.
- copy.go, app.go and handlers.go merged cleanly. Branch A has no wire or
  protocol changes, so protocol 29 is main's.

**Gates on the merged tree.**
- Pass: `make fmt-check migration-check copy-release-check lanes-check`,
  `python3 scripts/plan3-copy-check.py` (exit 0), `budget size` (93
  directories), `TestBudgetRecordsAreShort`, the perf lane, and the
  `internal/equipo/github` package.
- Linux vet on the touched packages and pinned staticcheck v0.7.0
  (`GOOS=linux GOARCH=amd64 -tags browser,perf,testbuild ./...`): clean.
- Mac-only failures, each confirmed identical on untouched origin/main
  927a031a:
  - `internal/equipo/team`: `TestPublishCoreAuthorizationContract`.
  - `internal/equipotest` (292.5s): `TestRunnerHTTPExpiredLeaseDefinitive`,
    `TestRunnerJournalServerCommitBeforeACK`,
    `TestDirectCompletionServerCommitBeforeACK` (all `provider_uncertain`,
    arriving with main), and the four `TestExecution*` startup tests.
  - `internal/plan3test`: `TestCoordinatorAcceptance3B`.

  Linux CI decides.
