# Implementation Plan: 009-order-management-matcher

> For the complete documentation index, see [llms.txt](https://deploy-preview-413--lucky-concha-f3599f.netlify.app/llms.txt).

[Learning Guide — Order Management and Matcher](https://deploy-preview-413--lucky-concha-f3599f.netlify.app/docs/learning/state-009-order-management-matcher.md): purpose, walkthrough, and related learning states.

# Implementation Plan: 009-order-management-matcher

## Scope

*   Transition from `008-pricing-awareness-market-data` to `009-order-management-matcher`.
*   Track focus: `functional`.
*   Define requirement deltas and generation/test hooks.

## Deliverables

1.  Requirement deltas in `requirements/`.
2.  Contract deltas in `contracts/`.
3.  Supporting artifacts: `research.md`, `data-model.md`, `quickstart.md`.
4.  Architecture and topology deltas in `system/`.
5.  Observability contract for order lifecycle metrics (open/unfilled gauges, events, latency).
6.  Generation hook implementation in `pipeline/generate-state-009-order-management-matcher.sh`.
7.  Smoke test implementation in `scripts/test-state-009-order-management-matcher.sh`.
8.  Generated deployment bundle for live demo deployment from this generated-state branch (issue `#351`), aligned with shared containerized deployment contract.

## Exit Criteria

*   Spec and tasks are complete and reviewed.
*   Generation hook produces expected artifacts.
*   Smoke tests pass for this state, including order observability assertions.
*   Deployment bundle artifacts are generated and locally dry-run validated.
*   State can be published to `code/generated-state-009-order-management-matcher`.

## Demo recovery (#487)

Preserve the PostgreSQL 16 volume and back it up before replacement. Rebuild runtime binaries with fixed dependencies, upgrade compatible telemetry components, and replace legacy Promtail while preserving Docker log labels. Publish through the one-snapshot branch pipeline, require exact-snapshot CI and host scans, then verify public ingress, order lifecycle, retained trades/positions and observability. Track broader generator/CI work in `docs/operations/state-009-recovery.md`.

## PR #495 upgrade and regression follow-up

Apply a state-local PostgreSQL upgrade through Spring SQL initialization before Hibernate. Generate the migration and JUnit tests from runtime overrides. Run real matcher unit tests and PostgreSQL upgrade/fresh-install tests in the existing booking-durability CI job after state-009 generation; retain Python checks only as static contracts.

## Portable conformance ownership

Own regression assertions in state 009, with a JSON-lines lifecycle/observation adapter boundary. The PostgreSQL/Java adapter is the reference harness only. Export the pack into generated snapshots so overlay consumers can validate their final adapted runtime without copying source or writing a new interpretation of the assertions. Run the pack in the existing state-009 regression command/CI step.
