feat: complete local layer model v0.7 conformance work
Assistant: codex Assistant-Model: gpt-6-astra Assistant-Session: 01a06eaf-3425-7f92-a0c2-bb4aa4faebe4
This commit is contained in:
parent
89b117f640
commit
00145d705e
13 changed files with 279 additions and 27 deletions
|
|
@ -6,7 +6,7 @@ from pathlib import Path
|
|||
|
||||
from typer.testing import CliRunner
|
||||
|
||||
from warden.access import expand_handoff, policy_gate_status
|
||||
from warden.access import agent_read_boundary_identity, expand_handoff, policy_gate_status
|
||||
from warden.cli import app
|
||||
from warden.routing.models import RouteEntry
|
||||
|
||||
|
|
@ -64,6 +64,33 @@ def test_policy_gate_status_no_config(monkeypatch, tmp_path):
|
|||
assert "advisory" in policy_gate_status()
|
||||
|
||||
|
||||
def test_issued_coding_agent_subject_drives_read_boundary_without_legacy_marker():
|
||||
env = {"WARDEN_POLICY_SUBJECT": "service:codex:railiance-platform"}
|
||||
assert agent_read_boundary_identity(env) == "service:codex:railiance-platform"
|
||||
|
||||
|
||||
def test_legacy_agent_marker_remains_fail_toward_safety_fallback():
|
||||
env = {"WARDEN_AGENT_ID": "grok"}
|
||||
assert agent_read_boundary_identity(env) == "grok"
|
||||
|
||||
|
||||
def test_non_agent_policy_subject_does_not_manufacture_agent_identity():
|
||||
env = {"WARDEN_POLICY_SUBJECT": "iam:bernd"}
|
||||
assert agent_read_boundary_identity(env) is None
|
||||
|
||||
|
||||
def test_explicit_empty_environment_does_not_inherit_process_identity(monkeypatch):
|
||||
monkeypatch.setenv("WARDEN_AGENT_ID", "codex")
|
||||
monkeypatch.setenv("WARDEN_POLICY_SUBJECT", "service:codex:railiance-platform")
|
||||
assert agent_read_boundary_identity({}) is None
|
||||
assert agent_read_boundary_identity() == "service:codex:railiance-platform"
|
||||
|
||||
|
||||
def test_operator_subject_does_not_override_legacy_agent_marker():
|
||||
env = {"WARDEN_POLICY_SUBJECT": "iam:bernd", "WARDEN_AGENT_ID": "codex"}
|
||||
assert agent_read_boundary_identity(env) == "codex"
|
||||
|
||||
|
||||
# --- CLI -------------------------------------------------------------------
|
||||
|
||||
def test_access_advisory_output(monkeypatch):
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ class TestDeclaration:
|
|||
d = _decl()
|
||||
assert d["repository"] == "ops-warden"
|
||||
assert d["layer"] == "staff"
|
||||
assert d["standard_version"] == "0.7"
|
||||
# §11: "only the repository's own file, in its own voice, conforms."
|
||||
assert d["declared_by"] == "docs/adr/ADR-0010"
|
||||
|
||||
|
|
@ -131,3 +132,21 @@ class TestPepStanceMap:
|
|||
"""§6.4 obligation 2: caching an input claim is permitted; caching the
|
||||
answer is a second decision point deciding early (§6.1)."""
|
||||
assert self._stance()["verdict_caching"] == "none"
|
||||
|
||||
def test_revocation_visibility_deadline_equals_enforced_ttl_policy(self):
|
||||
"""§9.7.2: a published replay window must not drift from issuance."""
|
||||
from warden.models import ActorType, MAX_TTL_HOURS
|
||||
|
||||
published = self._stance()["revocation_visibility"]
|
||||
expected = {actor.value: MAX_TTL_HOURS[actor] for actor in ActorType}
|
||||
assert published["deadline_hours"] == expected
|
||||
assert published["mechanism"] == "ttl_expiry"
|
||||
assert published["revocation_channel"] == "none"
|
||||
|
||||
def test_attributive_emission_cadence_deferral_carries_measurement(self):
|
||||
cadence = self._stance()["emission_cadence"]
|
||||
assert cadence["classification"] == "attributive"
|
||||
assert cadence["status"] == "deferred"
|
||||
assert cadence["observed_window"]["signature_records"] == 3
|
||||
assert cadence["observed_window"]["active_signature_days"] == 2
|
||||
assert cadence["reason"]
|
||||
|
|
|
|||
|
|
@ -590,6 +590,27 @@ def test_access_agent_high_risk_raw_stream_refused(tmp_path, monkeypatch):
|
|||
assert "agent read-boundary" in r.output.lower() or "risk=high" in r.output.lower()
|
||||
|
||||
|
||||
def test_access_issued_agent_subject_refuses_raw_stream_without_legacy_marker(
|
||||
tmp_path, monkeypatch
|
||||
):
|
||||
"""WP-0034 T02: the issued KeyCape subject is sufficient for exit 7."""
|
||||
_proxy_env(monkeypatch, tmp_path)
|
||||
monkeypatch.setenv("VAULT_TOKEN", "caller-token")
|
||||
monkeypatch.delenv("WARDEN_AGENT_ID", raising=False)
|
||||
monkeypatch.setenv(
|
||||
"WARDEN_POLICY_SUBJECT", "service:codex:railiance-platform"
|
||||
)
|
||||
r = runner.invoke(
|
||||
app,
|
||||
[
|
||||
"access", "railiance-backup-offsite-lane",
|
||||
"--fetch", "--unsafe-stdout",
|
||||
],
|
||||
)
|
||||
assert r.exit_code == 7, r.output
|
||||
assert "service:codex:railiance-platform" in r.output
|
||||
|
||||
|
||||
def test_access_agent_high_risk_fingerprint_allowed(tmp_path, monkeypatch):
|
||||
"""Agents may use --fingerprint on high-risk lanes (no raw value)."""
|
||||
_proxy_env(monkeypatch, tmp_path)
|
||||
|
|
|
|||
|
|
@ -143,6 +143,18 @@ def test_route_find_vault_token_ops_warden_prefers_broker_lane():
|
|||
assert matches[0].id == "ops-warden-warden-sign-token"
|
||||
|
||||
|
||||
def test_route_find_layer_declaration_resolves_to_reference_playbook():
|
||||
catalog = load_catalog(_repo_catalog())
|
||||
entry = catalog.find("how do I declare my layer", limit=1)[0]
|
||||
assert entry.id == "netkingdom-layer-declaration"
|
||||
assert entry.owner_repo == "ops-warden"
|
||||
assert entry.wiki_ref.endswith(
|
||||
"netkingdom-layer-declaration.md#worker-checklist"
|
||||
)
|
||||
assert entry.canon_ref.endswith("security-layer-model_v0.7.md")
|
||||
assert entry.exec_capable is False
|
||||
|
||||
|
||||
def test_whynot_design_npm_lane_is_concrete_and_resolvable():
|
||||
"""The provisioned Forgejo npm lane is exact, concrete, and resolvable."""
|
||||
catalog = load_catalog(_repo_catalog())
|
||||
|
|
|
|||
|
|
@ -14,9 +14,10 @@ def test_repo_catalog_uses_only_explicit_workload_references():
|
|||
assert report["ok"] is True
|
||||
assert len(report["resolved"]) == 3
|
||||
assert len(report["unknown"]) == 18
|
||||
# 11 since WARDEN-WP-0033: the two NetKingdom SSO lanes (c374d41) are
|
||||
# provider/control-plane credentials, not workload delivery lanes.
|
||||
assert len(report["not_applicable"]) == 11
|
||||
# 12 since WARDEN-WP-0034: the layer-declaration route is repository
|
||||
# conformance guidance, not a workload delivery lane. The two NetKingdom SSO
|
||||
# lanes (c374d41) remain provider/control-plane credentials as well.
|
||||
assert len(report["not_applicable"]) == 12
|
||||
assert {row["lane"] for row in report["resolved"]} == {
|
||||
"ops-warden-warden-sign-token",
|
||||
"issue-core-ingestion-api-key",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue