feat(source): add loopback CDP cookie source - #121
Conversation
Greptile SummaryThis PR adds a loopback-only CDP cookie source and subsequently integrates it with multi-sink fan-out, per-sink state, local commands, inspection commands, and wizard configuration.
Confidence Score: 4/5The PR is not yet safe to merge because adding a sink to a CDP-backed source silently rewrites it into a SQLite-backed source. The additive wizard does not preserve Files Needing Attention: internal/cli/wizard.go, internal/cli/source.go, internal/cli/status.go
|
| Filename | Overview |
|---|---|
| internal/cdpsource/source.go | Adds a loopback-restricted CDP reader and maps CDP cookie fields into the existing Chrome cookie model. |
| internal/cli/source.go | Integrates CDP reads and multi-sink encrypted fan-out, but successful empty cycles no longer update source health. |
| internal/cli/wizard.go | Adds additive sink pairing and config migration, but its renderer drops cdp_source and silently changes the selected source mode. |
| internal/config/config.go | Adds mutually exclusive CDP source configuration and backward-compatible effective sink resolution. |
| internal/cli/status.go | Reads config-scoped CDP state and reports per-sink results, while its configuration header still assumes the legacy scalar sink. |
| internal/cli/doctor.go | Aligns CDP source-state lookup with the writer and adds multi-sink failure details. |
| internal/state/state.go | Adds backward-compatible per-sink push-state records keyed by peer identity. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart LR
C[Source configuration] --> M{Source mode}
M -->|CDP| D[Loopback CDP cookie jar]
M -->|File| S[Chrome SQLite and browser storage]
D --> F[Fresh cookie policy and DBSC filtering]
S --> F
F --> E[Build one sync envelope]
E --> K1[Seal with sink A key]
E --> K2[Seal with sink B key]
K1 --> A[Configured sink A]
K2 --> B[Configured sink B]
A --> H[Per-sink source health]
B --> H
H --> O[status and doctor]
Comments Outside Diff (2)
-
internal/cli/source.go, line 337-355 (link)A successful cycle with no eligible cookies and no secrets returns no sink results, so this loop does not update
LastPushorTotalPushes. The command succeeds, butstatusanddoctorcan continue reporting that an active source has never pushed or is stale. Successful empty cycles should still update source health.Knowledge Base Used:
-
internal/cli/status.go, line 107-109 (link)Human-readable
statusprints only the legacySourceConfig.Sink.URL. A valid configuration using the authoritativesinks:list therefore displays a blanksource ->target, even though effective destinations are configured. This makes status misleading during setup and diagnosis; it should show the resolved sink list.Knowledge Base Used:
Reviews (5): Last reviewed commit: "test: isolate daemon path check from hos..." | Re-trigger Greptile
| if cfg.CDPSource.Enabled { | ||
| if err := cdpsource.ValidateEndpoint(cfg.CDPSource.Endpoint); err != nil { | ||
| return fmt.Errorf("%s: %w", path, err) | ||
| } | ||
| return nil |
There was a problem hiding this comment.
CDP Config Breaks Local Commands
When cdp_source is enabled, this branch returns before resolving the normal Chrome database path. However, export, agent-sync, and cmux-sync use this loader and still unconditionally read from SQLite through cfg.Chrome.DBPath. A valid CDP-enabled source.yaml therefore leaves the path empty and causes these existing commands to fail instead of reading the configured source. Either these commands need to support CDP, or their configuration load must still resolve the file-based source.
Knowledge Base Used: Agentcookie CLI workflows
| func sourceStatePath(cdpSource bool, configDir, home string) string { | ||
| if cdpSource { | ||
| return filepath.Join(configDir, "state", "source-state.json") | ||
| } | ||
| return state.SourcePath(home) |
There was a problem hiding this comment.
Source Health Becomes Invisible
CDP source health is written under <config-dir>/state/source-state.json, but both status and doctor still read only ~/.agentcookie/source-state.json. After a successful CDP-source push, status omits the source health and doctor can incorrectly report that the daemon has never pushed. The readers and writer need to use the same state path.
Knowledge Base Used: CLI configuration and local state
34b4fc8 to
5522141
Compare
Summary
cdp_sourcemode for reading an existing Chromium cookie jar through CDPVerified
go build ./...go vet ./...go test ./...remains blocked by the pre-existing host-sensitiveinternal/cli TestCheckDaemonBinaryPathfailure, reproduced on clean base and branch; all other packages passNotes
cdp_source.enabledandcdp_source.endpointtosource.yaml.source --watchpolls every 10 seconds because CDP has no cookie-change event.