Skip to content

seizu-cli Contract Specification

seizu-cli Contract Specification

seizu-cli domain logic contracts — self-documenting dogfooding example

Scenarios

Business workflows composed from multiple contract operations.

doc.generate

doc.generate

Acceptance Criteria

Business requirements that this contract fulfills.

  • ソースファイルからContract仕様書を自動生成できる
#OperationInput
1doc.parsesourceFiles: input.sourceFiles
2doc.filterfilterIds: input.filterIds
3doc.link-
4doc.analyzeenabled: input.coverageEnabled
5doc.render-
Flowchart (Mermaid)
flowchart TD
  n1(["start"])
  n2(["end"])
  n3["step doc.parse"]
  n4["step doc.filter"]
  n5["step doc.link"]
  n6["step doc.analyze"]
  n7["step doc.render"]
  n1 --> n3
  n3 --> n4
  n4 --> n5
  n5 --> n6
  n6 --> n7
  n7 --> n2

Flow Summary

MetricValue
Processing steps5
Branch count0
Error path count0
Unanalyzable count0

coverage.generate

coverage.generate

Acceptance Criteria

Business requirements that this contract fulfills.

  • テストカバレッジレポートを生成できる
#OperationInput
1doc.parsesourceFiles: input.sourceFiles
2doc.filterfilterIds: input.filterIds
3doc.link-
4doc.analyzeenabled: true
Flowchart (Mermaid)
flowchart TD
  n1(["start"])
  n2(["end"])
  n3["step doc.parse"]
  n4["step doc.filter"]
  n5["step doc.link"]
  n6["step doc.analyze"]
  n1 --> n3
  n3 --> n4
  n4 --> n5
  n5 --> n6
  n6 --> n2

Flow Summary

MetricValue
Processing steps4
Branch count0
Error path count0
Unanalyzable count0

render.markdown

render.markdown

Acceptance Criteria

Business requirements that this contract fulfills.

  • タイトル・シナリオ・目次をMarkdownとして組み立てられる
#OperationInput
1render.titletitle: input.title, description: input.description
2render.scenarioSectionscenarios: input.scenarios, messages: input.messages, flowEnabled: input.flowEnabled
3render.toccontracts: […input.contracts].sort((a, b) => a.contract.name.localeCompare(b.contract.name) ), messages: input.messages
Flowchart (Mermaid)
flowchart TD
  n1(["start"])
  n2(["end"])
  n3["step render.title"]
  n4["step render.scenarioSection"]
  n5["step render.toc"]
  n1 --> n3
  n3 --> n4
  n4 --> n5
  n5 --> n2

Flow Summary

MetricValue
Processing steps3
Branch count0
Error path count0
Unanalyzable count0

Table of Contents

  • doc.analyze (Preconditions: 0, Tests: 4)
  • doc.filter (Preconditions: 0, Tests: 4)
  • doc.link (Preconditions: 0, Tests: 2)
  • doc.parse (Preconditions: 2, Tests: 8)
  • doc.render (Preconditions: 0, Tests: 3)
  • render.scenarioSection (Preconditions: 0, Tests: 2)
  • render.title (Preconditions: 1, Tests: 3)
  • render.toc (Preconditions: 0, Tests: 3)
  • report.replay (Preconditions: 1, Tests: 4)
  • report.summary (Preconditions: 1, Tests: 5)

Contract Details


doc.analyze

Acceptance Criteria

Business requirements that this contract fulfills.

  • テストカバレッジを分析してレポートを生成できる
PropertyType
StateDocPipelineState
InputAnalyzeInput
Errornever
Flowchart (Mermaid)
flowchart TD
  n1(["start"])
  n2(["ok"])
  n3["transition"]
  n4{"if !input.enabled"}
  n5["return state"]
  n6["const coverageReport = analyzeCoverage(state.linked);"]
  n7["return { ...state, coverageReport }"]
  n8["post.1"]
  n1 --> n3
  n3 --> n4
  n4 -->|true| n5
  n4 -->|false| n6
  n5 --> n8
  n6 --> n7
  n7 --> n8
  n8 --> n2

Flow Summary

