Repository navigation
feat(go): establish local runtime - #173
Conversation
Implement the S0 Go executable seam, typed command catalog, JSON envelopes, local authentication status and atomic logout, and redacted diagnostics. Co-authored-by: Copilot <[email protected]> Copilot-Session: 8453c76f-a887-4fce-be42-d7997ed94292
|
Warning Review limit reached
Next review available in: 46 minutes You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (4)
📝 WalkthroughWalkthroughThe PR establishes a Go CLI module with structured command execution, generated schemas, authentication status and logout operations, redacted doctor diagnostics, injectable filesystem and clock dependencies, and process-level output and exit-code propagation. ChangesCLI foundation
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant CLI
participant app.Execute
participant auth.Status
participant FileSystem
CLI->>app.Execute: Submit command arguments
app.Execute->>auth.Status: Inspect credentials
auth.Status->>FileSystem: Read credential file
FileSystem-->>auth.Status: Credential data or error
auth.Status-->>app.Execute: Authentication state
app.Execute-->>CLI: Envelope and exit code
Possibly related issues
🚥 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 |
|
There was a problem hiding this comment.
Actionable comments posted: 4
🧹 Nitpick comments (5)
internal/auth/auth.go (1)
54-54: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueName the expiry warning threshold.
The value
5 * time.Minutedefines the boundary between "healthy" and "expiring". Extract it into a package-level constant so the policy is visible and testable.♻️ Proposed constant
+// expiringWindow is the interval before expiry in which a token is reported as "expiring". +const expiringWindow = 5 * time.Minute + func Status(files FileSystem, path string, now time.Time) (State, error) {- if credentials.ExpiresAt.After(now.Add(5 * time.Minute)) { + if credentials.ExpiresAt.After(now.Add(expiringWindow)) {🤖 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` at line 54, Extract the 5-minute expiry warning threshold used in the credentials expiry check into a package-level named constant, then reference that constant in the condition within the authentication logic so the policy is explicit and testable.internal/app/execute_test.go (2)
449-458: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAssert the stderr line on the logout failure path.
internal/app/app.goline 593 writes"partiful: local operation failed\n"to stderr forCREDENTIAL_STORE_UNAVAILABLE. This test does not assert it. The comparable status test at line 357 does. Add the assertion so both redacted failure paths are pinned.💚 Proposed assertion
if result.Stdout != wantStdout { t.Fatalf("stdout = %q, want %q", result.Stdout, wantStdout) } + if result.Stderr != "partiful: local operation failed\n" { + t.Fatalf("stderr = %q, want the redacted failure line", result.Stderr) + } if strings.Contains(result.Stdout+result.Stderr, privateValue) {🤖 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 449 - 458, Extend the logout failure assertions in the test around result.ExitCode and wantStdout to verify that result.Stderr contains exactly the expected “partiful: local operation failed\n” line. Keep the existing exit-code, stdout, and private-value redaction checks unchanged, matching the comparable status test’s assertion style.
229-231: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueGuard the nil
readFilehook.
Removeat lines 233-238 checks for a nil hook, butReadFiledoes not. A future test that sets onlyremovepanics with a nil dereference. Returnfs.ErrNotExistwhen the hook is absent, so the double stays symmetric.♻️ Proposed guard
func (filesystem fakeFilesystem) ReadFile(path string) ([]byte, error) { + if filesystem.readFile == nil { + return nil, fs.ErrNotExist + } return filesystem.readFile(path) }🤖 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 229 - 231, Update fakeFilesystem.ReadFile to check whether the readFile hook is nil before invoking it, and return fs.ErrNotExist when absent, matching the existing Remove guard behavior while preserving delegated reads when the hook is configured.internal/app/app.go (2)
298-322: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueCollapse the duplicate flag cases and handle more than one
Dependenciesvalue.The
--prettyand--non-interactivecases have identical bodies. A single case list removes the duplication. Also,len(provided) == 1silently discards every argument when a caller passes two or more values. Use the last value, or the first, but do not drop all of them.♻️ Proposed simplification
var dependencies Dependencies - if len(provided) == 1 { - dependencies = provided[0] + if len(provided) > 0 { + dependencies = provided[len(provided)-1] } @@ for _, argument := range request.Argv { - switch argument { - case "--pretty": - if seenGlobalFlags[argument] { - return repeatedFlagFailure(commandName(request.Argv), argument, pretty) - } - seenGlobalFlags[argument] = true - continue - case "--non-interactive": + switch argument { + case "--pretty", "--non-interactive": if seenGlobalFlags[argument] { return repeatedFlagFailure(commandName(request.Argv), argument, pretty) } seenGlobalFlags[argument] = true continue } argv = append(argv, argument) }🤖 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/app.go` around lines 298 - 322, Update Execute to select a Dependencies value whenever provided is non-empty, using a consistent first or last element instead of discarding multiple values. Combine the --pretty and --non-interactive switch cases into one shared case while preserving duplicate-flag detection and existing behavior.
378-459: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winExtract the doctor checks into a lookup.
Lines 378-459 repeat the same
success(definition.path, doctorData{...})shape five times. Onlyhealthy,status,message, andremediationchange. Move the diagnosis into a helper that maps a token state or a sentinel error to onedoctorCheck. The dispatch body then stays short, and a new check needs one table entry instead of a new branch.The redaction behavior is correct on every path. Keep the fixed message strings exactly as they are so the assertions in
internal/app/execute_test.golines 469-651 continue to pass.🤖 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/app.go` around lines 378 - 459, The doctorCommand branch in the app dispatch repeats diagnosis-specific success responses; extract this into a lookup-backed helper that maps token states and sentinel errors (auth.ErrInvalid and auth.ErrUnavailable) to a doctorCheck, including healthy status and remediation. Keep the existing message strings and redaction behavior unchanged, preserve the internal-failure path for unrecognized errors or states, and have the dispatch construct the shared doctorData response once.
🤖 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 `@cmd/partiful/main.go`:
- Line 14: Update the caller around auth.DefaultCredentialsPath to retain and
handle its error instead of discarding it. When resolving the credentials path
fails, surface a distinct configuration-directory failure through the command’s
existing error/reporting flow so auth.Status, auth.Logout, and doctor do not
collapse it into generic LOCAL_OPERATION_FAILED; preserve normal behavior when
path resolution succeeds.
In `@internal/app/app.go`:
- Around line 463-469: Update the fallback failure construction in the command
execution flow to pass commandName(request.Argv) instead of the hardcoded
"unknown" value, keeping the existing fallback behavior because commandName
returns "unknown" when no command prefix matches.
- Around line 523-533: The projectSchema function currently drops
commandDefinition.invocation, preventing discovered commands such as version
from being invoked correctly. Add an invocation field to commandSchema, project
definition.invocation in projectSchema, and declare invocation as a required
array of strings in schemaSuccessSchema; update the pinned literals in
execute_test.go to include the new field.
In `@internal/auth/auth.go`:
- Around line 63-76: Update the expired-token return in the credentials state
logic to set Authenticated to false while preserving TokenState "expired" and
the existing expiration timestamp. Align the corresponding expectation in
execute tests with the unauthenticated expired state so command results remain
consistent with doctor.
---
Nitpick comments:
In `@internal/app/app.go`:
- Around line 298-322: Update Execute to select a Dependencies value whenever
provided is non-empty, using a consistent first or last element instead of
discarding multiple values. Combine the --pretty and --non-interactive switch
cases into one shared case while preserving duplicate-flag detection and
existing behavior.
- Around line 378-459: The doctorCommand branch in the app dispatch repeats
diagnosis-specific success responses; extract this into a lookup-backed helper
that maps token states and sentinel errors (auth.ErrInvalid and
auth.ErrUnavailable) to a doctorCheck, including healthy status and remediation.
Keep the existing message strings and redaction behavior unchanged, preserve the
internal-failure path for unrecognized errors or states, and have the dispatch
construct the shared doctorData response once.
In `@internal/app/execute_test.go`:
- Around line 449-458: Extend the logout failure assertions in the test around
result.ExitCode and wantStdout to verify that result.Stderr contains exactly the
expected “partiful: local operation failed\n” line. Keep the existing exit-code,
stdout, and private-value redaction checks unchanged, matching the comparable
status test’s assertion style.
- Around line 229-231: Update fakeFilesystem.ReadFile to check whether the
readFile hook is nil before invoking it, and return fs.ErrNotExist when absent,
matching the existing Remove guard behavior while preserving delegated reads
when the hook is configured.
In `@internal/auth/auth.go`:
- Line 54: Extract the 5-minute expiry warning threshold used in the credentials
expiry check into a package-level named constant, then reference that constant
in the condition within the authentication logic so the policy is explicit and
testable.
🪄 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: c07a792b-1902-4a4d-82ba-4dc69c9e264e
📒 Files selected for processing (6)
cmd/partiful/main.gogo.modinternal/app/app.gointernal/app/execute_test.gointernal/auth/auth.gointernal/auth/os_files.go
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8d5e0c8cfc
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if err != nil { | ||
| return "", err | ||
| } | ||
| return filepath.Join(configDirectory, "partiful", "credentials.json"), nil |
There was a problem hiding this comment.
Read the existing auth.json credential store
When a user has authenticated with the current CLI, credentials are stored in ~/.config/partiful/auth.json and scripts may also point PARTIFUL_CREDENTIALS_FILE at that file; this default always looks for partiful/credentials.json instead. In that scenario the Go auth.status/doctor paths report missing credentials, and auth.logout leaves the real auth file intact, so existing authenticated users appear logged out. Use the existing auth.json default and the credential-file override before status/logout.
AGENTS.md reference: AGENTS.md:L23-L26
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Not changed: issue #161 explicitly requires a greenfield implementation rather than a TypeScript port, and the approved contract does not require the legacy auth.json path or PARTIFUL_CREDENTIALS_FILE. Preserving that legacy seam would violate the assigned scope.
|
|
||
| type credentialRecord struct { | ||
| AccessToken string `json:"accessToken"` | ||
| ExpiresAt time.Time `json:"expiresAt"` |
There was a problem hiding this comment.
Accept the login credential expiry field
When the credential file is the one written by the current login flow, it contains tokenExpiry as epoch milliseconds (src/commands/auth.ts:423-428), not an RFC3339 expiresAt field. This unmarshal leaves ExpiresAt zero and Status returns CREDENTIALS_INVALID, so authenticated users are treated as having corrupt credentials even after the path is fixed or injected in tests; read tokenExpiry or migrate it before rejecting the record.
AGENTS.md reference: AGENTS.md:L23-L26
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Not changed: issue #161 explicitly says the TypeScript credential format is research evidence only and must not be preserved unless the approved contracts require it. The S0 store is intentionally greenfield, so accepting legacy tokenExpiry would introduce out-of-scope compatibility behavior.
Preserve configuration-directory failures, report expired credentials as unauthenticated, and keep known command metadata on invalid invocations. Co-authored-by: Copilot <[email protected]> Copilot-Session: 8453c76f-a887-4fce-be42-d7997ed94292
Require explicit application dependencies and centralize construction of the single doctor credentials check without changing command behavior. Co-authored-by: Copilot <[email protected]> Copilot-Session: 8453c76f-a887-4fce-be42-d7997ed94292
Summary
cmd/partifulexecutableapp.Executeseam with a typed S0 command catalog, schema projection, and complete JSON envelopesValidation
go test ./...go vet ./...npm run typechecknpm test -- tests/remote-api-contract.test.js(14 passed)TZ=America/Los_Angeles npm test(335 passed, 6 skipped)scripts/pii-guard.shCloses #161
Summary by CodeRabbit