20 lines
4.2 KiB
Markdown
20 lines
4.2 KiB
Markdown
# RP22 — Preserve candidate decimal normalization during SQL admission
|
|
|
|
Parent E12. P1 / High research admission defect. Complexity S. Dependencies A02 and RP17. Discovered while executing the owner's authorized RP21 continuation. Root owns planning/integration and study recovery; one backend implementer owns an additive SQL migration, startup registration and PostgreSQL regression tests. Independent review required. Do not modify previous migrations or frozen research inputs.
|
|
|
|
Verified evidence: RP21's original filtered training request contains `minNotionalVolume: "0"`. `validateStrategyParameters()` in `apps/stock/config/src/contracts/strategy.ts` applies the known mean-reversion schema, producing `"0.00000000"`. `database/postgres/init/32-candidate-parameter-defaults.sql` expands defaults but compares raw parameter strings literally, so `validate_experiment_manifest` rejects the prepared request. Actual PostgreSQL logged its complete-identity guard error; exact-receipt inspection confirmed zero experiments/runs. The existing AI workflow fixture uses already-normalized parameters and misses this case. Frozen evidence is under `.data/research-pilots/aapl-202409-signals/`.
|
|
|
|
Scope: forward migration33, registered in `apps/stock/web-api/src/migrations/migration-runner.ts`, that preserves original input/preview hashes and performs the same existing normalization for the known mean-reversion financial-string parameter when comparing to the frozen request. Prefer a local SQL expression/variable inside the existing validator over a new general parameter framework. Preserve all other admission, ownership, approval, risk, dataset and immutable-receipt guards. Arbitrary candidate string parameters must retain exact string semantics. No TypeScript strategy, calculation, native engine or financial policy change.
|
|
|
|
The known parser accepts plain signed decimal strings with at most eight fractional digits and the fixed-eight financial range; it canonicalizes negative zero, while the strategy rejects negative nonzero notional. Verify actual grammar/range in `libs/core/types/src/financial-engine.ts` and the built-in strategy schema. SQL must not introduce rounding, exponent/leading-zero/plus spellings or loose numeric coercion. Match the exact trusted program identity, not an arbitrary property name.
|
|
|
|
Acceptance/tests:
|
|
|
|
- Disposable PostgreSQL reproduces the current failure through real candidate preview/admission using raw `"0"`, then the forward migration makes the exact same body/key/hash succeed and replay to the same IDs. No copied normalized input substituted for the original.
|
|
- Valid plain spellings, a fractional value, negative zero and already-canonical values retain their input bytes while requests normalize correctly. Default expansion and omitted optional parameters continue to work.
|
|
- Direct SQL guard mutations reject changed economic values, malformed or excessive-precision/out-of-range decimals, wrong parameter types, missing/extra parameters, and unrelated candidate normalization. Existing failure-oriented ownership/grant and admission tests stay green.
|
|
- Reapplying the migration leaves historical rows/results, IDs and active receipts unchanged. Existing known-program authorization checks remain intact.
|
|
- Affected disposable PostgreSQL suites, migration-runner tests, application/authored-test types, scoped lint/format and relevant repository gates pass. Preserve installed engine/worker/sandbox bytes for RP21; no builds while study identities are frozen. Record any unavailable/skipped gate accurately.
|
|
- After review/commit, apply through the normal migration runner's lock/transaction. Reopen the study's original receipt state, retry only the exact idempotent stopped request and continue from saved acknowledged resources. Never restart the entire cycle, recreate its hypothesis/family/version, alter risk/parameters, or exceed ten trials.
|
|
|
|
Exclusions: general SQL parameter engine, signal changes, migration history rewrites, deleting/replacing research artifacts, new candidate/version IDs for recovery, paper/live activation, performance work. Regression risk is weakened direct SQL validation or string coercion in arbitrary strategy schemas. Compare independently with the actual TypeScript parser; retain the original failed receipt as evidence.
|