Skip to content

Commit f3e606a

Browse files
V36 Gate 5: Implement Exchange pricing quote
Adds the package-owned ExchangePricingQuote builder, deterministic pricing/liquidity/wrapper artifact, generated quote roots, payment mismatch closure states, and source-safe docs/spec parity for V36 Exchange pricing. Validation: pnpm run check:v36-gate5; pnpm run check:v36-exchange-pricing-quote; pnpm --filter @bitcode/protocol exec node --test --test-force-exit test/v36-exchange-pricing-quote.test.js; pnpm --filter @bitcode/protocol typecheck; pnpm --filter @bitcode/protocol test; pnpm run check:v36-gate4; pnpm run check:v36-gate3; pnpm run check:v36-gate2; pnpm run check:v36-gate1; node scripts/check-bitcode-spec-family.mjs --version V36 --mode draft --current-target V35; node scripts/check-bitcode-canonical-inputs.mjs --current-target V35; node scripts/check-bitcode-canon-posture-drift.mjs --active-canon V35 --draft-target V36; node scripts/check-v35-gate10-promotion-readiness.mjs --promotion-mode --skip-branch-check; git diff --cached --check.
1 parent e07b988 commit f3e606a

18 files changed

Lines changed: 2770 additions & 4 deletions

.bitcode/v36-pricing-liquidity-fee-quote.json

Lines changed: 1552 additions & 0 deletions
Large diffs are not rendered by default.

.github/workflows/bitcode-canon-quality.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,9 @@ jobs:
8282
if [ -f scripts/check-v36-gate4-exchange-rights-transfer-review.mjs ]; then
8383
node scripts/check-v36-gate4-exchange-rights-transfer-review.mjs --skip-branch-check
8484
fi
85+
if [ -f scripts/check-v36-gate5-exchange-pricing-quote.mjs ]; then
86+
node scripts/check-v36-gate5-exchange-pricing-quote.mjs --skip-branch-check
87+
fi
8588
fi
8689
else
8790
echo "Unexpected BITCODE_SPEC.txt pointer: $POINTER" >&2

.github/workflows/bitcode-gate-quality.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,9 @@ jobs:
210210
if [ -f scripts/check-v36-gate4-exchange-rights-transfer-review.mjs ]; then
211211
node scripts/check-v36-gate4-exchange-rights-transfer-review.mjs --skip-branch-check
212212
fi
213+
if [ -f scripts/check-v36-gate5-exchange-pricing-quote.mjs ]; then
214+
node scripts/check-v36-gate5-exchange-pricing-quote.mjs --skip-branch-check
215+
fi
213216
fi
214217
else
215218
echo "Unexpected BITCODE_SPEC.txt pointer: $POINTER" >&2
@@ -268,6 +271,7 @@ jobs:
268271
pnpm --dir packages/protocol exec node --test --test-force-exit test/v36-exchange-activity-book.test.js
269272
pnpm --dir packages/protocol exec node --test --test-force-exit test/v36-exchange-intent-order-contracts.test.js
270273
pnpm --dir packages/protocol exec node --test --test-force-exit test/v36-exchange-rights-transfer-review.test.js
274+
pnpm --dir packages/protocol exec node --test --test-force-exit test/v36-exchange-pricing-quote.test.js
271275
pnpm --filter @bitcode/api exec jest --config jest.config.cjs --runTestsByPath src/routes/__tests__/btd-crypto.test.ts --runInBand
272276
pnpm --filter @bitcode/api exec jest --config jest.config.cjs --runTestsByPath src/routes/__tests__/auxillaries-contract.test.ts --runInBand
273277
pnpm --dir packages/executions-mcp/src/mcp-server run test:mcp -- --runTestsByPath src/__tests__/unit/auth.test.ts --runInBand

BITCODE_SPEC_V36.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,37 @@ and admits no payment or delivery until repaired.
118118
Ledger journal state remains stronger than database projection state for
119119
rights-transfer preview, owner truth, and unlock state.
120120

