Skip to content

feat(go): establish local runtime - #173

Merged
KalebCole merged 3 commits into
mainfrom
feat/go-local-runtime
Aug 11, 2026
Merged

KalebCole merged 3 commits into
mainfrom
feat/go-local-runtime

Conversation

@KalebCole

@KalebCole KalebCole commented Aug 11, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • add the greenfield Go module and composition-only cmd/partiful executable
  • expose the app.Execute seam with a typed S0 command catalog, schema projection, and complete JSON envelopes
  • implement local auth status, atomic logout, and redacted doctor diagnostics without remote calls

Validation

  • go test ./...
  • go vet ./...
  • npm run typecheck
  • npm test -- tests/remote-api-contract.test.js (14 passed)
  • TZ=America/Los_Angeles npm test (335 passed, 6 skipped)
  • scripts/pii-guard.sh

Closes #161

Summary by CodeRabbit

  • New Features
    • Added a command-line interface with version, schema, authentication, logout, and diagnostic commands.
    • Added credential status checks for missing, valid, expiring, expired, and invalid credentials.
    • Added secure credential logout and redacted sensitive data from output.
    • Added structured output, pretty-printing, validation, exit codes, and schema discovery.
    • Added automatic credentials-path detection and filesystem support.

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
@coderabbitai

coderabbitai Bot commented Aug 11, 2026 •

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@KalebCole, you've reached your PR review limit, so we couldn't start this review.

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 @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: a5854ab0-7ab4-4218-bfc6-d1850ccf64c9

📥 Commits

Reviewing files that changed from the base of the PR and between 8d5e0c8 and e21abc1.

📒 Files selected for processing (4)
  • cmd/partiful/main.go
  • internal/app/app.go
  • internal/app/execute_test.go
  • internal/auth/auth.go
📝 Walkthrough

Walkthrough

The 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.

Changes

CLI foundation

Layer / File(s) Summary
Authentication storage and state
internal/auth/auth.go, internal/auth/os_files.go
The auth package reads and validates credential files, classifies token state, supports logout, and provides operating-system filesystem access with a default credentials path.
Command contracts and execution
internal/app/app.go, internal/app/execute_test.go
The app package defines command metadata and schemas for version, discovery, authentication, and doctor commands. Execute validates arguments, dispatches commands, emits structured envelopes, formats output, assigns exit codes, and redacts credential data. Tests cover command, schema, authentication, logout, and diagnostics behavior.
Module and process entry point
go.mod, cmd/partiful/main.go
The module targets Go 1.22. The executable passes process arguments and runtime dependencies to app.Execute, writes stdout and stderr, and exits with the returned code.

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
Loading

Possibly related issues

  • Issue 172 — The PR implements the initial Go CLI foundation described by the issue.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the primary change: establishing the local Go runtime and executable.
Linked Issues check ✅ Passed The implementation covers issue #161: local commands, schema discovery, envelopes, authentication, atomic logout, and redacted diagnostics.
Out of Scope Changes check ✅ Passed The module, executable entry point, application logic, authentication layer, and tests directly support issue #161.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/go-local-runtime

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

github-actions Bot commented Aug 11, 2026 •

Copy link
Copy Markdown
PR Preview Action v1.8.1
Preview removed because the pull request was closed.
2026-08-11 01:06 UTC

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

🧹 Nitpick comments (5)
internal/auth/auth.go (1)

54-54: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Name the expiry warning threshold.

The value 5 * time.Minute defines 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 win

Assert the stderr line on the logout failure path.

internal/app/app.go line 593 writes "partiful: local operation failed\n" to stderr for CREDENTIAL_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 value

Guard the nil readFile hook.

Remove at lines 233-238 checks for a nil hook, but ReadFile does not. A future test that sets only remove panics with a nil dereference. Return fs.ErrNotExist when 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 value

Collapse the duplicate flag cases and handle more than one Dependencies value.

The --pretty and --non-interactive cases have identical bodies. A single case list removes the duplication. Also, len(provided) == 1 silently 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 win

Extract the doctor checks into a lookup.

Lines 378-459 repeat the same success(definition.path, doctorData{...}) shape five times. Only healthy, status, message, and remediation change. Move the diagnosis into a helper that maps a token state or a sentinel error to one doctorCheck. 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.go lines 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

📥 Commits

Reviewing files that changed from the base of the PR and between 8f4d3da and 8d5e0c8.

📒 Files selected for processing (6)
  • cmd/partiful/main.go
  • go.mod
  • internal/app/app.go
  • internal/app/execute_test.go
  • internal/auth/auth.go
  • internal/auth/os_files.go

Comment thread cmd/partiful/main.go Resolved
Comment thread internal/app/app.go Resolved
Comment thread internal/app/app.go Resolved
Comment thread internal/auth/auth.go Resolved

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread internal/auth/os_files.go
if err != nil {
return "", err
}
return filepath.Join(configDirectory, "partiful", "credentials.json"), nil

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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 👍 / 👎.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread internal/auth/auth.go

type credentialRecord struct {
AccessToken string `json:"accessToken"`
ExpiresAt time.Time `json:"expiresAt"`

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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 👍 / 👎.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
@KalebCole
KalebCole merged commit 5976533 into main Aug 11, 2026
2 checks passed
@KalebCole
KalebCole deleted the feat/go-local-runtime branch August 11, 2026 01:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Establish the local Go executable, discovery, and diagnostics

1 participant