oficina / equipo Public

Fix GitHub connect review findings: rows, notices, sweeps

Abandoned starts no longer claim an App; List shows live and pending
connections and only each account's latest dead attempt with an App.
A seen reinstall stops the uninstall clock; busy or transient Check
errors show check_failed; stuck conversions sweep to failed with the
recorded App; the metadata mutex is never held across a request.
States are a typed enum rendered without a default, the value search
uses escaped-key fragments in three phases, and the manifest code is
validated before its state is spent.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Paul Campbell pushed by claude agent, operated by paul@keymail.dev 7bf6afe3e03c7b5693bf7b17f015d95d6b478a66 parent aec3228
15 files changed, +1,305 −169
  • .rastrillo/budgets.txt +2 −2
  • docs/superpowers/plans/CONTROLLER-REPORT-github-connect-app.md +207 −0
  • internal/equipo/app.go +1 −1
  • internal/equipo/copy.go +1 −0
  • internal/equipo/github/callback.go +43 −14
  • internal/equipo/github/check.go +32 −22
  • internal/equipo/github/client.go +37 −3
  • internal/equipo/github/models.go +49 −5
  • internal/equipo/github/review_fixes_test.go +443 −0
  • internal/equipo/github/store.go +50 −8
  • internal/equipo/github_http.go +24 −18
  • internal/equipo/github_view.go +109 −42
  • internal/equipo/github_view_test.go +128 −29
  • internal/equipotest/github_app_test.go +54 −25
  • internal/equipotest/github_review_test.go +125 −0

CI failed — run details

CI log
=== prepare ===
ci-box: machine: aarch64, 32 CPUs, 62 GiB memory, kernel 7.0.0-1017-aws
ci-box: python 3.12.3; Docker version 29.1.3, build 29.1.3-0ubuntu3~24.04.2
ci-box: user namespaces allowed: 233151
ci-box: cgroup: cgroup2fs
ci-box: disk /home/ci/work/repos/oficina__equipo/wt/github__connect-app: Type  Size Avail | ext4   96G   84G
ci-box: disk /home/ci/.cache/equipo-ci-box: Type  Size Avail | ext4   96G   84G
ci-box: bwrap: fetched and verified in 0.3s
ci-box: claude: fetched and verified in 1.4s
ci-box: codex: fetched and verified in 3.4s
ci-box: codex-code-mode-host: fetched and verified in 1.3s
ci-box: libwrap: fetched and verified in 0.3s
ci-box: socat: fetched and verified in 0.3s
npm warn deprecated node-domexception@1.0.0: Use your platform's native DOMException instead
ci-box: image pulled in 10.0s
ci-box: pi: installed and verified in 7.8s
ci-box: opencode: installed and verified in 2.3s
ci-box: chromium 156.0.8078.79-1~deb13u1: 76 packages fetched, verified and unpacked in 8.8s
ci-box: clone deepened in 3.9s
ci-box: file times set from content: 2985 files, 193 directories
ci-box: ready in 17.8s
=== copy ===
EQUIPO_RELEASE_COPY_CHECK=1 CGO_ENABLED=0 go test ./internal/equipotest -run '^TestReleaseCopyReviewed$' -count=1
ok  	amadan.net/oficina/equipo/internal/equipotest	0.148s
=== compile ===
go build ./...
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py compile
+ go build -tags testbuild ./...
  2.6s
+ go list -export -test -tags testbuild -f  ./...
  3.7s
+ go list -export -test -tags browser,testbuild -f  ./internal/equipo ./internal/equipotest ./internal/headless ./internal/idtest ./internal/plan3test ./internal/thintest
  3.4s
go run honnef.co/go/tools/cmd/staticcheck@v0.7.0 -version
staticcheck 2026.1 (v0.7.0)
go run golang.org/x/vuln/cmd/govulncheck@v1.8.0 -version
Go: go1.26.11
Scanner: govulncheck@v1.8.0
DB: https://vuln.go.dev
DB updated: 2026-11-23 20:05:14 +0000 UTC

go run github.com/zricethezav/gitleaks/v8@v8.30.1 version
version is set by build process
=== check ===
--- shard 0 of 29 ---
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py shard
test lane headless-work: ./internal/headless
timing budgets: reported, not enforced: a shared runner's load is not this change's time (set EQUIPO_CI_DEDICATED=1 on a dedicated runner)
+ go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -tags testbuild -timeout 15m -run '^TestHeadless$/^4c_rebase$|^TestHeadless$/^4b_ask$|^TestHeadless$/^4c_checks_card$|^TestHeadless$/^4_step_crash$' ./internal/headless

