Skip to content

Commit ea3cdb1

Browse files
wip v23
1 parent 12c1997 commit ea3cdb1

13 files changed

Lines changed: 1852 additions & 87 deletions

ENGI_SPEC_V23.md

Lines changed: 89 additions & 34 deletions
Large diffs are not rendered by default.

ENGI_SPEC_V23_DELTA.md

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,23 +55,25 @@ The current accepted V23 drafting decisions are:
5555

5656
1. V23 is deployment-facing rather than another truth-alignment pass.
5757
2. Bitcoin enters ENGI first as a commitment and spend substrate.
58-
3. ENGI proof computation and bulk private artifact storage remain off-chain by default.
58+
3. ENGI proof computation and bulk private artifact storage remain off-chain by default, while NGI remains the denomination for share and settlement units.
5959
4. V23 opens two new proof families: `bitcoin-audit-anchor` and `bitcoin-settlement-interface`.
6060
5. V23 requires bounded-public and private commitment scopes at minimum.
6161
6. V23 requires audited payment intent and audited payment observation carriers before any future live settlement claim can be made.
62-
7. V23 keeps optional sidechain or L2 transferability as later work, not as the entry point.
62+
7. V23 keeps a sidechain connection point inside first gate so the ENGI:BTC bridge is not mainchain-only; generalized sidechain-issued transferability remains later work.
6363
8. V23 does not authorize canonical promotion or generated-proof claims until source and validation land.
6464
9. V23 first gate fixes replayable manifest-root derivation instead of leaving root construction implicit.
6565
10. V23 first gate fixes the minimum enum vocabulary and mode-specific journal finalization rules for BTC-facing artifacts.
6666
11. V23 first gate adds a treasury-policy surface and a BTC artifact projection matrix so buyer, reviewer, and public visibility are explicit.
67+
12. V23 first gate also requires prototype-demonstration compute-reality and storage-reality artifacts so deployed compute and storage posture are spec-bearing rather than implied.
6768

6869
## Explicitly deferred
6970

7071
Still explicitly deferred beyond this drafting pass:
7172
- live Bitcoin transaction assembly and signing,
7273
- live anchor publication,
7374
- live repeated-read payment network integration,
74-
- live optional L2 or sidechain transferability,
75+
- live sidechain bridge execution,
76+
- live generalized sidechain-issued transferability,
7577
- and any V23 `_PROVEN_` appendix or generated `.engi/v23-*` artifact family.
7678

7779
## Draft implementation sequence
@@ -82,18 +84,20 @@ The accepted V23 sequencing is:
8284
2. define the new Bitcoin-facing artifact family and proof-family members,
8385
3. derive public and private commitment scopes from existing deliverables classification,
8486
4. fix the manifest-root derivation contract, enum vocabulary, treasury policy shape, and mode-specific finalization rules,
85-
5. specialize the external-boundary manifest into anchor and spend interfaces,
86-
6. bind settlement intent and observation to existing exact settlement artifacts,
87-
7. add fail-closed validation for scope leakage, receipt drift, and mode-specific finalization drift,
88-
8. generate V23 proof and draft-readiness artifacts from real source behavior,
89-
9. and only then consider promotion away from V22.
87+
5. define and prototype-demonstrate compute-reality and storage-reality artifacts,
88+
6. specialize the external-boundary manifest into anchor and spend interfaces,
89+
7. bind settlement intent and observation to existing exact settlement artifacts,
90+
8. add fail-closed validation for scope leakage, receipt drift, compute/storage reality drift, and mode-specific finalization drift,
91+
9. generate V23 proof and draft-readiness artifacts from real source behavior,
92+
10. and only then consider promotion away from V22.
9093

9194
## Commit-body direction
9295

9396
The eventual V23 canonical commit body should describe:
9497
- the Bitcoin-facing artifact family added to source,
9598
- the exact public and private commitment-scope rules,
9699
- the manifest-root derivation contract, enum vocabulary, treasury-policy surface, and finalization policy,
100+
- the prototype-demonstration compute-reality and storage-reality surfaces,
97101
- the spend-intent and payment-observation closure path,
98102
- the new proof families and validation surfaces,
99103
- and the explicit continued honesty about what remains modeled versus live.

ENGI_SPEC_V23_NOTES.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,10 @@ The inherited baseline for V23 is:
4242

4343
The strongest V23 center from the current audit is:
4444
- define Bitcoin as ENGI's next public audit and spend interface layer,
45+
- keep a sidechain connection point in first-gate scope so the bridge is not mainchain-only,
4546
- keep proof computation and bulk private artifact storage off-chain,
47+
- clarify that NGI is the share and settlement denomination while ENGI names the system,
48+
- require prototype-demonstration compute and storage reality surfaces so deployed posture is explicit,
4649
- derive bounded-public and private commitment scopes from current artifact classifications,
4750
- bind buyer payment intent and network observation to exact ENGI bundle and settlement surfaces,
4851
- and preserve the repo's current honesty about modeled versus live boundaries.
@@ -76,6 +79,17 @@ Likely consequences:
7679