MetricValue
Processing steps6
Branch count1
Error path count0
Unanalyzable count0

Preconditions

Conditions that must be satisfied before this operation can execute. If a condition is not met, the corresponding error is returned.

Not defined

Postconditions

Conditions guaranteed to hold after this operation completes successfully.

#Condition
1coverage report is present when analysis is enabled

Invariants

Conditions that must hold both before and after this operation.

Not defined

Error Catalog

No errors defined

Test Cases

Test scenarios that verify the behavior of this operation.

#ScenarioExpected Result
1generates coverage report when enabledSucceeds
2skips coverage when disabledSucceeds
3post/invariant: hold when enabledSucceeds
4post/invariant: hold when disabledSucceeds

doc.filter

Acceptance Criteria

Business requirements that this contract fulfills.

  • 指定されたIDでContractをフィルタリングできる
PropertyType
StateDocPipelineState
InputFilterInput
Errornever
Flowchart (Mermaid)
flowchart TD
  n1(["start"])
  n2(["ok"])
  n3["transition"]
  n4{"if input.filterIds && input.filterIds.size > 0"}
  n5["return { ...state, filtered: state.contracts.filter( (c) => input.fi..."]
  n6["return { ...state, filtered: [...state.contracts] }"]
  n7["post.1"]
  n1 --> n3
  n3 --> n4
  n4 -->|true| n5
  n4 -->|false| n6
  n5 --> n7
  n6 --> n7
  n7 --> n2

Flow Summary

MetricValue
Processing steps5
Branch count1
Error path count0
Unanalyzable count0

Preconditions

Conditions that must be satisfied before this operation can execute. If a condition is not met, the corresponding error is returned.

Not defined

Postconditions

Conditions guaranteed to hold after this operation completes successfully.

#Condition
1filtered contracts are a subset of all contracts

Invariants

Conditions that must hold both before and after this operation.

Not defined

Error Catalog

No errors defined

Test Cases

Test scenarios that verify the behavior of this operation.

#ScenarioExpected Result
1filters contracts by IDsSucceeds
2passes all contracts when no filterSucceeds
3returns empty when filter matches nothingSucceeds
4post/invariant: hold after transitionSucceeds

Acceptance Criteria

Business requirements that this contract fulfills.

  • Contractとテストスイートを紐付けできる
PropertyType
StateDocPipelineState
InputRecord<string, never>
Errornever
Flowchart (Mermaid)
flowchart TD
  n1(["start"])
  n2(["ok"])
  n3["transition"]
  n4["const linked = linkContractsToTests(state.filtered, state.tes..."]
  n5["const linkedScenarios = linkScenarios(state.scenarios, state...."]
  n6["return { ...state, linked, linkedScenarios }"]
  n7["post.1"]
  n1 --> n3
  n3 --> n4
  n4 --> n5
  n5 --> n6
  n6 --> n7
  n7 --> n2

Flow Summary

MetricValue
Processing steps5
Branch count0
Error path count0
Unanalyzable count0

Preconditions

Conditions that must be satisfied before this operation can execute. If a condition is not met, the corresponding error is returned.

Not defined

Postconditions

Conditions guaranteed to hold after this operation completes successfully.

#Condition
1every filtered contract has a corresponding linked entry

Invariants

Conditions that must hold both before and after this operation.

Not defined

Error Catalog

No errors defined

Test Cases

Test scenarios that verify the behavior of this operation.

#ScenarioExpected Result
1links contracts to testsSucceeds
2post/invariant: hold after transitionSucceeds

doc.parse

Acceptance Criteria

Business requirements that this contract fulfills.

  • ソースファイルからContract・Scenario・テストをパースできる
  • ソースファイルが未指定の場合はエラーを返す