receipt: test step 1m15.517s against a 60s target (the gate's other steps are not in this figure)
receipt: 1 packages ran, 0 cached, 0 without tests, 0 failed
receipt: slow package 1m14s amadan.net/oficina/equipo/internal/headless
receipt: slow test 1m14s amadan.net/oficina/equipo/internal/headless TestHeadless
machine: 32 CPUs, load 56.59, cpu waiting 35.76%, memory waiting 0.00%, io waiting 0.47%
--- shard 1 of 29 ---
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py shard
test lane headless-review: ./internal/headless
timing budgets: reported, not enforced: a shared runner's load is not this change's time (set EQUIPO_CI_DEDICATED=1 on a dedicated runner)
+ go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -tags testbuild -timeout 15m -run '^TestHeadless$/^4_review$|^TestHeadless$/^2b_access$|^TestHeadless$/^runner_crash$|^TestHeadless$/^2b_first_message$|^TestHeadless$/^4_checks_honest$|^TestHeadless$/^7_stream_resume$|^TestHeadless$/^2b_notebook$|^TestHeadless$/^2b_move_in$|^TestHeadless$/^2b_desk_failure$|^TestHeadless$/^cancel$' ./internal/headless

receipt: test step 1m15.37s against a 60s target (the gate's other steps are not in this figure)
receipt: 1 packages ran, 0 cached, 0 without tests, 0 failed
receipt: slow package 1m13.812s amadan.net/oficina/equipo/internal/headless
receipt: slow test 1m13.81s amadan.net/oficina/equipo/internal/headless TestHeadless
machine: 32 CPUs, load 56.59, cpu waiting 35.76%, memory waiting 0.00%, io waiting 0.47%
--- shard 2 of 29 ---
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py shard
test lane headless-connections: ./internal/headless
timing budgets: reported, not enforced: a shared runner's load is not this change's time (set EQUIPO_CI_DEDICATED=1 on a dedicated runner)
+ go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -tags testbuild -timeout 15m -run '^TestHeadlessConnections$|^TestHeadlessTokenPasteEndToEnd$|^TestHeadlessTokenConnection$' ./internal/headless

receipt: test step 1m15.528s against a 60s target (the gate's other steps are not in this figure)
receipt: 1 packages ran, 0 cached, 0 without tests, 0 failed
receipt: slow package 1m13.812s amadan.net/oficina/equipo/internal/headless
receipt: slow test 1m4.54s amadan.net/oficina/equipo/internal/headless TestHeadlessConnections
receipt: slow test 5.13s amadan.net/oficina/equipo/internal/headless TestHeadlessTokenPasteEndToEnd
receipt: slow test 4.14s amadan.net/oficina/equipo/internal/headless TestHeadlessTokenConnection
machine: 32 CPUs, load 56.59, cpu waiting 35.76%, memory waiting 0.00%, io waiting 0.47%
--- shard 3 of 29 ---
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py shard
test lane headless-mac: ./internal/headless
timing budgets: reported, not enforced: a shared runner's load is not this change's time (set EQUIPO_CI_DEDICATED=1 on a dedicated runner)
+ go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -tags testbuild -timeout 15m -run '^TestMacWorker$|^TestHeadlessAttachments$|^TestHeadlessPrewarm$|^TestHeadless$/^1_first_token$|^TestHeadless$/^6_quick_messages$|^TestHeadless$/^8_instance_restart$|^TestHeadless$/^3_runner_offline$' ./internal/headless

receipt: test step 1m13.225s against a 60s target (the gate's other steps are not in this figure)
receipt: 1 packages ran, 0 cached, 0 without tests, 0 failed
receipt: slow package 1m11.464s amadan.net/oficina/equipo/internal/headless
receipt: slow test 35.21s amadan.net/oficina/equipo/internal/headless TestMacWorker
receipt: slow test 18.82s amadan.net/oficina/equipo/internal/headless TestHeadless
receipt: slow test 8.79s amadan.net/oficina/equipo/internal/headless TestHeadlessPrewarm
receipt: slow test 8.65s amadan.net/oficina/equipo/internal/headless TestHeadlessAttachments
machine: 32 CPUs, load 56.59, cpu waiting 35.52%, memory waiting 0.00%, io waiting 0.49%
--- shard 4 of 29 ---
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py shard
test lane headless-guards: ./internal/headless
timing budgets: reported, not enforced: a shared runner's load is not this change's time (set EQUIPO_CI_DEDICATED=1 on a dedicated runner)
+ go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -tags testbuild -timeout 15m -run '^TestHeadlessCopyRotation$|^TestHeadlessPolicyGuards$|^TestHeadlessRunnerKillLeavesNoCopies$|^TestHeadlessNewHouseRuleStartsFresh$|^TestHeadless$/^3_engineering$|^TestHeadless$/^3_step_cancel$|^TestHeadless$/^3_step_contained$|^TestHeadless$/^3_step_refused$|^TestHeadless$/^3_empty_repo$|^TestHeadless$/^3_empty_engineering$|^TestHeadless$/^3_empty_merge$|^TestHeadless$/^3_empty_merge_rebuilt$|^TestHeadless$/^3_empty_fix_round$' ./internal/headless

receipt: test step 1m30.513s against a 60s target (the gate's other steps are not in this figure)
receipt: 1 packages ran, 0 cached, 0 without tests, 0 failed
receipt: slow package 1m28.921s amadan.net/oficina/equipo/internal/headless
receipt: slow test 59.91s amadan.net/oficina/equipo/internal/headless TestHeadless
receipt: slow test 9.15s amadan.net/oficina/equipo/internal/headless TestHeadlessRunnerKillLeavesNoCopies
receipt: slow test 8.17s amadan.net/oficina/equipo/internal/headless TestHeadlessCopyRotation
receipt: slow test 7.04s amadan.net/oficina/equipo/internal/headless TestHeadlessPolicyGuards
receipt: slow test 4.66s amadan.net/oficina/equipo/internal/headless TestHeadlessNewHouseRuleStartsFresh
machine: 32 CPUs, load 50.95, cpu waiting 34.94%, memory waiting 0.00%, io waiting 0.36%
--- shard 5 of 29 ---
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py shard
test lane headless-rest: ./internal/headless
timing budgets: reported, not enforced: a shared runner's load is not this change's time (set EQUIPO_CI_DEDICATED=1 on a dedicated runner)
+ go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -tags testbuild -timeout 15m -skip '^TestHeadless$/^4c_rebase$|^TestHeadless$/^4b_ask$|^TestHeadless$/^4c_checks_card$|^TestHeadless$/^4_step_crash$|^TestHeadless$/^4_review$|^TestHeadless$/^2b_access$|^TestHeadless$/^runner_crash$|^TestHeadless$/^2b_first_message$|^TestHeadless$/^4_checks_honest$|^TestHeadless$/^7_stream_resume$|^TestHeadless$/^2b_notebook$|^TestHeadless$/^2b_move_in$|^TestHeadless$/^2b_desk_failure$|^TestHeadless$/^cancel$|^TestHeadlessConnections$|^TestHeadlessTokenPasteEndToEnd$|^TestHeadlessTokenConnection$|^TestMacWorker$|^TestHeadlessAttachments$|^TestHeadlessPrewarm$|^TestHeadless$/^1_first_token$|^TestHeadless$/^6_quick_messages$|^TestHeadless$/^8_instance_restart$|^TestHeadless$/^3_runner_offline$|^TestHeadlessCopyRotation$|^TestHeadlessPolicyGuards$|^TestHeadlessRunnerKillLeavesNoCopies$|^TestHeadlessNewHouseRuleStartsFresh$|^TestHeadless$/^3_engineering$|^TestHeadless$/^3_step_cancel$|^TestHeadless$/^3_step_contained$|^TestHeadless$/^3_step_refused$|^TestHeadless$/^3_empty_repo$|^TestHeadless$/^3_empty_engineering$|^TestHeadless$/^3_empty_merge$|^TestHeadless$/^3_empty_merge_rebuilt$|^TestHeadless$/^3_empty_fix_round$' ./internal/headless

receipt: test step 2m41.519s against a 60s target (the gate's other steps are not in this figure)
receipt: 1 packages ran, 0 cached, 0 without tests, 0 failed
receipt: slow package 2m39.769s amadan.net/oficina/equipo/internal/headless
receipt: slow test 1m34.19s amadan.net/oficina/equipo/internal/headless TestHeadlessAssistant
receipt: slow test 18.35s amadan.net/oficina/equipo/internal/headless TestHeadless
receipt: slow test 8.69s amadan.net/oficina/equipo/internal/headless TestHeadlessResearchHandoff
receipt: slow test 6.52s amadan.net/oficina/equipo/internal/headless TestHeadlessTurnBatching
receipt: slow test 6.47s amadan.net/oficina/equipo/internal/headless TestHeadlessBatchAfterRefusedReply
machine: 32 CPUs, load 22.16, cpu waiting 12.04%, memory waiting 0.00%, io waiting 0.10%
--- shard 6 of 29 ---
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py shard
test lane thintest: ./internal/thintest
timing budgets: reported, not enforced: a shared runner's load is not this change's time (set EQUIPO_CI_DEDICATED=1 on a dedicated runner)
+ go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -tags testbuild -timeout 15m -run '^Test([^C]|C[^o]|Co[^n]|Con[^t])|^TestContract(Assistant|Outcome|Team|Handoff|HostAllowlist|HostIsPerPerson|Look|Use[A-Z]|RemoteCall|LanesRunAtOnce|NoMergeQuestionWhenGateMerges|PreviewHeldUntilPublishAnswer|PreviewNotHeldBelow19|PublishNeedsOwnerAnswer)' ./internal/thintest

receipt: test step 2m4.536s against a 60s target (the gate's other steps are not in this figure)
receipt: 1 packages ran, 0 cached, 0 without tests, 0 failed
receipt: slow package 2m2.947s amadan.net/oficina/equipo/internal/thintest
receipt: slow test 8.17s amadan.net/oficina/equipo/internal/thintest TestContractTeamJobSettledStates
receipt: slow test 6.73s amadan.net/oficina/equipo/internal/thintest TestExplorePreviewsOff
receipt: slow test 3.92s amadan.net/oficina/equipo/internal/thintest TestContractPreviewHeldUntilPublishAnswer
receipt: slow test 3.67s amadan.net/oficina/equipo/internal/thintest TestContractTeamNudgePersonNeeds
receipt: slow test 2.43s amadan.net/oficina/equipo/internal/thintest TestResearchDoneFallsBack
machine: 32 CPUs, load 33.84, cpu waiting 21.29%, memory waiting 0.00%, io waiting 0.20%
--- shard 7 of 29 ---
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py shard
test lane thintest-contract: ./internal/thintest
timing budgets: reported, not enforced: a shared runner's load is not this change's time (set EQUIPO_CI_DEDICATED=1 on a dedicated runner)
+ go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -tags testbuild -timeout 15m -skip '^Test([^C]|C[^o]|Co[^n]|Con[^t])|^TestContract(Assistant|Outcome|Team|Handoff|HostAllowlist|HostIsPerPerson|Look|Use[A-Z]|RemoteCall|LanesRunAtOnce|NoMergeQuestionWhenGateMerges|PreviewHeldUntilPublishAnswer|PreviewNotHeldBelow19|PublishNeedsOwnerAnswer)' ./internal/thintest
--- FAIL amadan.net/oficina/equipo/internal/thintest TestContractRetryAccountActions
=== RUN   TestContractRetryAccountActions
    retry_contract_test.go:296: sign in again
--- FAIL: TestContractRetryAccountActions (0.18s)

--- FAIL amadan.net/oficina/equipo/internal/thintest (package output)
FAIL
rastrillo-budget/v1 ran 1m26.821s
FAIL	amadan.net/oficina/equipo/internal/thintest	87.014s


receipt: test step 1m28.254s against a 60s target (the gate's other steps are not in this figure)
receipt: 0 packages ran, 0 cached, 0 without tests, 1 failed
receipt: slow package 1m26.821s amadan.net/oficina/equipo/internal/thintest
receipt: slow test 9.09s amadan.net/oficina/equipo/internal/thintest TestContractPreviewNotScheduled
receipt: slow test 5.04s amadan.net/oficina/equipo/internal/thintest TestContractPublishNotOffered
receipt: slow test 4.49s amadan.net/oficina/equipo/internal/thintest TestContractMacRecheckMergeAuthority
receipt: slow test 2.37s amadan.net/oficina/equipo/internal/thintest TestContractPublishNameTaken
receipt: slow test 2.36s amadan.net/oficina/equipo/internal/thintest TestContractPreview
rastrillo: budget test: go test failed
exit status 1
+ go test -tags testbuild -timeout 15m -skip '^Test([^C]|C[^o]|Co[^n]|Con[^t])|^TestContract(Assistant|Outcome|Team|Handoff|HostAllowlist|HostIsPerPerson|Look|Use[A-Z]|RemoteCall|LanesRunAtOnce|NoMergeQuestionWhenGateMerges|PreviewHeldUntilPublishAnswer|PreviewNotHeldBelow19|PublishNeedsOwnerAnswer)' -v -run '^TestContractRetryAccountActions$' -count=1 ./internal/thintest   (retry, once)
##############################################################################
FLAKE ./internal/thintest:TestContractRetryAccountActions thintest-contract 7bf6afe3e03c7b5693bf7b17f015d95d6b478a66 0.18s 50.95
##############################################################################
failed, then passed on its one retry: the step stays green and the flake is on record
machine: 32 CPUs, load 50.95, cpu waiting 34.94%, memory waiting 0.00%, io waiting 0.36%
--- shard 8 of 29 ---
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py shard
test lane runner-thin: ./internal/runner/thin
timing budgets: reported, not enforced: a shared runner's load is not this change's time (set EQUIPO_CI_DEDICATED=1 on a dedicated runner)
+ go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -tags testbuild -timeout 15m ./internal/runner/thin
cache miss: amadan.net/oficina/equipo/internal/runner/thin: its inputs changed
budget note: internal/runner/thin took 4m43.377s, over the 45s its record on line 44 allows; reported only, timing fails on CI

receipt: test step 4m57.407s against a 60s target (the gate's other steps are not in this figure)
receipt: 1 packages ran, 0 cached, 0 without tests, 0 failed
receipt: slow package 4m43.377s amadan.net/oficina/equipo/internal/runner/thin
receipt: slow test 36.99s amadan.net/oficina/equipo/internal/runner/thin TestModelsProbeAnsweredByAnotherModel
receipt: slow test 36.9s amadan.net/oficina/equipo/internal/runner/thin TestModelsEngineeringProbesThenRunsTheStrongest
receipt: slow test 36.82s amadan.net/oficina/equipo/internal/runner/thin TestModelsUnhealthyRetriedOnDemand
receipt: slow test 18.48s amadan.net/oficina/equipo/internal/runner/thin TestModelsProbeRunsInsideTheAdmission
receipt: slow test 7.02s amadan.net/oficina/equipo/internal/runner/thin TestOpenCodeStepsRealOpenCode
machine: 32 CPUs, load 2.88, cpu waiting 1.24%, memory waiting 0.00%, io waiting 0.00%
--- shard 9 of 29 ---
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py shard
test lane runner-bug: ./internal/runner
timing budgets: reported, not enforced: a shared runner's load is not this change's time (set EQUIPO_CI_DEDICATED=1 on a dedicated runner)
+ go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -tags testbuild -timeout 15m -run '^TestDirectBugWorkflow$|^TestEnrolKeepsTheRole$' ./internal/runner
cache miss: amadan.net/oficina/equipo/internal/runner: its inputs changed

receipt: test step 51.267s against a 60s target (the gate's other steps are not in this figure)
receipt: 1 packages ran, 0 cached, 0 without tests, 0 failed
receipt: slow package 50.04s amadan.net/oficina/equipo/internal/runner
receipt: slow test 30.01s amadan.net/oficina/equipo/internal/runner TestDirectBugWorkflow
receipt: slow test 20.03s amadan.net/oficina/equipo/internal/runner TestEnrolKeepsTheRole
machine: 32 CPUs, load 54.30, cpu waiting 31.18%, memory waiting 0.00%, io waiting 0.71%
--- shard 10 of 29 ---
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py shard
test lane runner-plans: ./internal/runner
timing budgets: reported, not enforced: a shared runner's load is not this change's time (set EQUIPO_CI_DEDICATED=1 on a dedicated runner)
+ go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -tags testbuild -timeout 15m -run '^TestPlanWorkflowCandidateOrder$|^TestPlanWorkflowFeature$|^TestCoordinatorRecoveryCallRefusalKeepsServing$|^TestCoordinatorRefusalMatrix$' ./internal/runner
cache miss: amadan.net/oficina/equipo/internal/runner: its inputs changed

receipt: test step 58.592s against a 60s target (the gate's other steps are not in this figure)
receipt: 1 packages ran, 0 cached, 0 without tests, 0 failed
receipt: slow package 56.701s amadan.net/oficina/equipo/internal/runner
receipt: slow test 46.58s amadan.net/oficina/equipo/internal/runner TestPlanWorkflowCandidateOrder
receipt: slow test 44.72s amadan.net/oficina/equipo/internal/runner TestPlanWorkflowFeature
receipt: slow test 8.4s amadan.net/oficina/equipo/internal/runner TestCoordinatorRecoveryCallRefusalKeepsServing
receipt: slow test 1.7s amadan.net/oficina/equipo/internal/runner TestCoordinatorRefusalMatrix
machine: 32 CPUs, load 61.07, cpu waiting 34.32%, memory waiting 0.00%, io waiting 0.64%
--- shard 11 of 29 ---
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py shard
test lane runner-rest: ./internal/runner
timing budgets: reported, not enforced: a shared runner's load is not this change's time (set EQUIPO_CI_DEDICATED=1 on a dedicated runner)
+ go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -tags testbuild -timeout 15m -skip '^TestDirectBugWorkflow$|^TestEnrolKeepsTheRole$|^TestPlanWorkflowCandidateOrder$|^TestPlanWorkflowFeature$|^TestCoordinatorRecoveryCallRefusalKeepsServing$|^TestCoordinatorRefusalMatrix$' ./internal/runner
cache miss: amadan.net/oficina/equipo/internal/runner: its inputs changed

receipt: test step 36.337s against a 60s target (the gate's other steps are not in this figure)
receipt: 1 packages ran, 0 cached, 0 without tests, 0 failed
receipt: slow package 35.42s amadan.net/oficina/equipo/internal/runner
receipt: slow test 5.13s amadan.net/oficina/equipo/internal/runner TestDirectFaultIsolation
receipt: slow test 3.36s amadan.net/oficina/equipo/internal/runner TestClaimRefusalsBackOff
receipt: slow test 3.13s amadan.net/oficina/equipo/internal/runner TestCoordinatorRecoveryRefusedKeepsServing
receipt: slow test 2.81s amadan.net/oficina/equipo/internal/runner TestToolVerbUnderFakeHarness
receipt: slow test 1.62s amadan.net/oficina/equipo/internal/runner TestCoordinatorTransientRefusalKeepsServing
machine: 32 CPUs, load 35.70, cpu waiting 19.80%, memory waiting 0.00%, io waiting 0.93%
--- shard 12 of 29 ---
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py shard
stagger: equipotest-a started 30s late; cpu waiting 38.9%, load 25.31
test lane equipotest-a: ./internal/equipotest
timing budgets: reported, not enforced: a shared runner's load is not this change's time (set EQUIPO_CI_DEDICATED=1 on a dedicated runner)
+ go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -tags testbuild -timeout 15m -run '^Test[A-D]|^TestQ' ./internal/equipotest

receipt: test step 1m8.214s against a 60s target (the gate's other steps are not in this figure)
receipt: 1 packages ran, 0 cached, 0 without tests, 0 failed
receipt: slow package 1m6.263s amadan.net/oficina/equipo/internal/equipotest
receipt: slow test 27.86s amadan.net/oficina/equipo/internal/equipotest TestAuthorityCoreIntegration
receipt: slow test 27.78s amadan.net/oficina/equipo/internal/equipotest TestBootstrapNamesOwnersSetting
receipt: slow test 25.56s amadan.net/oficina/equipo/internal/equipotest TestAccountLabelMigration
receipt: slow test 23.11s amadan.net/oficina/equipo/internal/equipotest TestBudgetConfigurationFailuresAreAtomic
receipt: slow test 22.87s amadan.net/oficina/equipo/internal/equipotest TestBudgetLoweringBelowUsage
machine: 32 CPUs, load 46.09, cpu waiting 32.14%, memory waiting 0.00%, io waiting 0.31%
--- shard 13 of 29 ---
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py shard
stagger: equipotest-e started 30s late; cpu waiting 38.9%, load 25.31
test lane equipotest-e: ./internal/equipotest
timing budgets: reported, not enforced: a shared runner's load is not this change's time (set EQUIPO_CI_DEDICATED=1 on a dedicated runner)
+ go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -tags testbuild -timeout 15m -run '^Test[E-P]' ./internal/equipotest

receipt: test step 2m9.488s against a 60s target (the gate's other steps are not in this figure)
receipt: 1 packages ran, 0 cached, 0 without tests, 0 failed
receipt: slow package 2m7.581s amadan.net/oficina/equipo/internal/equipotest
receipt: slow test 19.91s amadan.net/oficina/equipo/internal/equipotest TestProjectWritesRequireCurrentOwner
receipt: slow test 19.9s amadan.net/oficina/equipo/internal/equipotest TestProjectOwnersAreMembers
receipt: slow test 19.89s amadan.net/oficina/equipo/internal/equipotest TestProjectsReopen
receipt: slow test 19.87s amadan.net/oficina/equipo/internal/equipotest TestProjectsFailuresRollBack
receipt: slow test 19.85s amadan.net/oficina/equipo/internal/equipotest TestProjectsSharedAndGrouped
machine: 32 CPUs, load 22.16, cpu waiting 12.45%, memory waiting 0.00%, io waiting 0.11%
--- shard 14 of 29 ---
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py shard
stagger: equipotest-r started 30s late; cpu waiting 38.9%, load 25.31
test lane equipotest-r: ./internal/equipotest
timing budgets: reported, not enforced: a shared runner's load is not this change's time (set EQUIPO_CI_DEDICATED=1 on a dedicated runner)
+ go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -tags testbuild -timeout 15m -run '^TestR' ./internal/equipotest

receipt: test step 1m14.292s against a 60s target (the gate's other steps are not in this figure)
receipt: 1 packages ran, 0 cached, 0 without tests, 0 failed
receipt: slow package 1m9.123s amadan.net/oficina/equipo/internal/equipotest
receipt: slow test 15.58s amadan.net/oficina/equipo/internal/equipotest TestReleaseStampContract
receipt: slow test 13.5s amadan.net/oficina/equipo/internal/equipotest TestRosterChangesAffectExistingSession
receipt: slow test 10.5s amadan.net/oficina/equipo/internal/equipotest TestRosterRemovalWhileAssigned
receipt: slow test 10.31s amadan.net/oficina/equipo/internal/equipotest TestRosterRemovalRollsBack
receipt: slow test 7.42s amadan.net/oficina/equipo/internal/equipotest TestRosterBootstrapOnce
machine: 32 CPUs, load 42.80, cpu waiting 30.13%, memory waiting 0.00%, io waiting 0.29%
--- shard 15 of 29 ---
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py shard
stagger: equipotest-rest started 30s late; cpu waiting 38.9%, load 25.31
test lane equipotest-rest: ./internal/equipotest
timing budgets: reported, not enforced: a shared runner's load is not this change's time (set EQUIPO_CI_DEDICATED=1 on a dedicated runner)
+ go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -tags testbuild -timeout 15m -skip '^Test[A-D]|^TestQ|^Test[E-P]|^TestR' ./internal/equipotest

receipt: test step 1m8.414s against a 60s target (the gate's other steps are not in this figure)
receipt: 1 packages ran, 0 cached, 0 without tests, 0 failed
receipt: slow package 1m6.403s amadan.net/oficina/equipo/internal/equipotest
receipt: slow test 25.35s amadan.net/oficina/equipo/internal/equipotest TestSigninNoProof
receipt: slow test 24.62s amadan.net/oficina/equipo/internal/equipotest TestSpecialistsSeedExistingTeam
receipt: slow test 24.59s amadan.net/oficina/equipo/internal/equipotest TestSpecialistsSeedRollback
receipt: slow test 22.85s amadan.net/oficina/equipo/internal/equipotest TestSpecialistSettings
receipt: slow test 22.74s amadan.net/oficina/equipo/internal/equipotest TestSigninCSRF
machine: 32 CPUs, load 46.09, cpu waiting 33.16%, memory waiting 0.00%, io waiting 0.32%
--- shard 16 of 29 ---
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py shard
stagger: plan3test started 30s late; cpu waiting 38.9%, load 25.31
test lane plan3test: ./internal/plan3test
timing budgets: reported, not enforced: a shared runner's load is not this change's time (set EQUIPO_CI_DEDICATED=1 on a dedicated runner)
+ go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -tags testbuild -timeout 15m ./internal/plan3test
--- FAIL amadan.net/oficina/equipo/internal/plan3test TestPlan3ReleaseBoundaries
=== RUN   TestPlan3ReleaseBoundaries
--- FAIL: TestPlan3ReleaseBoundaries (0.39s)

--- FAIL amadan.net/oficina/equipo/internal/plan3test TestPlan3ReleaseBoundaries/inventory
=== RUN   TestPlan3ReleaseBoundaries/inventory
    plan3_release_test.go:22: pending copy omitted or changed in review inventory copyGitHubSweep
--- FAIL: TestPlan3ReleaseBoundaries/inventory (0.07s)

--- FAIL amadan.net/oficina/equipo/internal/plan3test (package output)
FAIL
rastrillo-budget/v1 ran 52.072s
FAIL	amadan.net/oficina/equipo/internal/plan3test	52.385s


receipt: test step 54.124s against a 60s target (the gate's other steps are not in this figure)
receipt: 0 packages ran, 0 cached, 0 without tests, 1 failed
receipt: slow package 52.072s amadan.net/oficina/equipo/internal/plan3test
receipt: slow test 3.74s amadan.net/oficina/equipo/internal/plan3test TestPlan3Upgrade
receipt: slow test 3.5s amadan.net/oficina/equipo/internal/plan3test TestCoordinatorAcceptance3B
receipt: slow test 1.66s amadan.net/oficina/equipo/internal/plan3test TestConversationQuestionRace
receipt: slow test 1.56s amadan.net/oficina/equipo/internal/plan3test TestCoordinatorAcceptance3A
receipt: slow test 1.31s amadan.net/oficina/equipo/internal/plan3test TestCoordinatorDefinitiveRefusalReleasesQueue
rastrillo: budget test: go test failed
exit status 1
+ go test -tags testbuild -timeout 15m -v -run '^TestPlan3ReleaseBoundaries$/^inventory$' -count=1 ./internal/plan3test   (retry, once)
FAILED TWICE ./internal/plan3test:TestPlan3ReleaseBoundaries/inventory plan3test
=== RUN   TestPlan3ReleaseBoundaries
=== RUN   TestPlan3ReleaseBoundaries/inventory
    plan3_release_test.go:22: pending copy omitted or changed in review inventory copyGitHubSweep
--- FAIL: TestPlan3ReleaseBoundaries (0.05s)
    --- FAIL: TestPlan3ReleaseBoundaries/inventory (0.05s)
FAIL
rastrillo-budget/v1 ran 52ms
FAIL	amadan.net/oficina/equipo/internal/plan3test	0.263s
FAIL
machine: 32 CPUs, load 53.12, cpu waiting 35.75%, memory waiting 0.00%, io waiting 0.40%
make: *** [Makefile:113: ci-shard] Error 1

amadan: step check shard 16 of 29 failed: exit status 2
--- shard 17 of 29 ---
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py shard
stagger: rest started 30s late; cpu waiting 38.9%, load 25.31
test lane rest: ./cmd/equipo ./cmd/equipo-runner ./cmd/equipo-tool-proxy ./internal/advice ./internal/attach ./internal/attach/attachtest ./internal/chatmarkdown ./internal/chatsend ./internal/chatstream ./internal/coordinator ./internal/coordinatorcontract ./internal/coordinatormail ./internal/copydesk ./internal/equipo ./internal/equipo/activity ./internal/equipo/assist ./internal/equipo/chat ./internal/equipo/conversation ./internal/equipo/conversation/chatstate ./internal/equipo/door ./internal/equipo/github ./internal/equipo/housekeeping ./internal/equipo/icons ./internal/equipo/identity ./internal/equipo/kernel ./internal/equipo/library ./internal/equipo/mergegate ./internal/equipo/notifications ./internal/equipo/oficina ./internal/equipo/oficina/oficinatest ./internal/equipo/oficinaid ./internal/equipo/ownermode ./internal/equipo/personapi ./internal/equipo/planning ./internal/equipo/push ./internal/equipo/setup ./internal/equipo/team ./internal/equipo/teamcontract ./internal/equipo/triage ./internal/fakeclaude ./internal/fakecodex ./internal/fakeopencode ./internal/fakepi ./internal/idtest ./internal/ownermodetest ./internal/release ./internal/runner/checks ./internal/runner/connect ./internal/runner/containment ./internal/runner/containment/sysunix ./internal/runner/egress ./internal/runner/forge ./internal/runner/forge/forgetest ./internal/runner/heartbeat ./internal/runner/mac ./internal/runner/mcpresource ./internal/runner/metered ./internal/runner/planflow ./internal/runner/provider ./internal/runner/provider/claude ./internal/runner/provider/claude/realcli ./internal/runner/provider/codex ./internal/runner/provider/gotoolchain ./internal/runner/provider/opencode ./internal/runner/provider/pi ./internal/runner/setup ./internal/runner/transporttest ./internal/runner/webread ./internal/runner/workspace ./internal/runnerproto ./internal/schedule ./internal/sealbox ./internal/specialist ./internal/stagingtest ./internal/taskplan ./internal/testci ./internal/toolproxy ./internal/websource ./internal/wire ./internal/wire/forgekey ./internal/wire/wireschema ./internal/wire/wiretest ./tools/drive
timing budgets: reported, not enforced: a shared runner's load is not this change's time (set EQUIPO_CI_DEDICATED=1 on a dedicated runner)
+ go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -tags testbuild -timeout 15m ./cmd/equipo ./cmd/equipo-runner ./cmd/equipo-tool-proxy ./internal/advice ./internal/attach ./internal/attach/attachtest ./internal/chatmarkdown ./internal/chatsend ./internal/chatstream ./internal/coordinator ./internal/coordinatorcontract ./internal/coordinatormail ./internal/copydesk ./internal/equipo ./internal/equipo/activity ./internal/equipo/assist ./internal/equipo/chat ./internal/equipo/conversation ./internal/equipo/conversation/chatstate ./internal/equipo/door ./internal/equipo/github ./internal/equipo/housekeeping ./internal/equipo/icons ./internal/equipo/identity ./internal/equipo/kernel ./internal/equipo/library ./internal/equipo/mergegate ./internal/equipo/notifications ./internal/equipo/oficina ./internal/equipo/oficina/oficinatest ./internal/equipo/oficinaid ./internal/equipo/ownermode ./internal/equipo/personapi ./internal/equipo/planning ./internal/equipo/push ./internal/equipo/setup ./internal/equipo/team ./internal/equipo/teamcontract ./internal/equipo/triage ./internal/fakeclaude ./internal/fakecodex ./internal/fakeopencode ./internal/fakepi ./internal/idtest ./internal/ownermodetest ./internal/release ./internal/runner/checks ./internal/runner/connect ./internal/runner/containment ./internal/runner/containment/sysunix ./internal/runner/egress ./internal/runner/forge ./internal/runner/forge/forgetest ./internal/runner/heartbeat ./internal/runner/mac ./internal/runner/mcpresource ./internal/runner/metered ./internal/runner/planflow ./internal/runner/provider ./internal/runner/provider/claude ./internal/runner/provider/claude/realcli ./internal/runner/provider/codex ./internal/runner/provider/gotoolchain ./internal/runner/provider/opencode ./internal/runner/provider/pi ./internal/runner/setup ./internal/runner/transporttest ./internal/runner/webread ./internal/runner/workspace ./internal/runnerproto ./internal/schedule ./internal/sealbox ./internal/specialist ./internal/stagingtest ./internal/taskplan ./internal/testci ./internal/toolproxy ./internal/websource ./internal/wire ./internal/wire/forgekey ./internal/wire/wireschema ./internal/wire/wiretest ./tools/drive
cache miss: amadan.net/oficina/equipo/internal/chatmarkdown: its inputs changed
cache miss: amadan.net/oficina/equipo/internal/copydesk: its inputs changed
cache miss: amadan.net/oficina/equipo/internal/runner/forge: its inputs changed
cache miss: amadan.net/oficina/equipo/internal/runner/provider/claude/realcli: its inputs changed
cache miss: amadan.net/oficina/equipo/internal/equipo/team: its inputs changed
cache miss: amadan.net/oficina/equipo/internal/runner/provider/opencode: its inputs changed
cache miss: amadan.net/oficina/equipo/internal/runner/webread: its inputs changed
cache miss: amadan.net/oficina/equipo/internal/runnerproto: its inputs changed
cache miss: amadan.net/oficina/equipo/internal/testci: its inputs changed
cache miss: amadan.net/oficina/equipo/internal/runner/workspace: its inputs changed
cache miss: amadan.net/oficina/equipo/internal/runner/checks: its inputs changed
cache miss: amadan.net/oficina/equipo/internal/runner/containment: its inputs changed
cache miss: amadan.net/oficina/equipo/internal/runner/provider/pi: its inputs changed
--- FAIL amadan.net/oficina/equipo/internal/testci TestBudgetRecordsAreShort
=== RUN   TestBudgetRecordsAreShort
    budgets_file_test.go:37: .rastrillo/budgets.txt:19: reason is 255 bytes, over 200
--- FAIL: TestBudgetRecordsAreShort (0.00s)

--- FAIL amadan.net/oficina/equipo/internal/testci (package output)
FAIL
rastrillo-budget/v1 ran 1.172s
FAIL	amadan.net/oficina/equipo/internal/testci	1.177s

budget note: internal/equipo took 49.019s, over the 10s the default allows; reported only, timing fails on CI
budget note: internal/equipo/chat took 20.935s, over the 10s the default allows (measured on the run this cached result came from); reported only, timing fails on CI
budget note: internal/equipo/github took 27.953s, over the 10s the default allows; reported only, timing fails on CI
budget note: internal/idtest took 1m48.976s, over the 10s the default allows; reported only, timing fails on CI
budget note: internal/release took 36.558s, over the 10s the default allows (measured on the run this cached result came from); reported only, timing fails on CI
budget note: internal/runner/containment took 47.276s, over the 15s its record on line 40 allows; reported only, timing fails on CI

receipt: test step 2m29.8s against a 60s target (the gate's other steps are not in this figure)
receipt: 22 packages ran, 43 cached, 17 without tests, 1 failed
receipt: slow package 1m48.976s amadan.net/oficina/equipo/internal/idtest
receipt: slow package 1m3.679s amadan.net/oficina/equipo/internal/runner/provider/opencode
receipt: slow package 53.526s amadan.net/oficina/equipo/internal/runner/provider/pi
receipt: slow package 49.019s amadan.net/oficina/equipo/internal/equipo
receipt: slow package 48.87s amadan.net/oficina/equipo/internal/runner/checks
receipt: slow test 52.63s amadan.net/oficina/equipo/internal/idtest TestDoorRemembersOficinaID
receipt: slow test 46.03s amadan.net/oficina/equipo/internal/idtest TestDoorOficinaSettingsUnreadableIsNoLoop
receipt: slow test 45.61s amadan.net/oficina/equipo/internal/idtest TestDoorNeverJudgesANativeSession
receipt: slow test 45.6s amadan.net/oficina/equipo/internal/idtest TestDoorForgetsOficinaIDForARefusedSession
receipt: slow test 44.69s amadan.net/oficina/equipo/internal/idtest TestDoorStepUpIsLocal
rastrillo: budget test: go test failed
exit status 1
+ go test -tags testbuild -timeout 15m -v -run '^TestBudgetRecordsAreShort$' -count=1 ./internal/testci   (retry, once)
FAILED TWICE ./internal/testci:TestBudgetRecordsAreShort rest
=== RUN   TestBudgetRecordsAreShort
    budgets_file_test.go:37: .rastrillo/budgets.txt:19: reason is 255 bytes, over 200
--- FAIL: TestBudgetRecordsAreShort (0.00s)
FAIL
rastrillo-budget/v1 ran 0s
FAIL	amadan.net/oficina/equipo/internal/testci	0.004s
FAIL
machine: 32 CPUs, load 16.37, cpu waiting 8.92%, memory waiting 0.00%, io waiting 0.07%
make: *** [Makefile:113: ci-shard] Error 1

amadan: step check shard 17 of 29 failed: exit status 2
--- shard 18 of 29 ---
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py shard
timing budgets: reported, not enforced: a shared runner's load is not this change's time (set EQUIPO_CI_DEDICATED=1 on a dedicated runner)
browser: /opt/chromium-156.0.8078.79-1_deb13u1/chrome: Chromium 156.0.8078.79
browser lane browser-headless-chat: ./internal/headless
+ go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -tags browser,testbuild -timeout 15m -run '^TestBrowserChat$|^TestBrowserChatSendStaysOnPage$|^TestBrowserComposer$|^TestBrowserComposerReconcile$|^TestBrowserComposerFocus$|^TestBrowserComposerDock$|^TestBrowserDraftStreamsFormatted$|^TestBrowserDraftIsTheMessage$' ./internal/headless

receipt: test step 1m23.596s against a 60s target (the gate's other steps are not in this figure)
receipt: 1 packages ran, 0 cached, 0 without tests, 0 failed
receipt: slow package 1m21.979s amadan.net/oficina/equipo/internal/headless
receipt: slow test 38.12s amadan.net/oficina/equipo/internal/headless TestBrowserDraftIsTheMessage
receipt: slow test 14.78s amadan.net/oficina/equipo/internal/headless TestBrowserDraftStreamsFormatted
receipt: slow test 10.34s amadan.net/oficina/equipo/internal/headless TestBrowserChat
receipt: slow test 7.46s amadan.net/oficina/equipo/internal/headless TestBrowserComposer
receipt: slow test 6.34s amadan.net/oficina/equipo/internal/headless TestBrowserChatSendStaysOnPage
machine: 32 CPUs, load 53.12, cpu waiting 35.75%, memory waiting 0.00%, io waiting 0.40%
--- shard 19 of 29 ---
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py shard
timing budgets: reported, not enforced: a shared runner's load is not this change's time (set EQUIPO_CI_DEDICATED=1 on a dedicated runner)
browser: /opt/chromium-156.0.8078.79-1_deb13u1/chrome: Chromium 156.0.8078.79
browser lane browser-headless-work: ./internal/headless
+ go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -tags browser,testbuild -timeout 15m -run '^TestBrowserTaskCard$|^TestBrowserReceiptFollowsReview$|^TestBrowserRailFollowsWork$|^TestBrowserTaskThread$|^TestBrowserAskAfterMerge$|^TestBrowserReceiptsDesktop$|^TestBrowserReceiptsTouch$' ./internal/headless

receipt: test step 1m28.123s against a 60s target (the gate's other steps are not in this figure)
receipt: 1 packages ran, 0 cached, 0 without tests, 0 failed
receipt: slow package 1m26.488s amadan.net/oficina/equipo/internal/headless
receipt: slow test 26.4s amadan.net/oficina/equipo/internal/headless TestBrowserRailFollowsWork
receipt: slow test 20.52s amadan.net/oficina/equipo/internal/headless TestBrowserTaskThread
receipt: slow test 12.62s amadan.net/oficina/equipo/internal/headless TestBrowserReceiptFollowsReview
receipt: slow test 9.14s amadan.net/oficina/equipo/internal/headless TestBrowserAskAfterMerge
receipt: slow test 9.02s amadan.net/oficina/equipo/internal/headless TestBrowserTaskCard
machine: 32 CPUs, load 50.95, cpu waiting 35.31%, memory waiting 0.00%, io waiting 0.37%
--- shard 20 of 29 ---
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py shard
timing budgets: reported, not enforced: a shared runner's load is not this change's time (set EQUIPO_CI_DEDICATED=1 on a dedicated runner)
browser: /opt/chromium-156.0.8078.79-1_deb13u1/chrome: Chromium 156.0.8078.79
browser lane browser-headless-connections: ./internal/headless
+ go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -tags browser,testbuild -timeout 15m -run '^TestBrowserConnections|^TestBrowserPasteBox$|^TestBrowserPasteCopiesItsBox$' ./internal/headless

receipt: test step 1m40.183s against a 60s target (the gate's other steps are not in this figure)
receipt: 1 packages ran, 0 cached, 0 without tests, 0 failed
receipt: slow package 1m38.566s amadan.net/oficina/equipo/internal/headless
receipt: slow test 13.35s amadan.net/oficina/equipo/internal/headless TestBrowserConnectionsAddPage
receipt: slow test 13.12s amadan.net/oficina/equipo/internal/headless TestBrowserConnectionsConversation
receipt: slow test 12.08s amadan.net/oficina/equipo/internal/headless TestBrowserConnectionsAdd
receipt: slow test 10.89s amadan.net/oficina/equipo/internal/headless TestBrowserConnectionsMeteredLimitRequired
receipt: slow test 10.79s amadan.net/oficina/equipo/internal/headless TestBrowserConnectionsOpenCodeGoLimitRequired
machine: 32 CPUs, load 46.09, cpu waiting 31.12%, memory waiting 0.00%, io waiting 0.30%
--- shard 21 of 29 ---
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py shard
timing budgets: reported, not enforced: a shared runner's load is not this change's time (set EQUIPO_CI_DEDICATED=1 on a dedicated runner)
browser: /opt/chromium-156.0.8078.79-1_deb13u1/chrome: Chromium 156.0.8078.79
browser lane browser-headless-rest: ./internal/headless
+ go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -tags browser,testbuild -timeout 15m -run '^(TestBrowserAskAfterMerge|TestBrowserChat|TestBrowserChatSendStaysOnPage|TestBrowserComposer|TestBrowserComposerDock|TestBrowserComposerFocus|TestBrowserComposerReconcile|TestBrowserConnectionsAdd|TestBrowserConnectionsAddPage|TestBrowserConnectionsConversation|TestBrowserConnectionsCopyLink|TestBrowserConnectionsEndedNote|TestBrowserConnectionsMeteredLimitRequired|TestBrowserConnectionsOpenCodeGoLimitRequired|TestBrowserConnectionsSignIn|TestBrowserConnectionsSignInSwitch|TestBrowserConnectionsToken|TestBrowserCopyContinue|TestBrowserCopySettingAndFlag|TestBrowserDraftIsTheMessage|TestBrowserDraftStreamsFormatted|TestBrowserEmptyExplore|TestBrowserMoveIn|TestBrowserNotebook|TestBrowserNotebookLook|TestBrowserPasteBox|TestBrowserPasteBoxLook|TestBrowserPasteCopiesItsBox|TestBrowserRailFollowsWork|TestBrowserReceiptFollowsReview|TestBrowserReceiptsDesktop|TestBrowserReceiptsTouch|TestBrowserRefreshRace|TestBrowserStalePageReloads|TestBrowserTaskCard|TestBrowserTaskThread|TestBrowserThinkingAndCards|TestBrowserUsageAndAdvice|TestBrowserWaitingTurns|TestNotebookScreenshots)$' -skip '^TestBrowserChat$|^TestBrowserChatSendStaysOnPage$|^TestBrowserComposer$|^TestBrowserComposerReconcile$|^TestBrowserComposerFocus$|^TestBrowserComposerDock$|^TestBrowserDraftStreamsFormatted$|^TestBrowserDraftIsTheMessage$|^TestBrowserTaskCard$|^TestBrowserReceiptFollowsReview$|^TestBrowserRailFollowsWork$|^TestBrowserTaskThread$|^TestBrowserAskAfterMerge$|^TestBrowserReceiptsDesktop$|^TestBrowserReceiptsTouch$|^TestBrowserConnections|^TestBrowserPasteBox$|^TestBrowserPasteCopiesItsBox$' ./internal/headless
--- FAIL amadan.net/oficina/equipo/internal/headless TestBrowserCopyContinue
=== RUN   TestBrowserCopyContinue
time=2026-11-23T21:50:56.013Z level=INFO msg="startup phase" phase=state_lock
time=2026-11-23T21:50:56.014Z level=INFO msg="startup phase done" phase=state_lock took=237µs
time=2026-11-23T21:50:56.014Z level=INFO msg="startup phase" phase=claim_roots
time=2026-11-23T21:50:56.014Z level=INFO msg="startup phase done" phase=claim_roots took=136µs
time=2026-11-23T21:50:56.014Z level=INFO msg="startup phase" phase=sweep
time=2026-11-23T21:50:56.084Z level=INFO msg="startup phase done" phase=sweep took=70.626ms
time=2026-11-23T21:50:56.087Z level=INFO msg="startup phase" phase=credentials
time=2026-11-23T21:50:56.087Z level=INFO msg="startup phase done" phase=credentials took=253µs
time=2026-11-23T21:50:56.087Z level=INFO msg="startup phase" phase=open_state
time=2026-11-23T21:50:56.183Z level=INFO msg="startup phase done" phase=open_state took=95.564ms
time=2026-11-23T21:50:56.185Z level=WARN msg="no seal key: token connections cannot be added" err=*fs.PathError
time=2026-11-23T21:50:56.186Z level=INFO msg=connecting host=127.0.0.1:34123 protocol=28
time=2026-11-23T21:50:56.189Z level=INFO msg=connected host=127.0.0.1:34123 took=2.941ms
time=2026-11-23T21:50:56.189Z level=INFO msg="capabilities gathering"
time=2026-11-23T21:50:56.189Z level=INFO msg="capabilities gathered" took=457µs tags=linux,claude,go
time=2026-11-23T21:50:56.190Z level=INFO msg="hello sent" protocol=28
time=2026-11-23T21:50:56.197Z level=INFO msg=welcome protocol=28 role=primary generation=1
    browser_copy_test.go:90: waiting for !document.querySelector('[data-copy-continue]'): context deadline exceeded (last evaluation: context deadline exceeded)
--- FAIL: TestBrowserCopyContinue (6.51s)

--- FAIL amadan.net/oficina/equipo/internal/headless (package output)
FAIL
rastrillo-budget/v1 ran 1m31.328s
FAIL	amadan.net/oficina/equipo/internal/headless	91.531s


receipt: test step 1m32.813s against a 60s target (the gate's other steps are not in this figure)
receipt: 0 packages ran, 0 cached, 0 without tests, 1 failed
receipt: slow package 1m31.328s amadan.net/oficina/equipo/internal/headless
receipt: slow test 14.63s amadan.net/oficina/equipo/internal/headless TestBrowserThinkingAndCards
receipt: slow test 11.05s amadan.net/oficina/equipo/internal/headless TestBrowserStalePageReloads
receipt: slow test 10.55s amadan.net/oficina/equipo/internal/headless TestBrowserWaitingTurns
receipt: slow test 9.31s amadan.net/oficina/equipo/internal/headless TestBrowserMoveIn
receipt: slow test 7.5s amadan.net/oficina/equipo/internal/headless TestBrowserRefreshRace
rastrillo: budget test: go test failed
exit status 1
+ go test -tags browser,testbuild -timeout 15m -run '^(TestBrowserAskAfterMerge|TestBrowserChat|TestBrowserChatSendStaysOnPage|TestBrowserComposer|TestBrowserComposerDock|TestBrowserComposerFocus|TestBrowserComposerReconcile|TestBrowserConnectionsAdd|TestBrowserConnectionsAddPage|TestBrowserConnectionsConversation|TestBrowserConnectionsCopyLink|TestBrowserConnectionsEndedNote|TestBrowserConnectionsMeteredLimitRequired|TestBrowserConnectionsOpenCodeGoLimitRequired|TestBrowserConnectionsSignIn|TestBrowserConnectionsSignInSwitch|TestBrowserConnectionsToken|TestBrowserCopyContinue|TestBrowserCopySettingAndFlag|TestBrowserDraftIsTheMessage|TestBrowserDraftStreamsFormatted|TestBrowserEmptyExplore|TestBrowserMoveIn|TestBrowserNotebook|TestBrowserNotebookLook|TestBrowserPasteBox|TestBrowserPasteBoxLook|TestBrowserPasteCopiesItsBox|TestBrowserRailFollowsWork|TestBrowserReceiptFollowsReview|TestBrowserReceiptsDesktop|TestBrowserReceiptsTouch|TestBrowserRefreshRace|TestBrowserStalePageReloads|TestBrowserTaskCard|TestBrowserTaskThread|TestBrowserThinkingAndCards|TestBrowserUsageAndAdvice|TestBrowserWaitingTurns|TestNotebookScreenshots)$' -skip '^TestBrowserChat$|^TestBrowserChatSendStaysOnPage$|^TestBrowserComposer$|^TestBrowserComposerReconcile$|^TestBrowserComposerFocus$|^TestBrowserComposerDock$|^TestBrowserDraftStreamsFormatted$|^TestBrowserDraftIsTheMessage$|^TestBrowserTaskCard$|^TestBrowserReceiptFollowsReview$|^TestBrowserRailFollowsWork$|^TestBrowserTaskThread$|^TestBrowserAskAfterMerge$|^TestBrowserReceiptsDesktop$|^TestBrowserReceiptsTouch$|^TestBrowserConnections|^TestBrowserPasteBox$|^TestBrowserPasteCopiesItsBox$' -v -run '^TestBrowserCopyContinue$' -count=1 ./internal/headless   (retry, once)
##############################################################################
FLAKE ./internal/headless:TestBrowserCopyContinue browser-headless-rest 7bf6afe3e03c7b5693bf7b17f015d95d6b478a66 6.51s 48.71
##############################################################################
failed, then passed on its one retry: the step stays green and the flake is on record
machine: 32 CPUs, load 46.09, cpu waiting 33.16%, memory waiting 0.00%, io waiting 0.32%
--- shard 22 of 29 ---
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py shard
timing budgets: reported, not enforced: a shared runner's load is not this change's time (set EQUIPO_CI_DEDICATED=1 on a dedicated runner)
browser: /opt/chromium-156.0.8078.79-1_deb13u1/chrome: Chromium 156.0.8078.79
browser lane browser-rest: ./internal/equipo
+ go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -tags browser,testbuild -timeout 15m -run '^(TestBrowserPreviewBlocksNavigation)$' ./internal/equipo

receipt: test step 1.974s against a 60s target (the gate's other steps are not in this figure)
receipt: 1 packages ran, 0 cached, 0 without tests, 0 failed
receipt: slow package 600ms amadan.net/oficina/equipo/internal/equipo
receipt: slow test 600ms amadan.net/oficina/equipo/internal/equipo TestBrowserPreviewBlocksNavigation
browser lane browser-rest: ./internal/equipotest
+ go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -tags browser,testbuild -timeout 15m -run '^(TestBrowserGitHubManifestCSP)$' ./internal/equipotest

receipt: test step 7.674s against a 60s target (the gate's other steps are not in this figure)
receipt: 1 packages ran, 0 cached, 0 without tests, 0 failed
receipt: slow package 6.243s amadan.net/oficina/equipo/internal/equipotest
receipt: slow test 6.24s amadan.net/oficina/equipo/internal/equipotest TestBrowserGitHubManifestCSP
browser lane browser-rest: ./internal/idtest
+ go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -tags browser,testbuild -timeout 15m -run '^(TestBrowserOficinaIDDoor|TestBrowserSmartDoor)$' ./internal/idtest
budget note: internal/idtest took 10.771s, over the 10s the default allows; reported only, timing fails on CI

receipt: test step 12.099s against a 60s target (the gate's other steps are not in this figure)
receipt: 1 packages ran, 0 cached, 0 without tests, 0 failed
receipt: slow package 10.771s amadan.net/oficina/equipo/internal/idtest
receipt: slow test 8.51s amadan.net/oficina/equipo/internal/idtest TestBrowserSmartDoor
receipt: slow test 2.26s amadan.net/oficina/equipo/internal/idtest TestBrowserOficinaIDDoor
browser lane browser-rest: ./internal/plan3test
+ go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -tags browser,testbuild -timeout 15m -run '^(TestTeamsHierarchyBrowser)$' ./internal/plan3test

receipt: test step 3.615s against a 60s target (the gate's other steps are not in this figure)
receipt: 1 packages ran, 0 cached, 0 without tests, 0 failed
receipt: slow package 2.098s amadan.net/oficina/equipo/internal/plan3test
receipt: slow test 2.1s amadan.net/oficina/equipo/internal/plan3test TestTeamsHierarchyBrowser
browser lane browser-rest: ./internal/thintest
+ go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -tags browser,testbuild -timeout 15m -run '^(TestBrowserAccessEmojiByline|TestBrowserAccessFinalOutcomes|TestBrowserAccessRequest|TestBrowserAccessReview|TestBrowserActivitySubjects|TestBrowserAutonomySettings|TestBrowserCoordinatorQueue|TestBrowserEmptyConversation|TestBrowserEndedNoteStaysGone|TestBrowserHousekeeping|TestBrowserInnerGallery|TestBrowserInnerScreens|TestBrowserInstantThinking|TestBrowserInstantThinkingQueued|TestBrowserMachines|TestBrowserPhoneIndex|TestBrowserPlacementQuestionAndPending|TestBrowserProjectPlacement|TestBrowserProjectsList|TestBrowserReportActionFeedback|TestBrowserReportNextSteps|TestBrowserReportThread|TestBrowserRhythm|TestBrowserRollup|TestBrowserRosterAlignment|TestBrowserRosterDecisionStates|TestBrowserRosterQuietDay|TestBrowserRosterReports|TestBrowserRosterSetAside|TestBrowserRosterSubchat|TestBrowserRosterThinking|TestBrowserRosterVisual|TestBrowserSettingsHousekeepingGroups|TestBrowserSettingsMenu|TestBrowserSettingsRail|TestBrowserSettingsSaveBar|TestBrowserSettingsShots|TestBrowserSettingsStayOnPage|TestBrowserSettingsTeams|TestBrowserShipsButtons|TestBrowserSpecialistRows|TestBrowserSpendFollowsAnswers|TestBrowserTaskRows|TestBrowserTeamPanel|TestBrowserThinkingCycles|TestBrowserThinkingLinesClear|TestBrowserThinkingSteady|TestBrowserThinkingWords|TestBrowserTokenRowEmail|TestBrowserTrackPulse|TestBrowserTrackStarCentre|TestBrowserTryAgain)$' ./internal/thintest

receipt: test step 3m29.273s against a 60s target (the gate's other steps are not in this figure)
receipt: 1 packages ran, 0 cached, 0 without tests, 0 failed
receipt: slow package 3m27.643s amadan.net/oficina/equipo/internal/thintest
receipt: slow test 24.66s amadan.net/oficina/equipo/internal/thintest TestBrowserAccessRequest
receipt: slow test 14.41s amadan.net/oficina/equipo/internal/thintest TestBrowserSettingsTeams
receipt: slow test 12.05s amadan.net/oficina/equipo/internal/thintest TestBrowserThinkingCycles
receipt: slow test 10.56s amadan.net/oficina/equipo/internal/thintest TestBrowserPlacementQuestionAndPending
receipt: slow test 9.3s amadan.net/oficina/equipo/internal/thintest TestBrowserRhythm
machine: 32 CPUs, load 6.55, cpu waiting 3.39%, memory waiting 0.00%, io waiting 0.02%
--- shard 23 of 29 ---
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py shard
shard 23: make test-quarantine
python3 scripts/ci-test.py quarantine
quarantine: 12 tests from scripts/ci-quarantine.txt; a failure is retried once, and a pass on the retry is reported as a flake
+ go test -tags testbuild -timeout 15m -v -run '^TestHeadlessConnections$/^A5_cancel_and_sign_out$|^TestHeadlessConnections$/^C4_claude_sign_in$|^TestHeadlessConnections$/^C5_engineering_failover$|^TestHeadlessConnections$/^C5_engineering_to_codex$|^TestHeadlessConnections$/^C5_engineering_waits$' ./internal/headless   (50s)
ok ./internal/headless TestHeadlessConnections/A5_cancel_and_sign_out 4.84s
ok ./internal/headless TestHeadlessConnections/C4_claude_sign_in 1.27s
ok ./internal/headless TestHeadlessConnections/C5_engineering_failover 7.71s
ok ./internal/headless TestHeadlessConnections/C5_engineering_to_codex 8.21s
ok ./internal/headless TestHeadlessConnections/C5_engineering_waits 26.01s
+ go test -tags testbuild -timeout 15m -v -run '^TestHeadlessConnections$/^C5_review_auth$|^TestHeadlessConnections$/^C5_review_failover$|^TestHeadlessConnections$/^C5_review_on_codex$|^TestHeadlessConnections$/^C5_review_other_family_first$' ./internal/headless   (61s)
ok ./internal/headless TestHeadlessConnections/C5_review_auth 14.10s
ok ./internal/headless TestHeadlessConnections/C5_review_failover 11.18s
ok ./internal/headless TestHeadlessConnections/C5_review_on_codex 19.24s
ok ./internal/headless TestHeadlessConnections/C5_review_other_family_first 14.50s
+ go test -tags testbuild -timeout 15m -v -run '^TestMixedVersions$' ./internal/headless   (20s)
ok ./internal/headless TestMixedVersions 17.69s
+ go test -tags testbuild -timeout 15m -v -run '^TestCheckSandboxDeniedPathsTampering$' ./internal/runner/checks   (2s)
ok ./internal/runner/checks TestCheckSandboxDeniedPathsTampering 0.78s
+ go test -tags testbuild -timeout 15m -v -run '^TestRunnerCancelAndSupersede$' ./internal/runner/thin   (1s)
ok ./internal/runner/thin TestRunnerCancelAndSupersede 0.05s
quarantine: 0 flaked (passed on the retry), 0 failed
machine: 32 CPUs, load 61.07, cpu waiting 35.14%, memory waiting 0.00%, io waiting 0.60%
--- shard 24 of 29 ---
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py shard
shard 24: make runner-host
python3 scripts/runner-prerequisites.py
CGO_ENABLED=0 RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py retried runner-host -run 'TestDirect|TestProvider|TestCheckSandbox' -count=1 ./internal/runner/provider/... ./internal/runner/checks
+ go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -no-time -run 'TestDirect|TestProvider|TestCheckSandbox' -count=1 ./internal/runner/provider/... ./internal/runner/checks

receipt: test step 12.066s against a 60s target (the gate's other steps are not in this figure)
receipt: 4 packages ran, 0 cached, 4 without tests, 0 failed
receipt: slow package 7.926s amadan.net/oficina/equipo/internal/runner/checks
receipt: slow package 186ms amadan.net/oficina/equipo/internal/runner/provider/claude
receipt: slow package 90ms amadan.net/oficina/equipo/internal/runner/provider/codex
receipt: slow package 1ms amadan.net/oficina/equipo/internal/runner/provider
receipt: slow package 0s amadan.net/oficina/equipo/internal/runner/provider/claude/realcli
receipt: slow test 5.68s amadan.net/oficina/equipo/internal/runner/checks TestCheckSandboxDeniedPathsGoFixture
receipt: slow test 1.77s amadan.net/oficina/equipo/internal/runner/checks TestCheckSandboxDeniedPaths
receipt: slow test 340ms amadan.net/oficina/equipo/internal/runner/checks TestCheckSandboxDeniedPathsCache
receipt: slow test 180ms amadan.net/oficina/equipo/internal/runner/provider/claude TestDirectJournalAdapterBarrier
receipt: slow test 120ms amadan.net/oficina/equipo/internal/runner/checks TestCheckSandboxToolchain
CGO_ENABLED=0 RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py retried runner-host -run '^TestNamespace' -count=1 ./internal/runner/containment
+ go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -no-time -run '^TestNamespace' -count=1 ./internal/runner/containment

receipt: test step 3.515s against a 60s target (the gate's other steps are not in this figure)
receipt: 1 packages ran, 0 cached, 0 without tests, 0 failed
receipt: slow package 3.101s amadan.net/oficina/equipo/internal/runner/containment
receipt: slow test 320ms amadan.net/oficina/equipo/internal/runner/containment TestNamespaceReadOnlyScratch
receipt: slow test 180ms amadan.net/oficina/equipo/internal/runner/containment TestNamespaceRecoveryUnavailableProof
receipt: slow test 140ms amadan.net/oficina/equipo/internal/runner/containment TestNamespaceDirectPolicyAdmission
receipt: slow test 120ms amadan.net/oficina/equipo/internal/runner/containment TestNamespaceOpenCodeBinaryAfterAttestation
receipt: slow test 120ms amadan.net/oficina/equipo/internal/runner/containment TestNamespaceExitStatus
machine: 32 CPUs, load 13.20, cpu waiting 8.04%, memory waiting 0.00%, io waiting 1.30%
--- shard 25 of 29 ---
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py shard
stagger: runner-dead-references started 30s late; cpu waiting 38.9%, load 25.31
shard 25: make runner-dead-references lanes-check build vet fmt-check spacing budget migration-check
python3 scripts/runner-dead-references.py
reference scan: 2698 text files, 3210 matches, 0 failures
python3 scripts/ci-test.py check
lanes: 18 lanes and 5 browser lanes run every test once; 20-check@29
CGO_ENABLED=0 go build ./...
CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build -o /dev/null ./cmd/equipo-runner
go vet ./...
go vet -tags testbuild ./internal/runner/thin ./internal/headless
GOOS=darwin GOARCH=arm64 go vet ./cmd/equipo-runner/... ./internal/runner/... ./internal/wire/... ./internal/release/...
go tool fiesta spacing -skip tokens.css internal/equipo/static
go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget size
budget size: 92 directories within budget
CGO_ENABLED=0 go test ./internal/equipo -run '^TestMigrationModels$' -count=1
ok  	amadan.net/oficina/equipo/internal/equipo	2.504s
machine: 32 CPUs, load 60.91, cpu waiting 35.07%, memory waiting 0.00%, io waiting 0.58%
--- shard 26 of 29 ---
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py shard
stagger: staticcheck started 30s late; cpu waiting 38.9%, load 25.31
shard 26: make staticcheck
go run honnef.co/go/tools/cmd/staticcheck@v0.7.0 -tags browser,perf,testbuild ./...
machine: 32 CPUs, load 44.05, cpu waiting 24.54%, memory waiting 0.00%, io waiting 0.84%
--- shard 27 of 29 ---
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py shard
stagger: govulncheck started 30s late; cpu waiting 38.9%, load 25.31
shard 27: make govulncheck
go run golang.org/x/vuln/cmd/govulncheck@v1.8.0 ./...
=== Symbol Results ===

No vulnerabilities found.

Your code is affected by 0 vulnerabilities.
This scan also found 0 vulnerabilities in packages you import and 3
vulnerabilities in modules you require, but your code doesn't appear to call
these vulnerabilities.
Use '-show verbose' for more details.
machine: 32 CPUs, load 35.70, cpu waiting 21.48%, memory waiting 0.00%, io waiting 0.90%
--- shard 28 of 29 ---
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py shard
stagger: gitleaks started 30s late; cpu waiting 38.9%, load 25.31
shard 28: make gitleaks
9:50PM INF Unknown SCM platform. Use --platform to include links in findings. host=amadan.net
9:51PM INF 1131 commits scanned.
9:51PM INF scanned ~65244219 bytes (65.24 MB) in 21.7s
9:51PM INF no leaks found
machine: 32 CPUs, load 54.30, cpu waiting 31.18%, memory waiting 0.00%, io waiting 0.71%

amadan: job failed at step check shards 16, 17 of 29 — its output is above, not at the tail of this log
diff --git a/.rastrillo/budgets.txt b/.rastrillo/budgets.txt
index eaeed9d3..0dd7a1aa 100644
--- a/.rastrillo/budgets.txt
+++ b/.rastrillo/budgets.txt
@@ -14,9 +14,9 @@ perf GET /* skip Unknown private paths render 404; this fallback contains no scr
time internal/equipo/team 60s Plan 3 loaded CI measured 45.985s; niced serial reruns measured 18.079s and 22.031s. Keep migration, recovery, accounting and concurrency assertions; 60s leaves 30 percent headroom above loaded CI.
time internal/equipotest 300s Final fix package rerun measured 187.035s (review 172.4s); 300s gives 60 percent headroom for HTTP, sandbox, authority and final regression coverage.
-size internal/equipo 22503 - GitHub owner routes, lifecycle rendering and configuration glue; measured 22503 source lines; domain logic is in equipo/github.
+size internal/equipo 22577 - GitHub owner routes, typed lifecycle rendering with no default, retryable notices, sweep diagnostics and configuration glue; measured 22577 source lines; domain logic is in equipo/github.
size internal/wire 6830 - Successful-push proposal diagnostic in existing Reason fields; measured 6830 source lines.
-size internal/equipotest - 12468 GitHub manifest, callback, value-search and browser CSP contracts; measured 12468 test lines.
+size internal/equipotest - 12626 GitHub manifest, callback, phased value-search (after conversion, Connect and Disconnect, with escaped-key fragments), lifecycle rendering (abandoned starts, busy Check notice, owner-only Settings nav) and browser CSP contracts; measured 12626 test lines.
time internal/runner/checks 90s CI worker measured 44.553s (44.6s rounded);
time internal/runner 330s Plan 3 CI repair measured 292.120s for the full package (controller CI 472.184s).
diff --git a/docs/superpowers/plans/CONTROLLER-REPORT-github-connect-app.md b/docs/superpowers/plans/CONTROLLER-REPORT-github-connect-app.md
index 220f1237..30fc2613 100644
--- a/docs/superpowers/plans/CONTROLLER-REPORT-github-connect-app.md
+++ b/docs/superpowers/plans/CONTROLLER-REPORT-github-connect-app.md
@@ -322,3 +322,210 @@ 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. 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.
diff --git a/internal/equipo/app.go b/internal/equipo/app.go
index 4457caf8..6eae72f6 100644
--- a/internal/equipo/app.go
+++ b/internal/equipo/app.go
@@ -92,7 +92,7 @@ func (a *application) startBackground() *background.Group {
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
if err := a.store.forge.Sweep(ctx); err != nil {
- a.logger.Error(copyText("github.check_failed"))
+ logGitHubSweep(a.logger, err)
}
if err := a.store.personDevices().Sweep(ctx); err != nil {
a.logger.Error(copyAuthSweep, "err", err)
diff --git a/internal/equipo/copy.go b/internal/equipo/copy.go
index 7298c061..1196dcfb 100644
--- a/internal/equipo/copy.go
+++ b/internal/equipo/copy.go
@@ -44,6 +44,7 @@ const (
copyUnavailable = "The information is unavailable. Try again in a minute."
copyAuthSweep = "Could not clear expired sign-ins."
copyNonceSweep = "Could not clear expired form tokens."
+ copyGitHubSweep = "Could not clear expired GitHub setups."
copyInvalidDatabase = "EQUIPO_DATABASE must be a file name like equipo-v1.db." // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context)
copyChatSweep = "Could not clear old conversation events." // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context)
copyRunnerAPIFailed = "A runner request failed on the server." // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context)
diff --git a/internal/equipo/github/callback.go b/internal/equipo/github/callback.go
index 96763a7e..f288df06 100644
--- a/internal/equipo/github/callback.go
+++ b/internal/equipo/github/callback.go
@@ -25,12 +25,12 @@ func (s *Store) claimCallback(ctx context.Context, p Principal, state, stage str
}
if !s.now().Before(c.RedirectUntil) {
if stage == "manifest" {
- erase(&c, "manifest_expired")
+ erase(&c, StateManifestExpired)
} else if !s.now().Before(c.PendingUntil) {
- erase(&c, "expired")
+ erase(&c, StateExpired)
} else {
c.InstallationHash = ""
- c.State = "installation_expired"
+ c.State = StateInstallationExpired
}
if err := s.save(tx, p, &c, "forge.expire_redirect"); err != nil {
return err
@@ -40,7 +40,7 @@ func (s *Store) claimCallback(ctx context.Context, p Principal, state, stage str
}
if stage == "manifest" {
c.ManifestHash = ""
- c.State = "converting"
+ c.State = StateConverting
} else {
c.InstallationHash = ""
}
@@ -51,7 +51,26 @@ func (s *Store) claimCallback(ctx context.Context, p Principal, state, stage str
}
return c, refused
}
+
+// fenced loads the claimed conversion inside a write and refuses a late result.
+func (s *Store) fenced(tx *gorm.DB, claimed Connection, result *Connection) error {
+ if e := tx.First(result, "id = ?", claimed.ID).Error; e != nil {
+ return e
+ }
+ if result.Generation != claimed.Generation || result.State != StateConverting {
+ return ErrAccess
+ }
+ var slot Pending
+ if tx.First(&slot, "id = ?", 1).Error != nil || slot.ConnectionID != result.ID {
+ return ErrAccess
+ }
+ return nil
+}
func (s *Store) Convert(ctx context.Context, p Principal, state, code string) (View, error) {
+ // The code's shape is checked before the single-use state is spent.
+ if !ValidCode(code) {
+ return View{}, ErrAccess
+ }
claimed, err := s.claimCallback(ctx, p, state, "manifest")
if err != nil {
return s.view(claimed), err
@@ -61,23 +80,33 @@ func (s *Store) Convert(ctx context.Context, p Principal, state, code string) (V
if app.Owner.Type != claimed.AccountType || !equalLogin(app.Owner.Login, claimed.Login) {
callErr = ErrAccess
} else {
+ // Record the created App before verifying it, so a lost conversion
+ // still points cleanup at this App.
+ err = s.write(ctx, p, func(tx *gorm.DB) error {
+ var c Connection
+ if e := s.fenced(tx, claimed, &c); e != nil {
+ return e
+ }
+ c.AppID, c.Slug = app.ID, app.Slug
+ if e := s.save(tx, p, &c, "forge.convert_app"); e != nil {
+ return e
+ }
+ claimed = c
+ return nil
+ })
+ if err != nil {
+ return View{}, err
+ }
app, callErr = s.API.Verify(ctx, app)
}
}
var result Connection
err = s.write(ctx, p, func(tx *gorm.DB) error {
- if e := tx.First(&result, "id = ?", claimed.ID).Error; e != nil {
+ if e := s.fenced(tx, claimed, &result); e != nil {
return e
}
- if result.Generation != claimed.Generation || result.State != "converting" {
- return ErrAccess
- }
- var slot Pending
- if tx.First(&slot, "id = ?", 1).Error != nil || slot.ConnectionID != result.ID {
- return ErrAccess
- }
if callErr != nil {
- erase(&result, "failed")
+ erase(&result, StateFailed)
return s.save(tx, p, &result, "forge.convert_failed")
}
sealed, e := sealKey(s.Root, s.Origin, result.ID, app.ID, app.pem)
@@ -85,7 +114,7 @@ func (s *Store) Convert(ctx context.Context, p Principal, state, code string) (V
return e
}
result.AppID, result.Slug, result.AccountID, result.Login = app.ID, app.Slug, app.Owner.ID, app.Owner.Login
- result.SealedKey, result.State = sealed, "pending"
+ result.SealedKey, result.State = sealed, StatePending
result.PendingUntil = s.now().Add(24 * hour)
result.InstallationHash = digest(s.state(result, "installation"))
return s.save(tx, p, &result, "forge.convert")
diff --git a/internal/equipo/github/check.go b/internal/equipo/github/check.go
index b3ebe029..b814d878 100644
--- a/internal/equipo/github/check.go
+++ b/internal/equipo/github/check.go
@@ -12,13 +12,17 @@ import (
const hour = time.Hour
+// conversionBound covers the conversion and verification requests and their
+// commit; a converting row older than this was lost.
+const conversionBound = 2 * time.Minute
+
func equalLogin(a, b string) bool { return strings.EqualFold(a, b) }
-func (s *Store) expired(c Connection) string {
+func (s *Store) expired(c Connection) State {
if !c.Confirmed && !c.PendingUntil.IsZero() && !s.now().Before(c.PendingUntil) {
- return "expired"
+ return StateExpired
}
if c.Confirmed && !c.UninstalledAt.IsZero() && !s.now().Before(c.UninstalledAt.Add(7*24*time.Hour)) {
- return "uninstalled_expired"
+ return StateUninstalledExpired
}
return ""
}
@@ -44,7 +48,7 @@ func (s *Store) Check(ctx context.Context, p Principal, id string) (View, error)
return ErrAccess
}
if claimed.Claim != "" && s.now().Before(claimed.ClaimUntil) {
- return ErrUnavailable
+ return ErrBusy
}
claimed.Claim = strings.ToLower(rand.Text())
claimed.ClaimUntil = s.now().Add(30 * time.Second)
@@ -60,7 +64,7 @@ func (s *Store) Check(ctx context.Context, p Principal, id string) (View, error)
app, callErr := s.app(claimed)
var installation Installation
var inventory Inventory
- found := false
+ found, seen := false, false
if callErr == nil {
app, callErr = s.API.Verify(ctx, app)
}
@@ -82,6 +86,7 @@ func (s *Store) Check(ctx context.Context, p Principal, id string) (View, error)
}
if callErr == nil && found {
installation, callErr = s.API.Installation(ctx, app, installation.ID)
+ seen = callErr == nil
}
if callErr == nil && found && installation.Suspended == nil {
inventory, callErr = s.API.Inventory(ctx, app, installation)
@@ -92,40 +97,45 @@ func (s *Store) Check(ctx context.Context, p Principal, id string) (View, error)
return err
}
if result.Generation != claimed.Generation || result.Claim != claimed.Claim || !s.now().Before(result.ClaimUntil) {
- return ErrAccess
+ return ErrBusy
}
if app.ID == result.AppID && app.Slug != "" {
result.Slug = app.Slug
}
result.Claim = ""
result.ClaimUntil = time.Time{}
- if state := s.expired(result); state != "" {
- erase(&result, state)
+ expired := s.expired(result)
+ if expired == "" && seen {
+ // The JWT sees this installation again, in any state.
+ result.UninstalledAt = time.Time{}
+ }
+ if expired != "" {
+ erase(&result, expired)
refused = &Refusal{s.view(result), ErrAccess}
} else if errors.Is(callErr, ErrReconnect) {
- erase(&result, "reconnect")
+ erase(&result, StateReconnect)
refused = &Refusal{s.view(result), ErrReconnect}
} else if errors.Is(callErr, ErrTooMany) {
- result.State = "too_many"
+ result.State = StateTooMany
result.CountKnown = false
result.InstallationID = installation.ID
result.Selection = installation.Selection
} else if callErr != nil {
- result.State = "check_failed"
+ result.State = StateCheckFailed
result.CountKnown = false
refused = &Refusal{s.view(result), callErr}
} else if !found {
result.CountKnown = false
if result.Confirmed {
- result.State = "uninstalled"
+ result.State = StateUninstalled
if result.UninstalledAt.IsZero() {
result.UninstalledAt = s.now()
}
} else {
- result.State = "pending"
+ result.State = StatePending
}
} else if installation.Suspended != nil {
- result.State = "suspended"
+ result.State = StateSuspended
result.CountKnown = false
result.InstallationID = installation.ID
} else {
@@ -135,14 +145,14 @@ func (s *Store) Check(ctx context.Context, p Principal, id string) (View, error)
result.CountKnown = true
result.UninstalledAt = time.Time{}
result.Login = installation.Account.Login
- result.State = "ready"
+ result.State = StateReady
if result.Confirmed {
- result.State = "live"
+ result.State = StateLive
}
}
return s.save(tx, p, &result, "forge.check")
})
- if err != nil || result.SealedKey == "" || result.State == "uninstalled" || result.State == "suspended" {
+ if err != nil || result.SealedKey == "" || result.State == StateUninstalled || result.State == StateSuspended {
s.API.Forget(ctx, claimed.AppID)
}
if err != nil {
@@ -161,16 +171,16 @@ func (s *Store) Connect(ctx context.Context, p Principal, id string) (View, erro
return err
}
if c.Generation != checked.Generation {
- return ErrAccess
+ return ErrBusy
}
- if c.Confirmed && c.State == "live" {
+ if c.Confirmed && c.State == StateLive {
return nil
}
- if c.State != "ready" || !c.CountKnown || c.Count > MaxRepositories || c.SealedKey == "" || s.expired(c) != "" {
+ if c.State != StateReady || !c.CountKnown || c.Count > MaxRepositories || c.SealedKey == "" || s.expired(c) != "" {
return &Refusal{s.view(c), ErrAccess}
}
c.Confirmed = true
- c.State = "live"
+ c.State = StateLive
c.ActiveAccount = &c.AccountID
if err := s.save(tx, p, &c, "forge.connect"); err != nil {
return err
@@ -179,7 +189,7 @@ func (s *Store) Connect(ctx context.Context, p Principal, id string) (View, erro
})
result := s.view(c)
if err == nil && checked.Confirmed {
- result.State = "already_connected"
+ result.State = StateAlreadyConnected
}
return result, err
}
diff --git a/internal/equipo/github/client.go b/internal/equipo/github/client.go
index 5d76c22a..b0025ef6 100644
--- a/internal/equipo/github/client.go
+++ b/internal/equipo/github/client.go
@@ -30,12 +30,29 @@ var (
ErrAccess = errors.New("github: access refused")
ErrRateLimit = errors.New("github: rate limited")
ErrTooMany = errors.New("github: repository limit")
+ ErrBusy = errors.New("github: busy")
)
+// Retryable reports a busy or concurrent claim or a transient failure, not a
+// setup failure.
+func Retryable(err error) bool {
+ for _, kind := range []error{ErrBusy, ErrUnavailable, ErrRateLimit, context.DeadlineExceeded, context.Canceled} {
+ if errors.Is(err, kind) {
+ return true
+ }
+ }
+ return false
+}
+
const MaxRepositories = 1000
const maxAnswer = 2 << 20
var component = regexp.MustCompile(`^[A-Za-z0-9_-]{1,256}$`)
+var codePattern = regexp.MustCompile(`^[A-Za-z0-9._-]{1,256}$`)
+
+// ValidCode bounds a manifest code to one URL-safe path segment.
+func ValidCode(code string) bool { return codePattern.MatchString(code) && code != "." && code != ".." }
+
var loginPattern = regexp.MustCompile(`^[A-Za-z0-9](?:[A-Za-z0-9-]{0,37}[A-Za-z0-9])?$`)
func ValidAccount(login, kind string) bool {
@@ -103,6 +120,8 @@ type API struct {
now func() time.Time
mu sync.Mutex
tokens map[int64]metadataCredential
+ // epochs advance on Forget, so a token minted across it is revoked, not kept.
+ epochs map[int64]uint64
}
func NewAPI(transport http.RoundTripper, now func() time.Time) *API {
@@ -117,7 +136,7 @@ func NewAPI(transport http.RoundTripper, now func() time.Time) *API {
if now == nil {
now = time.Now
}
- return &API{client: &http.Client{Transport: transport, Timeout: 10 * time.Second, CheckRedirect: func(*http.Request, []*http.Request) error { return http.ErrUseLastResponse }}, now: now, tokens: map[int64]metadataCredential{}}
+ return &API{client: &http.Client{Transport: transport, Timeout: 10 * time.Second, CheckRedirect: func(*http.Request, []*http.Request) error { return http.ErrUseLastResponse }}, now: now, tokens: map[int64]metadataCredential{}, epochs: map[int64]uint64{}}
}
func (a *API) request(ctx context.Context, method, path, credential string, body, out any, conditional ...string) (http.Header, error) {
var payload []byte
@@ -209,7 +228,7 @@ func validApp(app App) bool {
return app.ID > 0 && component.MatchString(app.Slug) && app.Owner.ID > 0 && ValidAccount(app.Owner.Login, app.Owner.Type) && maps.Equal(app.Permissions, permissions()) && app.Events != nil && len(app.Events) == 0
}
func (a *API) Convert(ctx context.Context, code string) (App, error) {
- if !component.MatchString(code) {
+ if !ValidCode(code) {
return App{}, ErrAccess
}
var reply struct {
@@ -314,13 +333,16 @@ func nextPage(headers http.Header, path string, page int) (bool, error) {
return more, nil
}
func (a *API) metadata(ctx context.Context, app App, inst Installation) (string, error) {
+ // The mutex guards only the cache; no network call runs while it is held.
a.mu.Lock()
- defer a.mu.Unlock()
old := a.tokens[app.ID]
if old.value != "" && old.installation == inst.ID && old.selection == inst.Selection && a.now().Add(30*time.Second).Before(old.expires) {
+ a.mu.Unlock()
return old.value, nil
}
delete(a.tokens, app.ID)
+ epoch := a.epochs[app.ID]
+ a.mu.Unlock()
if old.value != "" {
_, _ = a.request(ctx, "DELETE", "/installation/token", old.value, nil, nil)
}
@@ -344,7 +366,18 @@ func (a *API) metadata(ctx context.Context, app App, inst Installation) (string,
}
return "", ErrAccess
}
+ a.mu.Lock()
+ if a.epochs[app.ID] != epoch {
+ a.mu.Unlock()
+ _, _ = a.request(ctx, "DELETE", "/installation/token", reply.Token, nil, nil)
+ return "", ErrAccess
+ }
+ displaced := a.tokens[app.ID]
a.tokens[app.ID] = metadataCredential{value: reply.Token, expires: reply.Expires, installation: inst.ID, selection: inst.Selection, pages: map[int]inventoryPage{}, generation: app.generation}
+ a.mu.Unlock()
+ if displaced.value != "" && displaced.value != reply.Token {
+ _, _ = a.request(ctx, "DELETE", "/installation/token", displaced.value, nil, nil)
+ }
return reply.Token, nil
}
func (a *API) Inventory(ctx context.Context, app App, inst Installation) (Inventory, error) {
@@ -409,6 +442,7 @@ func (a *API) Forget(ctx context.Context, id int64) {
a.mu.Lock()
entry := a.tokens[id]
delete(a.tokens, id)
+ a.epochs[id]++
a.mu.Unlock()
if entry.value != "" {
_, _ = a.request(ctx, "DELETE", "/installation/token", entry.value, nil, nil)
diff --git a/internal/equipo/github/models.go b/internal/equipo/github/models.go
index e217b7bd..0cd49b65 100644
--- a/internal/equipo/github/models.go
+++ b/internal/equipo/github/models.go
@@ -7,7 +7,7 @@ import "time"
type Connection struct {
ID string `gorm:"primaryKey"`
Generation int64
- State string
+ State State
Login string
AccountType string
AccountID int64
@@ -49,13 +49,57 @@ var Models = []any{&Connection{}, &Pending{}}
type Principal struct{ Address, Session string }
type View struct {
- ID, State, Login, AccountType, Slug, SettingsURL string
- Generation, AppID, AccountID, InstallationID int64
- Count int
- CountKnown, Confirmed bool
+ State State
+ ID, Login, AccountType, Slug, SettingsURL string
+ Generation, AppID, AccountID, InstallationID int64
+ Count int
+ CountKnown, Confirmed bool
}
type Started struct {
View View
State, Name string
Superseded *View
}
+
+// State is a connection's lifecycle state. Every value is listed in States and
+// has an explicit rendering; there is no default.
+type State string
+
+const (
+ StateManifest State = "manifest"
+ StateConverting State = "converting"
+ StatePending State = "pending"
+ StateReady State = "ready"
+ StateLive State = "live"
+ StateAlreadyConnected State = "already_connected"
+ StateManifestExpired State = "manifest_expired"
+ StateFailed State = "failed"
+ StateInstallationExpired State = "installation_expired"
+ StateExpired State = "expired"
+ StateSuperseded State = "superseded"
+ StateAbandoned State = "abandoned"
+ StateDisconnected State = "disconnected"
+ StateUninstalled State = "uninstalled"
+ StateUninstalledExpired State = "uninstalled_expired"
+ StateReconnect State = "reconnect"
+ StateCheckFailed State = "check_failed"
+ StateSuspended State = "suspended"
+ StateTooMany State = "too_many"
+)
+
+// Dead states hold no key and no authority. Only the latest per account is
+// listed, and only when GitHub has created its App.
+func (s State) Dead() bool {
+ switch s {
+ case StateSuperseded, StateAbandoned, StateFailed, StateManifestExpired, StateExpired, StateDisconnected, StateUninstalledExpired, StateReconnect:
+ return true
+ }
+ return false
+}
+
+// calledBack reports that GitHub redirected with a manifest code for this
+// attempt, so its App exists on GitHub even if conversion never finished.
+func calledBack(c Connection) bool { return c.State != StateManifest && c.State != StateAbandoned }
+
+// States lists every lifecycle state, for exhaustive rendering tests.
+var States = []State{StateManifest, StateConverting, StatePending, StateReady, StateLive, StateAlreadyConnected, StateManifestExpired, StateFailed, StateInstallationExpired, StateExpired, StateSuperseded, StateAbandoned, StateDisconnected, StateUninstalled, StateUninstalledExpired, StateReconnect, StateCheckFailed, StateSuspended, StateTooMany}
diff --git a/internal/equipo/github/review_fixes_test.go b/internal/equipo/github/review_fixes_test.go
new file mode 100644
index 00000000..e286dec0
--- /dev/null
+++ b/internal/equipo/github/review_fixes_test.go
@@ -0,0 +1,443 @@
+package github
+
+import (
+ "context"
+ "encoding/json"
+ "io"
+ "net/http"
+ "strings"
+ "testing"
+ "time"
+
+ "gorm.io/gorm"
+)
+
+// Review fixes (Fable, 2026-11-23). Each test names the guard it protects.
+
+func (r *rig) list(t *testing.T) []View {
+ t.Helper()
+ views, err := r.s.List(context.Background(), r.owner)
+ if err != nil {
+ t.Fatal(err)
+ }
+ return views
+}
+func countState(views []View, state State) int {
+ n := 0
+ for _, v := range views {
+ if v.State == state {
+ n++
+ }
+ }
+ return n
+}
+
+// P2-2: an abandoned manifest-stage start never claims an App exists.
+func TestForgeAbandonedStarts(t *testing.T) {
+ ctx := context.Background()
+ t.Run("start-back-start", func(t *testing.T) {
+ r := storeRig(t)
+ if _, err := r.s.Start(ctx, r.owner, r.g.Login, r.g.AccountType); err != nil {
+ t.Fatal(err)
+ }
+ again, err := r.s.Start(ctx, r.owner, r.g.Login, r.g.AccountType)
+ if err != nil {
+ t.Fatal(err)
+ }
+ if again.Superseded != nil {
+ t.Fatal("manifest-stage start claimed an App remains")
+ }
+ views := r.list(t)
+ if len(views) != 1 || views[0].ID != again.View.ID {
+ t.Fatalf("abandoned start listed: %+v", views)
+ }
+ })
+ t.Run("converted-then-superseded", func(t *testing.T) {
+ r := storeRig(t)
+ old := r.created(t)
+ next, err := r.s.Start(ctx, r.other, "another-org", "Organization")
+ if err != nil {
+ t.Fatal(err)
+ }
+ if next.Superseded == nil || next.Superseded.ID != old.ID {
+ t.Fatal("converted App cleanup not shown")
+ }
+ if _, err = r.s.Start(ctx, r.other, "third-org", "Organization"); err != nil {
+ t.Fatal(err)
+ }
+ views := r.list(t)
+ if countState(views, StateSuperseded) != 1 || len(views) != 2 {
+ t.Fatalf("want one superseded App and the current start, got %+v", views)
+ }
+ })
+ t.Run("three-abandoned", func(t *testing.T) {
+ r := storeRig(t)
+ var last Started
+ for range 3 {
+ var err error
+ if last, err = r.s.Start(ctx, r.owner, r.g.Login, r.g.AccountType); err != nil {
+ t.Fatal(err)
+ }
+ }
+ views := r.list(t)
+ if len(views) != 1 || views[0].ID != last.View.ID || views[0].State != StateManifest {
+ t.Fatalf("dead rows listed: %+v", views)
+ }
+ })
+ t.Run("disconnect-before-callback", func(t *testing.T) {
+ r := storeRig(t)
+ began, err := r.s.Start(ctx, r.owner, r.g.Login, r.g.AccountType)
+ if err != nil {
+ t.Fatal(err)
+ }
+ if _, err = r.s.Disconnect(ctx, r.owner, began.View.ID); err != nil {
+ t.Fatal(err)
+ }
+ if views := r.list(t); len(views) != 0 {
+ t.Fatalf("disconnected manifest-stage start listed: %+v", views)
+ }
+ })
+ t.Run("latest-per-account-until-reconnected", func(t *testing.T) {
+ r := storeRig(t)
+ view := r.created(t)
+ if _, err := r.s.Disconnect(ctx, r.owner, view.ID); err != nil {
+ t.Fatal(err)
+ }
+ older := Connection{ID: "older", Generation: 1, State: StateSuperseded, Login: r.g.Login, AccountType: r.g.AccountType, AppID: 77, StartedAt: r.now.Add(-time.Hour)}
+ if err := r.s.DB.Create(&older).Error; err != nil {
+ t.Fatal(err)
+ }
+ views := r.list(t)
+ if len(views) != 1 || views[0].ID != view.ID {
+ t.Fatalf("want only the latest dead attempt, got %+v", views)
+ }
+ account := r.g.AccountID
+ live := Connection{ID: "live", Generation: 1, State: StateLive, Confirmed: true, Login: strings.ToUpper(r.g.Login), AccountType: r.g.AccountType, AccountID: account, AppID: 88, ActiveAccount: &account, StartedAt: r.now.Add(time.Minute)}
+ if err := r.s.DB.Create(&live).Error; err != nil {
+ t.Fatal(err)
+ }
+ views = r.list(t)
+ if len(views) != 1 || views[0].ID != "live" {
+ t.Fatalf("dead notice survived reconnection: %+v", views)
+ }
+ })
+}
+
+// P3-1: a reinstall seen by the JWT in any state stops the uninstall clock.
+func TestForgeReinstallClearsUninstallClock(t *testing.T) {
+ for _, seen := range []string{"suspended", "too_many", "rate_limited"} {
+ t.Run(seen, func(t *testing.T) {
+ r := storeRig(t)
+ ctx := context.Background()
+ view := r.created(t)
+ if _, err := r.s.Connect(ctx, r.owner, view.ID); err != nil {
+ t.Fatal(err)
+ }
+ r.g.Uninstalled = true
+ if got, err := r.s.Check(ctx, r.owner, view.ID); err != nil || got.State != StateUninstalled {
+ t.Fatal("uninstall not observed:", err)
+ }
+ r.advance(3 * 24 * time.Hour)
+ r.g.Uninstalled = false
+ switch seen {
+ case "suspended":
+ r.g.Suspended = true
+ case "too_many":
+ r.g.Count = MaxRepositories + 1
+ case "rate_limited":
+ r.g.FailPath, r.g.FailStatus = "/installation/repositories", 503
+ }
+ _, _ = r.s.Check(ctx, r.owner, view.ID)
+ var c Connection
+ r.s.DB.First(&c, "id = ?", view.ID)
+ if !c.UninstalledAt.IsZero() {
+ t.Fatal("seen installation left the uninstall clock running")
+ }
+ r.advance(5 * 24 * time.Hour)
+ r.s.Maintain = func(tx *gorm.DB) error { var o []testOwner; return tx.Find(&o).Error }
+ if err := r.s.Sweep(ctx); err != nil {
+ t.Fatal(err)
+ }
+ r.s.DB.First(&c, "id = ?", view.ID)
+ if c.SealedKey == "" {
+ t.Fatal("reinstalled App key erased by the first uninstall's deadline")
+ }
+ })
+ }
+}
+
+// P3-2: Connect checks the roster in its own transaction, after Check commits.
+func TestForgeConnectOwnerInOwnTransaction(t *testing.T) {
+ r := storeRig(t)
+ ctx := context.Background()
+ view := r.created(t)
+ audit := r.s.Audit
+ r.s.Audit = func(tx *gorm.DB, person, kind, id string) error {
+ if kind == "forge.check" {
+ if err := tx.Model(&testOwner{}).Where("address = ?", person).Update("active", false).Error; err != nil {
+ return err
+ }
+ }
+ return audit(tx, person, kind, id)
+ }
+ if _, err := r.s.Connect(ctx, r.owner, view.ID); err == nil {
+ t.Fatal("removed owner connected")
+ }
+ var c Connection
+ r.s.DB.First(&c, "id = ?", view.ID)
+ if c.Confirmed || c.ActiveAccount != nil {
+ t.Fatal("Connect committed without a current owner")
+ }
+}
+
+// P3-2: the installation handoff is bound to the owner, the session and the deadline.
+func TestForgeInstallationURLBinding(t *testing.T) {
+ for _, change := range []string{"ok", "owner", "session", "deadline"} {
+ t.Run(change, func(t *testing.T) {
+ r := storeRig(t)
+ view := r.created(t)
+ who := r.owner
+ switch change {
+ case "owner":
+ who = Principal{r.other.Address, r.owner.Session}
+ case "session":
+ who.Session = "another-session"
+ case "deadline":
+ r.advance(10 * time.Minute)
+ }
+ target, err := r.s.InstallationURL(context.Background(), who, view.ID)
+ if change == "ok" {
+ if err != nil || !strings.HasPrefix(target, "https://github.com/apps/equipo-test-app/installations/new?state=") {
+ t.Fatal("installation handoff refused:", err)
+ }
+ return
+ }
+ if err == nil || target != "" {
+ t.Fatal("unbound installation handoff issued")
+ }
+ })
+ }
+}
+
+// P3-2: two installations matching the App and account are ambiguous.
+func TestForgeDuplicateInstallations(t *testing.T) {
+ r := storeRig(t)
+ view := r.created(t)
+ base := r.g.Transport()
+ r.s.API = NewAPI(transportFunc(func(req *http.Request) (*http.Response, error) {
+ response, err := base.RoundTrip(req)
+ if err != nil || req.URL.Path != "/app/installations" {
+ return response, err
+ }
+ var rows []map[string]any
+ err = json.NewDecoder(response.Body).Decode(&rows)
+ response.Body.Close()
+ if err != nil || len(rows) != 1 {
+ t.Error("fake installation list changed")
+ return nil, ErrUnavailable
+ }
+ twin := map[string]any{}
+ for k, v := range rows[0] {
+ twin[k] = v
+ }
+ twin["id"] = r.g.InstallationID + 1
+ raw, _ := json.Marshal([]map[string]any{twin, rows[0]})
+ response.Body = io.NopCloser(strings.NewReader(string(raw)))
+ return response, nil
+ }), func() time.Time { return r.now })
+ got, err := r.s.Check(context.Background(), r.owner, view.ID)
+ if err == nil || got.State == StateReady || got.CountKnown {
+ t.Fatal("ambiguous installation accepted")
+ }
+ if r.g.Calls("GET", "/installation/repositories") != 0 {
+ t.Fatal("ambiguous installation listed repositories")
+ }
+}
+
+// P3-2: Disconnect drops and revokes the in-memory metadata token.
+func TestForgeDisconnectDropsToken(t *testing.T) {
+ r := storeRig(t)
+ ctx := context.Background()
+ view := r.created(t)
+ if _, err := r.s.Check(ctx, r.owner, view.ID); err != nil {
+ t.Fatal(err)
+ }
+ if _, err := r.s.Disconnect(ctx, r.owner, view.ID); err != nil {
+ t.Fatal(err)
+ }
+ r.s.API.mu.Lock()
+ n := len(r.s.API.tokens)
+ r.s.API.mu.Unlock()
+ if n != 0 || r.g.Calls("DELETE", "/installation/token") != 1 {
+ t.Fatal("Disconnect retained the metadata token")
+ }
+}
+
+// P3-3: a busy claim is retryable, not a setup failure.
+func TestForgeBusyCheckIsRetryable(t *testing.T) {
+ r := storeRig(t)
+ ctx := context.Background()
+ view := r.created(t)
+ if err := r.s.DB.Model(&Connection{}).Where("id = ?", view.ID).Updates(map[string]any{"claim": "held", "claim_until": r.now.Add(time.Minute)}).Error; err != nil {
+ t.Fatal(err)
+ }
+ if _, err := r.s.Check(ctx, r.other, view.ID); !Retryable(err) {
+ t.Fatal("busy claim not retryable:", err)
+ }
+ for _, err := range []error{ErrBusy, ErrUnavailable, ErrRateLimit, context.DeadlineExceeded, &APIError{503, ErrUnavailable}} {
+ if !Retryable(err) {
+ t.Fatal("transient error not retryable:", err)
+ }
+ }
+ for _, err := range []error{ErrAccess, ErrReconnect, gorm.ErrRecordNotFound} {
+ if Retryable(err) {
+ t.Fatal("setup failure treated as retryable:", err)
+ }
+ }
+}
+
+// P3-4: a conversion that never finishes is swept to failed with its cleanup link.
+func TestForgeStuckConversion(t *testing.T) {
+ ctx := context.Background()
+ for _, recorded := range []bool{false, true} {
+ t.Run(map[bool]string{false: "no-app-id", true: "app-id"}[recorded], func(t *testing.T) {
+ r := storeRig(t)
+ r.s.Maintain = func(tx *gorm.DB) error { var o []testOwner; return tx.Find(&o).Error }
+ began, err := r.s.Start(ctx, r.owner, r.g.Login, r.g.AccountType)
+ if err != nil {
+ t.Fatal(err)
+ }
+ if recorded {
+ audit := r.s.Audit
+ r.s.Audit = func(tx *gorm.DB, person, kind, id string) error {
+ if kind == "forge.convert" {
+ return ErrUnavailable
+ }
+ return audit(tx, person, kind, id)
+ }
+ if _, err = r.s.Convert(ctx, r.owner, began.State, r.g.Code); err == nil {
+ t.Fatal("failed second transaction reported success")
+ }
+ r.s.Audit = audit
+ } else if _, err = r.s.claimCallback(ctx, r.owner, began.State, "manifest"); err != nil {
+ t.Fatal(err)
+ }
+ var c Connection
+ r.s.DB.First(&c, "id = ?", began.View.ID)
+ if c.State != StateConverting || (c.AppID != 0) != recorded {
+ t.Fatalf("setup: state %s app %d", c.State, c.AppID)
+ }
+ r.advance(time.Minute)
+ if err = r.s.Sweep(ctx); err != nil {
+ t.Fatal(err)
+ }
+ r.s.DB.First(&c, "id = ?", began.View.ID)
+ if c.State != StateConverting {
+ t.Fatal("conversion swept before its bound")
+ }
+ r.advance(2 * time.Minute)
+ if err = r.s.Sweep(ctx); err != nil {
+ t.Fatal(err)
+ }
+ r.s.DB.First(&c, "id = ?", began.View.ID)
+ if c.State != StateFailed || c.SealedKey != "" || c.ManifestHash != "" {
+ t.Fatal("stuck conversion not swept to failed:", c.State)
+ }
+ var slots int64
+ r.s.DB.Model(&Pending{}).Count(&slots)
+ if slots != 0 {
+ t.Fatal("stuck conversion kept the pending slot")
+ }
+ views := r.list(t)
+ if len(views) != 1 || views[0].State != StateFailed {
+ t.Fatalf("failed attempt not listed: %+v", views)
+ }
+ want := "https://github.com/organizations/" + r.g.Login + "/settings/apps"
+ if recorded {
+ want += "/equipo-test-app"
+ }
+ if views[0].SettingsURL != want {
+ t.Fatalf("cleanup link %s, want %s", views[0].SettingsURL, want)
+ }
+ })
+ }
+}
+
+// P3-8: the code's shape is checked before the single-use state is spent.
+func TestForgeManifestCodeShape(t *testing.T) {
+ ctx := context.Background()
+ for _, code := range []string{"", "a/b", "a b", "a%2Fb", "a?b", ".", "..", strings.Repeat("a", 257)} {
+ t.Run(code, func(t *testing.T) {
+ r := storeRig(t)
+ began, err := r.s.Start(ctx, r.owner, r.g.Login, r.g.AccountType)
+ if err != nil {
+ t.Fatal(err)
+ }
+ if _, err = r.s.Convert(ctx, r.owner, began.State, code); err == nil {
+ t.Fatal("malformed code accepted")
+ }
+ var c Connection
+ r.s.DB.First(&c, "id = ?", began.View.ID)
+ if c.State != StateManifest || c.ManifestHash == "" {
+ t.Fatal("malformed code spent the state")
+ }
+ if _, err = r.s.Convert(ctx, r.owner, began.State, r.g.Code); err != nil {
+ t.Fatal("state unusable after a refused code:", err)
+ }
+ })
+ }
+ t.Run("dotted", func(t *testing.T) {
+ r := storeRig(t)
+ r.g.Code = "v1.Ab_c-" + strings.Repeat("9", 200)
+ if v := r.created(t); v.State != StatePending {
+ t.Fatal("dotted code refused")
+ }
+ })
+}
+
+// P3-5: the API mutex is never held across a network call.
+func TestMetadataLockNotHeldAcrossNetwork(t *testing.T) {
+ r := storeRig(t)
+ ctx := context.Background()
+ view := r.created(t)
+ var c Connection
+ r.s.DB.First(&c, "id = ?", view.ID)
+ app, err := r.s.app(c)
+ if err != nil {
+ t.Fatal(err)
+ }
+ inst, err := r.s.API.Installation(ctx, app, r.g.InstallationID)
+ if err != nil {
+ t.Fatal(err)
+ }
+ entered, release := make(chan struct{}), make(chan struct{})
+ base := r.g.Transport()
+ api := NewAPI(transportFunc(func(req *http.Request) (*http.Response, error) {
+ if strings.HasSuffix(req.URL.Path, "/access_tokens") {
+ close(entered)
+ <-release
+ }
+ return base.RoundTrip(req)
+ }), func() time.Time { return r.now })
+ done := make(chan error, 1)
+ go func() { _, e := api.Inventory(ctx, app, inst); done <- e }()
+ <-entered
+ forgot := make(chan struct{})
+ go func() { api.Forget(ctx, app.ID); close(forgot) }()
+ select {
+ case <-forgot:
+ case <-time.After(2 * time.Second):
+ close(release)
+ t.Fatal("Forget waited behind a GitHub request")
+ }
+ close(release)
+ if err = <-done; err == nil {
+ t.Fatal("token minted across Forget was used")
+ }
+ api.mu.Lock()
+ n := len(api.tokens)
+ api.mu.Unlock()
+ if n != 0 || r.g.Calls("DELETE", "/installation/token") != 1 {
+ t.Fatal("token minted across Forget was retained or not revoked")
+ }
+}
diff --git a/internal/equipo/github/store.go b/internal/equipo/github/store.go
index 8016eca0..0c791c87 100644
--- a/internal/equipo/github/store.go
+++ b/internal/equipo/github/store.go
@@ -88,7 +88,7 @@ func (s *Store) view(c Connection) View {
}
return View{ID: c.ID, State: c.State, Login: c.Login, AccountType: c.AccountType, Slug: c.Slug, SettingsURL: settings, Generation: c.Generation, AppID: c.AppID, AccountID: c.AccountID, InstallationID: c.InstallationID, Count: c.Count, CountKnown: c.CountKnown, Confirmed: c.Confirmed}
}
-func erase(c *Connection, state string) {
+func erase(c *Connection, state State) {
c.SealedKey = ""
c.ManifestHash = ""
c.InstallationHash = ""
@@ -110,7 +110,7 @@ func (s *Store) Start(ctx context.Context, p Principal, login, kind string) (Sta
err := tx.Where("LOWER(login) = ? AND account_type = ? AND active_account IS NOT NULL", login, kind).First(&active).Error
if err == nil {
result.View = s.view(active)
- result.View.State = "already_connected"
+ result.View.State = StateAlreadyConnected
return nil
}
if !errors.Is(err, gorm.ErrRecordNotFound) {
@@ -126,16 +126,21 @@ func (s *Store) Start(ctx context.Context, p Principal, login, kind string) (Sta
if err = tx.First(&old, "id = ?", slot.ConnectionID).Error; err != nil {
return err
}
- prior := s.view(old)
- result.Superseded = &prior
forgotten = old.AppID
- erase(&old, "superseded")
+ if calledBack(old) {
+ prior := s.view(old)
+ result.Superseded = &prior
+ erase(&old, StateSuperseded)
+ } else {
+ // No manifest callback arrived, so no App is known to exist.
+ erase(&old, StateAbandoned)
+ }
if err = s.save(tx, p, &old, "forge.supersede"); err != nil {
return err
}
}
now := s.now()
- c := Connection{ID: strings.ToLower(rand.Text()), Generation: 1, State: "manifest", Login: login, AccountType: kind, AppName: "equipo-" + strings.ToLower(rand.Text()[:12]), Owner: p.Address, Session: digest(p.Session), Origin: s.Origin, StartedAt: now, RedirectUntil: now.Add(10 * time.Minute), UpdatedAt: now}
+ c := Connection{ID: strings.ToLower(rand.Text()), Generation: 1, State: StateManifest, Login: login, AccountType: kind, AppName: "equipo-" + strings.ToLower(rand.Text()[:12]), Owner: p.Address, Session: digest(p.Session), Origin: s.Origin, StartedAt: now, RedirectUntil: now.Add(10 * time.Minute), UpdatedAt: now}
raw := s.state(c, "manifest")
c.ManifestHash = digest(raw)
if err = tx.Create(&c).Error; err != nil {
@@ -169,11 +174,29 @@ func (s *Store) List(ctx context.Context, p Principal) ([]View, error) {
return nil, err
}
var records []Connection
- if err := tx.Order("started_at DESC").Find(&records).Error; err != nil {
+ if err := tx.Order("started_at DESC").Order("id").Find(&records).Error; err != nil {
return nil, err
}
+ // Live and pending connections are listed. A dead attempt is listed only as
+ // its account's latest, only if its App exists, and only until that account
+ // is connected again.
+ account := func(c Connection) string { return strings.ToLower(c.Login) + "\x00" + c.AccountType }
+ connected := map[string]bool{}
+ for _, record := range records {
+ if record.ActiveAccount != nil {
+ connected[account(record)] = true
+ }
+ }
+ shown := map[string]bool{}
views := make([]View, 0, len(records))
for _, record := range records {
+ if record.State.Dead() {
+ key := account(record)
+ if record.State == StateAbandoned || connected[key] || shown[key] {
+ continue
+ }
+ shown[key] = true
+ }
views = append(views, s.view(record))
}
return views, nil
@@ -184,7 +207,11 @@ func (s *Store) Disconnect(ctx context.Context, p Principal, id string) (View, e
if err := tx.First(&c, "id = ?", id).Error; err != nil {
return err
}
- erase(&c, "disconnected")
+ state := StateDisconnected
+ if !calledBack(c) {
+ state = StateAbandoned
+ }
+ erase(&c, state)
if err := s.save(tx, p, &c, "forge.disconnect"); err != nil {
return err
}
@@ -219,6 +246,21 @@ func (s *Store) Sweep(ctx context.Context) error {
if err := tx.Where("sealed_key <> ?", "").Find(&rows).Error; err != nil {
return err
}
+ // A conversion that neither finished nor failed within its bound
+ // (a failed transaction or a lost process) becomes a failed setup.
+ var stuck []Connection
+ if err := tx.Where("state = ? AND updated_at < ?", StateConverting, s.now().Add(-conversionBound)).Find(&stuck).Error; err != nil {
+ return err
+ }
+ for _, c := range stuck {
+ erase(&c, StateFailed)
+ if err := s.save(tx, Principal{}, &c, "forge.expire"); err != nil {
+ return err
+ }
+ if err := tx.Where("connection_id = ?", c.ID).Delete(&Pending{}).Error; err != nil {
+ return err
+ }
+ }
for _, c := range rows {
state := s.expired(c)
if state == "" {
diff --git a/internal/equipo/github_http.go b/internal/equipo/github_http.go
index a7f1b3d3..9ce3ac80 100644
--- a/internal/equipo/github_http.go
+++ b/internal/equipo/github_http.go
@@ -2,7 +2,6 @@ package equipo
import (
"encoding/json"
- "errors"
"net/http"
"net/url"
@@ -67,11 +66,16 @@ func (a *application) githubSettings(w http.ResponseWriter, r *http.Request) {
return
}
view := githubPageView{}
- if r.URL.Query().Get("failed") == "1" {
- view.Notice = copyText("github.setup_failed")
+ if key, ok := githubNotice(r.URL.Query().Get("failed")); ok {
+ view.Notice = copyText(key)
}
for _, v := range rows {
- view.Rows = append(view.Rows, githubRow(r, v))
+ row, err := githubRow(r, v)
+ if err != nil {
+ a.failure(w, r, ErrUnavailable)
+ return
+ }
+ view.Rows = append(view.Rows, row)
}
a.githubRender(w, r, view)
}
@@ -94,11 +98,21 @@ func (a *application) githubStart(w http.ResponseWriter, r *http.Request) {
view := githubPageView{}
if started.Superseded != nil {
old := *started.Superseded
- old.State = "superseded"
- view.Rows = append(view.Rows, githubRow(r, old))
+ old.State = github.StateSuperseded
+ row, err := githubRow(r, old)
+ if err != nil {
+ a.failure(w, r, ErrUnavailable)
+ return
+ }
+ view.Rows = append(view.Rows, row)
}
if started.State == "" {
- view.Rows = append(view.Rows, githubRow(r, started.View))
+ row, err := githubRow(r, started.View)
+ if err != nil {
+ a.failure(w, r, ErrUnavailable)
+ return
+ }
+ view.Rows = append(view.Rows, row)
a.githubRender(w, r, view)
return
}
@@ -144,11 +158,8 @@ func (a *application) githubCallback(w http.ResponseWriter, r *http.Request, man
view, err = a.store.forge.Install(ctx, p, r.URL.Query().Get("state"))
}
// No code, state, upstream body or raw error survives into the clean URL.
- target := "/conversation/settings/github"
- var refused *github.Refusal
- if err != nil && !errors.As(err, &refused) {
- target += "?failed=1"
- } else if manifest && err == nil {
+ target := "/conversation/settings/github" + githubFailure(err)
+ if manifest && err == nil {
target += "?id=" + url.QueryEscape(view.ID) + "&install=1"
}
http.Redirect(w, r, target, http.StatusSeeOther)
@@ -181,11 +192,6 @@ func (a *application) githubAction(action string) http.HandlerFunc {
case "disconnect":
_, err = a.store.forge.Disconnect(ctx, p, id)
}
- var refusal *github.Refusal
- target := "/conversation/settings/github"
- if err != nil && !errors.As(err, &refusal) {
- target += "?failed=1"
- }
- http.Redirect(w, r, target, http.StatusSeeOther)
+ http.Redirect(w, r, "/conversation/settings/github"+githubFailure(err), http.StatusSeeOther)
}
}
diff --git a/internal/equipo/github_view.go b/internal/equipo/github_view.go
index 4c205327..2eed61aa 100644
--- a/internal/equipo/github_view.go
+++ b/internal/equipo/github_view.go
@@ -1,7 +1,10 @@
package equipo
import (
+ "context"
+ "errors"
"fmt"
+ "log/slog"
"net/http"
"strconv"
"strings"
@@ -18,54 +21,92 @@ type githubPageView struct {
}
type githubRowView struct {
github.View
- Lines []string
+ Lines, Keys []string
Check, Confirm, Disconnect, Cleanup, Reconnect bool
RepositoriesURL string
}
-func githubStateKeys(v github.View) []string {
+var (
+ errGitHubUnknownState = errors.New("github: unknown connection state")
+ errGitHubHiddenState = errors.New("github: connection state is never rendered")
+)
+
+// githubStateKeys maps each typed state to its exact brief keys. There is no
+// default: an unknown state is an error, never a silent blank row.
+func githubStateKeys(v github.View) ([]string, error) {
switch v.State {
- case "manifest", "converting":
- return []string{"github.create_hint"}
- case "pending":
+ case github.StateManifest, github.StateConverting:
+ return []string{"github.create_hint"}, nil
+ case github.StatePending:
keys := []string{"github.pending", "github.pending_hint"}
if v.AccountType == "Organization" {
keys = append(keys, "github.pending_approval")
}
- return keys
- case "ready":
- return []string{"github.confirm_account", "github.repository_count"}
- case "live":
- return []string{"github.connected", "github.disconnect_hint"}
- case "already_connected":
- return []string{"github.already_connected", "github.connected", "github.disconnect_hint"}
- case "manifest_expired", "failed":
- return []string{"github.setup_failed", "github.app_remains"}
- case "installation_expired":
- return []string{"github.redirect_expired"}
- case "expired":
- return []string{"github.pending_expired", "github.app_remains"}
- case "superseded":
- return []string{"github.app_remains"}
- case "disconnected", "uninstalled_expired":
- return []string{"github.not_connected", "github.app_remains"}
- case "uninstalled":
- return []string{"github.not_connected"}
- case "reconnect":
- return []string{"github.reconnect_hint", "github.app_remains"}
- case "check_failed":
- return []string{"github.check_failed"}
- case "suspended":
- return []string{"github.suspended"}
- case "too_many":
- return []string{"github.too_many"}
- default:
- return nil
+ return keys, nil
+ case github.StateReady:
+ return []string{"github.confirm_account", "github.repository_count"}, nil
+ case github.StateLive:
+ return []string{"github.connected", "github.disconnect_hint"}, nil
+ case github.StateAlreadyConnected:
+ return []string{"github.already_connected", "github.connected", "github.disconnect_hint"}, nil
+ case github.StateManifestExpired, github.StateFailed:
+ return []string{"github.setup_failed", "github.app_remains"}, nil
+ case github.StateInstallationExpired:
+ return []string{"github.redirect_expired"}, nil
+ case github.StateExpired:
+ return []string{"github.pending_expired", "github.app_remains"}, nil
+ case github.StateSuperseded:
+ return []string{"github.app_remains"}, nil
+ case github.StateAbandoned:
+ // No App was created; List never returns these rows.
+ return nil, errGitHubHiddenState
+ case github.StateDisconnected, github.StateUninstalledExpired:
+ return []string{"github.not_connected", "github.app_remains"}, nil
+ case github.StateUninstalled:
+ return []string{"github.not_connected"}, nil
+ case github.StateReconnect:
+ return []string{"github.reconnect_hint", "github.app_remains"}, nil
+ case github.StateCheckFailed:
+ return []string{"github.check_failed"}, nil
+ case github.StateSuspended:
+ return []string{"github.suspended"}, nil
+ case github.StateTooMany:
+ return []string{"github.too_many"}, nil
+ }
+ return nil, errGitHubUnknownState
+}
+
+// githubNotice maps the clean redirect's failed parameter to its notice key.
+func githubNotice(failed string) (string, bool) {
+ switch failed {
+ case "1":
+ return "github.setup_failed", true
+ case "check":
+ return "github.check_failed", true
+ }
+ return "", false
+}
+
+// githubFailure is the clean redirect for a lifecycle error that has no row
+// state of its own: retryable work says so, anything else is a setup failure.
+func githubFailure(err error) string {
+ var refused *github.Refusal
+ switch {
+ case err == nil || errors.As(err, &refused):
+ return ""
+ case github.Retryable(err):
+ return "?failed=check"
}
+ return "?failed=1"
}
-func githubRow(r *http.Request, v github.View) githubRowView {
+
+func githubRow(r *http.Request, v github.View) (githubRowView, error) {
row := githubRowView{View: v}
- for _, key := range githubStateKeys(v) {
+ keys, err := githubStateKeys(v)
+ if err != nil {
+ return row, err
+ }
+ for _, key := range keys {
text := copyText(key)
switch key {
case "github.confirm_account", "github.already_connected":
@@ -81,26 +122,52 @@ func githubRow(r *http.Request, v github.View) githubRowView {
case "github.app_remains":
row.Cleanup = true
}
+ row.Keys = append(row.Keys, key)
row.Lines = append(row.Lines, text)
}
switch v.State {
- case "pending", "installation_expired", "check_failed", "uninstalled", "suspended", "too_many", "ready":
+ case github.StatePending, github.StateInstallationExpired, github.StateCheckFailed, github.StateUninstalled, github.StateSuspended, github.StateTooMany, github.StateReady:
row.Check = true
row.Disconnect = true
- case "live", "already_connected":
+ case github.StateLive, github.StateAlreadyConnected:
row.Disconnect = true
- case "expired", "uninstalled_expired", "disconnected", "reconnect":
+ case github.StateExpired, github.StateUninstalledExpired, github.StateDisconnected, github.StateReconnect:
row.Reconnect = true
}
- row.Confirm = v.State == "ready" && v.CountKnown && v.Count <= github.MaxRepositories
- if v.State == "too_many" && v.InstallationID > 0 {
+ row.Confirm = v.State == github.StateReady && v.CountKnown && v.Count <= github.MaxRepositories
+ if v.State == github.StateTooMany && v.InstallationID > 0 {
base := "https://github.com/settings/installations/"
if v.AccountType == "Organization" {
base = "https://github.com/organizations/" + v.Login + "/settings/installations/"
}
row.RepositoriesURL = base + strconv.FormatInt(v.InstallationID, 10)
}
- return row
+ for _, action := range []struct {
+ on bool
+ key string
+ }{{row.Cleanup, "github.app_settings"}, {row.RepositoriesURL != "", "github.choose_repositories"}, {row.Check, "github.check_again"}, {row.Confirm, "github.confirm"}, {row.Disconnect, "github.disconnect"}, {row.Reconnect, "github.reconnect"}} {
+ if action.on {
+ row.Keys = append(row.Keys, action.key)
+ }
+ }
+ return row, nil
+}
+
+// logGitHubSweep records a sweep failure with its type only: no error text,
+// which could carry an upstream value.
+func logGitHubSweep(logger *slog.Logger, err error) {
+ kind := "other"
+ switch {
+ case errors.Is(err, context.DeadlineExceeded), errors.Is(err, context.Canceled):
+ kind = "timeout"
+ case errors.Is(err, github.ErrAccess):
+ kind = "access"
+ case errors.Is(err, github.ErrBusy):
+ kind = "busy"
+ case errors.Is(err, github.ErrUnavailable), errors.Is(err, github.ErrRateLimit):
+ kind = "unavailable"
+ }
+ logger.Error(copyGitHubSweep, "err_type", fmt.Sprintf("%T", err), "kind", kind)
}
// Only the manifest document may submit outside the instance. Preserve the
diff --git a/internal/equipo/github_view_test.go b/internal/equipo/github_view_test.go
index 88131172..fc1e0b32 100644
--- a/internal/equipo/github_view_test.go
+++ b/internal/equipo/github_view_test.go
@@ -1,37 +1,64 @@
package equipo
import (
+ "fmt"
+ "log/slog"
+ "maps"
+ "net/http"
"net/http/httptest"
+ "os"
"reflect"
+ "regexp"
+ "slices"
"strings"
"testing"
"amadan.net/oficina/equipo/internal/equipo/github"
)
+// githubBriefKeys are branch A's 31 keys from the reviewed copy brief.
+var githubBriefKeys = []string{"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"}
+
+// githubStateFixtures has one explicit entry per typed state; nil means the
+// state is never rendered.
+var githubStateFixtures = map[github.State][]string{
+ github.StateManifest: {"github.create_hint"}, github.StateConverting: {"github.create_hint"},
+ github.StatePending: {"github.pending", "github.pending_hint", "github.pending_approval"},
+ github.StateReady: {"github.confirm_account", "github.repository_count"},
+ github.StateLive: {"github.connected", "github.disconnect_hint"},
+ github.StateAlreadyConnected: {"github.already_connected", "github.connected", "github.disconnect_hint"},
+ github.StateManifestExpired: {"github.setup_failed", "github.app_remains"},
+ github.StateInstallationExpired: {"github.redirect_expired"},
+ github.StateExpired: {"github.pending_expired", "github.app_remains"},
+ github.StateFailed: {"github.setup_failed", "github.app_remains"},
+ github.StateSuperseded: {"github.app_remains"},
+ github.StateAbandoned: nil,
+ github.StateDisconnected: {"github.not_connected", "github.app_remains"},
+ github.StateUninstalled: {"github.not_connected"},
+ github.StateUninstalledExpired: {"github.not_connected", "github.app_remains"},
+ github.StateReconnect: {"github.reconnect_hint", "github.app_remains"},
+ github.StateCheckFailed: {"github.check_failed"}, github.StateSuspended: {"github.suspended"}, github.StateTooMany: {"github.too_many"},
+}
+
func TestGitHubStateCopy(t *testing.T) {
- cases := map[string][]string{
- "manifest": {"github.create_hint"}, "converting": {"github.create_hint"},
- "pending": {"github.pending", "github.pending_hint", "github.pending_approval"},
- "ready": {"github.confirm_account", "github.repository_count"},
- "live": {"github.connected", "github.disconnect_hint"},
- "already_connected": {"github.already_connected", "github.connected", "github.disconnect_hint"},
- "manifest_expired": {"github.setup_failed", "github.app_remains"},
- "installation_expired": {"github.redirect_expired"},
- "expired": {"github.pending_expired", "github.app_remains"},
- "failed": {"github.setup_failed", "github.app_remains"},
- "superseded": {"github.app_remains"},
- "disconnected": {"github.not_connected", "github.app_remains"},
- "uninstalled": {"github.not_connected"},
- "uninstalled_expired": {"github.not_connected", "github.app_remains"},
- "reconnect": {"github.reconnect_hint", "github.app_remains"},
- "check_failed": {"github.check_failed"}, "suspended": {"github.suspended"}, "too_many": {"github.too_many"},
- }
- for state, want := range cases {
- t.Run(state, func(t *testing.T) {
- got := githubStateKeys(github.View{State: state, AccountType: "Organization"})
- if !reflect.DeepEqual(got, want) {
- t.Fatalf("state keys %v, want %v", got, want)
+ if len(githubStateFixtures) != len(github.States) {
+ t.Fatalf("%d fixtures for %d typed states", len(githubStateFixtures), len(github.States))
+ }
+ for _, state := range github.States {
+ t.Run(string(state), func(t *testing.T) {
+ want, ok := githubStateFixtures[state]
+ if !ok {
+ t.Fatal("typed state has no explicit fixture")
+ }
+ got, err := githubStateKeys(github.View{State: state, AccountType: "Organization"})
+ if want == nil {
+ if err == nil {
+ t.Fatalf("hidden state rendered %v", got)
+ }
+ return
+ }
+ if err != nil || !reflect.DeepEqual(got, want) {
+ t.Fatalf("state keys %v (%v), want %v", got, err, want)
}
for _, key := range got {
if copyText(key) == "" || copyText(key) == key {
@@ -40,9 +67,72 @@ func TestGitHubStateCopy(t *testing.T) {
}
})
}
- if got := githubStateKeys(github.View{State: "pending", AccountType: "User"}); !reflect.DeepEqual(got, []string{"github.pending", "github.pending_hint"}) {
+ if got, err := githubStateKeys(github.View{State: github.StatePending, AccountType: "User"}); err != nil || !reflect.DeepEqual(got, []string{"github.pending", "github.pending_hint"}) {
t.Fatalf("personal account: %v", got)
}
+ if got, err := githubStateKeys(github.View{State: "unknown"}); err == nil {
+ t.Fatalf("unknown state rendered %v", got)
+ }
+ if _, err := githubRow(httptest.NewRequest("GET", "/", nil), github.View{State: "unknown"}); err == nil {
+ t.Fatal("unknown state row rendered")
+ }
+}
+
+// The keys a page can render are exactly the brief's 31, with no fallback.
+func TestGitHubRenderedKeys(t *testing.T) {
+ r := httptest.NewRequest("GET", "https://equipo.example/settings", nil)
+ rendered := map[string]bool{}
+ for _, state := range github.States {
+ for _, kind := range []string{"Organization", "User"} {
+ for _, v := range []github.View{{State: state, AccountType: kind, Login: "oficina"}, {State: state, AccountType: kind, Login: "oficina", CountKnown: true, Count: 3, InstallationID: 12}} {
+ row, err := githubRow(r, v)
+ if githubStateFixtures[state] == nil {
+ if err == nil {
+ t.Fatalf("hidden state %s rendered", state)
+ }
+ continue
+ }
+ if err != nil {
+ t.Fatal(err)
+ }
+ for _, key := range row.Keys {
+ rendered[key] = true
+ }
+ }
+ }
+ }
+ for _, notice := range []string{"1", "check"} {
+ key, ok := githubNotice(notice)
+ if !ok {
+ t.Fatalf("notice %s unmapped", notice)
+ }
+ rendered[key] = true
+ }
+ if _, ok := githubNotice("other"); ok {
+ t.Fatal("unknown notice rendered")
+ }
+ raw, err := os.ReadFile("templates/github.html")
+ if err != nil {
+ t.Fatal(err)
+ }
+ for _, m := range regexp.MustCompile(`copy "(github\.[a-z_]+)"`).FindAllStringSubmatch(string(raw), -1) {
+ rendered[m[1]] = true
+ }
+ got := slices.Sorted(maps.Keys(rendered))
+ want := slices.Sorted(slices.Values(githubBriefKeys))
+ if len(want) != 31 || !reflect.DeepEqual(got, want) {
+ t.Fatalf("rendered keys differ from the brief:\n got %v\nwant %v", got, want)
+ }
+}
+
+func TestGitHubSweepLog(t *testing.T) {
+ var out strings.Builder
+ logger := slog.New(slog.NewTextHandler(&out, nil))
+ logGitHubSweep(logger, fmt.Errorf("ghs_secretvalue: %w", github.ErrUnavailable))
+ line := out.String()
+ if !strings.Contains(line, copyGitHubSweep) || !strings.Contains(line, "kind=unavailable") || !strings.Contains(line, "err_type=") || strings.Contains(line, "ghs_") || strings.Contains(line, copyText("github.check_failed")) {
+ t.Fatalf("sweep log: %s", line)
+ }
}
func TestGitHubCSPIsolation(t *testing.T) {
@@ -58,16 +148,16 @@ func TestGitHubCSPIsolation(t *testing.T) {
func TestGitHubConfirmationAndCleanup(t *testing.T) {
r := httptest.NewRequest("GET", "https://equipo.example/settings", nil)
for _, v := range []github.View{{State: "too_many", InstallationID: 12, AccountType: "Organization", Login: "oficina"}, {State: "ready", CountKnown: false}, {State: "ready", CountKnown: true, Count: 1001}} {
- if githubRow(r, v).Confirm {
+ if mustGitHubRow(t, r, v).Confirm {
t.Fatal("Connect shown without complete allowed count")
}
}
- row := githubRow(r, github.View{State: "too_many", InstallationID: 12, AccountType: "Organization", Login: "oficina"})
+ row := mustGitHubRow(t, r, github.View{State: "too_many", InstallationID: 12, AccountType: "Organization", Login: "oficina"})
if !strings.Contains(row.Lines[0], "1,000") || row.RepositoriesURL != "https://github.com/organizations/oficina/settings/installations/12" || !row.Check {
t.Fatal("over-limit controls or localized bound missing")
}
- for _, state := range []string{"expired", "uninstalled_expired", "disconnected", "reconnect", "failed", "manifest_expired", "superseded"} {
- row := githubRow(r, github.View{State: state})
+ for _, state := range []github.State{"expired", "uninstalled_expired", "disconnected", "reconnect", "failed", "manifest_expired", "superseded"} {
+ row := mustGitHubRow(t, r, github.View{State: state})
if !row.Cleanup || row.Check {
t.Fatalf("cleanup state %s offers Check or omits cleanup", state)
}
@@ -76,9 +166,18 @@ func TestGitHubConfirmationAndCleanup(t *testing.T) {
func TestGitHubDisconnectHeldKey(t *testing.T) {
r := httptest.NewRequest("GET", "https://equipo.example/settings", nil)
- for _, state := range []string{"pending", "ready", "installation_expired", "check_failed", "uninstalled", "suspended", "too_many", "live"} {
- if !githubRow(r, github.View{State: state}).Disconnect {
+ for _, state := range []github.State{"pending", "ready", "installation_expired", "check_failed", "uninstalled", "suspended", "too_many", "live"} {
+ if !mustGitHubRow(t, r, github.View{State: state}).Disconnect {
t.Fatalf("owner cannot disconnect %s", state)
}
}
}
+
+func mustGitHubRow(t *testing.T, r *http.Request, v github.View) githubRowView {
+ t.Helper()
+ row, err := githubRow(r, v)
+ if err != nil {
+ t.Fatal(err)
+ }
+ return row
+}
diff --git a/internal/equipotest/github_app_test.go b/internal/equipotest/github_app_test.go
index df9135d0..b769f583 100644
--- a/internal/equipotest/github_app_test.go
+++ b/internal/equipotest/github_app_test.go
@@ -4,6 +4,8 @@ import (
"amadan.net/oficina/equipo/internal/equipo/github"
"amadan.net/rastrillo/rastrillo"
"bytes"
+ "crypto/x509"
+ "encoding/base64"
"encoding/json"
"html"
"io"
@@ -13,6 +15,7 @@ import (
"net/url"
"reflect"
"regexp"
+ "strconv"
"strings"
"testing"
"time"
@@ -135,7 +138,27 @@ func TestGitHubHTTPFlowAndValues(t *testing.T) {
if !reflect.DeepEqual(m["default_permissions"], want) || m["hook_attributes"].(map[string]any)["active"] != false {
t.Fatal("manifest permissions or webhook widened")
}
- seen := []string{}
+ // Every sink is labelled so a leak names where it escaped, never the value.
+ seen := map[string]string{}
+ sink := func(label, value string) { seen[label+" "+strconv.Itoa(len(seen))] = value }
+ dump := func(phase string) {
+ t.Helper()
+ var tables []string
+ if err := f.db.G.Raw("SELECT name FROM sqlite_master WHERE type='table'").Scan(&tables).Error; err != nil {
+ t.Fatal(err)
+ }
+ for _, table := range tables {
+ var rows []map[string]any
+ if err := f.db.G.Table(table).Find(&rows).Error; err != nil {
+ t.Fatal(err)
+ }
+ raw, err := json.Marshal(rows)
+ if err != nil {
+ t.Fatal(err)
+ }
+ sink("table "+table+" "+phase, string(raw))
+ }
+ }
clean := func(response *http.Response) string {
t.Helper()
if response.StatusCode != 303 {
@@ -148,11 +171,13 @@ func TestGitHubHTTPFlowAndValues(t *testing.T) {
if response.Header.Get("Cache-Control") != "no-store" || response.Header.Get("Referrer-Policy") != "no-referrer" {
t.Fatal("callback caching or referrer")
}
- seen = append(seen, location, githubBody(t, response))
+ sink("location", location)
+ sink("callback body", githubBody(t, response))
return location
}
callback := f.server.URL + "/github/connect/manifest?" + url.Values{"state": {state}, "code": {g.Code}}.Encode()
location := clean(clientGet(t, client, callback))
+ dump("after conversion")
var connections []github.Connection
if err := f.db.G.Find(&connections).Error; err != nil {
t.Fatal(err)
@@ -176,7 +201,7 @@ func TestGitHubHTTPFlowAndValues(t *testing.T) {
t.Fatal("CSP exception spread")
}
body := githubBody(t, page)
- seen = append(seen, body)
+ sink("page", body)
if !strings.Contains(body, "Repositories: 2") || !strings.Contains(body, `action="/github/connect/confirm"`) {
t.Fatal("verified installation confirmation absent")
}
@@ -184,41 +209,45 @@ func TestGitHubHTTPFlowAndValues(t *testing.T) {
clean(clientPost(t, client, f.server.URL+"/github/connect/confirm", testOrigin, url.Values{"id": {id}}))
page = clientGet(t, client, f.server.URL+"/conversation/settings/github")
body = githubBody(t, page)
- seen = append(seen, body)
+ sink("page", body)
if !strings.Contains(body, "GitHub is connected") {
t.Fatal("Connect not reflected")
}
+ dump("after connect")
clean(clientGet(t, client, callback))
if g.Calls("POST", "/app-manifests/"+g.Code+"/conversions") != 1 {
t.Fatal("callback replay converted again")
}
clean(clientPost(t, client, f.server.URL+"/github/connect/disconnect", testOrigin, url.Values{"id": {id}}))
+ page = clientGet(t, client, f.server.URL+"/conversation/settings/github")
+ sink("page", githubBody(t, page))
// Search every application table, including audits, reports, frames and prompts.
// Credential boundaries above are the only permitted code/state surfaces.
- var tables []string
- if err := f.db.G.Raw("SELECT name FROM sqlite_master WHERE type='table'").Scan(&tables).Error; err != nil {
- t.Fatal(err)
+ dump("after disconnect")
+ sink("log", f.logs.String())
+ githubValueSearch(t, seen, g, state, installState)
+}
+
+// githubValueSearch looks for single-line key fragments, which survive JSON,
+// log and HTML escaping, as well as the other credential values. The raw PEM
+// spans lines, so a dump that escapes its newlines would hide it.
+func githubValueSearch(t *testing.T, seen map[string]string, g *forgetest.GitHub, state, installState string) {
+ t.Helper()
+ lines := strings.Split(strings.TrimSpace(g.PEM), "\n")
+ if len(lines) < 4 {
+ t.Fatal("generated PEM too short")
}
- for _, table := range tables {
- var rows []map[string]any
- if err := f.db.G.Table(table).Find(&rows).Error; err != nil {
- t.Fatal(err)
- }
- raw, err := json.Marshal(rows)
- if err != nil {
- t.Fatal(err)
- }
- seen = append(seen, string(raw))
+ forbidden := map[string]string{
+ "PEM body line": lines[len(lines)/2], "DER base64": base64.StdEncoding.EncodeToString(x509.MarshalPKCS1PrivateKey(g.Key)),
+ "client secret": g.ClientSecret, "webhook secret": g.WebhookSecret, "token": g.Token, "code": g.Code, "state": state, "installation state": installState,
}
- seen = append(seen, f.logs.String())
- forbidden := []string{g.PEM, g.ClientSecret, g.WebhookSecret, g.Token, g.Code, state, installState}
- for _, secret := range forbidden {
- if secret == "" {
- t.Fatal("empty value-search fixture")
+ for name, secret := range forbidden {
+ if len(secret) < 16 {
+ t.Fatal("weak value-search fixture:", name)
}
- for _, sink := range seen {
- if strings.Contains(sink, secret) {
- t.Fatal("credential or redirect secret escaped its boundary")
+ for label, value := range seen {
+ if strings.Contains(value, secret) || strings.Contains(html.UnescapeString(value), secret) {
+ t.Errorf("%s escaped into %s", name, label)
}
}
}
diff --git a/internal/equipotest/github_review_test.go b/internal/equipotest/github_review_test.go
new file mode 100644
index 00000000..9ba6832e
--- /dev/null
+++ b/internal/equipotest/github_review_test.go
@@ -0,0 +1,125 @@
+package equipotest
+
+import (
+ "net/http"
+ "net/url"
+ "strings"
+ "testing"
+ "time"
+
+ "amadan.net/oficina/equipo/internal/equipo"
+ "amadan.net/oficina/equipo/internal/equipo/github"
+ "amadan.net/oficina/equipo/internal/runner/forge/forgetest"
+)
+
+// Review fixes (Fable, 2026-11-23): page-level lifecycle rendering.
+
+const githubAppRemains = "still exists on GitHub"
+
+func githubStart(t *testing.T, f githubAuthFixture, client *http.Client, login, kind string) string {
+ t.Helper()
+ response := clientPost(t, client, f.server.URL+"/github/connect/start", testOrigin, url.Values{"account": {login}, "account_type": {kind}})
+ if response.StatusCode != 200 {
+ t.Fatalf("start %d", response.StatusCode)
+ }
+ return githubBody(t, response)
+}
+func githubPage(t *testing.T, f githubAuthFixture, client *http.Client, query string) string {
+ t.Helper()
+ response := clientGet(t, client, f.server.URL+"/conversation/settings/github"+query)
+ if response.StatusCode != 200 {
+ t.Fatalf("page %d", response.StatusCode)
+ }
+ return githubBody(t, response)
+}
+func githubConvert(t *testing.T, f githubAuthFixture, g *forgetest.GitHub, client *http.Client, body string) {
+ t.Helper()
+ _, _, state := githubManifestForm(t, body)
+ response := clientGet(t, client, f.server.URL+"/github/connect/manifest?"+url.Values{"state": {state}, "code": {g.Code}}.Encode())
+ githubBody(t, response)
+ if location := response.Header.Get("Location"); !strings.Contains(location, "install=1") {
+ t.Fatalf("conversion failed: %s", location)
+ }
+}
+
+func TestGitHubAbandonedStartsPage(t *testing.T) {
+ f, g := githubFixture(t, true)
+ client := signinClient(t, f.server.URL)
+ signinEmail(t, client, f.server.URL, testOrigin, f.mail, ownerAddress)
+ githubStart(t, f, client, g.Login, g.AccountType)
+ if body := githubStart(t, f, client, g.Login, g.AccountType); strings.Contains(body, githubAppRemains) {
+ t.Fatal("start-back-start claimed an App remains")
+ }
+ body := githubStart(t, f, client, g.Login, g.AccountType)
+ if page := githubPage(t, f, client, ""); strings.Contains(page, githubAppRemains) || strings.Count(page, "data-forge-connection=") != 1 {
+ t.Fatal("three abandoned starts left dead rows on the page")
+ }
+ githubConvert(t, f, g, client, body)
+ if body = githubStart(t, f, client, "another-org", "Organization"); strings.Count(body, githubAppRemains) != 1 {
+ t.Fatal("converted-then-superseded App not shown exactly once on Start")
+ }
+ githubStart(t, f, client, "third-org", "Organization")
+ if page := githubPage(t, f, client, ""); strings.Count(page, githubAppRemains) != 1 {
+ t.Fatal("converted-then-superseded App not shown exactly once on the page")
+ }
+}
+
+func TestGitHubBusyCheckNotice(t *testing.T) {
+ f, g := githubFixture(t, true)
+ client := signinClient(t, f.server.URL)
+ signinEmail(t, client, f.server.URL, testOrigin, f.mail, ownerAddress)
+ githubConvert(t, f, g, client, githubStart(t, f, client, g.Login, g.AccountType))
+ var c github.Connection
+ if err := f.db.G.First(&c).Error; err != nil {
+ t.Fatal(err)
+ }
+ for _, path := range []string{"check", "confirm"} {
+ response := clientPost(t, client, f.server.URL+"/github/connect/"+path, testOrigin, url.Values{"id": {c.ID}})
+ githubBody(t, response)
+ if path == "confirm" && response.Header.Get("Location") != "/conversation/settings/github" {
+ t.Fatal("Connect failed")
+ }
+ }
+ // A second tap while the first Check still holds its claim.
+ if err := f.db.G.Model(&github.Connection{}).Where("id = ?", c.ID).Updates(map[string]any{"claim": "held", "claim_until": time.Now().Add(time.Minute)}).Error; err != nil {
+ t.Fatal(err)
+ }
+ response := clientPost(t, client, f.server.URL+"/github/connect/check", testOrigin, url.Values{"id": {c.ID}})
+ githubBody(t, response)
+ location := response.Header.Get("Location")
+ if location != "/conversation/settings/github?failed=check" {
+ t.Fatalf("busy Check redirected to %s", location)
+ }
+ page := githubPage(t, f, client, strings.TrimPrefix(location, "/conversation/settings/github"))
+ if !strings.Contains(page, "could not check GitHub right now") || strings.Contains(page, "Start again to create a new GitHub App") || !strings.Contains(page, "GitHub is connected") {
+ t.Fatal("busy Check showed the wrong notice")
+ }
+}
+
+func TestGitHubSettingsNav(t *testing.T) {
+ for _, tc := range []struct {
+ name string
+ enabled, show bool
+ role equipo.Role
+ }{{"owner", true, true, equipo.RoleOwner}, {"member", true, false, equipo.RoleMember}, {"flag-off", false, false, equipo.RoleOwner}} {
+ t.Run(tc.name, func(t *testing.T) {
+ f, _ := githubFixture(t, tc.enabled)
+ client := signinClient(t, f.server.URL)
+ signinEmail(t, client, f.server.URL, testOrigin, f.mail, ownerAddress)
+ if err := f.db.G.Model(&equipo.Member{}).Where("address = ?", ownerAddress).Update("role", tc.role).Error; err != nil {
+ t.Fatal(err)
+ }
+ response := clientGet(t, client, f.server.URL+"/conversation/settings")
+ if response.StatusCode != 200 {
+ t.Fatalf("settings %d", response.StatusCode)
+ }
+ body := githubBody(t, response)
+ if !strings.Contains(body, `data-settings-link="thinking"`) {
+ t.Fatal("settings nav absent")
+ }
+ if got := strings.Contains(body, `data-settings-link="github"`); got != tc.show {
+ t.Fatalf("GitHub in nav: %v, want %v", got, tc.show)
+ }
+ })
+ }
+}