7780
First-gate drafting choice:
7881
- add `.engi/bitcoin-treasury-policy.json` as the policy carrier for anchor mode, payment mode, signer policy, and journal finalization policy.
82+
- include sidechain bridge policy in that same treasury-policy surface.
83+
84+
### 2.5. Compute and storage reality surfaces
85+
86+
Candidate requirement:
87+
- add prototype-demonstration manifests for off-chain compute reality and content-addressed storage reality.
88+
89+
Likely consequences:
90+
- new `.engi/compute-reality-manifest.json`,
91+
- new `.engi/storage-reality-manifest.json`,
92+
- and explicit audit-visible closure over how deployed compute and storage bind to ENGI ledgered artifacts.
7993

8094
### 3. Settlement intent and observation surfaces
8195

@@ -84,6 +98,7 @@ Candidate requirement:
8498

8599
Likely consequences:
86100
- larger purchases and repeated read-like purchases use different modes,
101+
- sidechain bridge mode remains a first-gate connection point,
87102
- but the same closure rules still apply,
88103
- and journal or settlement effects do not become network-implicit.
89104

ENGI_SPEC_V23_PARITY_MATRIX.md

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -49,18 +49,21 @@ This matrix is grounded in:
4949
| Deliverables confidentiality classification | `run-artifacts.js` already classifies deliverables by `confidentialityClass` and `potentiallyDisclosable` | V23 public commitment scope must derive only from disclosable artifacts | public-root inclusion rule is derived from deliverables classification and projection policy | implemented prerequisite |
5050
| Manifest-root derivation contract | current source has stable hashing but no BTC-specific root contract | V23 requires replayable manifest-root derivation rather than an implicit or ad hoc root algorithm | `publicRoot` and `privateRoot` are derived from sorted scope entries under a fixed `v23.manifest-root.v1` contract | implemented in docs |
5151
| BTC enum vocabulary | current source has no BTC-specific enum set | V23 requires fixed enum values for anchor, payment, publication, confirmation, network, and journal-binding states | enum vocabulary is declared in spec and used consistently across artifact definitions | implemented in docs |
52+
| Compute-reality surface | current source exposes model execution as a boundary but has no compute-reality manifest | V23 requires a prototype-demonstration compute-reality artifact that binds off-chain execution to replayable proof and settlement surfaces | `.engi/compute-reality-manifest.json` is emitted, classified, and test-covered | not yet implemented |
53+
| Storage-reality surface | current source exposes artifact uploads and deliverables but has no storage-reality manifest | V23 requires a prototype-demonstration storage-reality artifact that binds commitment scopes to content-addressed retrieval posture | `.engi/storage-reality-manifest.json` is emitted, classified, and test-covered | not yet implemented |
5254
| Exact settlement event size | `engi-demo/src/engi-demo.js` exports `METERED_MICRO_UNITS = '100000000'`; `settlement.js` allocates exact micro-units against it | V23 payment intent and observation must bind to the same exact event size | settlement-intent and settlement-observation artifacts reference the same metered-unit event | implemented prerequisite |
55+
| NGI denomination rule | current source has exact integer settlement carriers but no BTC-facing denomination rule | V23 requires ENGI to remain the system name and NGI to be the share and settlement denomination | BTC-facing artifacts declare `unitDenomination = NGI` and treasury policy declares settlement denomination explicitly | implemented in docs |
5356
| Settlement proof chain | source-to-shares, settlement participation, accounting precision, journal diff, and settlement proof already close over exact accounting | V23 audited spend surfaces must bind to the existing settlement proof chain | payment observation does not contradict or replace settlement proof closure | implemented prerequisite |
5457
| Bounded-public proof surfaces | projection policy, bounded-public proof, redaction proof, and disclosure proof already exist | V23 public anchor receipts must project only these safe surfaces | bounded-public anchor is derivable without leaking private artifacts | implemented prerequisite |
55-
| Treasury-policy surface | current source has no explicit treasury or finalization policy artifact | V23 requires a treasury-policy carrier referenced by settlement intent, anchor policy, and finalization rules | `.engi/bitcoin-treasury-policy.json` is emitted and classified in deliverables manifest | not yet implemented |
58+
| Treasury-policy surface | current source has no explicit treasury or finalization policy artifact | V23 requires a treasury-policy carrier referenced by settlement intent, anchor policy, sidechain bridge policy, and finalization rules | `.engi/bitcoin-treasury-policy.json` is emitted and classified in deliverables manifest | not yet implemented |
5659
| BTC artifact projection matrix | current source has no per-principal visibility matrix for `bitcoin-*` artifacts | V23 requires explicit public/reviewer/buyer/internal visibility for each new BTC artifact | projection policy and deliverables classification cover each BTC artifact explicitly | implemented in docs |
5760
| External boundary specialization | `engi-demo/src/engi-demo.js` already emits a generic `settlement-network-effects` interface | V23 requires explicit anchor-publication and spend-observation interface contracts | external-boundary manifest is specialized beyond generic settlement network effects | draft-required |
5861
| Bitcoin-facing artifact family | no current source emits `bitcoin-*` artifacts | V23 requires commitment-manifest, anchor, bounded-public anchor, settlement intent, settlement observation, and two proof artifacts | new artifact family is emitted in `.engi/` and classified in deliverables manifest | not yet implemented |
5962
| Bitcoin proof-family validation | no current source emits `bitcoin-audit-anchor` or `bitcoin-settlement-interface` proof families | V23 requires both proof families with theorem and replay closure | proof-witness manifest and proof-contract include the new families | not yet implemented |
60-
| Mode-specific finalization policy | current source has no BTC-facing finalization semantics | V23 requires explicit finalization rules for base-layer, repeated-read, and checkpointed-L2 modes | tests and runtime enforce `journalBindingState` transitions by mode | not yet implemented |
63+
| Sidechain bridge mode and finalization policy | current source has no BTC-facing sidechain bridge semantics | V23 requires an explicit sidechain bridge connection point and finalization rules for base-layer, repeated-read, and checkpointed-sidechain modes | tests and runtime enforce `journalBindingState` transitions by mode and sidechain checkpoints | not yet implemented |
6164
| Live network execution | README and external-boundary surfaces remain explicit that networked settlement effects are modeled only | V23 must preserve that honesty until real implementation lands | docs and runtime continue to state modeled versus live boundaries accurately | accepted boundary |
6265
| Generated V23 evidence | no `ENGI_SPEC_V23_PROVEN.md` or generated `.engi/v23-*` evidence exists | V23 promotion requires generated evidence from real source behavior | generated appendix and generated V23 reports exist before promotion | accepted boundary |
63-
| Optional sidechain or L2 transferability | no current source models transferability beyond deterministic settlement accounting | V23 keeps this as later optional deployment work | any future transfer mode still binds back to the same commitment and settlement carriers | accepted boundary |
66+
| Sidechain connection point with later transferability | no current source models a sidechain bridge connection point or transferability beyond deterministic settlement accounting | V23 keeps the sidechain bridge connection point in first-gate scope while generalized transferability remains later work | sidechain bridge mode is specified now; any later generalized transfer mode still binds back to the same commitment and settlement carriers | implemented in docs / pending in source |
6467

