CLI auth (PAT/device) + direct-to-org-database data plane - #1
Conversation
- Added workspace configuration to include the CLI and backend in a single workspace for better data contract visibility. - Set default members to optimize build times, allowing for explicit backend builds when needed. - Updated resolver version to 3.
- Updated Cargo.lock to include new dependencies such as `async-trait`, `atoi`, `autter-server`, and others, enhancing the project's capabilities. - Added `BadRequest` variant to `AppError` enum in `error.rs`, marked as dead code for future use in API handling.
- Integrated Better Auth JWT verification into the server, allowing for stateless identity management via JWKS. - Updated `Cargo.toml` to include new dependencies: `jsonwebtoken`, `reqwest`, and `base64` for handling JWTs and HTTP requests. - Refactored database interactions to support per-organization PostgreSQL databases, utilizing the `org_db_url` claim from the JWT. - Revised the schema in `0001_init.sql` to remove organization-specific tables, as each organization now has its own database. - Updated README to reflect changes in identity and routing mechanisms, clarifying the role of autter.dev as the identity/control plane. - Enhanced error handling and logging for better traceability during authentication processes.
- Revised the JWKS URL in the documentation to reflect the correct endpoint for token signing keys. - Made the `resolve_hostname` function public to allow access from other modules. - Improved device metadata reporting in the OAuth device flow to include hostname and OS information.
- Added `token_id` field to `Claims` and `Identity` structs for tracking Personal Access Token (PAT) usage in audit logs. - Implemented audit logging for batch uploads in `cas.rs` and per-commit uploads in `notes.rs` to improve traceability of data pushes. - Introduced `exchange_pat` method in `OAuthClient` for validating PATs during login, enhancing the login experience with a new `--token` option. - Updated command handling in `login.rs` to support a two-step PAT login process, improving user guidance for token creation and usage.
- Introduced in-process caching for organization resolution and access tokens associated with Personal Access Tokens (PATs). - Added methods to load and validate stored PATs, enabling organization-specific token minting and routing for note uploads. - Enhanced the notes database schema to include a `repo_url` field, allowing notes to be associated with their originating repository for better organization routing. - Updated the HTTP backend to support repository-specific note writing, improving the accuracy of note uploads to the correct organization. - Refactored login handling to display user and organization information upon successful PAT login, enhancing user feedback during authentication.
- Deleted the `autter-server` package and its associated files, as the backend functionality is no longer required. - Updated `Cargo.toml` to reflect the removal of the server dependencies and adjusted workspace settings accordingly. - Enhanced the README to clarify the new architecture, emphasizing direct database interactions from the CLI. - Removed outdated documentation related to the server's HTTP contract and database schema. - Updated `Cargo.lock` to remove references to the deleted server dependencies.
Metrics previously POSTed to a `/worker/metrics/upload` endpoint that no longer exists. Write them straight to each org's own Postgres instead, matching the notes/CAS data path: - New `cli_metrics` table (auto-created on connect) stores each event with its sparse `values`/`attrs` as JSONB, plus a content-hash `dedup_key` so re-flushing the local SQLite queue after a partial failure can't duplicate. - `org_db::insert_metrics` writes the batch and returns per-event errors. - `ApiClient::upload_metrics` decodes `org_db_url` from the access token and calls into `org_db`; the daemon flush and `flush-metrics-db` now gate on being logged in (an API key alone can't carry `org_db_url`). Generated-By: PostHog Code Task-Id: 257180bd-77bd-4424-a821-2c67c3a3fa8a
`autter onboard` installs the extension by ID (`autter.autter-vscode`), which only resolves if the editor's marketplace carries it. Cursor and VS Code resolve IDs against the Microsoft Marketplace, where the extension isn't published, so the install failed with "Extension not found" even though it's on Open VSX. Add a fallback: when the ID-based install fails, download the .vsix from Open VSX and install from the local file (every VS Code-family editor accepts a local .vsix), so onboarding works regardless of which gallery an editor uses. Wired into the Cursor, Windsurf, and VS Code installers. Also fix the publish workflow to derive the extension version from the `vscode-v*` tag (the tag and package.json had drifted: tag 0.1.23 but package.json 0.1.22, so the "0.1.23" release published 0.1.22), and bump package.json to 0.1.23 to match. Generated-By: PostHog Code Task-Id: 257180bd-77bd-4424-a821-2c67c3a3fa8a
|
Caution Review failedPull request was closed or merged during review 📝 WalkthroughWalkthroughThis PR migrates the CLI's notes, CAS, and metrics API calls from HTTP worker endpoints to direct per-org PostgreSQL writes via a new ChangesOrg DB Data-Plane Migration
VS Code VSIX Fallback and Publish Workflow
Sequence Diagram(s)sequenceDiagram
participant User
participant CLI as autter CLI
participant OAuthClient
participant CredentialStore
participant org_db
participant PostgreSQL
User->>CLI: autter login --token <PAT>
CLI->>OAuthClient: exchange_pat(pat)
OAuthClient-->>CLI: StoredCredentials
CLI->>CredentialStore: save credentials
CLI->>CLI: extract TokenIdentity (active_org_id)
CLI-->>User: signed in as <user> / org <org>
User->>CLI: autter notes migrate (or telemetry flush)
CLI->>org_db: identity_from_token(access_token)
org_db-->>CLI: OrgIdentity{org_db_url}
CLI->>org_db: upsert_notes / upsert_cas / insert_metrics
org_db->>PostgreSQL: connect (TLS) + provision schema
org_db->>PostgreSQL: execute upsert with ON CONFLICT
org_db->>PostgreSQL: record_push (audit log)
PostgreSQL-->>org_db: result rows
org_db-->>CLI: NotesUploadResponse / CasUploadResponse / failures
Estimated code review effort🎯 5 (Critical) | ⏱️ ~120 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 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 |
The repo doesn't use Devin (CodeRabbit is the active review bot), so the "wait for and address Devin feedback" instruction no longer applies. Keep the CI-monitoring guidance; remove the Devin-specific parts. Generated-By: PostHog Code Task-Id: 257180bd-77bd-4424-a821-2c67c3a3fa8a
Summary
This branch finishes CLI ↔ platform authentication and reworks how the CLI persists data, removing the intermediate data-plane backend entirely.
Authentication
autter login --token autter_pat_…) for non-interactive/CI sign-in, with per-org token minting and repo→org resolution.Direct-to-org-database data plane (no more CLI backend)
The CLI now writes authorship notes, prompt transcripts (CAS), and usage metrics straight to each organization's own Postgres, using the
org_db_urlclaim already carried in the signed access token. The previous pass-throughserver/crate is deleted.src/api/org_db.rs: decodeorg_db_url/identity from the token, cached TLS connection per org DB, schema auto-creation (authorship_notes,cas_objects,cli_audit_log,cli_metrics), and the upsert/read/audit logic the server used to do.upload_notes/read_notes/upload_cas/ metrics upload now write to the org DB;data.pushaudit rows are written by the CLI.server/crate, the obsoletenotes-backend-spec.md, and the in-memory reference HTTP backend (notes serve).Editor extension install fix
.vsixfrom Open VSX and installing from the local file — works across VS Code / Cursor / Windsurf / VSCodium.vscode-v*tag so the tag and published version can't drift.Testing
Verified end-to-end against a real org's Neon Postgres from a clean install: authorship notes, ~2k usage-metric rows, and
data.pushaudit rows all landed via the direct connection (TLS + schema auto-create confirmed); the CLI's own upload queue reportedsynced=1with no errors.Created with PostHog Code
Summary by CodeRabbit
New Features
Improvements