Formalize

From tyevans/tackline · View interactive version

Formalize is an AI agent skill from the GitHub repository tyevans/tackline. Use after a human jam session to turn agreements into code. Converts shared artifacts into versioned event schemas, mocks, and validation config. Keywords: formalize, contracts, event schemas, boundaries, multi-human, event storming.

How to use this skill

Skill file

Formalize: Event Contract Generation from Jam Artifacts

You are running the formalize skill — Phase 3 of the multi-human Event Storming workflow. Input: $ARGUMENTS

This skill consumes the shared jam artifact produced by a human jam session (seeded by /storm-prep) and generates machine-readable event contracts that /integrate will use to wire services together.

When to Use

DO NOT Use When

Named Law

NO SCHEMA WITHOUT JAM ARTIFACT — If you are formalizing from assumptions rather than a shared artifact, STOP. Return to /storm-prep and complete the jam session. Contracts without jam artifacts are guesses wearing a schema's clothing.

What NOT to Do

Overview

$ARGUMENTS (shared jam artifact path)
    |
    v
Phase 0: Gate — artifact exists and readable?
    |
    v
Phase 1: Parse — extract this human's bounded context, owned events, consumed events
    |
    v
Phase 2: Schema generation — versioned YAML schemas with field definitions and confidence tags
    |
    v
Phase 3: Mock generation — mock producers for consumed events, stub consumers for provided events
    |
    v
Phase 4: Validation config — contract-aware validation for local /sprint agents
    |
    v