121+
## V36 Gate 5 ExchangePricingQuote canon
122+
123+
Gate 5 implements `ExchangePricingQuote` as the package-owned deterministic
124+
pricing contract for Exchange quote review.
125+
`ExchangePricingQuote` names quote identity, quote state, AssetPack id, BTD
126+
range identity, BTC amount, measurement weight, measurement volume, liquidity
127+
band, wrapper analysis, treasury route, depositor route, reader route, quote
128+
root, network posture, settlement window, fail-closed conditions, proof roots,
129+
event ids, and ledger/database projection references before settlement can
130+
continue.
131+
132+
Gate 5 emits `.bitcode/v36-pricing-liquidity-fee-quote.json` with
133+
`source-safe-exchange-pricing-quote-metadata`.
134+
The deterministic quote basis includes measurement weight, measurement volume, liquidity band, wrapper analysis, BTC amount, treasury route, depositor route, reader route, and quote root.
135+
The source-safe quote may expose quote identity, AssetPack id, BTD range
136+
identity, BTC amount, measurement metadata, liquidity metadata, wrapper
137+
metadata, route metadata, proof roots, event ids, ledger/database projection
138+
refs, and fail-closed conditions; it must not expose protected source, unpaid
139+
AssetPack source, wallet private material, provider tokens, protected prompts,
140+
protected model responses, private payment credentials, private buyer
141+
repository payloads, or secret values.
142+
143+
wrapper analysis cannot make BTD range cells fungible chain-of-record assets.
144+
BTD range cells remain non-fungible source-share identities whose chain of
145+
record is the BTD range ledger journal, even when a wrapper is used for
146+
pricing, review, transfer, or market UX metadata.
147+
underpayment, overpayment, stale quote, or unsupported network posture fails closed.
148+
Ledger journal state remains stronger than database projection state for quote
149+
roots, settlement admission, payment matching, route allocation, and network
150+
posture.
151+
121152
## Canonical Bitcode executive summary
122153

123154
Bitcode measures technical knowledge, finds deposits that fit reviewed Reads, synthesizes source-bearing AssetPacks, and settles read rights in BTC with BTD range and rights receipts.

BITCODE_SPEC_V36_DELTA.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,9 @@ Closure acceptance:
114114

115115
- `ExchangePricingQuote` includes BTC amount, measurement weight, measurement volume, liquidity band, wrapper analysis, treasury route, depositor route, reader route, and quote root;
116116
- wrapper analysis cannot make BTD range cells fungible chain-of-record assets;
117-
- underpayment, overpayment, stale quote, or unsupported network posture fails closed.
117+
- underpayment, overpayment, stale quote, or unsupported network posture fails closed;
118+
- `.bitcode/v36-pricing-liquidity-fee-quote.json` is generated from the package-owned builder with `source-safe-exchange-pricing-quote-metadata`;
119+
- `pnpm run check:v36-gate5` validates package source, artifact freshness, package tests, docs, workflow wiring, BTC amount, measurement weight, measurement volume, liquidity band, wrapper analysis, treasury/depositor/reader routes, quote roots, wrapper non-fungibility, payment mismatch closure, stale quote closure, unsupported network closure, source-safety, proof roots, event ids, and ledger/database projection posture.
118120

119121
### Gate 6: Exchange Settlement Ledger Database Reconciliation
120122

BITCODE_SPEC_V36_NOTES.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,18 @@ The preview states distinguish owner-read, licensed-read, and blocked transfer s
114114
admitting payment/delivery for stale ownership, missing authority, policy denial,
115115
or missing transfer receipts.
116116

117+
## Gate 5 closure notes
118+
119+
Gate 5 closes when `ExchangePricingQuote` is package-owned and generated
120+
through `.bitcode/v36-pricing-liquidity-fee-quote.json`.
121+
The generated artifact carries `source-safe-exchange-pricing-quote-metadata`,
122+
BTC amount, measurement weight, measurement volume, liquidity band, wrapper analysis, treasury route, depositor route, reader route, quote root, proof
123+
roots, event ids, ledger/database projection refs, and fail-closed conditions.
124+
wrapper analysis cannot make BTD range cells fungible chain-of-record assets;
125+
the BTD range ledger journal remains the ownership and range identity record.
126+
underpayment, overpayment, stale quote, or unsupported network posture fails closed so settlement cannot continue with mismatched payment, expired price,
127+
or unsupported network state.
128+
117129
## Accepted boundaries
118130

119131
- V36 owns deeper Exchange.

