Skip to content

Add spec-authoring guide for AI-generated services#678

Merged
xavierjohn merged 3 commits into
mainfrom
docs/spec-authoring-guide
Jul 4, 2026
Merged

Add spec-authoring guide for AI-generated services#678
xavierjohn merged 3 commits into
mainfrom
docs/spec-authoring-guide

Conversation

@xavierjohn

Copy link
Copy Markdown
Owner

Adds a new documentation article, docs/docfx_project/articles/writing-specs.md, registered in the articles TOC under AI & Automation (immediately before Trellis for AI Code Generation).

Why

A precise, framework-aligned specification is the highest-leverage input to AI-assisted development. When a spec agrees with the framework defaults, generated code is predictable and review is fast; when it does not, every ambiguity is a place where runs and models diverge. This guide is meant to be handed to an AI (alongside a business plan) so it authors a spec that maps cleanly onto Trellis constructs -- the step before the existing AI code-generation article.

What it covers

  • Anatomy of a Trellis-aligned spec -- the sections a complete spec needs.
  • Value objects over primitives -- typed IDs, RequiredEnum, ActorId owners.
  • Status codes that match the framework default -- 422 for business/input validation and invalid state transitions (Error.InvalidInput / Error.InvariantViolation); 400 limited to protocol errors (missing api-version, malformed JSON, missing/malformed Idempotency-Key).
  • Persistence and unit of work -- stage-only repositories, per-command commit, aggregate-root repositories, and a binding-contract note for pre-existing schemas.
  • HTTP semantics -- idempotency replay contract, ETag/concurrency, forward-only cursor pagination.
  • Authorization and testing requirements, a copy-paste spec skeleton, and a consistency checklist.

Docs-only. All internal links resolve; audit-stale-docs.ps1 passes; content verified against framework source and the existing error-handling.md / ai-code-generation.md articles.

Adds docs/docfx_project/articles/writing-specs.md, a guide for turning a
business idea into a framework-aligned specification that an AI can
implement predictably. It is the step before the AI code-generation
article: it captures the conventions that keep a generated spec agreeing
with framework defaults (422 for business/input validation and invalid
state transitions vs 400 for protocol errors, value objects over
primitives, stage-only repositories with a per-command unit of work,
explicit HTTP/idempotency/ETag/pagination semantics, authorization, and
real test coverage), plus a spec skeleton and a consistency checklist.
Registered in the articles TOC under AI and Automation.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new DocFX article that guides writing Trellis-aligned specifications intended for AI-assisted service generation, and links it into the documentation navigation under AI & Automation.

Changes:

  • Added writing-specs.md article covering spec structure, value objects, status-code conventions, persistence/UoW, HTTP semantics, authorization, and testing expectations.
  • Registered the new article in docs/docfx_project/articles/toc.yml immediately before the existing AI code generation article.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
docs/docfx_project/articles/writing-specs.md New spec-authoring guide article intended to be handed to AI before code generation.
docs/docfx_project/articles/toc.yml Adds the new article to the AI & Automation section of the docs TOC.

Comment thread docs/docfx_project/articles/writing-specs.md
@github-actions

github-actions Bot commented Jul 4, 2026

Copy link
Copy Markdown

Test Results

7 241 tests  ±0   7 223 ✅ ±0   6m 23s ⏱️ +36s
   27 suites ±0      18 💤 ±0 
   27 files   ±0       0 ❌ ±0 

Results for commit cfb5e47. ± Comparison against base commit f1bcde6.

♻️ This comment has been updated with latest results.

@codecov

codecov Bot commented Jul 4, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 87.59%. Comparing base (f1bcde6) to head (cfb5e47).

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main     #678   +/-   ##
=======================================
  Coverage   87.58%   87.59%           
=======================================
  Files         402      402           
  Lines       17525    17525           
  Branches     3673     3673           
=======================================
+ Hits        15350    15351    +1     
  Misses       1332     1332           
+ Partials      843      842    -1     

see 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

The idempotency reference documented the 400/409/422 status codes but not
their source. Adds a note tracing them to draft-ietf-httpapi-idempotency-key-header
section 2.7 (Error Handling): missing key -> 400, reuse with a different
payload -> 422, in-flight retry -> 409; a malformed key stays 400 as a
request-syntax error.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

Comment thread docs/docfx_project/articles/writing-specs.md Outdated
Comment thread docs/docfx_project/articles/writing-specs.md Outdated
- Add the repo-required UTF-8 BOM so the file matches .editorconfig
  (charset = utf-8-bom) like the other DocFX articles.
- Add the markdown separator rows to the Endpoints and Error Behavior
  tables in the copy/paste skeleton so it renders as tables when pasted.
- Add trellis-api-primitives.md and trellis-value-object-taxonomy.md to
  related_api_reference (the article links to both).

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.

@xavierjohn
xavierjohn merged commit 2636c30 into main Jul 4, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants