Skip to content

Commit d14dd9a

Browse files
V36 Gate 7: Implement Exchange dispute repair revenue routes
Adds package-owned ExchangeDisputeRepairCase and ExchangeRevenueRoute canon, generated source-safe artifact, generator, checker, focused protocol tests, docs/spec parity updates, and workflow wiring. Advances the V36 roadmap to Gate 8 while keeping earlier gate checks greenable.
1 parent 3e63fa5 commit d14dd9a

19 files changed

Lines changed: 4652 additions & 3 deletions

.bitcode/v36-exchange-dispute-repair-revenue-route.json

Lines changed: 3101 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
@@ -88,6 +88,9 @@ jobs:
8888
if [ -f scripts/check-v36-gate6-exchange-settlement-reconciliation.mjs ]; then
8989
node scripts/check-v36-gate6-exchange-settlement-reconciliation.mjs --skip-branch-check
9090
fi
91+
if [ -f scripts/check-v36-gate7-exchange-dispute-repair-revenue-route.mjs ]; then
92+
node scripts/check-v36-gate7-exchange-dispute-repair-revenue-route.mjs --skip-branch-check
93+
fi
9194
fi
9295
else
9396
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
@@ -216,6 +216,9 @@ jobs:
216216
if [ -f scripts/check-v36-gate6-exchange-settlement-reconciliation.mjs ]; then
217217
node scripts/check-v36-gate6-exchange-settlement-reconciliation.mjs --skip-branch-check
218218
fi
219+
if [ -f scripts/check-v36-gate7-exchange-dispute-repair-revenue-route.mjs ]; then
220+
node scripts/check-v36-gate7-exchange-dispute-repair-revenue-route.mjs --skip-branch-check
221+
fi
219222
fi
220223
else
221224
echo "Unexpected BITCODE_SPEC.txt pointer: $POINTER" >&2
@@ -276,6 +279,7 @@ jobs:
276279
pnpm --dir packages/protocol exec node --test --test-force-exit test/v36-exchange-rights-transfer-review.test.js
277280
pnpm --dir packages/protocol exec node --test --test-force-exit test/v36-exchange-pricing-quote.test.js
278281
pnpm --dir packages/protocol exec node --test --test-force-exit test/v36-exchange-settlement-reconciliation.test.js
282+
pnpm --dir packages/protocol exec node --test --test-force-exit test/v36-exchange-dispute-repair-revenue-route.test.js
279283
pnpm --filter @bitcode/api exec jest --config jest.config.cjs --runTestsByPath src/routes/__tests__/btd-crypto.test.ts --runInBand
280284
pnpm --filter @bitcode/api exec jest --config jest.config.cjs --runTestsByPath src/routes/__tests__/auxillaries-contract.test.ts --runInBand
281285
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: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,34 @@ settlement finality and delivery are auditable.
177177
Delivery stays blocked while finality, rights-transfer receipt, database
178178
projection, or object-storage projection is missing, stale, or drifted.
179179

180+
## V36 Gate 7 ExchangeDisputeRepairCase and ExchangeRevenueRoute canon
181+
182+
Gate 7 implements `ExchangeDisputeRepairCase` and `ExchangeRevenueRoute` as the
183+
package-owned operational contracts for Exchange failures, repairs, operator
184+
runbooks, and revenue conservation.
185+
`ExchangeDisputeRepairCase` covers stale owner, cancelled order replay, underpayment, overpayment, projection drift, source leakage, and delivery mismatch.
186+
Each case binds affected order identity, affected settlement receipt identity,
187+
affected projection roots, source-safe repair command, verification command,
188+
proof-rooted runbook, escalation path, proof roots, and event ids.
189+
190+
`ExchangeRevenueRoute` covers depositor, reader, treasury, fee, BTC route, BTD right route, and conservation proof.
191+
Each route binds public principal ids, BTC debit/credit amounts, BTD range
192+
identity, rights-transfer receipt identity, source-to-shares proof root, and a
193+
conservation proof that reader debit equals depositor credit plus treasury
194+
credit plus fee credit plus reader refund.
195+
196+
Gate 7 emits `.bitcode/v36-exchange-dispute-repair-revenue-route.json` with
197+
`source-safe-exchange-dispute-repair-revenue-route-metadata`.
198+
runbooks and repair commands are source-safe and proof-rooted.
199+
The artifact may expose dispute identities, incident classes, affected order and
200+
settlement ids, projection roots, source-safe repair commands, verification
201+
commands, runbook ids, escalation status, revenue accounts, BTC amounts, BTD
202+
right-route metadata, source-to-shares roots, conservation proofs, proof roots,
203+
and event ids; it must not expose protected source, unpaid AssetPack source,
204+
wallet private material, provider tokens, protected prompts, protected model
205+
responses, private payment credentials, private buyer repository payloads,
206+
object-storage private bytes, raw disputed source bytes, or secret values.
207+
180208
## Canonical Bitcode executive summary
181209