BITCODE_SPEC_V36_PARITY_MATRIX.md

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ No `_legacy/` source is active source truth.
5757
| Exchange activity book | Gate 2 | `ExchangeActivityBook`, `.bitcode/v36-exchange-activity-book.json`, package source, tests, and `check:v36-gate2` | closed | Market-wide source-safe activity rows, filters, details, proof roots, event ids, redaction posture, and telemetry bindings exist. |
5858
| Exchange intent and order contracts | Gate 3 | `ExchangeIntent`, `ExchangeOrder`, `.bitcode/v36-exchange-intent-order-contracts.json`, package source, tests, and `check:v36-gate3` | closed | Buy, sell, bid, ask, cancel, accept, settle, and history transitions are typed, authorized, idempotent, policy-gated, source-safe, and replayable. |
5959
| Rights-transfer review | Gate 4 | `ExchangeRightsTransferPreview`, `.bitcode/v36-exchange-rights-transfer-review.json`, package source, tests, and `check:v36-gate4` | closed | BTD range identity, ownership, buyer, rights scope, disclosure boundary, settlement unlock, owner-read, licensed-read, and blocked transfer states are source-safe. |
60-
| Pricing quote | Gate 5 | `ExchangePricingQuote`, `.bitcode/v36-pricing-liquidity-fee-quote.json`, package source, tests, and `check:v36-gate5` | draft-required | BTC price, measurement weight, measurement volume, liquidity, wrapper analysis, fee split, and quote root are deterministic. |
60+
| Pricing quote | Gate 5 | `ExchangePricingQuote`, `.bitcode/v36-pricing-liquidity-fee-quote.json`, package source, tests, and `check:v36-gate5` | closed | BTC price, measurement weight, measurement volume, liquidity band, wrapper analysis, treasury/depositor/reader routes, quote roots, and fail-closed payment/network posture are deterministic. |
6161
| Settlement reconciliation | Gate 6 | `ExchangeSettlementReceipt`, `.bitcode/v36-exchange-settlement-reconciliation.json`, observers, repair tests, and `check:v36-gate6` | draft-required | Ledger, database, object storage, finality, delivery, and rights-transfer roots reconcile. |
6262
| Dispute repair revenue routes | Gate 7 | `ExchangeDisputeRepairCase`, `ExchangeRevenueRoute`, `.bitcode/v36-exchange-dispute-repair-revenue-route.json`, tests, and `check:v36-gate7` | draft-required | Disputes, repairs, revenue routes, conservation proofs, runbooks, and escalation paths exist. |
6363
| Exchange UX and Terminal integration | Gate 8 | `/exchange`, Terminal handoff, public docs, telemetry dashboards, `.bitcode/v36-exchange-ux-proof.json`, and `check:v36-gate8` | draft-required | Master-detail UX, source-safe expanded detail, order history, and Terminal navigation are validated. |
@@ -78,7 +78,7 @@ No `_legacy/` source is active source truth.
7878
| Exchange vocabulary | V36 spec family names `ExchangeActivityBook`, `ExchangeIntent`, `ExchangeOrder`, `ExchangeRightsTransferPreview`, `ExchangePricingQuote`, `ExchangeSettlementReceipt`, `ExchangeDisputeRepairCase`, and `ExchangeRevenueRoute` | drafted |
7979
| Disclosure boundary | Exchange previews expose source-safe market, proof, fee, rights, and settlement metadata, not protected source, secrets, wallet private material, or unpaid AssetPack contents | drafted |
8080
| Ledger projection boundary | Ledger records and journals outrank Supabase/PostgreSQL projections for ownership, settlement, and finality | drafted |
81-
| Pricing determinism | Measurement weight, measurement volume, liquidity, wrapper analysis, and BTC fee roots are auditable before settlement | draft-required |
81+
| Pricing determinism | Measurement weight, measurement volume, liquidity band, wrapper analysis, and BTC fee roots are auditable before settlement | closed |
8282
| Repair posture | Dispute and repair paths exist before optimistic Exchange settlement UX is promotion-ready | draft-required |
8383

