Add append-only research experiment ledger and integrate with temporal baseline CLI - #56
Merged
Merged
Conversation
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.
Motivation
tools/run_temporal_change_baselines.pyso real CLI runs can record snapshots, stages, and output artifacts while preserving existing behaviour when the ledger is omitted.Description
research_ledgerimplementing canonical UTF-8 JSON serialization with sorted keys and finite-number rejection, immutable typed dataclasses (RunSnapshot,NewEvent,StoredEvent,ArtifactDescriptor,RunProjection), canonical SHA-256 hashing, recursive secret redaction, and a_freezehelper for stable in-memory objects (research_ledger/ledger.py).events.jsonlstreams with contiguous sequence numbers,prev_event_hashandevent_hash, an inter-processflockduring append,flush+fsyncbefore acknowledgement, torn final-line detection, append-only verification, deterministic in-memoryreconstruct(), and astage()context manager that recordsstage.started/stage.failed/stage.completedand re-raises original exceptions.tools/run_temporal_change_baselines.pyvia a--ledger-dirargument that is opt-in and preserves previous behaviour when omitted, recordrun.started, source/config/dataset/split/ontology snapshots, validate facade split leakage, wrap the baseline execution in a recorded stage, record the produced score CSV as anartifact.createdwith hash/size/path, and appendrun.completedorrun.failedappropriately.tests/test_research_ledger.py(serialization, append/read round-trip, verification of mutation/deletion/insertion/reordering, concurrent writers, torn-line detection, stage failure recording, facade overlap rejection, metadata adapter) andtests/test_temporal_baseline_ledger_cli.py(synthetic PPM-based end-to-end CLI run that compares outputs with and without ledger recording and verifies artifact hash), add documentationdocs/research_ledger.md, and add a lightweight GitHub Actions workflow.github/workflows/research-ledger.ymlfor CPU validation.Testing
PYTHONPATH=/usr/lib/python3/dist-packages:$PYTHONPATH python -m pytest -q tests/test_research_ledger.py, which passed (11 passed).python -m ruff format --check research_ledger tools/run_temporal_change_baselines.py tests/test_research_ledger.py tests/test_temporal_baseline_ledger_cli.pyandpython -m ruff check research_ledger tools/run_temporal_change_baselines.py tests/test_research_ledger.py tests/test_temporal_baseline_ledger_cli.py, both of which passed after minor fixes.python -m compileall -q .andgit diff --checkto ensure byte-compile and whitespace checks passed.PYTHONPATHto system-provided packages so the core ledger tests and CLI integration tests could be exercised in CI-like CPU settings.Codex Task