........................................................................ [  8%]
........................................................................ [ 17%]
............s........................................................... [ 26%]
.................................................................F...... [ 35%]
..FF..................FF....................FF..FFFFFFF................. [ 44%]
........................................................................ [ 53%]
..........................................F............F................ [ 62%]
........................................................................ [ 71%]
............................................ssssss...................... [ 80%]
........................................................................ [ 89%]
........................................................................ [ 98%]
...............                                                          [100%]
=================================== FAILURES ===================================
___ test_actual_bound_child_gets_only_selected_secret_and_fixed_environment ____

bound = ({'id': 'test-lane', 'org': 'coulomb', 'repo': 'team-repo', 'stage': 'test', ...}, PosixPath('/tmp/pytest-of-worsch/py...nd_child_gets_o0/owner'), PosixPath('/tmp/pytest-of-worsch/pytest-207/test_actual_bound_child_gets_o0/owner/owner.sh'))
monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x756740d72750>
capsys = <_pytest.capture.CaptureFixture object at 0x756740d70da0>

    def test_actual_bound_child_gets_only_selected_secret_and_fixed_environment(bound, monkeypatch, capsys):
        data, private, _ = bound
        entry = validate_entry(data)
        for name in ["PARENT_CREDENTIAL", "BAO_TOKEN", "SECRETS_ENGINE_APPROVAL_CLIENT_SECRET_FILE", "PYTHONPATH"]:
            monkeypatch.setenv(name, "parent-sensitive-fixture")
        monkeypatch.setattr(exec_delivery, "_fetch_value", lambda *a, **k: "synthetic-owner-value")
>       assert exec_delivery.exec_with_secret(object(), entry, "api_token", data["delivery_config"]["exec_owner"]["command"], mode="exec-env", expected_owner_digest=owner_digest(entry)) == 0
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

tests/test_exec_owner.py:55: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
src/secrets_engine/exec_delivery.py:199: in exec_with_secret
    binding_digest = validate_delivery_target(entry, field, command, mode)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
src/secrets_engine/exec_owner.py:171: in validate_delivery_target
    _check_path(Path(binding["cwd"]), directory=True, private=True)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

path = PosixPath('/tmp/pytest-of-worsch/pytest-207/test_actual_bound_child_gets_o0/owner')
directory = True, private = True

    def _check_path(path: Path, *, directory: bool = False, private: bool = False) -> None:
        """No symlink or untrusted writable ancestor; root-owned sticky /tmp is safe."""
        for candidate in [*reversed(path.parents), path]:
            info = candidate.lstat()
            leaf = candidate == path
            is_dir = not leaf or directory
            if not (stat.S_ISDIR(info.st_mode) if is_dir else stat.S_ISREG(info.st_mode)):
                raise DeliveryError("exec owner path is not a regular file/directory")
            if info.st_uid not in {0, os.getuid()}:
>               raise DeliveryError("exec owner path has an untrusted owner")
E               secrets_engine.errors.DeliveryError: exec owner path has an untrusted owner

src/secrets_engine/exec_owner.py:146: DeliveryError
_______________ test_config_changed_during_fetch_does_not_launch _______________

bound = ({'id': 'test-lane', 'org': 'coulomb', 'repo': 'team-repo', 'stage': 'test', ...}, PosixPath('/tmp/pytest-of-worsch/py...nged_during_fet0/owner'), PosixPath('/tmp/pytest-of-worsch/pytest-207/test_config_changed_during_fet0/owner/owner.sh'))
monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x756740da8500>

    def test_config_changed_during_fetch_does_not_launch(bound, monkeypatch):
        data, _, script = bound
        entry = validate_entry(data)
        def fetch(*a, **k):
            script.write_text("changed during fetch")
            return "synthetic-owner-value"
        monkeypatch.setattr(exec_delivery, "_fetch_value", fetch)
        monkeypatch.setattr(exec_delivery, "_spawn", lambda *a, **k: pytest.fail("must not launch"))
>       with pytest.raises(DeliveryError, match="digest"):
E       AssertionError: Regex pattern did not match.
E         Expected regex: 'digest'
E         Actual message: 'exec owner path has an untrusted owner'

tests/test_exec_owner.py:91: AssertionError
___________ test_binding_changed_after_approval_refuses_before_fetch ___________