PropertyType
StateDocPipelineState
InputParseInput
ErrorPipelineError
Flowchart (Mermaid)
flowchart TD
  n1(["start"])
  n2(["ok"])
  n3{"pre.1"}
  n4(["error(pre.1)"])
  n5{"pre.2"}
  n6(["error(pre.2)"])
  n7["transition"]
  n8["const contracts: ParsedContract[] = [];"]
  n9["const scenarios: ParsedScenario[] = [];"]
  n10["const testSuites: ParsedTestSuite[] = [];"]
  n11["const sourceFilePaths: string[] = [];"]
  n12{"for-of input.sourceFiles"}
  n13["sourceFilePaths.push(entry.path);"]
  n14[["unsupported: SwitchStatement"]]
  n15["return { ...state, sourceFiles: [...new Set(sourceFilePaths)], contr..."]
  n16["post.1"]
  n1 --> n3
  n3 -->|fail| n4
  n3 -->|pass| n5
  n5 -->|fail| n6
  n5 -->|pass| n7
  n7 --> n8
  n8 --> n9
  n9 --> n10
  n10 --> n11
  n11 --> n12
  n12 -->|iterate| n13
  n12 -->|done| n15
  n13 --> n14
  n14 -->|next| n12
  n15 --> n16
  n16 --> n2

Flow Summary

MetricValue
Processing steps11
Branch count1
Error path count2
Unanalyzable count1

Warning: 1 unsupported syntax path(s) were detected.

Preconditions

Conditions that must be satisfied before this operation can execute. If a condition is not met, the corresponding error is returned.

#ConditionError
1source files must not be emptyNoSourceFiles
2scenario flow must be deterministicDynamicScenarioFlow

Postconditions

Conditions guaranteed to hold after this operation completes successfully.

#Condition
1source file paths are tracked uniquely

Invariants

Conditions that must hold both before and after this operation.

Not defined

Error Catalog

Error TagSource
NoSourceFilesPrecondition #1
DynamicScenarioFlowPrecondition #2

Test Cases

Test scenarios that verify the behavior of this operation.

#ScenarioExpected Result
1parses contracts from source filesSucceeds
2parses test suites from source filesSucceeds
3rejects empty source filesReturns error
4rejects dynamic scenario flow patternsReturns error
5rejects non-direct step elements in scenario flow arraysReturns error
6preserves title and messagesSucceeds
7post/invariant: hold after transition-
8exposes contract metadata-

doc.render

Acceptance Criteria

Business requirements that this contract fulfills.

  • パイプライン状態からMarkdownドキュメントを生成できる
PropertyType
StateDocPipelineState
InputRecord<string, never>
Errornever
Flowchart (Mermaid)
flowchart TD
  n1(["start"])
  n2(["ok"])
  n3["transition"]
  n4["const result = renderMarkdownScenario([], { title: state.titl..."]
  n5["const baseLines = isOk(result) ? result.value : [];"]
  n6["let lines = renderContractSections(baseLines, { contracts: st..."]
  n7{"if state.coverageReport"}
  n8["lines = renderCoverageSection(lines, { report: state.coverage..."]
  n9["const markdown = lines.join('\\n').replace(/\\n{3,}/g, '\\n\\n');"]
  n10["return { ...state, markdown }"]
  n11["post.1"]
  n1 --> n3
  n3 --> n4
  n4 --> n5
  n5 --> n6
  n6 --> n7
  n7 -->|true| n8
  n7 -->|false| n9
  n8 --> n9
  n9 --> n10
  n10 --> n11
  n11 --> n2

Flow Summary

MetricValue
Processing steps9
Branch count1
Error path count0
Unanalyzable count0

Preconditions

Conditions that must be satisfied before this operation can execute. If a condition is not met, the corresponding error is returned.

Not defined

Postconditions

Conditions guaranteed to hold after this operation completes successfully.

#Condition
1non-empty linked state produces non-empty markdown

Invariants

Conditions that must hold both before and after this operation.

Not defined

Error Catalog

No errors defined

Test Cases

Test scenarios that verify the behavior of this operation.

#ScenarioExpected Result
1renders markdown from linked stateSucceeds
2renders title-only markdown for empty stateSucceeds
3post/invariant: hold after transitionSucceeds

render.scenarioSection

Acceptance Criteria

Business requirements that this contract fulfills.

  • シナリオセクションをレンダリングできる
