Skip to content

test(core): execute UWR profile KAT vectors - #17

Merged
Gio2050 merged 1 commit into
mainfrom
test/uwr-profile-kat-exec
Jul 12, 2026
Merged

test(core): execute UWR profile KAT vectors#17
Gio2050 merged 1 commit into
mainfrom
test/uwr-profile-kat-exec

Conversation

@Gio2050

@Gio2050 Gio2050 commented Jul 12, 2026

Copy link
Copy Markdown
Contributor

Summary

Executes the afi-config UWR profile KAT vectors against the afi-core engines — the executable half of the UP-11 KAT/golden gate. Additions only: 6 new files, 0 modified, no dependency/lockfile/tsconfig/CI changes.

  • validators/__tests__/computeUwrScore.kat.test.ts — 10 score vectors vs computeUwrScore (16 tests)
  • src/decay/__tests__/applyTimeDecay.kat.test.ts — 32 decay vectors vs applyTimeDecay (36 tests)
  • Byte-identical vendored KAT copies + provenance sidecar READMEs under colocated kats/ fixture dirs

Authorization chain

  1. UP-11 clarification (afi-governance/decisions/uwr-profile-pin-v0.1.md): KAT vectors (pure data) live in afi-config; KAT execution against afi-core code is "a separately-authorized afi-core PR (PR-UWR-KAT-EXEC), following the established vendored-golden-with-source-pin pattern used by afi-mint for the emissions goldens."
  2. §7 follow-up table row: PR-UWR-KAT-EXEC — "afi-core: execute vendored KAT vectors against computeUwrScore / applyTimeDecay (vendored-golden-with-source-pin pattern)" — marked "No — separate authorization."
  3. Owner authorization: the owner's direct instruction to implement this PR (2026-07-12, per the approved planning report) is that separate authorization. Merging this PR is the owner-review acceptance act.

Provenance pins

