Skip to content

[#335] [backend] Deterministic incident replay framework for full quote decision graph#2

Draft
Copilot wants to merge 2 commits into
mainfrom
copilot/fix335-deterministic-incident-replay-framework-for
Draft

[#335] [backend] Deterministic incident replay framework for full quote decision graph#2
Copilot wants to merge 2 commits into
mainfrom
copilot/fix335-deterministic-incident-replay-framework-for

Conversation

Copy link
Copy Markdown

Copilot AI commented May 30, 2026

This PR adds deterministic incident replay support to quote generation by capturing a full decision graph and emitting a replay artifact that can be used for forensic debugging and regression checks. It also introduces redaction at artifact level so persisted replay data does not expose sensitive identifiers.

  • Replay data model in quote response

    • Added optional decision_graph and replay_artifact fields to QuoteResponse.
    • Introduced replay-specific types (QuoteDecisionGraph, QuoteDecisionNode, QuoteReplayArtifact, QuoteReplayResult, etc.) to represent inputs, intermediate stages, and final selection deterministically.
  • Deterministic replay in quote pipeline

    • Extended find_best_price output to include both captured graph and replay artifact.
    • Captures full candidate inputs + ranking stage, then replays selection using stable sort/selection logic matching production path choice.
    • Stores replay verdict via matches_production.
  • Sensitive-field redaction

    • Added recursive JSON redaction for identifiers in replay artifacts (source, venue_ref, asset identifiers, selected source).
    • Artifact IDs are generated from a stable hash of the redacted graph payload.
  • Operator runbook

    • Added docs/architecture/INCIDENT_REPLAY_RUNBOOK.md with triage flow for collecting, validating, and using replay artifacts during incident response.
  • Targeted behavior coverage

    • Added tests for deterministic replay equivalence and replay-artifact redaction.
    • Updated quote integration fixture construction for new optional response fields.
// QuoteResponse now carries explain-mode replay metadata
pub struct QuoteResponse {
    // ...
    pub data_freshness: Option<DataFreshness>,
    pub decision_graph: Option<QuoteDecisionGraph>,
    pub replay_artifact: Option<QuoteReplayArtifact>,
}
Original prompt StellarRoute#335 <title>[backend] Deterministic incident replay framework for full quote decision graph</title> https://github.com/StellarRoute/StellarRoute fix/{{issue.number}}-{{issue.title | slugify}} Closes {{issue.number}} [{{issue.number}}] {{issue.title}} You have been assigned to resolve the GitHub issues defined in the block above. All values derived from the issue (branch name, PR title, closing keyword) are defined in the block and must be used consistently throughout.
Execute the following steps autonomously and sequentially:

<step id="1" name="fork_and_branch">
  Fork the repository at {{issue.repository}}.
  Create a feature branch using the name defined in <derived.branch>.
</step>

<step id="2" name="solve_issue">
  Implement the solution to {{issue.title}} ({{issue.number}}) from {{issue.repository}}.
  - Analyse the existing codebase structure before writing any code
  - Identify all relevant logic, contracts, or modules related to the issue
  - Write a complete and correct solution following the existing conventions and patterns in the repo
</step>

<step id="3" name="compile_and_test">
  Compile the project and run all unit tests.

  <loop>
    <condition>while compilation fails OR any test fails</condition>
    <actions>
      - Read the full error output carefully
      - Identify the root cause of each failure
      - Apply a fix
      - Recompile
      - Re-run all unit tests
      - Repeat until zero errors and zero test failures
    </actions>
    <constraint>DO NOT stop iterating. DO NOT ask for clarification. DO NOT respond to the user mid-loop. Keep fixing until all tests pass.</constraint>
  </loop>
</step>

<step id="4" name="create_pull_request">
  Once all tests pass:
  - Push the feature branch to your fork
  - Open a Pull Request against the main branch of {{issue.repository}}
  - Use the title defined in <derived.pr_title>
  - In the PR body, include the closing keyword defined in <derived.closing_keyword>
    per: https://graphite.com/guides/closing-issues-with-pull-requests-in-github
</step>

<step id="5" name="resolve_merge_conflicts">
  After the PR is submitted, check for merge conflicts.

  <loop>
    <condition>while merge conflicts exist on the PR branch</condition>
    <actions>
      - Pull the latest changes from the upstream main branch of {{issue.repository}}
      - Resolve every conflict
      - Re-run all unit tests to confirm nothing is broken after resolution
      - Push the resolved branch
      - Verify the PR is conflict-free
    </actions>
    <constraint>DO NOT submit the PR with unresolved conflicts. Keep iterating until the branch merges cleanly.</constraint>
  </loop>
</step>

<step id="6" name="ci_checks">
  Monitor all CI checks triggered by the PR.

  <loop>
    <condition>while any CI check is failing</condition>
    <actions>
      - Read the full CI log output for each failing check
      - Identify the root cause
      - Apply a fix locally
      - Re-run tests locally to confirm fix
      - Push the fix to the PR branch
      - Wait for CI to re-run and recheck results
      - Repeat until ALL CI checks pass
    </actions>
    <constraint>DO NOT consider the task complete if any CI check is red. Keep fixing until all checks are green.</constraint>
  </loop>
</step>

<success_criteria>
The task is ONLY complete when ALL of the following are true simultaneously:

<criterion id="1">The repository at {{issue.repository}} has been forked and the fix is on branch <derived.branch></criterion>
<criterion id="2">{{issue.title}} ({{issue.number}}) has been fully and correctly implemented</criterion>
<criterion id="3">The project compiles with zero errors</criterion>
<criterion id="4">All unit tests pass with zero failures</criterion>
<criterion id="5">A Pull Request has been submitted with title <derived.pr_title> and body containing <derived.closing_keyword></criterion>
<criterion id="6">The PR branch has zero merge conflicts against {{issue.repository}}</criterion>
<criterion id="7">All CI checks on the PR are green / passing</criterion>

If ANY criterion above is not met, continue iterating. Do not stop. Do not ask the user anything. Just keep fixing.

</success_criteria>

<behavioral_constraints>
Never ask the user for clarification at any point
Never respond...

Created from VS Code.

Copilot AI changed the title [WIP] [335] [backend] Deterministic incident replay framework for full quote decision graph [#335] [backend] Deterministic incident replay framework for full quote decision graph May 30, 2026
Copilot finished work on behalf of UzyKhs May 30, 2026 13:27
Copilot AI requested a review from UzyKhs May 30, 2026 13:27
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