diff --git a/CHANGELOG.md b/CHANGELOG.md index e5c08355..8958da8c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## 0.6.0 candidate — optional wallet profile semantics + +- Add opt-in ISI-6@0.1.0 with ten UMP/profile continuity flows, independent of core ISI-4 acceptance. +- Add digest-bound engineering observation evaluation, a labelled synthetic pack and seeded regression tests; no native SUT result or certification is issued. +- Add v0.2 catalog/index schemas and preserve original v0.1 contracts and historical program artifacts. + ## Unreleased - Add ITCVE-1 1.1.0 with independent TypeScript/Go Overlay, ChainTracks and Wallet Storage selection, pinned native dependencies, authenticated mixed-component tests, fault/recovery checks, wallet/Android configuration and CI evidence. Historical profiles and results remain fixed. diff --git a/README.md b/README.md index a1113ddc..3438e4fa 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,9 @@ **TPNIL** is a BSV Blockchain initiative for impartial interoperability evaluation, without fear or favor. The laboratory brings published requirements, canonical software artifacts, integrated test environments, deterministic results, and durable evidence into a common framework open to equal participation. -**Version 0.5.0 — public experimental release.** The laboratory executes the causally joined transaction-processing reference stack and an admitted production-wallet BRC-100 lane. The latest two clean Yours Wallet 5.1.0 repetitions on the Go-backed ITCVE-1 2.0.0 profile match: V001–V007 pass and V008 fails, with 180 PASS, 99 FAIL and one BLOCKED predicate each. [Native findings and retained workflow boundaries](docs/native-conformance-results-2026-11-09.md) distinguish environment admission, remaining wallet findings and the separately qualified Rust3 reevaluation: 77 integration and 48 Rust checks pass per repetition on the unchanged native observations. The component-only ITCVE-1 3.0.0 profile independently records 584 PASS and six unchanged Go Message Box FAIL observations across 590 assertions. Four controlled-WAB Metanet Explorer runs completed activation, mined-output funding and UMP publication, then submitted a ToDo token; each stopped at the WebView wallet-response and task-visibility boundary. A BSV Browser source candidate reached an authenticated 28-method BRC-100 context and the ToDo funding boundary. These are experimental results and engineering observations. Certification remains unavailable. [Implementation status](docs/implementation-status.md) records the exact boundary. +**Version 0.6.0 candidate adds optional [ISI-6 UMP/profile semantics](programs/ISI-6/0.1.0/README.md).** + +**Retained 0.5.0 public experimental release.** The laboratory executes the causally joined transaction-processing reference stack and an admitted production-wallet BRC-100 lane. The latest two clean Yours Wallet 5.1.0 repetitions on the Go-backed ITCVE-1 2.0.0 profile match: V001–V007 pass and V008 fails, with 180 PASS, 99 FAIL and one BLOCKED predicate each. [Native findings and retained workflow boundaries](docs/native-conformance-results-2026-11-09.md) distinguish environment admission, remaining wallet findings and the separately qualified Rust3 reevaluation: 77 integration and 48 Rust checks pass per repetition on the unchanged native observations. The component-only ITCVE-1 3.0.0 profile independently records 584 PASS and six unchanged Go Message Box FAIL observations across 590 assertions. Four controlled-WAB Metanet Explorer runs completed activation, mined-output funding and UMP publication, then submitted a ToDo token; each stopped at the WebView wallet-response and task-visibility boundary. A BSV Browser source candidate reached an authenticated 28-method BRC-100 context and the ToDo funding boundary. These are experimental results and engineering observations. Certification remains unavailable. [Implementation status](docs/implementation-status.md) records the exact boundary. ## The laboratory @@ -14,8 +16,9 @@ The [charter](CHARTER.md) defines the mission and principles. [Governance](GOVER | [ISI-2](programs/ISI-2/0.1.0/README.md) | Overlay synchronization, submission, and lookup | 0.1.0 | Draft | | [ISI-3](programs/ISI-3/0.1.0/README.md) | Remote wallet storage boundary and mediated synchronization | 0.1.0 | Draft | | [ISI-4](programs/ISI-4/4.0.0/README.md) | Production BRC-100 wallet and application interoperability | 4.0.0 | Draft | +| [ISI-6](programs/ISI-6/0.1.0/README.md) | Optional UMP and profile continuity semantics | 0.1.0 | Draft; observation evaluator | -All four programs select versioned ITCVE-1 profiles. The latest ISI-4 lane uses the [native decision and shutdown profile](itcves/ITCVE-1/2.0.0/README.md); its [original production-wallet profile](itcves/ITCVE-1/1.0.0/README.md) remains separately reproducible; ISI-1 through ISI-3 retain [version 0.1.0](itcves/ITCVE-1/0.1.0/README.md). ISI-1 defines the integrated foundation; the other programs evaluate narrower profiles within it. Results are specific to the executed profile and artifact combination. +The programs select versioned ITCVE-1 profiles. ISI-6 is an optional, separate compatibility selection with an executable evidence evaluator; native adapter admission remains separate. The latest ISI-4 lane uses the [native decision and shutdown profile](itcves/ITCVE-1/2.0.0/README.md); its [original production-wallet profile](itcves/ITCVE-1/1.0.0/README.md) remains separately reproducible; ISI-1 through ISI-3 retain [version 0.1.0](itcves/ITCVE-1/0.1.0/README.md). ISI-1 defines the integrated foundation; the other programs evaluate narrower profiles within it. Results are specific to the executed profile and artifact combination. [BSV Desktop 2.8.5](suts/intake/bsv-desktop-2.8.5.md) remains the reference desktop wallet candidate. [Yours Wallet 5.1.0](suts/intake/yours-wallet-5.1.0.md) is the first wallet with a retained experimental result. [Metanet Explorer 1.1.10](suts/intake/metanet-explorer-1.1.10-android.md) has a qualified Android artifact, four controlled-WAB native observations and an unresolved ToDo response boundary. [BSV Browser 1.6.1](suts/candidates/bsv-browser-1.6.1-source-candidate.md) has engineering evidence but awaits a publisher binary for admission. The canonical application artifact is the deterministic compiled `p2ppsr/todo-ts` web-root archive under `fixtures/artifacts/`. diff --git a/VERSION b/VERSION index 8f0916f7..a918a2aa 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.5.0 +0.6.0 diff --git a/bin/tpnil.mjs b/bin/tpnil.mjs index 27bf1719..e514d4c2 100644 --- a/bin/tpnil.mjs +++ b/bin/tpnil.mjs @@ -13,6 +13,7 @@ import { archiveRuntimeQualification, verifyRuntimeQualification } from '../src/ import { archiveReferenceQualification, verifyReferenceQualification } from '../src/reference-qualification.mjs'; import { archiveSynthesisStackQualification, verifySynthesisStackQualification } from '../src/synthesis-stack-qualification.mjs'; import { paymentMatrix } from '../src/payment-journeys.mjs'; +import { evaluateWalletProfileFiles } from '../src/wallet-profiles.mjs'; try { const [command, ...args] = process.argv.slice(2); @@ -22,6 +23,7 @@ try { const matrix = paymentMatrix(); result = args.length ? { ...matrix, cells: undefined } : matrix; } + else if (command === 'evaluate-wallet-profiles' && args.length === 3) result = evaluateWalletProfileFiles(...args); else if (command === 'qualify-standards' && args.length === 0) result = qualifyStandardFixtures(); else if (command === 'review-intake' && args.length === 2) { result = await reviewIntakeFile(args[0], args[1]); @@ -85,7 +87,7 @@ try { const actual = hash.digest('hex'); if (actual !== args[1]) throw new Error('Artifact digest mismatch'); result = { sha256: actual, size, verified: true }; - } else throw new Error('Usage: tpnil check | payment-matrix [--summary] | qualify-standards | demo [new-directory] | verify | replay | verify-prefix | verify-artifact | review-intake | run-qualification | verify-qualification | archive-native-qualification | verify-native-qualification | run-component-qualification | verify-component-qualification | archive-runtime-qualification | verify-runtime-qualification | archive-reference-qualification | verify-reference-qualification | archive-synthesis-stack | verify-synthesis-stack '); + } else throw new Error('Usage: tpnil check | evaluate-wallet-profiles | payment-matrix [--summary] | qualify-standards | demo [new-directory] | verify | replay | verify-prefix | verify-artifact | review-intake | run-qualification | verify-qualification | archive-native-qualification | verify-native-qualification | run-component-qualification | verify-component-qualification | archive-runtime-qualification | verify-runtime-qualification | archive-reference-qualification | verify-reference-qualification | archive-synthesis-stack | verify-synthesis-stack '); process.stdout.write(JSON.stringify(result, null, 2) + '\n'); } catch (error) { process.stderr.write(`TPNIL ERROR: ${error.message}\n`); diff --git a/docs/implementation-status.md b/docs/implementation-status.md index 5a59fd5e..f78d2204 100644 --- a/docs/implementation-status.md +++ b/docs/implementation-status.md @@ -1,6 +1,6 @@ # Implementation status -| Capability | Laboratory 0.5.0 | +| Capability | Laboratory 0.6.0 candidate | | --- | --- | | Reproducible compiled-webroot packaging | Implemented with fixed archive metadata; Python standard library | | Strict JSON contract validation, digest verification, deterministic equality oracle | Implemented for laboratory self-tests | @@ -9,8 +9,9 @@ | Native macOS qualification execution | Implemented on clean hosted Apple-silicon macOS VMs; two retained BSV Desktop repetitions pass installation, initialization, mainnet-mode, and local BRC-100 bridge assertions | | BRC-38/39 file portability | [Proposed profile](../programs/ISI-4/proposals/brc39-file-portability-0.1.0.md) and pinned synthetic envelope oracle; native cross-wallet file matrix remains unexecuted; ITCVE-1 2.0 V007 separately passes supported Go counterpart-provider replacement, which is not file export/import | | Native Send/Receive, PeerPay and Mountaintops | [Payment journey proposal](payment-journeys.md), deterministic coverage inventory and executable pinned application source regressions. ITCVE-1 1.3.0 separately implements controlled Message Box faults and independent payment outcomes through wallet APIs. Native payment UI drivers and the broader wallet payment-profile admission remain open; application source checks issue infrastructure findings only | -| ISI requirement catalogs and machine-readable vector plans | Four program families with versioned catalogs; the retained qualified ISI-4 4.0 result executes V001–V008. V007 supported counterpart replacement passes; V008 retains observed failures and one broader-coverage gate. Later candidate profiles have separate execution and admission records | -| Four ISI reports on admitted SUTs | First ISI-4 experimental result retained; ISI-1, ISI-2, and ISI-3 SUT reports remain pending | +| Optional UMP/profile semantics | [ISI-6 0.1.0](../programs/ISI-6/0.1.0/README.md) defines ten opt-in flows with a digest-bound engineering observation evaluator and executable synthetic regression pack. Native collector/platform/service admission and SUT evaluation remain pending; no ISI-4 vector, runner or retained result changes | +| ISI requirement catalogs and machine-readable vector plans | Five independently selected program families with versioned catalogs; the retained qualified ISI-4 4.0 result executes V001–V008. V007 supported counterpart replacement passes; V008 retains observed failures and one broader-coverage gate. Later candidate profiles have separate execution and admission records | +| ISI reports on admitted SUTs | First ISI-4 experimental result retained; ISI-1, ISI-2, and ISI-3 SUT reports remain pending | | Teranode regtest closure and mining | Implemented with pinned source and image digests; real PushDrop post and revision spends, conflict rejection, deterministic mining, retrieval, and full-stack restart recovery retain passing evidence | | Selectable Go service components | [ITCVE-1 1.1.0](../itcves/ITCVE-1/1.1.0/README.md): real Go Overlay Services, ChainTracks and Wallet Storage, all eight mixed combinations, source/module/binary identities, controlled fault/recovery checks and Linux CI. Engineering selection retains its claim; native admission is recorded separately below | | Native wallet with all-Go services | [ITCVE-1 1.2.0](../itcves/ITCVE-1/1.2.0/README.md) qualified for unchanged Yours Wallet 5.1.0 on native Linux/amd64. [Two retained repetitions](../journals/native-wallet-qualification/2026-11-06/yours-wallet-5.1.0-all-go/qualification.json) match: V001–V004 PASS, V005–V006 FAIL, V007–V008 BLOCKED. Exact artifacts, sandbox/trust, kernel isolation, mined ancestry, serialized redemption and cleanup verify offline. Other wallets and mixed closures require separate admission | diff --git a/docs/operator-quickstart.md b/docs/operator-quickstart.md index 505402ec..9fc99282 100644 --- a/docs/operator-quickstart.md +++ b/docs/operator-quickstart.md @@ -144,3 +144,7 @@ image, exact wallet/application artifacts and both raw records. Its `qualifiedEnvironment` finding is separate from the wallet's vector outcomes. Android, desktop HTTP and mixed Go/TypeScript closures require their own native admission and qualification evidence. + +## Optional UMP and profile semantics + +[ISI-6](../programs/ISI-6/0.1.0/README.md) runs independently of ISI-4. Generate a LAB_SELF_TEST_ONLY pack with `node scripts/create-isi6-self-test.mjs out/isi6-self-test`, or evaluate a frozen engineering observation pack with `node bin/tpnil.mjs evaluate-wallet-profiles plan.json record.json evidence-root`. Complete FAIL and BLOCKED outcomes are laboratory data; invalid evidence exits with code 2. Native adapters, exact artifacts/platforms and controlled services require separate admission before SUT findings. diff --git a/package.json b/package.json index 4d9f6ac6..ef789aad 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "tpnil", - "version": "0.5.0", + "version": "0.6.0", "private": true, "description": "Transaction Processing Network Interoperability Laboratory", "type": "module", diff --git a/programs/ISI-6/0.1.0/README.md b/programs/ISI-6/0.1.0/README.md new file mode 100644 index 00000000..f7a54011 --- /dev/null +++ b/programs/ISI-6/0.1.0/README.md @@ -0,0 +1,139 @@ +# ISI-6 0.1.0 — optional UMP and wallet profile semantics + +ISI-6 is an opt-in compatibility program for wallets that implement UMP-backed +accounts and multiple wallet profiles. Selection of `ump-profiles` requires all +ten vectors in [the catalog](catalog.json). ISI-4 acceptance, its ToDo flows, +BRC-100 method inventory and retained results are independent of ISI-6. A wallet +that does not select this program acquires no new ISI-4 failure or requirement. +These requirements are laboratory profile semantics, not additions to BRC-100. + +The executable observation evaluator is available. Native UI/protocol collection, +artifact/platform admission and controlled-service qualification remain separate; +[implementation status](../../../docs/implementation-status.md) records maturity. +The fixture oracle carries its own claim marker; a synthetic pack cannot be +promoted by changing only the plan mode. The evaluator emits `ENGINEERING_OBSERVATION_ONLY` for actual observation records +and `LAB_SELF_TEST_ONLY` for synthetic fixtures. It does not issue certification +or promote either claim to a SUT conformance finding. + +## Required flows and independent outcomes + +| Vector | Operation | Required outcome | +| --- | --- | --- | +| V001 | Create secondary | Intended UMP successor and profile inventory are independently visible; durable revision precedes success; creation preserves the existing selection. | +| V002 | Switch live | Fresh BRC-100 identity is secondary; UMP remains unchanged; old replies/caches are fenced, switches serialize and an active financial call excludes a switch. | +| V003 | Terminate/relaunch | Whole-process exit and relaunch retain selected ID, actual key, profile inventory and UMP without wallet logout. Home/background alone is insufficient. | +| V004 | Create third while secondary is active | Root mutation creates one original action; secondary remains active through creation and reopen without wallet logout. | +| V005 | Reconcile stale state | Startup/foreground discover the authenticated successor while preserving selection. Discovery failure retains state and refuses new UMP mutations instead of creating an account. | +| V006 | Fail a local save | Failure preserves committed state and either withholds APIs or serves the independently verified previous durable identity. New UMP writes remain refused; refresh commits state without a financial action. | +| V007 | Recover an uncertain update | Recovery binds root ownership, intended profiles, exact predecessor/outpoint and original receipt bytes. Replay reuses those bytes; admission without a receipt retains a pending checkpoint and creates no replacement. | +| V008 | Missing profile, failed builder, account replacement | Remote removal cannot silently serve root. Failed activation preserves the prior actual identity or refuses APIs. Delayed callbacks cannot overwrite a replacement account. | +| V009 | Explicit application re-login | A controlled application's fresh authenticated peer and server principal match secondary after explicit sign-out/sign-in, without a page reload, payment replay or account linking. | +| V010 | Mirrors, logout and background work | Canonical revision wins over a stale mirror; conflicting accounts are retained/refused. Logout disables mirrors, prevents old-copy login and defers background work. The declared root/profile notification identity contract is preserved. | + +`newActionIds` counts original UMP mutation operations; separately identified +permission and funding transactions retain their own provenance. V002 orders +admitted selection operations; pre-admission cancellations remain in the raw +concurrency evidence. Its cache predicate covers identity-bound reads. V006 +injects failure before the first selection-intent commit and permits either +unavailability or verified rollback. V007 separately makes the original outcome +unavailable after admission, which requires retaining the unresolved checkpoint. + +Profile names and UI labels are not identity oracles. A fixture oracle independently +binds the root and replacement account to canonical compressed secp256k1 public +keys before the run. Secondary and third profile bindings are outputs of an +independent observer over the newly published UMP records; their entropy is not +predetermined. The derived oracle binds the frozen plan and observer digest, +unchanged root/replacement identities and exact source UMP evidence digests. Root, secondary, third and a replacement account have distinct identities. +A frozen `optionalConsumers` inventory declares mirror and background consumers. +Absent consumers require independent absence-inventory evidence rather than a +new implementation; consumer-specific assertions are applied only when present. +The result retains that scope, and logout retention remains mandatory. +Use the controlled fixture's independently derived keys or an admitted equivalent +oracle, rather than copying expected values from the SUT response being tested. +The selected profile is a device preference; switching alone does not publish a +UMP transaction. A valid remote deletion requires an explicit unavailable state +and user selection. The frozen `notificationIdentityRole` may be root-scoped or profile-scoped; +the admitted wallet's declared contract controls that separate assertion. + +A website cookie may continue to identify the previous account after a wallet +switch. V009 evaluates fresh wallet identity and an explicit authenticated login +separately. A generic controlled BRC-103 fixture can replace any named commercial +application; the program does not require BitGenius or a third-party account. + +## Run and evidence contract + +Freeze the catalog, `tpnil-isi6-plan@0.1.0`, baseline fixture/observer, exact SUT bytes, +platform/device kind, service closure and fault schedule before collecting data. +The plan binds the catalog's TPNIL-JSON-1 hash, baseline fixture path/size/SHA-256, independent observer digest, +SUT/environment digests, network and selected program. Every run binds that plan +hash and its derived profile-oracle artifact. The baseline fixture uses +`tpnil-isi6-fixture@0.1.0` with `claim`, `root` and `replacement` records; each +contains `profile` and `identity`. The derived `tpnil-isi6-oracle@0.1.0` adds +`secondary`, `third`, `planHash`, `observerSha256` and `sources.secondary/third` +artifact descriptors. The v0.2 catalog/index schemas add ISI-6 while retaining the original v0.1 +schemas for historical records. ISI-6 identifiers and vector versions are permanent. + +The plan selects isolated controlled services and prohibits public broadcast. +Supported mainnet-format controlled-service configurations preserve the existing +ITCVE funding ancestry, header/Merkle, WAB, UMP and submission requirements. TTN +or another test network is a separately declared engineering configuration; it +cannot inherit mainnet, production-binary or physical-device admission. Personal +wallets, customer recovery data and public-mainnet spending are excluded. Normal +wallet trust and permission controls apply. Device execution requires a bounded, +costed work order under the laboratory's shared-device policy. + +A record supplies all ten case IDs. Each case references one normalized JSON +projection and separate role-labelled raw evidence files, all bound by size and +SHA-256. The catalog lists the required roles; V007 also retains raw original +AtomicBEEF under `atomic-beef`. Path traversal, symlinks, duplicate vector IDs, +unknown vectors, plan/catalog substitutions and changed bytes fail the evidence +contract. Absent cases, semantic facts or required raw evidence produce BLOCKED; +observed contradictions produce FAIL. The command exits successfully for completed +PASS/FAIL/BLOCKED evaluations and exits with code 2 for invalid evidence. + +```sh +node bin/tpnil.mjs evaluate-wallet-profiles plan.json record.json evidence-root +``` + +The plan and record schemas are +[wallet-profile-plan](../../../schemas/wallet-profile-plan.schema.json) and +[wallet-profile-record](../../../schemas/wallet-profile-record.schema.json). +The fixed predicates and normalized field names are in +[the evaluator](../../../src/wallet-profiles.mjs). State projections contain +`selected`, `identity`, `root`, `profiles`, `ump`, `revision`, `snapshot`, and +`ready`. Identity values are canonical compressed public keys; snapshot values +are SHA-256 only. Raw snapshots, wallet keys, OTPs and passwords remain in the +protected fixture custody system, outside shared observation packs. + +A normalized projection is not proof that a native action occurred. The collector +retains the source UI/protocol/lifecycle/storage/application evidence. An admitted +independent observer validates UMP owner/signature, lineage and transaction proof, +including that the original receipt spends its exact predecessor. This evaluator +checks digest integrity and semantic consistency of those projections; it does +not implement a second blockchain verifier, authenticate a collector, prove +prospective freezing, or establish device admission. Repeated fingerprints and +transaction counts require independent observer records, not SUT-authored counters. + +## Reproduction and regression + +Generate a new synthetic pack and evaluate it: + +```sh +node scripts/create-isi6-self-test.mjs out/isi6-self-test +node bin/tpnil.mjs evaluate-wallet-profiles out/isi6-self-test/plan.json out/isi6-self-test/record.json out/isi6-self-test +node --test test/wallet-profiles.test.mjs +``` + +Every generated raw fixture, including its non-transaction AtomicBEEF placeholder, +is labelled LAB_SELF_TEST_ONLY. Regression tests seed stale/default identity, +background-only restart, lost creation, failed save, duplicate/replacement action, +missing checkpoint, obsolete callback, cached authenticated peer, logout revival, +and missing/tampered evidence. Synthetic success tests the evaluator only. + +Native adapter qualification freezes supported creation/selection controls, +observed process-exit boundaries, BRC-100 transport, fault injection and independent +state/receipt readers before scored execution. Run two fresh repetitions on each +admitted wallet/platform combination and compare semantic outcomes. Retain every +failed attempt; a later correction creates a new result and references the old. +Wallet-specific UMP internals and native automation adapters can be added after +that admission without coupling this program to SQLite, Toolbox, or ISI-4. diff --git a/programs/ISI-6/0.1.0/catalog.json b/programs/ISI-6/0.1.0/catalog.json new file mode 100644 index 00000000..c47c479d --- /dev/null +++ b/programs/ISI-6/0.1.0/catalog.json @@ -0,0 +1,315 @@ +{ + "schemaVersion": "0.2.0", + "id": "ISI-6", + "version": "0.1.0", + "status": "draft", + "title": "Optional UMP and wallet profile continuity semantics", + "itcve": { + "id": "ITCVE-1", + "version": "1.0.0" + }, + "profile": "ump-profiles", + "vectors": [ + { + "id": "ISI-6-V001", + "version": "0.1.0", + "requirementId": "ISI-6-R001", + "title": "Create and durably retain a profile", + "origin": "laboratory-profile", + "reference": "programs/ISI-6/0.1.0/README.md", + "applicability": "Mandatory only after explicit selection of ISI-6 ump-profiles; independent of ISI-4 acceptance.", + "executable": true, + "preconditions": [ + "Digest-frozen SUT, platform, profile catalog, independent fixture oracle and controlled-service plan.", + "Isolated funded fixture identities; supported wallet controls and fault boundaries; no personal wallet or public-mainnet spending." + ], + "steps": [ + "Create a secondary profile through the supported wallet control, then query its published UMP and device state.", + "Retain the independent projections and raw role-specific evidence; evaluate the complete ISI-6 record." + ], + "expected": [ + "Creation preserves the selected root, publishes exactly the intended profile inventory and commits a durable snapshot before readiness." + ], + "evidence": [ + "native-ui", + "brc100", + "independent-ump", + "device-state" + ], + "blockers": [ + "Native adapter, artifact/platform and controlled-service admission are separate prerequisites to a SUT conformance finding." + ] + }, + { + "id": "ISI-6-V002", + "version": "0.1.0", + "requirementId": "ISI-6-R002", + "title": "Activate the actual profile identity live", + "origin": "laboratory-profile", + "reference": "programs/ISI-6/0.1.0/README.md", + "applicability": "Mandatory only after explicit selection of ISI-6 ump-profiles; independent of ISI-4 acceptance.", + "executable": true, + "preconditions": [ + "Digest-frozen SUT, platform, profile catalog, independent fixture oracle and controlled-service plan.", + "Isolated funded fixture identities; supported wallet controls and fault boundaries; no personal wallet or public-mainnet spending." + ], + "steps": [ + "Switch root to secondary while an old-profile request is held; query fresh identity and exercise concurrent controls.", + "Retain the independent projections and raw role-specific evidence; evaluate the complete ISI-6 record." + ], + "expected": [ + "The fresh BRC-100 key is the independently derived secondary key; the UMP is unchanged, old replies/caches are fenced and financial activity cannot race a switch." + ], + "evidence": [ + "native-ui", + "brc100", + "device-state", + "concurrency" + ], + "blockers": [ + "Native adapter, artifact/platform and controlled-service admission are separate prerequisites to a SUT conformance finding." + ] + }, + { + "id": "ISI-6-V003", + "version": "0.1.0", + "requirementId": "ISI-6-R003", + "title": "Retain selection across process termination", + "origin": "laboratory-profile", + "reference": "programs/ISI-6/0.1.0/README.md", + "applicability": "Mandatory only after explicit selection of ISI-6 ump-profiles; independent of ISI-4 acceptance.", + "executable": true, + "preconditions": [ + "Digest-frozen SUT, platform, profile catalog, independent fixture oracle and controlled-service plan.", + "Isolated funded fixture identities; supported wallet controls and fault boundaries; no personal wallet or public-mainnet spending." + ], + "steps": [ + "Force-stop the complete wallet process, prove its exit, relaunch and query identity without signing the wallet out.", + "Retain the independent projections and raw role-specific evidence; evaluate the complete ISI-6 record." + ], + "expected": [ + "The selected secondary identity, profile inventory and UMP survive; a background/Home transition alone is insufficient." + ], + "evidence": [ + "native-ui", + "brc100", + "device-state", + "process-lifecycle" + ], + "blockers": [ + "Native adapter, artifact/platform and controlled-service admission are separate prerequisites to a SUT conformance finding." + ] + }, + { + "id": "ISI-6-V004", + "version": "0.1.0", + "requirementId": "ISI-6-R004", + "title": "Mutate root metadata while a secondary remains selected", + "origin": "laboratory-profile", + "reference": "programs/ISI-6/0.1.0/README.md", + "applicability": "Mandatory only after explicit selection of ISI-6 ump-profiles; independent of ISI-4 acceptance.", + "executable": true, + "preconditions": [ + "Digest-frozen SUT, platform, profile catalog, independent fixture oracle and controlled-service plan.", + "Isolated funded fixture identities; supported wallet controls and fault boundaries; no personal wallet or public-mainnet spending." + ], + "steps": [ + "Create a third profile while secondary is active, without wallet logout; inspect the new UMP independently and reopen.", + "Retain the independent projections and raw role-specific evidence; evaluate the complete ISI-6 record." + ], + "expected": [ + "One original update adds the third profile and preserves the selected secondary identity and root ownership." + ], + "evidence": [ + "native-ui", + "brc100", + "independent-ump", + "device-state" + ], + "blockers": [ + "Native adapter, artifact/platform and controlled-service admission are separate prerequisites to a SUT conformance finding." + ] + }, + { + "id": "ISI-6-V005", + "version": "0.1.0", + "requirementId": "ISI-6-R005", + "title": "Reconcile a stale snapshot without losing intent", + "origin": "laboratory-profile", + "reference": "programs/ISI-6/0.1.0/README.md", + "applicability": "Mandatory only after explicit selection of ISI-6 ump-profiles; independent of ISI-4 acceptance.", + "executable": true, + "preconditions": [ + "Digest-frozen SUT, platform, profile catalog, independent fixture oracle and controlled-service plan.", + "Isolated funded fixture identities; supported wallet controls and fault boundaries; no personal wallet or public-mainnet spending." + ], + "steps": [ + "Restore the admitted stale predecessor, discover a valid successor at startup and foreground; separately interrupt discovery.", + "Retain the independent projections and raw role-specific evidence; evaluate the complete ISI-6 record." + ], + "expected": [ + "Verified reconciliation preserves secondary selection; failed discovery retains recoverable state and refuses new UMP mutations instead of creating an account." + ], + "evidence": [ + "device-state", + "independent-ump", + "brc100", + "fault-injection" + ], + "blockers": [ + "Native adapter, artifact/platform and controlled-service admission are separate prerequisites to a SUT conformance finding." + ] + }, + { + "id": "ISI-6-V006", + "version": "0.1.0", + "requirementId": "ISI-6-R006", + "title": "Refuse and recover an unsuccessful durable save", + "origin": "laboratory-profile", + "reference": "programs/ISI-6/0.1.0/README.md", + "applicability": "Mandatory only after explicit selection of ISI-6 ump-profiles; independent of ISI-4 acceptance.", + "executable": true, + "preconditions": [ + "Digest-frozen SUT, platform, profile catalog, independent fixture oracle and controlled-service plan.", + "Isolated funded fixture identities; supported wallet controls and fault boundaries; no personal wallet or public-mainnet spending." + ], + "steps": [ + "Inject local commit failure during a switch/update, query public APIs, remove the fault and explicitly refresh.", + "Retain the independent projections and raw role-specific evidence; evaluate the complete ISI-6 record." + ], + "expected": [ + "A failed save preserves committed state, reports the operation rejected and either withholds APIs or serves only the independently verified prior durable identity. New UMP writes remain refused; explicit local-save retry creates no financial action." + ], + "evidence": [ + "native-ui", + "device-state", + "brc100", + "fault-injection" + ], + "blockers": [ + "Native adapter, artifact/platform and controlled-service admission are separate prerequisites to a SUT conformance finding." + ] + }, + { + "id": "ISI-6-V007", + "version": "0.1.0", + "requirementId": "ISI-6-R007", + "title": "Recover the original uncertain UMP update", + "origin": "laboratory-profile", + "reference": "programs/ISI-6/0.1.0/README.md", + "applicability": "Mandatory only after explicit selection of ISI-6 ump-profiles; independent of ISI-4 acceptance.", + "executable": true, + "preconditions": [ + "Digest-frozen SUT, platform, profile catalog, independent fixture oracle and controlled-service plan.", + "Isolated funded fixture identities; supported wallet controls and fault boundaries; no personal wallet or public-mainnet spending." + ], + "steps": [ + "Interrupt after action admission and after original signed receipt retention; reconcile or re-publish that same receipt, then repeat recovery.", + "Retain the independent projections and raw role-specific evidence; evaluate the complete ISI-6 record." + ], + "expected": [ + "Ownership, predecessor, intended profiles and exact receipt bind recovery; no replacement action is created. Admission without a receipt stays pending until the original outcome is established." + ], + "evidence": [ + "independent-ump", + "device-state", + "fault-injection", + "transaction-receipt", + "atomic-beef" + ], + "blockers": [ + "Native adapter, artifact/platform and controlled-service admission are separate prerequisites to a SUT conformance finding." + ] + }, + { + "id": "ISI-6-V008", + "version": "0.1.0", + "requirementId": "ISI-6-R008", + "title": "Handle missing profiles and obsolete sessions explicitly", + "origin": "laboratory-profile", + "reference": "programs/ISI-6/0.1.0/README.md", + "applicability": "Mandatory only after explicit selection of ISI-6 ump-profiles; independent of ISI-4 acceptance.", + "executable": true, + "preconditions": [ + "Digest-frozen SUT, platform, profile catalog, independent fixture oracle and controlled-service plan.", + "Isolated funded fixture identities; supported wallet controls and fault boundaries; no personal wallet or public-mainnet spending." + ], + "steps": [ + "Remove the selected profile remotely, fail wallet construction, then replace the account while the previous identity read is delayed.", + "Retain the independent projections and raw role-specific evidence; evaluate the complete ISI-6 record." + ], + "expected": [ + "A missing profile cannot silently become root; a failed builder preserves identity or withholds APIs; late callbacks cannot overwrite the replacement account." + ], + "evidence": [ + "native-ui", + "brc100", + "device-state", + "fault-injection", + "concurrency" + ], + "blockers": [ + "Native adapter, artifact/platform and controlled-service admission are separate prerequisites to a SUT conformance finding." + ] + }, + { + "id": "ISI-6-V009", + "version": "0.1.0", + "requirementId": "ISI-6-R009", + "title": "Authenticate the selected identity on explicit application login", + "origin": "laboratory-profile", + "reference": "programs/ISI-6/0.1.0/README.md", + "applicability": "Mandatory only after explicit selection of ISI-6 ump-profiles; independent of ISI-4 acceptance.", + "executable": true, + "preconditions": [ + "Digest-frozen SUT, platform, profile catalog, independent fixture oracle and controlled-service plan.", + "Isolated funded fixture identities; supported wallet controls and fault boundaries; no personal wallet or public-mainnet spending." + ], + "steps": [ + "Use a controlled BRC-103 application with root, switch to secondary, then explicitly sign out and sign in on the same page.", + "Retain the independent projections and raw role-specific evidence; evaluate the complete ISI-6 record." + ], + "expected": [ + "The resulting server principal and peer belong to secondary, prior session is revoked, and neither payment replay nor account linking occurs. A cookie alone is not a wallet identity oracle." + ], + "evidence": [ + "native-ui", + "brc100", + "application-auth" + ], + "blockers": [ + "Native adapter, artifact/platform and controlled-service admission are separate prerequisites to a SUT conformance finding." + ] + }, + { + "id": "ISI-6-V010", + "version": "0.1.0", + "requirementId": "ISI-6-R010", + "title": "Prevent stale mirror and background account restoration", + "origin": "laboratory-profile", + "reference": "programs/ISI-6/0.1.0/README.md", + "applicability": "Mandatory only after explicit selection of ISI-6 ump-profiles; independent of ISI-4 acceptance.", + "executable": true, + "preconditions": [ + "Digest-frozen SUT, platform, profile catalog, independent fixture oracle and controlled-service plan.", + "Isolated funded fixture identities; supported wallet controls and fault boundaries; no personal wallet or public-mainnet spending." + ], + "steps": [ + "Establish divergent legacy/mirror copies; reconcile, log out, restart and deliver a background event under the declared notification identity contract.", + "Retain the independent projections and raw role-specific evidence; evaluate the complete ISI-6 record." + ], + "expected": [ + "Canonical revision wins; conflicting accounts are retained/refused, logout tombstones prevent old-copy login and background work defers disabled state." + ], + "evidence": [ + "device-state", + "process-lifecycle", + "background-consumer", + "fault-injection" + ], + "blockers": [ + "Native adapter, artifact/platform and controlled-service admission are separate prerequisites to a SUT conformance finding." + ] + } + ] +} diff --git a/programs/README.md b/programs/README.md index 60a3c6a8..df1e970a 100644 --- a/programs/README.md +++ b/programs/README.md @@ -1,6 +1,6 @@ # Program register -TPNIL defines four programs. [index.json](index.json) selects their current versions; earlier definitions remain retained. +TPNIL defines five independently selected programs. [index.json](index.json) selects their current versions; earlier definitions remain retained. | Program | Scope | Initial profile | | --- | --- | --- | @@ -8,9 +8,12 @@ TPNIL defines four programs. [index.json](index.json) selects their current vers | [ISI-2](ISI-2/0.1.0/README.md) | Overlay synchronization, submission, and lookup | `overlay-http-sync` | | [ISI-3](ISI-3/0.1.0/README.md) | Remote Wallet Storage synchronization and HTTP boundary | `storage-http-sync` | | [ISI-4](ISI-4/1.0.0/README.md) | Production BRC-100 wallet/application interoperability | `production-wallet-todo` | +| [ISI-6](ISI-6/0.1.0/README.md) | Optional UMP and wallet profile continuity semantics | `ump-profiles` | Program identifiers are permanent. ISI-1 defines full integration; the other programs select versioned profiles of ITCVE-1. ISI-4 1.0.0 supersedes mandatory wallet regtest admission with production-fidelity intake. -Each `catalog.json` is a machine-validated design catalog containing requirement IDs, origins, references, vector steps, expected observations, evidence, and unresolved dependencies. Initial cases are marked `executable: false`. Adoption requires clause-level references, exact fixtures, independent executable predicates, admitted component digests, and qualified adapters. +Each `catalog.json` is a machine-validated design catalog containing requirement IDs, origins, references, vector steps, expected observations, evidence, and unresolved dependencies. Design-only cases are marked `executable: false`. ISI-6 has an executable observation evaluator; its native adapter and SUT admission remain separate. Adoption requires clause-level references, exact fixtures, independent executable predicates, admitted component digests, and qualified adapters. The `production-wallet-todo` profile covers the application's wallet interactions. A comprehensive BRC-100 profile additionally requires the [complete boundary inventory](../docs/boundary-inventories.md). + +ISI-6 is explicitly opt-in and adds no ISI-4 acceptance requirement. Its digest-bound evaluator and synthetic regressions are described in [the profile](ISI-6/0.1.0/README.md). diff --git a/programs/index.json b/programs/index.json index 3ffe0943..c7f72b3f 100644 --- a/programs/index.json +++ b/programs/index.json @@ -1,5 +1,5 @@ { - "schemaVersion": "0.1.0", + "schemaVersion": "0.2.0", "programs": [ { "id": "ISI-1", @@ -16,6 +16,10 @@ { "id": "ISI-4", "version": "1.0.0" + }, + { + "id": "ISI-6", + "version": "0.1.0" } ] } diff --git a/schemas/README.md b/schemas/README.md index 08883c1e..be0cccf0 100644 --- a/schemas/README.md +++ b/schemas/README.md @@ -13,3 +13,5 @@ Canonical encoding **TPNIL-JSON-1** is UTF-8 JSON without trailing whitespace; o `component-qualification-plan.schema.json` binds an external source revision, an argument-vector command, and semantic output assertions. The runner retains stdout, stderr, source state, tool versions, and the replayable result as content-addressed objects. These findings qualify supporting infrastructure only. ISI-4 wallet-run and native-observation records use explicit `tpnil-isi4-*` schema identifiers and the verifier in `src/sut-evidence.mjs`. It checks the claim and program boundary, all eight vector outcomes, the exact evidence file set, sizes and SHA-256 digests. The wallet runner additionally compares the semantic projection across clean repetitions. + +The additive `catalog-v2` and `program-index-v2` contracts use schemaVersion `0.2.0` and register optional ISI-6; original v0.1 contracts remain unchanged and dispatched by version. `wallet-profile-plan` and `wallet-profile-record` bind ISI-6 engineering observations to a frozen catalog/oracle and exact evidence digests. The evaluator cannot issue SUT conformance or certification. diff --git a/schemas/catalog-v2.schema.json b/schemas/catalog-v2.schema.json new file mode 100644 index 00000000..baa35770 --- /dev/null +++ b/schemas/catalog-v2.schema.json @@ -0,0 +1,162 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "title": "catalog", + "type": "object", + "properties": { + "schemaVersion": { + "const": "0.2.0" + }, + "id": { + "enum": [ + "ISI-1", + "ISI-2", + "ISI-3", + "ISI-4", + "ISI-6" + ] + }, + "version": { + "type": "string", + "pattern": "^(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)$" + }, + "status": { + "const": "draft" + }, + "title": { + "type": "string", + "minLength": 1 + }, + "itcve": { + "type": "object", + "properties": { + "id": { + "type": "string", + "minLength": 1 + }, + "version": { + "type": "string", + "pattern": "^(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)$" + } + }, + "required": [ + "id", + "version" + ], + "additionalProperties": false + }, + "profile": { + "type": "string", + "minLength": 1 + }, + "vectors": { + "type": "array", + "items": { + "type": "object", + "properties": { + "id": { + "type": "string", + "minLength": 1 + }, + "version": { + "type": "string", + "pattern": "^(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)$" + }, + "requirementId": { + "type": "string", + "minLength": 1 + }, + "title": { + "type": "string", + "minLength": 1 + }, + "origin": { + "enum": [ + "standard", + "laboratory-profile", + "open-interpretation" + ] + }, + "reference": { + "type": "string", + "minLength": 1 + }, + "applicability": { + "type": "string", + "minLength": 1 + }, + "executable": { + "type": "boolean" + }, + "preconditions": { + "type": "array", + "items": { + "type": "string", + "minLength": 1 + }, + "minItems": 1 + }, + "steps": { + "type": "array", + "items": { + "type": "string", + "minLength": 1 + }, + "minItems": 1 + }, + "expected": { + "type": "array", + "items": { + "type": "string", + "minLength": 1 + }, + "minItems": 1 + }, + "evidence": { + "type": "array", + "items": { + "type": "string", + "minLength": 1 + }, + "minItems": 1 + }, + "blockers": { + "type": "array", + "items": { + "type": "string", + "minLength": 1 + }, + "minItems": 1 + } + }, + "required": [ + "id", + "version", + "requirementId", + "title", + "origin", + "reference", + "applicability", + "executable", + "preconditions", + "steps", + "expected", + "evidence", + "blockers" + ], + "additionalProperties": false + }, + "minItems": 1 + } + }, + "required": [ + "schemaVersion", + "id", + "version", + "status", + "title", + "itcve", + "profile", + "vectors" + ], + "additionalProperties": false +} diff --git a/schemas/program-index-v2.schema.json b/schemas/program-index-v2.schema.json new file mode 100644 index 00000000..640fc2da --- /dev/null +++ b/schemas/program-index-v2.schema.json @@ -0,0 +1,41 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "type": "object", + "properties": { + "schemaVersion": { + "const": "0.2.0" + }, + "programs": { + "type": "array", + "items": { + "type": "object", + "properties": { + "id": { + "enum": [ + "ISI-1", + "ISI-2", + "ISI-3", + "ISI-4", + "ISI-6" + ] + }, + "version": { + "type": "string", + "pattern": "^(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)$" + } + }, + "required": [ + "id", + "version" + ], + "additionalProperties": false + }, + "minItems": 1 + } + }, + "required": [ + "schemaVersion", + "programs" + ], + "additionalProperties": false +} diff --git a/schemas/wallet-profile-plan.schema.json b/schemas/wallet-profile-plan.schema.json new file mode 100644 index 00000000..d272d53c --- /dev/null +++ b/schemas/wallet-profile-plan.schema.json @@ -0,0 +1,123 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "type": "object", + "properties": { + "schema": { + "const": "tpnil-isi6-plan@0.1.0" + }, + "program": { + "const": "ISI-6@0.1.0" + }, + "selection": { + "const": "ump-profiles" + }, + "mode": { + "enum": [ + "self-test", + "engineering" + ] + }, + "profileHash": { + "type": "string", + "pattern": "^[0-9a-f]{64}$" + }, + "sutSha256": { + "type": "string", + "pattern": "^[0-9a-f]{64}$" + }, + "environmentSha256": { + "type": "string", + "pattern": "^[0-9a-f]{64}$" + }, + "platform": { + "type": "string", + "minLength": 1 + }, + "deviceKind": { + "enum": [ + "physical", + "virtual", + "simulator", + "headless" + ] + }, + "network": { + "enum": [ + "main", + "testnet", + "ttn" + ] + }, + "publicBroadcast": { + "const": false + }, + "optionalConsumers": { + "type": "object", + "properties": { + "mirrors": { + "type": "boolean" + }, + "background": { + "type": "boolean" + } + }, + "required": [ + "mirrors", + "background" + ], + "additionalProperties": false + }, + "notificationIdentityRole": { + "enum": [ + "root", + "active-profile" + ] + }, + "fixtureOracle": { + "type": "object", + "properties": { + "path": { + "type": "string", + "minLength": 1 + }, + "sha256": { + "type": "string", + "pattern": "^[0-9a-f]{64}$" + }, + "size": { + "type": "integer", + "minimum": 1, + "maximum": 16777216 + } + }, + "required": [ + "path", + "sha256", + "size" + ], + "additionalProperties": false + }, + "oracleObserverSha256": { + "type": "string", + "pattern": "^[0-9a-f]{64}$" + } + }, + "required": [ + "schema", + "program", + "selection", + "mode", + "profileHash", + "fixtureOracle", + "sutSha256", + "environmentSha256", + "platform", + "deviceKind", + "network", + "publicBroadcast", + "optionalConsumers", + "notificationIdentityRole", + "oracleObserverSha256" + ], + "additionalProperties": false +} diff --git a/schemas/wallet-profile-record.schema.json b/schemas/wallet-profile-record.schema.json new file mode 100644 index 00000000..281c4fb6 --- /dev/null +++ b/schemas/wallet-profile-record.schema.json @@ -0,0 +1,132 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "type": "object", + "properties": { + "schema": { + "const": "tpnil-isi6-record@0.1.0" + }, + "program": { + "const": "ISI-6@0.1.0" + }, + "planHash": { + "type": "string", + "pattern": "^[0-9a-f]{64}$" + }, + "startedAt": { + "type": "string", + "minLength": 1 + }, + "finishedAt": { + "type": "string", + "minLength": 1 + }, + "cases": { + "type": "array", + "items": { + "type": "object", + "properties": { + "id": { + "type": "string", + "pattern": "^ISI-6-V[0-9]{3}$" + }, + "projection": { + "type": "object", + "properties": { + "path": { + "type": "string", + "minLength": 1 + }, + "sha256": { + "type": "string", + "pattern": "^[0-9a-f]{64}$" + }, + "size": { + "type": "integer", + "minimum": 1, + "maximum": 16777216 + } + }, + "required": [ + "path", + "sha256", + "size" + ], + "additionalProperties": false + }, + "evidence": { + "type": "array", + "items": { + "type": "object", + "properties": { + "path": { + "type": "string", + "minLength": 1 + }, + "sha256": { + "type": "string", + "pattern": "^[0-9a-f]{64}$" + }, + "size": { + "type": "integer", + "minimum": 1, + "maximum": 16777216 + }, + "role": { + "type": "string", + "minLength": 1 + } + }, + "required": [ + "path", + "sha256", + "size", + "role" + ], + "additionalProperties": false + } + } + }, + "required": [ + "id", + "projection", + "evidence" + ], + "additionalProperties": false + } + }, + "oracle": { + "type": "object", + "properties": { + "path": { + "type": "string", + "minLength": 1 + }, + "sha256": { + "type": "string", + "pattern": "^[0-9a-f]{64}$" + }, + "size": { + "type": "integer", + "minimum": 1, + "maximum": 16777216 + } + }, + "required": [ + "path", + "sha256", + "size" + ], + "additionalProperties": false + } + }, + "required": [ + "schema", + "program", + "planHash", + "startedAt", + "finishedAt", + "cases", + "oracle" + ], + "additionalProperties": false +} diff --git a/scripts/create-isi6-self-test.mjs b/scripts/create-isi6-self-test.mjs new file mode 100644 index 00000000..903b12b4 --- /dev/null +++ b/scripts/create-isi6-self-test.mjs @@ -0,0 +1,7 @@ +import path from 'node:path'; +import { createWalletProfileSelfTest } from '../src/wallet-profile-self-test.mjs'; +import { evaluateWalletProfiles } from '../src/wallet-profiles.mjs'; +const output = process.argv[2]; +if (!output || process.argv.length !== 3) throw new Error('Usage: node scripts/create-isi6-self-test.mjs '); +const fixture = createWalletProfileSelfTest(path.resolve(output)); +process.stdout.write(JSON.stringify(evaluateWalletProfiles(fixture.plan, fixture.record, fixture.directory), null, 2) + '\n'); diff --git a/src/core.mjs b/src/core.mjs index 49222e7e..50923b52 100644 --- a/src/core.mjs +++ b/src/core.mjs @@ -5,7 +5,7 @@ import { canonical, digest, hashJson, parseJson, validate, equal } from './json. export const ROOT = path.dirname(path.dirname(fileURLToPath(import.meta.url))); export const VERSION = '0.1.0'; // Stable self-test and evidence protocol. -export const RELEASE_VERSION = '0.5.0'; +export const RELEASE_VERSION = '0.6.0'; export const readJson = file => parseJson(fs.readFileSync(file)); const schemas = new Map(); export function checkSchema(name, value) { @@ -64,7 +64,7 @@ export function evaluate(plan, observations) { return { schemaVersion: VERSION, claim: 'LAB_SELF_TEST_ONLY', planHash: hashJson(plan), observationsHash: hashJson(observations), overall, outcomes }; } export function checkCatalog(catalog) { - checkSchema('catalog', catalog); + checkSchema(catalog.schemaVersion === '0.2.0' ? 'catalog-v2' : 'catalog', catalog); unique(catalog.vectors.map(v => v.id), 'vector ID'); unique(catalog.vectors.map(v => v.requirementId), 'requirement ID'); for (const v of catalog.vectors) { @@ -74,9 +74,9 @@ export function checkCatalog(catalog) { } export function checkRepository() { const index = readJson(path.join(ROOT, 'programs/index.json')); - checkSchema('program-index', index); + checkSchema(index.schemaVersion === '0.2.0' ? 'program-index-v2' : 'program-index', index); unique(index.programs.map(p => p.id), 'program ID'); - if (index.programs.length !== 4) throw new Error('Expected four registered programs'); + if (index.programs.length !== (index.schemaVersion === '0.2.0' ? 5 : 4)) throw new Error('Incomplete registered program set'); const catalogs = index.programs.map(p => readJson(path.join(ROOT, 'programs', p.id, p.version, 'catalog.json'))); const version = fs.readFileSync(path.join(ROOT, 'VERSION'), 'utf8').trim(); if (version !== RELEASE_VERSION || readJson(path.join(ROOT, 'package.json')).version !== RELEASE_VERSION) throw new Error('Laboratory version mismatch'); diff --git a/src/wallet-profile-self-test.mjs b/src/wallet-profile-self-test.mjs new file mode 100644 index 00000000..2721d201 --- /dev/null +++ b/src/wallet-profile-self-test.mjs @@ -0,0 +1,43 @@ +import fs from 'node:fs'; +import path from 'node:path'; +import { createECDH } from 'node:crypto'; +import { ROOT, readJson } from './core.mjs'; +import { digest, hashJson } from './json.mjs'; +import { WALLET_PROFILE_CATALOG } from './wallet-profiles.mjs'; + +/** Synthetic oracle exercise; none of these projections are native observations. */ +export function createWalletProfileSelfTest(directory) { + if (fs.existsSync(directory)) throw new Error('Self-test output already exists'); + fs.mkdirSync(directory, { recursive: true, mode: 0o700 }); + const put = (name, value) => { + const bytes = Buffer.isBuffer(value) ? value : Buffer.from(JSON.stringify(value, null, 2) + '\n'); + fs.writeFileSync(path.join(directory, name), bytes, { mode: 0o600, flag: 'wx' }); + return { path: name, sha256: digest(bytes), size: bytes.length }; + }; + const key = number => { const ec = createECDH('secp256k1'); ec.setPrivateKey(Buffer.from(number.toString(16).padStart(64, '0'), 'hex')); return ec.getPublicKey('hex', 'compressed'); }; + const roles = ['root', 'secondary', 'third', 'replacement']; + const oracle = { schema: 'tpnil-isi6-oracle@0.1.0', claim: 'LAB_SELF_TEST_ONLY', ...Object.fromEntries(roles.map((role, index) => [role, { profile: role, identity: key(index + 1) }])) }; + const state = (role = 'secondary', revision = 2, count = 2, ump = '02'.repeat(32) + '.0') => ({ selected: role, identity: oracle[role].identity, root: oracle.root.identity, profiles: roles.slice(0, count), ump, revision, snapshot: digest(`synthetic-snapshot-${revision}`), ready: true }); + const before = state(), after = state('secondary', 3, 3, '03'.repeat(32) + '.0'); + const beef = Buffer.from('LAB_SELF_TEST_ONLY synthetic AtomicBEEF placeholder'); + const projections = [ + { before: state('root', 1, 1, '01'.repeat(32) + '.0'), after: state('root'), published: { ump: before.ump, profiles: before.profiles }, successRevision: 2 }, + { before: state('root'), after: before, freshIdentity: oracle.secondary.identity, oldReply: { status: 'rejected', generation: 1 }, newGeneration: 2, requestedSwitches: ['root', 'secondary'], activatedSwitches: ['root', 'secondary'], busyFinancialSwitch: 'refused', oldCacheReused: false }, + { before, after: before, lifecycle: { kind: 'force-stop', processExited: true, relaunchObserved: true }, walletLogoutCount: 0 }, + { before, after, reopened: after, published: { ump: after.ump, profiles: after.profiles }, newActionIds: ['original-third'], walletLogoutCount: 0 }, + { stale: before, reconciled: after, authoritative: { ump: after.ump, profiles: after.profiles }, unavailable: { newUmpMutation: 'refused', newAccountCreated: false, retainedSnapshot: before.snapshot } }, + { before, afterFailure: { ...before, ready: false }, afterRetry: { ...before, revision: 3 }, failureOutcome: 'unavailable', writeResult: 'rejected', afterFailureAccess: { identityCall: 'rejected', umpMutation: 'rejected' }, newActionIds: [] }, + { before, after, receipt: { ownerIdentity: oracle.root.identity, predecessor: before.ump, outpoint: after.ump, profiles: after.profiles }, originalReceiptSha256: digest(beef), replayedReceiptSha256s: [digest(beef), digest(beef)], originalActionId: 'original-update', newActionIds: ['original-update'], withoutReceipt: { originalOutcome: 'unavailable', status: 'pending', newActionCount: 0, checkpointRetained: true } }, + { removed: { selected: 'secondary', ready: false, identityCall: 'rejected', status: 'profile-unavailable' }, failedBuild: { ready: false, identity: oracle.secondary.identity, selected: 'secondary', identityCall: 'rejected' }, replacement: { identity: oracle.replacement.identity }, lateCallback: { served: false }, afterLateCallback: { identity: oracle.replacement.identity } }, + { walletIdentity: oracle.secondary.identity, initialServerIdentity: oracle.root.identity, explicitLogin: { serverIdentity: oracle.secondary.identity, peerIdentity: oracle.secondary.identity, userId: 'secondary-user' }, rootUserId: 'root-user', secondaryUserId: 'secondary-user', priorSessionStatus: 'revoked', pageReloadCount: 0, paymentReplayCount: 0, accountLinksCreated: 0 }, + { canonicalRevision: 3, selectedRevision: 3, staleMirrorRevision: 1, conflictingAccounts: 'retained-and-refused', logout: { mirrorStatus: 'disabled', reopenedAuthenticated: false, oldSnapshotRestored: false }, backgroundAfterLogout: 'deferred', notificationIdentityBefore: oracle.root.identity, notificationIdentityAfterSwitch: oracle.root.identity, notificationCrossAccountAccepted: false, consumerInventory: { mirrors: true, background: true } } + ]; + const catalog = readJson(path.join(ROOT, WALLET_PROFILE_CATALOG)); + const plan = { schema: 'tpnil-isi6-plan@0.1.0', program: 'ISI-6@0.1.0', selection: 'ump-profiles', mode: 'self-test', profileHash: hashJson(catalog), fixtureOracle: put('fixture-oracle.json', { schema: 'tpnil-isi6-fixture@0.1.0', claim: 'LAB_SELF_TEST_ONLY', root: oracle.root, replacement: oracle.replacement }), oracleObserverSha256: digest('synthetic independent UMP observer'), sutSha256: digest('synthetic SUT'), environmentSha256: digest('synthetic controlled environment'), platform: 'synthetic-unit-fixture', deviceKind: 'headless', network: 'main', publicBroadcast: false, optionalConsumers: { mirrors: true, background: true }, notificationIdentityRole: 'root' }; + const record = { schema: 'tpnil-isi6-record@0.1.0', program: 'ISI-6@0.1.0', planHash: hashJson(plan), startedAt: '2026-11-16T00:00:00.000Z', finishedAt: '2026-11-16T00:00:01.000Z', cases: catalog.vectors.map((vector, index) => ({ id: vector.id, projection: put(`${vector.id}.json`, projections[index]), evidence: vector.evidence.map(role => ({ role, ...put(`${vector.id}-${role}.raw`, role === 'atomic-beef' ? beef : Buffer.from(`LAB_SELF_TEST_ONLY ${vector.id} ${role}`)) })) })) }; + const source = number => { const { role: _role, ...artifact } = record.cases[number - 1].evidence.find(item => item.role === 'independent-ump'); return artifact; }; + Object.assign(oracle, { planHash: record.planHash, observerSha256: plan.oracleObserverSha256, sources: { secondary: source(1), third: source(4) } }); + record.oracle = put('derived-oracle.json', oracle); + put('plan.json', plan); put('record.json', record); + return { plan, record, oracle, directory }; +} diff --git a/src/wallet-profiles.mjs b/src/wallet-profiles.mjs new file mode 100644 index 00000000..d5a9576e --- /dev/null +++ b/src/wallet-profiles.mjs @@ -0,0 +1,173 @@ +import fs from 'node:fs'; +import path from 'node:path'; +import { ECDH } from 'node:crypto'; +import { ROOT, artifactBytes, checkCatalog, checkSchema, readJson, unique } from './core.mjs'; +import { canonical, hashJson, parseJson } from './json.mjs'; + +export const WALLET_PROFILE_CATALOG = 'programs/ISI-6/0.1.0/catalog.json'; +const same = (a, b) => canonical(a) === canonical(b); +const list = (a, b) => Array.isArray(a) && Array.isArray(b) && new Set(a).size === a.length && new Set(b).size === b.length && same([...a].sort(), [...b].sort()); +const field = (value, key) => key.split('.').reduce((v, k) => v != null && Object.hasOwn(v, k) ? v[k] : undefined, value); +const stateFields = ['selected', 'identity', 'root', 'profiles', 'ump', 'revision', 'snapshot', 'ready']; +const hashPattern = /^[0-9a-f]{64}$/; +const outpointPattern = /^[0-9a-f]{64}\.(0|[1-9][0-9]*)$/; +function oracleRecord(value) { + const roles = ['root', 'secondary', 'third', 'replacement']; + if (value.schema !== 'tpnil-isi6-oracle@0.1.0' || Object.keys(value).sort().join() !== ['schema', 'claim', 'planHash', 'observerSha256', 'sources', ...roles].sort().join() || !['LAB_SELF_TEST_ONLY', 'ENGINEERING_OBSERVATION_ONLY'].includes(value.claim)) throw new Error('Invalid profile fixture oracle'); + for (const role of roles) { + const item = value[role]; + if (!item || Object.keys(item).sort().join() !== 'identity,profile' || typeof item.profile !== 'string' || !item.profile || !/^(02|03)[0-9a-f]{64}$/.test(item.identity)) throw new Error('Invalid profile fixture identity'); + ECDH.convertKey(item.identity, 'secp256k1', 'hex', 'hex', 'compressed'); + } + unique(roles.map(role => value[role].profile), 'fixture profile'); + unique(roles.map(role => value[role].identity), 'fixture identity'); + return value; +} +function caseOracle(vector, observation, oracle, evidence, plan) { + const assertions = []; + const check = (name, paths, predicate) => { + const values = paths.map(key => field(observation, key)); + let status = 'BLOCKED'; + if (values.every(value => value !== undefined)) { + try { status = predicate(...values) ? 'PASS' : 'FAIL'; } catch { status = 'FAIL'; } + } + assertions.push({ id: `${vector.id}/${name}`, status }); + }; + const compare = (name, paths) => check(name, paths, (...values) => values.every(value => same(value, values[0]))); + const state = (name, role, ready = true) => check(name, stateFields.map(key => `${name}.${key}`), (selected, identity, root, profiles, ump, revision, snapshot, actualReady) => selected === oracle[role].profile && identity === oracle[role].identity && root === oracle.root.identity && Array.isArray(profiles) && profiles.includes(selected) && profiles.includes(oracle.root.profile) && profiles.every(profile => ['root', 'secondary', 'third'].some(role => oracle[role].profile === profile)) && new Set(profiles).size === profiles.length && outpointPattern.test(ump) && Number.isSafeInteger(revision) && revision > 0 && hashPattern.test(snapshot) && actualReady === ready); + const inventory = (name, roles) => check(name, [name], value => list(value, roles.map(role => oracle[role].profile))); + const flag = (name, expected) => check(name, [name], value => same(value, expected)); + for (const role of vector.evidence) assertions.push({ id: `${vector.id}/evidence/${role}`, status: evidence.some(item => item.role === role) ? 'PASS' : 'BLOCKED' }); + switch (vector.id) { + case 'ISI-6-V001': + state('before', 'root'); state('after', 'root'); inventory('after.profiles', ['root', 'secondary']); + check('successor', ['before.ump', 'after.ump', 'published.ump'], (before, after, published) => before !== after && after === published); + inventory('published.profiles', ['root', 'secondary']); + check('durable-before-ready', ['before.revision', 'after.revision', 'successRevision'], (before, after, success) => after > before && success === after); + break; + case 'ISI-6-V002': + state('before', 'root'); state('after', 'secondary'); + compare('no-ump-write', ['before.ump', 'after.ump']); + flag('freshIdentity', oracle.secondary.identity); flag('oldReply.status', 'rejected'); + check('old-generation-fenced', ['oldReply.generation', 'newGeneration'], (old, current) => Number.isSafeInteger(old) && Number.isSafeInteger(current) && old < current); + check('serialized-switches', ['requestedSwitches', 'activatedSwitches'], (requested, activated) => Array.isArray(requested) && requested.length >= 2 && requested.at(-1) === oracle.secondary.profile && requested.every(profile => ['root', 'secondary', 'third'].some(role => oracle[role].profile === profile)) && same(requested, activated)); + flag('busyFinancialSwitch', 'refused'); flag('oldCacheReused', false); + break; + case 'ISI-6-V003': + state('before', 'secondary'); state('after', 'secondary'); + for (const key of ['selected', 'identity', 'ump']) compare(`retained-${key}`, [`before.${key}`, `after.${key}`]); + check('retained-inventory', ['before.profiles', 'after.profiles'], list); + flag('lifecycle.kind', 'force-stop'); flag('lifecycle.processExited', true); flag('lifecycle.relaunchObserved', true); flag('walletLogoutCount', 0); + check('monotonic-commit', ['before.revision', 'after.revision'], (before, after) => after >= before); + break; + case 'ISI-6-V004': + state('before', 'secondary'); state('after', 'secondary'); state('reopened', 'secondary'); + inventory('after.profiles', ['root', 'secondary', 'third']); inventory('published.profiles', ['root', 'secondary', 'third']); + check('one-original-update', ['before.ump', 'after.ump', 'published.ump', 'newActionIds'], (before, after, published, ids) => before !== after && after === published && Array.isArray(ids) && ids.length === 1 && typeof ids[0] === 'string' && ids[0].length > 0); + compare('reopened-successor', ['after.ump', 'reopened.ump']); flag('walletLogoutCount', 0); + break; + case 'ISI-6-V005': + state('stale', 'secondary'); state('reconciled', 'secondary'); + check('verified-successor', ['stale.ump', 'reconciled.ump', 'authoritative.ump'], (stale, current, authoritative) => stale !== current && current === authoritative); + check('authoritative-inventory', ['reconciled.profiles', 'authoritative.profiles'], list); + flag('unavailable.newUmpMutation', 'refused'); flag('unavailable.newAccountCreated', false); + compare('unavailable-retains-snapshot', ['stale.snapshot', 'unavailable.retainedSnapshot']); + break; + case 'ISI-6-V006': + state('before', 'secondary'); state('afterFailure', 'secondary', observation?.failureOutcome === 'verified-rollback'); state('afterRetry', 'secondary'); + check('safe-failure-outcome', ['failureOutcome'], value => ['unavailable', 'verified-rollback'].includes(value)); + for (const key of ['selected', 'ump', 'revision', 'snapshot']) compare(`failed-save-retains-${key}`, [`before.${key}`, `afterFailure.${key}`]); + flag('writeResult', 'rejected'); + if (observation?.failureOutcome === 'verified-rollback') { flag('afterFailureAccess.identityCall', 'served-previous'); flag('afterFailureAccess.identity', oracle.secondary.identity); } + else flag('afterFailureAccess.identityCall', 'rejected'); + flag('afterFailureAccess.umpMutation', 'rejected'); flag('newActionIds', []); + compare('local-only-retry', ['before.ump', 'afterRetry.ump']); + check('retry-commits', ['before.revision', 'afterRetry.revision'], (before, after) => after > before); + break; + case 'ISI-6-V007': { + state('before', 'secondary'); state('after', 'secondary'); + flag('receipt.ownerIdentity', oracle.root.identity); compare('exact-predecessor', ['before.ump', 'receipt.predecessor']); compare('exact-outpoint', ['after.ump', 'receipt.outpoint']); + check('intended-profiles', ['after.profiles', 'receipt.profiles'], list); + const beef = evidence.find(item => item.role === 'atomic-beef'); + if (beef == null) assertions.push({ id: `${vector.id}/retained-original-bytes`, status: 'BLOCKED' }); + else check('retained-original-bytes', ['originalReceiptSha256', 'replayedReceiptSha256s'], (original, replayed) => original === beef.sha256 && Array.isArray(replayed) && replayed.length > 0 && replayed.every(value => value === original)); + check('no-duplicate-action', ['originalActionId', 'newActionIds'], (original, ids) => typeof original === 'string' && original.length > 0 && same(ids, [original])); + flag('withoutReceipt.originalOutcome', 'unavailable'); flag('withoutReceipt.status', 'pending'); flag('withoutReceipt.newActionCount', 0); flag('withoutReceipt.checkpointRetained', true); + check('successor-not-predecessor', ['before.ump', 'after.ump'], (before, after) => before !== after); + break; + } + case 'ISI-6-V008': + flag('removed.selected', oracle.secondary.profile); flag('removed.ready', false); flag('removed.identityCall', 'rejected'); flag('removed.status', 'profile-unavailable'); + check('builder-failure-safe', ['failedBuild.ready', 'failedBuild.identity', 'failedBuild.selected', 'failedBuild.identityCall'], (ready, identity, selected, call) => (ready === false && call === 'rejected') || (ready === true && identity === oracle.secondary.identity && selected === oracle.secondary.profile && call === 'served')); + flag('replacement.identity', oracle.replacement.identity); flag('lateCallback.served', false); flag('afterLateCallback.identity', oracle.replacement.identity); + break; + case 'ISI-6-V009': + flag('walletIdentity', oracle.secondary.identity); flag('initialServerIdentity', oracle.root.identity); flag('explicitLogin.serverIdentity', oracle.secondary.identity); flag('explicitLogin.peerIdentity', oracle.secondary.identity); + check('separate-principal', ['rootUserId', 'secondaryUserId', 'explicitLogin.userId'], (root, secondary, actual) => typeof root === 'string' && root.length > 0 && typeof secondary === 'string' && secondary.length > 0 && root !== secondary && actual === secondary); + flag('priorSessionStatus', 'revoked'); flag('pageReloadCount', 0); flag('paymentReplayCount', 0); flag('accountLinksCreated', 0); + break; + case 'ISI-6-V010': + flag('consumerInventory', plan.optionalConsumers); + if (plan.optionalConsumers.mirrors) { + check('canonical-mirror-authority', ['canonicalRevision', 'selectedRevision', 'staleMirrorRevision'], (canonicalRevision, selected, stale) => Number.isSafeInteger(canonicalRevision) && Number.isSafeInteger(stale) && canonicalRevision > stale && selected === canonicalRevision); + flag('conflictingAccounts', 'retained-and-refused'); flag('logout.mirrorStatus', 'disabled'); + } else flag('mirrorConsumer', 'absent'); + flag('logout.reopenedAuthenticated', false); flag('logout.oldSnapshotRestored', false); + if (plan.optionalConsumers.background) { + flag('backgroundAfterLogout', 'deferred'); flag('notificationIdentityBefore', oracle.root.identity); + flag('notificationIdentityAfterSwitch', plan.notificationIdentityRole === 'root' ? oracle.root.identity : oracle.secondary.identity); + flag('notificationCrossAccountAccepted', false); + } else flag('backgroundConsumer', 'absent'); + break; + default: throw new Error('Unknown ISI-6 vector'); + } + const status = assertions.some(item => item.status === 'FAIL') ? 'FAIL' : assertions.some(item => item.status === 'BLOCKED') ? 'BLOCKED' : 'PASS'; + return { id: vector.id, requirementId: vector.requirementId, status, assertions }; +} + +/** Evaluates digest-bound observations. Native admission and certification are separate. */ +export function evaluateWalletProfiles(plan, record, evidenceRoot) { + checkSchema('wallet-profile-plan', plan); checkSchema('wallet-profile-record', record); + const catalog = readJson(path.join(ROOT, WALLET_PROFILE_CATALOG)); checkCatalog(catalog); + if (plan.profileHash !== hashJson(catalog) || record.planHash !== hashJson(plan)) throw new Error('Wallet profile plan/catalog digest mismatch'); + const started = Date.parse(record.startedAt), finished = Date.parse(record.finishedAt); + if (!Number.isFinite(started) || !Number.isFinite(finished) || new Date(started).toISOString() !== record.startedAt || new Date(finished).toISOString() !== record.finishedAt || finished < started) throw new Error('Invalid observation interval'); + unique(record.cases.map(item => item.id), 'profile observation vector'); + if (record.cases.some(item => !catalog.vectors.some(vector => vector.id === item.id))) throw new Error('Unknown profile observation vector'); + const fixture = parseJson(artifactBytes(evidenceRoot, plan.fixtureOracle)); + const claim = plan.mode === 'self-test' ? 'LAB_SELF_TEST_ONLY' : 'ENGINEERING_OBSERVATION_ONLY'; + if (fixture.schema !== 'tpnil-isi6-fixture@0.1.0' || Object.keys(fixture).sort().join() !== 'claim,replacement,root,schema') throw new Error('Invalid frozen profile fixture'); + if (fixture.claim !== claim) throw new Error('Synthetic fixture and observation claims cannot be promoted or relabelled'); + const oracle = oracleRecord(parseJson(artifactBytes(evidenceRoot, record.oracle))); + if (oracle.claim !== claim || oracle.planHash !== record.planHash || oracle.observerSha256 !== plan.oracleObserverSha256 || !same(oracle.root, fixture.root) || !same(oracle.replacement, fixture.replacement)) throw new Error('Derived profile oracle does not bind its frozen fixture/observer/plan'); + if (!oracle.sources || Object.keys(oracle.sources).sort().join() !== 'secondary,third') throw new Error('Missing derived UMP source bindings'); + for (const role of ['secondary', 'third']) { + const source = oracle.sources[role]; + if (!source || Object.keys(source).sort().join() !== 'path,sha256,size' || !hashPattern.test(source.sha256) || !Number.isSafeInteger(source.size) || source.size < 1) throw new Error('Invalid derived UMP source binding'); + artifactBytes(evidenceRoot, source); + const creation = record.cases.find(item => item.id === (role === 'secondary' ? 'ISI-6-V001' : 'ISI-6-V004')); + const observedSources = creation?.evidence.filter(item => item.role === 'independent-ump') ?? []; + if (observedSources.length && !observedSources.some(item => item.sha256 === source.sha256 && item.size === source.size)) throw new Error('Derived key is not bound to its creation UMP observation'); + } + const outcomes = catalog.vectors.map(vector => { + const item = record.cases.find(item => item.id === vector.id); + if (!item) return { id: vector.id, requirementId: vector.requirementId, status: 'BLOCKED', assertions: [{ id: `${vector.id}/execution`, status: 'BLOCKED' }] }; + unique([item.projection.path, ...item.evidence.map(artifact => artifact.path)], 'vector evidence path'); + let projection; + const evidence = []; + try { projection = parseJson(artifactBytes(evidenceRoot, item.projection)); } catch (error) { if (error.code !== 'ENOENT') throw error; } + for (const artifact of item.evidence) { + try { artifactBytes(evidenceRoot, artifact); evidence.push(artifact); } catch (error) { if (error.code !== 'ENOENT') throw error; } + } + return caseOracle(vector, projection, oracle, evidence, plan); + }); + return { + schema: 'tpnil-isi6-result@0.1.0', claim: plan.mode === 'self-test' ? 'LAB_SELF_TEST_ONLY' : 'ENGINEERING_OBSERVATION_ONLY', + program: plan.program, selection: plan.selection, profileHash: plan.profileHash, planHash: hashJson(plan), recordHash: hashJson(record), + sutSha256: plan.sutSha256, environmentSha256: plan.environmentSha256, platform: plan.platform, deviceKind: plan.deviceKind, network: plan.network, optionalConsumers: plan.optionalConsumers, notificationIdentityRole: plan.notificationIdentityRole, + overall: outcomes.some(item => item.status === 'FAIL') ? 'FAIL' : outcomes.some(item => item.status === 'BLOCKED') ? 'BLOCKED' : 'PASS', outcomes + }; +} +export function evaluateWalletProfileFiles(planFile, recordFile, evidenceRoot) { + return evaluateWalletProfiles(readJson(planFile), readJson(recordFile), fs.realpathSync(evidenceRoot)); +} diff --git a/test/core.test.mjs b/test/core.test.mjs index 6b6b052d..06362555 100644 --- a/test/core.test.mjs +++ b/test/core.test.mjs @@ -32,7 +32,7 @@ test('strict parser rejects ambiguous keys, Unicode, numbers and trailing data', }); test('unsupported schema keywords fail closed', () => assert.throws(() => validate({ allOf: [] }, {}), /Unsupported/)); test('catalogs distinguish executable vectors from design-only vectors', () => { - assert.deepEqual(checkRepository(), { catalogs: 4, draftVectors: 26, executableSutVectors: 6 }); + assert.deepEqual(checkRepository(), { catalogs: 5, draftVectors: 36, executableSutVectors: 16 }); const c = clone(readJson(path.join(ROOT, 'programs/ISI-4/0.1.0/catalog.json'))); c.vectors[0].executable = true; checkCatalog(c); c.vectors[1].id = c.vectors[0].id; assert.throws(() => checkCatalog(c), /Duplicate/); diff --git a/test/wallet-profiles.test.mjs b/test/wallet-profiles.test.mjs new file mode 100644 index 00000000..d9037d3c --- /dev/null +++ b/test/wallet-profiles.test.mjs @@ -0,0 +1,123 @@ +import test from 'node:test'; +import assert from 'node:assert/strict'; +import fs from 'node:fs'; +import os from 'node:os'; +import path from 'node:path'; +import { spawnSync } from 'node:child_process'; +import { digest, hashJson } from '../src/json.mjs'; +import { ROOT, readJson, checkCatalog, checkSchema } from '../src/core.mjs'; +import { evaluateWalletProfiles, WALLET_PROFILE_CATALOG } from '../src/wallet-profiles.mjs'; +import { createWalletProfileSelfTest } from '../src/wallet-profile-self-test.mjs'; +function fixture(t) { const root = fs.mkdtempSync(path.join(os.tmpdir(), 'tpnil-isi6-')); t.after(() => fs.rmSync(root, { recursive: true, force: true })); return createWalletProfileSelfTest(path.join(root, 'new')); } +function mutate(f, number, change) { const item = f.record.cases[number - 1], file = path.join(f.directory, item.projection.path); const value = readJson(file); change(value); const bytes = Buffer.from(JSON.stringify(value)); fs.writeFileSync(file, bytes); item.projection.sha256 = digest(bytes); item.projection.size = bytes.length; } +const evaluate = f => evaluateWalletProfiles(f.plan, f.record, f.directory); +function rebindPlan(f) { + f.record.planHash = hashJson(f.plan); + const file = path.join(f.directory, f.record.oracle.path), oracle = readJson(file); + oracle.planHash = f.record.planHash; + const bytes = Buffer.from(JSON.stringify(oracle)); fs.writeFileSync(file, bytes); + f.record.oracle.sha256 = digest(bytes); f.record.oracle.size = bytes.length; +} + + +test('optional ISI-6 has ten complete vectors; old index/catalog schemas retain their namespace', () => { + const catalog = readJson(path.join(ROOT, WALLET_PROFILE_CATALOG)); checkCatalog(catalog); + assert.equal(catalog.vectors.length, 10); + assert.ok(catalog.vectors.every(vector => vector.applicability.includes('independent of ISI-4'))); + assert.throws(() => checkSchema('program-index', { schemaVersion: '0.1.0', programs: [{ id: 'ISI-6', version: '0.1.0' }] })); + assert.equal(readJson(path.join(ROOT, 'programs/ISI-4/1.0.0/catalog.json')).vectors.length, 8); +}); +test('complete synthetic observations pass only LAB_SELF_TEST_ONLY and engineering cannot issue conformance', t => { + const f = fixture(t), result = evaluate(f); + assert.equal(result.overall, 'PASS'); assert.equal(result.outcomes.length, 10); assert.equal(result.claim, 'LAB_SELF_TEST_ONLY'); + assert.ok(result.outcomes.every(outcome => outcome.assertions.length > 5)); + f.plan.mode = 'engineering'; rebindPlan(f); + assert.throws(() => evaluate(f), /cannot be promoted/); + f.plan.mode = 'CERTIFIED'; assert.throws(() => evaluate(f)); +}); +const regressions = [ + [1, 'success before durable commit', o => { o.successRevision = 1; }], + [2, 'UI selects secondary but BRC100 serves root', o => { o.freshIdentity = o.before.identity; }], + [2, 'old profile response escapes', o => { o.oldReply.status = 'served'; }], + [2, 'concurrent switches disappear', o => { o.activatedSwitches = []; }], + [2, 'empty concurrency trace', o => { o.requestedSwitches = o.activatedSwitches = []; }], + [2, 'financial call races switching', o => { o.busyFinancialSwitch = 'allowed'; }], + [2, 'old read cache reused', o => { o.oldCacheReused = true; }], + [3, 'Home gesture substitutes for process death', o => { o.lifecycle.kind = 'background'; }], + [3, 'default restored on relaunch', o => { o.after = { ...o.after, selected: 'root' }; }], + [4, 'third creation resets active key', o => { o.after = { ...o.after, identity: o.after.root }; }], + [4, 'third creation duplicates financial action', o => { o.newActionIds.push('duplicate'); }], + [5, 'lookup failure recreates account', o => { o.unavailable.newAccountCreated = true; }], + [5, 'stale token accepted as current', o => { o.reconciled = { ...o.reconciled, ump: o.stale.ump }; }], + [6, 'failed save reports ready', o => { o.afterFailure = { ...o.afterFailure, ready: true }; }], + [6, 'refresh omits retrying the save', o => { o.afterRetry = { ...o.afterRetry, revision: o.before.revision }; }], + [7, 'receipt has wrong owner', o => { o.receipt.ownerIdentity = o.before.identity; }], + [7, 'receipt consumes the wrong predecessor', o => { o.receipt.predecessor = o.after.ump; }], + [7, 'receipt publishes a different outpoint', o => { o.receipt.outpoint = o.before.ump; }], + [7, 'receipt changes the intended inventory', o => { o.receipt.profiles = ['root']; }], + [7, 'replacement receipt broadcast', o => { o.replayedReceiptSha256s.push('ff'.repeat(32)); }], + [7, 'uncertain admission creates replacement action', o => { o.withoutReceipt.newActionCount = 1; }], + [7, 'uncertain checkpoint silently discarded', o => { o.withoutReceipt.checkpointRetained = false; }], + [8, 'missing profile silently falls back', o => { o.removed.identityCall = 'served'; }], + [8, 'late account callback poisons identity', o => { o.afterLateCallback.identity = o.failedBuild.identity; }], + [8, 'failed builder still serves API', o => { o.failedBuild.identityCall = 'served'; }], + [9, 'cached authenticated root peer reused', o => { o.explicitLogin.peerIdentity = o.initialServerIdentity; }], + [9, 'relogin keeps root server account', o => { o.explicitLogin.userId = o.rootUserId; }], + [9, 'login retries payment', o => { o.paymentReplayCount = 1; }], + [10, 'stale mirror wins', o => { o.selectedRevision = o.staleMirrorRevision; }], + [10, 'logout resurrects legacy account', o => { o.logout.oldSnapshotRestored = true; }], + [10, 'background consumes logged-out identity', o => { o.backgroundAfterLogout = 'accepted'; }] +]; +for (const [number, name, change] of regressions) test(`reject regression: ${name}`, t => { const f = fixture(t); mutate(f, number, change); const result = evaluate(f); assert.equal(result.overall, 'FAIL'); assert.equal(result.outcomes[number - 1].status, 'FAIL'); }); +test('each omitted vector and each required evidence role blocks full compatibility', t => { + const f = fixture(t); + for (let i = 0; i < 10; i++) { const missing = structuredClone(f); missing.record.cases.splice(i, 1); assert.equal(evaluate(missing).overall, 'BLOCKED'); } + for (const item of f.record.cases) for (let i = 0; i < item.evidence.length; i++) { const missing = structuredClone(f); missing.record.cases.find(row => row.id === item.id).evidence.splice(i, 1); assert.equal(evaluate(missing).overall, 'BLOCKED'); } +}); +test('missing semantic fact or absent raw artifact blocks instead of passing', t => { + const f = fixture(t); mutate(f, 3, o => { delete o.lifecycle.processExited; }); assert.equal(evaluate(f).overall, 'BLOCKED'); + fs.unlinkSync(path.join(f.directory, f.record.cases[0].evidence[0].path)); assert.equal(evaluate(f).outcomes[0].status, 'BLOCKED'); +}); +test('tamper, symlinks, duplicates, unknown vectors and wrong plan/catalog binding fail the evidence contract', t => { + const f = fixture(t); + for (const change of [x => { x.record.planHash = '00'.repeat(32); }, x => { x.plan.profileHash = '00'.repeat(32); }, x => { x.record.cases.push(x.record.cases[0]); }, x => { x.record.cases[0].id = 'ISI-6-V999'; }, x => { x.record.cases[0].projection.path = '../escape'; }, x => { x.record.finishedAt = '2026-11-15T00:00:00.000Z'; }]) { const invalid = structuredClone(f); change(invalid); assert.throws(() => evaluate(invalid)); } + const file = path.join(f.directory, f.record.cases[0].projection.path); fs.appendFileSync(file, ' '); assert.throws(() => evaluate(f), /size|digest/i); + fs.unlinkSync(file); fs.symlinkSync('oracle.json', file); assert.throws(() => evaluate(f), /Symlink/); +}); +test('CLI reports FAIL/BLOCKED as lab data and reserves error exit for invalid evidence', t => { + const f = fixture(t); const run = () => spawnSync(process.execPath, ['bin/tpnil.mjs', 'evaluate-wallet-profiles', path.join(f.directory, 'plan.json'), path.join(f.directory, 'record.json'), f.directory], { cwd: ROOT, encoding: 'utf8' }); + assert.equal(run().status, 0); mutate(f, 9, o => { o.paymentReplayCount = 1; }); fs.writeFileSync(path.join(f.directory, 'record.json'), JSON.stringify(f.record)); const result = run(); assert.equal(result.status, 0); assert.equal(JSON.parse(result.stdout).overall, 'FAIL'); f.record.planHash = 'ff'.repeat(32); fs.writeFileSync(path.join(f.directory, 'record.json'), JSON.stringify(f.record)); assert.equal(run().status, 2); +}); + +test('single-store and absent background consumers have explicit frozen scope rather than mandatory extra components', t => { + const f = fixture(t); f.plan.optionalConsumers = { mirrors: false, background: false }; rebindPlan(f); + mutate(f, 10, o => { o.consumerInventory = f.plan.optionalConsumers; o.mirrorConsumer = o.backgroundConsumer = 'absent'; delete o.canonicalRevision; delete o.backgroundAfterLogout; }); + assert.equal(evaluate(f).overall, 'PASS'); + mutate(f, 10, o => { o.consumerInventory.background = true; }); assert.equal(evaluate(f).overall, 'FAIL'); +}); +test('declared profile-scoped notification identity is preserved independently of root-scoped implementations', t => { + const f = fixture(t); f.plan.notificationIdentityRole = 'active-profile'; rebindPlan(f); + assert.equal(evaluate(f).outcomes[9].status, 'FAIL'); + mutate(f, 10, o => { o.notificationIdentityAfterSwitch = f.oracle.secondary.identity; }); assert.equal(evaluate(f).overall, 'PASS'); +}); + +test('profile inventory ordering cannot invent a semantic mismatch', t => { + const f = fixture(t); mutate(f, 3, o => { o.after = { ...o.after, profiles: [...o.after.profiles].reverse() }; }); + assert.equal(evaluate(f).overall, 'PASS'); +}); + +test('derived keys bind the pre-frozen observer/root and original UMP evidence without predetermined profile entropy', t => { + const f = fixture(t), file = path.join(f.directory, f.record.oracle.path); + const original = readJson(file); + for (const change of [o => { o.observerSha256 = 'ff'.repeat(32); }, o => { o.planHash = 'ff'.repeat(32); }, o => { o.root.identity = o.secondary.identity; }, o => { o.sources.third.sha256 = 'ff'.repeat(32); }, o => { o.sources.third = o.sources.secondary; }]) { + const oracle = structuredClone(original); change(oracle); const bytes = Buffer.from(JSON.stringify(oracle)); + fs.writeFileSync(file, bytes); f.record.oracle.sha256 = digest(bytes); f.record.oracle.size = bytes.length; + assert.throws(() => evaluate(f)); + } +}); + +test('verified rollback may serve the previously committed identity while unresolved writes remain refused', t => { + const f = fixture(t); mutate(f, 6, o => { o.failureOutcome = 'verified-rollback'; o.afterFailure.ready = true; o.afterFailureAccess.identityCall = 'served-previous'; o.afterFailureAccess.identity = o.before.identity; }); + assert.equal(evaluate(f).overall, 'PASS'); + mutate(f, 6, o => { o.afterFailureAccess.identity = o.before.root; }); assert.equal(evaluate(f).overall, 'FAIL'); +});