Skip to content

fix(staging): avoid unnecessary daemon start and AWS fetch in edit/add commands#123

Merged
mpyw merged 4 commits intomainfrom
fix/edit-unnecessary-aws-fetch
Jan 15, 2026
Merged

fix(staging): avoid unnecessary daemon start and AWS fetch in edit/add commands#123
mpyw merged 4 commits intomainfrom
fix/edit-unnecessary-aws-fetch

Conversation

@mpyw
Copy link
Copy Markdown
Owner

@mpyw mpyw commented Jan 15, 2026

Summary

  • Implement "Ping-first" pattern in EditUseCase and AddUseCase to avoid unnecessary daemon auto-start and AWS requests
  • Move Pinger/Starter interfaces from lifecycle package to store layer for correct dependency direction
  • Update AgentStore interface to embed Pinger/Starter
  • Add comprehensive unit tests for all Ping-first cases (97.9% coverage)

Problem

When editing or adding staged parameters, the edit command would auto-start the daemon and make unnecessary AWS requests even when nothing was staged. This was caused by GetEntry calls that auto-start the daemon.

Solution

Check if daemon is running (via Pinger.Ping()) before accessing staged state:

  • If Ping fails → daemon not running → nothing staged → skip to AWS/default
  • If Ping succeeds → daemon running → check staged state

This pattern is applied to:

  • EditUseCase.Baseline() - Returns AWS value if daemon not running
  • EditUseCase.Execute() - Skips staged check if daemon not running
  • AddUseCase.Draft() - Returns "not staged" if daemon not running

Test plan

  • All existing tests pass
  • New Ping-first tests added for Edit and Add use cases
  • Coverage: usecase/staging at 97.9%
  • go build ./... succeeds
  • go test ./... passes

Fixes #122

🤖 Generated with Claude Code

…d commands

## Problem
When editing or adding staged parameters, the edit command would auto-start
the daemon and make unnecessary AWS requests even when nothing was staged.
This was caused by GetEntry calls that auto-start the daemon.

## Solution
Implement "Ping-first" pattern in EditUseCase and AddUseCase:
- Check Pinger interface before accessing staged state
- If daemon not running (Ping fails), skip staged check and proceed to AWS
- If daemon running, check staged state first

## Changes
- Move Pinger/Starter interfaces from lifecycle package to store layer
- Update AgentStore to embed Pinger/Starter interfaces
- Update lifecycle executors to use store.Pinger/store.Starter
- Implement Ping-first pattern in EditUseCase.Baseline() and Execute()
- Implement Ping-first pattern in AddUseCase.Draft()
- Add comprehensive unit tests for all Ping-first cases
- Update CLAUDE.md documentation for affected packages

## Test Coverage
usecase/staging package: 97.9% (up from 85% target)

Fixes #122

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@codecov
Copy link
Copy Markdown

codecov bot commented Jan 15, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.35%. Comparing base (6eb4e48) to head (69f1058).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #123      +/-   ##
==========================================
+ Coverage   90.29%   90.35%   +0.05%     
==========================================
  Files         132      132              
  Lines        7701     7745      +44     
==========================================
+ Hits         6954     6998      +44     
  Misses        503      503              
  Partials      244      244              
Flag Coverage Δ
e2e 67.77% <1.96%> (-0.38%) ⬇️
platform-darwin 64.38% <ø> (ø)
platform-linux 62.85% <ø> (ø)
platform-windows 73.46% <ø> (ø)
unittests 79.69% <100.00%> (+0.11%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

mpyw and others added 3 commits January 15, 2026 11:42
Add missing test coverage for the Ping-first pattern:
- Non-Pinger store behavior (FileStore simulation)
- GetEntry error propagation when Ping succeeds
- Edge case: Ping fails but staged entry exists
- Fix lint issues (wsl_v5, nilerr)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add missing tests for Non-Pinger store (FileStore simulation):
- Execute/Baseline/Draft with ErrNotStaged
- Execute/Baseline/Draft with GetEntry error propagation

This completes the Ping-first pattern test matrix covering:
- Pinger + Ping success/fail combinations
- Non-Pinger + all GetEntry result patterns

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add tests for additional edge cases:
- UnstageEntry error during auto-unstage (revert to AWS value)
- Ping failure with staged CREATE (resource not found on AWS)

These tests ensure proper error propagation in unusual scenarios.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@mpyw mpyw merged commit d76474a into main Jan 15, 2026
23 checks passed
@mpyw mpyw deleted the fix/edit-unnecessary-aws-fetch branch January 15, 2026 03:53
@mpyw mpyw added the staging Staging workflow functionality label Jan 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

staging Staging workflow functionality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(staging): edit command makes unnecessary AWS requests and daemon auto-start

1 participant