mirror of
https://github.com/saymrwulf/proof-aware-crypto-tooling-agent.git
synced 2026-09-03 19:53:43 +00:00
169 lines
6.3 KiB
Text
169 lines
6.3 KiB
Text
|
|
{
|
||
|
|
"cells": [
|
||
|
|
{
|
||
|
|
"cell_type": "markdown",
|
||
|
|
"metadata": {},
|
||
|
|
"source": [
|
||
|
|
"# Lecture 7: Agent Consequences\n",
|
||
|
|
"\n",
|
||
|
|
"An evidence interpreter is incomplete if nothing changes after evaluation. PACTA has a small consequence engine: it can build a lower-layer Rust decision capsule when evidence satisfies policy, and it refuses wallet construction when coverage is insufficient.\n"
|
||
|
|
]
|
||
|
|
},
|
||
|
|
{
|
||
|
|
"cell_type": "markdown",
|
||
|
|
"metadata": {},
|
||
|
|
"source": [
|
||
|
|
"## Learning Objectives\n",
|
||
|
|
"\n",
|
||
|
|
"- Explain how risk levels map to actions.\n",
|
||
|
|
"- Run a dry-run agent action.\n",
|
||
|
|
"- Understand the generated Rust capsule.\n",
|
||
|
|
"- Explain why R3 permits lower-layer use but denies wallet demos.\n",
|
||
|
|
"- Connect transparency receipts to build authorization.\n"
|
||
|
|
]
|
||
|
|
},
|
||
|
|
{
|
||
|
|
"cell_type": "markdown",
|
||
|
|
"metadata": {},
|
||
|
|
"source": [
|
||
|
|
"## Action Policy\n",
|
||
|
|
"\n",
|
||
|
|
"Current actions:\n",
|
||
|
|
"\n",
|
||
|
|
"- `build-library`: default threshold R3. Produces a proof-gated component capsule.\n",
|
||
|
|
"- `build-wallet-demo`: threshold R4. Writes a denial artifact below R4.\n",
|
||
|
|
"\n",
|
||
|
|
"This is deliberately conservative. The theorem boundary for Ed25519 field plus Edwards arithmetic is valuable, but it does not cover key custody, encoding, hashing, scalar arithmetic completeness, signature verification, transaction construction, or market decisions.\n"
|
||
|
|
]
|
||
|
|
},
|
||
|
|
{
|
||
|
|
"cell_type": "code",
|
||
|
|
"execution_count": null,
|
||
|
|
"metadata": {},
|
||
|
|
"outputs": [],
|
||
|
|
"source": [
|
||
|
|
"from pathlib import Path\n",
|
||
|
|
"import sys\n",
|
||
|
|
"\n",
|
||
|
|
"repo_root = Path.cwd()\n",
|
||
|
|
"if not (repo_root / \"src\" / \"pacta\").exists():\n",
|
||
|
|
" repo_root = repo_root.parent\n",
|
||
|
|
"sys.path.insert(0, str(repo_root / \"src\"))\n",
|
||
|
|
"\n",
|
||
|
|
"from pacta.agent import run_agent_action\n",
|
||
|
|
"from pacta.claims import build_claim_card\n",
|
||
|
|
"from pacta.config import load_config\n",
|
||
|
|
"\n",
|
||
|
|
"repo = load_config(repo_root / \"examples\" / \"repos.yaml\").repo_named(\"dalek-ed25519-verified\")\n",
|
||
|
|
"card = build_claim_card(repo, repo_root / \"repos\" / repo.name, offline_fixture=True)\n",
|
||
|
|
"\n",
|
||
|
|
"library_decision = run_agent_action(card, \"build-library\", repo_root / \"artifacts-notebook\", dry_run=True)\n",
|
||
|
|
"wallet_decision = run_agent_action(card, \"build-wallet-demo\", repo_root / \"artifacts-notebook\", dry_run=True)\n",
|
||
|
|
"print(library_decision.to_dict())\n",
|
||
|
|
"print(wallet_decision.to_dict())\n"
|
||
|
|
]
|
||
|
|
},
|
||
|
|
{
|
||
|
|
"cell_type": "markdown",
|
||
|
|
"metadata": {},
|
||
|
|
"source": [
|
||
|
|
"## The Rust Capsule\n",
|
||
|
|
"\n",
|
||
|
|
"The generated capsule is not cryptographic code. It is a consumable policy artifact. It embeds the claim card and exposes constants such as:\n",
|
||
|
|
"\n",
|
||
|
|
"- component,\n",
|
||
|
|
"- repo URL,\n",
|
||
|
|
"- kind,\n",
|
||
|
|
"- verified backend,\n",
|
||
|
|
"- risk level,\n",
|
||
|
|
"- evidence mode,\n",
|
||
|
|
"- attestation provider,\n",
|
||
|
|
"- deployment constraints.\n",
|
||
|
|
"\n",
|
||
|
|
"Downstream automation can import this crate and check `allowed_for_lower_layer_crypto()` before enabling a code path.\n"
|
||
|
|
]
|
||
|
|
},
|
||
|
|
{
|
||
|
|
"cell_type": "code",
|
||
|
|
"execution_count": null,
|
||
|
|
"metadata": {},
|
||
|
|
"outputs": [],
|
||
|
|
"source": [
|
||
|
|
"from pacta.artifact import _lib_rs\n",
|
||
|
|
"\n",
|
||
|
|
"print(_lib_rs(card).splitlines()[:24])\n"
|
||
|
|
]
|
||
|
|
},
|
||
|
|
{
|
||
|
|
"cell_type": "markdown",
|
||
|
|
"metadata": {},
|
||
|
|
"source": [
|
||
|
|
"## Receipt-Required Builds\n",
|
||
|
|
"\n",
|
||
|
|
"The strongest dogfood path in this prototype is:\n",
|
||
|
|
"\n",
|
||
|
|
"1. Provider replays Lean and signs attestation.\n",
|
||
|
|
"2. Provider appends attestation to a Merkle transparency log.\n",
|
||
|
|
"3. Provider emits an inclusion receipt with Signed Tree Head.\n",
|
||
|
|
"4. Agent verifies provider signature, receipt inclusion proof, and STH signature.\n",
|
||
|
|
"5. Agent builds only if risk and transparency policy pass.\n",
|
||
|
|
"\n",
|
||
|
|
"This transforms \"I read a report\" into \"I accepted a logged, signed proof-check result and acted within its theorem boundary.\"\n"
|
||
|
|
]
|
||
|
|
},
|
||
|
|
{
|
||
|
|
"cell_type": "markdown",
|
||
|
|
"metadata": {},
|
||
|
|
"source": [
|
||
|
|
"## Command-Line Lab\n",
|
||
|
|
"\n",
|
||
|
|
"Run these from the repository root after generating a provider attestation:\n",
|
||
|
|
"\n",
|
||
|
|
"```bash\n",
|
||
|
|
"pacta receipt-verify \\\n",
|
||
|
|
" --attestation provider/out/dalek-ed25519.attestation.yaml \\\n",
|
||
|
|
" --receipt provider/out/dalek-ed25519.receipt.yaml \\\n",
|
||
|
|
" --log-public-key provider/state/local-provider/provider.ed25519.pub\n",
|
||
|
|
"\n",
|
||
|
|
"pacta agent \\\n",
|
||
|
|
" --config examples/repos.yaml \\\n",
|
||
|
|
" --repo-name dalek-ed25519-verified \\\n",
|
||
|
|
" --repo repos/dalek-ed25519-verified \\\n",
|
||
|
|
" --attestation provider/out/dalek-ed25519.attestation.yaml \\\n",
|
||
|
|
" --trust-attestation-provider local-pacta-provider \\\n",
|
||
|
|
" --attestation-public-key provider/state/local-provider/provider.ed25519.pub \\\n",
|
||
|
|
" --transparency-receipt provider/out/dalek-ed25519.receipt.yaml \\\n",
|
||
|
|
" --transparency-log-public-key provider/state/local-provider/provider.ed25519.pub \\\n",
|
||
|
|
" --require-transparency-receipt \\\n",
|
||
|
|
" --action build-library\n",
|
||
|
|
"```\n"
|
||
|
|
]
|
||
|
|
},
|
||
|
|
{
|
||
|
|
"cell_type": "markdown",
|
||
|
|
"metadata": {},
|
||
|
|
"source": [
|
||
|
|
"## Exercises\n",
|
||
|
|
"\n",
|
||
|
|
"- Modify a claim card to R2 and show that `build-library` is refused.\n",
|
||
|
|
"- Explain why a denial artifact is useful for auditability.\n",
|
||
|
|
"- Design a policy where an agent requires `both` Ed25519 and ML-DSA signatures for production deployment but allows Ed25519-only in a local lab.\n",
|
||
|
|
"- Write a downstream Rust pseudo-code snippet that imports the generated capsule before enabling a code path.\n"
|
||
|
|
]
|
||
|
|
}
|
||
|
|
],
|
||
|
|
"metadata": {
|
||
|
|
"kernelspec": {
|
||
|
|
"display_name": "Python 3",
|
||
|
|
"language": "python",
|
||
|
|
"name": "python3"
|
||
|
|
},
|
||
|
|
"language_info": {
|
||
|
|
"name": "python",
|
||
|
|
"pygments_lexer": "ipython3"
|
||
|
|
}
|
||
|
|
},
|
||
|
|
"nbformat": 4,
|
||
|
|
"nbformat_minor": 5
|
||
|
|
}
|