bound = ({'id': 'test-lane', 'org': 'coulomb', 'repo': 'team-repo', 'stage': 'test', ...}, PosixPath('/tmp/pytest-of-worsch/py...anged_after_app0/owner'), PosixPath('/tmp/pytest-of-worsch/pytest-207/test_binding_changed_after_app0/owner/owner.sh'))
monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x756740d5cbf0>

    def test_binding_changed_after_approval_refuses_before_fetch(bound, monkeypatch):
        data, _, _ = bound
        entry = validate_entry(data)
        expected = owner_digest(entry)
        entry.delivery_config["exec_owner"]["environment"]["LANG"] = "C"
        monkeypatch.setattr(exec_delivery, "_fetch_value", lambda *a, **k: pytest.fail("must not read"))
>       with pytest.raises(DeliveryError, match="after action admission"):
E       AssertionError: Regex pattern did not match.
E         Expected regex: 'after action admission'
E         Actual message: 'exec owner path has an untrusted owner'

tests/test_exec_owner.py:101: AssertionError
___________ test_companion_value_reaches_bound_child_and_is_redacted ___________

bound = ({'id': 'test-lane', 'org': 'coulomb', 'repo': 'team-repo', 'stage': 'test', ...}, PosixPath('/tmp/pytest-of-worsch/py...value_reaches_b0/owner'), PosixPath('/tmp/pytest-of-worsch/pytest-207/test_companion_value_reaches_b0/owner/owner.sh'))
monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x756741ef8b00>
capsys = <_pytest.capture.CaptureFixture object at 0x756741efa2a0>

    def test_companion_value_reaches_bound_child_and_is_redacted(bound, monkeypatch, capsys):
        data, _, script = bound
        script.write_text('''test "$API_TOKEN" = synthetic-owner-value || exit 10
    test "$WORKER_TOKEN" = synthetic-worker-value || exit 11
    read ignored && exit 15
    printf '%s %s\\n' "$API_TOKEN" "$WORKER_TOKEN"
    printf 'companion-child-ok\\n'
    ''')
        import hashlib
        data["delivery_config"]["exec_owner"]["files"][str(script)]["sha256"] = hashlib.sha256(script.read_bytes()).hexdigest()
        entry = validate_entry(_with_companion(data))
        lane = validate_entry(_companion())
        companions = resolve_companions(entry, _lookup(lane))
        values = {"test-lane": "synthetic-owner-value", "test-worker": "synthetic-worker-value"}
        seen = []
        def fetch(client, e, field, **kwargs):
            seen.append((e.id, field))
            return values[e.id]
        monkeypatch.setattr(exec_delivery, "_fetch_value", fetch)
        sessions = {}
>       rc = exec_delivery.exec_with_secret(
            object(), entry, "api_token", data["delivery_config"]["exec_owner"]["command"],
            mode="exec-env", expected_owner_digest=owner_digest(entry),
            companions=companions, companion_sessions=sessions,
        )

tests/test_exec_owner_companions.py:55: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
src/secrets_engine/exec_delivery.py:199: in exec_with_secret
    binding_digest = validate_delivery_target(entry, field, command, mode)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
src/secrets_engine/exec_owner.py:171: in validate_delivery_target
    _check_path(Path(binding["cwd"]), directory=True, private=True)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

path = PosixPath('/tmp/pytest-of-worsch/pytest-207/test_companion_value_reaches_b0/owner')
directory = True, private = True

    def _check_path(path: Path, *, directory: bool = False, private: bool = False) -> None:
        """No symlink or untrusted writable ancestor; root-owned sticky /tmp is safe."""
        for candidate in [*reversed(path.parents), path]:
            info = candidate.lstat()
            leaf = candidate == path
            is_dir = not leaf or directory
            if not (stat.S_ISDIR(info.st_mode) if is_dir else stat.S_ISREG(info.st_mode)):
                raise DeliveryError("exec owner path is not a regular file/directory")
            if info.st_uid not in {0, os.getuid()}:
>               raise DeliveryError("exec owner path has an untrusted owner")
E               secrets_engine.errors.DeliveryError: exec owner path has an untrusted owner

src/secrets_engine/exec_owner.py:146: DeliveryError
_________________ test_companion_fetch_failure_starts_no_child _________________

