Skip to content

fix(replay): stand down KEPLOY_AGENT_OWNS_CONSUMED under --retry-passing-test - #4623

Open
pujitha24 wants to merge 1 commit into
keploy:mainfrom
pujitha24:auto/issue-4622
Open

pujitha24 wants to merge 1 commit into
keploy:mainfrom
pujitha24:auto/issue-4622

Conversation

@pujitha24

Copy link
Copy Markdown
Contributor

Describe the changes that are made

  • KEPLOY_AGENT_OWNS_CONSUMED (experimental, default OFF) and --retry-passing-test are mutually
    incompatible: --retry-passing-test rewinds the CLI's own consumed-mock map to a baseline between
    retry cycles so per-test single-use mocks are servable again, but the agent's own consumption history
    (used when the flag is set) is never rewound anywhere. Under the flag, a retry cycle is filtered
    against everything the previous cycle consumed and every single-use mock the retry needs is already
    marked gone, failing as an ordinary mock mismatch. This change makes KEPLOY_AGENT_OWNS_CONSUMED
    stand down whenever --retry-passing-test is active, so the CLI's rewindable map is the one enforced
    instead — the smaller of the two fix shapes the issue proposes (the larger one gives the agent its own
    rewind primitive, which is a bigger change left for later).

Links & References

Closes: #4622

  • NA

🔗 Related PRs

  • NA

🐞 Related Issues

  • NA

📄 Related Documents

  • NA

What type of PR is this? (check all applicable)

  • 📦 Chore
  • 🍕 Feature
  • 🐞 Bug Fix
  • 📝 Documentation Update
  • 🎨 Style
  • 🧑‍💻 Code Refactor
  • 🔥 Performance Improvements
  • ✅ Test
  • 🔁 CI
  • ⏩ Revert

Added e2e test pipeline?

  • 👍 yes
  • 🙅 no, because they aren't needed

Added comments for hard-to-understand areas?

  • 👍 yes
  • 🙅 no, because the code is self-explanatory

Added to documentation?

  • 📜 README.md
  • 📓 Wiki
  • 🙅 no documentation needed

Are there any sample code or steps to test the changes?

  • 👍 yes, mentioned below
  • 🙅 no, because it is not needed

go test ./pkg/service/replay/... -run TestSendMockFilterParamsStandsDownAgentOwnsConsumedUnderRetryPassing -v
fails on the pre-fix code and passes after this change (verified with git stash of just replay.go).

Self Review done?

  • ✅ yes
  • ❌ no, because I need help

Any relevant screenshots, recordings or logs?

  • NA

🧠 Semantics for PR Title & Branch Name

Please ensure your PR title and branch name follow the Keploy semantics:

📌 PR Semantics Guide
📌 Branch Semantics Guide

Examples:

  • PR Title: fix: patch MongoDB document update bug
  • Branch Name: feat/#1-login-flow (You may skip mentioning the issue number in the branch name if the change is small and the PR description clearly explains it.)

Additional checklist:


AI assistance: this change was drafted with Claude Code.

Fixes #4622

…ing-test

Motivation:
KEPLOY_AGENT_OWNS_CONSUMED (experimental, default OFF) and
--retry-passing-test are mutually incompatible. --retry-passing-test
re-runs passing tests in extra cycles, rewinding the CLI's own
totalConsumedMocks map to a baseline at the top of every cycle so
per-test single-use mocks consumed in cycle 1 are servable again in
cycle 2. When the flag is set, the CLI instead sends the agent a nil
map and lets it filter from its own consumedPersistent history, which
is only ever appended to and has no rewind point anywhere in its
lifecycle. Every retry cycle is therefore filtered against everything
every prior cycle consumed, so any single-use mock a retried test
needs is already marked gone. It fails as an ordinary mock mismatch
(match_phase=no_mocks) rather than as an error naming the real cause.

Approach:
Stand the flag down whenever RetryPassing is set, in
SendMockFilterParamsToAgent (pkg/service/replay/replay.go). This is
the smaller of the two fix shapes the report lays out - the CLI keeps
using its own rewindable map instead of handing filtering to the
agent for the duration of a retry-passing run. The larger shape (give
the agent an equivalent rewind primitive so the flag can stay on
under RetryPassing) is left for a follow-up; this only removes the
silent breakage.

Validation:
- go test ./pkg/service/replay/... -run TestSendMockFilterParamsStandsDownAgentOwnsConsumedUnderRetryPassing -v
  fails on the pre-fix code and passes after this change (confirmed by
  stashing just replay.go and re-running).
- go test ./pkg/service/replay/... (full package) passes.
- go build ./... passes.
- gofmt -l -d on both changed files: clean.
- golangci-lint run ./pkg/service/replay/...: 0 issues.

Report: keploy#4622
Signed-off-by: Pujitha Paladugu <10557236+pujitha24@users.noreply.github.com>
Assisted-by: claude-sonnet-5 (via Claude Code)
Copilot AI lite review requested due to automatic review settings September 21, 2026 21:44
@github-actions

Copy link
Copy Markdown

CLA Assistant Lite bot:
Thank you for your submission, we really appreciate it. Like many open-source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution. You can sign the CLA by just posting a Pull Request Comment same as the below format.


I have read the CLA Document and I hereby sign the CLA


You can retrigger this bot by commenting recheck in this Pull Request

@github-actions

Copy link
Copy Markdown

The CLA check failed. Please ensure you have:

  • Signed the CLA by commenting 'I have read the CLA Document and I hereby sign the CLA'
  • Used the correct email address in your commits (matches the one you used to sign the CLA).

After fixing these issues, comment 'recheck' to trigger the workflow again.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟢 Approval recommended

No unresolved review comments; regression coverage is included.

Review effort: Lite
Findings: None

What changed in this PR

Fixes replay failures when KEPLOY_AGENT_OWNS_CONSUMED is used with --retry-passing-test.

Changes:

  • Disables agent-owned consumption during retry-passing mode.
  • Adds regression coverage while preserving normal behavior.
File Summary
pkg/​service/​replay/​replay.go Applies the retry compatibility guard.
pkg/​service/​replay/​agent_holds_stored_mocks_test.go Adds regression coverage.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@chilkotiKartik

Copy link
Copy Markdown

Review for PR #4623: Stand down KEPLOY_AGENT_OWNS_CONSUMED under --retry-passing-test

Concurrency & Fallback Behavior

  1. Conflict Resolution:
    Temporarily falling back to server-managed consumption when --retry-passing-test is active prevents agent-side state corruption while full snapshot rollbacks are finalized.

  2. Telemetry Logging:
    Ensure a debug log is emitted notifying developers that KEPLOY_AGENT_OWNS_CONSUMED is bypassed for the active test retry run.

@pujitha24

Copy link
Copy Markdown
Contributor Author

The debug log is already in this PR. When KEPLOY_AGENT_OWNS_CONSUMED is set and --retry-passing-test is active, SendMockFilterParamsToAgent logs ignoring KEPLOY_AGENT_OWNS_CONSUMED: --retry-passing-test needs the CLI's rewindable consumed-mock map, ... at Debug (pkg/service/replay/replay.go:3690).

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.

KEPLOY_AGENT_OWNS_CONSUMED breaks --retry-passing-test: the agent's consumption map is never rewound

3 participants