diff --git a/Makefile b/Makefile index 8856a654..aef8d241 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ -.PHONY: validate test validate-agent-cycle-health validate-authority-dependency-evidence validate-prometheus-sr validate-reasoning-failure-traces validate-governance-context validate-lattice-data-governai-execution-refs validate-lattice-runtime-profile-refs validate-network-native-assistant-evidence validate-guardrail-evidence-artifacts validate-stop-gate-evaluator validate-guarded-workcell-artifact validate-guarded-workcell-executor validate-guarded-invocation-artifact validate-guarded-invocation validate-agentic-pr-work-order validate-semantic-enterprise-agent-boundary validate-ops-history-contracts validate-action-contracts validate-agent-operation-contract validate-superconscious-reasoning-import validate-agent-harness-runtime-contracts validate-bounded-action-loop agentplane-evidence-receipt-composition-tier2-binding-ci lawful-learning-phase9-contract-ci validate-evidence-receipt-binding validate-semantic-activation-receipt validate-governed-run-contract validate-preflight-receipt validate-attempt-admission-receipt validate-verification-execution-receipt validate-synthetic-verification-receipt validate-governed-runner-v0-2-contract-chain validate-budget-settlement-receipt validate-rollback-receipts validate-run-dossier validate-governed-runner-readonly validate-workroom-context-evidence validate-wallguard-collaboration-admission validate-prophet-mesh-agentplane-adapter +.PHONY: validate test validate-agent-cycle-health validate-authority-dependency-evidence validate-prometheus-sr validate-reasoning-failure-traces validate-governance-context validate-lattice-data-governai-execution-refs validate-lattice-runtime-profile-refs validate-network-native-assistant-evidence validate-guardrail-evidence-artifacts validate-stop-gate-evaluator validate-guarded-workcell-artifact validate-guarded-workcell-executor validate-guarded-invocation-artifact validate-guarded-invocation validate-agentic-pr-work-order validate-semantic-enterprise-agent-boundary validate-ops-history-contracts validate-action-contracts validate-agent-operation-contract validate-superconscious-reasoning-import validate-agent-harness-runtime-contracts validate-bounded-action-loop agentplane-evidence-receipt-composition-tier2-binding-ci lawful-learning-phase9-contract-ci validate-evidence-receipt-binding validate-semantic-activation-receipt validate-governed-run-contract validate-preflight-receipt validate-attempt-admission-receipt validate-verification-execution-receipt validate-synthetic-verification-receipt validate-governed-runner-v0-2-contract-chain validate-budget-settlement-receipt validate-rollback-receipts validate-run-dossier validate-governed-runner-readonly validate-workroom-context-evidence validate-wallguard-collaboration-admission validate-prophet-mesh-agentplane-adapter validate-boundary-calculus-evidence -validate: validate-agent-cycle-health validate-authority-dependency-evidence validate-prometheus-sr validate-reasoning-failure-traces validate-governance-context validate-lattice-data-governai-execution-refs validate-lattice-runtime-profile-refs validate-network-native-assistant-evidence validate-guardrail-evidence-artifacts validate-stop-gate-evaluator validate-guarded-workcell-artifact validate-guarded-workcell-executor validate-guarded-invocation-artifact validate-guarded-invocation validate-agentic-pr-work-order validate-semantic-enterprise-agent-boundary validate-ops-history-contracts validate-action-contracts validate-agent-operation-contract validate-superconscious-reasoning-import validate-agent-harness-runtime-contracts validate-bounded-action-loop agentplane-evidence-receipt-composition-tier2-binding-ci lawful-learning-phase9-contract-ci validate-evidence-receipt-binding validate-semantic-activation-receipt validate-governed-run-contract validate-preflight-receipt validate-attempt-admission-receipt validate-verification-execution-receipt validate-synthetic-verification-receipt validate-governed-runner-v0-2-contract-chain validate-budget-settlement-receipt validate-rollback-receipts validate-run-dossier validate-governed-runner-readonly validate-workroom-context-evidence validate-wallguard-collaboration-admission validate-prophet-mesh-agentplane-adapter +validate: validate-agent-cycle-health validate-authority-dependency-evidence validate-prometheus-sr validate-reasoning-failure-traces validate-governance-context validate-lattice-data-governai-execution-refs validate-lattice-runtime-profile-refs validate-network-native-assistant-evidence validate-guardrail-evidence-artifacts validate-stop-gate-evaluator validate-guarded-workcell-artifact validate-guarded-workcell-executor validate-guarded-invocation-artifact validate-guarded-invocation validate-agentic-pr-work-order validate-semantic-enterprise-agent-boundary validate-ops-history-contracts validate-action-contracts validate-agent-operation-contract validate-superconscious-reasoning-import validate-agent-harness-runtime-contracts validate-bounded-action-loop agentplane-evidence-receipt-composition-tier2-binding-ci lawful-learning-phase9-contract-ci validate-evidence-receipt-binding validate-semantic-activation-receipt validate-governed-run-contract validate-preflight-receipt validate-attempt-admission-receipt validate-verification-execution-receipt validate-synthetic-verification-receipt validate-governed-runner-v0-2-contract-chain validate-budget-settlement-receipt validate-rollback-receipts validate-run-dossier validate-governed-runner-readonly validate-workroom-context-evidence validate-wallguard-collaboration-admission validate-prophet-mesh-agentplane-adapter validate-boundary-calculus-evidence python3 tools/validate_execution_timing.py validate-governance-context: @@ -248,6 +248,9 @@ validate-prophet-mesh-agentplane-adapter: python3 -m json.tool contracts/prophet-mesh/prophet-mesh-agentplane-adapter.v0.1.json >/dev/null python3 tools/validate_prophet_mesh_agentplane_adapter.py +validate-boundary-calculus-evidence: + python3 tools/validate_boundary_calculus_evidence.py + validate-agent-cycle-health: python3 tools/validate_agent_cycle_health.py diff --git a/docs/integrations/boundary-calculus-evidence-envelope.md b/docs/integrations/boundary-calculus-evidence-envelope.md new file mode 100644 index 00000000..a1503f27 --- /dev/null +++ b/docs/integrations/boundary-calculus-evidence-envelope.md @@ -0,0 +1,78 @@ +# Boundary Calculus Evidence Envelope Integration + +AgentPlane emits a `BoundaryCalculusEvidenceEnvelope` when an agent uses the Boundary Calculus claim discipline. SocioSphere owns the standard and the promotion/demotion controller. + +## Boundary + +- AgentPlane: emits evidence envelopes, enforces policy gates, provides replay artifacts. +- SocioSphere: owns the Boundary Calculus standard, controls claim promotion/demotion. +- AgentPlane does not promote or demote claims unilaterally. + +## Envelope fields + +| Field | Required | Description | +|-------|----------|-------------| +| `claim_id` | Yes | Stable identifier for this claim instance | +| `claim_status` | Yes | `observation` / `hypothesis` / `supported` / `confirmed` / `falsified` / `metaphor` / `load_bearing_assertion` | +| `local_model` | Yes | Model or agent producing the claim | +| `boundary_or_interface` | Yes | The boundary or interface at which the claim is evaluated | +| `load_bearing` | No | Whether the claim is load-bearing in a downstream decision or security gate | +| `non_claims` | Yes | Explicit list of what this envelope does NOT assert (minItems 1) | +| `evidence_refs` | Yes | References to supporting evidence (minItems 1) | +| `promotion_gate` | Yes | Gate required before promotion: `none_required` / `peer_review` / `sociosphere_controller` / `policy_fabric_evaluation` / `agentplane_replay_verification` | +| `policy_result` | Yes | `allow` / `allow_with_warning` / `block` / `escalate` / `pending_review` | +| `security_escalation_ref` | Conditional | Required when `policy_result=escalate` | +| `attribution_source` | No | Attribution claim source; if present, requires `attribution_discriminating_evidence_refs` | + +## Policy hooks + +The validator warns or blocks when: + +- `claim_status=metaphor` and `load_bearing=true` — metaphors must not be load-bearing. +- `claim_status` is `confirmed` or `load_bearing_assertion` and `promotion_gate=none_required` — strong claims require a gate. +- `policy_result=escalate` without a `security_escalation_ref` — security escalations must reference their escalation record. +- `attribution_source` is present without `attribution_discriminating_evidence_refs` — attribution without discriminating evidence is not valid. + +## Schema location + +`schemas/boundary-calculus-evidence-envelope.schema.v0.1.json` + +## Validation + +``` +make validate-boundary-calculus-evidence +``` + +## Example: supported claim + +```json +{ + "kind": "BoundaryCalculusEvidenceEnvelope", + "claim_status": "supported", + "promotion_gate": "peer_review", + "policy_result": "allow", + "non_claims": ["This envelope does not authorize deployment."], + "evidence_refs": ["evidence://agentplane/run/.../policy-gate-trace"] +} +``` + +## Example: security escalation + +When a hypothesis at a security boundary triggers escalation: + +```json +{ + "claim_status": "hypothesis", + "load_bearing": true, + "promotion_gate": "policy_fabric_evaluation", + "policy_result": "escalate", + "security_escalation_ref": "escalation://security/agentplane/..." +} +``` + +## Non-claims + +This document does not: +- Define the Boundary Calculus standard (SocioSphere owns this). +- Grant AgentPlane authority to promote or demote claims. +- Certify that claim evidence is complete or sufficient for downstream use. diff --git a/schemas/boundary-calculus-evidence-envelope.schema.v0.1.json b/schemas/boundary-calculus-evidence-envelope.schema.v0.1.json new file mode 100644 index 00000000..44b56151 --- /dev/null +++ b/schemas/boundary-calculus-evidence-envelope.schema.v0.1.json @@ -0,0 +1,107 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "$id": "https://socioprophet.io/schemas/agentplane/boundary-calculus-evidence-envelope/v0.1", + "title": "BoundaryCalculusEvidenceEnvelope", + "description": "AgentPlane evidence envelope emitted when agents use the Boundary Calculus claim discipline. AgentPlane emits evidence; SocioSphere owns the standard and promotion/demotion controller.", + "type": "object", + "required": [ + "kind", + "envelope_id", + "run_ref", + "claim_id", + "claim_status", + "local_model", + "boundary_or_interface", + "non_claims", + "evidence_refs", + "promotion_gate", + "policy_result", + "captured_at" + ], + "additionalProperties": false, + "properties": { + "kind": { "type": "string", "const": "BoundaryCalculusEvidenceEnvelope" }, + "envelope_id": { "type": "string", "minLength": 1 }, + "run_ref": { + "type": "string", + "description": "AgentPlane run artifact reference that emitted this envelope" + }, + "claim_id": { "type": "string", "minLength": 1 }, + "claim_status": { + "type": "string", + "enum": [ + "observation", + "hypothesis", + "supported", + "confirmed", + "falsified", + "metaphor", + "load_bearing_assertion" + ] + }, + "local_model": { + "type": "string", + "description": "The model or agent producing the claim" + }, + "boundary_or_interface": { + "type": "string", + "description": "The boundary or interface at which the claim is being evaluated" + }, + "load_bearing": { + "type": "boolean", + "description": "Whether the claim is load-bearing in a downstream decision or security gate" + }, + "non_claims": { + "type": "array", + "items": { "type": "string" }, + "minItems": 1, + "description": "Explicit list of what this envelope does NOT assert" + }, + "evidence_refs": { + "type": "array", + "items": { "type": "string" }, + "minItems": 1, + "description": "References to supporting evidence for this claim" + }, + "promotion_gate": { + "type": "string", + "description": "Reference to the gate that must approve promotion to a stronger claim status", + "enum": [ + "none_required", + "peer_review", + "sociosphere_controller", + "policy_fabric_evaluation", + "agentplane_replay_verification" + ] + }, + "policy_result": { + "type": "string", + "enum": ["allow", "allow_with_warning", "block", "escalate", "pending_review"] + }, + "security_escalation_ref": { + "type": "string", + "description": "Reference to security escalation record, required when policy_result=escalate" + }, + "attribution_source": { + "type": "string", + "description": "Source of attribution claim, if any" + }, + "attribution_discriminating_evidence_refs": { + "type": "array", + "items": { "type": "string" }, + "description": "Evidence refs that discriminate this attribution from alternatives" + }, + "captured_at": { "type": "string", "format": "date-time" } + }, + "if": { + "properties": { + "claim_status": { "const": "metaphor" } + } + }, + "then": { + "properties": { + "load_bearing": { "const": false } + }, + "required": ["load_bearing"] + } +} diff --git a/tests/fixtures/boundary-calculus/escalation-claim.valid.json b/tests/fixtures/boundary-calculus/escalation-claim.valid.json new file mode 100644 index 00000000..7a57de87 --- /dev/null +++ b/tests/fixtures/boundary-calculus/escalation-claim.valid.json @@ -0,0 +1,23 @@ +{ + "kind": "BoundaryCalculusEvidenceEnvelope", + "envelope_id": "bcee_security_escalation_001", + "run_ref": "agentplane://run/boundary-calculus/run_20260611_002", + "claim_id": "claim://boundary-calculus/security-boundary-breach-001", + "claim_status": "hypothesis", + "local_model": "claude-sonnet-4-6", + "boundary_or_interface": "Security.CapabilityBoundary.DataAccess", + "load_bearing": true, + "non_claims": [ + "This envelope does not confirm a breach has occurred.", + "This envelope does not authorize incident response actions.", + "This envelope does not replace a formal security review." + ], + "evidence_refs": [ + "evidence://agentplane/run/boundary-calculus/run_20260611_002/anomaly-signal", + "evidence://agentplane/run/boundary-calculus/run_20260611_002/capability-trace" + ], + "promotion_gate": "policy_fabric_evaluation", + "policy_result": "escalate", + "security_escalation_ref": "escalation://security/agentplane/boundary-calculus/esc_20260611_001", + "captured_at": "2026-06-11T11:00:00Z" +} diff --git a/tests/fixtures/boundary-calculus/reject_metaphor-load-bearing.json b/tests/fixtures/boundary-calculus/reject_metaphor-load-bearing.json new file mode 100644 index 00000000..d0a39ec3 --- /dev/null +++ b/tests/fixtures/boundary-calculus/reject_metaphor-load-bearing.json @@ -0,0 +1,20 @@ +{ + "_reject_reason": "claim_status=metaphor but load_bearing=true — schema enforces load_bearing must be false for metaphor claims", + "kind": "BoundaryCalculusEvidenceEnvelope", + "envelope_id": "bcee_reject_metaphor_001", + "run_ref": "agentplane://run/boundary-calculus/run_reject_001", + "claim_id": "claim://boundary-calculus/reject-metaphor-001", + "claim_status": "metaphor", + "local_model": "claude-sonnet-4-6", + "boundary_or_interface": "API.Authorization.PolicyGate", + "load_bearing": true, + "non_claims": [ + "This is a reject fixture." + ], + "evidence_refs": [ + "evidence://agentplane/run/boundary-calculus/run_reject_001/trace" + ], + "promotion_gate": "none_required", + "policy_result": "allow", + "captured_at": "2026-06-11T10:30:00Z" +} diff --git a/tests/fixtures/boundary-calculus/reject_promoted-without-gate.json b/tests/fixtures/boundary-calculus/reject_promoted-without-gate.json new file mode 100644 index 00000000..88297a31 --- /dev/null +++ b/tests/fixtures/boundary-calculus/reject_promoted-without-gate.json @@ -0,0 +1,19 @@ +{ + "_reject_reason": "claim_status=confirmed but promotion_gate=none_required — validator must reject promotion without a gate for confirmed claims", + "kind": "BoundaryCalculusEvidenceEnvelope", + "envelope_id": "bcee_reject_no_gate_001", + "run_ref": "agentplane://run/boundary-calculus/run_reject_002", + "claim_id": "claim://boundary-calculus/reject-no-gate-001", + "claim_status": "confirmed", + "local_model": "claude-sonnet-4-6", + "boundary_or_interface": "API.Authorization.PolicyGate", + "non_claims": [ + "This is a reject fixture." + ], + "evidence_refs": [ + "evidence://agentplane/run/boundary-calculus/run_reject_002/trace" + ], + "promotion_gate": "none_required", + "policy_result": "allow", + "captured_at": "2026-06-11T10:45:00Z" +} diff --git a/tests/fixtures/boundary-calculus/supported-claim.valid.json b/tests/fixtures/boundary-calculus/supported-claim.valid.json new file mode 100644 index 00000000..9abbc9ab --- /dev/null +++ b/tests/fixtures/boundary-calculus/supported-claim.valid.json @@ -0,0 +1,22 @@ +{ + "kind": "BoundaryCalculusEvidenceEnvelope", + "envelope_id": "bcee_supported_claim_001", + "run_ref": "agentplane://run/boundary-calculus/run_20260611_001", + "claim_id": "claim://boundary-calculus/auth-bypass-absent-001", + "claim_status": "supported", + "local_model": "claude-sonnet-4-6", + "boundary_or_interface": "API.Authorization.PolicyGate", + "load_bearing": false, + "non_claims": [ + "This envelope does not assert that the boundary is secure against all attack vectors.", + "This envelope does not certify that upstream policy gates are correctly configured.", + "This envelope does not authorize deployment." + ], + "evidence_refs": [ + "evidence://agentplane/run/boundary-calculus/run_20260611_001/policy-gate-trace", + "evidence://agentplane/run/boundary-calculus/run_20260611_001/test-harness-output" + ], + "promotion_gate": "peer_review", + "policy_result": "allow", + "captured_at": "2026-06-11T10:00:00Z" +} diff --git a/tools/validate_boundary_calculus_evidence.py b/tools/validate_boundary_calculus_evidence.py new file mode 100644 index 00000000..01f0fe9e --- /dev/null +++ b/tools/validate_boundary_calculus_evidence.py @@ -0,0 +1,110 @@ +#!/usr/bin/env python3 +"""Validate BoundaryCalculusEvidenceEnvelope fixtures. + +Policy gates (beyond schema validation): +- claim_status=metaphor requires load_bearing=false +- confirmed/load_bearing_assertion status requires promotion_gate != none_required +- policy_result=escalate requires security_escalation_ref +- attribution_source present requires attribution_discriminating_evidence_refs (minItems 1) +""" +from __future__ import annotations + +import json +import sys +from pathlib import Path + +try: + import jsonschema +except ImportError: + print("ERROR: jsonschema not installed", file=sys.stderr) + sys.exit(1) + +ROOT = Path(__file__).resolve().parent.parent +SCHEMA_PATH = ROOT / "schemas" / "boundary-calculus-evidence-envelope.schema.v0.1.json" +FIXTURES = ROOT / "tests" / "fixtures" / "boundary-calculus" + +SCHEMA = json.loads(SCHEMA_PATH.read_text()) + +STRONG_CLAIM_STATUSES = {"confirmed", "load_bearing_assertion"} + +errors: list[str] = [] +results: list[bool] = [] + + +def ok(label: str) -> None: + print(f"PASS {label}") + results.append(True) + + +def fail(label: str, reason: str) -> None: + errors.append(f"FAIL {label}: {reason}") + results.append(False) + + +def policy_gate_errors(data: dict) -> list[str]: + errs = [] + status = data.get("claim_status") + load_bearing = data.get("load_bearing") + promotion_gate = data.get("promotion_gate") + policy_result = data.get("policy_result") + attribution = data.get("attribution_source") + attribution_ev = data.get("attribution_discriminating_evidence_refs", []) + + # metaphor + load_bearing check (also in schema via conditional, belt-and-suspenders) + if status == "metaphor" and load_bearing is True: + errs.append("claim_status=metaphor requires load_bearing=false") + + # strong claims require a real promotion gate + if status in STRONG_CLAIM_STATUSES and promotion_gate == "none_required": + errs.append(f"claim_status={status} requires promotion_gate != none_required") + + # escalation requires escalation ref + if policy_result == "escalate" and not data.get("security_escalation_ref"): + errs.append("policy_result=escalate requires security_escalation_ref") + + # attribution requires discriminating evidence + if attribution and not attribution_ev: + errs.append("attribution_source present requires attribution_discriminating_evidence_refs (minItems 1)") + + return errs + + +for path in sorted(FIXTURES.glob("*.json")): + is_reject = path.name.startswith("reject_") + label = path.name + + try: + data = json.loads(path.read_text()) + except json.JSONDecodeError as e: + fail(f"json-parse {label}", str(e)) + continue + + ok(f"json-parse {label}") + + v = jsonschema.Draft202012Validator(SCHEMA) + schema_errs = list(v.iter_errors(data)) + policy_errs = policy_gate_errors(data) + has_errors = bool(schema_errs) or bool(policy_errs) + + if is_reject: + if has_errors: + ok(f"reject-expected {label}") + else: + fail(f"reject-fixture {label}", "expected failure but fixture appears valid") + else: + for e in schema_errs: + fail(f"schema {label}", e.message) + for e in policy_errs: + fail(f"policy-gate {label}", e) + if not schema_errs and not policy_errs: + ok(f"valid {label}") + +passed = sum(results) +if errors: + print(file=sys.stderr) + for e in errors: + print(e, file=sys.stderr) + print(f"\n{passed} passed, {len(errors)} failed", file=sys.stderr) + sys.exit(1) + +print(f"\n{passed} boundary-calculus-evidence checks passed")