bound = ({'id': 'test-lane', 'org': 'coulomb', 'repo': 'team-repo', 'stage': 'test', ...}, PosixPath('/tmp/pytest-of-worsch/py...fetch_failure_s0/owner'), PosixPath('/tmp/pytest-of-worsch/pytest-207/test_companion_fetch_failure_s0/owner/owner.sh'))
monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x756741f37ec0>

    def test_companion_fetch_failure_starts_no_child(bound, monkeypatch):
        data, _, _ = bound
        entry = validate_entry(_with_companion(data))
        lane = validate_entry(_companion())
        def fetch(client, e, field, **kwargs):
            if e.id == "test-worker":
                raise DeliveryError("scoped read failed for lane 'test-worker' (denied or absent)")
            return "synthetic-owner-value"
        monkeypatch.setattr(exec_delivery, "_fetch_value", fetch)
        monkeypatch.setattr(exec_delivery, "_spawn", lambda *a, **k: pytest.fail("must not launch"))
>       with pytest.raises(DeliveryError, match="test-worker"):
E       AssertionError: Regex pattern did not match.
E         Expected regex: 'test-worker'
E         Actual message: 'exec owner path has an untrusted owner'

tests/test_exec_owner_companions.py:77: AssertionError
______________ test_each_lane_is_gated_separately_before_backend _______________

bound = ({'id': 'test-lane', 'org': 'coulomb', 'repo': 'team-repo', 'stage': 'test', ...}, PosixPath('/tmp/pytest-of-worsch/py...is_gated_separa0/owner'), PosixPath('/tmp/pytest-of-worsch/pytest-207/test_each_lane_is_gated_separa0/owner/owner.sh'))
monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x756741f36990>
tmp_path = PosixPath('/tmp/pytest-of-worsch/pytest-207/test_each_lane_is_gated_separa0')

    def test_each_lane_is_gated_separately_before_backend(bound, monkeypatch, tmp_path):
        data, _, _ = bound
        entry = validate_entry(_with_companion(data))
        lane = validate_entry(_companion())
        table = {entry.id: entry, lane.id: lane}
        monkeypatch.setattr(cli, "get_entry", lambda _dir, cid: table[cid])
        gated = []
        def gate(cfg, e, action, evidence, *, fields=(), auth_args=None):
            assert auth_args is args
            gated.append((e.id, action, fields))
            if e.id == "test-worker":
                raise DeliveryError("companion lane denied")
            return SimpleNamespace(status="approved")
        monkeypatch.setattr(cli, "_require_lane_approval", gate)
        monkeypatch.setattr(cli, "require_delivery_state", lambda *a: None)
        monkeypatch.setattr(cli, "_open_backend", lambda *a, **k: pytest.fail("no backend after a lane refusal"))
        command = data["delivery_config"]["exec_owner"]["command"]
        args = SimpleNamespace(field=None, catalog=entry.id, command=command, mode="exec-env")
>       with pytest.raises(DeliveryError, match="companion lane denied"):
E       AssertionError: Regex pattern did not match.
E         Expected regex: 'companion lane denied'
E         Actual message: 'exec owner path has an untrusted owner'

tests/test_exec_owner_companions.py:166: AssertionError
_____________ test_unresolvable_companion_refuses_before_any_gate ______________

bound = ({'id': 'test-lane', 'org': 'coulomb', 'repo': 'team-repo', 'stage': 'test', ...}, PosixPath('/tmp/pytest-of-worsch/py...le_companion_re0/owner'), PosixPath('/tmp/pytest-of-worsch/pytest-207/test_unresolvable_companion_re0/owner/owner.sh'))
monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x756741f37bf0>
tmp_path = PosixPath('/tmp/pytest-of-worsch/pytest-207/test_unresolvable_companion_re0')

    def test_unresolvable_companion_refuses_before_any_gate(bound, monkeypatch, tmp_path):
        data, _, _ = bound
        entry = validate_entry(_with_companion(data))
        def get(_dir, cid):
            if cid == entry.id:
                return entry
            raise KeyError(cid)
        monkeypatch.setattr(cli, "get_entry", get)
        monkeypatch.setattr(cli, "_require_lane_approval", lambda *a, **k: pytest.fail("no gate"))
        monkeypatch.setattr(cli, "_open_backend", lambda *a, **k: pytest.fail("no backend"))
        command = data["delivery_config"]["exec_owner"]["command"]