182210
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: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,8 @@ Closure acceptance:
139139
- `ExchangeDisputeRepairCase` covers stale owner, cancelled order replay, underpayment, overpayment, projection drift, source leakage, and delivery mismatch;
140140
- `ExchangeRevenueRoute` covers depositor, reader, treasury, fee, BTC route, BTD right route, and conservation proof;
141141
- runbooks and repair commands are source-safe and proof-rooted.
142+
- `.bitcode/v36-exchange-dispute-repair-revenue-route.json` is generated from the package-owned builder with `source-safe-exchange-dispute-repair-revenue-route-metadata`;
143+
- `pnpm run check:v36-gate7` validates package source, artifact freshness, package tests, docs, workflow wiring, dispute coverage, revenue route coverage, repair commands, verification commands, proof-rooted runbooks, escalation paths, conservation proofs, source-safety, proof roots, and event ids.
142144

143145
### Gate 8: Exchange UX And Terminal Navigation Integration
144146

BITCODE_SPEC_V36_NOTES.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,21 @@ Delivery remains blocked until paid finality, rights-transfer receipt,
138138
projection synchronization, object-storage projection, and delivery state are
139139
all source-safe and proof-rooted.
140140

141+
## Gate 7 closure notes
142+
143+
Gate 7 closes when `ExchangeDisputeRepairCase` and `ExchangeRevenueRoute` are
144+
package-owned and generated through
145+
`.bitcode/v36-exchange-dispute-repair-revenue-route.json`.
146+
The generated artifact carries
147+
`source-safe-exchange-dispute-repair-revenue-route-metadata`.
148+
`ExchangeDisputeRepairCase` covers stale owner, cancelled order replay, underpayment, overpayment, projection drift, source leakage, and delivery mismatch.
149+
`ExchangeRevenueRoute` covers depositor, reader, treasury, fee, BTC route, BTD right route, and conservation proof.
150+
runbooks and repair commands are source-safe and proof-rooted.
151+
Dispute and revenue artifacts remain source-safe: they expose roots, public
152+
principal ids, status, commands, routes, and proof posture, not protected source,
153+
unpaid AssetPack source, private payment credentials, or wallet private
154+
material.
155+
141156
## Accepted boundaries
142157

143158
- V36 owns deeper Exchange.

