Skip to content

Commit 54abbbe

Browse files
Merge pull request #39 from engineeredsoftware/v30/gate-7-bridge-readiness-research-boundaries
V30 Gate 7: Bridge Readiness Research Boundaries
2 parents f7b91fe + 1fd0226 commit 54abbbe

16 files changed

Lines changed: 1092 additions & 1 deletion

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ jobs:
8585
node scripts/check-v30-gate4-btd-assetpack-mint-read-receipts.mjs --skip-branch-check
8686
node scripts/check-v30-gate5-testnet-ledger-projection-hardening.mjs --skip-branch-check
8787
node scripts/check-v30-gate6-source-to-shares-proof-cleanup.mjs --skip-branch-check
88+
node scripts/check-v30-gate7-bridge-readiness-research-boundaries.mjs --skip-branch-check
8889
else
8990
echo "Unexpected BITCODE_SPEC.txt pointer: $POINTER" >&2
9091
exit 1

BITCODE_SPEC_V30.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,26 @@ Gate 6 source-to-shares precision:
242242
Prepared, signed, broadcast, replaced, reorged, and failed fee receipts do
243243
not unlock protected source.
244244

245+
Gate 7 bridge-readiness research boundaries:
246+
247+
- `BridgeReadinessResearchPosture` is package-owned in `@bitcode/btd` and is
248+
the reusable policy boundary for bridge and distribution research.
249+
- The required research paths are Taproot, BitVM, BSC/opBNB, Binance Web3
250+
Wallet, and future distribution paths. Each path must have a posture record
251+
naming feasibility, risks, current non-admission, rereview triggers, required
252+
proof before admission, and required policy before admission.
253+
- V30 admits no bridge path as current `$BTD` chain-of-record truth.
254+
The posture root must retain `bitcoin_btd_registry` as the active BTD chain
255+
of record and `no_bridge_chain_of_record` as the bridge truth.
256+
- Bridge-readiness records are source-safe research facts. They may not contain
257+
secrets or protected source, and they may not become wrappers, transfers,
258+
settlement rails, ownership claims, or fee rails without a future promoted
259+
version that supplies proof, policy, repair, telemetry, and disclosure
260+
admission.
261+
- Terminal and API surfaces may show bridge-readiness posture as operational
262+
research evidence, but they must fail closed on any payload attempting to
263+
set `chainOfRecordAdmitted` or to mark a bridge as current BTD truth.
264+
245265
## V30 whole Bitcode operator chain
246266

247267
The V30 Terminal operator chain is:

BITCODE_SPEC_V30_DELTA.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,19 @@ Closure acceptance:
254254
- each record names feasibility, risks, current non-admission, rereview triggers, and required proof before admission;
255255
- no bridge path is treated as current `$BTD` chain-of-record truth.
256256

257+
Gate 7 implementation centers `BridgeReadinessResearchPosture` in
258+
`packages/btd/src/bridge-readiness.ts`.
259+
It deliberately models bridge and distribution candidates as research facts,
260+
not as live chain-of-record adapters.
261+
The package builder synthesizes the required Taproot, BitVM, BSC/opBNB,
262+
Binance Web3 Wallet, and future-distribution records, rejects duplicate paths,
263+
rejects secret-looking posture text, and fails closed when a caller attempts
264+
`chainOfRecordAdmitted`.
265+
The BTD API boundary exposes `/btd/bridge-readiness-research` as a source-safe
266+
route for policy/readiness posture only; it returns a Terminal journal
267+
`proof_admission` entry and never writes bridge ownership, settlement, or fee
268+
state.
269+
257270
### Gate 8: Protocol Telemetry And Proof Hooks
258271

259272
Gate 8 adds Protocol/BTD telemetry and proof hooks.

BITCODE_SPEC_V30_NOTES.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,25 @@ slices, or BTC fee allocations.
212212
10. **Gate 10: V30 Promotion Readiness**
213213
- Close local/staging proof, generated artifacts, V30 promotion workflow, and post-promotion V30 active / V31 draft posture.
214214

