Skip to content

Commit f9fff9c

Browse files
V30 Gate 9: Prove interface integration regression
Add package-owned BTD interface integration contracts and regression proof builders, including source-safe coverage for Terminal, API, MCP, ChatGPT App, Auxillaries hooks, and Exchange hooks. Expose the JSON-safe API admission route, wire Terminal/MCP/ChatGPT adapter records, and update V30 spec, parity, notes, README, gate workflow, and checker coverage. Proof: BTD/API/MCP/ChatGPT/Terminal focused tests, touched typechecks, V30 Gate 1-9 checkers, spec-family/canonical-input/posture checks, and diff hygiene passed locally.
1 parent 3d371cb commit f9fff9c

35 files changed

Lines changed: 1349 additions & 2 deletions

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ jobs:
8787
node scripts/check-v30-gate6-source-to-shares-proof-cleanup.mjs --skip-branch-check
8888
node scripts/check-v30-gate7-bridge-readiness-research-boundaries.mjs --skip-branch-check
8989
node scripts/check-v30-gate8-protocol-telemetry-proof-hooks.mjs --skip-branch-check
90+
node scripts/check-v30-gate9-interface-integration-regression-proof.mjs --skip-branch-check
9091
else
9192
echo "Unexpected BITCODE_SPEC.txt pointer: $POINTER" >&2
9293
exit 1
@@ -131,6 +132,8 @@ jobs:
131132
tests/terminalDepositReadWorkbench.test.ts \
132133
tests/terminalTransactionQuery.test.ts \
133134
tests/terminalTransactionReadModel.test.ts \
135+
tests/terminalProtocolProjection.test.ts \
136+
tests/terminalInterfaceIntegrationRegression.test.ts \
134137
tests/terminalWalletBtcOperation.test.ts \
135138
tests/terminalJournalReconciliation.test.ts \
136139
tests/terminalOrganizationAuthority.test.ts \

BITCODE_SPEC_V30.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,28 @@ The focused Playwright spec proves the cockpit in a real browser in deterministi
349349
Gate 9 acceptance does not change Reading law, source disclosure law, settlement law, or organization authority law.
350350
It makes the current V30 Terminal cockpit commercially operable enough that later local/staging promotion readiness can debug failures from the UI rather than from browser network logs alone.
351351

352+
### Gate 9 interface integration regression proof
353+
354+
Gate 9 adds a package-owned proof that current interface surfaces consume the
355+
Protocol/BTD rails instead of duplicating them:
356+
357+
- `BtdInterfaceIntegrationRegressionProof` covers Terminal, API, MCP,
358+
ChatGPT App, Auxillaries hook, and Exchange hook surfaces.
359+
- `BtdInterfaceIntegrationRecordInput` and
360+
`@bitcode/btd/interface-integration-contract` give browser-facing
361+
interfaces a client-safe contract for surface and object-family coverage.
362+
- `/btd/interface-integration-regression` wraps the package proof in a
363+
source-safe Terminal journal `proof_admission` boundary.
364+
- The proof covers BTD registry, read access, BTD receipts, BTC fee operation,
365+
ledger projection, source-to-shares proof, Protocol telemetry,
366+
organization authority, and Terminal journal object families.
367+
- Every record must set `packageOwned: true`,
368+
`routeLocalReimplementation: false`, `sourceSafeLowDetailIntact: true`, and
369+
`transactionCockpitRegression: false`.
370+
- The proof fails closed on missing surfaces, missing object families,
371+
protected source, secrets, route-local policy copies, or low-detail cockpit
372+
regression.
373+
352374
## V30 local and staging promotion readiness canon
353375

354376
V30 promotion is admissible only when the version branch can prove both source

BITCODE_SPEC_V30_DELTA.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,20 @@ Closure acceptance:
305305
- low-detail source-safe UX remains intact;
306306
- focused regression tests prove no V29 transaction cockpit behavior regresses.
307307

308+
Gate 9 implementation centers on:
309+
310+
- `packages/btd/src/interface-integration-contract.ts` for client-safe
311+
surface and object-family contracts;
312+
- `packages/btd/src/interface-integration.ts` for
313+
`BtdInterfaceIntegrationRegressionProof` and source-safe fail-closed
314+
record validation;
315+
- `buildBtdInterfaceIntegrationRegressionSettlement` and
316+
`/btd/interface-integration-regression` for JSON-safe API admission;
317+
- Terminal, MCP, and ChatGPT App adapter records proving package-owned
318+
consumption without route-local BTD policy copies;
319+
- focused BTD, API, MCP, ChatGPT App, and Terminal tests for source-safe
320+
low-detail regression closure.
321+
308322
### Gate 10: V30 Promotion Readiness
309323

