| 1 | # Project card hardening |
| 2 | |
| 3 | Branch: projects/card-tests, based on origin/main f6189100. The landed |
| 4 | projects/card-names worktree was clean and has been removed. |
| 5 | |
| 6 | ## Plan |
| 7 | |
| 8 | 1. Choose both existing repositories in the placement identity regression. |
| 9 | Mutate the identity condition so every option matches the first repository; |
| 10 | the second-choice test must fail, then pass after restoration. |
| 11 | 2. Send exactly "Don't use choice03" through the device API with a visible typed |
| 12 | card and a real trusted name choice03. Mutate anchored matching to substring |
| 13 | matching; the card must incorrectly close and the regression must fail. |
| 14 | 3. Send a matching project name with a runner below ProtocolPlacement. Observe |
| 15 | the current 409, then preflight the capability and pass through as an ordinary |
| 16 | message. Remove the preflight deliberately and observe the same failure. |
| 17 | 4. Run the pinned gates, suites and fixture checks. Commit, scan references, |
| 18 | push only this branch through the helper, and wait for Linux CI. |
| 19 | |
| 20 | No runtime copy, wire shape, migrations, main push or deployment changes. |
| 21 | |
| 22 | ## Findings and evidence |
| 23 | |
| 24 | 1. Identity mapping: the regression now chooses both old and new, checking the |
| 25 | learned name against the selected project's ID. Disabling the identity |
| 26 | condition chooses p_old for the second option and fails. |
| 27 | 2. Phrase anchoring: the device API regression sends exactly "Don't use choice03" |
| 28 | with choice03 registered as a trusted team name. Matching use anywhere |
| 29 | incorrectly answers the card, so the state assertion fails. |
| 30 | 3. Old runner: the new device case first reproduced HTTP 409 idempotency_conflict |
| 31 | at ProtocolPlacement - 1. Composer interception now checks placement support |
| 32 | before answering; an old runner uses ordinary send behavior instead. The card |
| 33 | stays open, words and retry identity are preserved, and the message dispatches. |
| 34 | |
| 35 | Test-first command: `GOTOOLCHAIN=go1.26.11 CGO_ENABLED=0 go test ./internal/equipo/chat ./internal/thintest -run 'TestCardNamesPlacementIdentity|TestCardNamesComposerDevice' -count=1`. |
| 36 | Before the fix, the old-runner case failed with 409. After the fix both packages |
| 37 | passed (0.490s and 2.698s). Each mutation below ran alone and was restored in a |
| 38 | finally block. All three failed on the intended assertion. |
| 39 | |
| 40 | ### every option matches first repository |
| 41 | |
| 42 | File: `internal/equipo/chat/project_resolution.go`. |
| 43 | |
| 44 | Changed `if choice != ProjectName(repo) && repo != p.ChosenRepo {` to `if false && choice != ProjectName(repo) && repo != p.ChosenRepo {`. |
| 45 | |
| 46 | `GOTOOLCHAIN=go1.26.11 CGO_ENABLED=0 go test ./internal/equipo/chat -run TestCardNamesPlacementIdentity/suggestion=portal/new -count=1` |
| 47 | |
| 48 | ```text |
| 49 | --- FAIL: TestCardNamesPlacementIdentity (0.06s) |
| 50 | --- FAIL: TestCardNamesPlacementIdentity/suggestion=portal/new (0.06s) |
| 51 | project_card_names_test.go:262: name learned for the wrong repository [{p_old owner@example.com portal 2026-11-12 12:00:00 +0000 UTC}] want new |
| 52 | FAIL |
| 53 | rastrillo-budget/v1 ran 58ms |
| 54 | FAIL amadan.net/oficina/equipo/internal/equipo/chat 0.438s |
| 55 | FAIL |
| 56 | ``` |
| 57 | |
| 58 | ### unanchored use phrase |
| 59 | |
| 60 | File: `internal/equipo/chat/project_composer.go`. |
| 61 | |
| 62 | Changed `if name, ok := strings.CutPrefix(phrase, prefix); ok {` to `if _, name, ok := strings.Cut(phrase, prefix); ok {`. |
| 63 | |
| 64 | `GOTOOLCHAIN=go1.26.11 CGO_ENABLED=0 go test ./internal/thintest -run TestCardNamesComposerDevice/negated -count=1` |
| 65 | |
| 66 | ```text |
| 67 | --- FAIL: TestCardNamesComposerDevice (0.61s) |
| 68 | --- FAIL: TestCardNamesComposerDevice/negated (0.61s) |
| 69 | project_card_names_test.go:91: card state answered want open |
| 70 | FAIL |
| 71 | rastrillo-budget/v1 ran 615ms |
| 72 | FAIL amadan.net/oficina/equipo/internal/thintest 1.156s |
| 73 | FAIL |
| 74 | ``` |
| 75 | |
| 76 | ### missing old-runner pass-through |
| 77 | |
| 78 | File: `internal/equipo/chat/project_composer.go`. |
| 79 | |
| 80 | Changed `if err := t.placementRunner(person); errors.Is(err, ErrConflict) {` to `if err := t.placementRunner(person); false && errors.Is(err, ErrConflict) {`. |
| 81 | |
| 82 | `GOTOOLCHAIN=go1.26.11 CGO_ENABLED=0 go test ./internal/thintest -run TestCardNamesComposerDevice/old-runner -count=1` |
| 83 | |
| 84 | ```text |
| 85 | --- FAIL: TestCardNamesComposerDevice (0.61s) |
| 86 | --- FAIL: TestCardNamesComposerDevice/old-runner (0.61s) |
| 87 | project_card_names_test.go:71: composer refused by open card HTTP 409: {"code":"idempotency_conflict","copy_key":"api.idempotency_conflict","request_id":"SIMM24KXQIDDT5NUJ2WDGNKH4O"} |
| 88 | FAIL |
| 89 | rastrillo-budget/v1 ran 611ms |
| 90 | FAIL amadan.net/oficina/equipo/internal/thintest 1.135s |
| 91 | FAIL |
| 92 | ``` |
| 93 | |
| 94 | ## Final local verification |
| 95 | |
| 96 | All commands used GOTOOLCHAIN=go1.26.11, CGO_ENABLED=0 and pinned gofmt on PATH. |
| 97 | fmt-check, gitleaks, budget, migration-check, copy-release-check, lanes-check and |
| 98 | spacing passed. Full suites passed: equipo 18.121s, chat 3.634s, thintest 154.219s, |
| 99 | wire 0.224s, wireschema 0.618s and testci 12.915s. PersonAPI/Plan3Release passed |
| 100 | in 11.433s; all seven native fixtures match the schema. |
| 101 | |
| 102 | Measured budgets: chat 33340 source / 8282 test lines, thintest 33989 test lines. |
| 103 | The increases are five source, two chat-test and twelve device-test lines. |
| 104 | Explanations remain below 200 bytes; TestBudgetRecordsAreShort passed. |
| 105 | |
| 106 | Fresh origin/main is f6189100454e8e914f9e87ac9c9c31d6f0e08bd0, the branch base. |
| 107 | No integration merge is needed. Postcommit reference scan and Linux CI verdict |
| 108 | will be reported with the pushed SHA. No copy changes or outstanding decisions. |
| 109 | |