Skip to content

Commit 6e8d98e

Browse files
Merge pull request #207 from engineeredsoftware/v45/gate-4-btd-scalar-volume-state-machine
V45 Gate 4: BTD Scalar Volume State Machine
2 parents ba357d1 + 743acdc commit 6e8d98e

3 files changed

Lines changed: 237 additions & 0 deletions

File tree

BITCODE_SPEC_V45_NOTES.md

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,76 @@ separation, source visibility boundaries, Need-relative BTD calculation
265265
condition, one-to-many Finding Fits input set, BTC settlement-before-source law,
266266
and repair-required fail-closed posture.
267267

268+
## V45 protocol atom 3: BTD scalar-volume state machine
269+
270+
Audit classification: V44 names BTD range, rights transfer, BTC settlement,
271+
and source-to-shares accounting, and the BTD package already owns semantic
272+
volume measurement, measureminting, range allocation, mint receipts, read
273+
receipts, rights transfer receipts, and contributor allocation. V45 must make
274+
the protocol meaning explicit: BTD is first the weighted scalar
275+
knowledge-volume of a Need-Fit AssetPack, and only its settled form carries
276+
rights, source unlock, ownership boundaries, and contributor allocation
277+
context.
278+
279+
Protocol-law statement:
280+
281+
BTD is the non-fungible, proof-addressed scalar unit of technical knowledge
282+
volume for a Need-Fit AssetPack. Deposit-time measurement may estimate BTD
283+
potential, but final BTD size is only computed after a reviewed Need, selected
284+
Fit set, synthesized Need-Fit AssetPack, deterministic measurement weights,
285+
dedupe proofs, and source-safe proof roots exist. BTC remains the payment
286+
asset. BTD is not money, not a spendable balance, not raw source, not a
287+
fungible exchange token, and not final merely because a deposit was admitted.
288+
289+
The canonical BTD state machine is:
290+
291+
| State | Meaning | Required inputs | Output posture |
292+
| --- | --- | --- | --- |
293+
| `btd-not-applicable` | Raw source, a Read Request, or an unreviewed pipeline output is not BTD. | none | no BTD claim |
294+
| `btd-potential-measured` | Deposit or market intelligence has source-safe measurements that may estimate future utility. | deposit option root, source-safety root, measurement roots | potential/range language only; no final BTD size |
295+
| `need-fit-measurements-admitted` | A reviewed Need, selected Fit set, and synthesized Need-Fit AssetPack admit measurement rows. | accepted Need root, selected Fit root, synthesis root, dedupe roots | admissible measurement vector |
296+
| `measurement-weight-policy-locked` | Deterministic measurement weights are bound before scalar volume calculation. | weight policy id/hash, measurement taxonomy root, versioned formula root | no post hoc reweighting |
297+
| `weighted-scalar-volume-computed` | Each admissible measurement contributes `normalizedMeasurementVolume * measurementWeight`, summed with fixed-point arithmetic into BTD scalar knowledge-volume. | admitted measurement vector, weight policy root, dedupe roots, proof roots | Need-relative normalized BTD volume |
298+
| `btd-quantized` | The normalized scalar volume is quantized into protocol BTD cell count or zero-cell tail posture. | normalized BTD volume, quantization root, fixed supply parameters | quoteable BTD token count or zero-cell receipt |
299+
| `measuremint-applied` | The measureminting curve applies cumulative admitted measurement against fixed supply. | prior measuremint state, normalized BTD volume, settlement journal root, access policy hash | measuremint receipt and next measuremint state |
300+
| `btd-range-assigned` | A non-overlapping AssetPack BTD range is assigned when positive cells are minted. | measuremint receipt, supply state, range allocation inputs | source-safe mint receipt; no Reader rights yet |
301+
| `btd-quote-bound` | The BTD volume/range and access policy are bound to a BTC quote for the Reader. | BTD receipt roots, quote root, budget approval root when required | source-safe quote; no payment finality |
302+
| `btd-rights-pending` | BTC payment may be prepared, signed, broadcast, or observed, but finality and rights transfer are incomplete. | payment observation root, quote root, ledger journal root | source remains locked |
303+
| `btd-rights-transferred` | Confirmed BTC settlement authorizes BTD rights transfer to the Reader boundary. | confirmed BTC finality root, rights transfer receipt, ledger projection root | rights-bearing BTD and source unlock authority |
304+
| `btd-source-to-shares-allocated` | Contributor compensation is allocated from the paid Need-Fit settlement. | source-to-shares proof, BTD range slices, BTC payment observation, contributor roots | allocation and compensation readback |
305+
| `btd-repair-required` | Measurement, weight, mint, range, quote, payment, rights, allocation, or reconciliation proof is missing or stale. | repair blocker root | fail-closed repair only |
306+
307+
Measurement law:
308+
309+
- Every final BTD measurement row must be Need-relative, accepted, deduped,
310+
proof-rooted, and tied to the selected Fit set that contributed to the
311+
synthesized Need-Fit AssetPack.
312+
- Measurement weights are deterministic protocol policy, not UI preference,
313+
operator discretion, model confidence alone, or depositor-provided pricing.
314+
- Scalar volume calculation uses fixed-point or integer arithmetic. Floating
315+
rounding, hidden post-processing, or undocumented prompt-derived weights are
316+
not protocol-valid.
317+
- Deposit-time measurements may inform depositor review, Depository search,
318+
market intelligence, and BTD potential, but they cannot mint, transfer,
319+
quote final BTD, unlock source, or allocate contributor shares without a
320+
reviewed Need and selected Fit set.
321+
- Positive BTD cells must conserve fixed supply and occupy a contiguous,
322+
non-overlapping AssetPack range. Zero-cell tail receipts remain valid
323+
measuremint evidence but cannot be represented as positive rights-bearing
324+
BTD cells.
325+
- Rights-bearing BTD exists only after BTC settlement finality and BTD rights
326+
transfer. Before that, BTD volume/range is preview or quote state only.
327+
- Source-to-shares uses the settled Need-Fit AssetPack, selected Fit deposits,
328+
BTD range slices, and BTC payment observation to allocate contributor
329+
compensation; it must not be confused with scalar-volume calculation.
330+
331+
Acceptance for this atom: later V45 specification may refine measurement
332+
taxonomy and formula constants, but it must preserve BTD as Need-relative
333+
weighted scalar knowledge-volume, deposit-time BTD potential as non-final,
334+
deterministic fixed-point measurement weighting, measuremint/range conservation,
335+
zero-cell tail posture, BTC-before-rights law, and source-to-shares as
336+
post-settlement contributor allocation rather than BTD size.
337+
268338
## Non-goals during V45 opening
269339

