FA-7986 / Form lifecycle / Open access
Form dirty-field bookkeeping: Reset accepts unsaved edits as the new baseline · case 01
Reset accepts unsaved edits as the new baseline.
ROOT CAUSE
The reset operation uses `initial = dict(current)` where the contract requires `current = dict(initial)`.
VERIFIED REPAIR
Implement the reset operation as `current = dict(initial)`.
Unsuccessful approach: Clearing the draft loses initial values.
Case contract
Edits change draft only; reset restores baseline; commit accepts draft; unmount removal clears both; dirty comparison includes additions and removals.
Why this case matters
A deterministic model of form dirty-field bookkeeping; this isolates one interface invariant without requiring a browser.
1 / The failure
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(initial, current, event, name, value):
initial, current = initial.copy(), current.copy()
if event == 'input': current[name] = value
elif event == 'reset': initial = dict(current)
elif event == 'commit': initial = dict(current)
elif event == 'remove': current.pop(name, None); initial.pop(name, None)
dirty = sorted(k for k in set(initial) | set(current) if initial.get(k, object()) != current.get(k, object()))
return (initial, current, dirty)
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('edit', solve({'a':1}, {'a':1}, 'input', 'a', 2), ({'a': 1}, {'a': 2}, ['a']))
check('reset', solve({'a':1}, {'a':2}, 'reset', None, None), ({'a': 1}, {'a': 1}, []))
check('commit', solve({'a':1}, {'a':2}, 'commit', None, None), ({'a': 2}, {'a': 2}, []))
check('remove', solve({'a':1,'b':2}, {'a':3,'b':2}, 'remove', 'a', None), ({'b': 2}, {'b': 2}, []))
check('new', solve({}, {'new':0}, 'read', None, None), ({}, {'new': 0}, ['new']))
check('removed', solve({'a':1}, {}, 'read', None, None), ({'a': 1}, {}, ['a']))
check('parameterized dirty value', solve({'a':N}, {'a':N}, 'input', 'a', N+1), ({'a':N}, {'a':N+1}, ['a']))
for repetition in range(N):
check('repeat removed', solve({'a':1}, {}, 'read', None, None), ({'a': 1}, {}, ['a']))
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| edit | [{'a': 1}, {'a': 2}, ['a']] | [{'a': 1}, {'a': 2}, ['a']] | Passed |
| reset | [{'a': 2}, {'a': 2}, []] | [{'a': 1}, {'a': 1}, []] | Failed |
| commit | [{'a': 2}, {'a': 2}, []] | [{'a': 2}, {'a': 2}, []] | Passed |
| remove | [{'b': 2}, {'b': 2}, []] | [{'b': 2}, {'b': 2}, []] | Passed |
| new | [{}, {'new': 0}, ['new']] | [{}, {'new': 0}, ['new']] | Passed |
| removed | [{'a': 1}, {}, ['a']] | [{'a': 1}, {}, ['a']] | Passed |
| parameterized dirty value | [{'a': 1}, {'a': 2}, ['a']] | [{'a': 1}, {'a': 2}, ['a']] | Passed |
| repeat removed | [{'a': 1}, {}, ['a']] | [{'a': 1}, {}, ['a']] | Passed |
SHA-256 / 9681e986ea37fbfb992ecee66754a9fba319c112e554ba3e54f4487baad06f54
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(initial, current, event, name, value):
initial, current = initial.copy(), current.copy()
if event == 'input': current[name] = value
elif event == 'reset': current = {}
elif event == 'commit': initial = dict(current)
elif event == 'remove': current.pop(name, None); initial.pop(name, None)
dirty = sorted(k for k in set(initial) | set(current) if initial.get(k, object()) != current.get(k, object()))
return (initial, current, dirty)
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('edit', solve({'a':1}, {'a':1}, 'input', 'a', 2), ({'a': 1}, {'a': 2}, ['a']))
check('reset', solve({'a':1}, {'a':2}, 'reset', None, None), ({'a': 1}, {'a': 1}, []))
check('commit', solve({'a':1}, {'a':2}, 'commit', None, None), ({'a': 2}, {'a': 2}, []))
check('remove', solve({'a':1,'b':2}, {'a':3,'b':2}, 'remove', 'a', None), ({'b': 2}, {'b': 2}, []))
check('new', solve({}, {'new':0}, 'read', None, None), ({}, {'new': 0}, ['new']))
check('removed', solve({'a':1}, {}, 'read', None, None), ({'a': 1}, {}, ['a']))
check('parameterized dirty value', solve({'a':N}, {'a':N}, 'input', 'a', N+1), ({'a':N}, {'a':N+1}, ['a']))
for repetition in range(N):
check('repeat removed', solve({'a':1}, {}, 'read', None, None), ({'a': 1}, {}, ['a']))
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| edit | [{'a': 1}, {'a': 2}, ['a']] | [{'a': 1}, {'a': 2}, ['a']] | Passed |
| reset | [{'a': 1}, {}, ['a']] | [{'a': 1}, {'a': 1}, []] | Failed |
| commit | [{'a': 2}, {'a': 2}, []] | [{'a': 2}, {'a': 2}, []] | Passed |
| remove | [{'b': 2}, {'b': 2}, []] | [{'b': 2}, {'b': 2}, []] | Passed |
| new | [{}, {'new': 0}, ['new']] | [{}, {'new': 0}, ['new']] | Passed |
| removed | [{'a': 1}, {}, ['a']] | [{'a': 1}, {}, ['a']] | Passed |
| parameterized dirty value | [{'a': 1}, {'a': 2}, ['a']] | [{'a': 1}, {'a': 2}, ['a']] | Passed |
| repeat removed | [{'a': 1}, {}, ['a']] | [{'a': 1}, {}, ['a']] | Passed |
SHA-256 / c1ab267fa9e993886f159d7a8f6f6b04323ec62972c821cac3b363f695c4b68f
3 / The verified repair
Exit 0"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(initial, current, event, name, value):
initial, current = initial.copy(), current.copy()
if event == 'input': current[name] = value
elif event == 'reset': current = dict(initial)
elif event == 'commit': initial = dict(current)
elif event == 'remove': current.pop(name, None); initial.pop(name, None)
dirty = sorted(k for k in set(initial) | set(current) if initial.get(k, object()) != current.get(k, object()))
return (initial, current, dirty)
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('edit', solve({'a':1}, {'a':1}, 'input', 'a', 2), ({'a': 1}, {'a': 2}, ['a']))
check('reset', solve({'a':1}, {'a':2}, 'reset', None, None), ({'a': 1}, {'a': 1}, []))
check('commit', solve({'a':1}, {'a':2}, 'commit', None, None), ({'a': 2}, {'a': 2}, []))
check('remove', solve({'a':1,'b':2}, {'a':3,'b':2}, 'remove', 'a', None), ({'b': 2}, {'b': 2}, []))
check('new', solve({}, {'new':0}, 'read', None, None), ({}, {'new': 0}, ['new']))
check('removed', solve({'a':1}, {}, 'read', None, None), ({'a': 1}, {}, ['a']))
check('parameterized dirty value', solve({'a':N}, {'a':N}, 'input', 'a', N+1), ({'a':N}, {'a':N+1}, ['a']))
for repetition in range(N):
check('repeat removed', solve({'a':1}, {}, 'read', None, None), ({'a': 1}, {}, ['a']))
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| edit | [{'a': 1}, {'a': 2}, ['a']] | [{'a': 1}, {'a': 2}, ['a']] | Passed |
| reset | [{'a': 1}, {'a': 1}, []] | [{'a': 1}, {'a': 1}, []] | Passed |
| commit | [{'a': 2}, {'a': 2}, []] | [{'a': 2}, {'a': 2}, []] | Passed |
| remove | [{'b': 2}, {'b': 2}, []] | [{'b': 2}, {'b': 2}, []] | Passed |
| new | [{}, {'new': 0}, ['new']] | [{}, {'new': 0}, ['new']] | Passed |
| removed | [{'a': 1}, {}, ['a']] | [{'a': 1}, {}, ['a']] | Passed |
| parameterized dirty value | [{'a': 1}, {'a': 2}, ['a']] | [{'a': 1}, {'a': 2}, ['a']] | Passed |
| repeat removed | [{'a': 1}, {}, ['a']] | [{'a': 1}, {}, ['a']] | Passed |
SHA-256 / b63e8e7931c4bdb9300dcd6b9f00fae2852e95c78e3e5bd58ac37e930f722a94
Verification & scope
This reproducer isolates one failure mechanism. Results cover the supplied fixtures. Variants within a family share a test contract and should remain grouped when constructing evaluation splits. Related mechanisms with a shared evaluation_group must also remain together; these controlled models are not independent production incidents.
Observations recorded using Python 3.12.14 at 2026-09-29T14:38:17.132804+00:00.
Case digest / 9560a0707230c38b0b5e812358b6527d739036911a5e4899ebe0ca298976eba1