215+
## Gate 7 bridge-readiness research notes
216+
217+
Gate 7 keeps bridge work honest by making bridge candidates typed research
218+
posture instead of latent implementation claims.
219+
Taproot, BitVM, BSC/opBNB, Binance Web3 Wallet, and future distribution paths
220+
are all represented as records with feasibility, risks, rereview triggers,
221+
required proof, and required policy, but every record remains
222+
`research_only`.
223+
224+
The accepted implementation is package-owned:
225+
`packages/btd/src/bridge-readiness.ts` builds
226+
`BridgeReadinessResearchPosture`; `packages/btd/src/api-boundaries.ts` wraps it
227+
in a Terminal journal `proof_admission` settlement; and
228+
`packages/api/src/routes/btd-crypto.ts` exposes the source-safe
229+
`/btd/bridge-readiness-research` route.
230+
No Gate 7 code may mint, wrap, transfer, settle, or unlock BTD through a bridge.
231+
The only current chain-of-record posture is `bitcoin_btd_registry` plus
232+
`no_bridge_chain_of_record`.
233+
215234
## Gate 1 working notes
216235

217236
Gate 1 is complete only when the V30 family exists, validates in draft mode over active V29, and makes the roadmap truthful enough to drive V31 through V37 without stale V27/V28/V29 posture.

BITCODE_SPEC_V30_PARITY_MATRIX.md

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ No `_legacy/` source is active source truth.
6060
| BTD AssetPack mint/read receipts | Gate 4 | `packages/btd/src/receipts.ts`, `packages/btd/src/api-boundaries.ts`, asset-pack harness evidence, Terminal detail snapshot/read model tests, gate checker | drafted | Mint, read, and rights-transfer receipts bind BTD range, preview, paid unlock, delivery, and ledger projection. |
6161
| Testnet ledger projection hardening | Gate 5 | `packages/btd/src/reconciliation.ts`, API route tests, asset-pack harness evidence, Terminal journal reconciliation UI/tests, gate checker | drafted | Ledger/database/object-storage/private facts are distinct; staging-testnet readback is secret-free; drift, quarantine, retry, and unlock blocking are tested. |
6262
| Source-to-shares proof cleanup | Gate 6 | `packages/btd/src/source-to-shares.ts`, API route boundary, focused BTD/API tests, gate checker | drafted | Measurement contribution, fee allocation, zero-cell/refit tail, ancestry evidence, and conservation invariants are testable. |
63-
| Bridge-readiness research boundaries | Gate 7 | Protocol/BTD research notes, policy posture tests, docs | pending | Bridge paths are documented as research until admitted by explicit future proof and policy. |
63+
| Bridge-readiness research boundaries | Gate 7 | `packages/btd/src/bridge-readiness.ts`, BTD/API tests, route boundary, docs, gate checker | drafted | Bridge paths are typed research-only records until admitted by explicit future proof and policy. |
6464
| Protocol telemetry/proof hooks | Gate 8 | telemetry schema, proof hooks, generated-artifact inventory, tests | pending | Receipts, fee states, projections, and source-to-shares facts emit source-safe telemetry and proof hooks. |
6565
| Interface integration regression | Gate 9 | Terminal/API/MCP/ChatGPT App adapters and tests | pending | Existing interfaces consume package-owned objects without regressing V29 behavior. |
6666
| Promotion readiness | Gate 10 | V30 promotion workflow, generated `.bitcode/v30-*`, `BITCODE_SPEC_V30_PROVEN.md` | pending | `version/v30` can promote to `main` only after all V30 checks pass and promotion automation can commit generated canon. |
@@ -192,6 +192,24 @@ No `_legacy/` source is active source truth.
192192
- Gate 6 does not admit bridge chain-of-record semantics; Gate 7 owns bridge-readiness boundaries.
193193
- Gate 6 does not promote V30 or change the active canon pointer.
194194