6568
---
6669

@@ -73,32 +76,38 @@ This matrix is grounded in:
7376
| Public/private commitment scope rule | bounded-public and private roots are specified distinctly | implemented in docs |
7477
| Manifest-root derivation contract | `publicRoot` and `privateRoot` are defined replayably | implemented in docs |
7578
| Enum vocabulary | BTC-facing artifact state enums are fixed | implemented in docs |
79+
| Compute-reality surface | prototype compute posture is explicit | implemented in docs |
80+
| Storage-reality surface | prototype storage posture is explicit | implemented in docs |
81+
| NGI denomination rule | ENGI versus NGI naming and unit semantics are explicit | implemented in docs |
7682
| Bitcoin artifact family | new `.engi/bitcoin-*` carriers are defined | implemented in docs |
7783
| Bitcoin proof families | new proof families are defined and bounded | implemented in docs |
7884
| Treasury policy surface | spend-policy and finalization carrier is defined | implemented in docs |
7985
| BTC artifact projection matrix | per-principal visibility for BTC artifacts is explicit | implemented in docs |
86+
| Sidechain bridge connection point | sidechain bridge mode is explicit in first-gate scope | implemented in docs |
8087
| Source emission | current runtime emits the new artifacts | pending |
88+
| Prototype compute/storage emission | current runtime emits compute-reality and storage-reality artifacts | pending |
8189
| Deliverables classification | current deliverables manifest classifies new artifacts correctly | pending |
8290
| External boundary specialization | current external-boundary manifest splits anchor and spend interfaces | pending |
83-
| Test closure | tests fail closed on scope leakage, receipt drift, and mode-specific finalization drift | pending |
91+
| Test closure | tests fail closed on scope leakage, receipt drift, compute/storage reality drift, and mode-specific finalization drift | pending |
8492
| Generated evidence | generated V23 appendix and V23 reports exist | pending |
8593

8694
## Accepted boundaries
8795