310324
Gate 10 owns final local/staging proof, generated artifacts, and V30 promotion workflow support.

BITCODE_SPEC_V30_NOTES.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,22 @@ boundary exposes `/btd/protocol-telemetry` as a JSON-safe proof-admission route;
251251
it does not commit source-bearing artifacts, and it does not replace existing
252252
crypto telemetry rows used for deployment readiness health.
253253

254+
## Gate 9 interface integration notes
255+
256+
Gate 9 makes interface reuse explicit. The accepted package shape is
257+
`BtdInterfaceIntegrationRegressionProof` plus the browser-safe
258+
`@bitcode/btd/interface-integration-contract` subpath. Terminal uses the
259+
contract without importing storage-backed BTD entry points into the client.
260+
API uses `buildBtdInterfaceIntegrationRegressionSettlement` and exposes
261+
`/btd/interface-integration-regression` as a JSON-safe proof-admission route.
262+
MCP and ChatGPT App expose small adapter records that name their package-owned
263+
BTD object consumption.
264+
265+
The proof is not a new user journey. It is regression evidence that the V30
266+
rails can be consumed by current interfaces without losing low-detail source
267+
safety, reintroducing route-local BTD policy copies, or changing the selected
268+
Terminal transaction behavior promoted in V29.
269+
254270
## Gate 1 working notes
255271

256272
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: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ No `_legacy/` source is active source truth.
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. |
6363
| 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 | `packages/btd/src/telemetry.ts`, API route boundary, focused BTD/API tests, gate checker | drafted | Receipts, fee states, projections, source-to-shares proofs, and bridge-readiness posture emit source-safe telemetry and proof hooks. |
65-
| Interface integration regression | Gate 9 | Terminal/API/MCP/ChatGPT App adapters and tests | pending | Existing interfaces consume package-owned objects without regressing V29 behavior. |
65+
| Interface integration regression | Gate 9 | `packages/btd/src/interface-integration.ts`, `packages/api/src/routes/btd-crypto.ts`, Terminal/MCP/ChatGPT adapters and tests, gate checker | drafted | 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. |
6767

6868
## V30 implementation checklist
@@ -229,6 +229,25 @@ No `_legacy/` source is active source truth.
229229
- Gate 8 may expose telemetry/proof hooks to Terminal/API callers for operator review.
230230
- Gate 8 does not promote V30 or change the active canon pointer.
231231

232+
## Gate 9 Parity
233+
234+
| Requirement | Source evidence | Current V30 judgment |
235+
| --- | --- | --- |
236+
| Interface integration proof is package-owned | `packages/btd/src/interface-integration.ts`, `packages/btd/src/interface-integration-contract.ts`, `packages/btd/src/index.ts` | drafted |
237+
| Terminal can consume client-safe package contracts | `uapi/app/terminal/terminal-interface-integration-regression.ts`, `uapi/app/terminal/terminal-protocol-projection.ts` | drafted |
238+
| API exposes JSON-safe proof admission | `buildBtdInterfaceIntegrationRegressionSettlement`, `buildPostBtdInterfaceIntegrationRegressionRoute`, `uapi/app/api/btd/interface-integration-regression/route.ts` | drafted |
239+
| MCP and ChatGPT App declare package-owned object records | `packages/executions-mcp/src/mcp-server/src/interface-integration.ts`, `packages/chatgptapp/src/interface-integration.ts` | drafted |
240+
| Source-safe low-detail and transaction cockpit regression are tested | BTD interface-integration tests, BTD crypto route tests, Terminal projection tests, MCP auth test, ChatGPT tools test | drafted |
241+
| Gate checker protects interface integration boundaries | `scripts/check-v30-gate9-interface-integration-regression-proof.mjs`, `pnpm run check:v30-gate9`, gate-quality workflow | drafted |
242+
243+
## Gate 9 accepted boundaries
244+
245+
- Gate 9 does not redesign Reading, settlement, source disclosure, organization authority, MCP, ChatGPT App, Auxillaries, or Exchange.
246+
- Gate 9 does not expose protected AssetPack source, prompts, raw source, private keys, service keys, model keys, JWT-looking secrets, or database passwords.
247+
- Gate 9 admits only source-safe interface integration records and a proof-admission route; it does not commit ledger state or deliver AssetPacks.
248+
- Gate 9 proves current interfaces consume package-owned BTD object families without route-local policy copies.
249+
- Gate 9 does not promote V30 or change the active canon pointer.
250+
232251
## completion condition
233252