>       with pytest.raises(DeliveryError, match="unavailable"):
E       AssertionError: Regex pattern did not match.
E         Expected regex: 'unavailable'
E         Actual message: 'exec owner path has an untrusted owner'

tests/test_exec_owner_companions.py:182: AssertionError
______ test_delivery_rechecks_companion_contract_before_any_read[missing] ______

bound = ({'id': 'test-lane', 'org': 'coulomb', 'repo': 'team-repo', 'stage': 'test', ...}, PosixPath('/tmp/pytest-of-worsch/py...echecks_compani0/owner'), PosixPath('/tmp/pytest-of-worsch/pytest-207/test_delivery_rechecks_compani0/owner/owner.sh'))
monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x756740d5c860>
change = 'missing'

    @pytest.mark.parametrize("change", ["missing", "extra", "env", "field", "lane", "consent", "stage"])
    def test_delivery_rechecks_companion_contract_before_any_read(bound, monkeypatch, change):
        data, _, _ = bound
        entry = validate_entry(_with_companion(data))
        lane_data = _companion()
        if change == "consent":
            lane_data["delivery_config"] = {}
        elif change == "stage":
            lane_data.update(stage="build", path="build/team/worker")
        elif change == "lane":
            lane_data["id"] = "another-worker"
        lane = validate_entry(lane_data)
        companions = [(lane, "worker_token", "WORKER_TOKEN")]
        if change == "missing": companions = []
        elif change == "extra": companions *= 2
        elif change == "env": companions = [(lane, "worker_token", "API_TOKEN")]
        elif change == "field": companions = [(lane, "other_field", "WORKER_TOKEN")]
        monkeypatch.setattr(exec_delivery, "_fetch_value", lambda *a, **k: pytest.fail("no read"))
        monkeypatch.setattr(exec_delivery, "_spawn", lambda *a, **k: pytest.fail("no child"))
>       with pytest.raises(DeliveryError, match="companion"):
E       AssertionError: Regex pattern did not match.
E         Expected regex: 'companion'
E         Actual message: 'exec owner path has an untrusted owner'

tests/test_exec_owner_companions.py:223: AssertionError
_______ test_delivery_rechecks_companion_contract_before_any_read[extra] _______

bound = ({'id': 'test-lane', 'org': 'coulomb', 'repo': 'team-repo', 'stage': 'test', ...}, PosixPath('/tmp/pytest-of-worsch/py...echecks_compani1/owner'), PosixPath('/tmp/pytest-of-worsch/pytest-207/test_delivery_rechecks_compani1/owner/owner.sh'))
monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x756740d5d9a0>
change = 'extra'

    @pytest.mark.parametrize("change", ["missing", "extra", "env", "field", "lane", "consent", "stage"])
    def test_delivery_rechecks_companion_contract_before_any_read(bound, monkeypatch, change):
        data, _, _ = bound
        entry = validate_entry(_with_companion(data))
        lane_data = _companion()
        if change == "consent":
            lane_data["delivery_config"] = {}
        elif change == "stage":
            lane_data.update(stage="build", path="build/team/worker")
        elif change == "lane":
            lane_data["id"] = "another-worker"
        lane = validate_entry(lane_data)
        companions = [(lane, "worker_token", "WORKER_TOKEN")]
        if change == "missing": companions = []
        elif change == "extra": companions *= 2
        elif change == "env": companions = [(lane, "worker_token", "API_TOKEN")]
        elif change == "field": companions = [(lane, "other_field", "WORKER_TOKEN")]
        monkeypatch.setattr(exec_delivery, "_fetch_value", lambda *a, **k: pytest.fail("no read"))
        monkeypatch.setattr(exec_delivery, "_spawn", lambda *a, **k: pytest.fail("no child"))
>       with pytest.raises(DeliveryError, match="companion"):
E       AssertionError: Regex pattern did not match.
E         Expected regex: 'companion'
E         Actual message: 'exec owner path has an untrusted owner'

tests/test_exec_owner_companions.py:223: AssertionError
________ test_delivery_rechecks_companion_contract_before_any_read[env] ________

