{"slug": "pactern-language-delegate-the-code-keep-the-contract", "title": "Pactern Language: Delegate the code. Keep the contract", "summary": "Andrew Arrow released Pactern 0.1.0, a developer-preview programming language for AI-written backend components in which an external baseline called a pact defines acceptable behavior separately from the implementation, so agents can change code while the requirement stays fixed. The toolchain checks signatures, effects, arithmetic safety and termination, runs guarded C/Wasm with bounded memory, and rejects stale or weakened edits; static Z3 proof covers only a loop-free pure fragment, loops and recursion remain unsupported, storage is in-memory, and agent productivity gains have not been measured.", "body_md": "### Requirements survive edits.\n\nAn external baseline protects pacts and their meaning-defining helpers. Both text edits and semantic requests face the acceptance gate. Changing a requirement needs approval tied to the exact diff.\n\n[Protected changes](https://github.com/andrewarrow/pactern/blob/main/docs/semantic.md)\n\n0.1.0 · Developer preview\n\nDelegate the code.\n\nKeep the contract.\n\nA programming language for AI-written backend components. You define the requirements. Agents change the implementation. The toolchain checks the agreement.\n\nA repair with a fixed target\n\nA green build means less if an agent also rewrites the expected result. A pact states acceptable behavior separately, so the implementation can change while the requirement stays put.\n\nsrc/quota.ptn · function excerpt\n\n``` php\npub fn reserve(\n    available: I64,\n    amount: I64\n) -> Result<I64, ReserveError> {\n    if (amount <= 0) {\n        return Result::Err(\n            ReserveError::InvalidAmount\n        );\n    }\n    if (amount > available) {\n        return Result::Err(\n            ReserveError::InsufficientQuota\n        );\n    }\n    return Result::Ok(available - amount);\n}\n```\n\nCheck before subtracting.\n\nThe repair rejects invalid amounts and insufficient quota. A valid reservation still has to succeed: returning an error for every request would also violate the pact.\n\n`3`` 4``Err(InsufficientQuota)`\nSame pact in both cases. The verifier also checks arithmetic safety and termination separately.\n\nA useful pact describes acceptable results independently of the algorithm. For quotas, worker allocation, or validation, a few stable properties can constrain many implementations. The pact itself still needs human review.\n\nBeyond a function contract\n\nThe executable quota workflow connects inspection, verification, protected edits, sandboxed execution, and replay.\n\nInspect signatures, callers, effects, and affected pacts through the semantic API. Stage an edit against persistent symbol IDs and a workspace revision. Managed snapshots commit atomically; stale proposals are rejected.\n\nEffect declarations expose requested operations. Host-issued, noncopyable handles grant tenant-scoped access. The Wasm host bounds memory and execution; the quota adapter enforces transactions, budgets, and cleanup.\n\nProofs, runtime guards, and executed tests have separate results bound to source, tools, policy, and artifact hashes. Quota traces replay against their recorded revision with zero live writes. Unknown and unsupported remain explicit.\n\nExpose the defect, reject a weakened pact, apply a proof-gated repair, reject a stale change, and replay the original failure.\n\n```\ncargo run -p pactern --locked \\\n  --example quota_workflow -- target/quota-workflow\n```\n\nA scripted demonstration. Outputs include generated C/Wasm, traces, repair receipts, and artifact-linked evidence.\n\nWhere to use it first\n\nStart with business rules, validation, data transformations, and bounded jobs called by an existing application.\n\nFunctions, records, enums, generics, `Option` and `Result`. Immutable values by default. Explicit local mutation. Checked signed 64-bit arithmetic.\n\n`.ptn` sourceRust toolchainGenerated CWebAssembly\nThe interpreter, C backend, and verifier consume the same typed core representation.\n\nSource checking and formatting, effect and handle checks, guarded C/Wasm execution, seeded property tests, narrow Z3 verification, semantic queries, managed edits, and the transactional quota/replay host.\n\nStatic proof covers a loop-free pure fragment; loops and recursion remain unsupported by the verifier. Invocation arguments are specialized into each Wasm artifact. Storage is in-memory. A complete LSP extension and external CI activation remain open.\n\nAgent productivity gains have not been measured. This is an experimental developer preview.\n\nBuild it. Check it. Run it.\n\nBuild from source, then reserve two units from a balance of three. The CLI compiles the quota function and its pact to guarded Wasm and runs it in the bounded host.\n\nUse the pinned Rust toolchain via rustup. Compiled execution needs Clang and wasm-ld; verification also needs Z3. Exact versions and setup are in the candidate guide.\n\n```\ngit clone https://github.com/andrewarrow/pactern.git\ncd pactern\ncargo build --workspace --locked\n\ncd fixtures/conformance\n../../target/debug/pactern run \\\n  --entry quota::reserve --args '[\"3\",\"2\"]' \\\n  src/quota.ptn contracts/quota.pact.ptn --json\n```\n\nResult`Result::Ok(1)` One unit remains.\n\n```\n../../target/debug/pactern verify \\\n  src/quota.ptn contracts/quota.pact.ptn --json\n```\n\nI64 arguments use JSON decimal strings to preserve their exact value.", "url": "https://wpnews.pro/news/pactern-language-delegate-the-code-keep-the-contract", "canonical_source": "https://andrewarrow.dev/pactern/", "published_at": "2026-10-18 14:24:03+00:00", "updated_at": "2026-10-18 14:47:40.402166+00:00", "lang": "en", "topics": ["ai-agents", "developer-tools", "ai-tools", "ai-safety"], "entities": ["Pactern", "Andrew Arrow", "Z3", "WebAssembly", "Rust"], "also_reported_by": [], "alternates": {"html": "https://wpnews.pro/news/pactern-language-delegate-the-code-keep-the-contract", "markdown": "https://wpnews.pro/news/pactern-language-delegate-the-code-keep-the-contract.md", "text": "https://wpnews.pro/news/pactern-language-delegate-the-code-keep-the-contract.txt", "jsonld": "https://wpnews.pro/news/pactern-language-delegate-the-code-keep-the-contract.jsonld"}}