Skip to content

Freeze hot-path result DTO; add governance docs and testing working model - #3

Merged
wolpert merged 1 commit into
mainfrom
pre-implementation-hardening
Jul 18, 2026
Merged

Freeze hot-path result DTO; add governance docs and testing working model#3
wolpert merged 1 commit into
mainfrom
pre-implementation-hardening

Conversation

@wolpert

@wolpert wolpert commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

Summary

Pre-implementation hardening from a second four-role design review (fraud/rules adopter, gateway
security operator, engineering architect, business leader). This lands the fixes that must be in
place before the velocity-spi contract is frozen and code is written, plus the project's
governance docs and a testing working model. Documentation, spec, and build-config only — no
product code yet
(modules remain stubs).

Requirements bumped to v0.3.

Contract freeze — ADR 0009

The apply()/query() result rides on every call and velocity-spi is additive-only (NFR-17), so
its shape must be frozen complete now or a later addition re-cuts a published DTO.

  • ADR 0009 freezes the result as a value-or-failure sum type — FeatureResult = Success{FeatureValue} | Failure{FailureCode} — carrying, per feature, the read-your-write level, exact|approximate, the
    definition-version hash, an apply status, and a distinguishable UNAVAILABLE|DEADLINE_EXCEEDED|…
    (never a silent 0). Completes ADR 0007.
  • velocity-spi is serialization-neutral — Jackson removed from its api surface; Jackson 3 is
    required in velocity-core/the wire layer (ADR 0002 amended).
  • HLL sketches are same-implementation-only — cross-backend HLL migration dropped from v1 (ADR
    0006/0008, GR-6 scoped to exact aggregates).
  • Both Postgres and Redis are committed production-grade v1 backends (§11 Bump io.lettuce:lettuce-core from 6.5.5.RELEASE to 7.6.0.RELEASE in the gradle-dependencies group #2, GR-7/GR-8).
  • New acceptance gates: idempotency-exactness (Bump the gradle-dependencies group across 1 directory with 10 updates #15) and seed-implemented (#16); AR-5 gains
    deadline-exceeded/overloaded; KMS key custody required for the R11 hash salt.

Governance docs (GR-2 / GR-3)

New README.md, GOVERNANCE.md, SECURITY.md, CONTRIBUTING.md, CHANGELOG.md. The README clearly
marks pre-release status (no functional code / benchmarks / published artifacts yet).

Testing working model / Definition of Done

  • Coverage gate raised to LINE ≥80% / BRANCH ≥70% for library modules; trivial/generated code
    (records/DTOs, **/dto/**, **/model/**, generated DI) excluded from the denominator so the floor
    applies to logic, not boilerplate.
  • CONTRIBUTING.md gains a Definition of Done (tests required, trivial-code carve-out, a feature
    isn't done without an end-to-end/integration test).
  • CLAUDE.md gains a working model: write code+tests → run the build (never "done" on a red/skipped
    gate) → invoke the reviewer sub-agent.
  • New reusable reviewer agent .claude/agents/change-validator.md (checks tests are meaningful and
    code meets its requirement/ADR).

CI

Dependabot auto-merge hardened to patch/minor only; major bumps and all github-actions updates
now require human review.

Verification

./gradlew clean build passes (BUILD SUCCESSFUL). The raised coverage gate currently reports
SKIPPED because no code/tests exist yet; it begins enforcing once modules gain real classes.

🤖 Generated with Claude Code

…odel

Post re-review hardening (requirements v0.3), before implementation begins.

Contract freeze (ADR 0009):
- Freeze the apply()/query() result as a value-or-failure sum type carrying,
  per feature, the read-your-write level, exact|approximate, definition-version
  hash, apply status, and a distinguishable failure code (never a silent 0).
- Make velocity-spi serialization-neutral; Jackson 3 required in velocity-core.
- Scope HLL sketches same-implementation-only; drop cross-backend HLL migration.
- Commit both Postgres and Redis as production-grade v1 backends.
- New acceptance gates (idempotency-exactness, seed-implemented); AR-5 gains
  deadline-exceeded/overloaded; KMS key custody for the R11 hash salt.

Governance (GR-2/GR-3): add README, GOVERNANCE, SECURITY, CONTRIBUTING, CHANGELOG.

Working model / Definition of Done:
- Raise the coverage gate to LINE >=80% / BRANCH >=70%; exclude trivial/generated
  code (records/DTOs, **/dto/**, **/model/**, generated DI) from the denominator.
- Add the CONTRIBUTING Definition of Done and a CLAUDE.md working model.
- Add a reusable .claude/agents/change-validator reviewer agent.

CI: harden Dependabot auto-merge to patch/minor only; majors and github-actions
updates now require human review.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@wolpert
wolpert merged commit fa8251e into main Jul 18, 2026
3 checks passed
@wolpert
wolpert deleted the pre-implementation-hardening branch July 18, 2026 21:16
wolpert added a commit that referenced this pull request Jul 19, 2026
… TCK

Proves the frozen velocity-spi contract is implementable and provides the
harness every backend (JDBI/Redis) must pass (ADR 0004, NFR-13/18, acceptance #3).

- InMemoryVelocityBackend: thread-safe, EXACT, ATOMIC reference backend
  implementing VelocityBackend + Count/Sum/DistinctStore + Sliding/TumblingSupport
  + SeedSupport. Injectable Clock (backend is the clock authority); raw-event
  store computed per window at read; sliding = (now-D, now], tumbling = aligned
  bucket; apply returns one PerFeature per (intent x feature window) and its value
  already reflects the write (read-your-write); down/unsupported -> distinguishable
  Failure, never a silent 0.
- Conformance TCK (tck/*Scenarios, in src/main so backends reuse it): Count/Sum/
  Distinct/Sliding/Tumbling/Seed/Capability/Purge scenarios (27 methods) that
  advance the clock and assert real windowed values, aging-out / bucket-reset,
  seeded==recorded merge (acceptance #16), unsupported-window Failure, and
  declaration<->implementation agreement.
- InMemoryVelocityBackendTck drives all 27 scenarios; 48 tests total; coverage
  97.8% line / 87% branch (gate 80/70).
- velocity-spi: comment-only javadoc clarification on apply* result cardinality
  (one PerFeature per intent x window); no signature/type change.

Validated by the change-validator agent: VERDICT APPROVE ("this TCK would fail a
broken backend"). Removed unused testkit deps (jackson/caffeine/slf4j) per the
review.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.

1 participant