I rebuilt a question found in actual production source as independent synthetic code. The complete implementation, examples and tests are shared without connecting the original business program or material.
Compare values only after units are explicit
Normalization accepts bounded unsigned decimal text and per-thousand or per-million units, using Decimal to reach a common per-million basis. Unknown units, exponent notation, numeric objects and booleans fail. No actual provider name or current rate is imported.
Evidence compares Decimal values, so two and two-point-zero-zero-zero are equal. Uncertain units are not guessed. The contract performs no currency conversion or interpretation of discount conditions.
One field cannot certify a whole row
Coverage compares each field’s value and unit against structured evidence. A reference and date do not count as a numeric match when the value disagrees. Evidence for input leaves output missing unless it has its own match, avoiding row-wide verification inferred from one source badge.
Evidence rows are caller-prepared declarations. The code neither reads original prose nor authenticates official material. Copying a matching number does not make its reference genuine; original-source review remains separate.
Reject duplicates before dictionary construction
Index checks the provider and model pair before inserting it. Both snapshots pass the same check, and a duplicate on either side makes diff fail. This independently addresses the source code’s possibility of losing repeated identities during dictionary construction.
Diff retains changed numeric fields, verification metadata and raw representation changes separately. A new checked date remains recorded without becoming a price change. Preserving rather than discarding metadata is a deliberate difference from the source comparison.
Explore the implementation
Complete independent synthetic implementation
"""Synthetic price normalization and evidence-aware diff. No provider fetch."""
from decimal import Decimal,InvalidOperation
from datetime import date
import re
def normalized(value,unit):
if not isinstance(value,str) or not re.fullmatch(r'\d{1,9}(?:\.\d{1,6})?',value):raise ValueError('bounded unsigned decimal text')
if unit not in ('per_1k','per_1m'):raise ValueError('unit needs review')
return format(Decimal(value)*(1000 if unit=='per_1k' else 1),'f')
def coverage(fields,evidence):
if not isinstance(fields,dict) or not isinstance(evidence,list):raise ValueError('explicit fields and evidence')
matched={k:[] for k in fields}
for e in evidence:
if set(e)!={'field','value','unit','reference','checked'} or not isinstance(e['reference'],str) or not e['reference'].strip():raise ValueError('evidence contract')
date.fromisoformat(e['checked'])
if e['field'] not in fields:raise ValueError('unknown field')
row=fields[e['field']]
if Decimal(normalized(row['value'],row['unit']))==Decimal(normalized(e['value'],e['unit'])):matched[e['field']].append(e['reference'])
return dict(matches=matched,missing=sorted(k for k,v in matched.items() if not v),automatic_source_authentication=False)
def index(rows):
result={}
for r in rows:
if set(r)!={'provider','model','input','output','checked','reference','note'}:raise ValueError('snapshot contract')
if any(not isinstance(r[k],str) or not r[k].strip() for k in ('provider','model','reference')):raise ValueError('identifier/reference')
key=(r['provider'],r['model'])
if key in result:raise ValueError('duplicate composite identity')
date.fromisoformat(r['checked'])
for k in ('input','output'):normalized(r[k]['value'],r[k]['unit'])
result[key]=r
return result
def diff(before,after):
a,b=index(before),index(after);changes=[]
for key in sorted(a.keys()|b.keys()):
if key not in a or key not in b:changes.append(dict(identity=list(key),kind='added' if key in b else 'removed'));continue
values=[k for k in ('input','output') if Decimal(normalized(a[key][k]['value'],a[key][k]['unit']))!=Decimal(normalized(b[key][k]['value'],b[key][k]['unit']))]
metadata=[k for k in ('checked','reference','note') if a[key][k]!=b[key][k]]
representation=[k for k in ('input','output') if a[key][k]!=b[key][k]]
if values or metadata or representation:changes.append(dict(identity=list(key),kind='value_changed' if values else 'verification_or_representation_only',value_fields=values,metadata_fields=metadata,representation_fields=representation))
return changesRetain representation without inventing a new value
Point-zero-zero-two per thousand equals two per million, but their raw representations differ. Diff leaves value fields empty while retaining representation fields; a checked-date refresh appears as metadata. This preserves evidence and wording changes without manufacturing a price update.
The counterexample is inspectable through tests and saved execution records. Adoption requires checking input meaning and failure policy before changing labels. A small independent function does not replace an operational application.
Published code and ZIP use the same reviewed files. The central decision can be inspected without importing company records or running another system. Any added integration needs separate observed results; the existing package does not pre-certify its behavior.
Actual execution evidence and its boundary
The source folder and a fresh ZIP extraction each passed 12 tests. Actual example results are saved in records.json, and the published core can be compared with the download. Historical project completion messages and test totals were not reused as evidence of this execution.
The selector reads results saved by actual local runs; it does not execute Python or a server in the browser. These checks do not establish rendered-browser or physical-device behavior. An integrated service needs its own observed verification rather than inheriting a broader claim from these small tests.
Before adapting the download
The ZIP contains core implementation, tests, runner, saved results and guidance; live examples also include bilingual HTML. This is new synthetic code with permission to modify and reuse, without original customer images, operational records or credentials. It contains no instruction to execute the source business program or transmit its material.
Begin adoption by defining units, input provenance and failure messages for the actual workflow. Passing tests cannot certify all supplied facts or grant operational authority. Authentication, persistence, transmission and rendered-interface review remain outside the small contract. I share both a reusable implementation and the decisions an adopter still needs to make.