PropertyType
Statereadonly string[]
InputScenarioSectionInput
ErrorRenderError
Flowchart (Mermaid)
flowchart TD
  n1(["start"])
  n2(["ok"])
  n3["transition"]
  n4["return input.scenarios.length === 0 ? lines : [ ...lines, ...renderS..."]
  n5["post.1"]
  n1 --> n3
  n3 --> n4
  n4 --> n5
  n5 --> n2

Flow Summary

MetricValue
Processing steps3
Branch count0
Error path count0
Unanalyzable count0

Preconditions

Conditions that must be satisfied before this operation can execute. If a condition is not met, the corresponding error is returned.

Not defined

Postconditions

Conditions guaranteed to hold after this operation completes successfully.

#Condition
1rendering scenario section appends lines only when scenarios exist

Invariants

Conditions that must hold both before and after this operation.

Not defined

Error Catalog

No errors defined

Test Cases

Test scenarios that verify the behavior of this operation.

#ScenarioExpected Result
1renders scenario sectionSucceeds
2skips scenario section when scenarios are emptySucceeds

render.title

Acceptance Criteria

Business requirements that this contract fulfills.

  • ドキュメントのタイトルと説明をレンダリングできる
PropertyType
Statereadonly string[]
InputTitleInput
ErrorRenderError
Flowchart (Mermaid)
flowchart TD
  n1(["start"])
  n2(["ok"])
  n3{"pre.1"}
  n4(["error(pre.1)"])
  n5["transition"]
  n6["const result = [...lines, `# ${input.title}`, ''];"]
  n7{"if input.description"}
  n8["return [...result, `> ${input.description}`, '']"]
  n9["return result"]
  n10["post.1"]
  n1 --> n3
  n3 -->|fail| n4
  n3 -->|pass| n5
  n5 --> n6
  n6 --> n7
  n7 -->|true| n8
  n7 -->|false| n9
  n8 --> n10
  n9 --> n10
  n10 --> n2

Flow Summary

MetricValue
Processing steps7
Branch count1
Error path count1
Unanalyzable count0

Preconditions

Conditions that must be satisfied before this operation can execute. If a condition is not met, the corresponding error is returned.

#ConditionError
1document title must not be emptyTitleEmpty

Postconditions

Conditions guaranteed to hold after this operation completes successfully.

#Condition
1rendering a title always appends new lines

Invariants

Conditions that must hold both before and after this operation.

Not defined

Error Catalog

Error TagSource
TitleEmptyPrecondition #1

Test Cases

Test scenarios that verify the behavior of this operation.

#ScenarioExpected Result
1renders title with descriptionSucceeds
2rejects empty titleReturns error
3post: lines increase after transition-

render.toc

Acceptance Criteria

Business requirements that this contract fulfills.

  • 2つ以上のContractがある場合に目次を生成できる
PropertyType
Statereadonly string[]
InputTocInput
ErrorRenderError
Flowchart (Mermaid)
flowchart TD
  n1(["start"])
  n2(["ok"])
  n3["transition"]
  n4["const { contracts, messages } = input;"]
  n5{"if contracts.length < 2"}
  n6["return lines"]
  n7["const result = [...lines];"]
  n8["result.push(`## ${messages.toc.title}`);"]
  n9["result.push('');"]
  n10{"for-of contracts"}
  n11["const { contract } = linked;"]
  n12["const firstLine = contract.description?.split('\\n')[0]?.trim();"]
  n13["const testCount = linked.testSuite?.tests.length ?? 0;"]
  n14["const guardCount = contract.guards.length;"]
  n15["const label = firstLine ? `**${contract.name}** - ${firstLine..."]
  n16["const meta = messages.toc.meta(guardCount, testCount);"]
  n17["result.push(`- ${label} (${meta})`);"]
  n18["result.push('');"]
  n19["return result"]
  n20["post.1"]
  n1 --> n3
  n3 --> n4
  n4 --> n5
  n5 -->|true| n6
  n5 -->|false| n7
  n6 --> n20
  n7 --> n8
  n8 --> n9
  n9 --> n10
  n10 -->|iterate| n11
  n10 -->|done| n18
  n11 --> n12
  n12 --> n13
  n13 --> n14
  n14 --> n15
  n15 --> n16
  n16 --> n17
  n17 -->|next| n10
  n18 --> n19
  n19 --> n20
  n20 --> n2

