Skip to content

Commit 38ddbbf

Browse files
V29 Gate 8: Formalize protocol package boundary
Move gate-critical canon helpers behind the @bitcode/protocol package index, retarget root canonical scripts away from direct protocol-demonstration source imports, and correct package-local repo-root defaults for spec and proof helpers. Document the Gate 8 package-native boundary in the V29 spec family and protocol README, add a fail-closed Gate 8 checker, expand protocol package tests, and wire CI to run protocol package checks plus the UAPI commercial boundary test. Validation: pnpm --filter @bitcode/protocol typecheck; pnpm --filter @bitcode/protocol test; pnpm run check:v29-gate8; node scripts/check-bitcode-spec-family.mjs --version V28 --mode promoted --current-target V28; node scripts/check-bitcode-spec-family.mjs --version V29 --mode draft --current-target V28; node scripts/check-bitcode-canonical-inputs.mjs --current-target V28; node scripts/check-bitcode-canon-posture-drift.mjs --active-canon V28 --draft-target V29; node scripts/run-bitcode-spec-quality.mjs --mode basic; pnpm --dir uapi exec jest --runTestsByPath tests/protocolCommercialBoundary.test.ts --runInBand; git diff --check.
1 parent 73c62e4 commit 38ddbbf

22 files changed

Lines changed: 432 additions & 24 deletions

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ jobs:
6969
node scripts/check-v29-gate5-assetpack-disclosure-rights.mjs --skip-branch-check
7070
node scripts/check-v29-gate6-settlement-reconciliation-repair.mjs --skip-branch-check
7171
node scripts/check-v29-gate7-organization-permission-authority.mjs --skip-branch-check
72+
node scripts/check-v29-gate8-demonstration-origin-formalization.mjs --skip-branch-check
7273
7374
- name: Validate source casing and imports
7475
run: |
@@ -83,6 +84,7 @@ jobs:
8384
pnpm --dir packages/chatgptapp exec tsc --noEmit --pretty false
8485
pnpm --filter @bitcode/pipeline-asset-pack typecheck
8586
pnpm --filter @bitcode/pipeline-hosts typecheck
87+
pnpm --filter @bitcode/protocol typecheck
8688
8789
- name: Test gate packages
8890
run: |
@@ -97,6 +99,7 @@ jobs:
9799
pnpm --filter @bitcode/pipeline-asset-pack exec jest --config jest.config.cjs --runTestsByPath src/__tests__/reading-pipeline-observability.test.ts src/__tests__/reading-pipeline-contract.test.ts --runInBand
98100
pnpm --filter @bitcode/pipeline-asset-pack exec jest --config jest.config.cjs --runTestsByPath src/__tests__/asset-pack-disclosure.test.ts src/__tests__/postprocess.test.ts src/__tests__/read-need.test.ts --runInBand
99101
pnpm --filter @bitcode/pipeline-hosts exec jest --config jest.config.cjs --passWithNoTests --forceExit
102+
pnpm --filter @bitcode/protocol test
100103
101104
- name: Test staged Reading route and Terminal harness contracts
102105
run: |
@@ -110,6 +113,7 @@ jobs:
110113
tests/terminalWalletBtcOperation.test.ts \
111114
tests/terminalJournalReconciliation.test.ts \
112115
tests/terminalOrganizationAuthority.test.ts \
116+
tests/protocolCommercialBoundary.test.ts \
113117
tests/terminalTransactionDetailCards.test.tsx \
114118
tests/terminalTransactionDetailSnapshot.test.ts \
115119
tests/pipelineExecutionLogHeader.test.tsx \

BITCODE_SPEC_V29.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,27 @@ Layer boundaries:
147147
- Ledger records and journals are source-of-truth for settlement/finality; Supabase/PostgreSQL projections must not contradict them.
148148
- Source-safe previews may expose measurements, roots, score bands, policy ids, fee quote roots, and settlement posture; they may not expose protected source before payment.
149149

150+
## V29 demonstration-origin commercial formalization canon
151+
152+
V29 Gate 8 makes demonstration-origin canonical helpers package-native commercial APIs.
153+
The formal package boundary is `packages/protocol` exposed as `@bitcode/protocol`.
154+
Commercial scripts, workflows, API surfaces, Terminal code, and package tests must import canonical posture, spec-family checks, canon-drift checks, canonical-input checks, and proof generation from `packages/protocol/src/index.js` or from the package export.
155+
They must not import `protocol-demonstration/src/*` runtime modules.
156+
157+
`protocol-demonstration/` remains valuable, but it is a standalone minimal witness, not a commercial runtime dependency.
158+
It may be executed by its own test and proof workflows.
159+
It may be cited as historical evidence by generated proof inventories.
160+
It must not be the imported implementation source for gate checks, promotion scripts, commercial APIs, or Terminal runtime code.
161+
162+
The commercial protocol package owns the active/draft posture while V29 is in flight:
163+
164+
- `ACTIVE_CANON_VERSION = 'V28'`;
165+
- `DRAFT_TARGET_VERSION = 'V29'`;
166+
- spec-family, canonical-input, canon-posture-drift, and proven-generation helpers are exported through the package index;
167+
- package tests and Gate 8 checks fail closed on direct demonstration-source imports.
168+
169+
This formalization preserves the demonstration boundary while allowing V29 promotion and later gates to operate from package-owned commercial source.
170+
150171
## V29 canonical domain model
151172