195+
## Gate 7 Parity
196+
197+
| Requirement | Source evidence | Current V30 judgment |
198+
| --- | --- | --- |
199+
| Bridge-readiness posture is package-owned | `packages/btd/src/bridge-readiness.ts`, `packages/btd/src/index.ts` | drafted |
200+
| Taproot, BitVM, BSC/opBNB, Binance Web3 Wallet, and future distribution paths are covered | `BRIDGE_READINESS_RESEARCH_PATHS`, `packages/btd/__tests__/bridge-readiness.test.ts` | drafted |
201+
| Every bridge path remains research-only and not current BTD chain-of-record truth | `assertNoBridgeChainOfRecordAdmission`, `bridgeChainOfRecordTruth: no_bridge_chain_of_record` | drafted |
202+
| API and Terminal boundary expose source-safe research posture only | `buildBtdBridgeReadinessResearchSettlement`, `buildPostBtdBridgeReadinessResearchRoute`, `uapi/app/api/btd/bridge-readiness-research/route.ts` | drafted |
203+
| Gate checker protects bridge research boundaries | `scripts/check-v30-gate7-bridge-readiness-research-boundaries.mjs`, `pnpm run check:v30-gate7`, gate-quality workflow | drafted |
204+
205+
## Gate 7 accepted boundaries
206+
207+
- Gate 7 does not implement a bridge chain-of-record path.
208+
- Gate 7 does not mint, wrap, transfer, settle, unlock, or deliver `$BTD` through Taproot, BitVM, BSC/opBNB, Binance Web3 Wallet, or any future distribution path.
209+
- Gate 7 does not store secrets or protected source in bridge-readiness records.
210+
- Gate 7 may expose source-safe research posture to Terminal/API callers for operator review.
211+
- Gate 7 does not promote V30 or change the active canon pointer.
212+
195213
## completion condition
196214

197215
Gate 1 is complete when the V30 draft family validates, `check:v30-gate1` passes, workflow posture is V30-aware, README and roadmap reflect V30 initiation, V31-V37 scopes are current enough to guide future gates, diff hygiene passes, and the gate branch is committed and pushed for review into `version/v30`.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
"check:v30-gate4": "node scripts/check-v30-gate4-btd-assetpack-mint-read-receipts.mjs",
6161
"check:v30-gate5": "node scripts/check-v30-gate5-testnet-ledger-projection-hardening.mjs",
6262
"check:v30-gate6": "node scripts/check-v30-gate6-source-to-shares-proof-cleanup.mjs",
63+
"check:v30-gate7": "node scripts/check-v30-gate7-bridge-readiness-research-boundaries.mjs",
6364
"check:spec-quality": "node scripts/run-bitcode-spec-quality.mjs --mode basic",
6465
"check:spec-quality:title": "node scripts/run-bitcode-spec-quality.mjs --mode strict-from-title",
6566
"check:spec-quality:v24": "node scripts/run-bitcode-spec-quality.mjs --mode strict-version --version V24",

