Skip to content

feat(ipc): add list and info query commands with lastSyncAt#1015

Merged
corylanou merged 6 commits intomainfrom
issue-1013-ipc-status-query-commands
Feb 5, 2026
Merged

feat(ipc): add list and info query commands with lastSyncAt#1015
corylanou merged 6 commits intomainfrom
issue-1013-ipc-status-query-commands

Conversation

@corylanou
Copy link
Collaborator

@corylanou corylanou commented Jan 17, 2026

Summary

  • Add IPC query commands for the Litestream control system (Phase 2)
  • New litestream list -socket command lists all managed databases with sync status
  • New litestream info -socket command shows daemon information (version, PID, uptime)
  • Add lastSyncAt field to database list for monitoring sync timing

Related Issue: #1013

Changes

Server (server.go)

  • Add GET /list, GET /info HTTP endpoints
  • Add Version and startedAt fields to Server struct
  • Add ListResponse, InfoResponse types
  • Add LastSyncAt field to DatabaseSummary for monitoring last successful sync time
  • Improve status accuracy: "replicating" vs "open" vs "stopped"

CLI Commands

  • list: New command to list all managed databases via socket (includes lastSyncAt)
  • info: New command to show daemon information via socket
  • status: Unchanged - uses config-based mode only (no socket mode)

Command Registration (main.go)

  • Register list and info commands
  • Update help text

Tests Added

  • Comprehensive server endpoint tests (server_test.go)
  • CLI command tests with happy-path integration tests (list_test.go, info_test.go)
  • Test for lastSyncAt field in list response

Design Decision

Per review feedback, the /status endpoint and -socket flag for the status command were removed. The lastSyncAt field was added to the /list response instead, providing sync timing information without requiring a separate endpoint. This avoids the confusing UX where only one command would need the -socket flag.

Test plan

  • Build succeeds: go build -o bin/litestream ./cmd/litestream
  • Pre-commit hooks pass
  • All tests pass: go test -v ./...
  • Server endpoint tests cover info and list endpoints
  • CLI command tests cover error paths and success paths
  • Help text shows new commands
  • Manual testing with running daemon:
    ./bin/litestream replicate -config test.yml
    ./bin/litestream info -socket /tmp/litestream.sock
    ./bin/litestream list -socket /tmp/litestream.sock

🤖 Generated with Claude Code

corylanou added a commit that referenced this pull request Jan 19, 2026
Per review feedback on PR #1015, this removes the /status endpoint
and socket mode from the status command to avoid the confusing
behavior where only one command requires the -socket flag.

Instead of /status, the /list endpoint now includes lastSyncAt
for each database, providing the sync timing information without
needing a separate endpoint.

Changes:
- Remove GET /status endpoint from server
- Remove -socket flag and runWithSocket from status command
- Add LastSyncAt field to DatabaseSummary in /list response
- Update tests accordingly

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@corylanou corylanou changed the title feat(ipc): add status, list, and info query commands feat(ipc): add list and info query commands with lastSyncAt Jan 19, 2026
corylanou added a commit that referenced this pull request Jan 19, 2026
Per review feedback on PR #1015, this removes the /status endpoint
and socket mode from the status command to avoid the confusing
behavior where only one command requires the -socket flag.

Instead of /status, the /list endpoint now includes lastSyncAt
for each database, providing the sync timing information without
needing a separate endpoint.

Changes:
- Remove GET /status endpoint from server
- Remove -socket flag and runWithSocket from status command
- Add LastSyncAt field to DatabaseSummary in /list response
- Update tests accordingly

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@corylanou corylanou force-pushed the issue-1013-ipc-status-query-commands branch from 92ec82a to bc02dc7 Compare January 19, 2026 20:31
corylanou and others added 4 commits January 30, 2026 13:51
Add IPC status and query commands for the Litestream control system,
building on the Unix socket infrastructure from Phase 1.

New commands:
- `litestream status -socket <path> <db>` - Query database replication status
- `litestream list -socket <path>` - List all managed databases
- `litestream info -socket <path>` - Show daemon information

Server changes:
- Add GET /status, /list, /info endpoints to the HTTP server
- Add Version and startedAt fields to Server struct
- Add StatusResponse, ListResponse, InfoResponse types

The status command now supports both modes:
- Config-based: reads local files for static status (existing behavior)
- Socket-based: queries running daemon for live status (new)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Use Replica.Pos() for faster cached position lookup
- Fall back to db.Pos() only when replica position unavailable
- Surface position read errors in StatusResponse.Error field
- Improve status accuracy: distinguish "replicating" vs "open" vs "stopped"
  - "replicating": DB open with active replica monitor
  - "open": DB open but monitor disabled (e.g., -once mode)
  - "stopped": DB closed
- Add nil check for Replica.Client before accessing
- Add comprehensive server endpoint tests
- Add CLI command tests for status, list, and info

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Address Codex review findings:
- Fix checksum issue: Replica.Pos() only tracks TXID, so we now use
  db.Pos() which reads the full position including checksum
- Add happy-path integration tests for info, list, and status CLI
  commands with socket mode

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Per review feedback on PR #1015, this removes the /status endpoint
and socket mode from the status command to avoid the confusing
behavior where only one command requires the -socket flag.

Instead of /status, the /list endpoint now includes lastSyncAt
for each database, providing the sync timing information without
needing a separate endpoint.

Changes:
- Remove GET /status endpoint from server
- Remove -socket flag and runWithSocket from status command
- Add LastSyncAt field to DatabaseSummary in /list response
- Update tests accordingly

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@corylanou corylanou force-pushed the issue-1013-ipc-status-query-commands branch from bc02dc7 to 8c4f948 Compare January 30, 2026 19:52
@corylanou
Copy link
Collaborator Author

Addressing review feedback from @benbjohnson:

Fixed in commit bc02dc7 (now rebased as 8c4f948):

  • ✅ Removed the /status endpoint from the server
  • ✅ Removed the -socket flag from the status command
  • ✅ Added lastSyncAt field to the /list endpoint's DatabaseSummary response

The status command now only works in config-based mode, consistent with other commands. Sync timing information is available through the /list endpoint instead of a separate /status endpoint.

@corylanou corylanou requested a review from benbjohnson January 30, 2026 20:04
- list command now shows: /path/to/db [status] (last sync: time)
- info command now shows human-readable format with uptime
- Added -json flag to both commands for raw JSON output

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@corylanou
Copy link
Collaborator Author

@codex review

@corylanou corylanou requested a review from benbjohnson February 2, 2026 23:33
- Validate timeout > 0 in info and list commands to prevent
  unexpected http.Client behavior with zero/negative values
- Move startedAt assignment after successful socket listen to
  ensure uptime reflects actual server availability time
- Add documentation clarifying LastSyncAt represents replica sync
  time, not just local WAL processing
- Add test for "replicating" status when MonitorEnabled is true
- Add tests for invalid timeout validation (zero and negative)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@corylanou corylanou merged commit bab4fd4 into main Feb 5, 2026
19 checks passed
@corylanou corylanou deleted the issue-1013-ipc-status-query-commands branch February 5, 2026 18:50
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.

2 participants