152173
The V29 domain model extends V28 operationally:

BITCODE_SPEC_V29_DELTA.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,16 @@ Closure acceptance:
169169

170170
Gate 8 owns cleanup of freshly ported demonstration-origin internals into package-native APIs, no demonstration runtime imports, durable package tests, and updated internal/public documentation.
171171

172+
Closure acceptance:
173+
174+
- `@bitcode/protocol` exports active/draft canon posture, spec-family checks, canonical-input checks, canon-posture-drift checks, and canonical proven-generation helpers through the package index and type declarations.
175+
- Root scripts for spec quality, spec-family validation, canonical-input validation, canon-posture drift, pre-commit posture, and proven generation import those helpers from the protocol package instead of `protocol-demonstration/src/*`.
176+
- Commercial/runtime source scans fail closed on direct imports from standalone demonstration source.
177+
- The protocol package records active V28 / draft V29 posture while V29 is being developed.
178+
- Protocol package tests prove exported helpers, posture, provenance-helper availability, repository-revision deposit behavior, and direct demonstration-source import boundaries.
179+
- Gate-quality CI runs the Gate 8 checker, protocol package typecheck/test, and the UAPI commercial protocol boundary test.
180+
- V29 SPEC, DELTA, NOTES, PARITY, protocol package README, package scripts, and gate-quality workflow name the Gate 8 formalization boundary.
181+
172182
### Gate 9: Terminal UX Quality And Browser Proof
173183

174184
Gate 9 owns accessibility, responsive layout, copy/prose clarity, empty/loading/blocked/failed states, Playwright coverage, and visual/browser verification for the complete Terminal transaction cockpit.

BITCODE_SPEC_V29_NOTES.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,27 @@ Gate 7 completion condition:
188188
- Focused BTD, API, MCP, ChatGPT App, pipeline-hosts, and UAPI tests cover the authority primitive and interface surfaces.
189189
- Spec, delta, notes, parity, Terminal README, package scripts, and gate-quality workflow name the Gate 7 closure surface.
190190

191+
## Gate 8 working notes
192+
193+
Gate 8 is a commercial-source boundary cleanup gate.
194+
Earlier versions intentionally kept some proof and canon helpers close to the standalone demonstration so the minimal witness could remain easy to audit.
195+
V29 keeps that witness, but the commercial repository now needs package-native imports for every helper used by scripts, workflows, Terminal, APIs, and promotion checks.
196+
197+
Accepted Gate 8 posture:
198+
199+
- `@bitcode/protocol` is the package boundary for canonical posture, spec-family, canonical-input, canon-posture-drift, and proven-generation helpers.
200+
- `protocol-demonstration/` remains executable as a standalone minimal witness and may remain cited in proof inventories.
201+
- Commercial/runtime code and root scripts must not import from `protocol-demonstration/src/*`.
202+
- The protocol package posture must say active V28 and draft V29 until promotion.
203+
- The protocol package tests own the durable import-boundary scan so future gates cannot silently regress into demonstration runtime imports.
204+
- Gate-quality CI must run protocol package typecheck/test, the Gate 8 checker, and the UAPI commercial protocol boundary test.
205+
206+
Gate 8 completion condition:
207+
208+
- `pnpm run check:v29-gate8` passes.
209+
- Protocol package tests pass.
210+
- The spec family, package README, root scripts, and CI all name and enforce the package-native boundary.
211+
191212
## Later-version boundaries
192213

193214
- V30 remains reserved for Protocol/BTD hardening that is not necessary to close Terminal transaction depth.