234253
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
@@ -62,6 +62,7 @@
6262
"check:v30-gate6": "node scripts/check-v30-gate6-source-to-shares-proof-cleanup.mjs",
6363
"check:v30-gate7": "node scripts/check-v30-gate7-bridge-readiness-research-boundaries.mjs",
6464
"check:v30-gate8": "node scripts/check-v30-gate8-protocol-telemetry-proof-hooks.mjs",
65+
"check:v30-gate9": "node scripts/check-v30-gate9-interface-integration-regression-proof.mjs",
6566
"check:spec-quality": "node scripts/run-bitcode-spec-quality.mjs --mode basic",
6667
"check:spec-quality:title": "node scripts/run-bitcode-spec-quality.mjs --mode strict-from-title",
6768
"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: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import {
2121
buildBtdBtcFeeTransactionSettlement,
2222
buildBtdBridgeReadinessResearchSettlement,
2323
buildBtdDeploymentReadinessSettlement,
24+
buildBtdInterfaceIntegrationRegressionSettlement,
2425
buildBtdLedgerDatabaseReconciliationSettlement,
2526
buildBtdLicensedReadRevenueSettlement,
2627
buildBtdMintDraft,
@@ -41,6 +42,7 @@ import {
4142
buildPostBtdBtcFeeTransactionRoute,
4243
buildPostBtdBridgeReadinessResearchRoute,
4344
buildPostBtdDeploymentReadinessRoute,
45+
buildPostBtdInterfaceIntegrationRegressionRoute,
4446
buildPostBtdLedgerDatabaseReconciliationRoute,
4547
buildPostBtdLicensedReadRevenueRoute,
4648
buildPostBtdMintDraftRoute,
@@ -49,6 +51,7 @@ import {
4951
buildPostBtdReadAccessRoute,
5052
buildPostBtdSourceToSharesProofRoute,
5153
buildPostBtdTerminalJournalRoute,
54+
postBtdInterfaceIntegrationRegression,
5255
} from '../btd-crypto';
5356

5457
const issuedAt = '2026-05-06T00:00:00.000Z';
@@ -259,6 +262,86 @@ function protocolTelemetryBody(overrides: Record<string, unknown> = {}) {
259262
};
260263
}
261264