Output: contracts/agreed/*.schema.yaml + mocks/ + validation config + pipe-format summary

Phase 0: Gate (Precondition Check)

STOP if any gate fails. Do not proceed to Phase 1 until all gates pass.

Gate 1 — Artifact path provided

If $ARGUMENTS is empty, ask: "What is the path to the shared jam artifact? (e.g., docs/jam/session-YYYY-MM-DD.md)"

Gate 2 — Artifact exists and is readable

Read the file at $ARGUMENTS. If the file does not exist or cannot be read:

"Jam artifact not found at <path>. Ensure the shared artifact from your human jam session is committed and accessible before running /formalize. If you have not completed a jam session, run /storm-prep first."

Gate 3 — Artifact has required structure

Scan the artifact for:

If the artifact is missing any of these:

"The jam artifact at <path> is missing required sections: [list what is missing]. Complete the human jam session and update the artifact before formalizing. Formalize codifies agreement — it cannot create it."

Gate 4 — Identify this human's context

Ask (or detect from $ARGUMENTS if a context name was provided): "Which bounded context are you formalizing contracts for?"

State the detected context before proceeding: "Formalizing contracts for bounded context: <context-name>"


Phase 1: Parse Shared Artifact

Read the full shared artifact. Extract three lists for this human's bounded context only:

1a. Owned Events

Events this context produces and owns — the events for which this team generates authoritative schemas.

For each owned event, extract:

1b. Consumed Events

Events this context receives from other bounded contexts. This context does not own these schemas — it generates mocks for local testing only.

For each consumed event, extract:

1c. Boundary Agreements

Explicit interface contracts agreed at the boundary:

Parse Report

Print a structured summary before proceeding to Phase 2:

## Parse Summary: <context-name>

**Owned events**: N
  - <event-name> (CONFIRMED | LIKELY | POSSIBLE)
  - ...

**Consumed events**: N
  - <event-name> from <owning-context>
  - ...

**Boundary agreements**: N
  - <agreement summary>
  - ...

**Unresolved items** (require user input before schema generation):
  - <item> — [what is unclear]
  - ...

If unresolved items exist, ask the user to resolve them before continuing. Do not proceed to Phase 2 with unresolved ownership or missing field definitions for CONFIRMED events.


Phase 2: Schema Generation

Generate versioned event schemas as YAML for owned events only. Store each schema at contracts/agreed/<event-name>.<version>.schema.yaml.

Create contracts/agreed/ if it does not exist.

Schema Format

Each schema file follows this structure:

# contracts/agreed/<event-name>.<version>.schema.yaml
schema:
  name: <EventName>
  version: "<version>"
  owner: "<bounded-context-name>"
  source: "<path-to-jam-artifact>"
  formalized: "<YYYY-MM-DD>"

description: >
  <One paragraph describing what this event means in the domain,
  when it is emitted, and what guarantees the producer makes.>

fields:
  - name: <field-name>
    type: <string | integer | boolean | object | array | uuid | timestamp | enum>
    required: true | false
    description: "<What this field means. Cite the jam artifact if named explicitly.>"
    confidence: CONFIRMED | LIKELY | POSSIBLE
    constraints:
      - <e.g., "non-empty string", "ISO 8601 timestamp", "must be a valid UUID">
    example: <example value>

  - name: <field-name>
    ...

envelope:
  topic: "<message-bus-topic or queue name, if agreed>"
  ordering-key: "<field used for ordering, if agreed>"
  idempotency-key: "<field used for deduplication, if agreed>"

unresolved:
  - "<description of any POSSIBLE-confidence element needing human sign-off>"

Confidence Tagging Rules

Tag every field with its confidence level. Do not omit tags on the grounds that "it is obvious."

Schema Generation Loop

For each owned event:

  1. Create the schema file at contracts/agreed/<event-name>.<version>.schema.yaml
  2. Populate from the parse output in Phase 1a
  3. Tag each field with confidence
  4. Add any POSSIBLE-confidence items to the unresolved section
  5. State: "Written: contracts/agreed/<event-name>.<version>.schema.yaml (N fields, M unresolved)"

After all schemas are written, list the schema files created.


Phase 3: Mock Generation

Generate mock producers and stub consumers to enable local development without cross-team coordination.

3a. Mock Producers (for consumed events)

For each consumed event identified in Phase 1b, generate a mock producer that emits plausible test payloads. This lets local agents simulate upstream events without requiring the owning team's service.

Create mocks/producers/<event-name>-mock.yaml:

# mocks/producers/<event-name>-mock.yaml
mock:
  event: <EventName>
  owner: <owning-context>
  warning: "This mock is for LOCAL TESTING ONLY. Do not use in integration or production."
  source-schema: "<path-to-owning-team-schema if available, else 'unknown — schema not yet received'>"

payloads:
  - label: "happy path"
    fields:
      <field>: <plausible-test-value>
      ...

  - label: "edge case: <description>"
    fields:
      <field>: <edge-case-value>
      ...

Notes:

3b. Stub Consumers (for owned events)

For each owned event, generate a stub consumer that documents the expected consumption pattern. This serves as a contract test target.

Create mocks/consumers/<event-name>-stub.yaml:

# mocks/consumers/<event-name>-stub.yaml
stub:
  event: <EventName>
  version: "<version>"
  owner: "<this-context>"
  schema: "contracts/agreed/<event-name>.<version>.schema.yaml"

consumption-contract:
  reads-fields:
    - <field-name>: "<why this field matters to consumers>"
    ...
  ordering-guarantee: "<guaranteed | best-effort | none>"
  idempotency: "<idempotent | at-least-once | exactly-once | unknown>"

contract-tests:
  - name: "rejects events missing required fields"
    input: { <omit a required field> }
    expected: reject

  - name: "accepts valid happy-path event"
    input: { <all required fields with valid values> }
    expected: accept

Phase 4: Validation Config

Generate a validation config that local /sprint agents can use to enforce contract compliance during development.

Create contracts/validation.yaml:

# contracts/validation.yaml
# Generated by /formalize from <path-to-jam-artifact>
# DO NOT edit manually — re-run /formalize to regenerate

context: "<bounded-context-name>"
formalized: "<YYYY-MM-DD>"

schemas:
  - event: <EventName>
    version: "<version>"
    schema: "contracts/agreed/<event-name>.<version>.schema.yaml"
    role: producer  # this context produces this event
    enforce: strict  # reject events that fail schema validation

  - event: <ConsumedEventName>
    version: "unknown"  # version not yet confirmed from owning team
    mock: "mocks/producers/<event-name>-mock.yaml"
    role: consumer  # this context consumes this event
    enforce: warn   # warn on schema mismatches but do not fail

sprint-agent-instructions: |
  Before dispatching sprint agents that produce or consume events:
  1. Check contracts/validation.yaml to identify owned vs consumed events
  2. Owned events: schema at contracts/agreed/ is authoritative — validate against it
  3. Consumed events: use mocks/producers/ for local testing — do not call real endpoints
  4. Flag any POSSIBLE-confidence fields in schemas as needing human sign-off before shipping
  5. Do not treat consumed event mocks as confirmed schemas — verify with the owning team

unresolved-flags:
  - <description of each POSSIBLE-confidence item requiring human sign-off>

After writing contracts/validation.yaml, read it back and verify it was written correctly. State: "Verified: contracts/validation.yaml written with N owned events and M consumed events."


Output Summary

After all phases complete, emit a pipe-format summary block. This output is consumed by /integrate as its Phase 0 input.

## Formalize Output: <bounded-context-name>

**Source**: /formalize
**Input**: <path to shared jam artifact>
**Pipeline**: /storm-prep (human jam session) -> /formalize

### Items (N)

1. **<EventName> schema** — versioned schema at contracts/agreed/<event-name>.<version>.schema.yaml
   - source: contracts/agreed/<event-name>.<version>.schema.yaml
   - confidence: CONFIRMED | LIKELY

2. **<ConsumedEventName> mock** — mock producer for local testing
   - source: mocks/producers/<event-name>-mock.yaml
   - confidence: LIKELY

3. **Validation config** — sprint-agent contract enforcement rules
   - source: contracts/validation.yaml
   - confidence: CONFIRMED

[... one item per schema, mock, and unresolved flag]

N+1. **Unresolved: <element>** — requires human sign-off before implementation
   - source: <jam artifact section>
   - confidence: POSSIBLE

### Summary

<One paragraph: which bounded context was formalized, how many owned schemas were generated, how many consumed mocks, how many unresolved items require sign-off, and what the integration gate is.>

The pipe-format block is the handoff artifact for /integrate. It lists all schemas, mocks, and unresolved items that the integration phase must reconcile across teams.


Guidelines

  1. Artifact is truth — Every schema element traces to the jam artifact. When in doubt, cite the artifact line. If you cannot cite it, the element is POSSIBLE.
  2. One context per run — Each human runs formalize for their own bounded context only. Do not generate schemas for events owned by other teams.
  3. Confidence is non-negotiable — Every field gets a confidence tag. Fields without tags will silently mislead sprint agents.
  4. Mocks are not schemas — A mock producer for a consumed event is a testing convenience, not an authoritative schema. Label it accordingly.
  5. Unresolved items are features, not bugs — Surfacing POSSIBLE items for human sign-off is the skill working correctly. Do not suppress them to produce a "cleaner" output.
  6. Verify every write — After writing each schema file, read it back to confirm it was written. Do not report success without verification.
  7. Contracts gate implementation — Sprint agents should not implement producers or consumers until the relevant schema is at CONFIRMED confidence. The validation config encodes this gate.

See Also

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.