Flow Summary

MetricValue
Processing steps18
Branch count2
Error path count0
Unanalyzable count0

Preconditions

Conditions that must be satisfied before this operation can execute. If a condition is not met, the corresponding error is returned.

Not defined

Postconditions

Conditions guaranteed to hold after this operation completes successfully.

#Condition
1rendering TOC appends lines only when two or more contracts are present

Invariants

Conditions that must hold both before and after this operation.

Not defined

Error Catalog

No errors defined

Test Cases

Test scenarios that verify the behavior of this operation.

#ScenarioExpected Result
1renders TOC for 2+ contractsSucceeds
2skips TOC when fewer than 2 contractsSucceeds
3post: lines increase after transition-

report.replay

Acceptance Criteria

Business requirements that this contract fulfills.

  • 失敗したPBT検証のリプレイコマンドを生成できる
PropertyType
Statestring
InputReporterInput
ErrorReporterError
Flowchart (Mermaid)
flowchart TD
  n1(["start"])
  n2(["ok"])
  n3{"pre.1"}
  n4(["error(pre.1)"])
  n5["transition"]
  n6["return replay(input.result)"]
  n7["post.1"]
  n8["invariant.1"]
  n1 --> n3
  n3 -->|fail| n4
  n3 -->|pass| n5
  n5 --> n6
  n6 --> n7
  n7 --> n8
  n8 --> n2

Flow Summary

MetricValue
Processing steps5
Branch count0
Error path count1
Unanalyzable count0

Preconditions

Conditions that must be satisfied before this operation can execute. If a condition is not met, the corresponding error is returned.

#ConditionError
1must have at least one failure to generate replayNoFailures

Postconditions

Conditions guaranteed to hold after this operation completes successfully.

#Condition
1output is non-empty

Invariants

Conditions that must hold both before and after this operation.

#Condition
1output is always a string

Error Catalog

Error TagSource
NoFailuresPrecondition #1

Test Cases

Test scenarios that verify the behavior of this operation.

#ScenarioExpected Result
1formats failed resultSucceeds
2rejects successful resultReturns error
3post/invariant: hold after transition-
4exposes contract metadata-

report.summary

Acceptance Criteria

Business requirements that this contract fulfills.

  • PBT検証結果のサマリーレポートを生成できる
PropertyType
Statestring
InputReporterInput
ErrorReporterError
Flowchart (Mermaid)
flowchart TD
  n1(["start"])
  n2(["ok"])
  n3{"pre.1"}
  n4(["error(pre.1)"])
  n5["transition"]
  n6["return summary(input.result)"]
  n7["post.1"]
  n8["invariant.1"]
  n1 --> n3
  n3 -->|fail| n4
  n3 -->|pass| n5
  n5 --> n6
  n6 --> n7
  n7 --> n8
  n8 --> n2

Flow Summary

MetricValue
Processing steps5
Branch count0
Error path count1
Unanalyzable count0

Preconditions

Conditions that must be satisfied before this operation can execute. If a condition is not met, the corresponding error is returned.

#ConditionError
1verification results must not be emptyNoResults

Postconditions

Conditions guaranteed to hold after this operation completes successfully.

#Condition
1output contains seizu-verify header

Invariants

Conditions that must hold both before and after this operation.

#Condition
1output is always a string

Error Catalog

Error TagSource
NoResultsPrecondition #1

Test Cases

Test scenarios that verify the behavior of this operation.

#ScenarioExpected Result
1formats passing resultSucceeds
2formats result with multiple contractsSucceeds
3rejects empty resultsReturns error
4post/invariant: hold after transition-
5exposes contract metadata-

Test Coverage

Test coverage status for each contract.

ContractTestsError Tag CoverageStatus
doc.parse80/2Tested
doc.filter4-Tested
doc.link2-Tested
doc.analyze4-Tested
doc.render3-Tested
render.title30/1Tested
render.toc3-Tested
render.scenarioSection2-Tested
report.summary50/1Tested
report.replay40/1Tested

Contract coverage: 10/10 (100.0%) Error tag coverage: 0/5 (0.0%)