packages/api/src/routes/__tests__/btd-crypto.test.ts

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import {
1919
buildBtdAssetPackLedgerAnchorSettlement,
2020
buildBtdAssetPackExchangeSettlement,
2121
buildBtdBtcFeeTransactionSettlement,
22+
buildBtdBridgeReadinessResearchSettlement,
2223
buildBtdDeploymentReadinessSettlement,
2324
buildBtdLedgerDatabaseReconciliationSettlement,
2425
buildBtdLicensedReadRevenueSettlement,
@@ -36,6 +37,7 @@ import {
3637
buildPostBtdAssetPackLedgerAnchorRoute,
3738
buildPostBtdAssetPackExchangeRoute,
3839
buildPostBtdBtcFeeTransactionRoute,
40+
buildPostBtdBridgeReadinessResearchRoute,
3941
buildPostBtdDeploymentReadinessRoute,
4042
buildPostBtdLedgerDatabaseReconciliationRoute,
4143
buildPostBtdLicensedReadRevenueRoute,
@@ -206,6 +208,15 @@ function sourceToSharesProofBody(overrides: Record<string, unknown> = {}) {
206208
};
207209
}
208210

211+
function bridgeReadinessResearchBody(overrides: Record<string, unknown> = {}) {
212+
return {
213+
postureId: 'bridge-readiness-api-1',
214+
exchangeSequence: '19',
215+
issuedAt,
216+
...overrides,
217+
};
218+
}
219+
209220
describe('BTD crypto API builders', () => {
210221
it('builds a deterministic mint draft from accepted Read-Fit semantic units', () => {
211222
const draft = buildBtdMintDraft(mintDraftInput());
@@ -967,6 +978,30 @@ describe('BTD crypto API builders', () => {
967978
);
968979
});
969980

981+
it('builds bridge-readiness research settlements without chain-of-record admission', () => {
982+
const settlement = buildBtdBridgeReadinessResearchSettlement({
983+
actorId: 'user-1',
984+
...bridgeReadinessResearchBody(),
985+
exchangeSequence: 19n,
986+
} as any);
987+
988+
expect(settlement.kind).toBe('btd_bridge_readiness_research_settlement');
989+
expect(settlement.committed).toBe(false);
990+
expect(settlement.posture.bridgeChainOfRecordTruth).toBe('no_bridge_chain_of_record');
991+
expect(settlement.posture.records.map((record) => record.path)).toEqual([
992+
'bitcoin_taproot_anchor',
993+
'bitvm_execution_bridge',
994+
'bsc_opbnb_distribution',
995+
'binance_web3_wallet_distribution',
996+
'future_distribution_path',
997+
]);
998+
expect(settlement.posture.records.every((record) => record.chainOfRecordAdmitted === false)).toBe(
999+
true,
1000+
);
1001+
expect(settlement.terminalJournalEntry.transactionKind).toBe('proof_admission');
1002+
expect(settlement.terminalJournalEntry.receiptRoots).toContain(settlement.posture.proofRoot);
1003+
});
1004+
9701005
it('builds deployment readiness, telemetry, and upgrade settlements', () => {
9711006
const readiness = buildBtdDeploymentReadinessSettlement({
9721007
actorId: 'user-1',
@@ -1535,6 +1570,28 @@ describe('BTD crypto API builders', () => {
15351570
expect(body.terminalJournalEntry.exchangeSequence).toBe('18');
15361571
});
15371572

1573+
it('returns JSON-safe bridge-readiness research posture from the route boundary', async () => {
1574+
const route = buildPostBtdBridgeReadinessResearchRoute({
1575+
resolveAuthenticatedUser: async () => ({ userId: 'user-1' }),
1576+
});
1577+
const response = await route(
1578+
new Request('https://bitcode.test/api/btd/bridge-readiness-research', {
1579+
method: 'POST',
1580+
body: JSON.stringify(bridgeReadinessResearchBody()),
1581+
}),
1582+
);
1583+
const body = await response.json();
1584+
1585+
expect(response.status).toBe(200);
1586+
expect(body.kind).toBe('btd_bridge_readiness_research_settlement');
1587+
expect(body.committed).toBe(false);
1588+
expect(body.posture.activeBtdChainOfRecord).toBe('bitcoin_btd_registry');
1589+
expect(body.posture.bridgeChainOfRecordTruth).toBe('no_bridge_chain_of_record');
1590+
expect(body.posture.allNonAdmitted).toBe(true);
1591+
expect(body.posture.records).toHaveLength(5);
1592+
expect(body.terminalJournalEntry.exchangeSequence).toBe('19');
1593+
});
1594+
15381595
it('returns JSON-safe deployment readiness settlements and persists telemetry or upgrades', async () => {
15391596
const insertCryptoTelemetryEvent = jest.fn(async (row) => ({
15401597
event: row.event,

packages/api/src/routes/btd-crypto.ts

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ import {
1313
type BtdAssetPackExchangeSettlement,
1414
type BtdAssetPackLedgerAnchorInput,
1515
type BtdAssetPackLedgerAnchorSettlement,
16+
type BtdBridgeReadinessResearchInput,
17+
type BtdBridgeReadinessResearchSettlement,
1618
type BtdBtcFeeTransactionInput,
1719
type BtdBtcFeeTransactionSettlement,
1820
type BtdDeploymentReadinessInput,
@@ -40,6 +42,7 @@ import {
4042
buildBtdAncestryReviewSettlement,
4143
buildBtdAssetPackExchangeSettlement,
4244
buildBtdAssetPackLedgerAnchorSettlement,
45+
buildBtdBridgeReadinessResearchSettlement,
4346
buildBtdBtcFeeTransactionSettlement,
4447
buildBtdDeploymentReadinessSettlement,
4548
buildBtdLedgerDatabaseReconciliationSettlement,
@@ -62,6 +65,7 @@ export {
6265
buildBtdAncestryReviewSettlement,
6366
buildBtdAssetPackExchangeSettlement,
6467
buildBtdAssetPackLedgerAnchorSettlement,
68+
buildBtdBridgeReadinessResearchSettlement,
6569
buildBtdBtcFeeTransactionSettlement,
6670
buildBtdDeploymentReadinessSettlement,
6771
buildBtdLedgerDatabaseReconciliationSettlement,
@@ -601,6 +605,39 @@ export function buildPostBtdSourceToSharesProofRoute(options: BtdRouteOptions =
601605
});
602606
}
603607

608+
export function buildPostBtdBridgeReadinessResearchRoute(options: BtdRouteOptions = {}) {
609+
return traceRoute('/btd/bridge-readiness-research', async (request: Request) => {
610+
const user = await (options.resolveAuthenticatedUser ?? defaultResolveAuthenticatedUser)(
611+
request,
612+
);
613+
if (!user) {
614+
return createJsonResponse({ error: 'Unauthorized' }, 401);
615+
}
616+
617+
let body: Omit<BtdBridgeReadinessResearchInput, 'actorId' | 'exchangeSequence'> & {
618+
exchangeSequence: string | number;
619+
};
620+
try {
621+
body = await request.json();
622+
} catch {
623+
return createJsonResponse({ error: 'Invalid JSON body' }, 400);
624+
}
625+
626+
let settlement: BtdBridgeReadinessResearchSettlement;
627+
try {
628+
settlement = buildBtdBridgeReadinessResearchSettlement({
629+
...body,
630+
actorId: user.userId,
631+
exchangeSequence: parseBtdRequiredBigInt(body.exchangeSequence, 'exchangeSequence'),
632+
});
633+
} catch (error) {
634+
return createJsonResponse({ error: toBadRequestMessage(error) }, 400);
635+
}
636+
637+
return createJsonResponse(toJsonSafe(settlement));
638+
});
639+
}
640+
604641
export function buildPostBtdDeploymentReadinessRoute(options: BtdRouteOptions = {}) {
605642
return traceRoute('/btd/deployment-readiness', async (request: Request) => {
606643
const user = await (options.resolveAuthenticatedUser ?? defaultResolveAuthenticatedUser)(
@@ -661,6 +698,7 @@ export const postBtdTerminalJournal = buildPostBtdTerminalJournalRoute();
661698
export const postBtdLedgerDatabaseReconciliation =
662699
buildPostBtdLedgerDatabaseReconciliationRoute();
663700
export const postBtdSourceToSharesProof = buildPostBtdSourceToSharesProofRoute();
701+
export const postBtdBridgeReadinessResearch = buildPostBtdBridgeReadinessResearchRoute();
664702
export const postBtdDeploymentReadiness = buildPostBtdDeploymentReadinessRoute();
665703

666704
function toBadRequestMessage(error: unknown): string {

packages/btd/README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ This package owns:
1919
largest-remainder share weights, BTD range slices, exact BTC fee allocation,
2020
settlement conservation, zero-cell/refit tail posture, ancestry evidence, and
2121
no-overpayment/no-underpayment theorem verdicts
22+
- bridge-readiness research boundaries for Taproot, BitVM, BSC/opBNB,
23+
Binance Web3 Wallet, and future distribution paths; every bridge posture is
24+
research-only and cannot become current `$BTD` chain-of-record truth without
25+
explicit future proof and policy admission
2226
- ledger/database/object-storage projection reconciliation, including
2327
deterministic repair classes, source-safe object artifact roots,
2428
secret-free Supabase staging-testnet readback receipts, quarantine/retry
@@ -54,6 +58,7 @@ import {
5458
buildBtdRegistrySnapshot,
5559
buildSupabaseStagingTestnetProjectionReadback,
5660
buildSourceToSharesProof,
61+
buildBridgeReadinessResearchPosture,
5762
reconcileLedgerDatabaseProjection,
5863
sourceToSharesProofToSettlementConservationCheck,
5964
toBtdJsonSafe,

0 commit comments

Comments
 (0)