Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ jobs:
- run: build/workspace-training/bin/python -m unittest discover -s tests -p test_pointclouds.py
- run: build/workspace-training/bin/python -m unittest discover -s tests -p test_volume_assets.py
- run: build/workspace-training/bin/python -m unittest discover -s tests -p test_rheon_cpu_training.py
- run: build/workspace-training/bin/python -m unittest discover -s tests -p test_rheon_evaluation.py
- run: python -m unittest discover -s tests
- run: node --check static/auth.js
- run: node tests/test_auth_helpers.cjs
Expand Down
391 changes: 391 additions & 0 deletions adapters/rheon/evaluate.py

Large diffs are not rendered by default.

74 changes: 74 additions & 0 deletions adapters/rheon/evaluation_project.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
"""Assemble evaluation sources; inputs are selected from one completed training Run."""
import argparse
import os
from pathlib import Path
import shutil
import uuid

if __package__:
from . import evaluate, cpu_compare, generate
else:
import evaluate
import cpu_compare
import generate


def definition(sources,snapshot):
evaluate.require(type(snapshot) is str and generate.HASH.fullmatch(snapshot),'Runtime snapshot SHA256 required.')
native='lab/target/release/rheon-trajectory-parallel'
arguments=[]
for slot in evaluate.INPUTS:arguments.extend([{'literal':'--'+slot.replace('_','-')},{'input':slot}])
for name,token in [('build-receipt',{'input':'build_receipt'}),('native-policy',{'native_policy':native}),
('input-evidence',{'input_evidence':True}),('runtime-snapshot-sha256',{'literal':snapshot}),
('output',{'output_dir':True})]:arguments.extend([{'literal':'--'+name},token])
return {'schema_version':1,'format':'external_recipe_v1','id':'rheon-autonomous-evaluation',
'name':'Rheon autonomous CPU evaluation','version':1,'runtime':'captured_cpu_python_v1',
'runtime_snapshot_sha256':snapshot,'sources':[{'path':name,'sha256':generate.sha(raw)} for name,raw in sorted(sources.items())],
'native_sources':[native],'entrypoint':'evaluate.py','arguments':arguments,'parameters':{},
'inputs':{**{name:{'max_bytes':cap} for name,(_role,cap) in evaluate.INPUTS.items()},'build_receipt':{'max_bytes':1024*1024}},
'outputs':[{'path':name,'role':role,'max_bytes':cap,'required':True} for name,role,cap in evaluate.outputs()],
'environment':{},'resources':{'profile':'captured_cpu_large_outputs_v1','wall_seconds':2400,'max_output_bytes':evaluate.TOTAL_LIMIT}}


def assemble(lab_root,binary,build_receipt,runtime_snapshot_sha256,destination):
lab=Path(lab_root);adapter=Path(__file__).parent
native=generate.capture(binary,8*1024*1024)[0];build=generate.capture(build_receipt,1024*1024)[0]
evaluate.require(generate.sha(native)==cpu_compare.BINARY_SHA256 and generate.sha(build)==cpu_compare.BUILD_RECEIPT_SHA256,
'Qualified parallel build required.')
sources={'lab/target/release/rheon-trajectory-parallel':native}
for name,digest in cpu_compare.SOURCES.items():
raw=generate.capture(lab/'scripts'/name,65536)[0]
evaluate.require(generate.sha(raw)==digest,'Original numerical source differs.')
sources['lab/scripts/'+name]=raw
for name in ('evaluate.py','cpu_compare.py','generate.py','native_transport.py'):
sources[name]=generate.capture(adapter/name,256*1024)[0]
recipe=generate.encode(definition(sources,runtime_snapshot_sha256))
manifest={'schema_version':1,'id':uuid.uuid4().hex,'name':'Rheon autonomous CPU evaluation',
'data':[{'id':'build_receipt','label':'Parallel build evidence','path':'build-receipt.json','sha256':generate.sha(build)}],
'recipes':[{'id':'evaluate','label':'Evaluate completed training checkpoint','path':'recipe.json','sha256':generate.sha(recipe)}],
'evidence':[],'requirements':[{'id':'completed-training','label':'Bind four verified artifacts from one completed training Run'}]}
files={**sources,'build-receipt.json':build,'recipe.json':recipe,'project.json':generate.encode(manifest)}
destination=Path(destination);destination.mkdir(mode=0o700,exist_ok=False)
try:
for name,raw in files.items():
path=destination/name;path.parent.mkdir(parents=True,exist_ok=True)
with path.open('xb') as handle:
handle.write(raw);handle.flush();os.fchmod(handle.fileno(),0o400);os.fsync(handle.fileno())
for directory in [*sorted((p for p in destination.rglob('*') if p.is_dir()),reverse=True),destination]:
fd=os.open(directory,os.O_RDONLY|os.O_DIRECTORY)
try:os.fsync(fd)
finally:os.close(fd)
except BaseException:
shutil.rmtree(destination);raise
return manifest