270340
- Do not implement V45 gate behavior before the V45 intent discussion is

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,7 @@
389389
"check:v44-gate10": "node scripts/check-v44-gate10-promotion-readiness.mjs",
390390
"check:v45-gate2": "node scripts/check-v45-gate2-knowledge-commoditization-law.mjs",
391391
"check:v45-gate3": "node scripts/check-v45-gate3-assetpack-lifecycle-state-machine.mjs",
392+
"check:v45-gate4": "node scripts/check-v45-gate4-btd-scalar-volume-state-machine.mjs",
392393
"generate:v38-inference-surface-inventory": "node scripts/generate-v38-inference-surface-inventory.mjs",
393394
"check:v38-inference-surface-inventory": "node scripts/generate-v38-inference-surface-inventory.mjs --check",
394395
"check:v38-gate2": "node scripts/check-v38-gate2-inference-surface-inventory.mjs",
Lines changed: 166 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,166 @@
1+
#!/usr/bin/env node
2+
3+
import { execFileSync } from 'node:child_process';
4+
import { existsSync, readFileSync } from 'node:fs';
5+
import path from 'node:path';
6+
import { fileURLToPath } from 'node:url';
7+
8+
const __filename = fileURLToPath(import.meta.url);
9+
const __dirname = path.dirname(__filename);
10+
const defaultRepoRoot = path.resolve(__dirname, '..');
11+
12+
function read(root, relativePath) {
13+
return readFileSync(path.join(root, relativePath), 'utf8');
14+
}
15+
16+
function exists(root, relativePath) {
17+
return existsSync(path.join(root, relativePath));
18+
}
19+
20+
function git(root, args) {
21+
return execFileSync('git', args, { cwd: root, encoding: 'utf8' }).trim();
22+
}
23+
24+
function assertCheck(failures, condition, message) {
25+
if (!condition) failures.push(message);
26+
}
27+
28+
function normalize(content) {
29+
return content.replace(/\s+/gu, ' ').trim();
30+
}
31+
32+
function parseArgs(argv) {
33+
const args = { repoRoot: defaultRepoRoot, skipBranchCheck: false };
34+
for (let index = 0; index < argv.length; index += 1) {
35+
const arg = argv[index];
36+
if (arg === '--repo-root') args.repoRoot = path.resolve(argv[++index]);
37+
else if (arg === '--skip-branch-check') args.skipBranchCheck = true;
38+
else if (arg === '--help' || arg === '-h') args.help = true;
39+
else throw new Error(`Unknown argument ${arg}`);
40+
}
41+
return args;
42+
}
43+
44+
function printHelp() {
45+
process.stdout.write(
46+
[
47+
'Usage: node scripts/check-v45-gate4-btd-scalar-volume-state-machine.mjs [--skip-branch-check] [--repo-root <path>]',
48+
'',
49+
'Checks the V45 BTD scalar-volume state machine specification atom.',
50+
].join('\n'),
51+
);
52+
process.stdout.write('\n');
53+
}
54+
55+
function main() {
56+
const args = parseArgs(process.argv.slice(2));
57+
if (args.help) {
58+
printHelp();
59+
return;
60+
}
61+
62+
const root = args.repoRoot;
63+
const failures = [];
64+
const pointer = read(root, 'BITCODE_SPEC.txt').trim();
65+
66+
assertCheck(failures, pointer === 'V44', `BITCODE_SPEC.txt must remain V44 during V45 atom work. Observed ${pointer || 'empty'}.`);
67+
68+
if (!args.skipBranchCheck) {
69+
const branch = git(root, ['branch', '--show-current']);
70+
assertCheck(
71+
failures,
72+
branch === 'version/v45' || /^v45\/gate-\d+-[a-z0-9][a-z0-9-]*$/u.test(branch),
73+
`V45 work must occur on version/v45 or v45/gate-N-* branches. Observed ${branch || 'detached HEAD'}.`,
74+
);
75+
}
76+
77+
for (const relativePath of [
78+
'BITCODE_SPEC_V45_NOTES.md',
79+
'BITCODE_SPEC_V44.md',
80+
'packages/btd/src/semantic-volume.ts',
81+
'packages/btd/src/measuremint.ts',
82+
'packages/btd/src/range.ts',
83+
'packages/btd/src/source-to-shares.ts',
84+
'package.json',
85+
'scripts/check-v45-gate3-assetpack-lifecycle-state-machine.mjs',
86+
]) {
87+
assertCheck(failures, exists(root, relativePath), `Missing required V45 Gate 4 file: ${relativePath}`);
88+
}
89+
90+
const notes = read(root, 'BITCODE_SPEC_V45_NOTES.md');
91+
const normalizedNotes = normalize(notes);
92+
const packageJson = read(root, 'package.json');
93+
94+
for (const phrase of [
95+
'V45 protocol atom 3: BTD scalar-volume state machine',
96+
'BTD is first the weighted scalar knowledge-volume of a Need-Fit AssetPack',
97+
'only its settled form carries rights',
98+
'BTD is the non-fungible, proof-addressed scalar unit of technical knowledge volume',
99+
'Deposit-time measurement may estimate BTD potential',
100+
'final BTD size is only computed after a reviewed Need',
101+
'selected Fit set, synthesized Need-Fit AssetPack',
102+
'deterministic measurement weights',
103+
'BTC remains the payment asset',
104+
'BTD is not money',
105+
'btd-not-applicable',
106+
'btd-potential-measured',
107+
'need-fit-measurements-admitted',
108+
'measurement-weight-policy-locked',
109+
'weighted-scalar-volume-computed',
110+
'btd-quantized',
111+
'measuremint-applied',
112+
'btd-range-assigned',
113+
'btd-quote-bound',
114+
'btd-rights-pending',
115+
'btd-rights-transferred',
116+
'btd-source-to-shares-allocated',
117+
'btd-repair-required',
118+
'potential/range language only; no final BTD size',
119+
'normalizedMeasurementVolume * measurementWeight',
120+
'Need-relative normalized BTD volume',
121+
'quoteable BTD token count or zero-cell receipt',
122+
'source-safe mint receipt; no Reader rights yet',
123+
'rights-bearing BTD and source unlock authority',
124+
'Every final BTD measurement row must be Need-relative',
125+
'Measurement weights are deterministic protocol policy',
126+
'Scalar volume calculation uses fixed-point or integer arithmetic',
127+
'Deposit-time measurements may inform depositor review',
128+
'cannot mint, transfer, quote final BTD, unlock source, or allocate contributor shares',
129+
'contiguous, non-overlapping AssetPack range',
130+
'Zero-cell tail receipts remain valid measuremint evidence',
131+
'Rights-bearing BTD exists only after BTC settlement finality and BTD rights transfer',
132+
'Source-to-shares uses the settled Need-Fit AssetPack',
133+
'must not be confused with scalar-volume calculation',
134+
'Acceptance for this atom',
135+
'BTD as Need-relative weighted scalar knowledge-volume',
136+
'deposit-time BTD potential as non-final',
137+
'deterministic fixed-point measurement weighting',
138+
'measuremint/range conservation',
139+
'BTC-before-rights law',
140+
]) {
141+
assertCheck(failures, normalizedNotes.includes(phrase), `V45 Gate 4 notes must include phrase: ${phrase}`);
142+
}
143+
144+
assertCheck(
145+
failures,
146+
packageJson.includes('"check:v45-gate4": "node scripts/check-v45-gate4-btd-scalar-volume-state-machine.mjs"'),
147+
'package.json must expose check:v45-gate4.',
148+
);
149+
150+
if (failures.length > 0) {
151+
process.stderr.write('V45 Gate 4 BTD scalar-volume state machine check failed:\n');
152+
for (const failure of failures) process.stderr.write(`- ${failure}\n`);
153+
process.exitCode = 1;
154+
return;
155+
}
156+
157+
process.stdout.write('V45 Gate 4 BTD scalar-volume state machine check passed.\n');
158+
}
159+
160+
try {
161+
main();
162+
} catch (error) {
163+
const detail = error instanceof Error ? error.message : String(error);
164+
process.stderr.write(`${detail}\n`);
165+
process.exitCode = 1;
166+
}

0 commit comments

Comments
 (0)