bound = ({'id': 'test-lane', 'org': 'coulomb', 'repo': 'team-repo', 'stage': 'test', ...}, PosixPath('/tmp/pytest-of-worsch/py...echecks_compani2/owner'), PosixPath('/tmp/pytest-of-worsch/pytest-207/test_delivery_rechecks_compani2/owner/owner.sh'))
monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x756741ec4800>
change = 'env'

    @pytest.mark.parametrize("change", ["missing", "extra", "env", "field", "lane", "consent", "stage"])
    def test_delivery_rechecks_companion_contract_before_any_read(bound, monkeypatch, change):
        data, _, _ = bound
        entry = validate_entry(_with_companion(data))
        lane_data = _companion()
        if change == "consent":
            lane_data["delivery_config"] = {}
        elif change == "stage":
            lane_data.update(stage="build", path="build/team/worker")
        elif change == "lane":
            lane_data["id"] = "another-worker"
        lane = validate_entry(lane_data)
        companions = [(lane, "worker_token", "WORKER_TOKEN")]
        if change == "missing": companions = []
        elif change == "extra": companions *= 2
        elif change == "env": companions = [(lane, "worker_token", "API_TOKEN")]
        elif change == "field": companions = [(lane, "other_field", "WORKER_TOKEN")]
        monkeypatch.setattr(exec_delivery, "_fetch_value", lambda *a, **k: pytest.fail("no read"))
        monkeypatch.setattr(exec_delivery, "_spawn", lambda *a, **k: pytest.fail("no child"))
>       with pytest.raises(DeliveryError, match="companion"):
E       AssertionError: Regex pattern did not match.
E         Expected regex: 'companion'
E         Actual message: 'exec owner path has an untrusted owner'

tests/test_exec_owner_companions.py:223: AssertionError
_______ test_delivery_rechecks_companion_contract_before_any_read[field] _______

bound = ({'id': 'test-lane', 'org': 'coulomb', 'repo': 'team-repo', 'stage': 'test', ...}, PosixPath('/tmp/pytest-of-worsch/py...echecks_compani3/owner'), PosixPath('/tmp/pytest-of-worsch/pytest-207/test_delivery_rechecks_compani3/owner/owner.sh'))
monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x756741ec4260>
change = 'field'

    @pytest.mark.parametrize("change", ["missing", "extra", "env", "field", "lane", "consent", "stage"])
    def test_delivery_rechecks_companion_contract_before_any_read(bound, monkeypatch, change):
        data, _, _ = bound
        entry = validate_entry(_with_companion(data))
        lane_data = _companion()
        if change == "consent":
            lane_data["delivery_config"] = {}
        elif change == "stage":
            lane_data.update(stage="build", path="build/team/worker")
        elif change == "lane":
            lane_data["id"] = "another-worker"
        lane = validate_entry(lane_data)
        companions = [(lane, "worker_token", "WORKER_TOKEN")]
        if change == "missing": companions = []
        elif change == "extra": companions *= 2
        elif change == "env": companions = [(lane, "worker_token", "API_TOKEN")]
        elif change == "field": companions = [(lane, "other_field", "WORKER_TOKEN")]
        monkeypatch.setattr(exec_delivery, "_fetch_value", lambda *a, **k: pytest.fail("no read"))
        monkeypatch.setattr(exec_delivery, "_spawn", lambda *a, **k: pytest.fail("no child"))
>       with pytest.raises(DeliveryError, match="companion"):
E       AssertionError: Regex pattern did not match.
E         Expected regex: 'companion'
E         Actual message: 'exec owner path has an untrusted owner'

tests/test_exec_owner_companions.py:223: AssertionError
_______ test_delivery_rechecks_companion_contract_before_any_read[lane] ________

bound = ({'id': 'test-lane', 'org': 'coulomb', 'repo': 'team-repo', 'stage': 'test', ...}, PosixPath('/tmp/pytest-of-worsch/py...echecks_compani4/owner'), PosixPath('/tmp/pytest-of-worsch/pytest-207/test_delivery_rechecks_compani4/owner/owner.sh'))
monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x756741ec7b60>
change = 'lane'

    @pytest.mark.parametrize("change", ["missing", "extra", "env", "field", "lane", "consent", "stage"])
    def test_delivery_rechecks_companion_contract_before_any_read(bound, monkeypatch, change):
        data, _, _ = bound
        entry = validate_entry(_with_companion(data))
        lane_data = _companion()
        if change == "consent":
            lane_data["delivery_config"] = {}
        elif change == "stage":
            lane_data.update(stage="build", path="build/team/worker")
        elif change == "lane":
            lane_data["id"] = "another-worker"
        lane = validate_entry(lane_data)
        companions = [(lane, "worker_token", "WORKER_TOKEN")]
        if change == "missing": companions = []
        elif change == "extra": companions *= 2
        elif change == "env": companions = [(lane, "worker_token", "API_TOKEN")]
        elif change == "field": companions = [(lane, "other_field", "WORKER_TOKEN")]
        monkeypatch.setattr(exec_delivery, "_fetch_value", lambda *a, **k: pytest.fail("no read"))
        monkeypatch.setattr(exec_delivery, "_spawn", lambda *a, **k: pytest.fail("no child"))