def main():
parser=argparse.ArgumentParser(description=__doc__)
for name in ('lab-root','binary','build-receipt','runtime-snapshot-sha256','destination'):parser.add_argument('--'+name,required=True)
args=parser.parse_args()
manifest=assemble(args.lab_root,args.binary,args.build_receipt,args.runtime_snapshot_sha256,args.destination)
print(generate.encode({'project_id':manifest['id'],'manifest':str(Path(args.destination)/'project.json')}).decode())


if __name__=='__main__':main()
12 changes: 10 additions & 2 deletions adapters/rheon/native_transport.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,17 @@ def exact(stream, size):
class Transport:
PIPE = subprocess.PIPE

def __init__(self, binary, policy_raw, *, allowed_seeds=(900, 901, 902, 903), capture_diagnostics=False):
def __init__(self, binary, policy_raw, *, allowed_seeds=(900, 901, 902, 903), capture_diagnostics=False, evaluation_mode=False, capture_hook=None):
if type(allowed_seeds) is not tuple or allowed_seeds not in ((900, 901, 902, 903), (500, 501)):
raise ValueError('Unsupported reviewed native seed scope.')
if type(capture_diagnostics) is not bool:
raise ValueError('Invalid diagnostic capture flag.')
if type(evaluation_mode) is not bool or (capture_hook is not None and not callable(capture_hook)):
raise ValueError('Invalid evaluation capture hook.')
if (evaluation_mode and allowed_seeds != (900, 901, 902, 903)) or (capture_hook is not None and not evaluation_mode):
raise ValueError('Evaluation capture requires the closed evaluation seed scope.')
self.evaluation_mode = evaluation_mode
self.capture_hook = capture_hook
self.capture_diagnostics = capture_diagnostics
self.diagnostics = []
self.allowed_seeds = tuple(str(seed) for seed in allowed_seeds)
Expand Down Expand Up @@ -110,10 +116,12 @@ def wait_with_diagnostics(*wait_args, **wait_kwargs):
or ready.get('face_lengths') != [33*32*32]*3):
raise ValueError('Native READY differs from requested controls.')
maps = generate.mapping_evidence(process.pid, self.observed, native_fd, loader_fd)
if len(self.evidence) >= 64:
if len(self.evidence) >= (72 if getattr(self, 'evaluation_mode', False) else 64):
raise ValueError('Native launch count exceeds admitted comparison.')
self.evidence.append({'method': args[2], 'seed': int(args[3]), 'ready': ready, 'mappings': maps})
process.stdout = PrefixReader(header + raw, process.stdout)
if getattr(self, 'capture_hook', None) is not None:
process.stdout = self.capture_hook(args, process.stdout)
return process
except BaseException:
if process is not None:
Expand Down
24 changes: 22 additions & 2 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,24 @@ def reply(self, data, status=200, content_type='application/json', headers=()):
except (BrokenPipeError, ConnectionResetError):
pass

def reply_stream(self, stream, metadata):
# The owner has already verified a private spool before HTTP success.
self.send_response(200)
self.send_header('Content-Type', metadata['media_type'])
self.send_header('Content-Length', str(metadata['bytes']))
self.send_header('Cache-Control', 'no-store')
self.send_header('X-Content-Type-Options', 'nosniff')
self.end_headers()
try:
while True:
raw = stream.read(65536)
if not raw:
break
self.wfile.write(raw)
except (OSError, ConnectionError):
# Headers are committed; never append a JSON error to payload.
self.close_connection = True

def project_access(self):
# This opt-in file inspection surface is local-only until actor authentication.
host = urlsplit('http://' + self.headers.get('Host', '')).hostname
Expand Down Expand Up @@ -578,6 +596,8 @@ def _get(self):
return self.reply(dataset.pipelines.list())
if len(parts) == 2 and parts[0] == 'graphs':
return self.reply(dataset.pipelines.get(parts[1]))
if parts == ['run-artifact-inputs']:
return self.reply(dataset.runs.input_candidates())
if parts == ['runs']:
return self.reply(dataset.runs.list())
if len(parts) == 2 and parts[0] == 'runs':
Expand All @@ -588,8 +608,8 @@ def _get(self):
query = parse_qs(urlsplit(self.path).query)
return self.reply(dataset.runs.predictions(parts[1], query.get('split', ['validation'])[-1]))
if len(parts) == 4 and parts[0] == 'runs' and parts[2] == 'artifacts':
data, media_type = dataset.runs.artifact(parts[1], parts[3])
return self.reply(data, content_type=media_type)
with dataset.runs.open_artifact(parts[1], parts[3]) as (stream, metadata):
return self.reply_stream(stream, metadata)
return self.reply({'error': 'Workspace route not found.', 'code': 'not_found'}, 404)
if path == '/api/workbench/releases/input-candidates':
return self.reply(dataset.releases.input_candidates())
Expand Down
12 changes: 12 additions & 0 deletions docs/contracts/captured-cpu-runtime.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,3 +110,15 @@ original descriptor and specification after relocation; new execution resolves t
current snapshot root and requires fresh approval. Hash custody is not scientific
acceptance. Actual CPU computation, checkpoint compatibility, numerical gates and
UI workflows require their own qualification evidence.

