mcard-js 2.1.49 → 2.1.51
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/CardCollection-EMSBVZP3.js +10 -0
- package/dist/CardCollection-KQWR4PCV.js +10 -0
- package/dist/CardCollection-ORGE2XBG.js +10 -0
- package/dist/EngineRegistry-ABZXHZWO.js +17 -0
- package/dist/EngineRegistry-EIOT4MUZ.js +17 -0
- package/dist/EngineRegistry-IQ6EVO72.js +17 -0
- package/dist/EngineRegistry-PHRFXEOE.js +17 -0
- package/dist/IndexedDBEngine-EWA3SLAO.js +12 -0
- package/dist/IndexedDBEngine-FXAD42F3.js +12 -0
- package/dist/IndexedDBEngine-RD4447IS.js +12 -0
- package/dist/LLMRuntime-ARUWOX52.js +17 -0
- package/dist/LLMRuntime-C3XCO7WF.js +17 -0
- package/dist/LLMRuntime-CQ7X43QR.js +17 -0
- package/dist/LLMRuntime-PD45COKE.js +17 -0
- package/dist/LLMRuntime-QOUMLT33.js +17 -0
- package/dist/LLMRuntime-SZNLTHD7.js +17 -0
- package/dist/LLMRuntime-TVJGK2BG.js +17 -0
- package/dist/LambdaRuntime-25GMEJCU.js +19 -0
- package/dist/LambdaRuntime-7KQUMHPI.js +19 -0
- package/dist/LambdaRuntime-DRT7ODPC.js +19 -0
- package/dist/LambdaRuntime-HSREEYQG.js +19 -0
- package/dist/LambdaRuntime-IH7NVG6Z.js +19 -0
- package/dist/LambdaRuntime-MPG27FM2.js +19 -0
- package/dist/LambdaRuntime-ODSWIMNM.js +19 -0
- package/dist/LambdaRuntime-PHGRZYAW.js +19 -0
- package/dist/LambdaRuntime-QOEYR37L.js +19 -0
- package/dist/LambdaRuntime-RT33TFN2.js +19 -0
- package/dist/LambdaRuntime-W6TQBP5O.js +19 -0
- package/dist/Loader-35WSUC53.js +14 -0
- package/dist/Loader-STS3G4OQ.js +16 -0
- package/dist/Loader-W22AEM6F.js +12 -0
- package/dist/Loader-YBPWP43S.js +12 -0
- package/dist/Loader-ZYSS7B4D.js +12 -0
- package/dist/NetworkRuntime-KR2QITXV.js +987 -0
- package/dist/NetworkRuntime-S6V2CMZV.js +1575 -0
- package/dist/OllamaProvider-2ANW6EB2.js +9 -0
- package/dist/OllamaProvider-5QFJKYAC.js +9 -0
- package/dist/OllamaProvider-6QXJGR7V.js +9 -0
- package/dist/OllamaProvider-ABEEFX7M.js +9 -0
- package/dist/OllamaProvider-Z2CGY5LY.js +9 -0
- package/dist/VCard-225X42W7.js +25 -0
- package/dist/chunk-2APJYBH4.js +368 -0
- package/dist/chunk-4DFTWDRB.js +497 -0
- package/dist/chunk-4PBRTFSY.js +112 -0
- package/dist/chunk-4T3H25AP.js +299 -0
- package/dist/chunk-5DFXPIRL.js +42 -0
- package/dist/chunk-5HRZV4R3.js +217 -0
- package/dist/chunk-6ZRJXVJ3.js +529 -0
- package/dist/chunk-7N7JYGN2.js +364 -0
- package/dist/chunk-7QTJUGYQ.js +74 -0
- package/dist/chunk-7TXIPJI2.js +2360 -0
- package/dist/chunk-BFJUD527.js +2369 -0
- package/dist/chunk-CHXIVTQV.js +364 -0
- package/dist/chunk-DM2ABCA4.js +497 -0
- package/dist/chunk-DTPHGTBQ.js +275 -0
- package/dist/chunk-EDAJ5FO6.js +405 -0
- package/dist/chunk-ETJWXHKZ.js +246 -0
- package/dist/chunk-FLYGNPUC.js +2369 -0
- package/dist/chunk-FSDRDWOP.js +34 -0
- package/dist/chunk-GIKMCG4D.js +497 -0
- package/dist/chunk-IJKS3LGK.js +428 -0
- package/dist/chunk-JUQ2VQZA.js +428 -0
- package/dist/chunk-JVW4J7BY.js +2369 -0
- package/dist/chunk-JWTRVEC3.js +2369 -0
- package/dist/chunk-KJM4C65U.js +299 -0
- package/dist/chunk-KMC566CN.js +591 -0
- package/dist/chunk-KMNP6DBL.js +455 -0
- package/dist/chunk-LVU7O5IY.js +597 -0
- package/dist/chunk-M4C6RWLA.js +373 -0
- package/dist/chunk-NAAAKSEO.js +541 -0
- package/dist/chunk-NKIXLPHL.js +373 -0
- package/dist/chunk-NOEDMK7I.js +428 -0
- package/dist/chunk-NOPYSBOQ.js +2360 -0
- package/dist/chunk-P4G42QCY.js +2369 -0
- package/dist/chunk-PKLONZCF.js +253 -0
- package/dist/chunk-PNGECWPN.js +597 -0
- package/dist/chunk-PYP6T64W.js +217 -0
- package/dist/chunk-QFT3COE2.js +217 -0
- package/dist/chunk-QFZFXMNX.js +275 -0
- package/dist/chunk-QZGRQRJP.js +2369 -0
- package/dist/chunk-R3XRBAM7.js +253 -0
- package/dist/chunk-RYP66UMH.js +74 -0
- package/dist/chunk-RZIZYRLF.js +112 -0
- package/dist/chunk-T43V44RS.js +2369 -0
- package/dist/chunk-UCNVX5BZ.js +74 -0
- package/dist/chunk-UDF7HS4V.js +368 -0
- package/dist/chunk-VJPXJVEH.js +299 -0
- package/dist/chunk-VW3KBDK5.js +74 -0
- package/dist/chunk-X72XIYSN.js +364 -0
- package/dist/chunk-XETU7TV4.js +112 -0
- package/dist/chunk-Y4BT6LHA.js +368 -0
- package/dist/chunk-YQGB6BIA.js +2369 -0
- package/dist/chunk-ZEQPO3XV.js +217 -0
- package/dist/chunk-ZKRKWXEQ.js +2369 -0
- package/dist/chunk-ZMK2HTZ5.js +275 -0
- package/dist/constants-CLB7B6MN.js +101 -0
- package/dist/constants-O343SMHL.js +103 -0
- package/dist/constants-YPGDEX5X.js +103 -0
- package/dist/index.browser.cjs +11 -5
- package/dist/index.browser.js +12 -12
- package/dist/index.cjs +2358 -1896
- package/dist/index.d.cts +934 -776
- package/dist/index.d.ts +934 -776
- package/dist/index.js +1353 -1271
- package/dist/storage/SqliteNodeEngine.cjs +12 -6
- package/dist/storage/SqliteNodeEngine.js +4 -4
- package/dist/storage/SqliteWasmEngine.cjs +11 -5
- package/dist/storage/SqliteWasmEngine.js +4 -4
- package/package.json +5 -3
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { S as StorageEngine, M as MCard, D as DOTSMetadata } from './AbstractSqlEngine-DKka6XjT.js';
|
|
2
2
|
export { P as Page } from './AbstractSqlEngine-DKka6XjT.js';
|
|
3
|
-
import { CardCollection, Either, IO, Maybe } from './index.browser.js';
|
|
4
|
-
export { ALGORITHM_HIERARCHY, ContentHandle, ContentTypeInterpreter, EVENT_CONSTANTS, ErrorCodes, ExecutionResult, FaroSidecar, FaroSidecarConfig, GTime, HandleValidationError, HashValidator, IndexedDBEngine, JsonRpcRequest, JsonRpcResponse, LensProtocol,
|
|
3
|
+
import { CardCollection, Either, IO, Maybe, SafetyViolation, LivenessMetric } from './index.browser.js';
|
|
4
|
+
export { ALGORITHM_HIERARCHY, ContentHandle, ContentTypeInterpreter, EVENT_CONSTANTS, ErrorCodes, ExecutionResult, FaroSidecar, FaroSidecarConfig, GTime, HandleValidationError, HashValidator, IndexedDBEngine, JsonRpcRequest, JsonRpcResponse, LensProtocol, MCardStore, PolynomialTerm, PostconditionViolation, PreconditionViolation, PrimeHash, Reader, ServiceWorkerPTR, State, ValidationRegistry, VerificationStatus, Writer, computeHash, validateHandle, validationRegistry } from './index.browser.js';
|
|
5
5
|
export { SqliteWasmEngine } from './storage/SqliteWasmEngine.js';
|
|
6
6
|
export { SqliteNodeEngine } from './storage/SqliteNodeEngine.js';
|
|
7
7
|
import '@grafana/faro-web-sdk';
|
|
@@ -222,15 +222,21 @@ declare function processFileContent(filePath: string, options?: {
|
|
|
222
222
|
allowPathological?: boolean;
|
|
223
223
|
maxBytes?: number;
|
|
224
224
|
}): Promise<FileProcessingResult$1>;
|
|
225
|
+
/**
|
|
226
|
+
* Recursively hash the files in a directory to compute topological source hashes.
|
|
227
|
+
* Ignores problematic files.
|
|
228
|
+
*/
|
|
229
|
+
declare function getTreeHashes(dirPath: string): Promise<Record<string, string>>;
|
|
225
230
|
|
|
226
231
|
type FileIO_NormalizedReadResult = NormalizedReadResult;
|
|
232
|
+
declare const FileIO_getTreeHashes: typeof getTreeHashes;
|
|
227
233
|
declare const FileIO_isProblematicFile: typeof isProblematicFile;
|
|
228
234
|
declare const FileIO_listFiles: typeof listFiles;
|
|
229
235
|
declare const FileIO_processFileContent: typeof processFileContent;
|
|
230
236
|
declare const FileIO_readFileSafely: typeof readFileSafely;
|
|
231
237
|
declare const FileIO_streamReadNormalizedText: typeof streamReadNormalizedText;
|
|
232
238
|
declare namespace FileIO {
|
|
233
|
-
export { type FileProcessingResult$1 as FileProcessingResult, type FileIO_NormalizedReadResult as NormalizedReadResult, FileIO_isProblematicFile as isProblematicFile, FileIO_listFiles as listFiles, FileIO_processFileContent as processFileContent, FileIO_readFileSafely as readFileSafely, FileIO_streamReadNormalizedText as streamReadNormalizedText };
|
|
239
|
+
export { type FileProcessingResult$1 as FileProcessingResult, type FileIO_NormalizedReadResult as NormalizedReadResult, FileIO_getTreeHashes as getTreeHashes, FileIO_isProblematicFile as isProblematicFile, FileIO_listFiles as listFiles, FileIO_processFileContent as processFileContent, FileIO_readFileSafely as readFileSafely, FileIO_streamReadNormalizedText as streamReadNormalizedText };
|
|
234
240
|
}
|
|
235
241
|
|
|
236
242
|
interface FileProcessingResult {
|
|
@@ -265,14 +271,38 @@ declare function loadFileToCollection(targetPath: string, collection: CardCollec
|
|
|
265
271
|
maxBytesOnProblem?: number;
|
|
266
272
|
metadataOnly?: boolean;
|
|
267
273
|
}): Promise<LoaderResponse>;
|
|
274
|
+
/**
|
|
275
|
+
* AsyncGenerator for unblocking massive file ingest streams using backpressure semantics
|
|
276
|
+
* instead of buffering all results symmetrically into JS memory.
|
|
277
|
+
*/
|
|
278
|
+
declare function loadFileToCollectionStream(targetPath: string, collection: CardCollection, options?: {
|
|
279
|
+
recursive?: boolean;
|
|
280
|
+
includeProblematic?: boolean;
|
|
281
|
+
maxBytesOnProblem?: number;
|
|
282
|
+
metadataOnly?: boolean;
|
|
283
|
+
}): AsyncGenerator<{
|
|
284
|
+
progress: number;
|
|
285
|
+
total: number;
|
|
286
|
+
result: FileProcessingResult;
|
|
287
|
+
}, LoaderMetrics, unknown>;
|
|
288
|
+
/**
|
|
289
|
+
* Dump the entire SQLite collection out to standard filesystem topography based on registered handles.
|
|
290
|
+
* Serves as the key PCard Transition for isomorphism checking.
|
|
291
|
+
*/
|
|
292
|
+
declare function exportCollectionToDirectory(collection: CardCollection, targetDir: string): Promise<{
|
|
293
|
+
exportedCount: number;
|
|
294
|
+
bytesWritten: number;
|
|
295
|
+
}>;
|
|
268
296
|
|
|
269
297
|
type Loader_FileProcessingResult = FileProcessingResult;
|
|
270
298
|
type Loader_LoaderMetrics = LoaderMetrics;
|
|
271
299
|
type Loader_LoaderResponse = LoaderResponse;
|
|
300
|
+
declare const Loader_exportCollectionToDirectory: typeof exportCollectionToDirectory;
|
|
272
301
|
declare const Loader_loadFileToCollection: typeof loadFileToCollection;
|
|
302
|
+
declare const Loader_loadFileToCollectionStream: typeof loadFileToCollectionStream;
|
|
273
303
|
declare const Loader_processAndStoreFile: typeof processAndStoreFile;
|
|
274
304
|
declare namespace Loader {
|
|
275
|
-
export { type Loader_FileProcessingResult as FileProcessingResult, type Loader_LoaderMetrics as LoaderMetrics, type Loader_LoaderResponse as LoaderResponse, Loader_loadFileToCollection as loadFileToCollection, Loader_processAndStoreFile as processAndStoreFile };
|
|
305
|
+
export { type Loader_FileProcessingResult as FileProcessingResult, type Loader_LoaderMetrics as LoaderMetrics, type Loader_LoaderResponse as LoaderResponse, Loader_exportCollectionToDirectory as exportCollectionToDirectory, Loader_loadFileToCollection as loadFileToCollection, Loader_loadFileToCollectionStream as loadFileToCollectionStream, Loader_processAndStoreFile as processAndStoreFile };
|
|
276
306
|
}
|
|
277
307
|
|
|
278
308
|
type RuntimeConfig$1 = Record<string, unknown>;
|
|
@@ -899,978 +929,1106 @@ declare namespace index {
|
|
|
899
929
|
}
|
|
900
930
|
|
|
901
931
|
/**
|
|
902
|
-
*
|
|
932
|
+
* VCard Model (Application Plane) - Petri Net TOKEN / PRE-CONDITION CARRIER
|
|
903
933
|
*
|
|
904
|
-
* This module defines
|
|
905
|
-
*
|
|
934
|
+
* This module defines VCard, the sovereign decision layer in the MVP Cards architecture.
|
|
935
|
+
* VCard is the Applicative that manages all side effects and authorization.
|
|
906
936
|
*
|
|
907
|
-
* ##
|
|
937
|
+
* ## Category Theory Role: APPLICATIVE
|
|
908
938
|
*
|
|
909
|
-
*
|
|
939
|
+
* VCard is the **Applicative** in the MVP Cards categorical hierarchy:
|
|
940
|
+
* - **MCard (Monad)**: Data container with unit and bind
|
|
941
|
+
* - **PCard (Functor)**: Pure transformation
|
|
942
|
+
* - **VCard (Applicative)**: Context-aware application `<*> :: F (a -> b) -> F a -> F b`
|
|
910
943
|
*
|
|
911
|
-
*
|
|
944
|
+
* The Applicative nature means VCard can encode **static pre-conditions**:
|
|
945
|
+
* the authorization graph is known ahead of time, while actual execution
|
|
946
|
+
* depends on runtime results.
|
|
912
947
|
*
|
|
913
|
-
*
|
|
914
|
-
* - A^op denotes contravariance in input types (accepts MORE general)
|
|
915
|
-
* - B denotes covariance in output types (produces MORE specific)
|
|
916
|
-
* - Set is the category of sets (our value space)
|
|
948
|
+
* ## Petri Net Role: TOKEN + PRE-CONDITION
|
|
917
949
|
*
|
|
918
|
-
*
|
|
919
|
-
* - first: P(A, B) → P(C × A, C × B) (threading context through)
|
|
920
|
-
* - second: P(A, B) → P(A × C, B × C) (preserving additional structure)
|
|
950
|
+
* In the Categorical Petri Net model, VCard serves dual roles:
|
|
921
951
|
*
|
|
922
|
-
*
|
|
952
|
+
* ### As Token
|
|
953
|
+
* - VCard is the **Token** that resides in Places (Handles)
|
|
954
|
+
* - Tokens enable Transitions (PCards) to fire
|
|
955
|
+
* - Token movement represents verification cascade
|
|
923
956
|
*
|
|
924
|
-
*
|
|
957
|
+
* ### As Pre-Condition (Firing Guard)
|
|
958
|
+
* A Petri Net transition fires when all input VCards exist:
|
|
925
959
|
*
|
|
926
|
-
*
|
|
960
|
+
* ```
|
|
961
|
+
* M' = M - •t + t•
|
|
962
|
+
* ```
|
|
927
963
|
*
|
|
928
|
-
*
|
|
929
|
-
*
|
|
930
|
-
*
|
|
931
|
-
*
|
|
932
|
-
*
|
|
964
|
+
* VCard as Input Arc encodes:
|
|
965
|
+
* - **Input Place**: Handle pointing to required VCard
|
|
966
|
+
* - **Token in Place**: VCard content in `card` table
|
|
967
|
+
* - **Arc Guard**: VCard's Applicative authorization check
|
|
968
|
+
* - **Token "Consumption"**: Recording `previous_hash` in new VCard
|
|
933
969
|
*
|
|
934
|
-
*
|
|
970
|
+
* ### Hash as Token AND Certificate (Dual Role)
|
|
935
971
|
*
|
|
936
|
-
*
|
|
972
|
+
* | Role | Function | Implementation |
|
|
973
|
+
* |------|----------|----------------|
|
|
974
|
+
* | **Token** | Triggers firing (enables transitions) | `handle_registry.current_hash IS NOT NULL` |
|
|
975
|
+
* | **Certificate** | Proves correctness after verification | VCard content witnesses Hoare Triple |
|
|
937
976
|
*
|
|
938
|
-
*
|
|
939
|
-
*
|
|
940
|
-
*
|
|
941
|
-
* - **Tensor Product**: Parallel composition via `andAlso()` (⊗)
|
|
942
|
-
* - **Symmetry**: Port swapping via `swap()` (σ)
|
|
977
|
+
* ```
|
|
978
|
+
* {h_pre} PCard {h_post}
|
|
979
|
+
* ```
|
|
943
980
|
*
|
|
944
|
-
*
|
|
981
|
+
* Where:
|
|
982
|
+
* - h_pre = hash of input VCard (precondition satisfied)
|
|
983
|
+
* - PCard = CLM specification (transformation logic)
|
|
984
|
+
* - h_post = hash of output VCard (postcondition witnessed)
|
|
945
985
|
*
|
|
946
|
-
*
|
|
947
|
-
* - **MCard (Monad)**: Data container
|
|
948
|
-
* - **PCard (Functor)**: Pure transformation `fmap :: (a -> b) -> F a -> F b`
|
|
949
|
-
* - **VCard (Applicative)**: Context-aware application
|
|
986
|
+
* ## Cascade Pattern: Propagating Verification
|
|
950
987
|
*
|
|
951
|
-
*
|
|
988
|
+
* VCards enable **verification cascades** across the network:
|
|
952
989
|
*
|
|
953
|
-
*
|
|
954
|
-
*
|
|
955
|
-
*
|
|
956
|
-
* - Produces output VCards (Tokens) for output Places
|
|
990
|
+
* ```
|
|
991
|
+
* T1 → V1 → T2 → V2 → T3 → ... → Vn
|
|
992
|
+
* ```
|
|
957
993
|
*
|
|
958
|
-
*
|
|
994
|
+
* Each VerificationVCard (Vi) serves as:
|
|
995
|
+
* 1. **Post-condition** of transition Ti (what it produces)
|
|
996
|
+
* 2. **Pre-condition** of transition Ti+1 (what enables next step)
|
|
959
997
|
*
|
|
960
|
-
*
|
|
998
|
+
* ## DOTS Vocabulary Role: ARENA + ACTION
|
|
961
999
|
*
|
|
962
|
-
*
|
|
963
|
-
*
|
|
964
|
-
*
|
|
965
|
-
* - t• = Post-set (output VCards produced)
|
|
1000
|
+
* VCard is both:
|
|
1001
|
+
* - **Arena**: Interface type defining what can interact (subject_did, capabilities, external_refs)
|
|
1002
|
+
* - **Action**: Morphism where interactions (PCards) act on systems (MCards)
|
|
966
1003
|
*
|
|
967
|
-
* ##
|
|
1004
|
+
* ## The Four Roles:
|
|
1005
|
+
* 1. Identity & Credential Container (The "Who")
|
|
1006
|
+
* 2. Verification Hub (The "Rules")
|
|
1007
|
+
* 3. Side Effect Manager (The "Bridge")
|
|
1008
|
+
* 4. Input/Output Gatekeeper (The "Gate")
|
|
968
1009
|
*
|
|
969
|
-
*
|
|
970
|
-
* - **Abstract (A)**: WHY - Specification, intent, type signature
|
|
971
|
-
* - **Concrete (C)**: HOW - Implementation, runtime logic
|
|
972
|
-
* - **Balanced (B)**: WHAT - Tests, verification expectations
|
|
1010
|
+
* ## VCard as Egress Gate: The Sovereign Boundary
|
|
973
1011
|
*
|
|
974
|
-
*
|
|
1012
|
+
* When a VerificationVCard is produced, it may also serve as **egress authorization**:
|
|
975
1013
|
*
|
|
976
|
-
*
|
|
977
|
-
*
|
|
1014
|
+
* | Egress Role | VCard Content | Enables |
|
|
1015
|
+
* |-------------|--------------|---------|
|
|
1016
|
+
* | Export Authorization | `egress_capability: { destination_did, scope }` | Sharing to specific PKCs |
|
|
1017
|
+
* | Cross-PKC Transition | `transferable: true` | Token moves to destination's Petri Net |
|
|
1018
|
+
* | Federation Trigger | Signed VCard bundle | Downstream PKC's transitions enabled |
|
|
978
1019
|
*
|
|
979
|
-
* @see docs/
|
|
1020
|
+
* @see docs/VCard_Impl.md for full implementation specification
|
|
980
1021
|
*/
|
|
981
1022
|
|
|
982
|
-
type ClmObject = Record<string, unknown>;
|
|
983
1023
|
/**
|
|
984
|
-
*
|
|
1024
|
+
* Scope of a capability token.
|
|
985
1025
|
*/
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
purpose?: string;
|
|
1026
|
+
declare enum CapabilityScope {
|
|
1027
|
+
READ = "read",
|
|
1028
|
+
WRITE = "write",
|
|
1029
|
+
EXECUTE = "execute",
|
|
1030
|
+
ADMIN = "admin",
|
|
1031
|
+
DELEGATE = "delegate"
|
|
993
1032
|
}
|
|
994
1033
|
/**
|
|
995
|
-
*
|
|
1034
|
+
* Direction of gatekeeper authorization.
|
|
996
1035
|
*/
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
/** Type of VCard to generate */
|
|
1001
|
-
type: 'verification' | 'authorization' | 'audit' | 'result';
|
|
1002
|
-
/** Additional metadata to include in the VCard */
|
|
1003
|
-
metadata?: Record<string, unknown>;
|
|
1036
|
+
declare enum GatekeeperDirection {
|
|
1037
|
+
INGRESS = "ingress",
|
|
1038
|
+
EGRESS = "egress"
|
|
1004
1039
|
}
|
|
1005
1040
|
/**
|
|
1006
|
-
*
|
|
1041
|
+
* A capability token defining authorized actions.
|
|
1042
|
+
*/
|
|
1043
|
+
interface Capability {
|
|
1044
|
+
capabilityId: string;
|
|
1045
|
+
actorDid: string;
|
|
1046
|
+
scope: CapabilityScope;
|
|
1047
|
+
resourcePattern: string;
|
|
1048
|
+
expiresAt?: Date;
|
|
1049
|
+
constraints?: Record<string, unknown>;
|
|
1050
|
+
transferable: boolean;
|
|
1051
|
+
}
|
|
1052
|
+
/**
|
|
1053
|
+
* A verified external reference managed by VCard.
|
|
1054
|
+
*/
|
|
1055
|
+
interface ExternalRef {
|
|
1056
|
+
uri: string;
|
|
1057
|
+
contentHash: string;
|
|
1058
|
+
status: 'verified' | 'pending' | 'stale' | 'invalid';
|
|
1059
|
+
signature?: string;
|
|
1060
|
+
lastVerified?: Date;
|
|
1061
|
+
qosMetrics?: Record<string, unknown>;
|
|
1062
|
+
}
|
|
1063
|
+
type ParsedVCardContent = Record<string, unknown>;
|
|
1064
|
+
type SimulationLogEntry = {
|
|
1065
|
+
timestamp: Date;
|
|
1066
|
+
effectType: string;
|
|
1067
|
+
details: unknown;
|
|
1068
|
+
simulated: true;
|
|
1069
|
+
};
|
|
1070
|
+
/**
|
|
1071
|
+
* An ingress or egress gatekeeper event.
|
|
1072
|
+
*/
|
|
1073
|
+
interface GatekeeperEvent {
|
|
1074
|
+
direction: GatekeeperDirection;
|
|
1075
|
+
timestamp: Date;
|
|
1076
|
+
sourceDid?: string;
|
|
1077
|
+
destinationDid?: string;
|
|
1078
|
+
contentHash: string;
|
|
1079
|
+
authorized: boolean;
|
|
1080
|
+
capabilityUsed?: string;
|
|
1081
|
+
signature?: string;
|
|
1082
|
+
}
|
|
1083
|
+
/**
|
|
1084
|
+
* VCard - The Application Plane unit (Petri Net Token)
|
|
1007
1085
|
*
|
|
1008
|
-
*
|
|
1009
|
-
*
|
|
1086
|
+
* Implements the Empty Schema Principle: VCard IS an MCard.
|
|
1087
|
+
* This class provides a view and runtime state management over the immutable content.
|
|
1088
|
+
*
|
|
1089
|
+
* In Petri Net terms:
|
|
1090
|
+
* - VCard is a **Token** that resides in a **Place** (Handle)
|
|
1091
|
+
* - VCard enables **Transitions** (PCards) to fire when present
|
|
1092
|
+
* - VCard serves as both **Pre-condition** (what enables) and **Post-condition** (what is produced)
|
|
1010
1093
|
*/
|
|
1011
|
-
declare class
|
|
1012
|
-
private
|
|
1013
|
-
private
|
|
1014
|
-
|
|
1094
|
+
declare class VCard extends MCard {
|
|
1095
|
+
private _subjectDid;
|
|
1096
|
+
private _controllerPubkeys;
|
|
1097
|
+
private _capabilities;
|
|
1098
|
+
private _externalRefs;
|
|
1099
|
+
private _exportManifest;
|
|
1100
|
+
private _gatekeeperLog;
|
|
1101
|
+
private _pcardRefsHashes;
|
|
1102
|
+
private _managedEventTypes;
|
|
1103
|
+
private _wrappedPcardHash?;
|
|
1104
|
+
protected constructor(content: Uint8Array, hash: string, g_time: string, contentType: string, hashFunction: string, initialData: ParsedVCardContent);
|
|
1105
|
+
private _initializeMutableState;
|
|
1015
1106
|
/**
|
|
1016
|
-
* Create a new
|
|
1017
|
-
*
|
|
1018
|
-
* @param content - The CLM YAML string or bytes
|
|
1019
|
-
* @param hashAlgorithm - Hash algorithm to use
|
|
1020
|
-
* @param isLens - Whether this acts primarily as a Lens (default true)
|
|
1107
|
+
* Create a new VCard from parameters.
|
|
1108
|
+
* Follows strict UPTV structure { vcard: { ... } }.
|
|
1021
1109
|
*/
|
|
1022
|
-
static
|
|
1110
|
+
static createVCard(subjectDid: string, controllerPubkeys: string[], capabilities?: Capability[], externalRefs?: ExternalRef[], managedEventTypes?: string[], wrappedPcardHash?: string, hashAlgorithm?: string, extraFields?: Record<string, any>): Promise<VCard>;
|
|
1023
1111
|
/**
|
|
1024
|
-
*
|
|
1025
|
-
*
|
|
1026
|
-
* Automatically extracts dependencies from the CLM structure if available.
|
|
1112
|
+
* Create a VCard wrapper from an existing MCard.
|
|
1027
1113
|
*/
|
|
1114
|
+
static fromMCard(card: MCard): Promise<VCard>;
|
|
1028
1115
|
getDOTSMetadata(): DOTSMetadata;
|
|
1116
|
+
get subjectDid(): string;
|
|
1117
|
+
get controllerPubkeys(): string[];
|
|
1118
|
+
get capabilities(): Capability[];
|
|
1119
|
+
get externalRefs(): ExternalRef[];
|
|
1120
|
+
addCapability(capability: Capability): void;
|
|
1121
|
+
getValidCapabilities(): Capability[];
|
|
1122
|
+
hasCapability(scope: CapabilityScope, resourceHash: string): boolean;
|
|
1123
|
+
addPCardReference(pcardHash: string): void;
|
|
1124
|
+
getPCardReferences(): string[];
|
|
1125
|
+
addExternalRef(ref: ExternalRef): void;
|
|
1126
|
+
getExternalRefsByStatus(status: ExternalRef['status']): ExternalRef[];
|
|
1127
|
+
verifyExternalRef(uri: string, newHash: string): boolean;
|
|
1128
|
+
authorizeIngress(sourceDid: string, contentHash: string, capabilityId?: string): boolean;
|
|
1129
|
+
getManagedEventTypes(): string[];
|
|
1130
|
+
getWrappedPcardHash(): string | undefined;
|
|
1131
|
+
registerForEgress(contentHash: string): boolean;
|
|
1132
|
+
authorizeEgress(destinationDid: string, contentHash: string, capabilityId?: string): boolean;
|
|
1133
|
+
private _logEgress;
|
|
1134
|
+
getGatekeeperLog(direction?: GatekeeperDirection): GatekeeperEvent[];
|
|
1135
|
+
logGatekeeperEvent(event: GatekeeperEvent): void;
|
|
1136
|
+
getExportManifest(): string[];
|
|
1137
|
+
simulateMode(): VCardSimulation;
|
|
1029
1138
|
/**
|
|
1030
|
-
* Get the
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
* Get the Abstract Specification section (UPTV Role: Abstract)
|
|
1036
|
-
*/
|
|
1037
|
-
get abstract(): unknown;
|
|
1038
|
-
/**
|
|
1039
|
-
* Get the Concrete Implementation section (UPTV Role: Concrete)
|
|
1040
|
-
*/
|
|
1041
|
-
get concrete(): unknown;
|
|
1042
|
-
/**
|
|
1043
|
-
* Get the Balanced Expectations (tests) section (UPTV Role: Balanced)
|
|
1044
|
-
*/
|
|
1045
|
-
get balanced(): unknown;
|
|
1046
|
-
/**
|
|
1047
|
-
* Get the Abstract Specification section (Legacy)
|
|
1048
|
-
*/
|
|
1049
|
-
get abstractSpec(): unknown;
|
|
1050
|
-
/**
|
|
1051
|
-
* Get the Concrete Implementation section (Legacy)
|
|
1139
|
+
* Get the handle where this VCard token currently resides
|
|
1140
|
+
*
|
|
1141
|
+
* In Petri Net terms, this is the "Place" where the token is located.
|
|
1142
|
+
*
|
|
1143
|
+
* @returns Handle string if available in content, or hash-based handle
|
|
1052
1144
|
*/
|
|
1053
|
-
|
|
1145
|
+
getTokenHandle(): string;
|
|
1054
1146
|
/**
|
|
1055
|
-
*
|
|
1147
|
+
* Check if this VCard is a VerificationVCard (result of PCard execution)
|
|
1148
|
+
*
|
|
1149
|
+
* VerificationVCards are produced by PCard transitions and contain
|
|
1150
|
+
* execution results with provenance chain.
|
|
1151
|
+
*
|
|
1152
|
+
* @returns True if this is a verification token
|
|
1056
1153
|
*/
|
|
1057
|
-
|
|
1154
|
+
isVerificationVCard(): boolean;
|
|
1058
1155
|
/**
|
|
1059
|
-
*
|
|
1060
|
-
*
|
|
1061
|
-
* Implements profunctor composition using the Coend formula:
|
|
1156
|
+
* Get the previous hash in the provenance chain
|
|
1062
1157
|
*
|
|
1063
|
-
*
|
|
1158
|
+
* In Petri Net terms, this links to the input VCard that was "consumed"
|
|
1159
|
+
* when the transition fired to produce this VCard.
|
|
1064
1160
|
*
|
|
1065
|
-
*
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1161
|
+
* @returns Previous VCard hash if this is part of a verification cascade
|
|
1162
|
+
*/
|
|
1163
|
+
getPreviousHash(): string | undefined;
|
|
1164
|
+
/**
|
|
1165
|
+
* Get the PCard hash that produced this VCard (if verification)
|
|
1069
1166
|
*
|
|
1070
|
-
*
|
|
1071
|
-
* 1. Matching P's output type with Q's input type
|
|
1072
|
-
* 2. Creating a chain where P's result feeds into Q
|
|
1073
|
-
* 3. The composition is associative: (P ⨾ Q) ⨾ R = P ⨾ (Q ⨾ R)
|
|
1167
|
+
* This links the output token to the transition that created it.
|
|
1074
1168
|
*
|
|
1075
|
-
*
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
*
|
|
1169
|
+
* @returns PCard hash that produced this VCard
|
|
1170
|
+
*/
|
|
1171
|
+
getSourcePCardHash(): string | undefined;
|
|
1172
|
+
/**
|
|
1173
|
+
* Create a VerificationVCard from PCard execution result
|
|
1080
1174
|
*
|
|
1081
|
-
*
|
|
1175
|
+
* This is the factory method for producing output tokens in the Petri Net.
|
|
1082
1176
|
*
|
|
1083
|
-
* @param
|
|
1084
|
-
* @
|
|
1177
|
+
* @param pcard - The PCard (Transition) that executed
|
|
1178
|
+
* @param result - Execution result
|
|
1179
|
+
* @param previousVCard - Input VCard (pre-condition) if any
|
|
1180
|
+
* @param success - Whether execution succeeded
|
|
1181
|
+
* @returns New VerificationVCard
|
|
1085
1182
|
*/
|
|
1086
|
-
|
|
1183
|
+
static createVerificationVCard(pcard: {
|
|
1184
|
+
hash: string;
|
|
1185
|
+
getTransitionHandle?: () => string;
|
|
1186
|
+
getBalancedHandle?: () => string;
|
|
1187
|
+
}, result: unknown, previousVCard?: VCard, success?: boolean, hashAlgorithm?: string, executionTelemetry?: Record<string, unknown>): Promise<VCard>;
|
|
1087
1188
|
/**
|
|
1088
|
-
*
|
|
1189
|
+
* Check if this VCard enables a specific PCard to fire
|
|
1089
1190
|
*
|
|
1090
|
-
*
|
|
1191
|
+
* @param requiredHandle - The handle where a precondition VCard must exist
|
|
1192
|
+
* @returns True if this VCard satisfies that precondition
|
|
1091
1193
|
*/
|
|
1092
|
-
|
|
1194
|
+
enablesTransition(requiredHandle: string): boolean;
|
|
1195
|
+
}
|
|
1196
|
+
/**
|
|
1197
|
+
* Simulation context for VCard (EOS Compliance).
|
|
1198
|
+
*/
|
|
1199
|
+
declare class VCardSimulation {
|
|
1200
|
+
private vcard;
|
|
1201
|
+
private log;
|
|
1202
|
+
constructor(vcard: VCard);
|
|
1203
|
+
logEffect(effectType: string, details: unknown): void;
|
|
1204
|
+
getSimulationLog(): SimulationLogEntry[];
|
|
1205
|
+
}
|
|
1206
|
+
|
|
1207
|
+
/**
|
|
1208
|
+
* Type definitions for CLM (Cubical Logic Model) execution.
|
|
1209
|
+
*/
|
|
1210
|
+
/**
|
|
1211
|
+
* CLM specification structure (parsed from YAML).
|
|
1212
|
+
*/
|
|
1213
|
+
interface CLMSpec {
|
|
1214
|
+
version: string;
|
|
1215
|
+
chapter: {
|
|
1216
|
+
id: number;
|
|
1217
|
+
title: string;
|
|
1218
|
+
mvp_card?: string;
|
|
1219
|
+
pkc_task?: string;
|
|
1220
|
+
};
|
|
1221
|
+
clm: {
|
|
1222
|
+
abstract?: {
|
|
1223
|
+
concept?: string;
|
|
1224
|
+
purpose?: string;
|
|
1225
|
+
description?: string;
|
|
1226
|
+
goal?: string;
|
|
1227
|
+
context?: string;
|
|
1228
|
+
success_criteria?: string;
|
|
1229
|
+
[key: string]: unknown;
|
|
1230
|
+
};
|
|
1231
|
+
abstract_spec?: CLMSpec['clm']['abstract'];
|
|
1232
|
+
concrete?: {
|
|
1233
|
+
manifestation?: string;
|
|
1234
|
+
description?: string;
|
|
1235
|
+
logic_source?: string;
|
|
1236
|
+
runtime?: string;
|
|
1237
|
+
builtin?: boolean;
|
|
1238
|
+
code_file?: string;
|
|
1239
|
+
entry_point?: string;
|
|
1240
|
+
inputs?: string[];
|
|
1241
|
+
process?: string;
|
|
1242
|
+
outputs?: string[];
|
|
1243
|
+
action?: string;
|
|
1244
|
+
boundary?: 'intrinsic' | 'extrinsic';
|
|
1245
|
+
runtimes_config?: RuntimeConfig[];
|
|
1246
|
+
[key: string]: unknown;
|
|
1247
|
+
};
|
|
1248
|
+
concrete_impl?: CLMSpec['clm']['concrete'];
|
|
1249
|
+
balanced?: {
|
|
1250
|
+
expectation?: string;
|
|
1251
|
+
description?: string;
|
|
1252
|
+
test_cases?: unknown[];
|
|
1253
|
+
examples?: unknown[];
|
|
1254
|
+
[key: string]: unknown;
|
|
1255
|
+
};
|
|
1256
|
+
balanced_exp?: CLMSpec['clm']['balanced'];
|
|
1257
|
+
};
|
|
1258
|
+
examples?: CLMExample[];
|
|
1259
|
+
}
|
|
1260
|
+
/**
|
|
1261
|
+
* Runtime configuration for multi-runtime CLMs.
|
|
1262
|
+
*/
|
|
1263
|
+
interface RuntimeConfig {
|
|
1264
|
+
name: string;
|
|
1265
|
+
file?: string;
|
|
1266
|
+
binary?: string;
|
|
1267
|
+
module?: string;
|
|
1268
|
+
entry?: string;
|
|
1269
|
+
}
|
|
1270
|
+
/**
|
|
1271
|
+
* CLM example definition.
|
|
1272
|
+
*/
|
|
1273
|
+
interface CLMExample {
|
|
1274
|
+
name: string;
|
|
1275
|
+
input?: unknown;
|
|
1276
|
+
assumption?: unknown;
|
|
1277
|
+
expected_output?: unknown;
|
|
1278
|
+
confirmation?: unknown;
|
|
1279
|
+
result_contains?: string;
|
|
1280
|
+
[key: string]: unknown;
|
|
1281
|
+
}
|
|
1282
|
+
/**
|
|
1283
|
+
* Result of executing a single CLM.
|
|
1284
|
+
*/
|
|
1285
|
+
interface ExecutionResult {
|
|
1286
|
+
success: boolean;
|
|
1287
|
+
result?: unknown;
|
|
1288
|
+
error?: string;
|
|
1289
|
+
executionTime: number;
|
|
1290
|
+
clm: {
|
|
1291
|
+
chapter: string;
|
|
1292
|
+
concept: string;
|
|
1293
|
+
manifestation: string;
|
|
1294
|
+
boundary?: string;
|
|
1295
|
+
};
|
|
1296
|
+
}
|
|
1297
|
+
/**
|
|
1298
|
+
* Result of executing on a single runtime (for multi-runtime).
|
|
1299
|
+
*/
|
|
1300
|
+
interface RuntimeResult {
|
|
1301
|
+
runtime: string;
|
|
1302
|
+
success: boolean;
|
|
1303
|
+
result?: unknown;
|
|
1304
|
+
error?: string;
|
|
1305
|
+
executionTime: number;
|
|
1306
|
+
}
|
|
1307
|
+
/**
|
|
1308
|
+
* Result of multi-runtime consensus execution.
|
|
1309
|
+
*/
|
|
1310
|
+
interface MultiRuntimeResult {
|
|
1311
|
+
success: boolean;
|
|
1312
|
+
consensus: boolean;
|
|
1313
|
+
results: RuntimeResult[];
|
|
1314
|
+
consensusValue?: unknown;
|
|
1315
|
+
error?: string;
|
|
1316
|
+
executionTime: number;
|
|
1317
|
+
clm: {
|
|
1318
|
+
chapter: string;
|
|
1319
|
+
concept: string;
|
|
1320
|
+
manifestation: string;
|
|
1321
|
+
boundary?: string;
|
|
1322
|
+
};
|
|
1323
|
+
}
|
|
1324
|
+
/**
|
|
1325
|
+
* Summary of running all examples in a CLM.
|
|
1326
|
+
*/
|
|
1327
|
+
interface RunExamplesSummary {
|
|
1328
|
+
total: number;
|
|
1329
|
+
passed: number;
|
|
1330
|
+
results: ExampleRunResult[];
|
|
1331
|
+
}
|
|
1332
|
+
/**
|
|
1333
|
+
* Result of running a single example.
|
|
1334
|
+
*/
|
|
1335
|
+
interface ExampleRunResult {
|
|
1336
|
+
case: number;
|
|
1337
|
+
name: string;
|
|
1338
|
+
input: unknown;
|
|
1339
|
+
result: unknown;
|
|
1340
|
+
error?: string;
|
|
1341
|
+
expected: unknown;
|
|
1342
|
+
match: boolean;
|
|
1343
|
+
}
|
|
1344
|
+
/**
|
|
1345
|
+
* Execution report for external reporting.
|
|
1346
|
+
*/
|
|
1347
|
+
interface ExecutionReport {
|
|
1348
|
+
status: 'success' | 'failure';
|
|
1349
|
+
result?: unknown;
|
|
1350
|
+
error?: string;
|
|
1351
|
+
chapter_id: number;
|
|
1352
|
+
chapter_title: string;
|
|
1353
|
+
}
|
|
1354
|
+
/**
|
|
1355
|
+
* Summary report for external reporting.
|
|
1356
|
+
*/
|
|
1357
|
+
interface SummaryReport {
|
|
1358
|
+
status: 'success' | 'failure';
|
|
1359
|
+
result: {
|
|
1360
|
+
success: boolean;
|
|
1361
|
+
total: number;
|
|
1362
|
+
results: Array<{
|
|
1363
|
+
case: number;
|
|
1364
|
+
name: string;
|
|
1365
|
+
result: unknown;
|
|
1366
|
+
error?: string;
|
|
1367
|
+
}>;
|
|
1368
|
+
};
|
|
1369
|
+
chapter_id: number;
|
|
1370
|
+
chapter_title: string;
|
|
1371
|
+
}
|
|
1372
|
+
/**
|
|
1373
|
+
* CLM banner lines for display.
|
|
1374
|
+
*/
|
|
1375
|
+
interface CLMBannerLines {
|
|
1376
|
+
header: string[];
|
|
1377
|
+
}
|
|
1378
|
+
|
|
1379
|
+
/**
|
|
1380
|
+
* CLMRunner - Execute JavaScript logic from CLM specifications
|
|
1381
|
+
*
|
|
1382
|
+
* Node.js PTR runtime for interpreting Cubical Logic Models.
|
|
1383
|
+
*
|
|
1384
|
+
* Refactored to use modular components from ./clm/
|
|
1385
|
+
*/
|
|
1386
|
+
|
|
1387
|
+
declare class CLMRunner {
|
|
1388
|
+
private loader;
|
|
1389
|
+
private timeout;
|
|
1390
|
+
private collection?;
|
|
1391
|
+
private privateCollection?;
|
|
1392
|
+
constructor(basePath?: string, timeout?: number, collection?: CardCollection, privateCollection?: CardCollection);
|
|
1093
1393
|
/**
|
|
1094
|
-
*
|
|
1095
|
-
*
|
|
1096
|
-
* Swaps the input/output ports of a tensor product.
|
|
1394
|
+
* Run a CLM directly from a file path.
|
|
1097
1395
|
*/
|
|
1098
|
-
|
|
1396
|
+
runFile(clmPath: string, input?: unknown): Promise<ExecutionResult>;
|
|
1099
1397
|
/**
|
|
1100
|
-
*
|
|
1398
|
+
* Execute a CLM specification with given input.
|
|
1399
|
+
*
|
|
1400
|
+
* Implements Petri Net Transition Semantics:
|
|
1401
|
+
* 1. Constructs PCard (Transition)
|
|
1402
|
+
* 2. Checks Pre-conditions (Firing Rule)
|
|
1403
|
+
* 3. Executes Logic
|
|
1404
|
+
* 4. Produces VerificationVCard (Token)
|
|
1405
|
+
* 5. Persists to Collection (Place)
|
|
1101
1406
|
*/
|
|
1102
|
-
|
|
1407
|
+
executeCLM(clm: CLMSpec, chapterDir: string, input: unknown): Promise<ExecutionResult>;
|
|
1103
1408
|
/**
|
|
1104
|
-
*
|
|
1409
|
+
* Execute a CLM across multiple runtimes and verify consensus.
|
|
1105
1410
|
*/
|
|
1106
|
-
|
|
1411
|
+
executeMultiRuntime(clm: CLMSpec, chapterDir: string, input: unknown): Promise<MultiRuntimeResult>;
|
|
1107
1412
|
/**
|
|
1108
|
-
*
|
|
1413
|
+
* Check if a CLM is a multi-runtime CLM.
|
|
1109
1414
|
*/
|
|
1110
|
-
|
|
1415
|
+
isMultiRuntime(clm: CLMSpec): boolean;
|
|
1111
1416
|
/**
|
|
1112
|
-
*
|
|
1417
|
+
* Build CLM banner for display.
|
|
1113
1418
|
*/
|
|
1114
|
-
|
|
1419
|
+
buildCLMBanner(clm: CLMSpec): CLMBannerLines;
|
|
1115
1420
|
/**
|
|
1116
|
-
*
|
|
1117
|
-
*
|
|
1118
|
-
* These represent the preconditions that must be satisfied before
|
|
1119
|
-
* this PCard (Transition) can fire.
|
|
1120
|
-
*
|
|
1121
|
-
* @returns Array of input VCard references from CLM specification
|
|
1421
|
+
* Build execution report.
|
|
1122
1422
|
*/
|
|
1123
|
-
|
|
1423
|
+
buildExecutionReport(clm: CLMSpec, execution: ExecutionResult): ExecutionReport;
|
|
1124
1424
|
/**
|
|
1125
|
-
*
|
|
1126
|
-
*
|
|
1127
|
-
* These define what VCards (Tokens) this PCard produces when fired.
|
|
1128
|
-
*
|
|
1129
|
-
* @returns Array of output VCard specifications
|
|
1425
|
+
* Build summary report.
|
|
1130
1426
|
*/
|
|
1131
|
-
|
|
1427
|
+
buildSummaryReport(clm: CLMSpec, summary: RunExamplesSummary): SummaryReport;
|
|
1428
|
+
private executeLoader;
|
|
1429
|
+
private executeNetwork;
|
|
1430
|
+
private executeStandard;
|
|
1431
|
+
private executeRecursive;
|
|
1432
|
+
private resolveCodeOrPath;
|
|
1433
|
+
private buildNetworkContext;
|
|
1434
|
+
private buildJavaScriptContext;
|
|
1435
|
+
private buildRunCLM;
|
|
1436
|
+
}
|
|
1437
|
+
|
|
1438
|
+
type PreCheck$1 = (input: MCard) => boolean;
|
|
1439
|
+
type PostCheck$1 = (output: unknown) => boolean;
|
|
1440
|
+
/**
|
|
1441
|
+
* Composition object handling the REPL paradigm logic for the PTREngine.
|
|
1442
|
+
* prep → exec → post → await
|
|
1443
|
+
*/
|
|
1444
|
+
declare class REPLCycle {
|
|
1445
|
+
private engine;
|
|
1446
|
+
constructor(engine: PTREngine);
|
|
1132
1447
|
/**
|
|
1133
|
-
*
|
|
1134
|
-
*
|
|
1135
|
-
* @returns Handle string in form `clm://{module}/{function}/spec`
|
|
1448
|
+
* The Arrow execution primitive orchestrated as a REPL cycle.
|
|
1136
1449
|
*/
|
|
1137
|
-
|
|
1450
|
+
runWithSandwich(pcardHash: string, inputHash: string, preCheck?: PreCheck$1, postCheck?: PostCheck$1, context?: Record<string, any>): Promise<[unknown, VCard, number]>;
|
|
1138
1451
|
/**
|
|
1139
|
-
*
|
|
1140
|
-
*
|
|
1141
|
-
* This is where verification history is tracked in handle_history.
|
|
1142
|
-
*
|
|
1143
|
-
* @returns Handle string for balanced expectations
|
|
1452
|
+
* PHASE 1: PREP (Read & Validate)
|
|
1144
1453
|
*/
|
|
1145
|
-
|
|
1454
|
+
private prep;
|
|
1146
1455
|
/**
|
|
1147
|
-
*
|
|
1148
|
-
*
|
|
1149
|
-
* A transition can fire when all input VCards (preconditions) are present.
|
|
1150
|
-
*
|
|
1151
|
-
* @param availableVCards - Map of handle → VCard hash
|
|
1152
|
-
* @returns Object with canFire boolean and missing preconditions
|
|
1456
|
+
* PHASE 2: EXEC (Evaluate)
|
|
1153
1457
|
*/
|
|
1154
|
-
|
|
1155
|
-
canFire: boolean;
|
|
1156
|
-
missing: string[];
|
|
1157
|
-
};
|
|
1458
|
+
private exec;
|
|
1158
1459
|
/**
|
|
1159
|
-
*
|
|
1160
|
-
*
|
|
1161
|
-
* @returns Runtime name (e.g., 'javascript', 'python', 'lean')
|
|
1460
|
+
* PHASE 3: POST (Print/Bind)
|
|
1162
1461
|
*/
|
|
1163
|
-
|
|
1462
|
+
private post;
|
|
1164
1463
|
/**
|
|
1165
|
-
*
|
|
1166
|
-
*
|
|
1167
|
-
* @returns True if this PCard supports multiple runtimes
|
|
1464
|
+
* PHASE 4: AWAIT (Loop/Record)
|
|
1168
1465
|
*/
|
|
1169
|
-
|
|
1466
|
+
private awaitRecord;
|
|
1170
1467
|
/**
|
|
1171
|
-
*
|
|
1172
|
-
*
|
|
1173
|
-
* Extracts the precondition spec from abstract.preconditions,
|
|
1174
|
-
* classifying each condition by type.
|
|
1175
|
-
*
|
|
1176
|
-
* @returns Object with conditions array and classified conditions
|
|
1468
|
+
* Internal retry wrapper
|
|
1177
1469
|
*/
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
};
|
|
1470
|
+
private _executeWithRetry;
|
|
1471
|
+
}
|
|
1472
|
+
|
|
1473
|
+
declare class BatchProcessor {
|
|
1474
|
+
private engine;
|
|
1475
|
+
constructor(engine: PTREngine);
|
|
1185
1476
|
/**
|
|
1186
|
-
*
|
|
1477
|
+
* Execute a PCard against multiple targets sequentially.
|
|
1187
1478
|
*
|
|
1188
|
-
*
|
|
1189
|
-
* classifying each condition by type.
|
|
1479
|
+
* Task 8: Batch Processing
|
|
1190
1480
|
*
|
|
1191
|
-
* @
|
|
1481
|
+
* @param pcardHash - Hash of the PCard to execute
|
|
1482
|
+
* @param targetHashes - List of target MCard/VCard hashes
|
|
1483
|
+
* @param context - Execution context parameters
|
|
1484
|
+
* @param failFast - If true, stop on first failure; if false, continue and report all
|
|
1192
1485
|
*/
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
};
|
|
1486
|
+
executeBatch(pcardHash: string, targetHashes: string[], context?: Record<string, any>, failFast?: boolean): Promise<Array<{
|
|
1487
|
+
success: boolean;
|
|
1488
|
+
output: any;
|
|
1489
|
+
error?: string;
|
|
1490
|
+
targetHash: string;
|
|
1491
|
+
}>>;
|
|
1200
1492
|
/**
|
|
1201
|
-
*
|
|
1493
|
+
* Execute a PCard against multiple targets in parallel.
|
|
1202
1494
|
*
|
|
1203
|
-
*
|
|
1204
|
-
*
|
|
1495
|
+
* Task 8: Batch Processing Parallel
|
|
1496
|
+
*
|
|
1497
|
+
* @param pcardHash - Hash of the PCard to execute
|
|
1498
|
+
* @param targetHashes - List of target MCard/VCard hashes
|
|
1499
|
+
* @param context - Execution context parameters
|
|
1500
|
+
* @param maxConcurrency - Maximum number of concurrent executions
|
|
1205
1501
|
*/
|
|
1206
|
-
|
|
1502
|
+
executeBatchParallel(pcardHash: string, targetHashes: string[], context?: Record<string, any>, maxConcurrency?: number): Promise<Array<{
|
|
1503
|
+
success: boolean;
|
|
1504
|
+
output: any;
|
|
1505
|
+
error?: string;
|
|
1506
|
+
targetHash: string;
|
|
1507
|
+
}>>;
|
|
1207
1508
|
}
|
|
1208
1509
|
|
|
1209
1510
|
/**
|
|
1210
|
-
*
|
|
1211
|
-
*
|
|
1212
|
-
* This module defines VCard, the sovereign decision layer in the MVP Cards architecture.
|
|
1213
|
-
* VCard is the Applicative that manages all side effects and authorization.
|
|
1214
|
-
*
|
|
1215
|
-
* ## Category Theory Role: APPLICATIVE
|
|
1216
|
-
*
|
|
1217
|
-
* VCard is the **Applicative** in the MVP Cards categorical hierarchy:
|
|
1218
|
-
* - **MCard (Monad)**: Data container with unit and bind
|
|
1219
|
-
* - **PCard (Functor)**: Pure transformation
|
|
1220
|
-
* - **VCard (Applicative)**: Context-aware application `<*> :: F (a -> b) -> F a -> F b`
|
|
1221
|
-
*
|
|
1222
|
-
* The Applicative nature means VCard can encode **static pre-conditions**:
|
|
1223
|
-
* the authorization graph is known ahead of time, while actual execution
|
|
1224
|
-
* depends on runtime results.
|
|
1511
|
+
* PCard Model (Control Plane) - Petri Net TRANSITION
|
|
1225
1512
|
*
|
|
1226
|
-
*
|
|
1513
|
+
* This module defines PCard, the execution unit in the MVP Cards architecture.
|
|
1514
|
+
* PCards are MCards containing a valid CLM (Cubical Logic Model) specification.
|
|
1227
1515
|
*
|
|
1228
|
-
*
|
|
1516
|
+
* ## Categorical Foundation: STRONG PROFUNCTOR
|
|
1229
1517
|
*
|
|
1230
|
-
*
|
|
1231
|
-
* - VCard is the **Token** that resides in Places (Handles)
|
|
1232
|
-
* - Tokens enable Transitions (PCards) to fire
|
|
1233
|
-
* - Token movement represents verification cascade
|
|
1518
|
+
* PCard implements the Strong Profunctor pattern from category theory:
|
|
1234
1519
|
*
|
|
1235
|
-
*
|
|
1236
|
-
* A Petri Net transition fires when all input VCards exist:
|
|
1520
|
+
* P: A^op × B → Set
|
|
1237
1521
|
*
|
|
1238
|
-
*
|
|
1239
|
-
*
|
|
1240
|
-
*
|
|
1522
|
+
* Where:
|
|
1523
|
+
* - A^op denotes contravariance in input types (accepts MORE general)
|
|
1524
|
+
* - B denotes covariance in output types (produces MORE specific)
|
|
1525
|
+
* - Set is the category of sets (our value space)
|
|
1241
1526
|
*
|
|
1242
|
-
*
|
|
1243
|
-
*
|
|
1244
|
-
*
|
|
1245
|
-
* - **Arc Guard**: VCard's Applicative authorization check
|
|
1246
|
-
* - **Token "Consumption"**: Recording `previous_hash` in new VCard
|
|
1527
|
+
* The "Strong" property means PCard supports:
|
|
1528
|
+
* - first: P(A, B) → P(C × A, C × B) (threading context through)
|
|
1529
|
+
* - second: P(A, B) → P(A × C, B × C) (preserving additional structure)
|
|
1247
1530
|
*
|
|
1248
|
-
*
|
|
1531
|
+
* ## Composition via Coend
|
|
1249
1532
|
*
|
|
1250
|
-
*
|
|
1251
|
-
* |------|----------|----------------|
|
|
1252
|
-
* | **Token** | Triggers firing (enables transitions) | `handle_registry.current_hash IS NOT NULL` |
|
|
1253
|
-
* | **Certificate** | Proves correctness after verification | VCard content witnesses Hoare Triple |
|
|
1533
|
+
* Two PCards compose via the Coend (categorical integral):
|
|
1254
1534
|
*
|
|
1255
|
-
*
|
|
1256
|
-
* {h_pre} PCard {h_post}
|
|
1257
|
-
* ```
|
|
1535
|
+
* (P ⨾ Q)(A, C) = ∫ᴮ P(A, B) × Q(B, C)
|
|
1258
1536
|
*
|
|
1259
1537
|
* Where:
|
|
1260
|
-
*
|
|
1261
|
-
*
|
|
1262
|
-
*
|
|
1538
|
+
* - ∫ᴮ is the Coend over the intermediate type B
|
|
1539
|
+
* - P(A, B) is the first PCard (input A, output B)
|
|
1540
|
+
* - Q(B, C) is the second PCard (input B, output C)
|
|
1541
|
+
* - Result is a new PCard from A to C
|
|
1263
1542
|
*
|
|
1264
|
-
*
|
|
1543
|
+
* The `andThen()` method implements this Coend composition.
|
|
1265
1544
|
*
|
|
1266
|
-
*
|
|
1545
|
+
* ## SMC Structure (Symmetric Monoidal Category)
|
|
1267
1546
|
*
|
|
1268
|
-
*
|
|
1269
|
-
*
|
|
1270
|
-
*
|
|
1547
|
+
* PCard composition forms a Symmetric Monoidal Category:
|
|
1548
|
+
* - **Identity**: The "pass-through" PCard
|
|
1549
|
+
* - **Composition**: Sequential chaining via `andThen()` (;)
|
|
1550
|
+
* - **Tensor Product**: Parallel composition via `andAlso()` (⊗)
|
|
1551
|
+
* - **Symmetry**: Port swapping via `swap()` (σ)
|
|
1271
1552
|
*
|
|
1272
|
-
*
|
|
1273
|
-
* 1. **Post-condition** of transition Ti (what it produces)
|
|
1274
|
-
* 2. **Pre-condition** of transition Ti+1 (what enables next step)
|
|
1553
|
+
* ## Functor Role in MVP Cards Hierarchy
|
|
1275
1554
|
*
|
|
1276
|
-
*
|
|
1555
|
+
* PCard is the **Functor** in the categorical hierarchy:
|
|
1556
|
+
* - **MCard (Monad)**: Data container
|
|
1557
|
+
* - **PCard (Functor)**: Pure transformation `fmap :: (a -> b) -> F a -> F b`
|
|
1558
|
+
* - **VCard (Applicative)**: Context-aware application
|
|
1277
1559
|
*
|
|
1278
|
-
*
|
|
1279
|
-
* - **Arena**: Interface type defining what can interact (subject_did, capabilities, external_refs)
|
|
1280
|
-
* - **Action**: Morphism where interactions (PCards) act on systems (MCards)
|
|
1560
|
+
* ## Petri Net Role: TRANSITION
|
|
1281
1561
|
*
|
|
1282
|
-
*
|
|
1283
|
-
*
|
|
1284
|
-
*
|
|
1285
|
-
*
|
|
1286
|
-
* 4. Input/Output Gatekeeper (The "Gate")
|
|
1562
|
+
* In the Categorical Petri Net model, PCard is the **Transition**:
|
|
1563
|
+
* - Consumes input VCards (Tokens) from input Places
|
|
1564
|
+
* - Executes CLM logic (Abstract → Concrete transformation)
|
|
1565
|
+
* - Produces output VCards (Tokens) for output Places
|
|
1287
1566
|
*
|
|
1288
|
-
*
|
|
1567
|
+
* ### The Firing Rule
|
|
1289
1568
|
*
|
|
1290
|
-
*
|
|
1569
|
+
* M' = M - •t + t•
|
|
1291
1570
|
*
|
|
1292
|
-
*
|
|
1293
|
-
*
|
|
1294
|
-
*
|
|
1295
|
-
*
|
|
1296
|
-
* | Federation Trigger | Signed VCard bundle | Downstream PKC's transitions enabled |
|
|
1571
|
+
* Where:
|
|
1572
|
+
* - M = Current marking (token distribution)
|
|
1573
|
+
* - •t = Pre-set (input VCards required)
|
|
1574
|
+
* - t• = Post-set (output VCards produced)
|
|
1297
1575
|
*
|
|
1298
|
-
*
|
|
1576
|
+
* ## CLM Triad: Abstract, Concrete, Balanced
|
|
1577
|
+
*
|
|
1578
|
+
* PCard content encodes the three dimensions:
|
|
1579
|
+
* - **Abstract (A)**: WHY - Specification, intent, type signature
|
|
1580
|
+
* - **Concrete (C)**: HOW - Implementation, runtime logic
|
|
1581
|
+
* - **Balanced (B)**: WHAT - Tests, verification expectations
|
|
1582
|
+
*
|
|
1583
|
+
* ## DOTS Vocabulary Role: LENS + CHART
|
|
1584
|
+
*
|
|
1585
|
+
* - **Lens**: Tight morphism (Abstract ↔ Concrete coherence)
|
|
1586
|
+
* - **Chart**: Loose morphism (Balanced expectations wiring)
|
|
1587
|
+
*
|
|
1588
|
+
* @see docs/PCard_Impl.md for full implementation specification
|
|
1299
1589
|
*/
|
|
1300
1590
|
|
|
1591
|
+
type ClmObject = Record<string, unknown>;
|
|
1301
1592
|
/**
|
|
1302
|
-
*
|
|
1303
|
-
*/
|
|
1304
|
-
declare enum CapabilityScope {
|
|
1305
|
-
READ = "read",
|
|
1306
|
-
WRITE = "write",
|
|
1307
|
-
EXECUTE = "execute",
|
|
1308
|
-
ADMIN = "admin",
|
|
1309
|
-
DELEGATE = "delegate"
|
|
1310
|
-
}
|
|
1311
|
-
/**
|
|
1312
|
-
* Direction of gatekeeper authorization.
|
|
1313
|
-
*/
|
|
1314
|
-
declare enum GatekeeperDirection {
|
|
1315
|
-
INGRESS = "ingress",
|
|
1316
|
-
EGRESS = "egress"
|
|
1317
|
-
}
|
|
1318
|
-
/**
|
|
1319
|
-
* A capability token defining authorized actions.
|
|
1320
|
-
*/
|
|
1321
|
-
interface Capability {
|
|
1322
|
-
capabilityId: string;
|
|
1323
|
-
actorDid: string;
|
|
1324
|
-
scope: CapabilityScope;
|
|
1325
|
-
resourcePattern: string;
|
|
1326
|
-
expiresAt?: Date;
|
|
1327
|
-
constraints?: Record<string, unknown>;
|
|
1328
|
-
transferable: boolean;
|
|
1329
|
-
}
|
|
1330
|
-
/**
|
|
1331
|
-
* A verified external reference managed by VCard.
|
|
1593
|
+
* Input VCard reference for Petri Net pre-condition
|
|
1332
1594
|
*/
|
|
1333
|
-
interface
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1595
|
+
interface InputVCardRef {
|
|
1596
|
+
/** Handle name (Place) where precondition VCard must exist */
|
|
1597
|
+
handle: string;
|
|
1598
|
+
/** Expected VCard hash (optional, for strict matching) */
|
|
1599
|
+
expectedHash?: string;
|
|
1600
|
+
/** Purpose of this precondition (e.g., 'authenticate', 'authorize') */
|
|
1601
|
+
purpose?: string;
|
|
1340
1602
|
}
|
|
1341
|
-
type ParsedVCardContent = Record<string, unknown>;
|
|
1342
|
-
type SimulationLogEntry = {
|
|
1343
|
-
timestamp: Date;
|
|
1344
|
-
effectType: string;
|
|
1345
|
-
details: unknown;
|
|
1346
|
-
simulated: true;
|
|
1347
|
-
};
|
|
1348
1603
|
/**
|
|
1349
|
-
*
|
|
1604
|
+
* Output VCard specification for Petri Net post-condition
|
|
1350
1605
|
*/
|
|
1351
|
-
interface
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
capabilityUsed?: string;
|
|
1359
|
-
signature?: string;
|
|
1606
|
+
interface OutputVCardSpec {
|
|
1607
|
+
/** Handle name (Place) where output VCard will be deposited */
|
|
1608
|
+
handle: string;
|
|
1609
|
+
/** Type of VCard to generate */
|
|
1610
|
+
type: 'verification' | 'authorization' | 'audit' | 'result';
|
|
1611
|
+
/** Additional metadata to include in the VCard */
|
|
1612
|
+
metadata?: Record<string, unknown>;
|
|
1360
1613
|
}
|
|
1361
1614
|
/**
|
|
1362
|
-
*
|
|
1363
|
-
*
|
|
1364
|
-
* Implements the Empty Schema Principle: VCard IS an MCard.
|
|
1365
|
-
* This class provides a view and runtime state management over the immutable content.
|
|
1615
|
+
* PCard - The Control Plane unit (Petri Net Transition)
|
|
1366
1616
|
*
|
|
1367
|
-
*
|
|
1368
|
-
*
|
|
1369
|
-
* - VCard enables **Transitions** (PCards) to fire when present
|
|
1370
|
-
* - VCard serves as both **Pre-condition** (what enables) and **Post-condition** (what is produced)
|
|
1617
|
+
* A PCard is an MCard whose content is a valid CLM specification.
|
|
1618
|
+
* It represents a transformation (Lens) with a specific interaction pattern (Chart).
|
|
1371
1619
|
*/
|
|
1372
|
-
declare class
|
|
1373
|
-
private
|
|
1374
|
-
private
|
|
1375
|
-
|
|
1376
|
-
private _externalRefs;
|
|
1377
|
-
private _exportManifest;
|
|
1378
|
-
private _gatekeeperLog;
|
|
1379
|
-
private _pcardRefsHashes;
|
|
1380
|
-
protected constructor(content: Uint8Array, hash: string, g_time: string, contentType: string, hashFunction: string, initialData: ParsedVCardContent);
|
|
1381
|
-
private _initializeMutableState;
|
|
1620
|
+
declare class PCard extends MCard {
|
|
1621
|
+
private readonly parsedClm;
|
|
1622
|
+
private readonly isLens;
|
|
1623
|
+
protected constructor(content: Uint8Array, hash: string, g_time: string, contentType: string, hashFunction: string, parsedClm: ClmObject, isLens: boolean);
|
|
1382
1624
|
/**
|
|
1383
|
-
* Create a new
|
|
1384
|
-
*
|
|
1625
|
+
* Create a new PCard from CLM content
|
|
1626
|
+
*
|
|
1627
|
+
* @param content - The CLM YAML string or bytes
|
|
1628
|
+
* @param hashAlgorithm - Hash algorithm to use
|
|
1629
|
+
* @param isLens - Whether this acts primarily as a Lens (default true)
|
|
1385
1630
|
*/
|
|
1386
|
-
static
|
|
1631
|
+
static create(content: string | Uint8Array, hashAlgorithm?: string, isLens?: boolean): Promise<PCard>;
|
|
1387
1632
|
/**
|
|
1388
|
-
*
|
|
1633
|
+
* Get DOTS vocabulary metadata for this PCard
|
|
1634
|
+
*
|
|
1635
|
+
* Automatically extracts dependencies from the CLM structure if available.
|
|
1389
1636
|
*/
|
|
1390
|
-
static fromMCard(card: MCard): Promise<VCard>;
|
|
1391
1637
|
getDOTSMetadata(): DOTSMetadata;
|
|
1392
|
-
get subjectDid(): string;
|
|
1393
|
-
get controllerPubkeys(): string[];
|
|
1394
|
-
get capabilities(): Capability[];
|
|
1395
|
-
get externalRefs(): ExternalRef[];
|
|
1396
|
-
addCapability(capability: Capability): void;
|
|
1397
|
-
getValidCapabilities(): Capability[];
|
|
1398
|
-
hasCapability(scope: CapabilityScope, resourceHash: string): boolean;
|
|
1399
|
-
addPCardReference(pcardHash: string): void;
|
|
1400
|
-
getPCardReferences(): string[];
|
|
1401
|
-
addExternalRef(ref: ExternalRef): void;
|
|
1402
|
-
getExternalRefsByStatus(status: ExternalRef['status']): ExternalRef[];
|
|
1403
|
-
verifyExternalRef(uri: string, newHash: string): boolean;
|
|
1404
|
-
authorizeIngress(sourceDid: string, contentHash: string, capabilityId?: string): boolean;
|
|
1405
|
-
registerForEgress(contentHash: string): boolean;
|
|
1406
|
-
authorizeEgress(destinationDid: string, contentHash: string, capabilityId?: string): boolean;
|
|
1407
|
-
private _logEgress;
|
|
1408
|
-
getGatekeeperLog(direction?: GatekeeperDirection): GatekeeperEvent[];
|
|
1409
|
-
getExportManifest(): string[];
|
|
1410
|
-
simulateMode(): VCardSimulation;
|
|
1411
1638
|
/**
|
|
1412
|
-
* Get the
|
|
1413
|
-
*
|
|
1414
|
-
* In Petri Net terms, this is the "Place" where the token is located.
|
|
1415
|
-
*
|
|
1416
|
-
* @returns Handle string if available in content, or hash-based handle
|
|
1639
|
+
* Get the parsed CLM object
|
|
1417
1640
|
*/
|
|
1418
|
-
|
|
1641
|
+
get clm(): ClmObject;
|
|
1642
|
+
private getSection;
|
|
1419
1643
|
/**
|
|
1420
|
-
*
|
|
1421
|
-
*
|
|
1422
|
-
* VerificationVCards are produced by PCard transitions and contain
|
|
1423
|
-
* execution results with provenance chain.
|
|
1424
|
-
*
|
|
1425
|
-
* @returns True if this is a verification token
|
|
1644
|
+
* Get the Abstract Specification section (UPTV Role: Abstract)
|
|
1426
1645
|
*/
|
|
1427
|
-
|
|
1646
|
+
get abstract(): unknown;
|
|
1428
1647
|
/**
|
|
1429
|
-
* Get the
|
|
1430
|
-
*
|
|
1431
|
-
* In Petri Net terms, this links to the input VCard that was "consumed"
|
|
1432
|
-
* when the transition fired to produce this VCard.
|
|
1433
|
-
*
|
|
1434
|
-
* @returns Previous VCard hash if this is part of a verification cascade
|
|
1648
|
+
* Get the Concrete Implementation section (UPTV Role: Concrete)
|
|
1435
1649
|
*/
|
|
1436
|
-
|
|
1650
|
+
get concrete(): unknown;
|
|
1437
1651
|
/**
|
|
1438
|
-
* Get the
|
|
1652
|
+
* Get the Balanced Expectations (tests) section (UPTV Role: Balanced)
|
|
1653
|
+
*/
|
|
1654
|
+
get balanced(): unknown;
|
|
1655
|
+
/**
|
|
1656
|
+
* Get the Abstract Specification section (Legacy)
|
|
1657
|
+
*/
|
|
1658
|
+
get abstractSpec(): unknown;
|
|
1659
|
+
/**
|
|
1660
|
+
* Get the Concrete Implementation section (Legacy)
|
|
1661
|
+
*/
|
|
1662
|
+
get concreteImpl(): unknown;
|
|
1663
|
+
/**
|
|
1664
|
+
* Get the Balanced Expectations (tests) section (Legacy)
|
|
1665
|
+
*/
|
|
1666
|
+
get balancedExpectations(): unknown;
|
|
1667
|
+
/**
|
|
1668
|
+
* Sequential Composition via Coend (P ⨾ Q)
|
|
1669
|
+
*
|
|
1670
|
+
* Implements profunctor composition using the Coend formula:
|
|
1671
|
+
*
|
|
1672
|
+
* (P ⨾ Q)(A, C) = ∫ᴮ P(A, B) × Q(B, C)
|
|
1439
1673
|
*
|
|
1440
|
-
*
|
|
1674
|
+
* Where:
|
|
1675
|
+
* - this is P: A → B
|
|
1676
|
+
* - otherPCard is Q: B → C
|
|
1677
|
+
* - Result is P ⨾ Q: A → C
|
|
1441
1678
|
*
|
|
1442
|
-
*
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
* Create a VerificationVCard from PCard execution result
|
|
1679
|
+
* The Coend (∫ᴮ) "integrates out" the intermediate type B by:
|
|
1680
|
+
* 1. Matching P's output type with Q's input type
|
|
1681
|
+
* 2. Creating a chain where P's result feeds into Q
|
|
1682
|
+
* 3. The composition is associative: (P ⨾ Q) ⨾ R = P ⨾ (Q ⨾ R)
|
|
1447
1683
|
*
|
|
1448
|
-
*
|
|
1684
|
+
* In PTR execution:
|
|
1685
|
+
* - P is executed first (prep → exec → post)
|
|
1686
|
+
* - P's output VCard becomes Q's input VCard
|
|
1687
|
+
* - Q is executed second
|
|
1688
|
+
* - Final result is Q's output VCard
|
|
1449
1689
|
*
|
|
1450
|
-
*
|
|
1451
|
-
*
|
|
1452
|
-
* @param
|
|
1453
|
-
* @
|
|
1454
|
-
* @returns New VerificationVCard
|
|
1690
|
+
* Note: Named 'andThen' to avoid conflict with Promise.then (Thenable).
|
|
1691
|
+
*
|
|
1692
|
+
* @param otherPCard - The PCard to execute after this one (Q in P ⨾ Q)
|
|
1693
|
+
* @returns A new PCard representing the composed profunctor (P ⨾ Q)
|
|
1455
1694
|
*/
|
|
1456
|
-
|
|
1457
|
-
hash: string;
|
|
1458
|
-
getTransitionHandle?: () => string;
|
|
1459
|
-
getBalancedHandle?: () => string;
|
|
1460
|
-
}, result: unknown, previousVCard?: VCard, success?: boolean, hashAlgorithm?: string): Promise<VCard>;
|
|
1695
|
+
andThen(otherPCard: PCard): Promise<PCard>;
|
|
1461
1696
|
/**
|
|
1462
|
-
*
|
|
1697
|
+
* Tensor Product ($A \otimes B$)
|
|
1463
1698
|
*
|
|
1464
|
-
*
|
|
1465
|
-
* @returns True if this VCard satisfies that precondition
|
|
1699
|
+
* Runs this PCard and otherPCard in parallel.
|
|
1466
1700
|
*/
|
|
1467
|
-
|
|
1701
|
+
andAlso(otherPCard: PCard): Promise<PCard>;
|
|
1468
1702
|
/**
|
|
1469
|
-
*
|
|
1470
|
-
* the input was accepted for evaluation.
|
|
1703
|
+
* Symmetry ($\sigma$)
|
|
1471
1704
|
*
|
|
1472
|
-
*
|
|
1473
|
-
* @param hashAlgorithm - Hash algorithm to use
|
|
1474
|
-
* @returns VCard with type "precondition-witness"
|
|
1705
|
+
* Swaps the input/output ports of a tensor product.
|
|
1475
1706
|
*/
|
|
1476
|
-
|
|
1707
|
+
swap(): Promise<PCard>;
|
|
1477
1708
|
/**
|
|
1478
|
-
*
|
|
1479
|
-
* the output was produced by a PCard evaluation.
|
|
1480
|
-
*
|
|
1481
|
-
* @param output - The execution output
|
|
1482
|
-
* @param pcardHash - Hash of the PCard that produced the output
|
|
1483
|
-
* @param hashAlgorithm - Hash algorithm to use
|
|
1484
|
-
* @returns VCard with type "postcondition-witness"
|
|
1709
|
+
* Run the Balanced Expectations (Proof)
|
|
1485
1710
|
*/
|
|
1486
|
-
|
|
1711
|
+
verify(): Record<string, unknown>;
|
|
1487
1712
|
/**
|
|
1488
|
-
*
|
|
1489
|
-
* composite verification proof.
|
|
1490
|
-
*
|
|
1491
|
-
* @param vPre - Precondition witness VCard
|
|
1492
|
-
* @param vPost - Postcondition witness VCard
|
|
1493
|
-
* @param pcardHash - Hash of the PCard that was evaluated
|
|
1494
|
-
* @param hashAlgorithm - Hash algorithm to use
|
|
1495
|
-
* @returns VCard with type "verification-sandwich"
|
|
1713
|
+
* Run with instrumentation (eBPF/Tracing)
|
|
1496
1714
|
*/
|
|
1497
|
-
|
|
1498
|
-
}
|
|
1499
|
-
/**
|
|
1500
|
-
* Simulation context for VCard (EOS Compliance).
|
|
1501
|
-
*/
|
|
1502
|
-
declare class VCardSimulation {
|
|
1503
|
-
private vcard;
|
|
1504
|
-
private log;
|
|
1505
|
-
constructor(vcard: VCard);
|
|
1506
|
-
logEffect(effectType: string, details: unknown): void;
|
|
1507
|
-
getSimulationLog(): SimulationLogEntry[];
|
|
1508
|
-
}
|
|
1509
|
-
|
|
1510
|
-
/**
|
|
1511
|
-
* PTREngine — The Polynomial Type Runtime Engine (Arrow Interface)
|
|
1512
|
-
*
|
|
1513
|
-
* This is the canonical execution primitive for the MVP Cards architecture.
|
|
1514
|
-
* It implements the formal Arrow interface mandated by the design documents:
|
|
1515
|
-
*
|
|
1516
|
-
* - arr: Lift a pure function into a PTR-managed Arrow (PCard)
|
|
1517
|
-
* - compose: Sequential composition (>>>)
|
|
1518
|
-
* - first: Operate on first element of a product, preserving second
|
|
1519
|
-
*
|
|
1520
|
-
* The `runWithSandwich()` method is the core Arrow evaluation function,
|
|
1521
|
-
* implementing the VCard Sandwich lifecycle:
|
|
1522
|
-
*
|
|
1523
|
-
* V_pre → PCard(Evaluation Map) → V_post → Sandwich(V_pre, V_post)
|
|
1524
|
-
*
|
|
1525
|
-
* Mirrors Python: mcard.ptr.core.engine.PTREngine
|
|
1526
|
-
*
|
|
1527
|
-
* Usage:
|
|
1528
|
-
* import { PTREngine } from './PTREngine.js';
|
|
1529
|
-
* const engine = new PTREngine(collection);
|
|
1530
|
-
* const [output, sandwich] = await engine.runWithSandwich(pcardHash, inputHash);
|
|
1531
|
-
*
|
|
1532
|
-
* @module PTREngine
|
|
1533
|
-
*/
|
|
1534
|
-
|
|
1535
|
-
type PreCheck = (input: MCard) => boolean;
|
|
1536
|
-
type PostCheck = (output: unknown) => boolean;
|
|
1537
|
-
/**
|
|
1538
|
-
* PTREngine — The formal Arrow execution engine.
|
|
1539
|
-
*
|
|
1540
|
-
* Replaces ad-hoc CLMRunner execution paths with a formal
|
|
1541
|
-
* VCard Sandwich lifecycle. Every PCard execution generates
|
|
1542
|
-
* (V_pre, V_post) boundary proofs.
|
|
1543
|
-
*/
|
|
1544
|
-
declare class PTREngine {
|
|
1545
|
-
private collection;
|
|
1546
|
-
private executionLog;
|
|
1547
|
-
private runner;
|
|
1715
|
+
profile(): Record<string, unknown>;
|
|
1548
1716
|
/**
|
|
1549
|
-
*
|
|
1550
|
-
*
|
|
1551
|
-
* @param storageCollection - MCard collection for long-term knowledge (mcard_collection.db)
|
|
1552
|
-
* @param executionLogCollection - MCard collection for execution traces (execution_log.db).
|
|
1553
|
-
* If not provided, traces are written to storageCollection.
|
|
1554
|
-
* @param options - Additional configuration
|
|
1717
|
+
* Run in Operative mode (Step-by-step)
|
|
1555
1718
|
*/
|
|
1556
|
-
|
|
1557
|
-
basePath?: string;
|
|
1558
|
-
timeout?: number;
|
|
1559
|
-
});
|
|
1719
|
+
debug(): Record<string, unknown>;
|
|
1560
1720
|
/**
|
|
1561
|
-
*
|
|
1562
|
-
*
|
|
1563
|
-
* Implements the VCard Sandwich lifecycle:
|
|
1564
|
-
* V_pre → PCard(Evaluation Map) → V_post
|
|
1565
|
-
*
|
|
1566
|
-
* @param pcardHash - Hash of the PCard to execute
|
|
1567
|
-
* @param inputHash - Hash of the input MCard
|
|
1568
|
-
* @param preCheck - Optional callable to validate preconditions on input
|
|
1569
|
-
* @param postCheck - Optional callable to validate postconditions on output
|
|
1570
|
-
* @returns Tuple of [execution_output, vcard_sandwich]
|
|
1571
|
-
* @throws PreconditionViolation if preCheck returns false
|
|
1572
|
-
* @throws PostconditionViolation if postCheck returns false
|
|
1721
|
+
* Return documentation/explanation
|
|
1573
1722
|
*/
|
|
1574
|
-
|
|
1723
|
+
explain(): Record<string, unknown>;
|
|
1575
1724
|
/**
|
|
1576
|
-
*
|
|
1725
|
+
* Get input VCard references (Pre-set: •t)
|
|
1577
1726
|
*
|
|
1578
|
-
*
|
|
1579
|
-
*
|
|
1727
|
+
* These represent the preconditions that must be satisfied before
|
|
1728
|
+
* this PCard (Transition) can fire.
|
|
1580
1729
|
*
|
|
1581
|
-
* @
|
|
1582
|
-
* @param context - Execution context (inputs)
|
|
1583
|
-
* @returns Execution report with VCard Sandwich proof hashes
|
|
1730
|
+
* @returns Array of input VCard references from CLM specification
|
|
1584
1731
|
*/
|
|
1585
|
-
|
|
1732
|
+
getInputVCardRefs(): InputVCardRef[];
|
|
1586
1733
|
/**
|
|
1587
|
-
*
|
|
1734
|
+
* Get output VCard specifications (Post-set: t•)
|
|
1588
1735
|
*
|
|
1589
|
-
*
|
|
1736
|
+
* These define what VCards (Tokens) this PCard produces when fired.
|
|
1590
1737
|
*
|
|
1591
|
-
* @
|
|
1592
|
-
* @param name - Human-readable name for the PCard
|
|
1593
|
-
* @returns The created PCard (stored in collection)
|
|
1738
|
+
* @returns Array of output VCard specifications
|
|
1594
1739
|
*/
|
|
1595
|
-
|
|
1740
|
+
getOutputVCardSpecs(): OutputVCardSpec[];
|
|
1596
1741
|
/**
|
|
1597
|
-
*
|
|
1598
|
-
*
|
|
1599
|
-
* Creates a new PCard representing pcardA >>> pcardB,
|
|
1600
|
-
* where the output of A feeds into the input of B.
|
|
1742
|
+
* Get the canonical handle for this PCard (Transition)
|
|
1601
1743
|
*
|
|
1602
|
-
* @
|
|
1603
|
-
* @param pcardBHash - Hash of the second PCard (executed second)
|
|
1604
|
-
* @returns The composed PCard (stored in collection)
|
|
1744
|
+
* @returns Handle string in form `{module}/{function}/spec`
|
|
1605
1745
|
*/
|
|
1606
|
-
|
|
1746
|
+
getTransitionHandle(): string;
|
|
1607
1747
|
/**
|
|
1608
|
-
*
|
|
1609
|
-
*
|
|
1610
|
-
* Creates a new PCard that applies the original PCard to the
|
|
1611
|
-
* first element of a (A, C) pair while preserving C.
|
|
1748
|
+
* Get the balanced expectations handle for this PCard
|
|
1612
1749
|
*
|
|
1613
|
-
*
|
|
1614
|
-
*
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
id: number;
|
|
1630
|
-
title: string;
|
|
1631
|
-
mvp_card?: string;
|
|
1632
|
-
pkc_task?: string;
|
|
1633
|
-
};
|
|
1634
|
-
clm: {
|
|
1635
|
-
abstract?: {
|
|
1636
|
-
concept?: string;
|
|
1637
|
-
purpose?: string;
|
|
1638
|
-
description?: string;
|
|
1639
|
-
goal?: string;
|
|
1640
|
-
context?: string;
|
|
1641
|
-
success_criteria?: string;
|
|
1642
|
-
[key: string]: unknown;
|
|
1643
|
-
};
|
|
1644
|
-
abstract_spec?: CLMSpec['clm']['abstract'];
|
|
1645
|
-
concrete?: {
|
|
1646
|
-
manifestation?: string;
|
|
1647
|
-
description?: string;
|
|
1648
|
-
logic_source?: string;
|
|
1649
|
-
runtime?: string;
|
|
1650
|
-
builtin?: boolean;
|
|
1651
|
-
code_file?: string;
|
|
1652
|
-
entry_point?: string;
|
|
1653
|
-
inputs?: string[];
|
|
1654
|
-
process?: string;
|
|
1655
|
-
outputs?: string[];
|
|
1656
|
-
action?: string;
|
|
1657
|
-
boundary?: 'intrinsic' | 'extrinsic';
|
|
1658
|
-
runtimes_config?: RuntimeConfig[];
|
|
1659
|
-
[key: string]: unknown;
|
|
1660
|
-
};
|
|
1661
|
-
concrete_impl?: CLMSpec['clm']['concrete'];
|
|
1662
|
-
balanced?: {
|
|
1663
|
-
expectation?: string;
|
|
1664
|
-
description?: string;
|
|
1665
|
-
test_cases?: unknown[];
|
|
1666
|
-
examples?: unknown[];
|
|
1667
|
-
[key: string]: unknown;
|
|
1668
|
-
};
|
|
1669
|
-
balanced_exp?: CLMSpec['clm']['balanced'];
|
|
1670
|
-
};
|
|
1671
|
-
examples?: CLMExample[];
|
|
1672
|
-
}
|
|
1673
|
-
/**
|
|
1674
|
-
* Runtime configuration for multi-runtime CLMs.
|
|
1675
|
-
*/
|
|
1676
|
-
interface RuntimeConfig {
|
|
1677
|
-
name: string;
|
|
1678
|
-
file?: string;
|
|
1679
|
-
binary?: string;
|
|
1680
|
-
module?: string;
|
|
1681
|
-
entry?: string;
|
|
1682
|
-
}
|
|
1683
|
-
/**
|
|
1684
|
-
* CLM example definition.
|
|
1685
|
-
*/
|
|
1686
|
-
interface CLMExample {
|
|
1687
|
-
name: string;
|
|
1688
|
-
input?: unknown;
|
|
1689
|
-
expected_output?: unknown;
|
|
1690
|
-
result_contains?: string;
|
|
1691
|
-
[key: string]: unknown;
|
|
1692
|
-
}
|
|
1693
|
-
/**
|
|
1694
|
-
* Result of executing a single CLM.
|
|
1695
|
-
*/
|
|
1696
|
-
interface ExecutionResult {
|
|
1697
|
-
success: boolean;
|
|
1698
|
-
result?: unknown;
|
|
1699
|
-
error?: string;
|
|
1700
|
-
executionTime: number;
|
|
1701
|
-
clm: {
|
|
1702
|
-
chapter: string;
|
|
1703
|
-
concept: string;
|
|
1704
|
-
manifestation: string;
|
|
1705
|
-
boundary?: string;
|
|
1706
|
-
};
|
|
1707
|
-
}
|
|
1708
|
-
/**
|
|
1709
|
-
* Result of executing on a single runtime (for multi-runtime).
|
|
1710
|
-
*/
|
|
1711
|
-
interface RuntimeResult {
|
|
1712
|
-
runtime: string;
|
|
1713
|
-
success: boolean;
|
|
1714
|
-
result?: unknown;
|
|
1715
|
-
error?: string;
|
|
1716
|
-
executionTime: number;
|
|
1717
|
-
}
|
|
1718
|
-
/**
|
|
1719
|
-
* Result of multi-runtime consensus execution.
|
|
1720
|
-
*/
|
|
1721
|
-
interface MultiRuntimeResult {
|
|
1722
|
-
success: boolean;
|
|
1723
|
-
consensus: boolean;
|
|
1724
|
-
results: RuntimeResult[];
|
|
1725
|
-
consensusValue?: unknown;
|
|
1726
|
-
error?: string;
|
|
1727
|
-
executionTime: number;
|
|
1728
|
-
clm: {
|
|
1729
|
-
chapter: string;
|
|
1730
|
-
concept: string;
|
|
1731
|
-
manifestation: string;
|
|
1732
|
-
boundary?: string;
|
|
1750
|
+
* This is where verification history is tracked in handle_history.
|
|
1751
|
+
*
|
|
1752
|
+
* @returns Handle string for balanced expectations
|
|
1753
|
+
*/
|
|
1754
|
+
getBalancedHandle(): string;
|
|
1755
|
+
/**
|
|
1756
|
+
* Check if this PCard (Transition) can fire given the available VCards
|
|
1757
|
+
*
|
|
1758
|
+
* A transition can fire when all input VCards (preconditions) are present.
|
|
1759
|
+
*
|
|
1760
|
+
* @param availableVCards - Map of handle → VCard hash
|
|
1761
|
+
* @returns Object with canFire boolean and missing preconditions
|
|
1762
|
+
*/
|
|
1763
|
+
canFire(availableVCards: Map<string, string>): {
|
|
1764
|
+
canFire: boolean;
|
|
1765
|
+
missing: string[];
|
|
1733
1766
|
};
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
error?: string;
|
|
1761
|
-
expected: unknown;
|
|
1762
|
-
match: boolean;
|
|
1763
|
-
}
|
|
1764
|
-
/**
|
|
1765
|
-
* Execution report for external reporting.
|
|
1766
|
-
*/
|
|
1767
|
-
interface ExecutionReport {
|
|
1768
|
-
status: 'success' | 'failure';
|
|
1769
|
-
result?: unknown;
|
|
1770
|
-
error?: string;
|
|
1771
|
-
chapter_id: number;
|
|
1772
|
-
chapter_title: string;
|
|
1773
|
-
}
|
|
1774
|
-
/**
|
|
1775
|
-
* Summary report for external reporting.
|
|
1776
|
-
*/
|
|
1777
|
-
interface SummaryReport {
|
|
1778
|
-
status: 'success' | 'failure';
|
|
1779
|
-
result: {
|
|
1780
|
-
success: boolean;
|
|
1781
|
-
total: number;
|
|
1782
|
-
results: Array<{
|
|
1783
|
-
case: number;
|
|
1784
|
-
name: string;
|
|
1785
|
-
result: unknown;
|
|
1786
|
-
error?: string;
|
|
1787
|
-
}>;
|
|
1767
|
+
/**
|
|
1768
|
+
* Get the runtime required for this PCard
|
|
1769
|
+
*
|
|
1770
|
+
* @returns Runtime name (e.g., 'javascript', 'python', 'lean')
|
|
1771
|
+
*/
|
|
1772
|
+
getRuntime(): string;
|
|
1773
|
+
/**
|
|
1774
|
+
* Check if this is a multi-runtime PCard
|
|
1775
|
+
*
|
|
1776
|
+
* @returns True if this PCard supports multiple runtimes
|
|
1777
|
+
*/
|
|
1778
|
+
isMultiRuntime(): boolean;
|
|
1779
|
+
/**
|
|
1780
|
+
* Get precondition specification for VCard Sandwich evaluation.
|
|
1781
|
+
*
|
|
1782
|
+
* Extracts the precondition spec from abstract.preconditions,
|
|
1783
|
+
* classifying each condition by type.
|
|
1784
|
+
*
|
|
1785
|
+
* @returns Object with conditions array and classified conditions
|
|
1786
|
+
*/
|
|
1787
|
+
getPreVCardSpec(): {
|
|
1788
|
+
conditions: unknown[];
|
|
1789
|
+
classified: {
|
|
1790
|
+
type: string;
|
|
1791
|
+
condition: unknown;
|
|
1792
|
+
}[];
|
|
1788
1793
|
};
|
|
1789
|
-
|
|
1790
|
-
|
|
1794
|
+
/**
|
|
1795
|
+
* Get postcondition specification for VCard Sandwich evaluation.
|
|
1796
|
+
*
|
|
1797
|
+
* Extracts the postcondition spec from abstract.postconditions,
|
|
1798
|
+
* classifying each condition by type.
|
|
1799
|
+
*
|
|
1800
|
+
* @returns Object with conditions array and classified conditions
|
|
1801
|
+
*/
|
|
1802
|
+
getPostVCardSpec(): {
|
|
1803
|
+
conditions: unknown[];
|
|
1804
|
+
classified: {
|
|
1805
|
+
type: string;
|
|
1806
|
+
condition: unknown;
|
|
1807
|
+
}[];
|
|
1808
|
+
};
|
|
1809
|
+
/**
|
|
1810
|
+
* Classify a condition by its type (function, schema, capability, declarative).
|
|
1811
|
+
*
|
|
1812
|
+
* @param condition - The condition to classify
|
|
1813
|
+
* @returns Object with type and the original condition
|
|
1814
|
+
*/
|
|
1815
|
+
private classifyCondition;
|
|
1816
|
+
/**
|
|
1817
|
+
* Instantiate a VCard explicitly wrapping this PCard.
|
|
1818
|
+
*
|
|
1819
|
+
* This establishes the PCard as the literal factory for its VCards,
|
|
1820
|
+
* ensuring that the `wrappedPcardHash` is permanently embedded into
|
|
1821
|
+
* the generated VCard's content structure.
|
|
1822
|
+
*/
|
|
1823
|
+
createVCard(vcardClass?: any, subjectDid?: string, controllerPubkeys?: string[], capabilities?: any[], externalRefs?: any[], managedEventTypes?: string[], ...args: any[]): Promise<any>;
|
|
1791
1824
|
}
|
|
1825
|
+
|
|
1792
1826
|
/**
|
|
1793
|
-
*
|
|
1827
|
+
* Sandbox Executor
|
|
1828
|
+
*
|
|
1829
|
+
* Executes PCard logic in a sandboxed environment with multi-language support.
|
|
1830
|
+
* Wraps the execution pipeline inside a monadic boundary.
|
|
1794
1831
|
*/
|
|
1795
|
-
|
|
1796
|
-
|
|
1832
|
+
|
|
1833
|
+
declare class SandboxExecutor {
|
|
1834
|
+
private collection;
|
|
1835
|
+
constructor(collection: CardCollection);
|
|
1836
|
+
/**
|
|
1837
|
+
* Executes PCard logic via the underlying CLMRunner.
|
|
1838
|
+
*/
|
|
1839
|
+
executeMonad(pcardObj: PCard, inputMCard: MCard, context: Record<string, any>, runner: CLMRunner): Promise<{
|
|
1840
|
+
result: unknown;
|
|
1841
|
+
error?: string;
|
|
1842
|
+
}>;
|
|
1797
1843
|
}
|
|
1798
1844
|
|
|
1799
1845
|
/**
|
|
1800
|
-
*
|
|
1801
|
-
*
|
|
1802
|
-
* Node.js PTR runtime for interpreting Cubical Logic Models.
|
|
1846
|
+
* Certificate Generator
|
|
1803
1847
|
*
|
|
1804
|
-
*
|
|
1848
|
+
* Handles the generation of computable certificates (VCards) for
|
|
1849
|
+
* the execution phases. Acts as an isolating wrapper around VCardSandwich
|
|
1850
|
+
* and VCard factory boundaries.
|
|
1805
1851
|
*/
|
|
1806
1852
|
|
|
1807
|
-
declare class
|
|
1808
|
-
private
|
|
1809
|
-
|
|
1810
|
-
private collection?;
|
|
1811
|
-
private privateCollection?;
|
|
1812
|
-
constructor(basePath?: string, timeout?: number, collection?: CardCollection, privateCollection?: CardCollection);
|
|
1853
|
+
declare class CertificateGenerator {
|
|
1854
|
+
private collection;
|
|
1855
|
+
constructor(collection: CardCollection);
|
|
1813
1856
|
/**
|
|
1814
|
-
*
|
|
1857
|
+
* Generate V_pre (Precondition Witness)
|
|
1815
1858
|
*/
|
|
1816
|
-
|
|
1859
|
+
generateVCardPre(inputMCard: MCard): Promise<VCard>;
|
|
1817
1860
|
/**
|
|
1818
|
-
*
|
|
1861
|
+
* Generate V_post (Postcondition Witness)
|
|
1819
1862
|
*
|
|
1820
|
-
*
|
|
1821
|
-
*
|
|
1822
|
-
* 2. Checks Pre-conditions (Firing Rule)
|
|
1823
|
-
* 3. Executes Logic
|
|
1824
|
-
* 4. Produces VerificationVCard (Token)
|
|
1825
|
-
* 5. Persists to Collection (Place)
|
|
1863
|
+
* Optionally embeds governance telemetry (Token Arithmetics: M, N, E, Pi)
|
|
1864
|
+
* as structured metadata within the VCard postcondition.
|
|
1826
1865
|
*/
|
|
1827
|
-
|
|
1866
|
+
generateVCardPost(executionOutput: unknown, pcardHash: string, governanceTelemetry?: Record<string, number>): Promise<VCard>;
|
|
1828
1867
|
/**
|
|
1829
|
-
*
|
|
1868
|
+
* Generate Sandwich (Verification Integration)
|
|
1830
1869
|
*/
|
|
1831
|
-
|
|
1870
|
+
generateVerificationSandwich(vPre: VCard, vPost: VCard, pcardHash: string): Promise<VCard>;
|
|
1871
|
+
}
|
|
1872
|
+
|
|
1873
|
+
/**
|
|
1874
|
+
* Correctness tracking and mathematical verification.
|
|
1875
|
+
*/
|
|
1876
|
+
|
|
1877
|
+
declare class CorrectnessTracker {
|
|
1878
|
+
enableAlignmentScoring: boolean;
|
|
1879
|
+
private safetyViolations;
|
|
1880
|
+
private livenessMetrics;
|
|
1881
|
+
constructor(enableAlignmentScoring?: boolean);
|
|
1832
1882
|
/**
|
|
1833
|
-
*
|
|
1883
|
+
* Record a safety property violation.
|
|
1834
1884
|
*/
|
|
1835
|
-
|
|
1885
|
+
recordSafetyViolation(propertyName: string, violationType: string, details: string): void;
|
|
1836
1886
|
/**
|
|
1837
|
-
*
|
|
1887
|
+
* Record progress toward liveness goals.
|
|
1838
1888
|
*/
|
|
1839
|
-
|
|
1889
|
+
recordLivenessMetric(goal: string, progress: number): void;
|
|
1840
1890
|
/**
|
|
1841
|
-
*
|
|
1891
|
+
* Calculate directional alignment using cosine similarity.
|
|
1892
|
+
*
|
|
1893
|
+
* Implements: cos(θ) = (v_actual · v_spec) / (||v_actual|| ||v_spec||)
|
|
1842
1894
|
*/
|
|
1843
|
-
|
|
1844
|
-
name: string;
|
|
1845
|
-
result: ExecutionResult;
|
|
1846
|
-
}>>;
|
|
1895
|
+
calculateAlignment(output: unknown, specEmbedding?: number[]): number | undefined;
|
|
1847
1896
|
/**
|
|
1848
|
-
*
|
|
1897
|
+
* Verify that transformation preserves invariants (Jacobian check).
|
|
1898
|
+
*
|
|
1899
|
+
* Implements: |J| != 0 => transformation is reversible
|
|
1849
1900
|
*/
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1901
|
+
verifyInvariantPreservation(pcard: MCard, target: MCard, output: unknown): boolean;
|
|
1902
|
+
getSafetyViolations(): SafetyViolation[];
|
|
1903
|
+
getLivenessMetrics(): LivenessMetric[];
|
|
1904
|
+
clear(): void;
|
|
1905
|
+
}
|
|
1906
|
+
|
|
1907
|
+
/**
|
|
1908
|
+
* OpenTelemetry Sidecar & Observability Manager
|
|
1909
|
+
*
|
|
1910
|
+
* Implements the telemetry tracing logic from Python's ObservabilityManager.
|
|
1911
|
+
*/
|
|
1912
|
+
declare class OpenTelemetrySidecar {
|
|
1913
|
+
private static instance;
|
|
1914
|
+
private constructor();
|
|
1915
|
+
static getInstance(): OpenTelemetrySidecar;
|
|
1854
1916
|
/**
|
|
1855
|
-
*
|
|
1917
|
+
* Captures execution context, including LLM logs and warnings into observability payload.
|
|
1856
1918
|
*/
|
|
1857
|
-
|
|
1919
|
+
captureTelemetry(executionData: any): Record<string, unknown>;
|
|
1920
|
+
}
|
|
1921
|
+
|
|
1922
|
+
/**
|
|
1923
|
+
* PTREngine — The Polynomial Type Runtime Engine (Arrow Interface)
|
|
1924
|
+
*
|
|
1925
|
+
* This is the canonical execution primitive for the MVP Cards architecture.
|
|
1926
|
+
* It implements the formal Arrow interface mandated by the design documents:
|
|
1927
|
+
*
|
|
1928
|
+
* - arr: Lift a pure function into a PTR-managed Arrow (PCard)
|
|
1929
|
+
* - compose: Sequential composition (>>>)
|
|
1930
|
+
* - first: Operate on first element of a product, preserving second
|
|
1931
|
+
*
|
|
1932
|
+
* The `runWithSandwich()` method is the core Arrow evaluation function,
|
|
1933
|
+
* implementing the VCard Sandwich lifecycle:
|
|
1934
|
+
*
|
|
1935
|
+
* V_pre → PCard(Evaluation Map) → V_post → Sandwich(V_pre, V_post)
|
|
1936
|
+
*
|
|
1937
|
+
* Mirrors Python: mcard.ptr.core.engine.PTREngine
|
|
1938
|
+
*
|
|
1939
|
+
* Usage:
|
|
1940
|
+
* import { PTREngine } from './PTREngine.js';
|
|
1941
|
+
* const engine = new PTREngine(collection);
|
|
1942
|
+
* const [output, sandwich] = await engine.runWithSandwich(pcardHash, inputHash);
|
|
1943
|
+
*
|
|
1944
|
+
* @module PTREngine
|
|
1945
|
+
*/
|
|
1946
|
+
|
|
1947
|
+
type PreCheck = (input: MCard) => boolean;
|
|
1948
|
+
type PostCheck = (output: unknown) => boolean;
|
|
1949
|
+
/**
|
|
1950
|
+
* PTREngine — The formal Arrow execution engine.
|
|
1951
|
+
*
|
|
1952
|
+
* Replaces ad-hoc CLMRunner execution paths with a formal
|
|
1953
|
+
* VCard Sandwich lifecycle. Every PCard execution generates
|
|
1954
|
+
* (V_pre, V_post) boundary proofs.
|
|
1955
|
+
*/
|
|
1956
|
+
declare class PTREngine {
|
|
1957
|
+
private collection;
|
|
1958
|
+
private executionLog;
|
|
1959
|
+
private identitySpace;
|
|
1960
|
+
private runner;
|
|
1961
|
+
repl: REPLCycle;
|
|
1962
|
+
batch: BatchProcessor;
|
|
1963
|
+
sandbox: SandboxExecutor;
|
|
1964
|
+
certifier: CertificateGenerator;
|
|
1965
|
+
correctnessTracker: CorrectnessTracker;
|
|
1966
|
+
observability: OpenTelemetrySidecar;
|
|
1858
1967
|
/**
|
|
1859
|
-
*
|
|
1968
|
+
* Async Factory for PTREngine to support automatic Tri-Database Isolation.
|
|
1860
1969
|
*/
|
|
1861
|
-
|
|
1970
|
+
static create(storageCollection?: CardCollection, executionLogCollection?: CardCollection, identitySpaceCollection?: CardCollection, options?: {
|
|
1971
|
+
basePath?: string;
|
|
1972
|
+
timeout?: number;
|
|
1973
|
+
}): Promise<PTREngine>;
|
|
1862
1974
|
/**
|
|
1863
|
-
*
|
|
1975
|
+
* Initialize PTREngine. (Consider using PTREngine.create() for automatic database isolation)
|
|
1976
|
+
*
|
|
1977
|
+
* @param storageCollection - MCard collection for long-term knowledge (mcard_collection.db)
|
|
1978
|
+
* @param executionLogCollection - MCard collection for execution traces (execution_log.db).
|
|
1979
|
+
* @param identitySpaceCollection - MCard collection for isolated Zero-Trust checks.
|
|
1980
|
+
* @param options - Additional configuration
|
|
1864
1981
|
*/
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1982
|
+
constructor(storageCollection?: CardCollection, executionLogCollection?: CardCollection, identitySpaceCollection?: CardCollection, options?: {
|
|
1983
|
+
basePath?: string;
|
|
1984
|
+
timeout?: number;
|
|
1985
|
+
});
|
|
1986
|
+
getCollection(): CardCollection;
|
|
1987
|
+
getExecutionLog(): CardCollection;
|
|
1988
|
+
getIdentitySpace(): CardCollection;
|
|
1989
|
+
getRunner(): CLMRunner;
|
|
1990
|
+
/**
|
|
1991
|
+
* The Arrow execution primitive — the entire PTR in one method.
|
|
1992
|
+
*
|
|
1993
|
+
* Implements the VCard Sandwich lifecycle:
|
|
1994
|
+
* V_pre → PCard(Evaluation Map) → V_post
|
|
1995
|
+
*
|
|
1996
|
+
* @param pcardHash - Hash of the PCard to execute
|
|
1997
|
+
* @param inputHash - Hash of the input MCard
|
|
1998
|
+
* @param preCheck - Optional callable to validate preconditions on input
|
|
1999
|
+
* @param postCheck - Optional callable to validate postconditions on output
|
|
2000
|
+
* @returns Tuple of [execution_output, vcard_sandwich, retry_count]
|
|
2001
|
+
* @throws PreconditionViolation if preCheck returns false
|
|
2002
|
+
* @throws PostconditionViolation if postCheck returns false
|
|
2003
|
+
*/
|
|
2004
|
+
runWithSandwich(pcardHash: string, inputHash: string, preCheck?: PreCheck, postCheck?: PostCheck, context?: Record<string, any>): Promise<[unknown, VCard, number]>;
|
|
2005
|
+
}
|
|
2006
|
+
|
|
2007
|
+
/**
|
|
2008
|
+
* AuditVerifier handles the Pure Functional Software Deployment (PFSD) auditing phase.
|
|
2009
|
+
* It reads Verification Sandwich MCards and walks the execution log references
|
|
2010
|
+
* to assert Hoare-triples and mathematical state integrity.
|
|
2011
|
+
*/
|
|
2012
|
+
declare class AuditVerifier {
|
|
2013
|
+
private collection;
|
|
2014
|
+
constructor(collection: CardCollection);
|
|
2015
|
+
/**
|
|
2016
|
+
* Takes a Sandwich hash, loads it from the collection, and verifies the
|
|
2017
|
+
* structural integrity of the corresponding VCard_Pre and VCard_Post.
|
|
2018
|
+
*/
|
|
2019
|
+
verifyPfsdCertificate(sandwichHash: string): Promise<boolean>;
|
|
2020
|
+
}
|
|
2021
|
+
|
|
2022
|
+
declare function verifyIsomorphism(sourceHashes: Record<string, string>, destHashes: Record<string, string>): {
|
|
2023
|
+
isomorphic: boolean;
|
|
2024
|
+
missingInDest: string[];
|
|
2025
|
+
missingInSource: string[];
|
|
2026
|
+
hashMismatches: string[];
|
|
2027
|
+
};
|
|
2028
|
+
|
|
2029
|
+
declare const isomorphism_verifyIsomorphism: typeof verifyIsomorphism;
|
|
2030
|
+
declare namespace isomorphism {
|
|
2031
|
+
export { isomorphism_verifyIsomorphism as verifyIsomorphism };
|
|
1874
2032
|
}
|
|
1875
2033
|
|
|
1876
|
-
export { CLMRunner, CardCollection, type CreateEngineOptions, ENGINE_INFO, Either, type EngineEnvironment, type EngineInfo, EngineType, FileIO, IO, LLMConfig, LLMRuntime, index as Lambda, LambdaRuntime, Loader, MCard, Maybe, PTREngine, SandboxWorker, StorageEngine, chatMonad, createEngine, getAvailableEngines, getEngineInfo, getEnginesByEnvironment, promptMonad };
|
|
2034
|
+
export { AuditVerifier, CLMRunner, CardCollection, type CreateEngineOptions, ENGINE_INFO, Either, type EngineEnvironment, type EngineInfo, EngineType, FileIO, IO, isomorphism as IsomorphismValidator, LLMConfig, LLMRuntime, index as Lambda, LambdaRuntime, LivenessMetric, Loader, MCard, Maybe, PTREngine, SafetyViolation, SandboxWorker, StorageEngine, chatMonad, createEngine, getAvailableEngines, getEngineInfo, getEnginesByEnvironment, promptMonad };
|