| name | cfn-epic-creator-v2 |
| description | Hybrid AISP epic creation: formal API contracts plus natural language content. Use when epic needs AISP (AI Symbolic Protocol) type definitions and agent binding contracts alongside human-readable descriptions. |
| version | 2.0.0 |
| tags | ["epic","creator","aisp","contracts","types","hybrid"] |
| status | production |
CFN Epic Creator v2 (AISP Hybrid)
Supersedes cfn-epic-creator (v1, deprecated). For full tiered planning with the verifiable-done + haiku-executable gates, cfn-megaplan is the canonical entry point; use cfn-epic-creator-v2 directly when you specifically need AISP formal contracts in an epic doc. Output feeds cfn-epic-parser.
Overview
Epic Creator v2 integrates AISP (AI Symbolic Protocol) for formal API contracts while keeping natural language for user-facing content. This hybrid approach:
- Eliminates type drift between backend/frontend agents (97x improvement in multi-agent pipelines)
- Preserves human readability for user approval checkpoints
- Adds formal binding contracts for agent handoffs
What Changed from v1
| Aspect | v1 | v2 |
|---|
| API types | Prose in JSON ("type: string") | AISP formal types (TypeââšA|B|Câ©) |
| Agent handoffs | Implicit | Explicit AISP binding contracts |
| Database schema | SQL comments | AISP formal constraints |
| Error handling | Scattered strings | AISP typed errors |
| UI flows | Prose descriptions | AISP state machines |
| Acceptance criteria | Prose | AISP predicates (testable) |
| Feature flags | Ad-hoc | AISP with dependency rules |
| Migrations | File naming | AISP dependency graph |
| Descriptions | Natural language | Natural language (unchanged) |
| User stories | Natural language | Natural language (unchanged) |
| Risks | Natural language | Natural language (unchanged) |
| Validation | JSON schema | AISP Ambig(D)<0.02 invariant |
Natural Language vs AISP
| Use AISP | Keep Natural Language |
|---|
| API types & contracts | Epic title & description |
| Database schemas | User stories |
| Error definitions | Risk descriptions |
| State machines | Architecture prose |
| Acceptance predicates | Mitigation strategies |
| Feature flags | Persona recommendations |
| Migration ordering | Implementation notes |
| Agent bindings | UI copy & microcopy |
AISP Integration Points
1. Technical Requirements Types (MANDATORY)
The technicalRequirements.contracts section uses AISP format:
âŠÎŁ:Typesâ§{
;; Enums with explicit variants
FamilyTypeââšCore|Extended|Chosenâ©
Privacyââšpublic|privateâ©
MemberRoleââšowner|member|editorâ©
;; Constrained primitives
UUIDâđ:len(36)
InviteCodeâđ:len(6)â§uppercase
FamilyNameâđ:len(n)â§3â€nâ€50
;; Request/Response pairs
CreateFamilyRequestââš
name:FamilyName,
type:FamilyType,
privacy:Privacy
â©
CreateFamilyResponseââš
id:UUID,
name:FamilyName,
type:FamilyType, ;; Same enum - no string drift
privacy:Privacy,
inviteCode:InviteCode,
createdAt:ISO8601
â©
}
âŠÎ:Rulesâ§{
;; Validation constraints
âreq:CreateFamilyRequest:
len(req.name)â„3â§len(req.name)â€50
;; Response guarantees
âres:CreateFamilyResponse:
res.typeâFamilyTypeâ§res.privacyâPrivacy
}
âŠÎ:Funcsâ§{
createFamily:CreateFamilyRequestâCreateFamilyResponse
POST /api/family
auth:JWT
getMyFamilies:UnitâListâšFamilyWithCountâ©
GET /api/family/my-families
auth:JWT
}
2. Agent Binding Contracts (NEW)
Each persona handoff has formal pre/post conditions:
âŠÎ:Bindingâ§{
;; Architect â Backend handoff
Îâλ(Architect,Backend)âcase[
Post(Architect.interfaces)âPre(Backend.implementation) â 3, ;; zero-cost
Type(Architect.types)â Type(Backend.types) â 2, ;; adapt needed
_ â 1 ;; null - fail
]
;; Backend â Frontend handoff
Îâλ(Backend,Frontend)âcase[
Post(Backend.api)âPre(Frontend.calls) â 3,
_ â 2 ;; Frontend must adapt to backend contract
]
;; Invariant: exactly one binding state
âA,B:|{Îâλ(A,B)}|âĄ1
}
3. Database Schema Contracts (HIGH VALUE)
Formal schema definitions eliminate interpretation variance:
âŠÎŁ:Tablesâ§{
familiesââš
id:UUID:primary_key:default(gen_random_uuid()),
name:VARCHAR(100):not_null:check(len(name)â„3),
type:family_type_enum:not_null:default('core'),
invite_code:VARCHAR(6):unique:not_null,
created_by:UUID:not_null:references(auth.users.id)
â©
}
âŠÎ:RLSâ§{
policy_families_selectâ
âuser,f:families:
canSelect(user,f)â
âm:family_members:m.family_idâĄf.idâ§m.user_idâĄuser.id
}
Template: templates/database-schema.aisp
4. Error Handling Contracts (HIGH VALUE)
Type-safe errors with consistent messaging:
âŠÎŁ:Errorsâ§{
FAMILY_NOT_FOUNDââš
code:1001,
status:404,
technical:"Family with ID {id} not found",
user_friendly:"We couldn't find that family.",
senior_friendly:"The family you're looking for doesn't exist. Try checking your family list.",
retryable:false
â©
}
âŠÎ:Precedenceâ§{
priority:[AUTHENTICATION,AUTHORIZATION,NOT_FOUND,VALIDATION,SERVER]
}
Template: templates/error-handling.aisp
5. State Machine / UI Flows (HIGH VALUE)
Formal navigation flows with guards and actions:
âŠÎ:Transitionsâ§{
DashboardâFamilyCreate:onClick("Create Family")
FamilyCreateâFamilyShowInvite:onSuccess(createFamily)
FamilyCreateâFamilyCreate:onError(validation)
;; Auth-triggered transitions
âs:ViewState:sâLogin:onAuthExpired
}
âŠÎ:Guardsâ§{
canEnter(FamilySettings)â
AuthStateâĄauthenticatedâ§
âm:family_members:m.user_idâĄcurrentUser.idâ§m.roleâĄ'owner'
}
Template: templates/state-machine.aisp
6. Acceptance Criteria as Predicates (HIGH VALUE)
Testable acceptance criteria with auto-generated tests:
âŠÎŁ:Criteriaâ§{
AC_FAMILY_001ââš
feature:FamilyCreate,
scenario:"User creates family with valid name",
given:âšAuthStateâĄauthenticated, FamilyName.validâ©,
when:submit(CreateFamilyRequest),
then:âš
âf:families:f.nameâĄinput.name,
âm:family_members:m.user_idâĄuser.idâ§m.roleâĄ'owner',
response.statusâĄ201
â©
â©
}
âŠÎ:TestGenâ§{
toVitest(AC_FAMILY_001)â"
test('creates family with valid name', async () => {
await createFamily({ name: 'Test Family' });
expect(response.status).toBe(201);
})
"
}
Template: templates/acceptance-criteria.aisp
7. Feature Flags / Configuration (MEDIUM VALUE)
Typed flags with dependency validation:
âŠÎŁ:Flagsâ§{
flag_family_invitesââš
key:"ENABLE_FAMILY_INVITES",
type:boolean,
environments:{
development â enabled:true,
production â percentage:25
},
dependencies:["ENABLE_FAMILY_CREATION"]
â©
}
âŠÎ:Rulesâ§{
;; Dependencies must be enabled first
âf:FeatureFlag:
enabled(f)ââdâf.dependencies:enabled(d)
;; Rollout progression
isEnabled(f,production)âisEnabled(f,staging)
}
Template: templates/config-feature-flags.aisp
8. Migration Ordering (MEDIUM VALUE)
Dependency-ordered migrations with rollback chains:
âŠÎŁ:Migrationsâ§{
m_002_familiesââš
id:"20240115_002_create_families",
category:schema,
dependencies:["20240115_001_create_enums"],
rollback:auto,
breaking:false
â©
}
âŠÎ:Rulesâ§{
;; All dependencies must complete first
âm:Migration:
canExecute(m)ââdâm.dependencies:state(d)âĄcompleted
;; Rollback in reverse order
canRollback(m)ââd:Migration:
mâd.dependenciesâstate(d)â{pending,rolledback}
}
Template: templates/migration-ordering.aisp
9. Evidence Block (REQUIRED)
Every epic must include validation evidence:
âŠÎâ§âš
ÎŽâ0.78 ;; Density score (â„0.75 for ââșâș)
Ïâ96 ;; Completeness %
Ïâââșâș ;; Quality tier
âąAmbig(D)<0.02 ;; Ambiguity invariant
âąBinding:all_zero ;; All handoffs are zero-cost
â©
Output Structure (v2)
{
"epic": {
"id": "EPIC-XXXXXX",
"title": "Natural language title",
"description": "Natural language description for user review",
"status": "in-review",
"contracts": {
"aisp_version": "5.1",
"types": "âŠÎŁ:Typesâ§{...}",
"rules": "âŠÎ:Rulesâ§{...}",
"functions": "âŠÎ:Funcsâ§{...}",
"evidence": "âŠÎâ§âš...â©"
},
"bindings": {
"architect_to_backend": { "state": 3, "symbol": "â€" },
"backend_to_frontend": { "state": 3, "symbol": "â€" },
"frontend_to_tester": { "state": 3, "symbol": "â€" }
},
"personas": [
{
"name": "architect",
"reviewOrder": 3,
"outputs": {
"natural": "System uses modular architecture with...",
"aisp": "âŠÎŁ:Typesâ§{ModuleââšAuth|Family|Storiesâ©...}"
}
}
],
"userStories": [
"As a senior, I want to create a family so I can invite relatives"
],
"riskAssessment": {
"technical": [{"risk": "Natural language description", "mitigation": "Natural language"}]
}
}
}
Persona Review Order (v2)
| Order | Agent | Outputs Natural | Outputs AISP |
|---|
| 1 | simplifier | Scope recommendations | - |
| 2 | product-owner | User stories, acceptance | - |
| 3 | system-architect | Architecture description | Types, Interfaces |
| 4 | security-specialist | Threat model | Safety constraints |
| 5 | backend-developer | Implementation notes | API contracts |
| 6 | react-frontend-engineer | UI components | Consumes backend AISP |
| 7 | devops-engineer | Infrastructure | - |
| 8 | tester | Test strategy | Test predicates |
| 9 | code-standards-reviewer | Naming conventions | Type alignment check |
| 10 | strategic-alignment-reviewer | Integration gaps | Binding validation |
| 11 | simplifier | Final review | - |
AISP Symbol Quick Reference
| Symbol | Meaning | Example |
|---|
â | Definition | TypeââšA|Bâ© |
âšâ© | Tuple/Record | âšname:đ,age:ââ© |
â | Function type | f:AâB |
â | For all | âx:P(x) |
â§ | Logical AND | aâ§b |
â | Element of | xâSet |
â | Subset | Post(A)âPre(B) |
đ | String type | name:đ |
â | Natural number | count:â |
†| Zero-cost bind | Îâλ=3 |
â„ | Crash bind | Îâλ=0 |
ââșâș | Platinum tier | ÎŽâ„0.75 |
Binding States
| State | Code | Symbol | Meaning |
|---|
| Zero-cost | 3 | †| Perfect compatibility |
| Adapt | 2 | λ | Type mismatch, adaptation possible |
| Null | 1 | â
| Socket mismatch, connection fails |
| Crash | 0 | â„ | Logical contradiction |
Main Chat Execution (v2)
Step 1: Create Base Epic with AISP Scaffold
{
"epic_id": "unique-id",
"description": "Natural language epic description",
"contracts": {
"aisp_version": "5.1",
"types": "",
"rules": "",
"functions": "",
"evidence": ""
},
"bindings": {},
"personas": []
}
Step 2: Architect Persona Adds AISP Types
The Architect is the first persona to output AISP. Their task:
Read the epic description and existing codebase.
OUTPUT BOTH:
1. Natural language architecture description
2. AISP contracts block:
âŠÎŁ:Typesâ§{
;; Define all domain types with explicit variants
;; Use enums instead of strings where values are constrained
;; Define request/response pairs for each API
}
âŠÎ:Rulesâ§{
;; Add validation constraints
;; Add invariants that must hold
}
âŠÎ:Funcsâ§{
;; Define API signatures: Method Path
;; Include auth requirements
}
Write AISP to epic.contracts.types, .rules, .functions
Step 3: Backend Consumes Architect AISP
Backend developer reads the AISP contracts and implements:
Read epic.contracts (AISP types and functions).
Your implementation MUST:
1. Use exact types from âŠÎŁ:Typesâ§
2. Implement functions from âŠÎ:Funcsâ§
3. Enforce rules from âŠÎ:Rulesâ§
Add your implementation details (natural language).
Validate binding: Îâλ(Architect,Backend) should be 3 (â€).
Step 4: Frontend Consumes Backend AISP
Frontend reads the same AISP contracts:
Read epic.contracts (AISP types and functions).
Your implementation MUST:
1. Use exact types from âŠÎŁ:Typesâ§ for API calls
2. Call functions defined in âŠÎ:Funcsâ§
3. Handle errors per AISP contract
Binding state Îâλ(Backend,Frontend) should be 3 (â€).
Step 5: Validate All Bindings
Strategic Alignment Reviewer validates:
Check all binding states in epic.bindings:
â(A,B)âHandoffs: Îâλ(A,B)â„2
If any binding is 0 (crash) or 1 (null):
- Flag as blocking issue
- Identify type mismatches
- Recommend fixes
Step 6: Add Evidence Block
Final step before completion:
âŠÎâ§âš
ÎŽâ<calculated_density>
Ïâ<completeness_percent>
Ïâ<quality_tier>
âąAmbig(D)<0.02
âąBinding:âšarch_back:3,back_front:3,front_test:3â©
â©
Benefits Over v1
| Metric | v1 (Prose) | v2 (AISP Hybrid) |
|---|
| API type drift | Common | Eliminated |
| Agent interpretation variance | 40-65% | <2% |
| 10-agent pipeline success | ~1% | ~82% |
| Backend/Frontend mismatch | Frequent | Detected at bind |
| Human readability | Good | Good (unchanged) |
Files
| File | Purpose |
|---|
SKILL.md | This documentation |
reference/aisp-spec.md | Full AISP 5.1 specification |
reference/aisp-reference.md | Symbol reference and examples |
templates/api-contract.aisp | Template for API contracts |
templates/binding-contract.aisp | Template for agent bindings |
templates/database-schema.aisp | Database tables, RLS, indexes |
templates/error-handling.aisp | Typed errors with multilingual messages |
templates/state-machine.aisp | UI states, transitions, guards |
templates/acceptance-criteria.aisp | Testable criteria with auto-gen tests |
templates/config-feature-flags.aisp | Feature flags, rollout rules |
templates/migration-ordering.aisp | Migration dependencies, rollback chains |
lib/validate-aisp.sh | AISP validation helper |
When to Use v2
Use Epic Creator v2 when:
- Epic has API contracts between backend/frontend
- Multiple agents will implement from the same spec
- Type consistency is critical (TypeScript, Rust)
- You want compile-time detection of integration issues
Stick with v1 when:
- Simple single-domain epic
- No API boundaries
- Quick prototype without formal contracts