>       with pytest.raises(DeliveryError, match="companion"):
E       AssertionError: Regex pattern did not match.
E         Expected regex: 'companion'
E         Actual message: 'exec owner path has an untrusted owner'

tests/test_exec_owner_companions.py:223: AssertionError
______ test_delivery_rechecks_companion_contract_before_any_read[consent] ______

bound = ({'id': 'test-lane', 'org': 'coulomb', 'repo': 'team-repo', 'stage': 'test', ...}, PosixPath('/tmp/pytest-of-worsch/py...echecks_compani5/owner'), PosixPath('/tmp/pytest-of-worsch/pytest-207/test_delivery_rechecks_compani5/owner/owner.sh'))
monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x756741f37b60>
change = 'consent'

    @pytest.mark.parametrize("change", ["missing", "extra", "env", "field", "lane", "consent", "stage"])
    def test_delivery_rechecks_companion_contract_before_any_read(bound, monkeypatch, change):
        data, _, _ = bound
        entry = validate_entry(_with_companion(data))
        lane_data = _companion()
        if change == "consent":
            lane_data["delivery_config"] = {}
        elif change == "stage":
            lane_data.update(stage="build", path="build/team/worker")
        elif change == "lane":
            lane_data["id"] = "another-worker"
        lane = validate_entry(lane_data)
        companions = [(lane, "worker_token", "WORKER_TOKEN")]
        if change == "missing": companions = []
        elif change == "extra": companions *= 2
        elif change == "env": companions = [(lane, "worker_token", "API_TOKEN")]
        elif change == "field": companions = [(lane, "other_field", "WORKER_TOKEN")]
        monkeypatch.setattr(exec_delivery, "_fetch_value", lambda *a, **k: pytest.fail("no read"))
        monkeypatch.setattr(exec_delivery, "_spawn", lambda *a, **k: pytest.fail("no child"))
>       with pytest.raises(DeliveryError, match="companion"):
E       AssertionError: Regex pattern did not match.
E         Expected regex: 'companion'
E         Actual message: 'exec owner path has an untrusted owner'

tests/test_exec_owner_companions.py:223: AssertionError
_______ test_delivery_rechecks_companion_contract_before_any_read[stage] _______

bound = ({'id': 'test-lane', 'org': 'coulomb', 'repo': 'team-repo', 'stage': 'test', ...}, PosixPath('/tmp/pytest-of-worsch/py...echecks_compani6/owner'), PosixPath('/tmp/pytest-of-worsch/pytest-207/test_delivery_rechecks_compani6/owner/owner.sh'))
monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x756741f34200>
change = 'stage'

    @pytest.mark.parametrize("change", ["missing", "extra", "env", "field", "lane", "consent", "stage"])
    def test_delivery_rechecks_companion_contract_before_any_read(bound, monkeypatch, change):
        data, _, _ = bound
        entry = validate_entry(_with_companion(data))
        lane_data = _companion()
        if change == "consent":
            lane_data["delivery_config"] = {}
        elif change == "stage":
            lane_data.update(stage="build", path="build/team/worker")
        elif change == "lane":
            lane_data["id"] = "another-worker"
        lane = validate_entry(lane_data)
        companions = [(lane, "worker_token", "WORKER_TOKEN")]
        if change == "missing": companions = []
        elif change == "extra": companions *= 2
        elif change == "env": companions = [(lane, "worker_token", "API_TOKEN")]
        elif change == "field": companions = [(lane, "other_field", "WORKER_TOKEN")]
        monkeypatch.setattr(exec_delivery, "_fetch_value", lambda *a, **k: pytest.fail("no read"))
        monkeypatch.setattr(exec_delivery, "_spawn", lambda *a, **k: pytest.fail("no child"))
