Skip to content

Commit baec2c2

Browse files
wip v27
1 parent 355feaa commit baec2c2

38 files changed

Lines changed: 5249 additions & 153 deletions
Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
{
2+
"proofId": "v27-crypto-primitives-proof",
3+
"version": "V27",
4+
"generatedAt": "2026-05-06T00:00:00.000Z",
5+
"activeCanonicalPointer": "V26",
6+
"state": "draft-target-proof-slice",
7+
"scope": [
8+
"fixed-supply measureminting primitives",
9+
"proof-addressable semantic volume",
10+
"contiguous AssetPack range and mint receipts",
11+
"owner-read and licensed-read access evaluation",
12+
"whole-cell contributor allocation",
13+
"late-bound non-supply ancestry review",
14+
"local licensed-read BTC revenue routing",
15+
"wallet signer-session and BTC fee receipt lifecycle",
16+
"network-checked Bitcoin fee provider boundary",
17+
"AssetPack ledger anchor receipts",
18+
"minimal Exchange orders and rights-transfer receipts",
19+
"Terminal journal diffing",
20+
"ledger/database reconciliation repairs",
21+
"V27 crypto telemetry taxonomy",
22+
"deployment-lane guards",
23+
"protocol upgrade receipts",
24+
"protocol-demonstration V27 crypto receipt witness",
25+
"V27 registry/projection migration and ORM boundary"
26+
],
27+
"sourceSurfaces": [
28+
"BITCODE_SPEC_V27.md",
29+
"BITCODE_SPEC_V27_DELTA.md",
30+
"BITCODE_SPEC_V27_NOTES.md",
31+
"BITCODE_SPEC_V27_PARITY_MATRIX.md",
32+
"packages/btd/src/constants.ts",
33+
"packages/btd/src/supply.ts",
34+
"packages/btd/src/measuremint.ts",
35+
"packages/btd/src/semantic-volume.ts",
36+
"packages/btd/src/range.ts",
37+
"packages/btd/src/receipts.ts",
38+
"packages/btd/src/replay.ts",
39+
"packages/btd/src/access.ts",
40+
"packages/btd/src/allocation.ts",
41+
"packages/btd/src/ancestry.ts",
42+
"packages/btd/src/revenue.ts",
43+
"packages/btd/src/wallet.ts",
44+
"packages/btd/src/bitcoin-fees.ts",
45+
"packages/btd/src/bitcoin-provider.ts",
46+
"packages/btd/src/deployment-lanes.ts",
47+
"packages/btd/src/ledger-anchor.ts",
48+
"packages/btd/src/exchange.ts",
49+
"packages/btd/src/terminal-journal.ts",
50+
"packages/btd/src/reconciliation.ts",
51+
"packages/btd/src/telemetry.ts",
52+
"packages/btd/src/upgrade.ts",
53+
"packages/btd/__tests__/v27-crypto-primitives.test.ts",
54+
"protocol-demonstration/src/receipt-schemas.js",
55+
"protocol-demonstration/src/v27-crypto-primitives.js",
56+
"protocol-demonstration/test/v27-crypto-primitives.test.js",
57+
"supabase/migrations/002_v27_btd_crypto_registry.sql",
58+
"packages/orm/src/models/btd-registry.ts",
59+
"internal-docs/BITCODE_EXCHANGE_DATABASE.md"
60+
],
61+
"validation": [
62+
{
63+
"command": "./uapi/node_modules/.bin/jest --config '{...packages/btd focused ts-jest config...}' --runInBand",
64+
"status": "passed",
65+
"assertions": 27,
66+
"notes": "Jest still reports pre-existing duplicate manual mock warnings outside the V27 package slice."
67+
},
68+
{
69+
"command": "pnpm -C protocol-demonstration test:v27-crypto",
70+
"status": "passed",
71+
"assertions": 7
72+
},
73+
{
74+
"command": "pnpm -C packages/orm build",
75+
"status": "passed"
76+
},
77+
{
78+
"command": "git diff --check",
79+
"status": "passed"
80+
},
81+
{
82+
"command": "targeted trailing-whitespace scan over V27 changed files",
83+
"status": "passed"
84+
}
85+
],
86+
"closedInThisSlice": [
87+
"package-level fixed cap and measureminting law",
88+
"package-level zero-cell tail receipt behavior",
89+
"package-level semantic-volume measurement",
90+
"package-level range/mint/access/replay primitives",
91+
"package-level contributor allocation conservation",
92+
"package-level optional ancestry review with unpaid weak/citation edges",
93+
"package-level local BTC revenue-route conservation",
94+
"package-level BTC fee receipt lifecycle and provider boundary",
95+
"package-level deployment-lane mainnet approval guard",
96+
"demonstration receipt family coverage for V27 crypto primitives",
97+
"database migration and ORM projection boundary for V27 registry tables"
98+
],
99+
"remainingBlockingForPromotion": [
100+
"live wallet adapters",
101+
"regtest/signet broadcaster and observer proof",
102+
"selected Bitcoin commitment method with implementation proof",
103+
"Ethereum secondary boundary or explicit deferral proof",
104+
"route/API persistence integration",
105+
"range/policy UI disclosure",
106+
"generated V27 proof family set and BITCODE_SPEC_V27_PROVEN.md",
107+
"Supabase migration execution and generated DB type refresh",
108+
"full source-to-shares settlement integration",
109+
"external crypto library and standards rebinding proof"
110+
]
111+
}

