fix: address cleanup review lifecycle and connection settings

This commit is contained in:
Boki 2026-10-26 16:53:53 -04:00
parent 512f2f1c32
commit 9d3e1a7bb9
11 changed files with 264 additions and 17 deletions

View file

@ -110,3 +110,20 @@ Implementation references: plan `4ddffa6b`; foundations `805a9f8f`; shared resea
application cleanup (including the reviewed foundation follow-up) `8c39ccf7`. All 13
manifest entries identify the validated implementation tree while reserving completed
commit/sign-off for acceptance of independent review.
## Review follow-up — October 26
See [cleanup-review.md](cleanup-review.md) for reproduced findings, corrections and the
actual-data pilot. Fixed lifecycle reuse, bounded rollback, Redis ACL forwarding and
preservation of omitted PostgreSQL server timeout settings. These are CL02/CL03 follow-ups;
other cleanup stories remain unchanged and none has received independent sign-off yet.
The read-only pilot found stored intraday data but zero retained datasets and a concrete
null-volume/session preparation blocker. No real-market backtest result was invented,
no eligibility gate was weakened and no development database was modified.
Follow-up gate: `CARGO_BUILD_JOBS=2 bun run check` passed with 1,226 integration tests
(14 existing skips), 132 tooling, 43 utility, 44 calculation and 150 Rust tests
(4 ignored), plus build/types/contracts/secret audit/lint. The focused lifecycle and
store regressions passed 35 tests / 115 assertions. No financial simulation or strategy
policy was changed by these corrections.

View file

@ -0,0 +1,84 @@
# Cleanup review and first research pilot
Review baseline: `512f2f1c`, October 26, 2026. This records the primary agent's
follow-up inspection and fixes, **not independent sign-off**. The 13 cleanup stories
remain in `review`. A request to use three independent read-only reviewer agents is
pending; no separate reviewer has been launched or represented as approving this work.
## Findings and corrections
| Finding | Severity / evidence | Correction and regression |
| --- | --- | --- |
| CL03: cleanup was remembered across connection lifetimes | High / Verified: two initialize/shutdown cycles produced two connects and only one disconnect | Reset cleanup ownership before a fresh connection, wait for an earlier close, and reject overlapping unresolved initialization. Test repeated cycles and retry after a timed-out pending initializer. |
| CL03: rollback could hang indefinitely | High / Verified: a never-settling disconnect kept the original startup rejection pending beyond the initialization timeout | Bound rollback waiting by the configured timeout, keep its promise owned, clear the timer and preserve the original failure. Test a deferred disconnect and eventual cleanup. |
| CL02: Redis ACL username was dropped | Medium / Verified: the core schema accepted username, but cache/global cache, proxy/queue adapters and the rate-limiter connection omitted it | Forward username through the existing adapters and queue config. A separate child process substitutes only ioredis, captures both real constructor settings and queue worker connection settings, and opens no sockets. |
| CL02: omitted PostgreSQL timeouts became explicit zero | High / Verified: the DI mapping supplied query, statement, lock and idle-transaction zero values without corresponding user settings | Make individual client timeout fields optional and forward only the configured connection timeout. Assert omitted wire fields stay undefined so server-configured limits remain effective. |
Implementation: [lifecycle](../../libs/core/di/src/utils/lifecycle.ts),
[database mapping](../../libs/core/di/src/registrations/database.registration.ts),
[cache mapping](../../libs/core/di/src/registrations/cache.registration.ts),
[service mapping](../../libs/core/di/src/registrations/service.registration.ts),
[queue transport](../../libs/core/queue/src/queue-manager.ts).
MongoDB's adapter now states its existing effective minimum pool size (one), instead of
passing zero into a client that treats zero as its fallback of one.
The backend inspection checked canonical-only admission, exact receipt recovery before
mutable eligibility checks, run/outbox transaction order, result reads using an existing
transaction connection, retained artifact identity and historical result compatibility.
The frontend inspection checked request ownership across route changes, exact retry bodies,
submission-mode exclusion and cookie transport without automatic retries. This pass found
no additional blocking issue in those extracted paths; an independent review is still needed.
Rust accounting, matching, risk and strategy decision semantics were not changed.
## Validation
- `bun test test/integration/store-configuration.test.ts test/integration/questdb-configuration.test.ts libs/core/di/test/container-builder.test.ts libs/core/di/test/lifecycle.test.ts test/integration/service-startup-rollback.test.ts` — 35 pass / 115 assertions.
- PostgreSQL, queue and DI package builds, plus `bun run typecheck` — pass.
- Full combined check outcome is recorded in [cleanup-execution.md](cleanup-execution.md).
- No PostgreSQL/browser suite rerun is claimed for this follow-up. The previous 273 SQL
and 18 browser passes belong to the preceding cleanup implementation tree. These fixes
change configuration/lifecycle paths; SQL transaction and browser application code is unchanged.
## Actual-data pilot: stopped at preparation
Read-only checks used the configured development stores; no records, credentials, source
prices or trading state were changed. Network-isolated connection failures were rechecked
outside the sandbox before drawing conclusions.
- PostgreSQL contained **zero retained datasets**, 138 existing runs and one strategy.
Existing runs alone do not establish canonical research readiness.
- MongoDB contains indexed EOD intraday history. A bounded October 2024 five-minute query
returned no SPY.US rows and **1,816 AAPL.US rows over 23 dates**.
- **22 AAPL rows have null volume**, all at **20:00 UTC**; no duplicate timestamps were
observed in that sample. Their timing is a diagnostic, not proof of an approved session
exclusion rule. The current strict historical reader rejects null-volume rows before
dataset preparation, so this whole-window source is not directly ready for admission.
- The exact raw query snapshot hash is
`a8772d01d388b8fc9bca0d2790ad0d37146570fd09d057fcf1f1fcb5e6113bde`.
This hashes source-query JSON, **not** the canonical dataset format. The temporary capture
is `/tmp/stock-bot-review-20261026/aapl-2024-10-source.json`, with diagnostics in
`/tmp/stock-bot-review-20261026/data-quality.json`; temporary storage is not durable custody.
- Session/calendar identity, timestamp-availability assumptions and corporate-action
coverage still need supported declarations. Unknown coverage was not relabelled eligible.
No financial simulation, parameter selection, alpha claim or paper activation was made
from these raw observations. No real-market result or finding was saved without evidence.
Synthetic integration examples remain test evidence, not a substitute for this pilot.
## Next useful vertical slice
The next product work should make this preparation explicit using the existing source
preview/retain APIs and workbench, without adding another research engine:
1. Inspect indexed asset/timeframe/date coverage before selecting a source window.
2. Show quality diagnostics and proposed session inclusion/exclusion with counts. Any
approved transformation must retain its source snapshot, policy and exclusions;
never turn null volume into zero or silently omit unexplained records.
3. Supply reviewed calendar/timing/action metadata, preview eligibility, and freeze a
dataset through the existing retention path. Keep exploratory and execution eligibility
distinct. Do not weaken the worker's eligible-dataset gate to make a demonstration run.
4. Run one reviewed TypeScript baseline on Rust, then a bounded chronological/cost study,
reopen results and save a source-linked finding. Report sample and data limitations.
MCP/notebook tooling can wrap these verified interfaces later. The immediate gap is getting
existing stored market history into inspectable, trustworthy research inputs.