Chapter 10 · Course 3 c10-m03
How do you prove where data came from?
Your goal Preserve a raw response and checkable provenance record to distinguish a content change from the still-open question of who made it.
The lesson, the vocabulary, the worked example and the mission are separate blocks. You can follow them in order or return to the one you need.
Video explanation
This English explanation has English subtitles. Its examples may use a separate practice dataset; use the data stated in the written mission for your answers.
Story · optional context
The story so far
You are Aster Motors’ new data recruit. After Luca’s crash, Noctis 01 vanished and Voss accuses you using an authorization bearing your ID. Mara Sol recovered page 2, which the vendor report seemed to omit: it contains TRANSFER-7. Imani wants more than a screenshot of that word. She asks which address was requested, when the response arrived and whether the bytes shown tomorrow are exactly the ones preserved today.
This lesson stands alone. A service page arrives as bytes; it can be displayed as text, but displayed text can later be reformatted or changed. You will make a small provenance record with source URL, UTC time, byte size and SHA-256 fingerprint. The exercise uses fictional bytes in memory and makes no real connection. A fingerprint helps detect a changed copy; it cannot certify who sent the response.
Before the lesson
Purpose of this course
Preserve a raw response and checkable provenance record to distinguish a content change from the still-open question of who made it.
Topics covered
Record the exact page URL and a receipt time in UTC.; Tell received bytes from decoded JSON used for reading.; Calculate len(raw) and sha256(raw).hexdigest() on original bytes.; Compare fingerprints and explain the limits of that comparison.
What you will learn
- Record the exact page URL and a receipt time in UTC.
- Tell received bytes from decoded JSON used for reading.
- Calculate
len(raw)andsha256(raw).hexdigest()on original bytes. - Compare fingerprints and explain the limits of that comparison.
PART 1 · THE LESSON
Understand step by step
Lesson · explanation
Why ask where a page came from?
You work for Aster Motors. After the crash that injured Luca, Noctis 01 disappeared. Voss accuses you using an authorization bearing your ID. Mara has now recovered page 2 of the vendor service: it contains event TRANSFER-7, missing from the report Voss displayed. Imani wants to preserve this page before anyone can claim it never existed.
A data item is recorded information, like a word in a notebook. Provenance is the checkable story of its collection: where the team looked, when it received a response, and what exact content it kept. Think of an object found in a detective film. Writing only 'a key' is insufficient; investigators also record where and when they found it.
Two pictures of the same web page may look similar although their underlying data differ. A screenshot shows what a screen displayed at one moment, but it need not preserve the raw response received by the computer. Imani therefore wants a provenance record beside the original response. This lesson uses fictional bytes in memory, so it makes no real network request.
Counterexample: saying 'I saw TRANSFER-7 somewhere' without an address, receipt time, or inspectable copy. Mara could not repeat the comparison and Voss could challenge a memory. A useful record lets another person check the work. It does not alone establish that the vendor was honest, but it clarifies what was actually received.
Pause and think
Why is a screenshot showing TRANSFER-7 insufficient to trace the received page?
See the explanation
It need not contain the original bytes, exact URL, and checkable receipt time.
Lesson · explanation
The complete URL identifies the requested page
A URL is a resource address on a service. Here, https://api.example.test/events?page=2 identifies page 2 of the events. The ?page=2 part matters: removing it or writing page=1 would describe another request. Mara needs the exact address used during collection if she is to follow the same path.
Imagine a library with several shelves and catalog pages. Saying 'I checked the catalog' does not let a friend find the card. Saying 'events shelf, page 2' is better. Similarly, a base URL without its page number cannot explain why you saw TRANSFER-7 while Voss displays a page without that event.
One URL may return a different reply tomorrow if the service changes. The address identifies the request; it does not promise fixed content. That is why the actual received bytes must be kept as well. In a real collection log, include the request ID and response code if recorded; do not invent missing fields.
Counterexample: recording only https://api.example.test/events and later comparing that vague note with Voss's report. Nobody would know which page was downloaded. If a real URL contains a secret token, keep that detail securely in authorized records rather than displaying the token to the public. Exactness and careful handling both matter.
Pause and think
What is lost when ?page=2 is removed from the recorded URL?
See the explanation
The precise page number; the original request can no longer be identified confidently.
Lesson · explanation
UTC places the receipt on a shared clock
Mara records that reply A arrived on 12 October 2026 at 20:30 UTC. UTC is a common time reference. Without it, '20:30' might mean different moments on computers in different countries. The record does not invent when the vendor created the content. It says when our team received this response.
Imagine two friends calling an investigator, one in Madrid and one in London. Both say 'eight o'clock', but their local clocks may differ. A shared clock helps order observations. In Python, datetime(2026, 10, 12, 20, 30, tzinfo=timezone.utc).isoformat() returns a time marked +00:00, the UTC offset.
The date helps compare two versions of page 2. A arrived at 20:30 UTC; B appears in a report without a reliable creation time. Record that missing time rather than inventing one for B. Correctly timed copies may help narrow when a change occurred, but their times alone do not identify its author.
Counterexample: writing only 'Monday evening' or assigning 20:30 to B because A arrived then. That would blur the difference between observation and guess. Provenance works when every time is tied to a particular event: receipt, creation, copying, or publication. In this mission, only A's receipt time is given.
Pause and think
Does 20:30 UTC for A tell us when Voss created B?
See the explanation
No. It is A's receipt time; B has no reliable creation time in this exercise.
Lesson · explanation
Keep the bytes before reading the JSON
A digital response arrives as a sequence of bytes. A byte is a small unit of digital data; files and network replies are made of bytes. In Python, raw = b'{"events":["TRANSFER-7"],"next":3}'. The b prefix means raw holds bytes. The characters resemble JSON and are readable, but the bytes are the original of this exercise.
JSON is a way of writing data using named fields, lists, and values. Here, events is a list containing one event, TRANSFER-7, and next is 3. You may decode a copy to inspect the fields. Keep raw separately, just as you annotate a photocopy without writing on an original letter.
Reformatting JSON can change its bytes without changing its meaning to a reader. Adding a space after a comma or moving next before events produces another byte sequence. If you then fingerprint the reconstructed text, you are no longer checking the exact received reply. Save raw first, record its provenance, and make a readable view afterward.
Counterexample: open the response, tidy its spaces, save that result as 'original', and discard the received bytes. A future difference might then come from your own editing. Imani must separate what the service sent from what your program chose to display. She keeps the original and the human-readable view for their different purposes.
Pause and think
Why fingerprint raw instead of rewritten JSON?
See the explanation
raw contains the received bytes; rewriting JSON can change them even when the meaning looks the same.
Lesson · explanation
Count bytes and calculate SHA-256
len(raw) counts the bytes in a response. For A it returns 34. That is not the number of events: A's JSON has only one event, TRANSFER-7. Picture a 34-slot envelope holding one important card. Counting slots and counting cards answer different questions. The record must say '34 bytes', not '34 transfers'.
A digital fingerprint is a summary calculated from bytes. from hashlib import sha256 imports the Python function; sha256(raw).hexdigest() calculates the fingerprint and writes it as hexadecimal characters. Hexadecimal uses digits 0 through 9 and letters a through f. SHA-256 gives 64 characters here. You do not calculate them by hand; the program performs the exact operation.
For A the fingerprint is 8d515d05ec3b7c0fa7b187fb7c35b04d07734c4f87dc12ae78b0f2b358ea63cd. Record it beside the URL, UTC receipt time, and byte size. The record may also include a response code and request ID if the collector actually saved them. Keep the raw response itself: a fingerprint cannot recreate its input bytes.
Counterexample: see 34 and claim there were 34 events, or keep only the 64-character fingerprint while deleting raw. The first mixes a storage unit with a business fact. The second prevents anyone from reading TRANSFER-7 or comparing the actual content. Size, fingerprint, and original bytes serve complementary purposes.
Pause and think
What does len(raw) == 34 mean for A?
See the explanation
A's response contains 34 bytes; its JSON holds one event, not 34.
Lesson · explanation
Compare A and B without erasing the first version
Mara has two byte sequences. A is {"events":["TRANSFER-7"],"next":3} and measures 34 bytes. B is {"events":[],"next":3} and measures 22 bytes. B's events field is an empty list: TRANSFER-7 is absent. Even if both versions claim the same URL, their preserved contents are different.
Calculate B's fingerprint without adding spaces. It is 634f7983527b29968dc88de192f616f26b5d23237fb03e4745d9fd22cd2bac70, unlike A's fingerprint. Different fingerprints here reveal different bytes; reading the two JSON values lets you name the visible difference. The calculation by itself cannot explain why one list was emptied.
Picture two sealed envelopes. The first contains a TRANSFER-7 card; the second does not. Writing a size and fingerprint on each envelope helps show which preserved copies you compare. If another page arrives tomorrow, do not overwrite A. Keep each version together with its source and the time actually known for it.
Counterexample: claiming 'same address, therefore same response', or overwriting A with B to save space. One URL can deliver changing content, and overwriting A destroys evidence of the difference. Avoid a stronger conclusion too: B might result from transformation, error, or deliberate action. The investigation must distinguish these possibilities.
Pause and think
What certain differences can we read between A and B?
See the explanation
A has 34 bytes and TRANSFER-7; B has 22 bytes, an empty list, and a different fingerprint.
Lesson · explanation
A fingerprint checks a copy, not a person
If tomorrow you reread A's saved bytes and calculate the same fingerprint, you can check that they match the recorded bytes under normal SHA-256 assumptions. A different fingerprint signals that the compared bytes changed. This aids preservation. It does not prove that the vendor told the truth or that Voss altered B.
Someone who can create a fake file can also calculate its fingerprint and write a false record. A fingerprint is not the sender's signature. To attribute a change, Imani compares A and B with download logs, access records, backups, reliable times, and independently preserved copies. Each source adds a puzzle piece; no single label settles the case.
For the mission, give Mara A's raw reply and a record: complete URL with page=2, receipt at 20:30 UTC, size 34, A's fingerprint, and response code if known. Preserve B separately and mark that it lacks a reliable creation time. Then show that B's content and fingerprint differ. The report can state that observed difference and ask where B came from.
Counterexample: saying 'the fingerprints differ, therefore Voss forged B'. The calculation identifies a difference, not a hand. The story has a short deadline before Voss presents his report, but your exercise has no real timer. Take time to separate a computed fact from an accusation that still needs checking.
Pause and think
Does a SHA-256 fingerprint prove who sent A or created B?
See the explanation
No. It helps compare bytes; authorship and source require other evidence.
Visual guide
The page-preservation chain
- 1Receive URL, response and UTC time
- 2Keep original bytes without rewriting them
- 3Record byte size and SHA-256 beside the copy
The record helps repeat a comparison. It cannot replace investigation of the sender’s identity.
Code · read each line
Fingerprint of a fictional response
from datetime import datetime, timezone
from hashlib import sha256
source_url = 'https://api.example.test/events?page=2'
raw = b'{"events":["TRANSFER-7"],"next":3}'
received_at = datetime(2026, 10, 12, 20, 30, tzinfo=timezone.utc)
record = {
'source_url': source_url,
'received_at_utc': received_at.isoformat(),
'byte_count': len(raw),
'sha256': sha256(raw).hexdigest(),
}
print(record['byte_count'])
print(record['sha256'])raw is the exact simulated reply; len(raw) gives 34 and SHA-256 gives 8d515d05ec3b7c0fa7b187fb7c35b04d07734c4f87dc12ae78b0f2b358ea63cd. The +00:00 from isoformat() means UTC. The program contacts no URL.
PART 2 · WATCH IT WORK
A complete worked example
Follow each step, then the result
Worked example: compare two page-2 versions
Version A received at 20:30 UTC: {"events":["TRANSFER-7"],"next":3}. Version B copied into a report: {"events":[],"next":3}. They claim the same URL.
- Record each version’s URL and the time it was obtained or created. One URL does not guarantee identical content at two times.
- Keep A’s bytes, calculate size 34 and its fingerprint. Do not reformat the JSON first.
- Calculate B’s bytes: size 22 and a different fingerprint. These are not the same byte sequence.
- Describe the difference: B lacks
TRANSFER-7. The calculation cannot say who made B; it tells Imani what to compare in logs and source copies.
Proof of a change needs two dated comparable copies. A fingerprint helps check copies, while attributing an author needs other facts.
How this helps with your missionImani gives you recovered page 2 before Voss presents his report. You preserve A's exact 34 bytes received from https://api.example.test/events?page=2 at 20:30 UTC, then record len(raw) and sha256(raw).hexdigest() separately. You also keep B's 22 bytes, whose events list is empty and whose reliable creation time is unknown. The differing fingerprints and readable contents show that B omits TRANSFER-7. Mara can present this precise difference. Imani must then find who made B, from which response and with which access; the fingerprint cannot answer those questions.
PART 3 · YOUR TURN
Use the lesson to solve the mission
Story scene · practical task
Mission: preserve the recovered page
In the story, Imani must preserve page 2 before Voss presents an empty report. Mara gives you A bytes {"events":["TRANSFER-7"],"next":3} received from https://api.example.test/events?page=2 at 20:30 UTC, and B bytes {"events":[],"next":3} in a report lacking a reliable creation time. Both versions must stay available to investigators.
Your task
- List the provenance fields for A and distinguish byte size from event count.
- Give the Python method for fingerprinting A without rewriting its JSON.
- Compare sizes and fingerprints given in the lesson and describe the change.
- Explain what the fingerprints establish and what must still be checked to attribute that change.
How to know you have succeeded
- The record has URL, UTC time, response code if known, size 34 and fingerprint; 34 is not an event count.
sha256(raw).hexdigest()uses A’s bytes.- A has 34 bytes and contains TRANSFER-7; B has 22 and does not; fingerprints differ.
- The copy difference is established; B’s author and source remain to be found in other logs.
Try code or SQL and keep a local draft. The mission questions are checked separately below.
See the worked answer
- For A, note the exact URL with
page=2, 20:30 UTC, raw bytes, their size 34 and fingerprint. Note response code if recorded. JSON has one event, not 34. - In Python import
sha256fromhashlib, then calculatesha256(raw).hexdigest()on received bytes. Do not use reformatted JSON text. - A has fingerprint
8d515d05ec3b7c0fa7b187fb7c35b04d07734c4f87dc12ae78b0f2b358ea63cd; B has634f7983527b29968dc88de192f616f26b5d23237fb03e4745d9fd22cd2bac70. B omits the event. - Different fingerprints reveal different bytes. Imani must find who created B, when, from which reply and with what access. A fingerprint alone names no person.
You can keep a traceable delivery. The chapter’s last course will join reading, transformation and checks in a small local pipeline.
Before you leave
Remember this
- Provenance connects a saved copy to its URL, receipt time, and other available collection records.
- The exact URL includes
?page=2; one URL does not guarantee identical contents at different times. - UTC makes times comparable; 20:30 UTC records A's receipt, not B's unknown creation.
- Keep
rawbytes before decoding or reformatting JSON for reading. len(raw)gives 34 bytes for A, although its JSON contains only one event.sha256(raw).hexdigest()fingerprints original bytes; A and B have different fingerprints.- Preserve both versions and their records; a fingerprint signals a difference but does not name an author.
Continue with the integrated lessons
After the lesson and its mission, work through the additional lessons below in order. Each workshop supplies its own fictional data: do not merge identifiers or times from separate exercises into the story timeline.
Part of the lesson · keep nearby
New words, explained
These are the names of ideas used in the lesson above. Return here whenever a word feels unfamiliar.
- Provenance
- Information tracing where an item was received and under what conditions.
- Byte
- A small unit of digital data from which files and network replies are made.
- UTC
- A shared time reference for comparing clocks in different places.
- Fingerprint
- A calculated summary of content that changes greatly when its input changes.
- SHA-256
- A fingerprint calculation producing 256 bits, often written as 64 hexadecimal characters.
- Hexadecimal
- Number writing using digits 0 through 9 and letters a through f.
- Original
- The bytes kept as received, before correction or reformatting.
Approfondissements de ce cours
Contrôler la qualité sur tout le cycle de vie
Le cycle de vie décrit le parcours d’une donnée depuis sa préparation et sa collecte jusqu’à sa diffusion, puis son archivage ou sa destruction. Toute personne qui la manipule doit comprendre sa finalité et le trajet qui mène aux résultats. Le cycle n’est pas nécessairement linéaire : un défaut découvert à la publication peut imposer un retour à la collecte.
Le schéma du PDF présente six étapes : planifier ; collecter ou acquérir et ingérer ; préparer, stocker et maintenir ; utiliser et traiter ; partager et publier ; archiver ou détruire. C’est un modèle de réflexion, pas un ordre obligatoire valable pour toutes les organisations. Les responsables peuvent dessiner leur propre cycle selon leurs processus et leurs données.
Évaluer et assurer la qualité à chaque étape, avec des mesures adaptées. Un contrôle identique partout ne convient pas : à l’entrée on examine le format et la provenance ; après une jointure on examine les correspondances ; avant publication on examine les chiffres et leur documentation. Une anomalie d’entrée peut provoquer des effets en chaîne bien plus loin.
Intervenir aussi tôt que possible augmente souvent l’efficacité d’une amélioration. Les acteurs doivent toutefois connaître les utilisateurs futurs et les réutilisations possibles. Documenter puis communiquer l’état de qualité à chaque transfert permet à l’étape suivante de prendre une décision fondée sur le risque plutôt que de supposer une donnée parfaite.
Les fournisseurs, les utilisateurs et les équipes intermédiaires ont besoin de canaux de communication efficaces. Leur expliquer une modification de qualité et clarifier les exigences avec les producteurs réduit les malentendus. Une source sous-traitée doit également recevoir les retours sur les défauts observés ; le transfert de fichier ne termine pas la responsabilité de communication.
À toi de jouer
Une jointure fait disparaître 8 % des commandes. À quelle étape agir ?
Voir la correction expliquée
Mesurer la perte après jointure, empêcher une publication trompeuse, puis rechercher la cause dans les clés, standards et référentiels de l’entrée. Documenter le défaut et informer les producteurs et utilisateurs concernés.
Références : Cadre officiel et guides associés.
Adapté de The Government Data Quality Framework, Government Data Quality Hub, gouvernement britannique, pages 9–10, 13–14. Consulter le PDF source et ses illustrations · Provenance. Open Government Licence v3.0, © Crown copyright 2020 ; droits de tiers réservés lorsque signalés.