diff --git a/ENTITY_V3_EEP_CONFORMANCE_MANIFEST.json b/ENTITY_V3_EEP_CONFORMANCE_MANIFEST.json index 89f8dfad..600b2c38 100644 --- a/ENTITY_V3_EEP_CONFORMANCE_MANIFEST.json +++ b/ENTITY_V3_EEP_CONFORMANCE_MANIFEST.json @@ -1,105 +1,106 @@ -{ - "based_on_local_commit": "68179328a2b87408af93a5caa1c64312e70247be", - "claim_boundaries": [ - "development conformance evidence is not a released protocol qualification", - "signature cryptography remains governed by the ENTITY identity layer", - "stateful market authorization and signature verification are tested by executable campaigns in addition to schema vectors", - "external independent EEP clean-room interoperability remains pending" - ], - "conformance": { - "complete_active_tree": { - "passed": 90, - "total": 90 - }, - "json_schema_draft": "2020-12", - "record_definitions": 13, - "reference_mirror_convergence_tests": { - "passed": 16, - "total": 16 - }, - "schema_and_vector_tests": { - "passed": 4, - "total": 4 - }, - "signed_wire_schemas": 11, - "validator_chain": [ - "JSON_SCHEMA_DRAFT_2020_12", - "ENTITY_CANONICAL_SIGNED_WIRE_RULES" - ], - "vectors_expected_invalid": 14, - "vectors_expected_valid": 13, - "vectors_total": 27 - }, - "created_date": "2026-09-23", - "files": [ - { - "path": "src/31_Profiles/exchange_protocol.py", - "sha256": "cca451e553ea70a778c983805d155f05bb92baab5f481f75a60084a92e48d9f6" - }, - { - "path": "src/32_V3_Hardening/exchange_protocol.py", - "sha256": "a631e259d2f0d7e4c4abf3acf1c04586e22bf5072928e5f9a9ddc3c130713637" - }, - { - "path": "protocol/v3/ENTITY_EXCHANGE_PROTOCOL_DRAFT.md", - "sha256": "1733dcf2055a4353abd611344582438a04cbae08b358451290885697c665dbd7" - }, - { - "path": "protocol/v3/ENTITY_EXCHANGE_PROTOCOL.schema.json", - "sha256": "146932a4598797e295ad7d86ac3ee3ee80261fc1675b1bfb4724df0e05fa3218" - }, - { - "path": "protocol/v3/eep_vectors/VECTOR_MANIFEST.json", - "sha256": "08fe381309dc122e0efb8544490e23287e53b3d37cea868b5cd359cc736c4b53" - }, - { - "path": "protocol/v3/eep_vectors/SHA256SUMS.txt", - "sha256": "68989a573a74046e55d6b2713f9fdee8304d8b709d22dd5ccd17f32791d927b7" - }, - { - "path": "protocol/v3/eep_vectors/README.md", - "sha256": "ff734344b2be9e523109c677b4aa746b19eb7e505bd4ba01be8f11ef44ca030e" - }, - { - "path": "tests/test_v3_eep_conformance.py", - "sha256": "d832cc585662a8722bb3ac95763c6f487285983818794a314826792a6c11390f" - }, - { - "path": "tests/test_v3_exchange_convergence.py", - "sha256": "079767d481e2dd09582bbf8b5e97a0ea4334d3fe06acbcc32e99c03caddf29fd" - }, - { - "path": "tests/test_v3_hardening_exchange.py", - "sha256": "f7a7ecf9fa7d748d3953eb68c426945273c42fcf3a952048f21f0def773ecd17" - }, - { - "path": "requirements.txt", - "sha256": "ba36584e5af40e46435d63315f94fb6d600e3d18af53d123e321763f98f22668" - }, - { - "path": "tools/run_v3_regression.ps1", - "sha256": "0bc9f4acc6d1fb8b6b274c305bd89750b78e68ad5568887ee46a577385d5f5f9" - } - ], - "invariants": [ - "signed wire values are not silently normalized after signature verification", - "JSON integer fields reject numeric strings and booleans", - "enumerated tokens and usage actions are canonical uppercase", - "SHA-256 values are canonical lowercase hexadecimal", - "rights action lists are non-empty, unique, and lexicographically sorted", - "revenue allocations do not exceed 10000 basis points", - "RFQ and quote expiry follows signed creation time", - "entitlement expiry semantics converge across reference and qualification mirror", - "executed but unsettled sell quantities remain reserved until clearing completes", - "trade revenue allocation is bound at execution and is not changed by later rule-set mutation", - "sell admission rechecks unreserved entitlement atomically under concurrent submissions", - "concurrent matchers cannot create duplicate trades from the same executable orders", - "concurrent settlement attempts commit at most one entitlement transfer", - "revenue-event persistence is atomic with hardening-profile settlement state" - ], - "schema": "entity-v3-eep-conformance-manifest-v1", - "snapshot_sha256": "00b066155090b7612191852293429d00d76c996ccf00c122fc1f549f19f3cf53", - "status": "BTG_INTERNAL_QUALIFIED_RELEASE_COMPONENT", - "version": "3.0.0", - "working_tree_snapshot": false -} +{ + "based_on_local_commit": "68179328a2b87408af93a5caa1c64312e70247be", + "claim_boundaries": [ + "development conformance evidence is not a released protocol qualification", + "signature cryptography remains governed by the ENTITY identity layer", + "stateful market authorization and signature verification are tested by executable campaigns in addition to schema vectors", + "external independent EEP clean-room interoperability remains pending" + ], + "conformance": { + "complete_active_tree": { + "passed": 90, + "total": 90 + }, + "json_schema_draft": "2020-12", + "record_definitions": 13, + "reference_mirror_convergence_tests": { + "passed": 16, + "total": 16 + }, + "schema_and_vector_tests": { + "passed": 4, + "total": 4 + }, + "signed_wire_schemas": 11, + "validator_chain": [ + "JSON_SCHEMA_DRAFT_2020_12", + "ENTITY_CANONICAL_SIGNED_WIRE_RULES" + ], + "vectors_expected_invalid": 14, + "vectors_expected_valid": 13, + "vectors_total": 27 + }, + "created_date": "2026-09-23", + "files": [ + { + "path": "src/31_Profiles/exchange_protocol.py", + "sha256": "53761f15c7ae58726ce8cd01a28164d3a14ae29aac38a89859c408fc3c76b14a" + }, + { + "path": "src/32_V3_Hardening/exchange_protocol.py", + "sha256": "767e2a83a7ab5a71256c4f9535b75d91e7d33c97aaa7b7cefc617ffa7874bf41" + }, + { + "path": "protocol/v3/ENTITY_EXCHANGE_PROTOCOL_DRAFT.md", + "sha256": "1733dcf2055a4353abd611344582438a04cbae08b358451290885697c665dbd7" + }, + { + "path": "protocol/v3/ENTITY_EXCHANGE_PROTOCOL.schema.json", + "sha256": "146932a4598797e295ad7d86ac3ee3ee80261fc1675b1bfb4724df0e05fa3218" + }, + { + "path": "protocol/v3/eep_vectors/VECTOR_MANIFEST.json", + "sha256": "08fe381309dc122e0efb8544490e23287e53b3d37cea868b5cd359cc736c4b53" + }, + { + "path": "protocol/v3/eep_vectors/SHA256SUMS.txt", + "sha256": "68989a573a74046e55d6b2713f9fdee8304d8b709d22dd5ccd17f32791d927b7" + }, + { + "path": "protocol/v3/eep_vectors/README.md", + "sha256": "ff734344b2be9e523109c677b4aa746b19eb7e505bd4ba01be8f11ef44ca030e" + }, + { + "path": "tests/test_v3_eep_conformance.py", + "sha256": "d832cc585662a8722bb3ac95763c6f487285983818794a314826792a6c11390f" + }, + { + "path": "tests/test_v3_exchange_convergence.py", + "sha256": "079767d481e2dd09582bbf8b5e97a0ea4334d3fe06acbcc32e99c03caddf29fd" + }, + { + "path": "tests/test_v3_hardening_exchange.py", + "sha256": "f7a7ecf9fa7d748d3953eb68c426945273c42fcf3a952048f21f0def773ecd17" + }, + { + "path": "requirements.txt", + "sha256": "ba36584e5af40e46435d63315f94fb6d600e3d18af53d123e321763f98f22668" + }, + { + "path": "tools/run_v3_regression.ps1", + "sha256": "0bc9f4acc6d1fb8b6b274c305bd89750b78e68ad5568887ee46a577385d5f5f9" + } + ], + "invariants": [ + "signed wire values are not silently normalized after signature verification", + "JSON integer fields reject numeric strings and booleans", + "enumerated tokens and usage actions are canonical uppercase", + "SHA-256 values are canonical lowercase hexadecimal", + "rights action lists are non-empty, unique, and lexicographically sorted", + "revenue allocations do not exceed 10000 basis points", + "RFQ and quote expiry follows signed creation time", + "entitlement expiry semantics converge across reference and qualification mirror", + "executed but unsettled sell quantities remain reserved until clearing completes", + "trade revenue allocation is bound at execution and is not changed by later rule-set mutation", + "sell admission rechecks unreserved entitlement atomically under concurrent submissions", + "concurrent matchers cannot create duplicate trades from the same executable orders", + "concurrent settlement attempts commit at most one entitlement transfer", + "revenue-event persistence is atomic with hardening-profile settlement state", + "RFQ executions preserve a deterministic venue-signed source binding to signed RFQ, quote and acceptance records" + ], + "schema": "entity-v3-eep-conformance-manifest-v1", + "snapshot_sha256": "65224aa97bde5456c4079097a37284ce6e023f3e1c635f25456683c74e3df91a", + "status": "BTG_INTERNAL_QUALIFIED_RELEASE_COMPONENT", + "version": "3.0.0", + "working_tree_snapshot": false +} diff --git a/ENTITY_V3_EOPP_HARDENING_MANIFEST.json b/ENTITY_V3_EOPP_HARDENING_MANIFEST.json index d720e25d..ebaeee3a 100644 --- a/ENTITY_V3_EOPP_HARDENING_MANIFEST.json +++ b/ENTITY_V3_EOPP_HARDENING_MANIFEST.json @@ -1,72 +1,73 @@ -{ - "based_on_local_commit": "68179328a2b87408af93a5caa1c64312e70247be", - "claim_boundaries": [ - "working-tree hardening is not yet an immutable release", - "external independent v3 interoperability remains pending", - "external payment verification remains attestation evidence", - "indicative marks are not accounting fair value", - "legal and regulatory classification remains outside protocol truth" - ], - "created_date": "2026-09-23", - "files": [ - { - "path": "src/33_Economic_Participation/economic_participation.py", - "sha256": "3d805ab601bbf46001175796b601c3c66190c704408f86beb21f942f1de6a9d5" - }, - { - "path": "src/33_Economic_Participation/btg_deployment.py", - "sha256": "e6ecfe044ea3d5516f3fe3649252b0c23d3ec22a252e4cb8fc98880c98d1ff26" - }, - { - "path": "tests/test_v3_economic_participation.py", - "sha256": "35c376010c209108aa0c314f531c06739c8af929c0bfea6af1753d5452f1c093" - }, - { - "path": "protocol/v3/ENTITY_ORIGINATOR_PARTICIPATION_PROFILE.md", - "sha256": "d2e28bc76b8dfe65ecdbf0df9bc839777a913a75ffbee35e05b7a530203431d0" - }, - { - "path": "protocol/v3/ENTITY_ORIGINATOR_PARTICIPATION.schema.json", - "sha256": "4a8d4341e86f3d41eb41e16255d10cac8c0505ef216a6286ffbf76ac94b5a832" - }, - { - "path": "protocol/v3/BTG_TREASURY_DEPLOYMENT_REQUIREMENTS.md", - "sha256": "5d4157c537124b432027ef77d6bb891093074d5965a91b9ad3865b617f142cee" - } - ], - "hardenings": [ - "trade_time_policy_binding", - "non_retroactive_derivative_policy_binding", - "single_reserve_allocation_per_instrument", - "cross_store_atomic_reserve_allocation", - "atomic_economic_event_and_obligation", - "authorized_and_revocable_settlement_verifiers", - "event_and_obligation_trade_reconciliation", - "provider_receivable_without_payer_private_key", - "derivative_currency_binding", - "expanded_normative_record_schema" - ], - "invariants": { - "cryptocurrency_required": false, - "event_without_required_obligation_must_not_commit": true, - "hidden_btg_protocol_privilege": false, - "protocol_tax_bps": 0, - "reserve_transfer_without_allocation_record_must_not_commit": true - }, - "preserved_sealed_manifest_sha256": "7dc3dcd40e69dff30c615e01ecea32a96ea81243a123f108167b3fd6d390ad66", - "schema": "entity-v3-eopp-hardening-manifest-v1", - "snapshot_sha256": "6f787cf66a98f05eb9d43f5b2ef4d9ac94502cb9e084707ce060d146450a03a6", - "status": "BTG_INTERNAL_QUALIFIED_RELEASE_COMPONENT", - "validation": { - "complete_active_tree": { - "passed": 90, - "total": 90 - }, - "targeted_eopp": { - "passed": 20, - "total": 20 - } - }, - "version": "3.0.0", - "working_tree_snapshot": false -} +{ + "based_on_local_commit": "68179328a2b87408af93a5caa1c64312e70247be", + "claim_boundaries": [ + "working-tree hardening is not yet an immutable release", + "external independent v3 interoperability remains pending", + "external payment verification remains attestation evidence", + "indicative marks are not accounting fair value", + "legal and regulatory classification remains outside protocol truth" + ], + "created_date": "2026-09-23", + "files": [ + { + "path": "src/33_Economic_Participation/economic_participation.py", + "sha256": "493268dcc2a2d4564172cb7039e74861bfe63d93734e8b4a1cb70b97dc390d66" + }, + { + "path": "src/33_Economic_Participation/btg_deployment.py", + "sha256": "e6ecfe044ea3d5516f3fe3649252b0c23d3ec22a252e4cb8fc98880c98d1ff26" + }, + { + "path": "tests/test_v3_economic_participation.py", + "sha256": "f181089a2ed983dca3dfe1fb6f2a4690b4e285db9ed5992006a4477ef285be4b" + }, + { + "path": "protocol/v3/ENTITY_ORIGINATOR_PARTICIPATION_PROFILE.md", + "sha256": "d2e28bc76b8dfe65ecdbf0df9bc839777a913a75ffbee35e05b7a530203431d0" + }, + { + "path": "protocol/v3/ENTITY_ORIGINATOR_PARTICIPATION.schema.json", + "sha256": "4a8d4341e86f3d41eb41e16255d10cac8c0505ef216a6286ffbf76ac94b5a832" + }, + { + "path": "protocol/v3/BTG_TREASURY_DEPLOYMENT_REQUIREMENTS.md", + "sha256": "5d4157c537124b432027ef77d6bb891093074d5965a91b9ad3865b617f142cee" + } + ], + "hardenings": [ + "trade_time_policy_binding", + "non_retroactive_derivative_policy_binding", + "single_reserve_allocation_per_instrument", + "cross_store_atomic_reserve_allocation", + "atomic_economic_event_and_obligation", + "authorized_and_revocable_settlement_verifiers", + "event_and_obligation_trade_reconciliation", + "provider_receivable_without_payer_private_key", + "derivative_currency_binding", + "expanded_normative_record_schema", + "rfq_signed_source_participation_capture" + ], + "invariants": { + "cryptocurrency_required": false, + "event_without_required_obligation_must_not_commit": true, + "hidden_btg_protocol_privilege": false, + "protocol_tax_bps": 0, + "reserve_transfer_without_allocation_record_must_not_commit": true + }, + "preserved_sealed_manifest_sha256": "7dc3dcd40e69dff30c615e01ecea32a96ea81243a123f108167b3fd6d390ad66", + "schema": "entity-v3-eopp-hardening-manifest-v1", + "snapshot_sha256": "7f95bac570b5091346c2fa09a745e422e7b0449d8cf184d77c98ec4d65fdf503", + "status": "BTG_INTERNAL_QUALIFIED_RELEASE_COMPONENT", + "validation": { + "complete_active_tree": { + "passed": 90, + "total": 90 + }, + "targeted_eopp": { + "passed": 24, + "total": 24 + } + }, + "version": "3.0.0", + "working_tree_snapshot": false +} diff --git a/ENTITY_V3_MARKET_RECOVERY_MANIFEST.json b/ENTITY_V3_MARKET_RECOVERY_MANIFEST.json index 9a9beb1b..fb24daae 100644 --- a/ENTITY_V3_MARKET_RECOVERY_MANIFEST.json +++ b/ENTITY_V3_MARKET_RECOVERY_MANIFEST.json @@ -1,66 +1,66 @@ -{ - "based_on_local_commit": "68179328a2b87408af93a5caa1c64312e70247be", - "claim_boundaries": [ - "market recovery does not export private signing keys", - "market recovery composes with but does not replace ENTITY Core identity/key recovery", - "external settlement remains attestation evidence", - "development evidence is not release qualification", - "external independent market-recovery reimplementation remains pending" - ], - "created_date": "2026-09-23", - "files": [ - { - "path": "src/34_Market_Recovery/market_recovery.py", - "sha256": "97d084fdcece2289a5860e6a16007c40f39cd95f27693c961d702fdd1b388cd9" - }, - { - "path": "tests/test_v3_market_recovery.py", - "sha256": "e7a89fa2381421b21b37b6238217f72f8cc9cdf91259e82688128327b9b940ff" - }, - { - "path": "protocol/v3/ENTITY_MARKET_STATE_RECOVERY_PROFILE.md", - "sha256": "70be04b633a305b7c09d1873533370b1b059a2bc4227ae64c5b74320545df8c4" - }, - { - "path": "protocol/v3/ENTITY_V3_GAP_CLOSURE_MATRIX.md", - "sha256": "9b026fb2f29059fe8cb2bfac34f16845dae863dd420622738de224188828775c" - }, - { - "path": "ENTITY_V3_EEP_CONFORMANCE_MANIFEST.json", - "sha256": "07700ba28c78f9d7d5c65f946fc5a320f05f32918721f0e9efda75f054d34053" - }, - { - "path": "ENTITY_V3_EOPP_HARDENING_MANIFEST.json", - "sha256": "ecbb035a6fef8accfd68ca36bd2e7425957420b47c7f387c17dfd84341bdb3c4" - } - ], - "implemented": [ - "provider_independent_logical_eep_state_export", - "provider_independent_logical_eopp_state_export", - "per_table_and_per_database_semantic_roots", - "embedded_public_signer_manifests", - "venue_operator_and_treasury_owner_root_attestations", - "linked_core_sovereign_bundles", - "empty_destination_fail_closed_restore", - "atomic_cross_database_restore", - "post_restore_exact_state_root_comparison", - "destructive_market_database_recovery", - "tamper_detection_after_hash_recomputation", - "required_trade_revenue_binding_recovery" - ], - "schema": "entity-v3-market-recovery-evidence-manifest-v1", - "snapshot_sha256": "6055a9bd4c4a3ae0968bd425dd8245f62a4ce5cd57fbb4399903366667b970de", - "status": "BTG_INTERNAL_QUALIFIED_RELEASE_COMPONENT", - "validation": { - "complete_active_tree": { - "passed": 90, - "total": 90 - }, - "targeted_market_recovery": { - "passed": 7, - "total": 7 - } - }, - "version": "3.0.0", - "working_tree_snapshot": false -} +{ + "based_on_local_commit": "68179328a2b87408af93a5caa1c64312e70247be", + "claim_boundaries": [ + "market recovery does not export private signing keys", + "market recovery composes with but does not replace ENTITY Core identity/key recovery", + "external settlement remains attestation evidence", + "development evidence is not release qualification", + "external independent market-recovery reimplementation remains pending" + ], + "created_date": "2026-09-23", + "files": [ + { + "path": "src/34_Market_Recovery/market_recovery.py", + "sha256": "7a96f1e44b7910e7c1560074591c5a5dba208bd66d5e10702d828bd57b35e606" + }, + { + "path": "tests/test_v3_market_recovery.py", + "sha256": "e7a89fa2381421b21b37b6238217f72f8cc9cdf91259e82688128327b9b940ff" + }, + { + "path": "protocol/v3/ENTITY_MARKET_STATE_RECOVERY_PROFILE.md", + "sha256": "70be04b633a305b7c09d1873533370b1b059a2bc4227ae64c5b74320545df8c4" + }, + { + "path": "protocol/v3/ENTITY_V3_GAP_CLOSURE_MATRIX.md", + "sha256": "9b026fb2f29059fe8cb2bfac34f16845dae863dd420622738de224188828775c" + }, + { + "path": "ENTITY_V3_EEP_CONFORMANCE_MANIFEST.json", + "sha256": "265443f8c061c0fb77189900612c1474e1130e2d0ae5377fe4d1a64164429a02" + }, + { + "path": "ENTITY_V3_EOPP_HARDENING_MANIFEST.json", + "sha256": "1ebd28994b62cffb2e588395ff2bc94b98d8d1335dd07f907d7afef9db2e063a" + } + ], + "implemented": [ + "provider_independent_logical_eep_state_export", + "provider_independent_logical_eopp_state_export", + "per_table_and_per_database_semantic_roots", + "embedded_public_signer_manifests", + "venue_operator_and_treasury_owner_root_attestations", + "linked_core_sovereign_bundles", + "empty_destination_fail_closed_restore", + "atomic_cross_database_restore", + "post_restore_exact_state_root_comparison", + "destructive_market_database_recovery", + "tamper_detection_after_hash_recomputation", + "required_trade_revenue_binding_recovery" + ], + "schema": "entity-v3-market-recovery-evidence-manifest-v1", + "snapshot_sha256": "e6a4d64cd671a64e3f7497458c1e0f389c506bb86a189a27eef9854f0969f2d4", + "status": "BTG_INTERNAL_QUALIFIED_RELEASE_COMPONENT", + "validation": { + "complete_active_tree": { + "passed": 90, + "total": 90 + }, + "targeted_market_recovery": { + "passed": 7, + "total": 7 + } + }, + "version": "3.0.0", + "working_tree_snapshot": false +} diff --git a/src/31_Profiles/exchange_protocol.py b/src/31_Profiles/exchange_protocol.py index 20b2213d..8121df30 100644 --- a/src/31_Profiles/exchange_protocol.py +++ b/src/31_Profiles/exchange_protocol.py @@ -191,6 +191,10 @@ def _init(self): acceptance_id TEXT PRIMARY KEY, rfq_id TEXT NOT NULL, quote_id TEXT NOT NULL, requester TEXT NOT NULL, nonce TEXT NOT NULL UNIQUE, created_at_ms INTEGER NOT NULL, received_at_ms INTEGER NOT NULL, signature_json TEXT NOT NULL); + CREATE TABLE IF NOT EXISTS rfq_trade_sources( + trade_id TEXT PRIMARY KEY, rfq_id TEXT NOT NULL, quote_id TEXT NOT NULL, + acceptance_id TEXT NOT NULL, venue_operator TEXT NOT NULL, + created_at_ms INTEGER NOT NULL, signature_json TEXT NOT NULL); CREATE TABLE IF NOT EXISTS order_cancellations( cancellation_id TEXT PRIMARY KEY, order_id TEXT NOT NULL, participant TEXT NOT NULL, nonce TEXT NOT NULL UNIQUE, created_at_ms INTEGER NOT NULL, @@ -877,6 +881,15 @@ def _record_signed_quote_acceptance(self, body: dict, signature: dict) -> dict: buy_stub={"venue_id":rfq["venue_id"],"instrument_id":rfq["instrument_id"],"order_id":None,"participant":buyer} sell_stub={"order_id":None,"participant":seller} trade_id=self._execute_trade(db,buy_stub,sell_stub,int(rfq["quantity"]),int(quote["price"]),"RFQ") + venue=db.execute("SELECT * FROM venues WHERE venue_id=? AND status='ACTIVE'",(rfq["venue_id"],)).fetchone() + if not venue: raise KeyError("active RFQ venue missing") + source_created=now_ms() + source_body={"schema":"entity-eep-rfq-execution-source-v1","trade_id":trade_id,"venue_id":rfq["venue_id"],"instrument_id":rfq["instrument_id"], + "rfq_id":body["rfq_id"],"quote_id":body["quote_id"],"acceptance_id":body["acceptance_id"], + "requester":requester,"provider":quote["provider"],"buyer":buyer,"seller":seller, + "quantity":int(rfq["quantity"]),"price":int(quote["price"]),"venue_operator":venue["operator"],"created_at_ms":source_created} + source_sig=self.identity.sign(venue["operator"],source_body) + db.execute("INSERT INTO rfq_trade_sources VALUES(?,?,?,?,?,?,?)",(trade_id,body["rfq_id"],body["quote_id"],body["acceptance_id"],venue["operator"],source_created,json.dumps(source_sig,sort_keys=True))) db.execute("UPDATE rfqs SET status='ACCEPTED' WHERE rfq_id=?",(body["rfq_id"],)) db.execute("UPDATE quotes SET status='ACCEPTED' WHERE quote_id=?",(body["quote_id"],)) except sqlite3.IntegrityError as exc: raise ValueError("duplicate/replayed RFQ acceptance") from exc @@ -899,7 +912,7 @@ def surveillance_alerts(self, venue_id: str) -> list[dict]: def status(self) -> dict: with self._db() as db: - tables=("venues","instruments","listings","orders","order_cancellations","trades","clearing","payment_attestations","settlement_verifiers","entitlements","usage","surveillance","rfqs","quotes","rfq_acceptances","revenue_rule_sets","trade_revenue_bindings") + tables=("venues","instruments","listings","orders","order_cancellations","trades","clearing","payment_attestations","settlement_verifiers","entitlements","usage","surveillance","rfqs","quotes","rfq_acceptances","rfq_trade_sources","revenue_rule_sets","trade_revenue_bindings") counts={name:int(db.execute(f"SELECT COUNT(*) FROM {name}").fetchone()[0]) for name in tables} return {"schema":"entity-eep-status-v1","profile":"ENTITY_EXCHANGE_PROTOCOL","version":"3.0.0", "rights_are_traded_not_bytes":True,"venue_neutral":True,"payment_versus_right_transfer":True, diff --git a/src/32_V3_Hardening/exchange_protocol.py b/src/32_V3_Hardening/exchange_protocol.py index a1c55d60..b9e74bb1 100644 --- a/src/32_V3_Hardening/exchange_protocol.py +++ b/src/32_V3_Hardening/exchange_protocol.py @@ -128,6 +128,7 @@ def _init(self): CREATE TABLE IF NOT EXISTS rfqs(rfq_id TEXT PRIMARY KEY,venue_id TEXT,instrument_id TEXT,requester TEXT,side TEXT,quantity INTEGER,expires_at_ms INTEGER,status TEXT,created_at_ms INTEGER,nonce TEXT,received_at_ms INTEGER,signature_json TEXT); CREATE TABLE IF NOT EXISTS quotes(quote_id TEXT PRIMARY KEY,rfq_id TEXT,provider TEXT,price INTEGER,expires_at_ms INTEGER,status TEXT,created_at_ms INTEGER,nonce TEXT,received_at_ms INTEGER,signature_json TEXT); CREATE TABLE IF NOT EXISTS rfq_acceptances(acceptance_id TEXT PRIMARY KEY,rfq_id TEXT NOT NULL,quote_id TEXT NOT NULL,requester TEXT NOT NULL,nonce TEXT NOT NULL UNIQUE,created_at_ms INTEGER NOT NULL,received_at_ms INTEGER NOT NULL,signature_json TEXT NOT NULL); + CREATE TABLE IF NOT EXISTS rfq_trade_sources(trade_id TEXT PRIMARY KEY,rfq_id TEXT NOT NULL,quote_id TEXT NOT NULL,acceptance_id TEXT NOT NULL,venue_operator TEXT NOT NULL,created_at_ms INTEGER NOT NULL,signature_json TEXT NOT NULL); CREATE TABLE IF NOT EXISTS order_cancellations(cancellation_id TEXT PRIMARY KEY,order_id TEXT NOT NULL,participant TEXT NOT NULL,nonce TEXT NOT NULL UNIQUE,created_at_ms INTEGER NOT NULL,received_at_ms INTEGER NOT NULL,signature_json TEXT NOT NULL); CREATE TABLE IF NOT EXISTS settlement_verifiers(venue_id TEXT NOT NULL,verifier_entity_id TEXT NOT NULL,status TEXT NOT NULL,created_at_ms INTEGER NOT NULL,signature_json TEXT NOT NULL,PRIMARY KEY(venue_id,verifier_entity_id)); CREATE TABLE IF NOT EXISTS payment_attestations(attestation_id TEXT PRIMARY KEY,trade_id TEXT NOT NULL,verifier_entity_id TEXT NOT NULL,settlement_ref TEXT NOT NULL,evidence_sha256 TEXT NOT NULL,nonce TEXT NOT NULL UNIQUE,created_at_ms INTEGER NOT NULL,received_at_ms INTEGER NOT NULL,authority_basis TEXT NOT NULL,signature_json TEXT NOT NULL); @@ -575,10 +576,20 @@ def _record_signed_quote_acceptance(self,body,signature): if available