Examples · Atlas Payments demo project

Example: fix a partial refund bug

A developer and a tester describe a bug once, and Kitsune turns it into a change whose spec gains a regression scenario before the fix is written.

For
Developer, QA
Time
About 15 minutes
Plan
The Bug fix creator and handing the fix to your agent work on every plan. Check change and Build with agent need Solo Pro or Team.

A merchant of Atlas Payments refunded 60 € of a 100 € payment, then refunded another 60 €, and the second refund went through. The ledger went negative. The refunds spec already rejects one refund larger than the payment, but not several that add up to more:

openspec/specs/refunds/spec.md
### Requirement: Partial refund
When a merchant refunds part of a captured payment, the system SHALL refund that amount and record a ledger entry
against the original payment.

#### Scenario: Refund 10 of 42 EUR
- **WHEN** the merchant refunds 1000 minor units of a 42.00 EUR payment
- **THEN** the acquirer refunds 10.00 EUR and the ledger records a refund entry of 1000 linked to the payment

#### Scenario: More than captured
- **WHEN** the refunds would exceed the captured amount
- **THEN** the refund is rejected with "Refund exceeds captured amount" and nothing is sent to the acquirer

This example records the bug so your agent can fix it in one pass. From then on, a test keeps checking the fix.

You start with: the Atlas Payments project linked on this computer.

1. Describe the bug#

Choose New doc → Bug fix and give it a title that says what goes wrong: Partial refund over the remaining amount is accepted. Kitsune proposes the name fix-partial-refund-over-the-remaining-amount-is-accepted. Then fill in the steps:

  • Symptom says what happens now: A second partial refund succeeds even when it is larger than what is left of the payment, so the ledger goes negative.
  • Expected is one EARS sentence, which becomes the regression scenario: If a partial refund is larger than the amount not yet refunded, then the system shall refuse it with 422 and keep the ledger unchanged.
  • Reproduce: Refund 60 € of a 100 € payment, then refund another 60 €.
  • Unchanged says what must keep working, for example a refund of exactly the remaining amount. Leave it empty and Review warns: "Say what must keep working. Agents break neighbours".

2. Point at the requirement it breaks#

On Affected spec, choose the capability refunds and the requirement Partial refund. Kitsune shows its text and the regression scenario it will add to it.

The Bug fix creator on the Affected spec step: the capability refunds and its requirement Partial refund chosen, its text shown, and the line saying Kitsune adds the scenario Regression: Partial refund over the remaining amount is accepted

3. Create the change and hand it on#

Create writes the change: a proposal.md with the symptom, the steps, the cause and what must keep working, and a delta spec that copies Partial refund whole under ## MODIFIED Requirements with the scenario Regression: Partial refund over the remaining amount is accepted added last. The change passes openspec validate --strict.

Hand to your agent then plans the fix in a fixed order: first a test that reproduces the bug and fails, then the fix, then a check of every behaviour that must keep working. For a bug fix the agent writes only tasks.md.

What you have now#

  • A change fix-partial-refund-over-the-remaining-amount-is-accepted your agent can build, starting with a failing test.
  • A regression scenario that, once the change is archived, is part of the refunds spec, so the Tests tab lists it as a test case under Partial refund from then on.

Read more in Bug fix.