8484
## Gate 1 Parity
@@ -134,6 +134,19 @@ No `_legacy/` source is active source truth.
134134
| Ledger/database projection posture is explicit | ledger journal refs outrank database projection refs for rights-transfer preview and owner truth | closed |
135135
| Workflow and package tests are wired | `packages/protocol/test/v36-exchange-rights-transfer-review.test.js`, `scripts/check-v36-gate4-exchange-rights-transfer-review.mjs`, `.github/workflows/bitcode-gate-quality.yml` | closed |
136136

137+
## Gate 5 Parity
138+
139+
| Requirement | Source evidence | Current V36 judgment |
140+
| --- | --- | --- |
141+
| `ExchangePricingQuote` is package-owned | `packages/protocol/src/canonical/exchange-pricing-quote.js`, `packages/protocol/src/index.js`, `packages/protocol/src/index.d.ts` | closed |
142+
| Generated pricing artifact exists | `.bitcode/v36-pricing-liquidity-fee-quote.json`, `scripts/generate-v36-exchange-pricing-quote.mjs`, `pnpm run check:v36-exchange-pricing-quote` | closed |
143+
| Deterministic quote inputs are covered | BTC amount, measurement weight, measurement volume, liquidity band, wrapper analysis, treasury route, depositor route, reader route, and quote root | closed |
144+
| Wrapper non-fungibility boundary is enforced | wrapper analysis cannot make BTD range cells fungible chain-of-record assets | closed |
145+
| Payment and network failures close safely | underpayment, overpayment, stale quote, or unsupported network posture fails closed | closed |
146+
| Pricing payloads are source-safe | `source-safe-exchange-pricing-quote-metadata`; protected source, unpaid AssetPack source, private wallet material, provider tokens, protected prompts, protected model responses, private payment credentials, private buyer payloads, and secret values are forbidden | closed |
147+
| Ledger/database projection posture is explicit | ledger journal refs outrank database projection refs for quote roots, settlement admission, route allocation, and network posture | closed |
148+
| Workflow and package tests are wired | `packages/protocol/test/v36-exchange-pricing-quote.test.js`, `scripts/check-v36-gate5-exchange-pricing-quote.mjs`, `.github/workflows/bitcode-gate-quality.yml` | closed |
149+
137150
## V36 accepted boundaries
138151

139152
- V36 owns deeper Exchange.

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ identity, current owner, requested buyer, rights scope, settlement unlock,
3737
disclosure limit, and owner-read, licensed-read, and blocked transfer states.
3838
AssetPack source is hidden until paid settlement and rights transfer are
3939
complete.
40+
V36 Gate 5 anchors pricing through package-owned `ExchangePricingQuote` and the
41+
source-safe generated artifact `.bitcode/v36-pricing-liquidity-fee-quote.json`.
42+
The quote covers BTC amount, measurement weight, measurement volume, liquidity band, wrapper analysis, treasury route, depositor route, reader route, and
43+
quote root. The source-safe verdict is
44+
`source-safe-exchange-pricing-quote-metadata`; wrapper analysis cannot make BTD range cells fungible chain-of-record assets, and underpayment, overpayment, stale quote, or unsupported network posture fails closed.
4045
Promoted V35 closure owns telemetry and documentation depth over promoted V34:
4146
internal codebase docs, public `/docs`, telemetry taxonomy, dashboards, alert
4247
runbooks, incident response, operator escalation, documentation QA, developer

