census: agent login by link re-proposed (pending dir reads)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
docs/superpowers/notes/census-proposal-agent-login-link.md+3 −3docs/superpowers/reviews/CODEX-FINDINGS-agent-login-link-branch.md+38 −0internal/provision/testdata/plan14-root-reads-agent-login-link.tsv+5 −5internal/provision/testdata/plan14-root-reads-chain.tsv+1 −1
Intent
<task-notification> <task-id>a860323caa5890f17</task-id> <tool-use-id>toolu_01MAPwspVnVbr3dDaW5t1WiG</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/a1de5273-c148-49b8-8267-3dee9d49c9c1/tasks/a860323caa5890f17.output</output-file> <status>completed</status> <summary>Agent "Implement Task 4: CLI link + relay" finished</summary> <note>A task-notification fires each time this agent stops with no live background children of its own. The user can send it another message and resume it, so the same task-id may notify more than once.</note> <result>Status: DONE (fix wave: P1 and P2) Commit: 349cb549 "carlos auth login: one pending file per attempt; approved ends the attempt" **Tests:** `go test . -run 'TestAuth|TestPendingLogin|TestAgentLabel' -count=1` passes (26s). gofmt, go vet and the darwin and windows builds are clean. After running gofmt on `authpending.go`, I re-ran only `TestPendingLogin`, not the full filter. **P1:** The single `login-pending` file is now a directory, `login-pending.d/` (0700), holding one 0600 file per attempt. A new `--no-wait` removes all other attempts' files. A finishing `--wait` removes only its own exact path, with no locks. New test `TestPendingLoginInterleavedCleanupKeepsNewer`: A loaded, B saved, A's cleanup runs, B's file survives and is what the next load picks. **P2:** After an approved poll, a missing token or a credential load/save failure now ends the attempt. The pending file is removed and the error says the login was approved but the token could not be saved. New test `TestAuthLoginApprovedButUnsavableEndsTheAttempt`. **Census:** `go test ./internal/provision -run TestPlan14RootReadCensus -count=1` fails as expected, with 5 discrepancies. The changed root reads are `loadPendingLogin` and `savePendingLogin`, plus the root source envelope and both legacy declarations. I did not hand-edit census files, so the overlay must be re-proposed. **Other notes:** - `loadPendingLogin` and `savePendingLogin` keep their names and roles. `pendingLoginFile(deviceCode)` is a new path helper that does no I/O. - `docs/site` does not mention the pending file. - `.superpowers` is gitignored, so the appended report is on disk but not in the commit. Report (fix wave section appended): /home/paulca/amadan.net/carlos/platform/.claude/worktrees/design-agent-login-link/.superpowers/sdd/2026-11-07-agent-login-link/task-4-report.md</result> <usage><subagent_tokens>75571</subagent_tokens><tool_uses>5</tool_uses><duration_ms>132570</duration_ms></usage> </task-notification>
diff --git a/docs/superpowers/notes/census-proposal-agent-login-link.md b/docs/superpowers/notes/census-proposal-agent-login-link.md| index 6a6492a2d..9d5287500 100644 |
| --- a/docs/superpowers/notes/census-proposal-agent-login-link.md |
| +++ b/docs/superpowers/notes/census-proposal-agent-login-link.md |
| @@ -8,9 +8,9 @@ Review: a model from the other family than the author reads the branch's diff ag |
| New dispositions, which census-propose wrote and the reviewer checks against the unit's reads and the diff: |
| -- new `authpending.go:loadPendingLogin`: reads +file:ReadFile; written legacy, accepted-legacy, frozen |
| -- new `authpending.go:savePendingLogin`: reads +file:CreateTemp; written legacy, accepted-legacy, frozen |
| +- new `authpending.go:loadPendingLogin`: reads +file:ReadDir, +file:ReadFile; written legacy, accepted-legacy, frozen |
| +- new `authpending.go:savePendingLogin`: reads +file:CreateTemp, +file:ReadDir; written legacy, accepted-legacy, frozen |
| -Seal: `7247af7f4de84593d83c6f60c0147d0a04836146197dd60c2ed2bf78919cad22` → `9944dce822df78788311010be7588442fac40854df220322c674d17623da4872`. |
| +Seal: `7247af7f4de84593d83c6f60c0147d0a04836146197dd60c2ed2bf78919cad22` → `ba92f1aaa53d17ca26f8f8032b6d1d78eaa4720b8a3c9967f7eca55efe69addf`. |
| Overlay: `internal/provision/testdata/plan14-root-reads-agent-login-link.tsv`, appended to `internal/provision/testdata/plan14-root-reads-chain.tsv`. |
diff --git a/docs/superpowers/reviews/CODEX-FINDINGS-agent-login-link-branch.md b/docs/superpowers/reviews/CODEX-FINDINGS-agent-login-link-branch.md| new file mode 100644 |
| index 000000000..a165329bf |
| --- /dev/null |
| +++ b/docs/superpowers/reviews/CODEX-FINDINGS-agent-login-link-branch.md |
| @@ -0,0 +1,38 @@ |
| +Reviewed `432135ae..d532ad9b`, branch review round 1. Two findings: one P1 and one P2. Evidence below is verified by source inspection. Targeted tests could not start because the read-only sandbox prevented Go from creating its build directory. Formatting and `git diff --check` passed. |
| + |
| +1. **P1 — An older wait can delete a newer pending login.** |
| + Evidence: [authpending.go:82](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/design-agent-login-link/authpending.go:82), together with replacement at line 58. |
| + |
| + `clearPendingLoginIf(A)` reads A, another process saves B through `os.Rename`, then A’s cleanup removes the path now holding B. B’s device code is lost, so its subsequent `--wait` cannot complete. The “two syscalls wide” comment acknowledges the window but does not protect it. The existing test replaces A before cleanup starts, so it misses this interleaving. |
| + |
| + **Fix:** Serialize replacement and compare/remove under the same cross-process lock, with Darwin and Windows support, or use an equivalent safe ownership protocol. Add a test that forces replacement between the comparison and deletion. |
| + |
| + **Invariant / fault family:** Completing an older attempt must never erase its replacement. |
| + |
| +2. **P2 — Approval followed by a credential-storage failure leaves an uncollectable pending attempt.** |
| + Evidence: [auth.go:773](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/design-agent-login-link/auth.go:773) and [auth.go:842](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/design-agent-login-link/auth.go:842). The server consumes the attempt when returning the token: [authstore.go:593](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/design-agent-login-link/internal/console/authstore.go:593). |
| + |
| + If approval succeeds but loading or saving credentials fails, `pollLogin` returns an ordinary error. Cleanup consequently retains the pending file, although the server has already consumed the attempt. Retrying cannot recover that token; it receives `unknown`. |
| + |
| + **Fix:** Track the terminal server outcome independently of credential-storage success. Clear only the matching pending attempt after an approved response, preserve the storage error, and explain that a new login is needed. Cover the storage-failure case. |
| + |
| + **Invariant / fault family:** Approved attempts end the pending-file lifecycle; only retryable attempts remain. |
| + |
| +No additional P3 findings. |
| + |
| +The census verdicts apply to the pinned commit and the card’s root-authority criteria; they do not waive the lifecycle findings. |
| + |
| +| Census item | Verdict | Evidence and reason | |
| +|---|---|---| |
| +| `authpending.go:loadPendingLogin` | **Approve** | [Line 62](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/design-agent-login-link/authpending.go:62): reads the operator’s pending file beside the existing credential store. Calls originate from explicit CLI login operations. The recorded `accepted-legacy` disposition fits this read. | |
| +| `authpending.go:savePendingLogin` | **Approve** | [Line 31](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/design-agent-login-link/authpending.go:31): uses the existing credential-store pattern—same-directory temporary file, mode 0600 before writing, close, rename. No new root-service input or execution authority. | |
| +| Module-root envelope `.` | **Approve** | Reviewed the changed functions in `auth.go` and `authpending.go`, their callers, credential persistence, console client, and [auth dispatch](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/design-agent-login-link/main.go:180). Changes remain within user-invoked authentication; no root, termination, or production-storage behavior changes. | |
| + |
| +Deferred-minors triage: |
| + |
| +- **Must fix before merge:** Task 4’s approved-then-store-failure item, covered by P2 above. |
| +- **Already addressed:** The lede explicitly calls the label self-reported. Template em dashes were removed. |
| +- **May remain deferred:** Budget-ordering and POST refusal-body test gaps; expired-GET and hostile-label test gaps; attribution layout and `noreferrer`; duplicated 429 copy; stale copy comments/key; misplaced test comment; unused receiver, deny-label lookup, and decided-page `Days`; test-only mutable wait cap; sleep overshoot. |
| +- **No change required:** The accepted shared-NAT budget trade-off, decided-page simplification, settings-link placement, and `emptyOrDash` ruling. `loginDeadline` remains used when starting an attempt. |
| + |
| +**NOT READY** |
| \ No newline at end of file |
diff --git a/internal/provision/testdata/plan14-root-reads-agent-login-link.tsv b/internal/provision/testdata/plan14-root-reads-agent-login-link.tsv| index 54006cc3f..63d8c6337 100644 |
| --- a/internal/provision/testdata/plan14-root-reads-agent-login-link.tsv |
| +++ b/internal/provision/testdata/plan14-root-reads-agent-login-link.tsv |
| @@ -1,8 +1,8 @@ |
| # Census overlay agent-login-link, written by census-propose (#369). census-ruling-agent-login-link, approved on #280 before the merge; the approval card is docs/superpowers/notes/census-proposal-agent-login-link.md. |
| # 0 body, 0 sites, 1 envelope: each changed unit re-frozen at its existing disposition with its claim appended. |
| # 2 new dispositions: 0 reads re-frozen at their disposition with the claim, 2 new units frozen accepted-legacy, 0 quiet units retired while they read nothing, 0 other. |
| -@legacy 1880f36398070fb7ed9e65e0d8ec2789589333932bab030257110abbf7d59d4e authpending.go loadPendingLogin legacy accepted-legacy accepted-legacy;rev3=census-ruling-agent-login-link;basis=new: reads the CLI pending-login file (~/.carlos/login-pending, or beside CARLOS_CREDENTIALS) for carlos auth login --wait; user-run CLI path, same directory and pattern as loadCredentials file:ReadFile@62 0bdf459aa64daa912a3b5868274c2895fffaf30053fc74ebc26c64804bcaa237 |
| -@legacy 7613f3ee2e0aacd22a8db9b5ac7ed72b6027433626907ea4795541d357be69d9 authpending.go savePendingLogin legacy accepted-legacy accepted-legacy;rev3=census-ruling-agent-login-link;basis=new: writes the CLI pending-login file atomically (CreateTemp + chmod 0600 + rename) beside the credentials file for carlos auth login --no-wait; same pattern as credentialFile.save file:CreateTemp@285 09c49b8f245e5d3df407bcf0cadcdef55a795d380260478ce1ece79f79da1dbc |
| -authpending.go loadPendingLogin legacy accepted-legacy accepted-legacy;rev3=census-ruling-agent-login-link;basis=new: reads the CLI pending-login file (~/.carlos/login-pending, or beside CARLOS_CREDENTIALS) for carlos auth login --wait; user-run CLI path, same directory and pattern as loadCredentials file:ReadFile@62 0bdf459aa64daa912a3b5868274c2895fffaf30053fc74ebc26c64804bcaa237 |
| -authpending.go savePendingLogin legacy accepted-legacy accepted-legacy;rev3=census-ruling-agent-login-link;basis=new: writes the CLI pending-login file atomically (CreateTemp + chmod 0600 + rename) beside the credentials file for carlos auth login --no-wait; same pattern as credentialFile.save file:CreateTemp@285 09c49b8f245e5d3df407bcf0cadcdef55a795d380260478ce1ece79f79da1dbc |
| -@coverage . 4d727f747625c03880109ce4414644027b470c903fdee5342bbd75cf02c07c6d |
| +@legacy 197524f5f785b60fe96d18c962ce391e52bc4c077a09fe23bb1f3b5d76467d1b authpending.go loadPendingLogin legacy accepted-legacy accepted-legacy;rev3=census-ruling-agent-login-link;basis=new: reads the newest unexpired attempt file under login-pending.d/ beside the CLI credentials file for carlos auth login --wait; user-run CLI path, same directory and pattern as loadCredentials file:ReadDir@66,file:ReadFile@321 bae631810e22226c009bcf699e730e02eca94ca0da4035b57e4b0b06d116cc97 |
| +@legacy 29cdb9d9ebb9840795d01b8cfac1b2a98287f06728c3ee324b3339785f2ec92d authpending.go savePendingLogin legacy accepted-legacy accepted-legacy;rev3=census-ruling-agent-login-link;basis=new: writes one attempt file under login-pending.d/ atomically (CreateTemp + chmod 0600 + rename) beside the credentials file for carlos auth login --no-wait and removes other attempts; same pattern as credentialFile.save file:CreateTemp@257,file:ReadDir@675 b9a0d113e296a6e013427a8b312eaf8a19db33885b386cd91bfd9a4cfa5064f4 |
| +authpending.go loadPendingLogin legacy accepted-legacy accepted-legacy;rev3=census-ruling-agent-login-link;basis=new: reads the newest unexpired attempt file under login-pending.d/ beside the CLI credentials file for carlos auth login --wait; user-run CLI path, same directory and pattern as loadCredentials file:ReadDir@66,file:ReadFile@321 bae631810e22226c009bcf699e730e02eca94ca0da4035b57e4b0b06d116cc97 |
| +authpending.go savePendingLogin legacy accepted-legacy accepted-legacy;rev3=census-ruling-agent-login-link;basis=new: writes one attempt file under login-pending.d/ atomically (CreateTemp + chmod 0600 + rename) beside the credentials file for carlos auth login --no-wait and removes other attempts; same pattern as credentialFile.save file:CreateTemp@257,file:ReadDir@675 b9a0d113e296a6e013427a8b312eaf8a19db33885b386cd91bfd9a4cfa5064f4 |
| +@coverage . ccf5af22c7f7144d115a5e44e3c2a7952bc276f64d92c276c7aa82561b829261 |
diff --git a/internal/provision/testdata/plan14-root-reads-chain.tsv b/internal/provision/testdata/plan14-root-reads-chain.tsv| index e26c2bc57..ef1c705ab 100644 |
| --- a/internal/provision/testdata/plan14-root-reads-chain.tsv |
| +++ b/internal/provision/testdata/plan14-root-reads-chain.tsv |
| @@ -118,4 +118,4 @@ plan14-root-reads-claim-ux-edge.tsv 889ce9f72f93b581b29527e5c5d4410b47732424ce8c |
| plan14-root-reads-region-ha-g3-fixes.tsv cd001bf3a9a8871f12d1ca9cfa0a925760c1fc345dc911246ffaabc235dfabf6 |
| plan14-root-reads-claim-countdown.tsv 5b31785441c6a48ddae93e9f3c0f8962f7983b55d89b3acb90d9a6b505647b36 |
| plan14-root-reads-region-ha-dr2.tsv 7247af7f4de84593d83c6f60c0147d0a04836146197dd60c2ed2bf78919cad22 |
| -plan14-root-reads-agent-login-link.tsv 9944dce822df78788311010be7588442fac40854df220322c674d17623da4872 |
| +plan14-root-reads-agent-login-link.tsv ba92f1aaa53d17ca26f8f8032b6d1d78eaa4720b8a3c9967f7eca55efe69addf |