BITCODE_SPEC_V27.md

Lines changed: 112 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ V27 answers that question by specifying:
4646
- testnet, mainnet, telemetry, and upgrade readiness for the crypto surfaces;
4747
- protocol-local licensed-read revenue routing;
4848
- optional late-bound knowledge ancestry as an attribution and routing module, never as a supply primitive;
49-
- post-cap `refit-only` exhaustion behavior;
49+
- fixed-supply measureminting decay with zero-cell/refit tail behavior;
5050
- database, proof, receipt, package, and UI invariants that fail closed on drift.
5151

5252
## Version Boundaries
@@ -133,7 +133,7 @@ Candidate fit alone cannot mint $BTD.
133133
Uncommitted proof cannot mint $BTD.
134134
Quality can affect allocation and revenue routing, but not supply inflation.
135135
Ancestry can affect routing and attribution, but not mint count.
136-
After the cap is exhausted, the policy is refit-only.
136+
Issuance follows fixed-supply measureminting decay; when the decayed entitlement is below one whole cell or the tail is exhausted, the event emits a zero-cell receipt and routes through refit, license, ancestry, proof, and revenue receipts.
137137
```
138138

139139
Every implementation, proof, receipt, database row, API, and UI surface that speaks about `$BTD` must preserve these laws.
@@ -200,7 +200,7 @@ export interface BtcFeeTransactionReceipt {
200200
| 'terminal_operation';
201201
payerWalletId: string;
202202
network: 'regtest' | 'signet' | 'testnet' | 'mainnet';
203-
txid: string;
203+
txid: string | null;
204204
vout?: number;
205205
satsPaid: bigint;
206206
satsPerVbyte?: number;
@@ -236,7 +236,7 @@ export interface AssetPackLedgerAnchor {
236236
| 'sepolia'
237237
| 'holesky'
238238
| 'local';
239-
txidOrHash: string;
239+
txidOrHash: string | null;
240240
outputIndex?: number;
241241
contractAddress?: string;
242242
tokenId?: string;
@@ -395,7 +395,11 @@ export interface BtdSupplyState {
395395
maxSupply: 21_000_000;
396396
totalMinted: number;
397397
nextTokenId: BtdTokenId;
398-
exhaustionPolicy: 'refit-only';
398+
cumulativeAdmittedMeasurement: bigint;
399+
residualMintCredit: bigint;
400+
curve: 'hyperbolic_saturation';
401+
curveParameter: bigint;
402+
tailPolicy: 'zero_cell_receipt_then_refit_only';
399403
exhaustedAtExchangeSequence?: bigint;
400404
}
401405
```
@@ -406,7 +410,10 @@ Required invariants:
406410
- `totalMinted >= 0`.
407411
- `totalMinted <= maxSupply`.
408412
- `nextTokenId === totalMinted` for the base contiguous allocator unless a future spec explicitly introduces sparse registry repair.
409-
- any proposed mint must satisfy `totalMinted + tokenCount <= maxSupply`;
413+
- any proposed measuremint must satisfy `totalMinted + tokenCount <= maxSupply`;
414+
- cumulative admitted measurement advances only after Need-Fit-Prove-Settle;
415+
- residual mint credit is deterministic and replayable;
416+
- zero-cell receipts are valid receipts, not failed mints;
410417
- overflow fails closed before state mutation;
411418
- non-finite, negative, NaN, or unsafe integer mint inputs fail closed.
412419

@@ -489,13 +496,13 @@ Mint admission requires:
489496
- settlement journal root;
490497
- access policy id and hash;
491498
- Exchange sequence;
492-
- deterministic token count;
499+
- deterministic measureminted token count, including valid zero-cell tail receipts;
493500
- deterministic allocation;
494501
- and successful supply cap check.
495502

