mirror of
https://github.com/razzant/ouroboros.git
synced 2026-10-03 04:07:04 +00:00
Integrate installer source ee2a3bd78079b4ca1dc41e9202abf0fc0306324a over the lifecycle layer, including the exact owner-approved Install spec policy paragraph. The two supplied lifecycle classification rows were already carried in the preceding commit and are not duplicated. Use the existing dependency owner for exact resources, explicit source/postinstall actions and retained caches. Share exact byte delivery with the engine caller, and preserve literal Go/Deno arguments, permissions, exit status and process lifetime. Validation: 31 real resource/build/runtime/cancel/binary controls passed, with unchanged Ruby execution skipped because its runtime is absent; 88 dependency/engine/payload neighbors passed. Whole-tree Ruff F, size, inventories and domains passed. No live installation or shared packages changed.
46 lines
2.1 KiB
Python
46 lines
2.1 KiB
Python
"""Existing binary review descriptors survive delegated payload capture/apply."""
|
|
import hashlib
|
|
import json
|
|
from pathlib import Path
|
|
import struct
|
|
import zlib
|
|
|
|
import pytest
|
|
|
|
from ouroboros import delegate_custody as custody
|
|
from ouroboros.subagent_worktrees import find_execution_snapshot
|
|
from ouroboros.tools.delegate import _capture_terminal_patch
|
|
from ouroboros.tools.subagent_integration import _integrate_delegated_patch
|
|
from tests.test_delegated_skill_payload import _payload_entry, _provisioned
|
|
|
|
pytestmark = pytest.mark.serial
|
|
|
|
|
|
def test_binary_resource_capture_apply_preserves_exact_bytes_and_control_state(tmp_path, monkeypatch):
|
|
ctx, skill, handle = _provisioned(tmp_path, monkeypatch)
|
|
snapshot = Path(handle.path)
|
|
def chunk(kind, body):
|
|
return struct.pack('!I', len(body)) + kind + body + struct.pack('!I', zlib.crc32(kind + body))
|
|
png = (b'\x89PNG\r\n\x1a\n' + chunk(b'IHDR', struct.pack('!2I5B', 1, 1, 8, 2, 0, 0, 0))
|
|
+ chunk(b'IDAT', zlib.compress(b'\0\xff\0\0')) + chunk(b'IEND', b''))
|
|
(snapshot / 'image.png').write_bytes(png)
|
|
state = ctx.drive_root / 'state/skills/alpha'
|
|
state.mkdir(parents=True, exist_ok=True)
|
|
grants = state / 'grants.json'
|
|
grants.write_text('{"granted_keys":[]}\n')
|
|
original_grants = grants.read_bytes()
|
|
entry = _payload_entry(handle, skill)
|
|
try:
|
|
capture = _capture_terminal_patch(ctx, entry)
|
|
assert capture['status'] == 'ready_with_changes', capture
|
|
manifest = json.loads(Path(capture['manifest_artifact']).read_text())
|
|
assert manifest['binary_files'] == [{'path': 'image.png', 'size': len(png), 'mime_from_name': 'image/png',
|
|
'sha256': hashlib.sha256(png).hexdigest()}]
|
|
result = _integrate_delegated_patch(ctx, 'run-p1', 'apply', 'preserve the reviewed image')
|
|
assert '✅ Integrated' in result, result
|
|
assert (skill / 'image.png').read_bytes() == png
|
|
assert grants.read_bytes() == original_grants
|
|
assert not (skill / '.git').exists()
|
|
assert find_execution_snapshot('snapP') is None
|
|
finally:
|
|
custody._CUSTODY.clear()
|