BITCODE_SPEC_V36_PARITY_MATRIX.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ No `_legacy/` source is active source truth.
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. |
6060
| 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` | closed | Payment observation, finality state, rights-transfer receipt, ledger root, database projection root, object storage root, delivery state, repair id, observer jobs, and repair jobs reconcile. |
62-
| 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. |
62+
| Dispute repair revenue routes | Gate 7 | `ExchangeDisputeRepairCase`, `ExchangeRevenueRoute`, `.bitcode/v36-exchange-dispute-repair-revenue-route.json`, tests, and `check:v36-gate7` | closed | 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. |
6464
| Local staging rehearsal | Gate 9 | `.bitcode/v36-exchange-rehearsal.json`, local/staging logs, proof roots, and `check:v36-gate9` | draft-required | Local and staging-testnet list/bid/ask/cancel/accept/settle/repair/history flows are rehearsed. |
6565
| Promotion readiness | Gate 10 | `.bitcode/v36-promotion-readiness-report.json`, promotion workflow, generated proof support, and `check:v36-gate10` | draft-required | V36 can promote only after all Exchange gates pass and generated canon remains source-safe. |
@@ -159,6 +159,20 @@ No `_legacy/` source is active source truth.
159159
| Settlement payloads are source-safe | `source-safe-exchange-settlement-reconciliation-metadata`; protected source, unpaid AssetPack source, private wallet material, provider tokens, protected prompts, protected model responses, private payment credentials, object-storage private bytes, private buyer payloads, and secret values are forbidden | closed |
160160
| Workflow and package tests are wired | `packages/protocol/test/v36-exchange-settlement-reconciliation.test.js`, `scripts/check-v36-gate6-exchange-settlement-reconciliation.mjs`, `.github/workflows/bitcode-gate-quality.yml` | closed |
161161

162+
## Gate 7 Parity
163+
164+
| Requirement | Source evidence | Current V36 judgment |
165+
| --- | --- | --- |
166+
| `ExchangeDisputeRepairCase` and `ExchangeRevenueRoute` are package-owned | `packages/protocol/src/canonical/exchange-dispute-repair-revenue-route.js`, `packages/protocol/src/index.js`, `packages/protocol/src/index.d.ts` | closed |
167+
| Generated dispute and revenue artifact exists | `.bitcode/v36-exchange-dispute-repair-revenue-route.json`, `scripts/generate-v36-exchange-dispute-repair-revenue-route.mjs`, `pnpm run check:v36-exchange-dispute-repair-revenue-route` | closed |
168+
| Required dispute classes are covered | stale owner, cancelled order replay, underpayment, overpayment, projection drift, source leakage, and delivery mismatch | closed |
169+
| Required revenue route fields are covered | depositor, reader, treasury, fee, BTC route, BTD right route, and conservation proof | closed |
170+
| Repair operations are source-safe | runbooks and repair commands are source-safe and proof-rooted | closed |
171+
| Escalation and verification are explicit | repair commands, verification commands, escalation paths, proof roots, and event ids are present for every dispute case | closed |
172+
| Revenue conservation is explicit | every revenue route proves BTC debits equal credits while BTD rights and source-to-shares roots remain conserved | closed |
173+
| Dispute and revenue payloads are source-safe | `source-safe-exchange-dispute-repair-revenue-route-metadata`; protected source, unpaid AssetPack source, private wallet material, private payment credentials, raw disputed source bytes, provider tokens, protected prompts, protected model responses, private buyer payloads, object-storage private bytes, and secret values are forbidden | closed |
174+
| Workflow and package tests are wired | `packages/protocol/test/v36-exchange-dispute-repair-revenue-route.test.js`, `scripts/check-v36-gate7-exchange-dispute-repair-revenue-route.mjs`, `.github/workflows/bitcode-gate-quality.yml` | closed |
175+
162176
## V36 accepted boundaries
163177

164178
- V36 owns deeper Exchange.

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,13 @@ and the source-safe generated artifact
4848
The receipt binds payment observation, finality state, rights transfer receipt, ledger root, database projection root, object storage root, delivery state, and repair id.
4949
The source-safe verdict is
5050
`source-safe-exchange-settlement-reconciliation-metadata`; observers and repair jobs reconcile database projections to ledger truth, and settlement finality and delivery are auditable.
51+
V36 Gate 7 anchors dispute repair and revenue routing through package-owned
52+
`ExchangeDisputeRepairCase`, `ExchangeRevenueRoute`, and the source-safe
53+
generated artifact `.bitcode/v36-exchange-dispute-repair-revenue-route.json`.
54+
`ExchangeDisputeRepairCase` covers stale owner, cancelled order replay, underpayment, overpayment, projection drift, source leakage, and delivery mismatch.
55+
`ExchangeRevenueRoute` covers depositor, reader, treasury, fee, BTC route, BTD right route, and conservation proof.
56+
The source-safe verdict is
57+
`source-safe-exchange-dispute-repair-revenue-route-metadata`; runbooks and repair commands are source-safe and proof-rooted.
5158
Promoted V35 closure owns telemetry and documentation depth over promoted V34:
5259
internal codebase docs, public `/docs`, telemetry taxonomy, dashboards, alert
5360
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 7 Dispute Repair Revenue Route Operations, following V36 Gate 6 Exchange settlement reconciliation closure.
8+
- Current working gate: V36 Gate 8 Exchange UX And Terminal Navigation Integration, following V36 Gate 7 dispute repair revenue route 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`.
@@ -33,6 +33,7 @@
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.
3434
- 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.
3535
- V36 Gate 6 closure anchor: Exchange depth now owns package-backed `ExchangeSettlementReceipt` source, deterministic `.bitcode/v36-exchange-settlement-reconciliation.json`, `source-safe-exchange-settlement-reconciliation-metadata`, payment observation, finality state, rights transfer receipt, ledger root, database projection root, object storage root, delivery state, repair id, observer jobs, repair jobs, proof roots, event ids, package tests, workflow wiring, and `check:v36-gate6`; observers and repair jobs reconcile database projections to ledger truth, and settlement finality and delivery are auditable.
36+
- V36 Gate 7 closure anchor: Exchange depth now owns package-backed `ExchangeDisputeRepairCase` and `ExchangeRevenueRoute` source, deterministic `.bitcode/v36-exchange-dispute-repair-revenue-route.json`, `source-safe-exchange-dispute-repair-revenue-route-metadata`, stale owner, cancelled order replay, underpayment, overpayment, projection drift, source leakage, delivery mismatch, depositor, reader, treasury, fee, BTC route, BTD right route, conservation proof, source-safe proof-rooted runbooks, repair commands, verification commands, escalation paths, proof roots, event ids, package tests, workflow wiring, and `check:v36-gate7`.
3637
- Purpose: concise running index of Bitcode/ENGI specification history, current work, and planned work.
3738

3839
This roadmap is not an active system specification.

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,9 @@
200200
"generate:v36-exchange-settlement-reconciliation": "node scripts/generate-v36-exchange-settlement-reconciliation.mjs",
201201
"check:v36-exchange-settlement-reconciliation": "node scripts/generate-v36-exchange-settlement-reconciliation.mjs --check",
202202
"check:v36-gate6": "node scripts/check-v36-gate6-exchange-settlement-reconciliation.mjs",
203+
"generate:v36-exchange-dispute-repair-revenue-route": "node scripts/generate-v36-exchange-dispute-repair-revenue-route.mjs",
204+
"check:v36-exchange-dispute-repair-revenue-route": "node scripts/generate-v36-exchange-dispute-repair-revenue-route.mjs --check",
205+
"check:v36-gate7": "node scripts/check-v36-gate7-exchange-dispute-repair-revenue-route.mjs",
203206
"check:spec-quality": "node scripts/run-bitcode-spec-quality.mjs --mode basic",
204207
"check:spec-quality:title": "node scripts/run-bitcode-spec-quality.mjs --mode strict-from-title",
205208
"check:spec-quality:v24": "node scripts/run-bitcode-spec-quality.mjs --mode strict-version --version V24",

0 commit comments

Comments
 (0)