Repository navigation
feat(auth): implement human authentication and session lifecycle (#163) - #177
Conversation
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (5)
🚧 Files skipped from review as they are similar to previous changes (4)
📝 WalkthroughWalkthroughThe CLI adds interactive authentication login, remote token exchange and refresh, atomic credential persistence, terminal secret input, expanded authentication error mappings, and updated contract schemas and tests. ChangesAuthentication lifecycle
Estimated code review effort: 4 (Complex) | ~60 minutes Sequence Diagram(s)sequenceDiagram
participant CLI
participant OSTerminal
participant AuthLogin
participant AuthClient
participant CredentialStore
CLI->>OSTerminal: read authentication secret
CLI->>AuthLogin: execute login
AuthLogin->>AuthClient: exchange authentication data
AuthClient-->>AuthLogin: return tokens
AuthLogin->>CredentialStore: atomically save credentials
CredentialStore-->>CLI: return authentication state
Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
…178) * docs(contract): formalize Firebase transport configuration Propose remote contract revision 2026-08-11.3 adding two transport configuration facts absent from 2026-08-11.2 that the Go implementation (PR #177) requires for signInWithCustomToken, refreshToken, and lookupFirebaseUser: 1. Firebase web API key value: the firebaseApiKey security scheme now carries x-publicValue with the observed public key. This is embedded in every Partiful web client and documented in the March 24, 2026 browser interception. It is not a credential. 2. Referer header requirement: each Firebase operation now has a required Referer: https://partiful.com/ header parameter. Documented in the August 11, 2026 auth observation. Requests without it receive 403 API_KEY_HTTP_REFERRER_BLOCKED. Origin is NOT modelled. Agent probes succeeded without Origin, receiving valid 400 error responses. Origin is browser CORS behavior, not a Firebase transport requirement. Material claims: 992 -> 1008 Contract revision: 2026-08-11.3 (proposed, pending owner approval) Pacific full suite: 338 passed, 6 skipped, 0 failed Linked to #163 Co-authored-by: Copilot <[email protected]> * docs(contract): clarify observed Referer boundary Describe the observed accepted Referer separately from the unknown complete allowlist so revision 2026-08-11.3 does not overstate remote behavior. Co-authored-by: Copilot <[email protected]> * fix(contract): sanitize Firebase evidence provenance (#163) Co-authored-by: Copilot <[email protected]> Copilot-Session: 8453c76f-a887-4fce-be42-d7997ed94292 * fix(contract): isolate public auth provenance Move the public Firebase configuration claim to a dedicated privacy-safe evidence extract, reject unsafe provenance, and keep Origin unmodelled and unknown. Co-authored-by: Copilot <[email protected]> * test(contract): guard sanitized auth evidence Require redacted identity fields, retain public transport structure, and reject private-value patterns in the tracked historical auth note. Co-authored-by: Copilot <[email protected]> * docs(contract): normalize Firebase evidence formatting (#163) Co-authored-by: Copilot <[email protected]> Copilot-Session: 8453c76f-a887-4fce-be42-d7997ed94292 * fix(contract): correct auth request provenance Keep all authentication request schemas TypeScript-derived while preserving dated observation classifications for responses and the separately observed Firebase transport facts. Co-authored-by: Copilot <[email protected]> * docs(contract): approve Firebase transport revision (#163) Co-authored-by: Copilot <[email protected]> Copilot-Session: 8453c76f-a887-4fce-be42-d7997ed94292 --------- Co-authored-by: Ubuntu <azureuser@vm-copilot-agent.orgktuxli0vefjkhtvkzmrvmvh.xx.internal.cloudapp.net> Co-authored-by: Copilot <[email protected]> Copilot-Session: 8453c76f-a887-4fce-be42-d7997ed94292
Implement the reviewed callable and Firebase exchange flow, atomic credential persistence, redacted failure mappings, and auth.login schema registration. Co-authored-by: Copilot <[email protected]>
Refresh expiring credentials once through the reviewed token mapping, persist rotations atomically, fail closed on drift, and add definition-driven protected-session guards without prompting. Co-authored-by: Copilot <[email protected]>
Reject refresh and sign-in lifetimes that cannot be represented safely, and keep protected-session credential corruption on the redacted local failure path. Co-authored-by: Copilot <[email protected]>
1. Update RemoteContractRevision from 2026-08-11.2 to 2026-08-11.3 and all test expectations to match. 2. Remove Origin header from Firebase auth requests (signInWithCustomToken, refreshToken). Origin is not modelled in the approved contract — agent probes confirmed Firebase accepts requests without it. Keep Referer exactly as contracted. 3. Add end-to-end test assertions verifying Firebase requests send the contracted Referer header and do NOT send Origin. Callable requests retain Origin per browser-interception evidence. 4. Public Firebase web key stays confined to internal/remote/auth.go only; no key/credential/private values enter output or diagnostics. Pacific full suite: 341 passed, 6 skipped, 0 failed Cross-platform builds: linux/amd64, darwin/arm64, windows/amd64 Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]> Copilot-Session: 7b842425-e150-41a6-9cd2-6b0842fe8c01
Co-authored-by: Copilot <[email protected]> Copilot-Session: 7b842425-e150-41a6-9cd2-6b0842fe8c01
Co-authored-by: Copilot <[email protected]> Copilot-Session: 7b842425-e150-41a6-9cd2-6b0842fe8c01
Co-authored-by: Copilot <[email protected]> Copilot-Session: 7b842425-e150-41a6-9cd2-6b0842fe8c01
Co-authored-by: Copilot <[email protected]> Copilot-Session: 7b842425-e150-41a6-9cd2-6b0842fe8c01
Co-authored-by: Copilot <[email protected]> Copilot-Session: 7b842425-e150-41a6-9cd2-6b0842fe8c01
4fd079a to
112fc57
Compare
There was a problem hiding this comment.
Actionable comments posted: 7
🧹 Nitpick comments (7)
internal/auth/auth.go (1)
206-216: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueRemove the redundant
credentialRecordcopy.Lines 207-211 build the refreshed record and assign it to
credentials. Lines 212-216 then build a second, field-for-field identical record and pass that tosaveCredentialsUnlocked. Passcredentialsdirectly.♻️ Proposed refactor
expiresAt := now.Add(refreshed.ExpiresIn).UTC() credentials = credentialRecord{ AccessToken: refreshed.IDToken, RefreshToken: refreshed.RefreshToken, ExpiresAt: expiresAt, } - operationErr = saveCredentialsUnlocked(files, path, credentialRecord{ - AccessToken: credentials.AccessToken, - RefreshToken: credentials.RefreshToken, - ExpiresAt: credentials.ExpiresAt, - }) + operationErr = saveCredentialsUnlocked(files, path, credentials) if operationErr != nil {🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@internal/auth/auth.go` around lines 206 - 216, Remove the redundant credentialRecord reconstruction in the refresh flow: after assigning the refreshed values to credentials, pass credentials directly to saveCredentialsUnlocked. Preserve the existing save behavior and error handling.internal/auth/os_unix.go (1)
32-34: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winRemove the dead conditional in
syncDirectory.
syncDirectoryreturns no value. Thereturnat line 33 is the last statement of the function, so the condition and its body have no effect. Theerrors.Is(err, fs.ErrInvalid)test also has no effect.The code reads as if it distinguishes a tolerated
fs.ErrInvalidfrom a real failure. It does not. Collapse it to an explicit discard so the intent matches the behavior.♻️ Proposed refactor
func syncDirectory(directory string) { handle, err := os.Open(directory) if err != nil { return } defer handle.Close() - if err := handle.Sync(); err != nil && !errors.Is(err, fs.ErrInvalid) { - return - } + // Some filesystems reject fsync on a directory. A durability best effort is sufficient here. + _ = handle.Sync() }This removes the only uses of
errorsandio/fs, so drop both imports.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@internal/auth/os_unix.go` around lines 32 - 34, In syncDirectory, replace the final conditional Sync error check with an explicit discard of handle.Sync’s result, since the function returns immediately either way. Remove the now-unused errors and io/fs imports.internal/auth/persist.go (1)
18-24: 🔒 Security & Privacy | 🔵 Trivial | 💤 Low valueConsider mapping the
WriteFileAtomicerror toErrPersistencehere.Line 23 returns the raw filesystem error. That error can contain the credential file path. Both current callers replace it with
ErrPersistence(internal/auth/auth.golines 121-123 and lines 217-219), so no filesystem detail reaches the output today.The product contract requires that filesystem errors stay out of the output. Mapping the error at the source makes that guarantee hold for any future caller.
♻️ Proposed hardening
func saveCredentialsUnlocked(files FileSystem, path string, credentials credentialRecord) error { document, err := json.Marshal(credentials) if err != nil { return ErrUnavailable } - return files.WriteFileAtomic(path, document) + if err := files.WriteFileAtomic(path, document); err != nil { + return ErrPersistence + } + return nil }
internal/auth/auth.goline 218 then reassignsErrPersistenceto itself, which stays correct.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@internal/auth/persist.go` around lines 18 - 24, Update saveCredentialsUnlocked so errors returned by files.WriteFileAtomic are mapped to ErrPersistence instead of being returned directly, while preserving the existing ErrUnavailable mapping for json.Marshal failures.internal/remote/auth.go (2)
104-118: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueRename the local variable
urlto avoid shadowing thenet/urlpackage.Line 112 declares a local variable named
url. The file importsnet/urland usesurl.ValuesinRefreshToken. The code compiles today becauseSignInWithCustomTokendoes not use the package. A later edit that needsurl.Valuesin this function will fail to compile.callablePostuses the same parameter name at line 239.♻️ Proposed rename
- url := firebaseIdentityHost + "/v1/accounts:signInWithCustomToken?key=" + firebaseProjectKey - request, err := http.NewRequestWithContext(ctx, http.MethodPost, url, bytes.NewReader(payload)) + endpoint := firebaseIdentityHost + "/v1/accounts:signInWithCustomToken?key=" + firebaseProjectKey + request, err := http.NewRequestWithContext(ctx, http.MethodPost, endpoint, bytes.NewReader(payload))🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@internal/remote/auth.go` around lines 104 - 118, Rename the local `url` variable in `AuthClient.SignInWithCustomToken` to a non-conflicting name and update the `http.NewRequestWithContext` call to use it. Also rename the corresponding `url` parameter in `callablePost` to avoid shadowing the imported `net/url` package there.
227-237: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueSimplify
parseExpiresInand keep the overflow guard explicit.The function parses an integer, formats it back to a string, and then calls
time.ParseDuration. The round trip exists only becausetime.ParseDurationrejects values that overflowtime.Duration. An explicit bound expresses that intent directly and removes the string round trip.
time.Durationis anint64nanosecond count, so the maximum representable value is about 292 years.♻️ Proposed refactor
func parseExpiresIn(value string) (time.Duration, error) { seconds, err := strconv.ParseInt(value, 10, 64) if err != nil || seconds <= 0 { return 0, auth.ErrRemoteProtocolChanged } - duration, err := time.ParseDuration(strconv.FormatInt(seconds, 10) + "s") - if err != nil { + if seconds > int64(math.MaxInt64/time.Second) { return 0, auth.ErrRemoteProtocolChanged } - return duration, nil + return time.Duration(seconds) * time.Second, nil }Add
"math"to the import block.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@internal/remote/auth.go` around lines 227 - 237, Update parseExpiresIn to remove the strconv.FormatInt/time.ParseDuration round trip and explicitly reject seconds above the maximum representable time.Duration in seconds, using math.MaxInt64 and the existing nonpositive validation. Return the same auth.ErrRemoteProtocolChanged error for invalid or overflowing values, and construct the duration directly from seconds.internal/app/execute_test.go (2)
1488-1515: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueExtract the repeated login dependency scaffold into a helper.
Nine login tests repeat the same
app.Dependenciesliteral:memoryFilesystem, the fixed credentials path, a scripted terminal,AuthRandom, and the same fixedNow. Only theHTTPscript differs. A helper reduces the duplication and keeps the fixed clock consistent when it changes.♻️ Proposed helper
func loginDependencies(http remote.HTTPClient, values ...string) app.Dependencies { return app.Dependencies{ Files: &memoryFilesystem{files: map[string][]byte{}}, CredentialsPath: "/config/partiful/credentials.json", Terminal: &scriptedPrivateTerminal{values: values}, AuthRandom: strings.NewReader("0123456789abcdef"), Now: func() time.Time { return time.Date(2026, time.August, 11, 0, 0, 0, 0, time.UTC) }, HTTP: http, } }Tests that inspect the terminal or the filesystem can still build the struct and override the field.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@internal/app/execute_test.go` around lines 1488 - 1515, Extract the repeated login dependency setup into a loginDependencies helper accepting the HTTP client and terminal values, including the shared filesystem, credentials path, AuthRandom, and fixed Now configuration. Update the nine login tests to use this helper while preserving their individual HTTP scripts; tests that inspect or customize terminal/filesystem dependencies may construct and override those fields as needed.
1517-1544: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winSet
Content-Type: application/jsonon the oversized response.The current test fails at media-type validation before
readBoundedAuthBodyreads the body. Add the header so the body length proves the size limit.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@internal/app/execute_test.go` around lines 1517 - 1544, Update the HTTP response returned by the scriptedHTTP callback in TestExecuteAuthLoginRejectsOversizedSendAcknowledgement to include Content-Type: application/json, ensuring media-type validation passes and the oversized body reaches readBoundedAuthBody.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@docs/CLI-PRODUCT-CONTRACT.md`:
- Around line 285-293: Update the auth status behavior description around token
refresh to explicitly state that already expired stored credentials with a
refresh token are also refreshed. Preserve the existing outcomes for credentials
without a refresh token and the documented refresh/error behavior.
In `@internal/app/app.go`:
- Around line 890-904: Update the contract schema example around the documented
failureTypes field to reflect that every command includes the default
usage.invalid and input.invalid failures, or explicitly mark the empty array as
illustrative. Keep the example consistent with declaredFailureTypes and the
existing schema-test expectations.
In `@internal/app/execute_test.go`:
- Around line 1624-1658: Update
TestExecuteAuthLoginAllowsUndeclaredFirebaseErrorField to use a string status
value or omit the status field so validFirebaseTokenError accepts the fixture
and the test produces INVALID_CUSTOM_TOKEN. Rename the test to describe the
actual optional Firebase error field and intended behavior.
In `@internal/auth/auth.go`:
- Line 82: Update Login and refreshCredentials to use an injected clock function
rather than the fixed login-start time: read the current time immediately after
the sign-in response and use it for sessionID and expiresAt calculations.
Preserve deterministic tests by using the existing Now injection with a constant
implementation.
In `@internal/auth/os_terminal.go`:
- Around line 25-29: Update the command-level flow around both ReadSecret calls
to install SIGINT/SIGTERM handling that restores terminal echo before preserving
the signals’ normal process termination behavior. Ensure cleanup covers
interruptions during either term.ReadPassword invocation and does not alter
successful credential input handling.
In `@internal/auth/os_windows.go`:
- Around line 28-42: Update the credential storage flow using
DefaultCredentialsPath to enforce a user-only Windows DACL when creating the
parent directory and temporary credentials file, rather than relying on MkdirAll
or Chmod permissions. Ensure files remain inaccessible to other users even when
AppData is shared; alternatively, reject shared AppData locations before writing
credentials. Use the existing credential creation helpers and replaceFile flow
without changing unrelated file replacement behavior.
In `@internal/remote/auth.go`:
- Line 52: Make all six deferred Close calls explicitly discard their errors to
satisfy errcheck: update SendAuthCode, GetLoginToken, SignInWithCustomToken, and
RefreshToken in internal/remote/auth.go; WithLock in internal/auth/os_files.go,
preserving release() before closing; and syncDirectory in
internal/auth/os_unix.go. Wrap each Close in a deferred function assigning the
result to _, without changing other behavior.
---
Nitpick comments:
In `@internal/app/execute_test.go`:
- Around line 1488-1515: Extract the repeated login dependency setup into a
loginDependencies helper accepting the HTTP client and terminal values,
including the shared filesystem, credentials path, AuthRandom, and fixed Now
configuration. Update the nine login tests to use this helper while preserving
their individual HTTP scripts; tests that inspect or customize
terminal/filesystem dependencies may construct and override those fields as
needed.
- Around line 1517-1544: Update the HTTP response returned by the scriptedHTTP
callback in TestExecuteAuthLoginRejectsOversizedSendAcknowledgement to include
Content-Type: application/json, ensuring media-type validation passes and the
oversized body reaches readBoundedAuthBody.
In `@internal/auth/auth.go`:
- Around line 206-216: Remove the redundant credentialRecord reconstruction in
the refresh flow: after assigning the refreshed values to credentials, pass
credentials directly to saveCredentialsUnlocked. Preserve the existing save
behavior and error handling.
In `@internal/auth/os_unix.go`:
- Around line 32-34: In syncDirectory, replace the final conditional Sync error
check with an explicit discard of handle.Sync’s result, since the function
returns immediately either way. Remove the now-unused errors and io/fs imports.
In `@internal/auth/persist.go`:
- Around line 18-24: Update saveCredentialsUnlocked so errors returned by
files.WriteFileAtomic are mapped to ErrPersistence instead of being returned
directly, while preserving the existing ErrUnavailable mapping for json.Marshal
failures.
In `@internal/remote/auth.go`:
- Around line 104-118: Rename the local `url` variable in
`AuthClient.SignInWithCustomToken` to a non-conflicting name and update the
`http.NewRequestWithContext` call to use it. Also rename the corresponding `url`
parameter in `callablePost` to avoid shadowing the imported `net/url` package
there.
- Around line 227-237: Update parseExpiresIn to remove the
strconv.FormatInt/time.ParseDuration round trip and explicitly reject seconds
above the maximum representable time.Duration in seconds, using math.MaxInt64
and the existing nonpositive validation. Return the same
auth.ErrRemoteProtocolChanged error for invalid or overflowing values, and
construct the duration directly from seconds.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: c3a98ce4-9b25-489b-bf36-77e18675187f
⛔ Files ignored due to path filters (1)
go.sumis excluded by!**/*.sum
📒 Files selected for processing (13)
cmd/partiful/main.godocs/CLI-PRODUCT-CONTRACT.mdgo.modinternal/app/app.gointernal/app/execute_test.gointernal/auth/auth.gointernal/auth/os_files.gointernal/auth/os_terminal.gointernal/auth/os_unix.gointernal/auth/os_windows.gointernal/auth/persist.gointernal/auth/port.gointernal/remote/auth.go
| func TestExecuteAuthLoginAllowsUndeclaredFirebaseErrorField(t *testing.T) { | ||
| call := 0 | ||
| result := app.Execute(context.Background(), app.Request{ | ||
| Argv: []string{"auth", "login"}, | ||
| }, app.Dependencies{ | ||
| Files: &memoryFilesystem{files: map[string][]byte{}}, | ||
| CredentialsPath: "/config/partiful/credentials.json", | ||
| Terminal: &scriptedPrivateTerminal{values: []string{"+15555550123", "123456"}}, | ||
| AuthRandom: strings.NewReader("0123456789abcdef"), | ||
| Now: func() time.Time { | ||
| return time.Date(2026, time.August, 11, 0, 0, 0, 0, time.UTC) | ||
| }, | ||
| HTTP: scriptedHTTP{do: func(*http.Request) (*http.Response, error) { | ||
| call++ | ||
| switch call { | ||
| case 1: | ||
| return jsonResponse(http.StatusOK, `{}`), nil | ||
| case 2: | ||
| return jsonResponse( | ||
| http.StatusOK, | ||
| `{"result":{"data":{"token":"custom-private-token"}}}`, | ||
| ), nil | ||
| default: | ||
| return jsonResponse( | ||
| http.StatusBadRequest, | ||
| `{"error":{"code":400,"message":"invalid token","status":123}}`, | ||
| ), nil | ||
| } | ||
| }}, | ||
| }) | ||
| if result.ExitCode != 3 || | ||
| !strings.Contains(result.Stdout, `"code":"INVALID_CUSTOM_TOKEN"`) { | ||
| t.Fatalf("result = %#v, want undeclared Firebase error field to remain allowed", result) | ||
| } | ||
| } |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Description: Inspect Firebase token-error validation and the declared optional fields.
set -euo pipefail
rg -n -C15 'func validFirebaseTokenError|func validCallableAuthError|func validOptionalString' internal/remoteRepository: KalebCole/partiful-cli
Length of output: 5056
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf '%s\n' '--- validator and callers ---'
sed -n '288,386p' internal/remote/auth.go
rg -n -C12 'validFirebaseTokenError|TestExecuteAuthLoginAllowsUndeclaredFirebaseErrorField|TestExecuteAuthStatusMapsReviewedInvalidRefreshTokenToExpired|INVALID_CUSTOM_TOKEN' internal
printf '%s\n' '--- exact test region ---'
sed -n '1600,1680p' internal/app/execute_test.go
sed -n '2200,2260p' internal/app/execute_test.goRepository: KalebCole/partiful-cli
Length of output: 20169
🏁 Script executed:
#!/bin/bash
set -euo pipefail
if ! command -v go >/dev/null 2>&1; then
echo "go unavailable"
exit 0
fi
cat >/tmp/check_firebase_status.go <<'EOF'
package main
import (
"bytes"
"encoding/json"
"fmt"
)
func validOptionalString(raw json.RawMessage) bool {
if len(raw) == 0 {
return true
}
if bytes.Equal(bytes.TrimSpace(raw), []byte("null")) {
return false
}
var value string
return json.Unmarshal(raw, &value) == nil
}
func validFirebaseTokenError(data []byte) bool {
var failure struct {
Error *struct {
Code *float64 `json:"code"`
Message *string `json:"message"`
Status json.RawMessage `json:"status"`
} `json:"error"`
}
return json.Unmarshal(data, &failure) == nil &&
failure.Error != nil &&
failure.Error.Code != nil &&
failure.Error.Message != nil &&
validOptionalString(failure.Error.Status)
}
func main() {
for _, body := range []string{
`{"error":{"code":400,"message":"invalid token","status":123}}`,
`{"error":{"code":400,"message":"invalid token","status":"INVALID_ARGUMENT"}}`,
`{"error":{"code":400,"message":"invalid token"}}`,
} {
fmt.Printf("%s => %t\n", body, validFirebaseTokenError([]byte(body)))
}
}
EOF
go run /tmp/check_firebase_status.go
rm -f /tmp/check_firebase_status.goRepository: KalebCole/partiful-cli
Length of output: 373
Use a string or omit status in this test.
validFirebaseTokenError rejects numeric status values. The current fixture produces AUTH_PROTOCOL_CHANGED, not INVALID_CUSTOM_TOKEN. Rename the test to describe the actual optional field and intent.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@internal/app/execute_test.go` around lines 1624 - 1658, Update
TestExecuteAuthLoginAllowsUndeclaredFirebaseErrorField to use a string status
value or omit the status field so validFirebaseTokenError accepts the fixture
and the test produces INVALID_CUSTOM_TOKEN. Rename the test to describe the
actual optional Firebase error field and intended behavior.
Co-authored-by: Copilot <[email protected]> Copilot-Session: 7b842425-e150-41a6-9cd2-6b0842fe8c01
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@internal/auth/os_terminal.go`:
- Around line 35-37: Update the error handling around readRawSecret to preserve
and return ErrInputInvalid unchanged when the 4 KiB input limit is reached,
while continuing to map other read failures to ErrUnavailable so auth.Login
exposes the documented validation error.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 109563d3-8b8d-427d-98d0-53f28a6146d2
📒 Files selected for processing (12)
docs/CLI-PRODUCT-CONTRACT.mdinternal/app/app.gointernal/app/execute_test.gointernal/auth/auth.gointernal/auth/os_files.gointernal/auth/os_terminal.gointernal/auth/os_terminal_signals_unix.gointernal/auth/os_terminal_signals_windows.gointernal/auth/os_unix.gointernal/auth/os_windows.gointernal/auth/persist.gointernal/remote/auth.go
🚧 Files skipped from review as they are similar to previous changes (4)
- internal/auth/persist.go
- internal/remote/auth.go
- internal/app/app.go
- internal/auth/os_files.go
Co-authored-by: Copilot <[email protected]> Copilot-Session: 7b842425-e150-41a6-9cd2-6b0842fe8c01
Co-authored-by: Copilot <[email protected]> Copilot-Session: 7b842425-e150-41a6-9cd2-6b0842fe8c01
Co-authored-by: Copilot <[email protected]> Copilot-Session: 7b842425-e150-41a6-9cd2-6b0842fe8c01
Summary
Implements the complete S2 authentication lifecycle and closes #163 against owner-reviewed Remote API contract revision
2026-08-11.4.auth login, redacted status, and serialized logout.internal/authowns the port and lifecycle vocabulary;internal/remoteis the checked wire adapter.Slice boundary
The first protected-command
auth.requiredtracer and session acquisition materialize in #164 with the first evidence-complete protected event command. The stable private account fingerprint materializes in #166 with its first mutation-plan consumer.Safety and validation
No live authentication, SMS, credential entry, browser login, live probe, or Partiful mutation was used. Phone numbers, codes, tokens, identity values, remote bodies, and filesystem details never enter stdout/stderr.
Go race/vet/build/module checks, Linux/macOS/Windows target builds, 20 contract tests plus drift tests, 341 non-live JavaScript tests, typecheck, formatting/diff/privacy guards, and independent Standards/Spec review all pass.
Closes #163
Summary by CodeRabbit
New Features
auth.logincommand for interactive authentication.Bug Fixes
Documentation