| 1 | # GitHub App connection: implementation evidence |
| 2 | |
| 3 | Branch `github/connect-app`, based on main `eff421c7`. |
| 4 | The controller approved the step-4 plan and assigned branch A on 2026-11-23. |
| 5 | Implementation and local verification are complete. Linux CI is the final |
| 6 | runner gate; its fixed commit and verdict are reported with the branch handoff. |
| 7 | |
| 8 | ## Scope and order |
| 9 | |
| 10 | 1. Token/key shape redaction and generated-key fake GitHub HTTP contract. |
| 11 | 2. Primary-database forge connection lifecycle, sealed App key, additive schema, |
| 12 | owner checks, single-use callbacks and same-transaction audit records. |
| 13 | 3. Owner-only Settings section and manifest CSP, disabled by default. |
| 14 | 4. Lifetime, concurrency, value-search, browser and copy-rendering regressions. |
| 15 | 5. Individual guard mutations, local gates, commit, reference scan, push, CI. |
| 16 | |
| 17 | The controller's final implementation rulings supersede the plan where needed: |
| 18 | only one pending setup per team; Start replaces it regardless of account, |
| 19 | except an already-connected account leaves it untouched. Any current owner |
| 20 | may Check again, Connect, supersede or Disconnect. More than 1000 repositories |
| 21 | means an unknown snapshot with no Connect action until Check again obtains a |
| 22 | complete count within the limit. Branch B renders down Projects groups with |
| 23 | `github.group` plus `github.not_connected` or `github.suspended` and tests them. |
| 24 | |
| 25 | ## Test-first evidence |
| 26 | |
| 27 | - `GOTOOLCHAIN=go1.26.11 CGO_ENABLED=0 go test ./internal/runnerproto -run TestGitHubSecretShapes -count=1` |
| 28 | failed first for all four GitHub token prefixes and all full/truncated PEM |
| 29 | forms, then passed after shape redaction was implemented. The test supplies |
| 30 | no known-secret list and checks nested JSON as well as plain text. |
| 31 | |
| 32 | ## Mutation evidence |
| 33 | |
| 34 | Each mutation below was applied separately, the named test failed at runtime, |
| 35 | and the source was restored. The final restored test passed. |
| 36 | |
| 37 | | Guard removed | Killing test | |
| 38 | | --- | --- | |
| 39 | | ghs_ recognition | TestGitHubSecretShapes/ghs_ | |
| 40 | | ghu_ recognition | TestGitHubSecretShapes/ghu_ | |
| 41 | | gho_ recognition | TestGitHubSecretShapes/gho_ | |
| 42 | | ghr_ recognition | TestGitHubSecretShapes/ghr_ | |
| 43 | | PEM block redaction | TestGitHubSecretShapes, full and truncated key cases | |
| 44 | |
| 45 | ## Copy |
| 46 | |
| 47 | Use only the 39 keys and exact Luna-reviewed values in |
| 48 | [the copy brief](2026-11-23-github-connect-copy.md). Runtime inventory and |
| 49 | release acceptance list only keys actually introduced by this branch. |
| 50 | |
| 51 | ## App API contract, first pass |
| 52 | |
| 53 | `GOTOOLCHAIN=go1.26.11 CGO_ENABLED=0 go test ./internal/equipo/github -count=1` |
| 54 | first failed at runtime against the API stubs, then passed (2.292s). Tests |
| 55 | cover conversion with generated RSA keys, signed App JWTs, installation reads, |
| 56 | selected/all modes, metadata-only token requests and memory reuse/revocation, |
| 57 | redirect refusal, status classification including 403 rate limits, bounded |
| 58 | responses and complete inventories of 0, 100, 101, 1000 and 1001 repositories. |
| 59 | The later guards and HTTP value-search tests below complete the malformed-scope, |
| 60 | concurrency and sink coverage. |
| 61 | |
| 62 | ## Key sealing evidence |
| 63 | |
| 64 | `go test ./internal/equipo/github -run TestAppKeySealing -count=1` failed |
| 65 | against the stub, then passed. Six separate mutations were killed: omit the |
| 66 | origin binding, omit connection binding, omit App ID binding, use a fixed |
| 67 | instance key, reuse the device-result purpose, and clear the random nonce. |
| 68 | The restored test passed. The test also refuses corrupt ciphertext and checks |
| 69 | that encoding alone cannot hide the plaintext. |
| 70 | |
| 71 | ## Lifecycle and API mutation run |
| 72 | |
| 73 | Each command uses the pinned toolchain: `go test ./internal/equipo/github -run <test> -count=1`. |
| 74 | |
| 75 | | Guard mutation | Killing test | Result | |
| 76 | | --- | --- | --- | |
| 77 | | owner in write | `TestForgeRosterAndAuditGuards` | killed | |
| 78 | | flag | `TestForgeFlagAndOwner` | SURVIVED | |
| 79 | | audit save | `TestForgeRosterAndAuditGuards` | killed | |
| 80 | | supersede key erasure | `TestForgeStartSinglePending` | killed | |
| 81 | | already connected preserves pending | `TestForgeAlreadyConnectedPreservesPending` | killed | |
| 82 | | disconnect erasure | `TestForgeConnectionLifecycle` | killed | |
| 83 | | callback owner | `TestForgeCallbacksBound` | SURVIVED | |
| 84 | | callback session | `TestForgeCallbacksBound` | killed | |
| 85 | | callback origin | `TestForgeCallbacksBound` | killed | |
| 86 | | callback expiry | `TestForgeCallbacksBound` | killed | |
| 87 | | manifest single use | `TestForgeCallbacksBound\|TestForgeClaimAcrossProcesses` | killed | |
| 88 | | installation single use | `TestForgeInstallationCallback` | killed | |
| 89 | | late conversion generation | `TestForgeLateResults/convert/disconnect` | SURVIVED | |
| 90 | | pending lifetime | `TestForgePendingAndUninstallDeadlines` | killed | |
| 91 | | uninstall lifetime | `TestForgePendingAndUninstallDeadlines` | killed | |
| 92 | | uninstall first seen | `TestForgePendingAndUninstallDeadlines` | killed | |
| 93 | | reinstall no new Connect | `TestForgePendingAndUninstallDeadlines` | killed | |
| 94 | | late check generation | `TestForgeLateResults/check/disconnect` | killed | |
| 95 | | suspension | `TestForgeRecheckSuspensionAndRateLimit` | killed | |
| 96 | | unknown count Connect | `TestForgeConnectUnknownCount` | killed | |
| 97 | | unreadable key reconnect | `TestForgeUnreadableKey` | killed | |
| 98 | | API app identity | `TestAppResponseGuards/app_id` | killed | |
| 99 | | API owner identity | `TestAppResponseGuards/account_id` | killed | |
| 100 | | API owner type | `TestAppResponseGuards/account_type` | killed | |
| 101 | | API exact permissions | `TestAppResponseGuards/permissions` | killed | |
| 102 | | API no webhook events | `TestAppResponseGuards/events` | killed | |
| 103 | | API installation App | `TestAppResponseGuards/installation_app` | killed | |
| 104 | | API installation account | `TestAppResponseGuards/installation_account` | killed | |
| 105 | | API installation permissions | `TestAppResponseGuards/installation_permissions` | killed | |
| 106 | | API token exact permissions | `TestAppResponseGuards/token_permissions\|TestAppResponseGuards/token_missing_permissions` | killed | |
| 107 | | API token expiry | `TestAppResponseGuards/token_expired` | killed | |
| 108 | | API token one hour | `TestAppResponseGuards/token_long_expiry` | killed | |
| 109 | | API metadata-only request | `TestAppAPIContract` | killed | |
| 110 | | API inventory bound | `TestAppInventoryBound/1001` | killed | |
| 111 | | API inventory completeness | `TestAppResponseGuards/partial_inventory` | killed | |
| 112 | | API duplicate repository | `TestAppResponseGuards/duplicate_repository` | killed | |
| 113 | | API repository owner | `TestAppResponseGuards/repository_account` | killed | |
| 114 | |
| 115 | ## Branch A copy inventory |
| 116 | |
| 117 | 31 runtime keys use the exact reviewed values and Luna 2026-11-23 markers. |
| 118 | `copy-status.py pending` ran first; acceptance was recorded from the controller's verdict, without invoking `accept`. The bounded `acceptedGitHubApp` list |
| 119 | contains exactly these keys; the remaining eight belong to B, C and native. |
| 120 | |
| 121 | `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`. |
| 122 | | API redirect refusal | `TestAppRedirectAndDeadline` | INVALID | |
| 123 | | API 403 rate limit | `TestAppAPIRefusals/rate403\|TestAppAPIRefusals/secondary403` | killed | |
| 124 | | API token cache lifetime | `TestAppTokenLifetime` | killed | |
| 125 | | API token invalidation | `TestInventoryConditionalScope` | killed | |
| 126 | |
| 127 | ## Strengthened and surface mutation run |
| 128 | |
| 129 | The initial survivors above motivated independent fixtures. A looping redirect |
| 130 | mutant was terminated; its fixture now follows at most one redirect before a |
| 131 | finite response. These reruns must fail at runtime, not compilation. |
| 132 | |
| 133 | | Guard mutation | Package / killing test | Result | |
| 134 | | --- | --- | --- | |
| 135 | | outer flag, strengthened | `./internal/equipo/github -run TestForgeFlagBeforeTransaction` | killed | |
| 136 | | callback owner, strengthened | `./internal/equipo/github -run TestForgeOwnerBindingIndependentOfSession` | killed | |
| 137 | | conversion generation, strengthened | `./internal/equipo/github -run TestForgeConversionGeneration` | killed | |
| 138 | | verify conversion with JWT | `./internal/equipo/github -run TestForgeConversionVerification` | killed | |
| 139 | | redirect, finite follow-up response | `./internal/equipo/github -run TestAppRedirectAndDeadline` | killed | |
| 140 | | explicit empty events | `./internal/equipo/github -run TestAppResponseGuards/missing_events` | killed | |
| 141 | | unknown inventory rows | `./internal/equipo/github -run TestAppResponseGuards/missing_rows` | killed | |
| 142 | | idle metadata eviction | `./internal/equipo/github -run TestMetadataMemoryDeadline` | INVALID | |
| 143 | | ETag generation | `./internal/equipo/github -run TestInventoryConditionalScope` | killed | |
| 144 | | active account uniqueness | `./internal/equipo/github -run TestForgeUniqueAppAndNewNames` | killed | |
| 145 | | App name randomness | `./internal/equipo/github -run TestForgeUniqueAppAndNewNames` | killed | |
| 146 | | manifest private | `./internal/equipotest -run TestGitHubHTTPFlowAndValues` | killed | |
| 147 | | manifest permissions | `./internal/equipotest -run TestGitHubHTTPFlowAndValues` | killed | |
| 148 | | manifest expiry copy | `./internal/equipo -run TestGitHubStateCopy/manifest_expired` | killed | |
| 149 | | installation expiry copy | `./internal/equipo -run TestGitHubStateCopy/installation_expired` | killed | |
| 150 | | unmapped lifecycle copy | `./internal/equipo -run TestGitHubStateCopy/live` | killed | |
| 151 | | manifest CSP browser | `./internal/equipotest -run TestBrowserGitHubManifestCSP` | killed | |
| 152 | | CSP exception isolation | `./internal/equipotest -run TestGitHubHTTPFlowAndValues` | killed | |
| 153 | | scanner ghs_ | `./internal/runner/thin -run TestGitHubSecretScan/ghs_` | killed | |
| 154 | | scanner ghu_ | `./internal/runner/thin -run TestGitHubSecretScan/ghu_` | killed | |
| 155 | | scanner gho_ | `./internal/runner/thin -run TestGitHubSecretScan/gho_` | killed | |
| 156 | | scanner ghr_ | `./internal/runner/thin -run TestGitHubSecretScan/ghr_` | killed | |
| 157 | | scanner PEM | `./internal/runner/thin -run TestGitHubSecretScan/PEM` | killed | |
| 158 | |
| 159 | ## Final focused mutations |
| 160 | |
| 161 | | Guard | Killing test | Result | |
| 162 | | --- | --- | --- | |
| 163 | | idle metadata eviction corrected | `TestMetadataMemoryDeadline` | killed | |
| 164 | | primary reads | `TestForgeReadsUsePrimary` | killed | |
| 165 | | intended account login | `TestForgeAccountAndStageBinding/login` | killed | |
| 166 | | intended account type | `TestForgeAccountAndStageBinding/type` | killed | |
| 167 | | bounded read | `TestAppBodyBound` | killed | |
| 168 | | oversized valid JSON | `TestAppBodyBound` | killed | |
| 169 | | Disconnect while a pending/down key is held | `TestGitHubDisconnectHeldKey` | killed | |
| 170 | | Custom default RoundTripper | `TestAppCustomDefaultTransport` | killed | |
| 171 | | callback session epoch | `TestGitHubCallbackSessionRevokedDuringConversion` | killed | |
| 172 | | check session epoch | `TestGitHubInventorySessionRevoked/check` | killed | |
| 173 | | Connect session epoch | `TestGitHubInventorySessionRevoked/confirm` | killed | |
| 174 | | App identity survives slug rename | `TestForgeSameAppRename` | killed | |
| 175 | | verified renamed cleanup link | `TestForgeSameAppRename` | killed | |
| 176 | |
| 177 | ## Final implementation |
| 178 | |
| 179 | - `internal/equipo/github` owns the GitHub API contract, primary-database |
| 180 | lifecycle and memory-only metadata credentials. It has no runner dependency. |
| 181 | - `internal/equipo` supplies current-owner/session checks, transactional audit, |
| 182 | configuration, Settings rendering, callback handlers and background expiry. |
| 183 | `EQUIPO_GITHUB=1` is required; the default is off. |
| 184 | - Additive migration 0102 and the schema snapshot add `forge_connections` and |
| 185 | `forge_pending`. Existing migrations, project rows and device wire stay unchanged. |
| 186 | - `forgetest` supplies generated RSA keys, signed-JWT verification, single-use |
| 187 | conversion, installation identity/permission replies, conditional inventory |
| 188 | pages, metadata-only minting and revocation. No real credentials were read. |
| 189 | - `runnerproto` redacts the four GitHub token shapes and full/truncated PEM; |
| 190 | the runner's production gitleaks configuration scans the same shapes. |
| 191 | The new test imports the already-pinned Viper dependency directly, with no |
| 192 | dependency-version change. |
| 193 | |
| 194 | Owner browser routes are `GET /conversation/settings/github`, POST |
| 195 | `/github/connect/start`, `/github/connect/check`, `/github/connect/confirm`, |
| 196 | `/github/connect/disconnect`, and the two GET callbacks |
| 197 | `/github/connect/manifest` and `/github/connect/installation`. Browser forms |
| 198 | retain CSRF protection. The callbacks authenticate independently so every |
| 199 | outcome can redirect to a clean URL without echoing a code or state. |
| 200 | Only the manifest page expands `form-action` to GitHub; a real Chromium |
| 201 | contract exercises its POST and redirects and proves ordinary pages still |
| 202 | block an external form. |
| 203 | |
| 204 | The original owner's session, origin, account, attempt and stage bind each |
| 205 | single-use redirect. Both use the original absolute ten-minute deadline. |
| 206 | After creation, any current owner can act: pending keys last 24 hours; |
| 207 | uninstalled keys last seven days from the first observed uninstall. Same-App |
| 208 | reinstall preserves the existing Connect decision only for the same numeric |
| 209 | account identity. A verified slug rename updates the cleanup URL without |
| 210 | changing App identity. Unknown and over-limit inventory counts cannot Connect. |
| 211 | |
| 212 | Every lifecycle write checks the current roster and appends audit in its own |
| 213 | transaction. The integration also carries the verified session epoch through |
| 214 | GitHub calls: revoking a browser session during conversion, Check or Connect |
| 215 | prevents the late result from committing. State claims, refresh claims and |
| 216 | reads use the primary; generation fences stop stale responses after a new |
| 217 | Start, Disconnect or another completed action. All API errors have safe types; |
| 218 | upstream bodies never become user-facing text. |
| 219 | |
| 220 | The instance decrypts the App key only for an active API operation. An |
| 221 | in-flight handler can retain its local plaintext until its bounded request |
| 222 | returns; post-response roster, session and generation checks prevent it from |
| 223 | restoring erased authority. The database keeps only authenticated ciphertext, |
| 224 | bound to the purpose, instance origin, connection and numeric App ID. |
| 225 | Disposable client/webhook secrets are discarded. Metadata tokens are held |
| 226 | only in instance memory, revoked/dropped on invalidation and evicted shortly |
| 227 | before expiry; they cannot read contents. ETags are scoped to that token and |
| 228 | connection generation and discarded on a token change. No credential reaches |
| 229 | a runner in A. The spec's compromised-runner read-token residual belongs to C. |
| 230 | |
| 231 | `TestGitHubHTTPFlowAndValues` searches the actual response/log and persisted |
| 232 | report, frame, prompt and audit surfaces for generated key/token/client secret, |
| 233 | webhook secret, code and state values. Initial manifest state and the verified |
| 234 | installation redirect are the necessary browser exchange, explicitly excluded |
| 235 | from the post-exchange clean-response assertion. The sanitized live inventory |
| 236 | report is included verbatim beside the spec; it confirms the fake's per-token |
| 237 | ETags, missing `repositories` field, all-false item permissions and 401 after |
| 238 | revocation. |
| 239 | |
| 240 | A adds no device routes, protocol fields or runner content-reading authority; |
| 241 | there is therefore no OpenAPI wire delta. B will render the recorded down-group |
| 242 | rows and add project/reachability behavior. The native fixtures still pass. |
| 243 | All existing test names/assertions are preserved except the bounded release |
| 244 | copy-key acceptance list. No additional copy review is needed. |
| 245 | |
| 246 | ## Verification and mutation total |
| 247 | |
| 248 | 84 separate mutations were killed by runtime assertions: the 73 `killed` |
| 249 | rows above, five initial redaction mutations and six key-sealing mutations. |
| 250 | Three initial survivors are retained in the evidence table and have explicit |
| 251 | strengthened killing reruns. Two invalid attempts are retained and excluded |
| 252 | from the count; corrected versions failed at runtime. Every source was restored. |
| 253 | The final same-App rename regression also failed with the old slug-identity |
| 254 | comparison before the correction. |
| 255 | |
| 256 | Pinned environment for all checks: `GOTOOLCHAIN=go1.26.11 CGO_ENABLED=0`, pinned |
| 257 | GOROOT/bin first on PATH and physical TMPDIR (macOS /var is a symlink). |
| 258 | |
| 259 | Passed locally: |
| 260 | |
| 261 | - `make fmt-check budget migration-check copy-release-check lanes-check`. |
| 262 | Size exceptions were raised only to measured values with feature reasons: |
| 263 | equipo 22503 source, equipotest 12468 test, plan3test 11901 test, |
| 264 | runner/thin 28456 source and 22660 test lines. |
| 265 | - `python3 native/scripts/check-fixtures.py`: 11 device fixtures, 3586 markdown |
| 266 | fixtures and 32000 differential cases. |
| 267 | - Full equipo, chat, thintest and runner/forge suites, and all new github tests. |
| 268 | Full equipotest passes with only the two acknowledged release/Python cases |
| 269 | excluded; all new GitHub HTTP tests were rerun after the session-epoch fix. |
| 270 | - `go test ./internal/plan3test -run TestPersonAPI -count=1`. |
| 271 | - The real browser `TestBrowserGitHubManifestCSP`, restored after mutation. |
| 272 | - Targeted vet and pinned staticcheck v0.7.0 on the touched server/fake/redactor |
| 273 | packages (the whole tree's toolproxy package is Linux-only). |
| 274 | |
| 275 | The requested unfiltered run was also made: |
| 276 | `go test ./internal/equipo/... ./internal/equipotest ./internal/thintest ./internal/runner/... -count=1 -timeout=12m`. |
| 277 | It exposed two branch defects, both fixed and rerun: the schema snapshot needed |
| 278 | both new tables, and the client constructor must accept a custom default |
| 279 | RoundTripper. Remaining Mac failures are Linux sandbox/provider checks and |
| 280 | the release tests `TestRunnerReleaseContractPackaging` and |
| 281 | `TestReleasePinsAndProvenance`, whose fixed /usr/bin Python lacks |
| 282 | `hashlib.file_digest`. The runner/thin suite reaches its 12-minute timeout in |
| 283 | sandbox-dependent sign-in tests. An additional full runnerproto attempt fails |
| 284 | `TestCheckPolicyNoRedundantRunner`, whose fixture requires /usr/bin/bwrap, |
| 285 | absent on this Mac; the remainder and new redaction tests are checked separately. |
| 286 | Linux CI, not a skipped local test, decides the final runner verdict. |
| 287 | |
| 288 | Post-commit requirements are run against the committed branch: gitleaks, |
| 289 | `python3 scripts/runner-dead-references.py`, helper push, then Linux CI. |
| 290 | The final handoff records their result and SHA without rewriting this commit. |
| 291 | |
| 292 | ## Post-commit integration correction |
| 293 | |
| 294 | Reviewing the production Check path while CI ran found that App verification |
| 295 | preserved the key but discarded the connection generation. The new |
| 296 | `TestForgeVerifiedInventoryScope` first failed through two real Store Checks, |
| 297 | then passed when Verify retained that internal generation. Removing the |
| 298 | propagation again killed the test. Explicit owner Checks create a fresh claim |
| 299 | and therefore refetch inventory; same-generation reads can use conditional |
| 300 | ETags. The metadata token remains reused until its expiry margin. |
| 301 | |
| 302 | | Guard | Killing test | Result | |
| 303 | | --- | --- | --- | |
| 304 | | verified App retains inventory generation | `TestForgeVerifiedInventoryScope` | killed | |
| 305 | |
| 306 | After the initial commit, the reference scan passed (2696 text files, 3210 |
| 307 | matches, zero failures) and gitleaks scanned 1127 commits with no leaks. |
| 308 | Both scans are repeated after this correction commit. |
| 309 | |
| 310 | ## Tagged CI correction |
| 311 | |
| 312 | CI on 25d44365 failed only shard 26: tagged staticcheck ST1013 found two |
| 313 | literal 303 redirect codes in the browser fixture. Both now use |
| 314 | `http.StatusSeeOther`; no behavior, assertion, copy or guard changed. |
| 315 | The controller confirmed the two test flakes passed on retry. |
| 316 | |
| 317 | `make staticcheck` with its `browser,perf,testbuild` tags reaches only the |
| 318 | known macOS `internal/toolproxy` O_PATH compile failure. The same pinned |
| 319 | v0.7.0 checker, built as a host binary and run with `GOOS=linux GOARCH=amd64` |
| 320 | and those tags over `./...`, passes. Setting GOOS directly on `go run` cannot |
| 321 | run the resulting Linux checker binary on macOS, so the host binary is needed. |
| 322 | The real browser CSP test passes again (8.936s). No new mutation is needed |
| 323 | for a spelling-only status constant substitution; the 84 killing mutations |
| 324 | and runtime behavior are unchanged. |
| 325 | |
| 326 | ## Review fixes (Fable, 2026-11-23) |
| 327 | |
| 328 | Fable's review at 25d44365 (aec3228d added only the perf-lane fix). The |
| 329 | original implementer was out of usage, so these fixes were made on |
| 330 | `fix/connect-app` from `origin/github/connect-app` and pushed back to that |
| 331 | branch. Every command used `GOTOOLCHAIN=go1.26.11 CGO_ENABLED=0` with the |
| 332 | pinned GOROOT/bin first on PATH. New tests live in |
| 333 | `internal/equipo/github/review_fixes_test.go`, |
| 334 | `internal/equipotest/github_review_test.go`, |
| 335 | `internal/equipo/github_view_test.go` and the rewritten value search in |
| 336 | `internal/equipotest/github_app_test.go`. |
| 337 | |
| 338 | ### Test-first |
| 339 | |
| 340 | - `go test ./internal/equipo/github -count=1` with the new tests, after only |
| 341 | the typed-state names, `ErrBusy` and a stub `Retryable` were added so it |
| 342 | compiled: runtime failures in `TestForgeAbandonedStarts` (start-back-start, |
| 343 | converted-then-superseded, three-abandoned, latest-per-account), |
| 344 | `TestForgeReinstallClearsUninstallClock` (suspended, too_many, |
| 345 | rate_limited), `TestForgeBusyCheckIsRetryable`, `TestForgeStuckConversion` |
| 346 | (both), `TestForgeManifestCodeShape` (all eight malformed codes spent the |
| 347 | state; the dotted code was refused) and |
| 348 | `TestMetadataLockNotHeldAcrossNetwork` (Forget blocked for 2s). The new |
| 349 | P3-2 guard tests passed against the old code, as expected for existing |
| 350 | guards; they are proved by mutation below. |
| 351 | - The new HTTP tests were run against the original source with the source |
| 352 | changes stashed: `TestGitHubAbandonedStartsPage` failed ("start-back-start |
| 353 | claimed an App remains") and `TestGitHubBusyCheckNotice` failed (redirect |
| 354 | to `?failed=1`). `TestGitHubHTTPFlowAndValues` and `TestGitHubSettingsNav` |
| 355 | passed, since there was no leak and the nav guard existed; both are proved |
| 356 | by planting and mutation. |
| 357 | - The rendering contract tests (`TestGitHubStateCopy`, |
| 358 | `TestGitHubRenderedKeys`, `TestGitHubSweepLog`) were written against the |
| 359 | new signatures, so the old code could not compile them. They are proved by |
| 360 | the P3-6 and P3-7 mutations. |
| 361 | |
| 362 | ### Findings |
| 363 | |
| 364 | **P2-1, value search.** The search now looks for single-line fragments that |
| 365 | survive JSON, slog and HTML escaping: a PEM body line, and the standard |
| 366 | base64 of the key's DER. It also looks for the client secret, webhook |
| 367 | secret, token, code and both states. Each sink is labelled, and the search |
| 368 | checks both the raw sink and its HTML-unescaped form. All tables are dumped |
| 369 | after conversion, after Connect and after Disconnect. Plants were killed: |
| 370 | PEM in `app_name` at conversion ("PEM body line escaped into table |
| 371 | forge_connections after conversion"); PEM in an slog line ("into log"); PEM |
| 372 | rendered in the page HTML through the login heading, with the row restored |
| 373 | before the next dump ("into page"). |
| 374 | |
| 375 | **P2-2, abandoned starts and dead rows.** A typed `abandoned` state is used |
| 376 | for a start whose manifest callback never arrived. Start (supersede) and |
| 377 | Disconnect use it, it is never rendered, and Start returns `Superseded` |
| 378 | only for an attempt GitHub called back. `List` returns every live or pending |
| 379 | connection. For dead attempts it returns only the latest per account (login |
| 380 | and type), only if it is not `abandoned`, and only while that account has no |
| 381 | active connection. |
| 382 | |
| 383 | Ruling as applied: an App is known to exist once GitHub redirected with a |
| 384 | manifest code (state reached `converting`). GitHub creates the App before |
| 385 | that redirect. This keeps the brief's `manifest_expired` and failed- |
| 386 | conversion rows, both of which show `app_remains`, and drops every attempt |
| 387 | that never reached GitHub. |
| 388 | |
| 389 | Tests: start-back-start shows no notice (store and page); |
| 390 | converted-then-superseded shows exactly one (store, Start response and |
| 391 | page); three abandoned starts leave one row (the current start) and no |
| 392 | notice; disconnect-before-callback lists nothing; latest per account, hidden |
| 393 | once that account is connected again. |
| 394 | |
| 395 | **P3-1, uninstall clock.** When the JWT's installation list and the |
| 396 | installation read see a matching installation, in any state (live, |
| 397 | suspended, over the limit, or with a failed inventory), Check clears |
| 398 | `UninstalledAt`. The expiry check still runs first. Test: uninstall, wait 3 |
| 399 | days, reinstall suspended / 1001 repositories / 503 inventory, wait 5 more |
| 400 | days, sweep: the key is kept. |
| 401 | |
| 402 | **P3-2, guard tests.** Connect's own transaction rechecks the roster: the |
| 403 | owner is removed inside Check's committed transaction, and Connect must not |
| 404 | confirm. `InstallationURL` checks the owner, the session and the deadline. |
| 405 | Duplicate matching installations: the twin is listed first, so the mutant |
| 406 | would pick the genuine one and reach `ready`. Disconnect revokes and drops |
| 407 | the metadata token. The Settings nav hides GitHub from members and when the |
| 408 | flag is off (`data-settings-link="github"`). |
| 409 | |
| 410 | **P3-3, busy Check.** `github.Retryable` covers `ErrBusy` (a held claim, |
| 411 | or a lost generation/claim fence in Check or Connect), `ErrUnavailable`, |
| 412 | `ErrRateLimit` and context deadline/cancel. The handlers and callbacks |
| 413 | redirect those to `?failed=check`, which renders `github.check_failed`. Any |
| 414 | other non-refusal error still goes to `?failed=1`, which renders |
| 415 | `github.setup_failed`. Test: a double-tapped Check on a live connection shows |
| 416 | check_failed, not setup_failed, and the connected state is kept. |
| 417 | |
| 418 | **P3-4, stuck conversion.** Conversion now records the App id and slug in |
| 419 | its own fenced transaction (`forge.convert_app`) as soon as GitHub returns |
| 420 | an App for the intended account, before verification. Sweep moves any |
| 421 | `converting` row whose last write is older than 2 minutes to `failed`, |
| 422 | erases its hashes and frees the pending slot. It then renders |
| 423 | `setup_failed` + `app_remains` with the link. The link uses the slug when |
| 424 | the App id was recorded, otherwise the account's Apps list, per the brief. |
| 425 | Tests: a claimed callback with no conversion (a lost process), and a failed |
| 426 | final transaction with the App id recorded; each is not swept at 1 minute |
| 427 | and is swept at 3. |
| 428 | |
| 429 | **P3-5, metadata lock.** `metadata()` holds the mutex only to read or swap |
| 430 | the cache. `Forget` advances a per-App epoch, so a token minted across a |
| 431 | Forget is revoked and refused instead of being stored. A token displaced by |
| 432 | a concurrent mint is revoked. Test: a blocking fake on `access_tokens`; |
| 433 | Forget returns within 2s, the late token is revoked once and the map is |
| 434 | empty. |
| 435 | |
| 436 | **P3-6, rendering contract.** `github.State` is a typed string with 19 |
| 437 | constants in `github.States`. `githubStateKeys` switches over them with no |
| 438 | default: an unknown state returns an error, and `abandoned` returns a |
| 439 | hidden-state error. The handlers turn either into the unavailable page. |
| 440 | `TestGitHubStateCopy` requires an explicit fixture for every typed state. |
| 441 | `TestGitHubRenderedKeys` takes the union of every row's rendered keys |
| 442 | (lines and action labels) over every state, both account types and both |
| 443 | count shapes, the two notices and the template's literal `copy "github.*"` |
| 444 | keys. It asserts that the union equals exactly the brief's 31 branch-A keys. |
| 445 | |
| 446 | **P3-7, sweep log.** `logGitHubSweep` logs `copyGitHubSweep` ("Could not |
| 447 | clear expired GitHub setups.") with `err_type` (`%T`) and `kind` |
| 448 | (access/busy/unavailable/timeout/other) only, never the error text. The |
| 449 | controller approved the constant on 2026-11-23. Like its unmarked siblings |
| 450 | `copyAuthSweep` and `copyNonceSweep`, it has no acceptance marker. Luna |
| 451 | review queued for 11-25. `make copy-release-check` passes. |
| 452 | |
| 453 | **P3-8, manifest code.** `ValidCode` (`^[A-Za-z0-9._-]{1,256}$`, and not |
| 454 | `.` or `..`, which would be path dot-segments) is checked before the state |
| 455 | is claimed, and again in `API.Convert`. Tests: empty, `/`, space, `%2F`, |
| 456 | `?`, `.`, `..` and 257 characters are each refused, the state is unspent, |
| 457 | and the same state then converts. A dotted 208-character code converts. |
| 458 | |
| 459 | **Left for branch B:** every Check bumps the generation, so cached |
| 460 | inventory pages are always discarded (`store.go` save, `inventory_cache.go` |
| 461 | generation compare). Unchanged here. |
| 462 | |
| 463 | ### Mutations |
| 464 | |
| 465 | Each mutation was applied by a scratch runner that backs up the file, |
| 466 | replaces one exact span, runs the named test, classifies the result as |
| 467 | killed (a runtime `--- FAIL`) or survived/invalid, and restores the file. |
| 468 | The final restored tests pass. |
| 469 | |
| 470 | | Guard mutation | Killing test | Result | |
| 471 | | --- | --- | --- | |
| 472 | | PEM stored in app_name at conversion | `TestGitHubHTTPFlowAndValues` | killed | |
| 473 | | PEM planted in a log line | `TestGitHubHTTPFlowAndValues` | killed | |
| 474 | | PEM planted in page HTML | `TestGitHubHTTPFlowAndValues` | killed | |
| 475 | | supersede ignores callback | `TestForgeAbandonedStarts`, `TestGitHubAbandonedStartsPage` | killed | |
| 476 | | List shows every dead row | `TestForgeAbandonedStarts` | killed | |
| 477 | | List keeps notice after reconnection | `TestForgeAbandonedStarts` | killed | |
| 478 | | List shows every dead attempt per account | `TestForgeAbandonedStarts` | killed | |
| 479 | | List shows abandoned rows | `TestForgeAbandonedStarts` | killed | |
| 480 | | Disconnect before callback claims an App | `TestForgeAbandonedStarts` | killed | |
| 481 | | reinstall keeps uninstall clock | `TestForgeReinstallClearsUninstallClock` | killed (first form unused-variable INVALID, rerun with `&& false`) | |
| 482 | | Connect transaction skips owner check | `TestForgeConnectOwnerInOwnTransaction` | killed | |
| 483 | | InstallationURL owner | `TestForgeInstallationURLBinding/owner` | killed | |
| 484 | | InstallationURL session | `TestForgeInstallationURLBinding/session` | killed | |
| 485 | | InstallationURL deadline | `TestForgeInstallationURLBinding/deadline` | killed | |
| 486 | | duplicate installations | `TestForgeDuplicateInstallations` | killed (first run died on the fake's unexpected route; twin reordered so the test's own assertion kills it) | |
| 487 | | Disconnect keeps metadata token | `TestForgeDisconnectDropsToken` | killed | |
| 488 | | nav shows GitHub to members | `TestGitHubSettingsNav/member` | killed | |
| 489 | | nav shows GitHub with flag off | `TestGitHubSettingsNav/flag-off` | killed | |
| 490 | | retryable maps to setup_failed | `TestGitHubBusyCheckNotice` | killed | |
| 491 | | busy claim is ErrAccess | `TestForgeBusyCheckIsRetryable` | killed | |
| 492 | | Retryable omits rate limit | `TestForgeBusyCheckIsRetryable` | killed | |
| 493 | | no stuck-conversion sweep | `TestForgeStuckConversion` | killed | |
| 494 | | sweep ignores the 2-minute bound | `TestForgeStuckConversion` | killed | |
| 495 | | App id not recorded before verify | `TestForgeStuckConversion/app-id` | killed | |
| 496 | | lock held across token mint | `TestMetadataLockNotHeldAcrossNetwork` | killed | |
| 497 | | token kept across Forget | `TestMetadataLockNotHeldAcrossNetwork` | killed (first form unused-variable INVALID, rerun with `&& false`) | |
| 498 | | remove too_many mapping | `TestGitHubStateCopy`, `TestGitHubRenderedKeys` | killed | |
| 499 | | unknown state falls through silently | `TestGitHubStateCopy` | killed | |
| 500 | | exchange the two redirect-expiry mappings | `TestGitHubStateCopy` | killed | |
| 501 | | hidden state rendered | `TestGitHubStateCopy` | killed | |
| 502 | | extra key outside the brief | `TestGitHubRenderedKeys` | killed | |
| 503 | | sweep log carries error text | `TestGitHubSweepLog` | killed | |
| 504 | | sweep log uses a UI string | `TestGitHubSweepLog` | killed | |
| 505 | | code checked after state spent | `TestForgeManifestCodeShape` | killed | |
| 506 | | dot refused | `TestForgeManifestCodeShape/dotted` | killed | |
| 507 | | dot segment allowed | `TestForgeManifestCodeShape/..` | killed | |
| 508 | | code length unbounded | `TestForgeManifestCodeShape` | killed | |
| 509 | |
| 510 | 37 mutations killed by runtime assertions. The two INVALID first attempts |
| 511 | are excluded from the count and their corrected forms are counted. |
| 512 | |
| 513 | ### Gates |
| 514 | |
| 515 | - `make fmt-check migration-check copy-release-check lanes-check`: pass. |
| 516 | - `go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget size`: 92 |
| 517 | directories within budget, after raising `internal/equipo` to its |
| 518 | measured 22577 source lines and `internal/equipotest` to 12626 test lines, |
| 519 | with extended reasons (each under the 200-byte record limit checked by |
| 520 | `TestBudgetRecordsAreShort`). CI on aec3228d had already failed equipotest at 12472. |
| 521 | - Pinned staticcheck v0.7.0 built as a host binary and run with |
| 522 | `GOOS=linux GOARCH=amd64 -tags browser,perf,testbuild ./...`: clean. |
| 523 | Linux-target vet on the touched packages: clean. |
| 524 | - `go test ./internal/equipo/... -count=1`: everything passes except |
| 525 | `internal/equipo/team` `TestPublishCoreAuthorizationContract` ("team: |
| 526 | invalid"), which fails the same way on untouched aec3228d on this Mac. |
| 527 | - `go test ./internal/equipotest -count=1` (skipping the two system-Python |
| 528 | release tests): 282.8s, everything passes except |
| 529 | `TestExecutionStartupClosed`, `TestExecutionHibernateWitness`, |
| 530 | `TestExecutionStartupReconciliation` and `TestExecutionCarlosMarkerLayout`. |
| 531 | All four fail identically on untouched aec3228d on this Mac. Linux CI decides. |
| 532 | - Perf lane `go test -tags perf,testbuild -run 'TestPerfScreens$' ./internal/equipotest`: pass. |
| 533 | - Post-commit on 7bf6afe3: `python3 scripts/runner-dead-references.py` |
| 534 | (2698 text files, 3210 matches, 0 failures); `make gitleaks` (1131 |
| 535 | commits, no leaks). |
| 536 | |
| 537 | ### CI correction |
| 538 | |
| 539 | CI on 7bf6afe3 failed two shards, both on records rather than behavior. |
| 540 | Shard 17: `TestBudgetRecordsAreShort`, because the equipotest budget reason |
| 541 | was 255 bytes, over the 200-byte limit. Both touched reasons are now |
| 542 | shortened. Shard 16: `TestPlan3ReleaseBoundaries/inventory`, because the new |
| 543 | `copyGitHubSweep` constant had no row in the Plan 3 copy inventory. The row |
| 544 | is added beside the GitHub rows with status `COPY REVIEW REQUIRED` (Luna |
| 545 | review queued for 11-25). `make copy-release-check` reads only copy.go and |
| 546 | still passes. The CI failure is itself the killing evidence for the |
| 547 | inventory guard. Locally, `TestBudgetRecordsAreShort`, |
| 548 | `TestPlan3ReleaseBoundaries`, `make copy-release-check` and `budget size` |
| 549 | pass. `plan3test` `TestCoordinatorAcceptance3B` fails on this Mac |
| 550 | (`provider_uncertain`, runner journal) but passed in CI shard 16 on 7bf6afe3. |
| 551 | |
| 552 | ## Re-review fixes (Fable, 2026-11-25) |
| 553 | |
| 554 | Fable re-reviewed d0f321d0 and confirmed every earlier finding fixed. One P2 |
| 555 | (the release gate) and five P3s remained. These were fixed on a fresh |
| 556 | `fix/connect-app` from `origin/github/connect-app`, with the same pinned |
| 557 | toolchain. Then origin/main 927a031a (paused work, protocol 29) was merged in. |
| 558 | |
| 559 | **P2, release gate.** On d0f321d0, `python3 scripts/plan3-copy-check.py` |
| 560 | exited 1 because the `copyGitHubSweep` inventory row said |
| 561 | `COPY REVIEW REQUIRED`. Luna approved the string unchanged on 2026-11-25. The |
| 562 | row now reads `COPY ACCEPTED BY DELEGATION (Luna, 2026-11-25)`, and |
| 563 | `plan3_release_test.go` gains an `acceptedGitHubSweep` rule for exactly that |
| 564 | key and marker. The constant stays unmarked in copy.go, like its siblings, |
| 565 | because the check does not need a marker there. `plan3-copy-check.py` now |
| 566 | exits 0. Mutation: disabling the rule failed the inventory test ("entry has |
| 567 | no copy review status or applicable acceptance copyGitHubSweep"). The first |
| 568 | form of that mutation was INVALID (unused variable) and was replaced. |
| 569 | |
| 570 | **P3-1, BLOB columns.** The table dump turns `[]byte` values into strings |
| 571 | before `json.Marshal`, which would otherwise base64 them. Plant: the PEM |
| 572 | written into `app_name` with `CAST(? AS BLOB)` just before the |
| 573 | after-conversion dump, then restored. It was killed ("PEM body line escaped |
| 574 | into table forge_connections after conversion"). Control: the same plant |
| 575 | with the conversion disabled SURVIVED, which proves the old dump could not |
| 576 | see a BLOB key. The first control run was caught later only because |
| 577 | Disconnect rewrote the planted `app_name` as TEXT, so both plants now |
| 578 | restore the column straight after the dump. |
| 579 | |
| 580 | **P3-2, lost fences.** `TestForgeCheckLostFenceIsBusy`: a Check is blocked |
| 581 | mid-inventory past its 30-second claim; another owner's Check takes over; |
| 582 | the first must return `ErrBusy` (Retryable). `TestForgeConnectLostFenceIsBusy`: |
| 583 | the generation moves inside Connect's own transaction; Connect must return |
| 584 | `ErrBusy` and must not confirm. Reverting either line to `ErrAccess` was |
| 585 | killed. |
| 586 | |
| 587 | **P3-3, sweep log wiring.** `TestGitHubSweepFailureLogged` builds the real |
| 588 | router, drops `forge_connections`, and calls `equipo.Configure`, which |
| 589 | starts the serving loops. The minute loop's first pass must log "Could not |
| 590 | clear expired GitHub setups." with `kind=other` and `err_type`, and no |
| 591 | table name or UI string. Killed: the loop logging the old UI string, and |
| 592 | the loop dropping the sweep error. |
| 593 | |
| 594 | **P3-4, expired starts.** `List` hides a `manifest` row once its |
| 595 | `RedirectUntil` has passed. Nothing is erased, so a late callback still |
| 596 | gets `manifest_expired`, and that row is then listed with its cleanup link. |
| 597 | `TestForgeExpiredManifestStartHidden` failed first (the start was still |
| 598 | listed at 10 minutes), then passed. Killed: the hide removed, and a hide |
| 599 | that erases the manifest hash ("late callback lost its answer"). |
| 600 | |
| 601 | **P3-5, surviving guards.** `TestForgeInstallationURLRoster`: a removed |
| 602 | owner gets no installation handoff; removing `InstallationURL`'s own Owner |
| 603 | check was killed. `TestMetadataDisplacedTokenRevoked`: two concurrent |
| 604 | mints, where the first store displaces the second token, which must be |
| 605 | revoked; skipping that revoke was killed. |
| 606 | |
| 607 | **Merge of origin/main 927a031a** (merge commit, no rebase). Conflicts: |
| 608 | - `schema.sql` keeps the 0102 forge tables before main's 0104-0106 |
| 609 | statements. The migration numbers don't collide (branch 0102, main |
| 610 | 0103-0106). |
| 611 | - The Plan 3 inventory keeps both the GitHub rows and the paused-work |
| 612 | rows. |
| 613 | - The release test's acceptance condition keeps `acceptedGitHubApp`, |
| 614 | `acceptedGitHubSweep`, `acceptedPaused` and `acceptedNewTeamCard`. The |
| 615 | rest of the condition was identical on both sides, which the resolution |
| 616 | asserted. |
| 617 | - Budgets were re-measured: `internal/equipo` 23029, `internal/equipotest` |
| 618 | 0/12683, `internal/plan3test` 11912, `internal/runner/thin` 28488/22754. |
| 619 | `internal/wire` stays at main's 6946. Every reason is under 200 bytes. |
| 620 | - copy.go, app.go and handlers.go merged cleanly. Branch A has no wire or |
| 621 | protocol changes, so protocol 29 is main's. |
| 622 | |
| 623 | **Gates on the merged tree.** |
| 624 | - Pass: `make fmt-check migration-check copy-release-check lanes-check`, |
| 625 | `python3 scripts/plan3-copy-check.py` (exit 0), `budget size` (93 |
| 626 | directories), `TestBudgetRecordsAreShort`, the perf lane, and the |
| 627 | `internal/equipo/github` package. |
| 628 | - Linux vet on the touched packages and pinned staticcheck v0.7.0 |
| 629 | (`GOOS=linux GOARCH=amd64 -tags browser,perf,testbuild ./...`): clean. |
| 630 | - Mac-only failures, each confirmed identical on untouched origin/main |
| 631 | 927a031a: |
| 632 | - `internal/equipo/team`: `TestPublishCoreAuthorizationContract`. |
| 633 | - `internal/equipotest` (292.5s): `TestRunnerHTTPExpiredLeaseDefinitive`, |
| 634 | `TestRunnerJournalServerCommitBeforeACK`, |
| 635 | `TestDirectCompletionServerCommitBeforeACK` (all `provider_uncertain`, |
| 636 | arriving with main), and the four `TestExecution*` startup tests. |
| 637 | - `internal/plan3test`: `TestCoordinatorAcceptance3B`. |
| 638 | |
| 639 | Linux CI decides. |
| 640 | |