SPECIFICATIONS_ROADMAP.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
- Current active canonical pointer: `BITCODE_SPEC.txt` -> `V35`
66
- Current active canon: `BITCODE_SPEC_V35.md`
77
- Current draft target: `BITCODE_SPEC_V36.md`
8-
- Current working gate: V36 Gate 5 Pricing Liquidity Fee Quote And Wrapper Analysis, following V36 Gate 4 Exchange rights-transfer review closure.
8+
- Current working gate: V36 Gate 6 Exchange Settlement Ledger Database Reconciliation, following V36 Gate 5 Exchange pricing/liquidity quote closure.
99
- Latest closed version: V35 Telemetry And Documentation Depth, which promoted documentation surfaces, telemetry taxonomy, public docs, dashboards, alert runbooks, incident response, operator escalation, documentation QA, onboarding, local/staging telemetry rehearsal, and V35 promotion readiness.
1010
- Recent V35 closure anchor: V35 Gate 10 Promotion Readiness generated V35 proof support, promoted `BITCODE_SPEC.txt` to `V35`, prepared V35 active / V36 draft runtime posture, and closed telemetry/documentation-depth canon.
1111
- V34 Gate 2 closure anchor: deployment-depth now owns package-backed `DeploymentHostCapabilityCatalog` and `EnvironmentLaneContract` source, deterministic `.bitcode/v34-deployment-host-capability-catalog.json` and `.bitcode/v34-environment-lane-contracts.json`, and visible `value-bearing-mainnet` blocking through `blocked_future_canon_required`.
@@ -31,6 +31,7 @@
3131
- V36 Gate 2 closure anchor: Exchange depth now owns package-backed `ExchangeActivityBook` source, deterministic `.bitcode/v36-exchange-activity-book.json`, `source-safe-exchange-activity-book-metadata`, listing, bid, ask, cancellation, acceptance, settlement, repair, revenue route, and history entry rows, market-wide filters, detail sections, proof roots, event ids, redaction posture, ledger/database projection references, package tests, workflow wiring, and `check:v36-gate2`; activity detail never exposes protected source or unpaid AssetPack content.
3232
- V36 Gate 3 closure anchor: Exchange depth now owns package-backed `ExchangeIntent` and `ExchangeOrder` source, deterministic `.bitcode/v36-exchange-intent-order-contracts.json`, `source-safe-exchange-intent-order-contract-metadata`, buy, sell, bid, ask, cancel, accept, settle, and history transition rows, actor principals, organization roles, wallet posture, authority proofs, idempotency keys, policy decisions, fail-closed results, proof roots, event ids, ledger journal refs, database projection refs, package tests, workflow wiring, and `check:v36-gate3`; order history is replayable without private wallet material or secrets.
3333
- V36 Gate 4 closure anchor: Exchange depth now owns package-backed `ExchangeRightsTransferPreview` source, deterministic `.bitcode/v36-exchange-rights-transfer-review.json`, `source-safe-exchange-rights-transfer-review-metadata`, BTD range identity, current owner, requested buyer, rights scope, settlement unlock condition, disclosure limit, owner-read, licensed-read, and blocked transfer preview states, proof roots, event ids, ledger/database projection refs, package tests, workflow wiring, and `check:v36-gate4`; AssetPack source is hidden until paid settlement and rights transfer are complete.
34+
- V36 Gate 5 closure anchor: Exchange depth now owns package-backed `ExchangePricingQuote` source, deterministic `.bitcode/v36-pricing-liquidity-fee-quote.json`, `source-safe-exchange-pricing-quote-metadata`, BTC amount, measurement weight, measurement volume, liquidity band, wrapper analysis, treasury route, depositor route, reader route, quote root, proof roots, event ids, ledger/database projection refs, package tests, workflow wiring, and `check:v36-gate5`; wrapper analysis cannot make BTD range cells fungible chain-of-record assets, and underpayment, overpayment, stale quote, or unsupported network posture fails closed.
3435
- Purpose: concise running index of Bitcode/ENGI specification history, current work, and planned work.
3536

3637
This roadmap is not an active system specification.

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,9 @@
194194
"generate:v36-exchange-rights-transfer-review": "node scripts/generate-v36-exchange-rights-transfer-review.mjs",
195195
"check:v36-exchange-rights-transfer-review": "node scripts/generate-v36-exchange-rights-transfer-review.mjs --check",
196196
"check:v36-gate4": "node scripts/check-v36-gate4-exchange-rights-transfer-review.mjs",
197+
"generate:v36-exchange-pricing-quote": "node scripts/generate-v36-exchange-pricing-quote.mjs",
198+
"check:v36-exchange-pricing-quote": "node scripts/generate-v36-exchange-pricing-quote.mjs --check",
199+
"check:v36-gate5": "node scripts/check-v36-gate5-exchange-pricing-quote.mjs",
197200
"check:spec-quality": "node scripts/run-bitcode-spec-quality.mjs --mode basic",
198201
"check:spec-quality:title": "node scripts/run-bitcode-spec-quality.mjs --mode strict-from-title",
199202
"check:spec-quality:v24": "node scripts/run-bitcode-spec-quality.mjs --mode strict-version --version V24",

0 commit comments

Comments
 (0)