fix(orchestrator): own startup and shutdown resources (CL16)

This commit is contained in:
Boki 2026-10-26 19:28:43 -04:00
parent 21666242f4
commit 8546fce4a9
8 changed files with 384 additions and 117 deletions

View file

@ -2731,10 +2731,10 @@
],
"assignment": "/root/implement_cl14",
"branch": "cleanup/cl14-canonical-contracts",
"completed_commit": null,
"completed_commit": "21666242",
"blocker": null,
"release_gates": [],
"integration_state": "validated_pending_commit",
"integration_state": "validated_committed",
"integration_base": "700ee09c",
"completion_evidence": "orchestrator-engine-cleanup.md",
"worktree": "/tmp/stock-bot-engine-cleanup-20261026/cl14",
@ -2744,7 +2744,8 @@
"focused": "91 pass,6888 assertions across6 files",
"postgres": "33 pass,181 assertions across canonical-durable-backtest and durable-backtest; disposable stock_bot_safety database/Redis15",
"static": "Orchestrator build, application typecheck, negative contract fixtures and diff checks pass"
}
},
"implementation_commit": "21666242"
},
{
"id": "CL15",
@ -2805,7 +2806,7 @@
"epic": "E11",
"priority": "P1",
"severity": "High",
"status": "in_progress",
"status": "done",
"dependencies": [],
"decision_dependencies": [],
"task_file": "backlog/tasks/CL16.md",
@ -2833,10 +2834,18 @@
"completed_commit": null,
"blocker": null,
"release_gates": [],
"integration_state": "not_started",
"integration_state": "validated_pending_commit",
"integration_base": "700ee09c",
"completion_evidence": "orchestrator-engine-cleanup.md",
"worktree": "/tmp/stock-bot-engine-cleanup-20261026/cl16"
"worktree": "/tmp/stock-bot-engine-cleanup-20261026/cl16",
"reviewed_by": "/root/review_cl16",
"review_notes": "Independent source review accepted;39 lifecycle/composition cases and17 architecture checks passed independently. Root completed native-worker10/33 and explicit authored-test types/lint, then full combined repository gate.",
"validation": {
"focused": "39 pass,166 assertions across lifecycle/composition tests; worker lifecycle10 pass,33 assertions",
"review": "Independent source/scope acceptance by review_cl16; no blocking findings",
"static": "Application typecheck, explicit new-test typecheck, scoped lint, formatting and diff pass",
"combined": "CARGO_BUILD_JOBS=2 bun run check: tooling132, utilities43, calculations44, integration1231, Rust150 passed;14 integration conditional skips and4 Rust ignored retained"
}
},
{
"id": "CL17",

View file

@ -38,3 +38,13 @@ The durable runner now requires canonical engine/repository capabilities. Legacy
Implemented by `/root/implement_cl14`; independently reviewed/integrated by `/root`. Root rebuilt the orchestrator and passed application typecheck/contract tests. Focused runner/workflow/worker/pool/isolation/architecture suite: 91 passed, 6,888 assertions. Disposable PostgreSQL canonical and retained durable-run suites: 33 passed, 181 assertions. No SQL/native/economic policy changes. Worker tests required execution outside the sandbox; two transient worktree Bun dependency-reading failures passed on separate reruns and root integration. Legacy-only provider-spy assertions were removed with the unused injection, not replaced with fabricated coverage. Full combined repository gate follows CL16 integration.
CL15 implementation commit: `bc2b8a89`.
### CL16 — accepted
`ServiceContainerBuilder.buildOwned()` adds an explicit shared-resource lifetime while preserving `build()` for existing callers. Orchestrator composition returns `{services, shutdown}`; registration rollback and normal shutdown share idempotent application cleanup. Startup route/bind failures release the runtime. Shutdown finishes accepted HTTP requests and durable work before closing queue/database/cache adapters. The obsolete ModeManager closer and unowned delayed self-test timer are removed from the canonical entrypoint.
Implemented by `/root`; independently reviewed by `/root/review_cl16` with no blocking findings. Focused lifecycle/composition tests: 39 passed, 166 assertions. Independent architecture rerun: 17 passed. Native worker lifecycle outside sandbox: 10 passed, 33 assertions. The new test was explicitly typechecked and linted because the default application tsconfig excludes tests; controlled fixture adapters have an explicit test-only container widening. Tests cover registration/resolution/bind failure, original-error retention, repeated stop, continued cleanup and a delayed terminal write before PostgreSQL closes.
Combined `CARGO_BUILD_JOBS=2 bun run check` passed on CL14+CL15+CL16: 132 tooling, 43 utility, 44 calculation, 1,231 integration and 150 Rust tests. Fourteen existing integration conditional skips and four Rust ignored tests remain. Builds, application/contract typechecks, lint and secret audit passed. Scoped disposable PostgreSQL gate remains the CL14 33-case result; no UI or financial schema/transition changed, so browser/full database suites were not rerun. Logs are under `/tmp/stock-bot-engine-cleanup-20261026/` (`combined-check.log`, `cl14-root-postgres.log`, `cl16-worker-accepted.log`). No performance profiling or activation was performed.
CL14 implementation commit: `21666242`. First wave completes CL14, CL15 and CL16; CL17–CL20 are the next ready tasks and CL21 remains conditional. Prior 68 task records retain their pre-wave state.