>       with pytest.raises(DeliveryError, match="companion"):
E       AssertionError: Regex pattern did not match.
E         Expected regex: 'companion'
E         Actual message: 'exec owner path has an untrusted owner'

tests/test_exec_owner_companions.py:223: AssertionError
_ test_real_exec_handler_rejects_undeclared_claim_before_consume_backend_child _

bound = ({'id': 'test-lane', 'org': 'coulomb', 'repo': 'team-repo', 'stage': 'prod', ...}, PosixPath('/tmp/pytest-of-worsch/py...handler_rejects0/owner'), PosixPath('/tmp/pytest-of-worsch/pytest-207/test_real_exec_handler_rejects0/owner/owner.sh'))
tmp_path = PosixPath('/tmp/pytest-of-worsch/pytest-207/test_real_exec_handler_rejects0')
monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x756741eef5f0>

    def test_real_exec_handler_rejects_undeclared_claim_before_consume_backend_child(bound, tmp_path, monkeypatch):
        raw, _, _ = bound
        raw["stage"] = "prod"
        raw["approval"].update(model="decision", authorization_id=APPROVAL_ID,
                               purpose="contract-test", human_control=True)
        entry = validate_entry(raw)
        cfg = replace(_config(tmp_path), approval_url="https://approval.example",
                      approval_token_file=_token(tmp_path), authorization_subject_id="user:alice",
                      authorization_subject_type="Human")
        claim = _served(entry, action="exec")
        monkeypatch.setattr(cli, "get_entry", lambda *a: entry)
        monkeypatch.setattr(cli, "authorize_action", lambda *a, **k: authorize_action(*a, **k,
            opener=_opener(claim), pdp_opener=lambda *a, **k: pytest.fail("must not check")))
        for name in ("require_production_consume", "_open_backend"):
            monkeypatch.setattr(cli, name, lambda *a, **k: pytest.fail("must not consume or open backend"))
        with pytest.raises(DecisionError, match="human_control"):
>           cli.cmd_exec(cfg, SimpleNamespace(catalog=entry.id, field="api_token", mode="exec-env",
                command=raw["delivery_config"]["exec_owner"]["command"]))

tests/test_human_control.py:161: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
src/secrets_engine/cli.py:569: in cmd_exec
    owner_digest = validate_delivery_target(entry, field, args.command, args.mode)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
src/secrets_engine/exec_owner.py:171: in validate_delivery_target
    _check_path(Path(binding["cwd"]), directory=True, private=True)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

path = PosixPath('/tmp/pytest-of-worsch/pytest-207/test_real_exec_handler_rejects0/owner')
directory = True, private = True

    def _check_path(path: Path, *, directory: bool = False, private: bool = False) -> None:
        """No symlink or untrusted writable ancestor; root-owned sticky /tmp is safe."""
        for candidate in [*reversed(path.parents), path]:
            info = candidate.lstat()
            leaf = candidate == path
            is_dir = not leaf or directory
            if not (stat.S_ISDIR(info.st_mode) if is_dir else stat.S_ISREG(info.st_mode)):
                raise DeliveryError("exec owner path is not a regular file/directory")
            if info.st_uid not in {0, os.getuid()}:
>               raise DeliveryError("exec owner path has an untrusted owner")
E               secrets_engine.errors.DeliveryError: exec owner path has an untrusted owner

src/secrets_engine/exec_owner.py:146: DeliveryError
_____________________ test_two_lanes_reach_one_bound_owner _____________________