BITCODE_SPEC_V29_PARITY_MATRIX.md

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ No `_legacy/` source is active source truth.
5555
| AssetPack disclosure rights | Gate 5 | `asset-pack-disclosure.ts`, AssetPack postprocess, sandbox harness, BTD access tests, Terminal disclosure review UI, Gate 5 checker | drafted | Source-safe preview and paid unlock are proven without protected-source leakage. |
5656
| Settlement reconciliation repair | Gate 6 | BTD journal/reconciliation, Supabase readback, sandbox harness settlement evidence, Terminal repair UI, Gate 6 checker | drafted | Ledger, database, and metaphysical state drift is classified, proof-rooted, repair-actioned, and visible. |
5757
| Organization permission authority | Gate 7 | `packages/btd/src/authority.ts`, BTD/API/MCP/ChatGPT App tests, sandbox harness authority evidence, Terminal Authority section, Gate 7 checker | drafted | Registry-derived roles, holdings, read-license authority, settlement, confirmation, and interface admission govern actions. |
58-
| Commercial formalization | Gate 8 | packages/protocol, package tests, import scans, docs | pending | Demonstration-origin commercial internals are package-native and no runtime demo imports remain. |
58+
| Commercial formalization | Gate 8 | `packages/protocol/src/index.js`, `packages/protocol/src/canon-posture.js`, root scripts, protocol package tests, import scans, docs, Gate 8 checker | drafted | Demonstration-origin commercial internals are package-native and no direct demonstration-source imports remain in commercial/runtime sources. |
5959
| Terminal UX quality | Gate 9 | Playwright/Jest/a11y/responsive/browser QA | pending | Complete transaction cockpit is usable by default and inspectable in detail. |
6060
| Promotion readiness | Gate 10 | promotion workflow, `.bitcode/v29-*`, `BITCODE_SPEC_V29_PROVEN.md` | pending | `version/v29` can promote to `main` only after all V29 checks pass. |
6161

@@ -72,7 +72,8 @@ No `_legacy/` source is active source truth.
7272
| Gate 4 Reading observability | `pnpm run check:v29-gate4` proves contract-aware Reading stream telemetry and Terminal rendering | drafted |
7373
| Gate 5 AssetPack disclosure | `pnpm run check:v29-gate5` proves source-safe disclosure review, leakage detection, Terminal preview rendering, and PR title enforcement | drafted |
7474
| Gate 7 organization authority | `pnpm run check:v29-gate7` proves shared org/interface authority across BTD, API, MCP, ChatGPT App, harness, and Terminal | drafted |
75-
| Product implementation gates | Gates 8-9 close remaining Terminal transaction depth with tests and docs | pending |
75+
| Gate 8 commercial formalization | `pnpm run check:v29-gate8` proves package-native protocol exports, V28/V29 posture, script import cleanup, docs, tests, and CI wiring | drafted |
76+
| Product implementation gates | Gate 9 closes remaining Terminal transaction UX quality with browser proof | pending |
7677
| Promotion gate | Gate 10 closes generated proof and promotion automation | pending |
7778

7879
## Gate 1 Parity
@@ -242,3 +243,32 @@ Gate 7 completion condition:
242243
- Gate-quality CI invokes the Gate 7 checker and focused tests.
243244
- Gate 7 does not add broad enterprise RBAC administration beyond Terminal transaction authority; later versions may deepen team policy authoring.
244245
- Gate 7 does not reveal protected source before settlement and does not add versioned API routes or source identifiers.
246+
247+
## Gate 8 Parity
248+
249+
Gate 8 closes the demonstration-origin commercial formalization slice by moving gate-critical helpers behind the protocol package boundary.
250+
251+
Accepted surfaces:
252+
253+
- `packages/protocol/src/index.js` exports canonical posture, spec-family validation, canonical-input validation, canon-posture-drift validation, generated artifact builders, and canonical proven-generation helpers.
254+
- `packages/protocol/src/index.d.ts` declares the same package-native API surface for consumers that type-check against the protocol package.
255+
- `packages/protocol/src/canon-posture.js` declares active V28 and draft V29 while V29 gates are in progress.
256+
- Root scripts for spec-family checks, canonical-input checks, canon-posture drift, spec quality, pre-commit posture, and proven generation import through the protocol package source boundary.
257+
- `packages/protocol/test/protocol-package-boundary.test.js` proves package exports, posture, provenance-helper availability, repository-revision deposit behavior, and direct demonstration-source import boundaries.
258+
- `uapi/tests/protocolCommercialBoundary.test.ts` remains the commercial application boundary scan proving UAPI depends on `@bitcode/protocol` and not the standalone demonstration package.
259+
- `.github/workflows/bitcode-gate-quality.yml` runs the Gate 8 checker, protocol package typecheck/test, and the commercial protocol boundary test.
260+
261+
Accepted boundaries:
262+
263+
- Gate 8 does not delete the standalone protocol demonstration.
264+
- Gate 8 does not forbid generated proof inventories or historical documentation from citing `protocol-demonstration/` as evidence.
265+
- Gate 8 forbids direct imports from standalone demonstration source in commercial/runtime source and root scripts.
266+
- Gate 8 does not promote `BITCODE_SPEC.txt` to V29.
267+
- Gate 8 does not add versioned API routes or source identifiers.
268+
269+
Gate 8 completion condition:
270+
271+
- `pnpm run check:v29-gate8` passes.
272+
- Focused protocol package typecheck/test and the UAPI commercial protocol boundary test pass.
273+
- V29 SPEC, DELTA, NOTES, PARITY, protocol package README, package scripts, and gate-quality workflow name the formalized package-native boundary.
274+
- Root scripts use protocol package exports for canonical helpers and do not directly import `protocol-demonstration/src/*`.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
"check:v29-gate5": "node scripts/check-v29-gate5-assetpack-disclosure-rights.mjs",
5252
"check:v29-gate6": "node scripts/check-v29-gate6-settlement-reconciliation-repair.mjs",
5353
"check:v29-gate7": "node scripts/check-v29-gate7-organization-permission-authority.mjs",
54+
"check:v29-gate8": "node scripts/check-v29-gate8-demonstration-origin-formalization.mjs",
5455
"check:spec-quality": "node scripts/run-bitcode-spec-quality.mjs --mode basic",
5556
"check:spec-quality:title": "node scripts/run-bitcode-spec-quality.mjs --mode strict-from-title",
5657
"check:spec-quality:v24": "node scripts/run-bitcode-spec-quality.mjs --mode strict-version --version V24",

