Formal Specifications as Contracts for Multi-Agent AI Development
AI้งๅ้็บใซใใใฆใ่คๆฐใฎใจใผใธใงใณใใใใผใ ใฎใใใซๅ่ชฟใใใใใซใฏไฝใๅฟ ่ฆใ๏ผ
ๅพๆฅใฎใในใ้งๅ้็บ๏ผTDD๏ผใฏใๅธฐ็ด็ๆจ่ซใซๅบใฅใใฆใใพใใใในใใฑใผในใๆธใใฆๅฎ่ฃ ใๆค่จผใใพใใใใใใฏใใใพใง็นๅฎใฎใฑใผในใฎๆญฃๅฝๆงใ็คบใใ ใใงใใไธๆนใๅฝขๅผไปๆง๏ผFormal Specifications๏ผใฏๆผ็นน็ๆจ่ซใๆไพใใพใใ
ๆฌใใญใธใงใฏใใฎๆ ธใจใชใไปฎ่ชฌ๏ผ ๅฝขๅผไปๆง๏ผVDM-SL๏ผใใจใผใธใงใณใ้ใฎใๅฅ็ดใใจใใฆๆฉ่ฝใใใใใจใงใไปฅไธใๅฎ็พใงใใ๏ผ
- ่คๆฐใฎAIใจใผใธใงใณใใ็็ตๅใงไธฆ่ก้็บๅฏ่ฝ
- ๅใจใผใธใงใณใใฏ่ชๅใๆ ๅฝใใใขใธใฅใผใซไปๆงใจไพๅญใขใธใฅใผใซใฎใคใณใฟใผใใงใผในไปๆงใฎใฟๅฟ ่ฆ
- ใขใธใฅใผใซ้ใฎไบๆๆงใๆฉๆขฐ็ใซๆค่จผๅฏ่ฝ๏ผA.post โ B.pre ๅๆๅฏ่ฝๆง๏ผ
- ไบบ้ใฎๅฝนๅฒใใใใกใคใณๅฐ้ๅฎถ + ใขใผใญใใฏใใฃๆฑบๅฎ่ ใใธใทใใ
- ๅฝขๅผ็ใชไฟ่จผใซใใใใจใผใธใงใณใใ็ๆใใใณใผใใฎๆญฃๅฝๆงใๆฉๆขฐ็ใซๆค่จผ
ๆฌใชใใธใใชใฏใๅฝขๅผไปๆง้งๅ้็บใฎใขใใญใผใใไฝ็ณปๅใใๅฎ่ทตๅฏ่ฝใซใใใใใฎๅฎๅ จใชใใฌใคใใใฏใงใใVDM-SLใฎไปๆงใใณใใฌใผใใ่คๆฐใจใผใธใงใณใใๅ่ชฟใใใใใญใณใใใๅฎ่ฃ ไพใๆไพใใพใใ
ๅฏพ่ฑก่ ๏ผ ๆ่กใชใผใใปใขใผใญใใฏใใAI้งๅ้็บใฎ่ฉไพกใปๅฐๅ ฅใๆค่จใใฆใใ็ต็น
ใพใใฏๅบ็คใจใชใ่ซๆใ็่งฃใใฆใใ ใใ๏ผ
- ๆฅๆฌ่ช็:
docs/ja/paper.md- ๅฝขๅผไปๆง้งๅ้็บใฎ็่ซใจๅฎ่ทต - ่ฑ่ช็:
docs/en/paper.md- English full article
่ชญไบๆ้: 20-30ๅ
ๆไพใใใฆใใใใณใใฌใผใใไฝฟ็จใใฆใๅฐ่ฆๆจกใชใขใธใฅใผใซไปๆงใไฝๆใใฆใฟใฆใใ ใใ๏ผ
# VDM-SLไปๆงใใณใใฌใผใใฎ็ขบ่ช
cd templates/vdm-sl/
cat module-template.vdmsl
# AIใใญใณใใใใณใใฌใผใใฎ็ขบ่ช
cd templates/prompts/
ls -la่ฉณ็ดฐใฏ templates/vdm-sl/README.md ใๅ็
ง
ๅฎ้ใฎE-commerceใชใผใใผใทในใใ ใฎไพใ่ฆใฆใใใญใปในๅ จไฝใ็่งฃใใฆใใ ใใ๏ผ
cd examples/ec-site-order/
cat README.mdใใฎใตใณใใซใงใฏใไปฅไธใ็ขบ่ชใงใใพใ๏ผ
- 3ใคใฎใขใธใฅใผใซ๏ผๆณจๆใๅจๅบซใๆฑบๆธ๏ผใฎไปๆง
- ๅใจใผใธใงใณใใๅใๅใฃใใใญใณใใ
- VDM-SLใใ็ๆใใใๅฎ่ฃ ใณใผใ
ใขใธใฅใผใซA ใขใธใฅใผใซB
โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโ
โ ไบๅๆกไปถ โ โ ไบๅๆกไปถ โ
โ (precond) โ โ (precond) โ
โ โ โ โ
โ ไบๅพๆกไปถ โโโโๅฅ็ดโโโโโโโ ไบๅๆกไปถ โ
โ (postcond) โ โ (precond) โ
โ โ A.post โ โ
โโโโโโโโโโโโโโโ โ โ ไบๅพๆกไปถ โ
B.pre โ (postcond) โ
โโโโโโโโโโโโโโโ
A ใฎไบๅพๆกไปถใ B ใฎไบๅๆกไปถใๆบใใใฐใๆฉๆขฐ็ใซๅๆๅฏ่ฝๆงใๆค่จผใงใใพใใ
-
ใใกใคใณๅฐ้ๅฎถใจใผใธใงใณใ
- ใใธใใน่ฆไปถใใๅฝขๅผไปๆงใๅฏพ่ฉฑ็ใซๅฐๅบ
- ใขใธใฅใผใซ้ใฎใคใณใฟใผใใงใผใน่จญ่จ
-
ๅฎ่ฃ ใจใผใธใงใณใ
- ๅฝขๅผไปๆงใไธใใใใฆใๅฎ่ฃ ใ็ๆ
- ใในใใฑใผใน็ๆใ่ชๅๅ
-
ๆค่จผใจใผใธใงใณใ
- VDM-SLในใใใฏใฎๅฝขๅผ็ๆค่จผใๅฎ่ก
- ไปๆง้ใฎๅๆๅฏ่ฝๆงใ็ขบ่ช
| ้ ็ฎ | TDD๏ผๅธฐ็ด็๏ผ | ๅฝขๅผไปๆง้งๅ๏ผๆผ็นน็๏ผ |
|---|---|---|
| ๆจ่ซๆนๆณ | ใในใใฑใผใน โ ๆญฃๅฝๆงใฎๅธฐ็ด | ไปๆง โ ๅฎ่ฃ ใฎๆผ็นน |
| ๆค่จผในใณใผใ | ใในใใฑใผในใๅฏพ่ฑกใใ้จๅ | ไปๆงๅ จไฝใใซใใผ |
| ใจใผใธใงใณใๅ่ชฟ | ใในใใๅ ฑๆใปๅ็ ง | ไปๆงใๅ ฑๆใปๅ็ ง |
| ในใฑใผใฉใใชใใฃ | ใในใๆฐใฎๅขๅ ใซไผดใใกใณใใใณในใณในใ | ไปๆงใฎๆ็ขบใใซใใ |
| ๆฉๆขฐ็ไฟ่จผ | ใชใ | ใใ |
formal-spec-driven-dev/
โโโ README.md # ใใฎใใกใคใซ
โโโ LICENSE # Apache 2.0
โโโ CONTRIBUTING.md # ่ฒข็ฎใฌใคใ
โ
โโโ docs/
โ โโโ ja/
โ โ โโโ paper.md # ่ซๆ๏ผๆฅๆฌ่ช็๏ผ
โ โ โโโ architecture-guide.md # ่คๆฐใจใผใธใงใณใใปใขใผใญใใฏใใฃใฌใคใ
โ โโโ en/
โ โ โโโ paper.md # ่ซๆ๏ผ่ฑ่ช็๏ผ
โ โ โโโ architecture-guide.md # Multi-agent Architecture Guide
โ โโโ images/ # ใใคใขใฐใฉใ ็ญ
โ
โโโ templates/
โ โโโ vdm-sl/
โ โ โโโ module-template.vdmsl # ๅไธใขใธใฅใผใซ็จใใณใใฌใผใ
โ โ โโโ interface-contract.vdmsl # ใขใธใฅใผใซ้ๅฅ็ด็จใใณใใฌใผใ
โ โ โโโ README.md # VDM-SLไฝฟ็จๆนๆณ
โ โ
โ โโโ prompts/
โ โ โโโ phase1-specification.md # ใใงใผใบ1๏ผไปๆงๅฏพ่ฉฑใใญใณใใ
โ โ โโโ phase2-design.md # ใใงใผใบ2๏ผ่จญ่จใใญใณใใ
โ โ โโโ phase3-implementation.md # ใใงใผใบ3๏ผๅฎ่ฃ
ใใญใณใใ
โ โ โโโ phase4-verification.md # ใใงใผใบ4๏ผๆค่จผใใญใณใใ
โ โ
โ โโโ orchestration/
โ โโโ agent-config.yaml # ใจใผใธใงใณใๅฝนๅฒๅฎ็พฉ
โ โโโ workflow.md # ใชใผใฑในใใฌใผใทใงใณใฏใผใฏใใญใผ
โ
โโโ examples/
โ โโโ ec-site-order/
โ โโโ README.md # ใใฎใตใณใใซใฎ่ชฌๆ
โ โโโ .vdm/ # VDM-SLไปๆงใใกใคใซ
โ โ โโโ order-module.vdmsl
โ โ โโโ inventory-module.vdmsl
โ โ โโโ payment-module.vdmsl
โ โโโ prompts/ # ๅฎ้ใซไฝฟ็จใใใใญใณใใ
โ
โโโ .github/
โโโ ISSUE_TEMPLATE/ # Issue ใใณใใฌใผใ
ใใฎใใญใธใงใฏใใธใฎ่ฒข็ฎใๆญ่ฟใใพใใไปฅไธใฎๆนๆณใงใๅๅ ใใ ใใ๏ผ
-
ใใฃใผใใใใฏใปๆ่ฆๆๆก
- GitHub Issues ใงๆฉ่ฝๆๆกใปใใฐๅ ฑๅใไฝๆ
-
ใใญใฅใกใณใๆนๅ
- ๆฅๆฌ่ชใป่ฑ่ชใฎๆ็ซ ๆนๅใไพใฎ่ฟฝๅ
-
ๆฐใใใใณใใฌใผใใปไพใฎๆไพ
- ็ฐใชใใใกใคใณใฎVDM-SLใใณใใฌใผใ
- ๆฐใใใใญใณใใใใฟใผใณ
-
ๅฎ่ฃ ใธใฎๅๅ
- ๆค่จผใใผใซใฎๆนๅ
- ใชใผใฑในใใฌใผใทใงใณๆฉ่ฝใฎๆกๅผต
่ฉณ็ดฐใฏ CONTRIBUTING.md ใๅ็
งใใฆใใ ใใใ
ใใฎใใญใธใงใฏใใฏ Apache License 2.0 ใฎไธใงๅ
ฌ้ใใใฆใใพใใ
่ฉณ็ดฐใฏ LICENSE ใๅ็
งใใฆใใ ใใใ
- ่ซๆ๏ผๆฅๆฌ่ช๏ผ: docs/ja/paper.md
- ่ซๆ๏ผ่ฑ่ช๏ผ: docs/en/paper.md
- Claude Codeๅฎ่ทตใฌใคใ: docs/claude-code-integration.md โ CLAUDE.mdใฎ้ๅฑคๆง้ ใๆดป็จใใๅ ทไฝ็ใช้็บๆนๆณ
- ใใซใใจใผใธใงใณใใปใขใผใญใใฏใใฃใฌใคใ๏ผๆฅๆฌ่ช๏ผ: docs/ja/architecture-guide.md
- ใใซใใจใผใธใงใณใใปใขใผใญใใฏใใฃใฌใคใ๏ผ่ฑ่ช๏ผ: docs/en/architecture-guide.md
- VDM-SLใใณใใฌใผใไฝฟ็จๆนๆณ: templates/vdm-sl/README.md
Hikaru Ando (ๅฎ่คๅ ๅคช้) (ando@iid.systems) IID Systems
What does it take for multiple AI agents to collaborate like a development team?
Traditional Test-Driven Development (TDD) relies on inductive reasoning. Writing test cases validates an implementation, but only for specific scenarios. Formal specifications, by contrast, provide deductive reasoning.
The core hypothesis of this project: By making formal specifications (VDM-SL) function as "contracts" between agents, we can achieve:
- Multiple AI agents developing in parallel with loose coupling
- Each agent needing only their own module spec and dependent module interface specs
- Mechanical verification of module compatibility (A.post โ B.pre composability)
- A shift in human roles to "domain expert + architecture decision maker"
- Formal guarantees enabling mechanical verification of agent-generated code
This repository systematizes the formal-specification-driven development approach and makes it practically deployable. It provides VDM-SL specification templates, prompts for coordinating multiple agents, and working examples.
Intended for: Tech leads and architects evaluating and adopting AI-driven development within their organizations
First, understand the foundational theory:
- Japanese version:
docs/ja/paper.md- Theory and practice of formal-specification-driven development - English version:
docs/en/paper.md- Full English article
Reading time: 20-30 minutes
Use the provided templates to create a small module specification:
# Review VDM-SL specification templates
cd templates/vdm-sl/
cat module-template.vdmsl
# Review AI prompt templates
cd templates/prompts/
ls -laDetails available in templates/vdm-sl/README.md
Examine the e-commerce order system example to understand the entire process:
cd examples/ec-site-order/
cat README.mdThe sample demonstrates:
- Specifications for three modules (order, inventory, payment)
- Actual prompts given to each agent
- Implementation code generated from VDM-SL specs
Module A Module B
โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโ
โ Preconditionโ โ Preconditionโ
โ (precond) โ โ (precond) โ
โ โ โ โ
โ Postcondition โโโโ Preconditionโ
โ (postcond) โโโโContract โ (precond) โ
โ โ A.post โ โ โ
โโโโโโโโโโโโโโโ B.pre โ Postcondition
โ (postcond) โ
โโโโโโโโโโโโโโโ
When A's postcondition satisfies B's precondition, mechanical composability verification becomes possible.
-
Domain Expert Agent
- Derives formal specifications from business requirements through dialogue
- Designs module interfaces
-
Implementation Agent
- Generates implementation from formal specs
- Automates test case generation
-
Verification Agent
- Executes formal verification of VDM-SL specs
- Confirms composability between specs
| Aspect | TDD (Inductive) | Formal-Spec-Driven (Deductive) |
|---|---|---|
| Reasoning | Test cases โ Inductive proof | Spec โ Deductive implementation |
| Verification scope | Only tested cases | Entire specification |
| Agent coordination | Shared test suite | Shared specification |
| Scalability | Test maintenance overhead | Specification clarity |
| Mechanical guarantee | None | Yes |
formal-spec-driven-dev/
โโโ README.md # This file
โโโ LICENSE # Apache 2.0
โโโ CONTRIBUTING.md # Contribution Guidelines
โ
โโโ docs/
โ โโโ ja/
โ โ โโโ paper.md # Paper (Japanese)
โ โ โโโ architecture-guide.md # Multi-agent Architecture Guide (JP)
โ โโโ en/
โ โ โโโ paper.md # Paper (English)
โ โ โโโ architecture-guide.md # Multi-agent Architecture Guide (EN)
โ โโโ images/ # Diagrams and illustrations
โ
โโโ templates/
โ โโโ vdm-sl/
โ โ โโโ module-template.vdmsl # Single module template
โ โ โโโ interface-contract.vdmsl # Inter-module contract template
โ โ โโโ README.md # How to use VDM-SL templates
โ โ
โ โโโ prompts/
โ โ โโโ phase1-specification.md # Phase 1: Specification dialogue prompt
โ โ โโโ phase2-design.md # Phase 2: Design prompt
โ โ โโโ phase3-implementation.md # Phase 3: Implementation prompt
โ โ โโโ phase4-verification.md # Phase 4: Verification prompt
โ โ
โ โโโ orchestration/
โ โโโ agent-config.yaml # Agent role definitions
โ โโโ workflow.md # Orchestration workflow guide
โ
โโโ examples/
โ โโโ ec-site-order/
โ โโโ README.md # This example explained
โ โโโ .vdm/ # VDM-SL specification files
โ โ โโโ order-module.vdmsl
โ โ โโโ inventory-module.vdmsl
โ โ โโโ payment-module.vdmsl
โ โโโ prompts/ # Actual prompts used
โ
โโโ .github/
โโโ ISSUE_TEMPLATE/ # Issue templates
We welcome contributions to this project. You can participate in the following ways:
-
Feedback and Suggestions
- Create issues for feature requests or bug reports on GitHub
-
Documentation Improvements
- Improve Japanese and English documentation
- Add examples and clarifications
-
New Templates and Examples
- Provide VDM-SL templates for different domains
- Contribute new prompt patterns
-
Implementation Support
- Improve verification tools
- Enhance orchestration features
See CONTRIBUTING.md for detailed guidelines.
This project is released under the Apache License 2.0.
See LICENSE for details.
- Paper (Japanese): docs/ja/paper.md
- Paper (English): docs/en/paper.md
- Claude Code Integration Guide: docs/claude-code-integration.md โ Practical guide using CLAUDE.md hierarchy for formal-spec-driven development
- Multi-Agent Architecture Guide (Japanese): docs/ja/architecture-guide.md
- Multi-Agent Architecture Guide (English): docs/en/architecture-guide.md
- VDM-SL Templates Usage: templates/vdm-sl/README.md
Hikaru Ando (ๅฎ่คๅ ๅคช้) (ando@iid.systems) IID Systems
Made with commitment to formal methods and AI-driven development.