8896
| Boundary | Rationale | Reopen condition |
8997
| --- | --- | --- |
9098
| No pointer promotion in this pass | V22 remains the only active canon | Reopen only after real source implementation and generated evidence exist |
91-
| No live BTC execution claims | current source does not execute those flows | Reopen only when runtime, tests, and generated evidence prove it |
99+
| No live BTC execution claims beyond prototype demonstration | current source does not execute those flows end-to-end yet | Reopen only when runtime, tests, and generated evidence prove it |
92100
| No `_PROVEN_` appendix yet | V23 is still a draft target | Reopen only when V23 behavior is generated from source |
93-
| No mandatory transferability layer | Bitcoin-audit anchoring and spend binding come first | Reopen only if later implementation requires optional L2 or sidechain support |
101+
| No mandatory generalized transferability layer | Bitcoin-audit anchoring, sidechain bridge connectivity, and spend binding come first; generalized transferability can remain later | Reopen only if later implementation requires sidechain-issued transferability in first gate |
94102
| No Merkle inclusion requirement in first gate | first-gate V23 uses replayable manifest roots instead | Reopen only if a later version needs compact inclusion-path semantics beyond manifest replay |
95103

96104
## Completion condition
97105

98106
This parity file is complete for V23 only when:
99107
1. every draft artifact and proof-family row is either implemented in source or explicitly deferred,
100108
2. public and private commitment scopes are enforced by source and tests,
101-
3. manifest-root derivation, enum vocabulary, treasury-policy surface, and mode-specific finalization rules are enforced by source and tests,
102-
4. external-boundary specialization is emitted in current runtime artifacts,
103-
5. generated V23 evidence exists,
104-
6. and promotion away from V22 is justified by real implementation rather than by draft intent alone.
109+
3. prototype compute-reality and storage-reality surfaces are emitted and enforced by source and tests,
110+
4. manifest-root derivation, enum vocabulary, treasury-policy surface, and mode-specific finalization rules are enforced by source and tests,
111+
5. external-boundary specialization is emitted in current runtime artifacts,
112+
6. generated V23 evidence exists,
113+
7. and promotion away from V22 is justified by real implementation rather than by draft intent alone.

engi-demo/server.js

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@
103103
* buyerId?: string | undefined,
104104
* scenarioId?: string | undefined,
105105
* branchMode?: string | undefined,
106+
* paymentMode?: string | undefined,
106107
* principal?: string | undefined
107108
* }} RequestBodyShape
108109
*/
@@ -124,6 +125,11 @@ const DEFAULT_PUBLIC_DIR = path.join(__dirname, 'public');
124125
const DEFAULT_PORT = Number(process.env['PORT'] || 4318);
125126
const ALLOWED_PROJECTION_PRINCIPALS = new Set(['public', 'buyer', 'reviewer', 'internal']);
126127
const ALLOWED_BRANCH_MODES = new Set(['patch', 'context']);
128+
const ALLOWED_PAYMENT_MODES = new Set([
129+
'audited-base-layer-purchase',
130+
'repeated-read-payment',
131+
'checkpointed-sidechain-bridge'
132+
]);
127133

128134
/**
129135
* @param {string} targetPath
@@ -198,6 +204,19 @@ export function createAppContext({
198204
return normalized;
199205
}
200206

207+
/**
208+
* @param {unknown} paymentMode
209+
* @returns {string | undefined}
210+
*/
211+
function normalizePaymentMode(paymentMode) {
212+
const normalized = String(paymentMode || '').trim().toLowerCase();
213+
if (!normalized) return undefined;
214+
if (!ALLOWED_PAYMENT_MODES.has(normalized)) {
215+
throw badRequest(`Unsupported payment mode: ${paymentMode}`);
216+
}
217+
return normalized;
218+
}
219+
201220
/**
202221
* @returns {{ bootstrapped: boolean, reason?: string, assetCount?: number, buyerCount?: number }}
203222
*/
@@ -455,6 +474,7 @@ export function createAppContext({
455474
const state = readState();
456475
const principal = normalizePrincipal(body.principal || undefined);
457476
const branchMode = normalizeBranchMode(body.branchMode);
477+
const paymentMode = normalizePaymentMode(body.paymentMode);
458478
const scenarioId = String(body.scenarioId || '').trim() || undefined;
459479
const buyerId = String(body.buyerId || '').trim() || undefined;
460480
if (buyerId && !state.buyers.some((buyer) => String(/** @type {any} */ (buyer)?.buyerId || '') === buyerId)) {
@@ -466,7 +486,8 @@ export function createAppContext({
466486
const branchRequest = {
467487
buyerId,
468488
scenarioId,
469-
branchMode
489+
branchMode,
490+
paymentMode
470491
};
471492
const { nextState, latestRun } = runMakeEngiBranch(state, branchRequest);
472493
writeState(nextState);

0 commit comments

Comments
 (0)