496503
No UI button, API route, MCP tool, ChatGPT App action, admin route, script, seed, migration, or treasury process may mint `$BTD` outside this lifecycle.
497504

498-
## Quantity Rule
505+
## Measureminting Quantity Rule
499506

500507
Range length is determined by normalized Bitcode volume after dedupe and admissibility checks.
501508
V27 defines normalized Bitcode volume as a proof-addressable semantic unit derived from fit-accepted contribution segments.
@@ -510,19 +517,78 @@ Required normalized-volume properties:
510517
- semantic units carry enough stable identity to replay the same token count from receipts;
511518
- excluded units record an exclusion reason.
512519

513-
Initial V27 default:
520+
V27 replaces simple per-pack quantization as the primary issuance law with fixed-supply measureminting decay.
521+
The simple `floor(volume / Q)` rule remains useful as a local measurement witness, but it is not the final supply issuance rule.
522+
523+
Primary V27 law:
514524

515525
```ts
516-
export const BTD_QUANTIZATION_Q = 1_000n;
526+
S_MAX = 21_000_000;
527+
528+
M_before = cumulativeAdmittedMeasurement;
529+
M_after = M_before + normalizedBitcodeVolume;
530+
531+
targetMinted(M) = floor(S_MAX * M / (M + K));
532+
533+
tokenCount = targetMinted(M_after) - targetMinted(M_before);
534+
tokenCount = min(tokenCount, S_MAX - totalMinted);
535+
```
536+
537+
`K` is the measurement half-saturation constant.
538+
When cumulative admitted measurement equals `K`, roughly half of the supply has been minted.
539+
As cumulative measurement grows, issuance approaches but never exceeds the fixed cap.
517540

518-
tokenCount = floor(normalizedBitcodeVolume / BTD_QUANTIZATION_Q);
519-
require(tokenCount >= 1);
520-
require(totalMinted + tokenCount <= BTD_MAX_MINTABLE_SUPPLY);
541+
Whole-cell indivisibility means nonzero issuance cannot be infinite.
542+
V27 therefore admits zero-cell measuremint receipts:
543+
544+
```ts
545+
zeroCellReason =
546+
| 'below_integer_threshold'
547+
| 'tail_exhausted'
548+
| 'refit_only_policy';
521549
```
522550

551+
Zero-cell receipts advance measurement and settlement truth without minting a new cell.
552+
They are not failed mints.
553+
523554
V27 implementation must still define the exact measurement algorithm, but the scalar class is now closed: proof-addressable semantic units.
524555
Promotion may not proceed with a byte-count or tokenizer-count quantity rule.
525556

557+
Required measureminting anti-game invariants:
558+
559+
- settlement order is Exchange-sequence order, not user-selected order;
560+
- splitting or merging equivalent source cannot improve total minted count;
561+
- residual mint credit is deterministic and replayable;
562+
- cumulative measurement advances only after admitted Need-Fit-Prove-Settle;
563+
- duplicate normalized source cannot increase cumulative measurement;
564+
- upload time, claim time, and broad abstract scope do not determine issuance.
565+
566+
Canonical measuremint receipt:
567+
568+
```ts
569+
export interface BtdMeasureMintReceipt {
570+
kind: 'btd.measure_mint';
571+
assetPackId: string;
572+
normalizedBitcodeVolume: bigint;
573+
cumulativeMeasurementBefore: bigint;
574+
cumulativeMeasurementAfter: bigint;
575+
targetMintedBefore: number;
576+
targetMintedAfter: number;
577+
residualMintCreditBefore: bigint;
578+
residualMintCreditAfter: bigint;
579+
tokenCount: number;
580+
rangeStart?: BtdTokenId;
581+
rangeEndExclusive?: BtdTokenId;
582+
zeroCellReason?: 'below_integer_threshold' | 'tail_exhausted' | 'refit_only_policy';
583+
totalMintedBefore: number;
584+
totalMintedAfter: number;
585+
maxSupply: 21_000_000;
586+
proofRoot: string;
587+
settlementJournalRoot: string;
588+
accessPolicyHash: string;
589+
}
590+
```
591+
526592
## Allocation Rule
527593

528594
Quality does not inflate supply.
@@ -761,13 +827,24 @@ Anti-game controls are therefore protocol requirements, not moderation polish.
761827
V27 requires Exchange schema support equivalent to:
762828