265+
function interfaceIntegrationRegressionBody(overrides: Record<string, unknown> = {}) {
266+
const recordBase = {
267+
packageOwned: true,
268+
routeLocalReimplementation: false,
269+
sourceSafeLowDetailIntact: true,
270+
transactionCockpitRegression: false,
271+
notes: ['package-owned object consumed source-safely'],
272+
issuedAt,
273+
};
274+
275+
return {
276+
records: [
277+
{
278+
...recordBase,
279+
surface: 'terminal',
280+
consumerId: 'terminal-transaction-cockpit',
281+
packageExport: '@bitcode/btd/interface-integration-contract',
282+
adapterPath: 'uapi/app/terminal/terminal-interface-integration-regression.ts',
283+
objectFamilies: ['btd_registry', 'read_access', 'terminal_journal'],
284+
proofRoot: 'terminal-interface-proof-root',
285+
},
286+
{
287+
...recordBase,
288+
surface: 'api',
289+
consumerId: 'btd-api-route-boundary',
290+
packageExport: '@bitcode/btd',
291+
adapterPath: 'packages/api/src/routes/btd-crypto.ts',
292+
objectFamilies: [
293+
'btd_receipts',
294+
'btc_fee_operation',
295+
'ledger_projection',
296+
'protocol_telemetry',
297+
],
298+
proofRoot: 'api-interface-proof-root',
299+
},
300+
{
301+
...recordBase,
302+
surface: 'mcp',
303+
consumerId: 'bitcode-mcp-interface',
304+
packageExport: '@bitcode/btd/interface-integration-contract',
305+
adapterPath: 'packages/executions-mcp/src/mcp-server/src/interface-integration.ts',
306+
objectFamilies: ['source_to_shares_proof', 'organization_authority'],
307+
proofRoot: 'mcp-interface-proof-root',
308+
},
309+
{
310+
...recordBase,
311+
surface: 'chatgpt_app',
312+
consumerId: 'bitcode-chatgpt-app-interface',
313+
packageExport: '@bitcode/btd/interface-integration-contract',
314+
adapterPath: 'packages/chatgptapp/src/interface-integration.ts',
315+
objectFamilies: ['read_access', 'organization_authority'],
316+
proofRoot: 'chatgpt-app-interface-proof-root',
317+
},
318+
{
319+
...recordBase,
320+
surface: 'auxillaries_hook',
321+
consumerId: 'auxillaries-interface-hook',
322+
packageExport: '@bitcode/btd/interface-integration-contract',
323+
adapterPath: 'uapi/app/terminal/terminal-interface-integration-regression.ts',
324+
objectFamilies: ['btd_registry', 'organization_authority'],
325+
proofRoot: 'auxillaries-interface-proof-root',
326+
},
327+
{
328+
...recordBase,
329+
surface: 'exchange_hook',
330+
consumerId: 'exchange-interface-hook',
331+
packageExport: '@bitcode/btd/interface-integration-contract',
332+
adapterPath: 'uapi/app/terminal/terminal-interface-integration-regression.ts',
333+
objectFamilies: ['btd_receipts', 'btc_fee_operation', 'ledger_projection'],
334+
proofRoot: 'exchange-interface-proof-root',
335+
},
336+
],
337+
lowDetailProofRoot: 'terminal-low-detail-source-safe-proof-root',
338+
transactionCockpitProofRoot: 'terminal-transaction-cockpit-regression-proof-root',
339+
exchangeSequence: '21',
340+
issuedAt,
341+
...overrides,
342+
};
343+
}
344+
262345
describe('BTD crypto API builders', () => {
263346
it('builds a deterministic mint draft from accepted Read-Fit semantic units', () => {
264347
const draft = buildBtdMintDraft(mintDraftInput());
@@ -1682,6 +1765,59 @@ describe('BTD crypto API builders', () => {
16821765
expect(body.terminalJournalEntry.exchangeSequence).toBe('20');
16831766
});
16841767

1768+
it('returns JSON-safe interface integration regression proof from the route boundary', async () => {
1769+
const direct = buildBtdInterfaceIntegrationRegressionSettlement({
1770+
...(interfaceIntegrationRegressionBody() as any),
1771+
exchangeSequence: 21n,
1772+
actorId: 'user-1',
1773+
});
1774+
const route = buildPostBtdInterfaceIntegrationRegressionRoute({
1775+
resolveAuthenticatedUser: async () => ({ userId: 'user-1' }),
1776+
});
1777+
const response = await route(
1778+
new Request('https://bitcode.test/api/btd/interface-integration-regression', {
1779+
method: 'POST',
1780+
body: JSON.stringify(interfaceIntegrationRegressionBody()),
1781+
}),
1782+
);
1783+
const body = await response.json();
1784+
1785+
expect(direct.kind).toBe('btd_interface_integration_regression_settlement');
1786+
expect(postBtdInterfaceIntegrationRegression).toBeDefined();
1787+
expect(response.status).toBe(200);
1788+
expect(body.kind).toBe('btd_interface_integration_regression_settlement');
1789+
expect(body.committed).toBe(false);
1790+
expect(body.proof.coverage.surfaces.missing).toEqual([]);
1791+
expect(body.proof.coverage.objectFamilies.missing).toEqual([]);
1792+
expect(body.proof.packageOwned).toBe(true);
1793+
expect(body.proof.routeLocalReimplementation).toBe(false);
1794+
expect(body.proof.sourceSafeLowDetailIntact).toBe(true);
1795+
expect(body.proof.transactionCockpitRegression).toBe(false);
1796+
expect(body.terminalJournalEntry.exchangeSequence).toBe('21');
1797+
});
1798+
1799+
it('fails interface integration regression when source-safe low detail is not proven', async () => {
1800+
const route = buildPostBtdInterfaceIntegrationRegressionRoute({
1801+
resolveAuthenticatedUser: async () => ({ userId: 'user-1' }),
1802+
});
1803+
const body = interfaceIntegrationRegressionBody({
1804+
records: (interfaceIntegrationRegressionBody().records as any[]).map((record, index) => ({
1805+
...record,
1806+
sourceSafeLowDetailIntact: index === 0 ? false : record.sourceSafeLowDetailIntact,
1807+
})),
1808+
});
1809+
const response = await route(
1810+
new Request('https://bitcode.test/api/btd/interface-integration-regression', {
1811+
method: 'POST',
1812+
body: JSON.stringify(body),
1813+
}),
1814+
);
1815+
const payload = await response.json();
1816+
1817+
expect(response.status).toBe(400);
1818+
expect(payload.error).toContain('source-safe low-detail UX');
1819+
});
1820+
16851821
it('returns JSON-safe deployment readiness settlements and persists telemetry or upgrades', async () => {
16861822
const insertCryptoTelemetryEvent = jest.fn(async (row) => ({
16871823
event: row.event,

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

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ import {
1919
type BtdBtcFeeTransactionSettlement,
2020
type BtdDeploymentReadinessInput,
2121
type BtdDeploymentReadinessSettlement,
22+
type BtdInterfaceIntegrationRegressionInput,
23+
type BtdInterfaceIntegrationRegressionSettlement,
2224
type BtdLedgerDatabaseReconciliationInput,
2325
type BtdLedgerDatabaseReconciliationSettlement,
2426
type BtdLicensedReadRevenueInput,
@@ -47,6 +49,7 @@ import {
4749
buildBtdBridgeReadinessResearchSettlement,
4850
buildBtdBtcFeeTransactionSettlement,
4951
buildBtdDeploymentReadinessSettlement,
52+
buildBtdInterfaceIntegrationRegressionSettlement,
5053
buildBtdLedgerDatabaseReconciliationSettlement,
5154
buildBtdLicensedReadRevenueSettlement,
5255
buildBtdMintDraft,
@@ -71,6 +74,7 @@ export {
7174
buildBtdBridgeReadinessResearchSettlement,
7275
buildBtdBtcFeeTransactionSettlement,
7376
buildBtdDeploymentReadinessSettlement,
77+
buildBtdInterfaceIntegrationRegressionSettlement,
7478
buildBtdLedgerDatabaseReconciliationSettlement,
7579
buildBtdLicensedReadRevenueSettlement,
7680
buildBtdMintDraft,
@@ -675,6 +679,39 @@ export function buildPostBtdProtocolTelemetryRoute(options: BtdRouteOptions = {}
675679
});
676680
}
677681

682+
export function buildPostBtdInterfaceIntegrationRegressionRoute(options: BtdRouteOptions = {}) {
683+
return traceRoute('/btd/interface-integration-regression', async (request: Request) => {
684+
const user = await (options.resolveAuthenticatedUser ?? defaultResolveAuthenticatedUser)(
685+
request,
686+
);
687+
if (!user) {
688+
return createJsonResponse({ error: 'Unauthorized' }, 401);
689+
}
690+
691+
let body: Omit<BtdInterfaceIntegrationRegressionInput, 'actorId' | 'exchangeSequence'> & {
692+
exchangeSequence: string | number;
693+
};
694+
try {
695+
body = await request.json();
696+
} catch {
697+
return createJsonResponse({ error: 'Invalid JSON body' }, 400);
698+
}
699+
700+
let settlement: BtdInterfaceIntegrationRegressionSettlement;
701+
try {
702+
settlement = buildBtdInterfaceIntegrationRegressionSettlement({
703+
...body,
704+
actorId: user.userId,
705+
exchangeSequence: parseBtdRequiredBigInt(body.exchangeSequence, 'exchangeSequence'),
706+
});
707+
} catch (error) {
708+
return createJsonResponse({ error: toBadRequestMessage(error) }, 400);
709+
}
710+
711+
return createJsonResponse(toJsonSafe(settlement));
712+
});
713+
}
714+
678715
export function buildPostBtdDeploymentReadinessRoute(options: BtdRouteOptions = {}) {
679716
return traceRoute('/btd/deployment-readiness', async (request: Request) => {
680717
const user = await (options.resolveAuthenticatedUser ?? defaultResolveAuthenticatedUser)(
@@ -737,6 +774,8 @@ export const postBtdLedgerDatabaseReconciliation =
737774
export const postBtdSourceToSharesProof = buildPostBtdSourceToSharesProofRoute();
738775
export const postBtdBridgeReadinessResearch = buildPostBtdBridgeReadinessResearchRoute();
739776
export const postBtdProtocolTelemetry = buildPostBtdProtocolTelemetryRoute();
777+
export const postBtdInterfaceIntegrationRegression =
778+
buildPostBtdInterfaceIntegrationRegressionRoute();
740779
export const postBtdDeploymentReadiness = buildPostBtdDeploymentReadinessRoute();
741780

742781
function toBadRequestMessage(error: unknown): string {

0 commit comments

Comments
 (0)