This repository holds the scripts from the feasibility experiments for Tidystudy.
Tidystudy is an R package in development. It will record every value of a study with its own hash and show what changed between the raw data and the analysis. These experiments tested single ideas before any design was fixed and before the package existed.
- This is throwaway code. The package does not build on it.
- All data are synthetic. No script reads real study data or contacts a real service.
- Two experiments support the design, two tested ideas that were not chosen. Each section names the decision it led to.
- The output is in German.
You need Docker.
docker build -t tidystudy-experiments .
docker run --rm -v "${PWD}:/work" tidystudy-experimentsThe second command runs run-all.sh. Its output is in results/run.log, and the files it writes go to out/, which Git ignores.
The image is pinned (rocker/r-ver:4.4.2@sha256:df26749182af64d5263bf64149d51a427b476ed28c4e046997143be3f97fdd7c) and contains R 4.4.2, Python 3.12.3 and OpenSSL 3.0.13. A few lines change from run to run, such as the nonce and one file hash. No reported number depends on them.
Can two fetches of the same data be compared when the file format, the encoding, the number format and the order of rows and columns differ? make_exports.py writes synthetic fetches in several forms, fallgleich.py compares two fetches value by value, and stresstest.py runs 600 random second fetches.
- A first fetch of 500 cases in a LimeSurvey-like CSV, and a second fetch with 37 new cases as JSON, as Windows-1252 with decimal commas and as UTF-16: all three give 496 unchanged, 37 new, 4 continued and 0 changed cases.
- A third fetch with 2 changed values and 1 deleted case: the script reports exactly these.
- Stress test: 300 of 300 fetches with changes of form only are reported as equal, and 300 of 300 fetches with one real change are reported as changed.
r_roundtrip.R: R without column types drops the leading zero of postcodes, and the script reports the changed cases. With column types set, all 500 cases are equal.
Limits: the data, the changes and the comparison were written together, so this is not an independent test. The stress test counts a change as found when the verdict changes, and does not check that the right case and variable are named. A case that was open at the first fetch may gain values without an alarm. An empty value and NA both count as missing. The CSV form was not checked against a real LimeSurvey export.
Led to: the comparison works value by value (ADR-0019), and a proposal for fixed rules for differences of form only (ADR-0039, proposed).
Can R build a timestamp request (RFC 3161) without extra packages?
- The request from
tsq_literal.Ris byte-identical to the one fromopenssl ts -query. The request fromtsq_tlv.R, built field by field with a nonce, is read correctly by OpenSSL. - A local test timestamp service answers both requests, and
openssl ts -verifyaccepts both tokens.
Limits: only the request is built in R. Sending it and checking the token in R are open. Both scripts call a command-line tool for the hash, and no real timestamp service was contacted.
Led to a proposal to build timestamp requests in R without system tools (ADR-0047, proposed).
Can someone check a shared part of a project without seeing the rest? To test only this question, mk.R uses a simplified setup: 5 files with one hash each, a flat list instead of the planned Merkle tree, and a signed proof for 2 shared files. verify.py checks the published folder.
The check passes, and it reports a changed file and an edited proof, so a part can be checked on its own. For the design, one hash per file proved too coarse, and a key that comes with the part proved too weak.
Led to: one hash per value (ADR-0013) and timestamps instead of keys (ADR-0015).
Can a comparison of two tables tell a change of form from a change of value? csvdiff.R compares two CSV files by a key column and treats numbers as equal within a small tolerance. test_diff.R runs four cases on 412 synthetic cases.
The script finds the changed value, the deleted and new rows and a new order of rows and columns, and it treats the 820 differences in number format as form. The tolerance, however, also hides small real changes.
Led to: every value is kept as delivered (ADR-0010), and a proposal that only listed differences count as form, without a numeric tolerance (ADR-0039, proposed).
Apache-2.0. See LICENSE.