763829
- `btd_supply_state`
830+
- `btd_semantic_volume_measurements`
831+
- `btd_measure_mint_receipts`
764832
- `btd_asset_pack_ranges`
765833
- `btd_cells`
766-
- `btd_mint_receipts`
767834
- `btd_ownership_events`
768835
- `btd_read_licenses`
836+
- `btd_mint_receipts`
837+
- `btd_contributor_allocations`
769838
- `btd_ancestor_edges`
770-
- `btd_revenue_routes`
839+
- `btd_licensed_read_revenue_routes`
840+
- `btc_fee_transactions`
841+
- `btd_asset_pack_ledger_anchors`
842+
- `btd_exchange_orders`
843+
- `btd_rights_transfer_receipts`
844+
- `btd_terminal_journal_entries`
845+
- `btd_ledger_database_reconciliation_repairs`
846+
- `btd_protocol_upgrade_receipts`
847+
- `btd_crypto_telemetry_events`
771848

772849
Database constraints must enforce:
773850

@@ -799,17 +876,30 @@ If retained temporarily, it must stay a compatibility read carrier only.
799876
- replay helpers;
800877
- and rejection of fungible mutation.
801878

802-
Recommended module split:
879+
Current draft module split:
803880

804881
```text
805882
packages/btd/src/constants.ts
806883
packages/btd/src/supply.ts
884+
packages/btd/src/measuremint.ts
807885
packages/btd/src/range.ts
808-
packages/btd/src/allocation.ts
809-
packages/btd/src/access.ts
810-
packages/btd/src/ancestor.ts
886+
packages/btd/src/semantic-volume.ts
811887
packages/btd/src/receipts.ts
812888
packages/btd/src/replay.ts
889+
packages/btd/src/allocation.ts
890+
packages/btd/src/access.ts
891+
packages/btd/src/ancestry.ts
892+
packages/btd/src/revenue.ts
893+
packages/btd/src/wallet.ts
894+
packages/btd/src/bitcoin-fees.ts
895+
packages/btd/src/bitcoin-provider.ts
896+
packages/btd/src/deployment-lanes.ts
897+
packages/btd/src/ledger-anchor.ts
898+
packages/btd/src/exchange.ts
899+
packages/btd/src/terminal-journal.ts
900+
packages/btd/src/reconciliation.ts
901+
packages/btd/src/telemetry.ts
902+
packages/btd/src/upgrade.ts
813903
```
814904

815905
## Interface Requirements
@@ -982,6 +1072,7 @@ Generated proof families must include:
9821072
- `v27-canonical-input-report`
9831073
- `v27-btd-supply-proof`
9841074
- `v27-btd-range-proof`
1075+
- `v27-btd-measuremint-proof`
9851076
- `v27-btd-mint-admission-proof`
9861077
- `v27-btd-receipt-replay-proof`
9871078
- `v27-btd-access-rights-proof`
@@ -1006,10 +1097,10 @@ V27 is not promotable until those generated families or their accepted equivalen
10061097

10071098
- V26 remains active canon.
10081099
- V27 notes are draft-target only.
1009-
- `packages/btd` currently has cap, BTC fee-basis helpers, measured `$BTD`, and fungible mutation rejection, but not full range/mint/access/ancestry implementation.
1100+
- `packages/btd` now contains draft V27 primitives for constants, supply, measureminting, range allocation, semantic volume, mint receipts, replay, access, contributor allocation, ancestry review, licensed-read revenue routing, wallet sessions, BTC fee receipts, ledger anchors, minimal Exchange orders, Terminal journals, reconciliation, telemetry, and upgrade receipts.
10101101
- `user_credits` and `user_credit_usages` remain compatibility storage carriers; V27 must replace or strictly bound them.
10111102
- Marketing and auxillary UI currently disclose BTC vs `$BTD` distinction; V27 must make route and range-level disclosure exact.
10121103
- Ancestry is specified as conditional and non-supply.
10131104
- External token standard comparisons are design inputs only until rebound to primary sources and translated into Bitcode-native law.
1014-
- Practical crypto library choices, chain standards, wallet compatibility, and RPC/provider choices must be web-researched and rebound to primary sources before promotion.
1105+
- Practical crypto library choices, chain standards, wallet compatibility, RPC/provider choices, live broadcaster/observer implementation, route/API persistence, generated proofs, and UI range/policy disclosure remain open before promotion.
10151106
- Value-bearing mainnet launch is not automatic promotion; it requires separate operational approval after V27 proves mainnet-ready controls.

0 commit comments

Comments
 (0)