feat: decode-able backtest fingerprint (strategy/input/engine/codegen provenance)#33
Merged
Conversation
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Add fingerprint helpers (strategy/input parsing, provenance builder, base64-encoded token + sha256 digest) to docker/run_json.py. The same block will be duplicated verbatim in scripts/run_strategy.py (Task 3). New CLI flags --generated-cpp and --transpiled feed the provenance. The fingerprint is injected into the JSON report under the top-level "fingerprint" key. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…t injection Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
… test Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Attaches a reversible
fingerprintto backtest output recording exactly what produced a run — so a result is self-describing and reproducible.report["fingerprint"] = { token, digest, provenance }:token— base64 of the canonical (sorted-keys) provenance JSON. Reversible, no key:jq -r .fingerprint.token report.json | base64 -d | jq .digest—sha256:of the same canonical JSON; stable run id (same target + settings ⇒ same digest).provenance—engine— version + git sha (read from the.sovia the already-exportedpf_version_get/pf_version_string)codegen— package version +sha256(generated.cpp)+transpiled_from_pinestrategy— allstrategy()params, effective (default ⊕ override), even with zero overridesinputs— allinput()values as{type, default, value}, effectiveapplied— the user-supplied deltas (inputs/overrides)runtime— timeframe / bar-magnifier knobsThe full effective param set is sourced by parsing the codegen-emitted
generated.cpp(the one artifact present in every run mode and already hashed):strategy()defaults from the constructor body plus a canonical engine-default seed for the two base-class-defaulted fields;input()s fromget_input_*calls.Changes
docker/run_json.py— fingerprint helpers, ctypes version reader,--generated-cpp/--transpiledargs, injectreport["fingerprint"](crash-proofed).scripts/run_strategy.py— same helpers (byte-identical block) + opt-in--fingerprint-json PATHsidecar (default off → corpus parity untouched).docker/entrypoint.sh— passes the compiled cpp path + transpile flag.docker/Dockerfile—pip install -U(force-latest codegen; fingerprint records what actually ran).docker/README.md— documents the field.scripts/fingerprint_self_test.py— pins both helper copies to identical behavior.No C++ changes (
pf_version_*already exported; the C-ABI runtime check is unaffected).Design notes
docker/run_json.pyandscripts/run_strategy.pybecausescripts/is.dockerignored (no shared runtime module); the self-test enforces they never drift. Matches the existing duplicated ctypes ABI mirror across the same two files.Test Plan
python3 scripts/fingerprint_self_test.py→ 52/52generated.cpp→ strategy=9 fields, inputs typed correctly; 257 files scanned, 0 malformed string defaults (afterstd::string()unwrap fix)ctest --test-dir build→ 72/72./scripts/run_corpus.sh→ 246 strategies, excellent=245 / anomaly=1 (baseline, no regression)python3 scripts/check_c_abi_runtime.py→ exit 0docker build+docker runreal.pine→ token round-trips, overrides applied,transpiled_from_pine:true,-Upulled codegen 0.7.0🤖 Generated with Claude Code