Skip to content

Commit c8aa443

Browse files
committed
Replay original learning provenance with bounded immutable artifact copies
1 parent 57291ad commit c8aa443

8 files changed

Lines changed: 884 additions & 2 deletions

File tree

‎.github/workflows/ci.yml‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ jobs:
5858
python -m tests.full_bundle --output runs/ci-full-bundle
5959
python -m tests.numerical_bundle --output runs/ci-numerical-bundle
6060
python -m tests.bundle_integrity --output runs/ci-bundle-integrity
61+
python -m tests.bundle_copy --output runs/ci-bundle-copy
62+
python -m tests.learning_bundle --output runs/ci-learning-bundle
6163
python -m tests.acceptance_readiness --output runs/ci-acceptance-readiness
6264
python -m tests.rules_replay --engine build/caissa --output runs/ci-rules-replay
6365
python -m tests.protocol_bundle --engine build/caissa --output runs/ci-protocol-bundle
@@ -122,6 +124,9 @@ jobs:
122124
runs/ci-numerical-bundle/*.json
123125
runs/ci-numerical-bundle/*.log
124126
runs/ci-bundle-integrity/CONTROLS.json
127+
runs/ci-bundle-copy/*.json
128+
runs/ci-learning-bundle/*.json
129+
runs/ci-learning-bundle/*.log
125130
runs/ci-acceptance-readiness/CONTROLS.json
126131
runs/ci-rules-replay/
127132
runs/ci-protocol-bundle/

‎docs/LEARNING_BUNDLE.md‎

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Original learning replay component
2+
3+
The `original-learning-v1` G07 driver replays the original three training runs.
4+
It retains the actual frozen v3 protocol, MODEL_CAMPAIGN.json, validation-only
5+
SELECTION.json, original q1024 network and selected float checkpoint. It does
6+
not rewrite a receipt to describe the deployed q4096 network. Both encodings
7+
must name the same validation-selected float checkpoint, and the original
8+
failed numerical domains remain visible in the lineage record.
9+
10+
The `original_learning` descriptor references its original `protocol`,
11+
`model_campaign`, `network` and `checkpoint`, plus complete `dataset`,
12+
`baseline` and `seeds` inventories. The dataset component supplies train
13+
features and validation features/targets. Test arrays are forbidden here.
14+
Each of seeds17/41/73 supplies its original configuration, initialization,
15+
initial identity, observations, summary and all80 chronological checkpoints.
16+
The original transaction metadata must name the actual best/last bytes.
17+
All files must be present in the immutable manifest and G07's declared inputs.
18+
19+
Large arrays and checkpoints stream into new external files through verified
20+
file descriptors, with one-megabyte reads, original byte/time ceilings and
21+
before/after identity checks. The independently implemented learning reader
22+
then checks initialization ancestry, optimizer/sampler/configuration state,
23+
all240 saved validation results, the original classical baseline, actual
24+
parameter changes and validation-only selection. It performs no training.
25+
The caller's original cumulative wall/active deadline bounds the entire child.
26+
Input file stamps are checked again after execution.
27+
28+
A successful learning replay is a G07 component pass, never a complete G07
29+
pass. The full original-data reconstruction must independently pass and join
30+
the same dataset identity. The coordinator keeps G07 pending until that joint
31+
audit exists. A failed loss-improvement endpoint stays failed with its actual
32+
observations; process and artifact failures are rejected.
33+
34+
The hosted controls admit only the real published original lineage, then use
35+
the actual full command to reject rewritten receipts, changed protocols or
36+
selection, a borrowed deployment network, different float parameters, changed
37+
training settings, missing raw work, test-array inputs, omitted seeds and
38+
missing checkpoints. Their fixtures never evaluate a tensor or certify a
39+
learning component. Full-size replay and the data join remain required.

‎tests/bundle_copy.py‎

Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
"""Actual bounded-memory copies and immutable-read/overwrite rejection controls."""
2+
3+
import argparse
4+
import hashlib
5+
import json
6+
import tempfile
7+
import time
8+
import tracemalloc
9+
from pathlib import Path
10+
11+
from tests.bundle_integrity import rejected
12+
from verification.bundle import Bundle
13+
14+
15+
def main():
16+
parser = argparse.ArgumentParser()
17+
parser.add_argument("--output", type=Path, required=True)
18+
args = parser.parse_args()
19+
args.output.mkdir(parents=True, exist_ok=False)
20+
cases = []
21+
with tempfile.TemporaryDirectory(prefix="caissa-stream-copy-") as temporary:
22+
root = Path(temporary) / "evidence"
23+
root.mkdir()
24+
payload = b"original-evidence\n" * 524288
25+
source = root / "raw.bin"
26+
source.write_bytes(payload)
27+
sha = hashlib.sha256(payload).hexdigest()
28+
(root / "MANIFEST.json").write_text(json.dumps({"files": {"raw.bin": sha}}))
29+
destination = Path(temporary) / "copy.bin"
30+
with Bundle(root, 20) as bundle:
31+
bundle.verify_manifest()
32+
tracemalloc.start()
33+
copied = bundle.copy("raw.bin", destination, 16 * 1024**2)
34+
_, peak = tracemalloc.get_traced_memory()
35+
tracemalloc.stop()
36+
assert copied == {"bytes": len(payload), "sha256": sha}
37+
assert peak < 4 * 1024**2, peak
38+
assert destination.read_bytes() == payload
39+
cases.append(
40+
{
41+
"case": "actual-stream-copy",
42+
"bytes": len(payload),
43+
"peak_python_bytes": peak,
44+
}
45+
)
46+
cases.append(
47+
{
48+
"case": "no-overwrite",
49+
"reason": rejected(
50+
lambda: bundle.copy("raw.bin", destination), None
51+
),
52+
}
53+
)
54+
assert destination.read_bytes() == payload
55+
cases.append(
56+
{
57+
"case": "preserve-original-root",
58+
"reason": rejected(
59+
lambda: bundle.copy("raw.bin", root / "extra.bin"),
60+
"preserve the original",
61+
),
62+
}
63+
)
64+
cases.append(
65+
{
66+
"case": "copy-byte-ceiling",
67+
"reason": rejected(
68+
lambda: bundle.copy(
69+
"raw.bin", Path(temporary) / "too-large", 1024
70+
),
71+
"byte ceiling",
72+
),
73+
}
74+
)
75+
cases.append(
76+
{
77+
"case": "typed-byte-ceiling",
78+
"reason": rejected(
79+
lambda: bundle.copy(
80+
"raw.bin", Path(temporary) / "bool-bound", True
81+
),
82+
"byte ceiling",
83+
),
84+
}
85+
)
86+
source.write_bytes(b"changed evidence\n")
87+
cases.append(
88+
{
89+
"case": "changed-after-manifest",
90+
"reason": rejected(
91+
lambda: bundle.copy("raw.bin", Path(temporary) / "changed"),
92+
"changed after manifest",
93+
),
94+
}
95+
)
96+
source.unlink()
97+
source.symlink_to(destination)
98+
cases.append(
99+
{
100+
"case": "linked-source",
101+
"reason": rejected(
102+
lambda: bundle.copy("raw.bin", Path(temporary) / "linked"), None
103+
),
104+
}
105+
)
106+
source.unlink()
107+
source.write_bytes(payload)
108+
with Bundle(root, 20) as bundle:
109+
cases.append(
110+
{
111+
"case": "unverified-source",
112+
"reason": rejected(
113+
lambda: bundle.copy("raw.bin", Path(temporary) / "unverified"),
114+
"verified manifest",
115+
),
116+
}
117+
)
118+
bundle.verify_manifest()
119+
bundle.wall_deadline = time.time() - 1
120+
cases.append(
121+
{
122+
"case": "original-deadline",
123+
"reason": rejected(
124+
lambda: bundle.copy("raw.bin", Path(temporary) / "expired"),
125+
"deadline exhausted",
126+
),
127+
}
128+
)
129+
value = {
130+
"status": "passed",
131+
"cases": cases,
132+
"full_acceptance": False,
133+
"scope": "Synthetic immutable streaming-copy controls; no model/native execution",
134+
}
135+
(args.output / "CONTROLS.json").write_text(json.dumps(value, indent=2) + "\n")
136+
print(json.dumps(value))
137+
138+
139+
if __name__ == "__main__":
140+
main()

0 commit comments

Comments
 (0)