Require declared human control in factory credential delivery
All checks were successful
CI Smoke / host-smoke (push) Successful in 0s
CI Smoke / container-smoke (push) Successful in 1s

Assistant: codex
Assistant-Model: gpt-6-astra
Assistant-Session: 01a07ff8-19d0-7820-b4d0-1353833cb7fc
This commit is contained in:
tegwick 2026-09-10 20:16:55 +02:00
parent d1c13b5dd6
commit 2b0d04e8e1
11 changed files with 451 additions and 27 deletions

View file

@ -355,15 +355,40 @@ def exercise(args):
"files": {str(p): {"sha256": hashlib.sha256(p.read_bytes()).hexdigest(), "private": True}
for p in [executable, script]},
}}
if args.human_control:
raw["approval"].update(model="decision", human_control=True,
decision_ref="synthetic-human-lane-review")
owner_entry = validate_entry(raw)
req = _expected_request(cfg, owner_entry, "exec", fields=("api_token",))
owner_request_digest = pdp.bind_request(req)
operator_request("/v1/approvals", {
"id": "synthetic-owner-delivery", "binding": {"action": "secrets.exec", "target": {"id": owner_entry.id, "stage": "prod"},
"actor": "service:approval-engine-operator", "principal": "synthetic-operator", "purpose": "disposable identity proof"},
"validity": {"not_before": (now - timedelta(minutes=1)).isoformat(), "expires_at": (now + timedelta(minutes=10)).isoformat()},
"pdp_digest": owner_request_digest, "pdp_path": True}, "approval:create")
operator_request("/v1/approvals/synthetic-owner-delivery/entries", {}, "approval:approve")
def issue_owner(ident, human_control):
# The requester declares intent on an unapproved object;
# only the subsequent human bind discharges the control.
return operator_request("/v1/approvals", {
"id": ident, "binding": {"action": "secrets.exec", "target": {"id": owner_entry.id, "stage": "prod"},
"actor": "service:approval-engine-operator", "principal": "synthetic-operator", "purpose": "disposable identity proof"},
"validity": {"not_before": (now - timedelta(minutes=1)).isoformat(), "expires_at": (now + timedelta(minutes=10)).isoformat()},
"pdp_digest": owner_request_digest, "pdp_path": True,
"human_control": human_control}, "approval:create")
issue_owner("synthetic-owner-delivery", args.human_control)
if args.human_control:
try:
operator_request("/v1/approvals/synthetic-owner-delivery/entries", {}, "approval:approve")
except HTTPError as error:
assert error.code == 403
assert engine.get("synthetic-owner-delivery").entries == []
else:
raise AssertionError("service bound a declared human control")
# Explicit local fixture: the positive human entry is seeded
# through the store, not a native human login/JWT claim.
engine.add_entry("synthetic-owner-delivery", "fixture:human",
principal_type="human", evidence_ref="synthetic-store-fixture")
issue_owner("synthetic-owner-undeclared", False)
operator_request("/v1/approvals/synthetic-owner-undeclared/entries", {}, "approval:approve")
receipt["checks"]["declared_control_refuses_real_keycape_service_bind"] = True
receipt["limitations"].append("positive human entry seeded in disposable store; no human JWT/PKCE proof")
else:
operator_request("/v1/approvals/synthetic-owner-delivery/entries", {}, "approval:approve")
backend_calls = []
class Backend:
@contextmanager
@ -380,7 +405,23 @@ def exercise(args):
yield Backend()
command = raw["delivery_config"]["exec_owner"]["command"]
cli_args = SimpleNamespace(catalog=owner_entry.id, field="api_token", mode="exec-env", command=command)
with patch.object(cli, "get_entry", return_value=owner_entry), patch.object(cli, "_open_backend", open_fixture_backend):
from secrets_engine.decisions import Decision
lane_review = Decision("synthetic-human-lane-review", "Synthetic lane review", "approved", None, "local-fixture")
with patch.object(cli, "get_entry", return_value=owner_entry), patch.object(cli, "_open_backend", open_fixture_backend), patch.object(cli, "resolve_decision", return_value=lane_review):
if args.human_control:
owner_entry.approval["authorization_id"] = "synthetic-owner-undeclared"
before_checks = len(pdp.calls)
try:
cli.cmd_exec(cfg, cli_args)
except DecisionError as error:
assert "human_control" in str(error)
assert not backend_calls and len(pdp.calls) == before_checks
assert not engine.claim("synthetic-owner-undeclared")["consumed"]
else:
raise AssertionError("undeclared control reached the protected action")
finally:
owner_entry.approval["authorization_id"] = "synthetic-owner-delivery"
receipt["checks"]["undeclared_control_refused_before_real_pdp_consume_backend"] = True
substituted = SimpleNamespace(**vars(cli_args))
substituted.command = ["/bin/echo", "substitute"]
try:
@ -411,6 +452,11 @@ def exercise(args):
"exec_owner_actual_child_excludes_parent_credentials": True,
"exec_owner_digest_preserved_by_real_evaluator": True,
})
if args.human_control:
assert pdp.last_decision["binding"]["context"]["human_control"] is True
assert engine.claim("synthetic-owner-delivery")["binding"]["human_control"] is True
receipt["checks"]["declared_human_intent_preserved_by_real_evaluator"] = True
receipt["checks"]["declared_human_fixture_consumed_before_owner_delivery"] = True
receipt["exec_owner_scope"] = "Synthetic recipient/backend with real KeyCape, Approval Engine, Flex Auth and Secrets Engine CLI; not native custody or human approval proof"
finally:
if api_server:
@ -436,7 +482,10 @@ def main():
parser.add_argument("--flex-auth-source", required=True, type=Path)
parser.add_argument("--receipt", required=True, type=Path)
parser.add_argument("--exec-owner", action="store_true", help="also prove catalog-bound child delivery against the actual approval/PDP chain")
parser.add_argument("--human-control", action="store_true", help="require declared human control in the exec-owner exercise; positive human entry is an explicit local store fixture")
args = parser.parse_args()
if args.human_control and not args.exec_owner:
parser.error("--human-control requires --exec-owner")
if args.receipt.exists():
raise SystemExit("receipt path must be new")
try: