liveBook · Manning

Deterministic check

As explained in Spec-Driven Development

Deterministic verification is verification based on repeatable checks that produce evidence of whether a specified outcome has been achieved.

A specified outcome is not yet evidence that the outcome works. A deterministic check turns the intended behavior into a repeatable observation with an explicit expected result. Completion means the check passes, not that an agent reports the implementation finished. section 3.2.4

For a URL shortener, “a short URL redirects to its destination” leaves verification underspecified. Create a short link, request GET /abc123, and assert both the response status and the Location header. The expected status must come from an intent decision: a temporary 302 redirect lets later visits reach the service for click counting, expiry, or destination changes; a permanent 301 may prevent those visits. section 3.2.4

Listing 3.4 A deterministic test that demonstrates redirection behavior.
test("short URL redirects to original URL", () => {
  givenShortLink({
    code: "abc123",
    longUrl: "https://example.com/articles/sdd"
  });
  const response = GET("/abc123");
  expect(response.status).toBe(302);
  expect(response.headers.Location).toBe("https://example.com/articles/sdd");
});
 

The test fixes the request and expected response so redirection can be demonstrated rather than inferred from generated code. section 3.2.4

Make the check part of the task, not an optional final inspection:

  • Translate the captured intent into a check before generating the implementation. section 3.2.4
  • Run it and confirm that it fails for the right reason: the behavior does not exist yet. section 3.2.4
  • Generate the implementation, then run the same check again. A passing result supplies evidence of the specified outcome. section 3.2.4

The check need not be a unit test. A curl command, database assertion, trace query, or accessibility scan can provide evidence when it observes the relevant outcome. For recurring concerns, hooks can run deterministic checks at fixed workflow points instead of relying on each feature specification to remember them. Invest most heavily where deviation is costly or recurring, such as security boundaries; a low-risk formatting change need not carry the same machinery. section 3.2.4 section 3.3.1 section 3.3.3

A failed outcome check identifies a verification gap only after the intended outcome is clear. If the decision was never made, improve the authoring dialogue; if it was captured loosely, strengthen the specification. Do not let a test silently decide an unresolved requirement. Use observed gaps to repair the part of the workflow that allowed them, then keep the check as evidence for future changes. section 3.2.4 section 3.2.5

How Spec-Driven Development covers it

How deep it goes
Works through a test-first failure-and-pass sequence and redirect assertions; leaves the choice of HTTP status to specification authoring.
Examples
Uses a short-link GET request with assertions for HTTP 302 and the destination Location header.
What it assumes
Assumes an intended outcome can be captured in a specification; teaches its translation into an observable check.
What you can do after
Practice/perform it by writing a check before implementation, confirming its initial failure, and rerunning it to verify the outcome.
How it connects
Connects specification-driven development, acceptance criteria, test-first implementation, hooks, and workflow feedback.

Also explained in

Compare how 3 books explain deterministic check →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Spec-Driven Development. The section links point to the parts of the book it draws on.