spectastic Examples
examples/spec.html
Feature specification · starter sample

Session token rotation

accepted owner  auth-platform version  1.2.0 updated  2026-06-12 Slice of AUTH-CORE
Words980 / 1500
Requirements2 / 20
Read time6 / 12 min
TL;DR

Session tokens become a liability the moment a user's authority changes. This spec makes rotation immediate and observable: a fresh token on every privilege change, the prior token dead within one request cycle, and a single serialised lock so concurrent logouts can't race.

§1  Goals & non-goals

Goals
  • Rotate on every privilege change
  • Invalidate the prior token in one cycle
  • Serialise concurrent rotations
Non-goals
  • ×Refresh-token storage policy → AUTH-STORE
  • ×Device-level revocation UI

§2  Requirements

REQ-AUTH-014 must

Tokens rotate on privilege change

The system MUST issue a fresh session token whenever a user's role changes, and MUST invalidate the prior token within one request cycle.

REQ-AUTH-015 should

Concurrent rotations serialise

Two privilege changes arriving within the same cycle SHOULD serialise behind a single rotation lock, so the later change always supersedes the earlier.

§3  Decision

D-007Architecture decision

Serialise with a per-subject advisory lock

Context
Logout and role-change can fire in the same cycle; an optimistic check left a window for double-rotation.
Decision
Take a per-subject advisory lock for the rotation critical section. Cheap, already available, no new infra.
Consequences
Adds <1ms under contention; lock held only across the write. Revisit if subjects shard across regions.

§4  Options considered

Option Effort Race-safe Infra
Optimistic version checkLowNoNone
Advisory lock LowYesNone
Dedicated queueHighYesNew

§5  Changelog

1.2.0 · 2026-06-12
Added REQ-AUTH-015 (serialised rotations) and D-007 after a triaged double-rotation defect.
1.1.0 · 2026-05-28
Tightened invalidation window to one request cycle.
1.0.0 · 2026-05-10
Accepted. Initial rotation requirement.
Want the full feature set?

This is a deliberately small starter — two requirements, one decision, no budget gauge, no change proposals. The canonical example is the spec for Spectastic itself — written in Spectastic, exercising every component: budget, status meta, requirements, decisions, conformance index, triage log, and archived change proposals.

More worked examples — meta-spec, triage logs, archived change proposals — live in the examples directory.

One file. Renders anywhere. Degrades to readable static HTML.

← Back to spectastic