bao_dev = OpenBaoClient(addr='http://127.0.0.1:55527', token='se-test-root', bao_bin='/home/worsch/.local/bin/bao')
bound = ({'id': 'test-lane', 'org': 'coulomb', 'repo': 'team-repo', 'stage': 'test', ...}, PosixPath('/tmp/pytest-of-worsch/py...reach_one_bound0/owner'), PosixPath('/tmp/pytest-of-worsch/pytest-207/test_two_lanes_reach_one_bound0/owner/owner.sh'))
tmp_path = PosixPath('/tmp/pytest-of-worsch/pytest-207/test_two_lanes_reach_one_bound0')
capsys = <_pytest.capture.CaptureFixture object at 0x756740d5fd70>

    def test_two_lanes_reach_one_bound_owner(bao_dev, bound, tmp_path, capsys):
        data, _, script = bound
        script.write_text('''test "$API_TOKEN" = primary-integration-value || exit 10
    test "$WORKER_TOKEN" = worker-integration-value || exit 11
    test -z "$BAO_TOKEN" || exit 12
    read ignored && exit 15
    printf '%s %s\\n' "$API_TOKEN" "$WORKER_TOKEN"
    printf 'two-lane-child-ok\\n'
    ''')
        data["delivery_config"]["exec_owner"]["files"][str(script)]["sha256"] = hashlib.sha256(
            script.read_bytes()
        ).hexdigest()
        entry = validate_entry(_with_companion(copy.deepcopy(data)))
        lane = validate_entry(_companion())
        _provision(bao_dev, entry, "api_token", "primary-integration-value", tmp_path)
        _provision(bao_dev, lane, "worker_token", "worker-integration-value", tmp_path)
    
        sessions, primary_session = {}, {}
>       rc = exec_with_secret(
            bao_dev, entry, "api_token", data["delivery_config"]["exec_owner"]["command"],
            mode="exec-env", session_evidence=primary_session,
            expected_owner_digest=owner_digest(entry),
            companions=resolve_companions(entry, _lookup(lane)), companion_sessions=sessions,
        )

tests/test_integration_companions.py:47: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
src/secrets_engine/exec_delivery.py:199: in exec_with_secret
    binding_digest = validate_delivery_target(entry, field, command, mode)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
src/secrets_engine/exec_owner.py:171: in validate_delivery_target
    _check_path(Path(binding["cwd"]), directory=True, private=True)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

path = PosixPath('/tmp/pytest-of-worsch/pytest-207/test_two_lanes_reach_one_bound0/owner')
directory = True, private = True

    def _check_path(path: Path, *, directory: bool = False, private: bool = False) -> None:
        """No symlink or untrusted writable ancestor; root-owned sticky /tmp is safe."""
        for candidate in [*reversed(path.parents), path]:
            info = candidate.lstat()
            leaf = candidate == path
            is_dir = not leaf or directory
            if not (stat.S_ISDIR(info.st_mode) if is_dir else stat.S_ISREG(info.st_mode)):
                raise DeliveryError("exec owner path is not a regular file/directory")
            if info.st_uid not in {0, os.getuid()}:
>               raise DeliveryError("exec owner path has an untrusted owner")
E               secrets_engine.errors.DeliveryError: exec owner path has an untrusted owner

src/secrets_engine/exec_owner.py:146: DeliveryError
=========================== short test summary info ============================
FAILED tests/test_exec_owner.py::test_actual_bound_child_gets_only_selected_secret_and_fixed_environment
FAILED tests/test_exec_owner.py::test_config_changed_during_fetch_does_not_launch
FAILED tests/test_exec_owner.py::test_binding_changed_after_approval_refuses_before_fetch
FAILED tests/test_exec_owner_companions.py::test_companion_value_reaches_bound_child_and_is_redacted
FAILED tests/test_exec_owner_companions.py::test_companion_fetch_failure_starts_no_child
FAILED tests/test_exec_owner_companions.py::test_each_lane_is_gated_separately_before_backend
FAILED tests/test_exec_owner_companions.py::test_unresolvable_companion_refuses_before_any_gate
FAILED tests/test_exec_owner_companions.py::test_delivery_rechecks_companion_contract_before_any_read[missing]
FAILED tests/test_exec_owner_companions.py::test_delivery_rechecks_companion_contract_before_any_read[extra]
FAILED tests/test_exec_owner_companions.py::test_delivery_rechecks_companion_contract_before_any_read[env]
FAILED tests/test_exec_owner_companions.py::test_delivery_rechecks_companion_contract_before_any_read[field]
FAILED tests/test_exec_owner_companions.py::test_delivery_rechecks_companion_contract_before_any_read[lane]
FAILED tests/test_exec_owner_companions.py::test_delivery_rechecks_companion_contract_before_any_read[consent]
FAILED tests/test_exec_owner_companions.py::test_delivery_rechecks_companion_contract_before_any_read[stage]
FAILED tests/test_human_control.py::test_real_exec_handler_rejects_undeclared_claim_before_consume_backend_child
FAILED tests/test_integration_companions.py::test_two_lanes_reach_one_bound_owner
16 failed, 784 passed, 7 skipped in 55.47s