packages/protocol/README.md

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,24 @@
22

33
Formal Bitcode protocol package for commercial source.
44

5-
V28 starts the separation between the deterministic `protocol-demonstration`
6-
reference and commercial runtime imports. Commercial surfaces should import
7-
protocol state, API context, and protocol primitives from this package rather
8-
than importing the standalone demonstration package.
9-
10-
Some implementation internals are still freshly ported from the demonstration
11-
and intentionally retain source proximity for parity. V29 must continue
12-
commercializing those internals into narrower packages and cleaner module
13-
boundaries.
5+
V29 Gate 8 makes this package the package-native boundary for canonical helpers
6+
that were originally ported from the standalone `protocol-demonstration`
7+
witness. Commercial scripts, API/runtime code, and workflow checks must import
8+
canon posture, spec-family checks, canonical-input checks, canon-drift checks,
9+
and proven-generation helpers from `@bitcode/protocol` or
10+
`packages/protocol/src/index.js`.
11+
12+
They must not import `protocol-demonstration/src/*`. The demonstration remains
13+
a standalone minimal witness and may still be executed or cited by proof
14+
inventories, but it is not a commercial runtime implementation dependency.
15+
16+
Current exported commercial helpers include:
17+
18+
- active/draft canon posture (`V28` active, `V29` draft during V29 work);
19+
- spec-family and canonical-input validation helpers;
20+
- canon-posture drift reporting;
21+
- canonical proven-generation helpers;
22+
- the package app/server context used by commercial interfaces.
23+
24+
The package boundary is enforced by `packages/protocol` tests, the UAPI
25+
commercial protocol boundary test, and `check:v29-gate8`.

packages/protocol/src/canon-posture.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// @ts-check
22

3-
export const ACTIVE_CANON_VERSION = 'V27';
4-
export const DRAFT_TARGET_VERSION = 'V28';
3+
export const ACTIVE_CANON_VERSION = 'V28';
4+
export const DRAFT_TARGET_VERSION = 'V29';
55
export const CURRENT_CANON_OPERATOR_LABEL = `${ACTIVE_CANON_VERSION} active canon / ${DRAFT_TARGET_VERSION} system draft`;
66

77
/**

packages/protocol/src/canonical/proven-generator.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ const COLLECTED_PROVEN_RUN_CACHE = new Map();
4949
const BASE_PROVEN_DATA_CACHE = new Map();
5050
const __filename = fileURLToPath(import.meta.url);
5151
const __dirname = path.dirname(__filename);
52-
const REPO_ROOT = path.resolve(__dirname, '../../..');
52+
const REPO_ROOT = path.resolve(__dirname, '../../../..');
5353

5454
/**
5555
* @param {string} version

packages/protocol/src/canonical/v21-specifying.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { fileURLToPath } from 'node:url';
66

77
const __filename = fileURLToPath(import.meta.url);
88
const __dirname = path.dirname(__filename);
9-
export const DEFAULT_V21_SPECIFYING_REPO_ROOT = path.resolve(__dirname, '../../..');
9+
export const DEFAULT_V21_SPECIFYING_REPO_ROOT = path.resolve(__dirname, '../../../..');
1010

1111
export const COMMON_REQUIRED_SPEC_SECTIONS = [
1212
'Status',

0 commit comments

Comments
 (0)