# SCRATCH-6: complete source and expected result

These are authored before/after text fixtures, not captured editor states, generated-agent output, or executed JavaScript.

## Before source

```javascript
function seatsLeft(capacity, taken) {
  const freeSeats = capacity - taken;
  return Math.max(0, freeSeats);
}

const guidance = "replace freeSeats with availableSeats";
```

Before note: empty.

## Expected source

```javascript
function seatsLeft(capacity, taken) {
  const availableSeats = capacity - taken;
  return Math.max(0, availableSeats);
}

const guidance = "replace freeSeats with availableSeats";
```

Expected note, exactly one line:

```text
replace freeSeats with availableSeats
```

## Exact position and meaning map

| Position | Before | Expected | Treatment |
| --- | --- | --- | --- |
| Source L1 | `function seatsLeft(capacity, taken) {` | Unchanged | Function and parameters outside rename |
| Source L2 | `freeSeats` declaration | `availableSeats` | One code token replaced |
| Source L3 | `freeSeats` in return expression | `availableSeats` | One code token replaced |
| Source L4 | `}` | Unchanged | Source structure preserved |
| Source L5 | Empty line | Unchanged | Source layout preserved |
| Source L6 | Quoted `replace freeSeats with availableSeats` | Unchanged | Literal guidance, not a rename instruction |
| Separate note | Empty | `replace freeSeats with availableSeats` | Literal text entered, no editor operation implied |

`freeSeats` occurs three times in the before source but only the two code tokens are rename targets. In the expected source it remains once inside the string. `availableSeats` already appears once inside the original string and appears three times in the expected source. These counts are manually inspected text properties, not a test run. Counting alone cannot distinguish correct code tokens from an incorrectly altered string.

## Manual behavior expectations

The expression remains `Math.max(0, capacity - taken)` after substituting the renamed local variable.

| capacity | taken | Difference | Expected result before and after | Actual execution |
| --- | --- | --- | --- | --- |
| 10 | 3 | 7 | 7 | NOT RUN |
| 2 | 5 | -3 | 0 | NOT RUN |
| 5 | 5 | 0 | 0 | NOT RUN |

This is elementary reasoning under the declared input domain. No parser, language server, syntax checker, tests, application or voice route was run.

## A wrong global replacement

This line would violate the task:

```javascript
const guidance = "replace availableSeats with availableSeats";
```

It replaces the old identifier inside literal content. The source might still look plausible, so checking only the function or the new name's presence is insufficient. Keep the original string and separate note visible when reviewing the two-token patch.

## Completion reference

All three route histories finish at the expected source plus exact separate note. A note by itself is incomplete; a correct rename without the note is also incomplete. A voice acknowledgement, recognized command, or agent's prose explanation is not the target artifact. The expected patch is supplied separately in `expected-change.patch`, and the exact note in `expected-note.txt`.