## Optional large-output resource profile

`resources.profile = "captured_cpu_large_outputs_v1"` selects bounded large
outputs only with the existing qualified captured CPU runtime. Helper validation
checks the complete descriptor/bootstrap before admitting 2400 seconds and
4 GiB aggregate outputs (at most 96 files, each at most 512 MiB). Default CPU and
system profiles retain their old shapes, limits and historical identities.
This extension does not enlarge captured input/source or diagnostic streams,
alter cancellation/drain deadlines, enable network isolation, or qualify GPU/JIT.
Actual recipes retain explicit smaller output budgets and require measured
capacity admission. See the external recipe contract for custody and downloads.
47 changes: 47 additions & 0 deletions docs/contracts/external-recipes.md
Original file line number Diff line number Diff line change
Expand Up @@ -227,3 +227,50 @@ artifacts remain readable even when separate staging diagnostics are unavailable
The UI labels metrics as recipe-reported, keeps logs/provenance in details and
uses the existing artifact download route. Neither stdout nor a filename suffix
can nominate a result or enable a checkpoint download.

## Completed-Run inputs and optional large CPU outputs

A new exact input binding is `{kind:"run_artifact", run_id, artifact_name,
expected_sha256}`. The existing Runs owner captures only a completed, drained,
same-catalog external artifact, verifies custody and payload bytes, and enforces
the declared input limit before reading. Failed, cancelled or unknown Runs are
ineligible. Its material receipt is `{kind:"run_artifact", source:<existing Run
artifact source receipt>}`; old project and frozen-release receipts are unchanged.
Cold validation reuses the custody owner's source validator without accessing
the original catalog. It checks internal retained relationships, not historical
database authenticity. Editing a binding invalidates material approval.

The optional argument token `{"input_evidence":true}` resolves to captured
`runtime-bootstrap/input-evidence.json`: canonical JSON mapping input slot names
to their exact typed material receipts. The generated bytes are hashed in capture
and recomputed during cold decoding. It carries no credentials or caller-authored
provenance. Definitions without this token gain no capture or identity field.

The explicit optional `resources.profile` value
`captured_cpu_large_outputs_v1` requires runtime `captured_cpu_python_v1`. Its
limits are 2400 wall seconds, 96 flat declared outputs, 512 MiB per file and 4 GiB
aggregate. Definitions still declare smaller per-file/aggregate limits as needed.
The helper's matching `resource_profile` field is accepted only with the verified
CPU descriptor/bootstrap. Old omitted-profile shapes and bounds are unchanged.
Input and source capture limits remain independent and unchanged from P5b.

Output verification and publication hash/copy bounded chunks and preserve the
existing manifest, receipt, fsync and completed-state sequence. Publication does
not rename or delete producer staging. Large downloads use one private anonymous
spool, fully verified before HTTP 200, then bounded transfer; failures/disconnects
close it. Current disk capacity is checked before large admission, publication
and spooling; this is not a filesystem reservation against concurrent writers.

For large-profile Runs only, list/get exposes receipt-verified inventory with
payloads explicitly not checked. Individual downloads/captures verify selected
bytes; full audit verifies every artifact. Small-profile reads keep their existing
whole-inventory verification semantics. A result summary verifies its own bytes
and referenced checkpoint, without certifying unrelated large field artifacts.
The UI labels recorded outputs as verified on download.

Inspect-authorized `GET /api/workspace/run-artifact-inputs` returns at most 100
completed external Runs with candidate artifacts at most 40 MiB. Receipt-verified
metadata is a selection hint; capture remains the byte authority. Closed Run rows
contain run_id, state, status, reason and artifacts. Available artifact rows contain
artifact_name, role, bytes, sha256 and status. Unavailable rows disclose no untrusted
artifact names. No classification holdout or arbitrary filesystem path is exposed.
Loading
Loading