jonnifyagile agents
jonnify / Agile Agent Workflow / A4 · Spec / A4.1 · Specification by Example

A4.1 · The spec layer

Specification by example

An abstract requirement admits many readings; a worked example pins one. The first move of the spec layer is to make the examples the specification.

“Handle bad input” could mean a redirect, a crash, a 404, or an empty page — the phrase does not decide. Replace it with worked examples and the readings collapse to one, before a line of code is written. On the right, contrast the abstract requirement with the examples that pin it. Three dives: examples as the specification, living documentation that cannot drift, and removing ambiguity.

Many readings, or one · switch the view

ABSTRACT REQUIREMENT "handle a bad request" a 404 a crash another's courses WORKED EXAMPLES enrolled learner → own courses no enrollments → empty state not signed in → redirected one reading only the learner's own an abstract requirement opens many readings · worked examples close on one
Worked examples: three concrete cases of the protected /my/courses route — an enrolled learner, a learner with no enrollments, and an unauthenticated request — converge on one reading: a learner sees only their own courses, never another's. Readings open: 1.

Examples are the specification

An abstract requirement is a sentence the reader has to interpret. “The page must handle a bad user id” is fine until two people read it: one builds a 404, one builds an empty page, one lets it crash. Each is a defensible reading of the same words, and none of them is what the requirement meant — because the requirement never decided.

Specification by example replaces the sentence with worked cases. Each case is concrete, stated as Given/When/Then, and pins exactly one behaviour. Together the cases narrow the readings to one, and because they are concrete, the build can be held to them: a worked example doubles as the executable check. The ambiguity is removed before a line of code is written, and the documentation cannot later drift from the system — the example is both at once.

the principle

Replace the abstract requirement with worked examples. The examples are the specification — concrete, unambiguous, and they double as the executable check.

on the Portal

The Portal's learner-enrollments page, , defines the protected /my/courses route by three worked Portal.Enrollment examples — an enrolled learner, a learner with no enrollments, and an unauthenticated request — and the acceptance harness reads its checks from them.

A worked example pins one reading and proves it — the specification and the check are the same artifact.

The three dives

Each dive takes one consequence of making examples the specification, in the arc be the spec → cannot drift → remove ambiguity: the example as the specification the harness reads, the living documentation that follows, and the mechanism underneath — readings collapsed from many to one. Read them in order — A4.1.1 starts.

After A4.1, the next module — A4.2 · The triad: spec, stories, agent brief — names which artifact answers which question, so no document is crammed. Return to the A4 chapter navigation to continue.

References

The sources behind examples-as-specification, and where the layer it opens connects in the course.

Sources

Related in this course