Vendored from AFI-Protocol/afi-config kats/uwr-profile/v0/ at merge commit fe329164919f0c1c9dc24bb5c279978fb680e983 (PR #17), content commit 7809af4b0308f7db47488947770a0ab9f236268d:

File git blob SHA-1 sha256
compute-uwr-score.kat.json (10 vectors) 276be9e9348b4e0c2e92e5a9c59d05b50bfeb75d ff2f63956038b1d5c01109184e2ddddb2606c11405d2420c35b7decb5eb36546
apply-time-decay.kat.json (32 vectors) 1199f705ee65eef70e6c0c58fffcd10206693cf0 1a1240cc9f8cc8ed70b22f4aa00e7cdfe1176f4f1d3c6b1e10e886b0cfe81b78

Executed against afi-core 254185381c3c9be91da303454c1f7a27e8818983 (main, PR #16 merge). The KATs' engine.sourceCommit: 390b440 pin: UniversalWeightingRule.ts is blob-identical between 390b440 and 2541853; GreeksDecayTemplate.ts differs only by the PR #16 kernel delegation, proven bit-exact in applyTimeDecay.mathEquivalence.test.ts — documented in the sidecars, vendored bytes left untouched per change control.

Drift detection: always-on sha256 self-integrity checks against pinned constants (hermetic in CI), plus it.skipIf-guarded full byte-compares against a sibling afi-config checkout on dev machines. Failure messages state the governance implication: divergence requires a new scoped authorization; never silently re-vendor.

Comparison policy (owned by this PR)

Both KAT files deliberately define no float-comparison policy; comparisonPolicyNote assigns it to PR-UWR-KAT-EXEC scope. Policy adopted:

  • Decay: Object.is bit-exact, all 32 vectors — per the file's exactnessRule (dyadic base scores × integer half-life multiples ⇒ every expected value exact in binary64).
  • Score: Object.is bit-exact for 9/10 vectors.
  • uwr-score-anchor-0650 — dual-pinned characterized exception. The engine's multiply-accumulate order over axes (0.6, 0.7, 0.6, 0.7) with 0.25 weights yields 0.6499999999999999, exactly 1 ULP below the decimal anchor 0.65. This is deterministic, correctly-rounded IEEE-754 binary64 arithmetic (no transcendentals) — identical on every conforming engine, not flake. The test asserts both |actual − 0.65| ≤ 1 ULP and Object.is(actual, 0.6499999999999999), pinning the engine's true output verbatim so any future engine change fails loudly (drift-detection strength equal to bit-exact). 0.65 is not decision-pinned (only the 0.1875 golden anchor and the 0.25 weights are decision-named). Rejected alternatives: editing the vendored expected value (violates afi-config change control) and blanket tolerances (weaken the 41 vectors that can be exact). Optional future item for the owner (separately authorized, not this PR): a one-vector afi-config erratum swapping the 0650 axes to e.g. (0.5, 0.6, 0.7, 0.8) would collapse the exception to uniform bit-exactness.
  • uwr-score-d2m2-golden-anchor (0.1875) — the decision-named D2 M2 golden replay anchor — reproduces bit-exactly and is called out in a dedicated test (UP-5/UP-11 byte-stability criterion).

What this does NOT unlock

Execution ≠ wiring. This PR runs KAT vectors in tests and nothing more:

  • No reward, mint, or qualification wiringIValidatorScorer/ValidatorDaemon and all reward/mint paths untouched; no eligibility assertions anywhere (the 0.5 = minDecayScoreThreshold coincidence in the decay data stays commentary).
  • No PR-UWR-STAMP — no reactor stamping; separately authorized.
  • No runtime registry consumption — the KAT JSON is imported only from *.test.ts; the executed config is built from the KAT's own weights block; defaultUwrConfig unchanged.
  • No UP-8 resolution — decay-engine canonicality remains OPEN; these tests pin the GreeksDecayTemplate surface only.
  • Status: testnet-provisional (x-afiStatus: draft-non-implementation). Each follow-up requires its own scoped authorization.

Validation

  • git check-ignore on new paths: nothing ignored (fixture dirs named kats/, not vendor*/)
  • cmp + sha256sum: vendored copies byte-identical to afi-config @ fe32916, hashes match pins
  • npm run test:run: 196 passed (existing 144 unchanged + 16 score-KAT + 36 decay-KAT), including live sibling byte-compares
  • npm run build, npm run typecheck, scripts/esm-check.sh: clean (tests are tsc-excluded; no config edits)
  • git status: exactly 6 additions, 0 modifications; git diff --stat empty
  • Adversarial verification pass: 0 blockers across 4 independent lenses — (1) provenance/byte-equivalence re-derived from the pinned afi-config commit (git-show bytes, blob SHAs, content-commit ancestry, every hash constant in tests/sidecars cross-checked; UniversalWeightingRule.ts confirmed blob-identical 390b4402541853, GreeksDecayTemplate.ts delta confirmed to be exactly the PR refactor(decay): delegate applyTimeDecay kernel to afi-math (PR-7, bit-exact) #16 delegation); (2) additions-only scope audit (status purity, no config/CI/lockfile edits, no vendor*/, KAT JSON referenced only from tests/sidecars, all six sibling repos byte-verified clean); (3) language guards (0 banned-phrase hits; required testnet-provisional / execution≠wiring / separately-authorized / never-silently-re-vendor language present; UP-8 stated OPEN); (4) test-strength review + mutation testing in an isolated copy — 4/4 mutations killed (vendored-byte flip, 0650 pin change, decay expected-value edit, weights swap), baseline green both with and without a sibling checkout (skip path verified)

🤖 Generated with Claude Code

Execute the afi-config uwr-profile v0 KAT vectors (PR #17, fe32916)
against computeUwrScore and applyTimeDecay per UP-11 (PR-UWR-KAT-EXEC).
Additions only: byte-identical vendored vectors + provenance sidecars +
two executor suites. Object.is bit-exact for 41/42 vectors; dual-pinned
characterized exception for uwr-score-anchor-0650. Testnet-provisional;
execution does not wire anything.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@Gio2050
Gio2050 merged commit 23fb99a into main Jul 12, 2026
1 of 2 checks passed
@Gio2050
Gio2050 deleted the test/uwr-profile-kat-exec branch July 13, 2026 01:15
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