mcard-js 2.1.16 → 2.1.19

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.
Files changed (44) hide show
  1. package/README.md +15 -6
  2. package/dist/model/MCard.d.ts +45 -20
  3. package/dist/model/MCard.d.ts.map +1 -1
  4. package/dist/model/MCard.js +45 -20
  5. package/dist/model/MCard.js.map +1 -1
  6. package/dist/model/PCard.d.ts +146 -7
  7. package/dist/model/PCard.d.ts.map +1 -1
  8. package/dist/model/PCard.js +235 -10
  9. package/dist/model/PCard.js.map +1 -1
  10. package/dist/model/VCard.d.ts +178 -63
  11. package/dist/model/VCard.d.ts.map +1 -1
  12. package/dist/model/VCard.js +417 -142
  13. package/dist/model/VCard.js.map +1 -1
  14. package/dist/model/detectors/BinaryDetector.d.ts +4 -0
  15. package/dist/model/detectors/BinaryDetector.d.ts.map +1 -1
  16. package/dist/model/detectors/BinaryDetector.js +13 -2
  17. package/dist/model/detectors/BinaryDetector.js.map +1 -1
  18. package/dist/ptr/lambda/LambdaRuntime.d.ts +23 -2
  19. package/dist/ptr/lambda/LambdaRuntime.d.ts.map +1 -1
  20. package/dist/ptr/lambda/LambdaRuntime.js +173 -10
  21. package/dist/ptr/lambda/LambdaRuntime.js.map +1 -1
  22. package/dist/ptr/node/FileSystemUtils.d.ts +1 -0
  23. package/dist/ptr/node/FileSystemUtils.d.ts.map +1 -1
  24. package/dist/ptr/node/FileSystemUtils.js +9 -53
  25. package/dist/ptr/node/FileSystemUtils.js.map +1 -1
  26. package/dist/ptr/node/clm/builtins/index.d.ts +4 -4
  27. package/dist/ptr/node/clm/builtins/index.d.ts.map +1 -1
  28. package/dist/ptr/node/clm/builtins/index.js +26 -15
  29. package/dist/ptr/node/clm/builtins/index.js.map +1 -1
  30. package/dist/ptr/node/clm/loader.d.ts +1 -1
  31. package/dist/ptr/node/clm/loader.d.ts.map +1 -1
  32. package/dist/ptr/node/clm/loader.js +58 -28
  33. package/dist/ptr/node/clm/loader.js.map +1 -1
  34. package/dist/ptr/node/clm/multiruntime.js +3 -3
  35. package/dist/ptr/node/clm/multiruntime.js.map +1 -1
  36. package/dist/ptr/node/clm/runner.d.ts +7 -0
  37. package/dist/ptr/node/clm/runner.d.ts.map +1 -1
  38. package/dist/ptr/node/clm/runner.js +88 -21
  39. package/dist/ptr/node/clm/runner.js.map +1 -1
  40. package/dist/ptr/node/clm/types.d.ts +57 -10
  41. package/dist/ptr/node/clm/types.d.ts.map +1 -1
  42. package/dist/ptr/node/clm/utils.js +2 -2
  43. package/dist/ptr/node/clm/utils.js.map +1 -1
  44. package/package.json +1 -1
package/README.md CHANGED
@@ -607,17 +607,26 @@ To run integration tests against a live Ollama instance:
607
607
  npx vitest tests/rag/Integration.test.ts
608
608
  ```
609
609
 
610
- ## Version 2.1.16 Release Notes (December 15, 2025)
611
- > UPTV Protocol Alignment & Loader Fixes
610
+ ## Version 2.1.16 Release Notes (December 16, 2025)
611
+ > Feature Parity, Refactoring, and UPTV Alignment
612
+
613
+ ### 🏗️ Code Refactoring & Cleanup
614
+ * **Binary Detector Parity**: Refactored `BinaryDetector.ts` to expose `detectFromBytes` and match Python's logic structure, ensuring consistent file signatures detection.
615
+ * **FileSystemUtils Optimization**: `detectContentType` in `FileSystemUtils` now delegates to the central `ContentTypeInterpreter`, removing code duplication and ensuring consistent MIME type detection across the loader.
616
+ * **Handle Validation**: Relaxed validation to allow colons (`:`), supporting URI-like handles (e.g., `vcard://auth/1`) used in the UPTV architecture.
617
+
618
+ ### 🎭 Feature Parity
619
+ * **Petri Net Metadata**: The CLM Runner now attaches `petriNet` metadata (pcardHash, vcardHash, handle) to execution results, matching the Python implementation.
620
+ * **VCard Standardization**:
621
+ - Aligned field names (`success` instead of `verified`, `token` types).
622
+ - Handles now default to `vcard://` namespace.
623
+ * **Global Time**: `GTime` now consistently uses UTC with `Z` suffix, ensuring hash consistency between runtimes.
612
624
 
613
625
  ### 📜 Unifying Protocol of Truth Verification (UPTV)
614
626
  * **Documentation Overhaul**: Updated PTR, CLM, and PCard documentation to align with the **Categorical Petri Net** architecture of UPTV.
615
627
  * **CLM Triad**: Explicitly defined the Abstract ($A$) × Concrete ($C$) × Balanced ($B$) structure as the core verification unit.
616
628
  * **Petri Net Mapping**: Clarified roles: Handle (Place), PCard (Transport/Function), VCard (Token/Evidence).
617
-
618
- ### 🐛 Loader Persistence Fixes
619
- * **Recursive Loading**: Fixed database corruption (`SQLITE_CORRUPT`) issues when recursively loading large directory trees in Node.js.
620
- * **Consistency**: Synchronized filtering logic (ignoring `_` prefix and `config.yaml`) between Python and JavaScript CLM runners.
629
+ * **Loader Persistence**: Fixed database corruption issues during recursive loading.
621
630
 
622
631
  ---
623
632
 
@@ -1,6 +1,26 @@
1
1
  import { DOTSMetadata } from '../types/dots';
2
2
  /**
3
- * MCard - Content-addressable data container
3
+ * MCard - Content-addressable data container (The Monad)
4
+ *
5
+ * ## Category Theory Role: MONAD
6
+ *
7
+ * MCard is the **Monad** in the MVP Cards categorical hierarchy:
8
+ * - **MCard (Monad)**: Data container with `unit` (create) and `bind` (chain)
9
+ * - **PCard (Functor)**: Pure transformation, `fmap` over MCard content
10
+ * - **VCard (Applicative)**: Context-aware application with pre-conditions
11
+ *
12
+ * ## Scale-Free Monadic Infrastructure: Spinoza-Leibniz Synthesis
13
+ *
14
+ * MCard implements the dual philosophical foundation:
15
+ *
16
+ * | Philosopher | Contribution | MCard Implementation |
17
+ * |-------------|--------------|---------------------|
18
+ * | **Spinoza** | One Substance (Deus sive Natura) | Fixed 3-field schema (Terminal Object) |
19
+ * | **Leibniz** | Infinite Monads (Pre-Established Harmony) | Infinite content-addressed entries |
20
+ * | **Both** | No windows / Internal causation | Content-addressing (same hash = same truth) |
21
+ *
22
+ * This enables **Experimental-Operational Symmetry (EOS)**: same behavior from
23
+ * a single user's PKC (100MB) to a planetary LLM registry (1PB).
4
24
  *
5
25
  * ## DOTS Vocabulary Role: CARRIER
6
26
  *
@@ -9,40 +29,48 @@ import { DOTSMetadata } from '../types/dots';
9
29
  * - Hash-links between MCards are **Morphisms** in Car(S)
10
30
  * - The Carrier is the category of all actual data/systems
11
31
  *
12
- * ## EOS Role: Invariant Content (Galois Root)
32
+ * ## Petri Net Role: TOKEN CONTENT
13
33
  *
14
- * MCard provides the **Invariant Substrate** in Experimental-Operational Symmetry:
15
- * - `Hash(Content)` is a **pure function** with no side effects
16
- * - Same content in Dev = Same hash in Prod (environment-invariant)
17
- * - This is the "Joint Reality" P(H,E) = P(E,H) in Bayesian terms
34
+ * In the Categorical Petri Net model:
35
+ * - **MCard content** is what tokens carry
36
+ * - **VCard** is the token type (Applicative wrapper)
37
+ * - **PCard** is the transition that transforms tokens
18
38
  *
19
39
  * ## MVP Cards Architecture: Data Plane
20
40
  *
21
41
  * ```
22
42
  * ┌───────────────────────────────────────────────────────┐
23
43
  * │ APPLICATION PLANE (VCard) │
24
- * │ Value Exchange / AuthN/AuthZ / Sovereign Memory
44
+ * │ Petri Net Token / AuthN/AuthZ / Side Effects
25
45
  * └─────────────────────────┬─────────────────────────────┘
26
- * │ (Policy Triggers)
46
+ * │ (Pre-Condition Check)
27
47
  * ┌─────────────────────────▼─────────────────────────────┐
28
48
  * │ CONTROL PLANE (PCard) │
29
- * │ Polynomial Functor Composition / Monadic Execution
49
+ * │ Petri Net Transition / CLM Logic / Pure Function
30
50
  * └─────────────────────────┬─────────────────────────────┘
31
- * │ (Hash References)
51
+ * │ (Content Transformation)
32
52
  * ┌─────────────────────────▼─────────────────────────────┐
33
53
  * │ DATA PLANE (MCard) ◀── YOU ARE HERE │
34
- * │ Immutable, Content-Addressable Storage / Monad
54
+ * │ Monad / Content-Addressable / Scale-Free Substrate
35
55
  * └───────────────────────────────────────────────────────┘
36
56
  * ```
37
57
  *
38
- * ## The Empty Schema Principle
58
+ * ## The Empty Schema Principle (Kenosis)
39
59
  *
40
- * MCard embodies the Empty Schema Principle from the Wordless Book:
60
+ * MCard embodies the Empty Schema Principle:
41
61
  * - Schema contains NO domain-specific terms (only hash, content, g_time)
42
62
  * - Domain customization happens via data (INSERT), not schema changes
43
63
  * - Universal applicability: same structure for ANY domain
64
+ * - This emptiness enables universality (Kenosis in code)
65
+ *
66
+ * ## Three Tables as Irreducible Semiotic Triad
44
67
  *
45
- * ## Functional Requirements (from design docs)
68
+ * The MCard infrastructure uses three tables (Peirce's semiotics):
69
+ * - `card` (Object/Referent): what the content means
70
+ * - `handle_registry` (Representamen/Sign): which concept is named
71
+ * - `handle_history` (Interpretant): how understanding evolved
72
+ *
73
+ * ## Functional Requirements
46
74
  *
47
75
  * | ID | Requirement | Implementation |
48
76
  * |----|-------------|----------------|
@@ -50,17 +78,14 @@ import { DOTSMetadata } from '../types/dots';
50
78
  * | M-2 | CRD-only (no UPDATE) | Immutable class, `readonly` fields |
51
79
  * | M-3 | Include g_time for ordering | `this.g_time` field |
52
80
  * | M-4 | Human-readable content | `getContentAsText()` method |
81
+ * | MONAD-1 | Unit (pure) operation | `MCard.create(content)` |
82
+ * | MONAD-2 | Bind (chain) operation | `MCard.bind(f)` via hash reference |
53
83
  * | EOS-M1 | Hash is pure function | No side effects in hash computation |
54
84
  * | EOS-M2 | Content is immutable | All fields are `readonly` |
55
85
  *
56
86
  * @see {@link DOTSRole.CARRIER} for DOTS vocabulary definition
57
87
  * @see {@link EOSRole.INVARIANT_CONTENT} for EOS role definition
58
- * @see docs/WorkingNotes/Permanent/Projects/PKC Kernel/MCard.md for full specification
59
- *
60
- * Each MCard has:
61
- * - content: Raw bytes (Uint8Array)
62
- * - hash: SHA-256 cryptographic hash (the Carrier Object identity)
63
- * - g_time: Global timestamp with algorithm identifier
88
+ * @see docs/MCard_Impl.md for full implementation specification
64
89
  */
65
90
  export declare class MCard {
66
91
  readonly content: Uint8Array;
@@ -1 +1 @@
1
- {"version":3,"file":"MCard.d.ts","sourceRoot":"","sources":["../../src/model/MCard.ts"],"names":[],"mappings":"AAGA,OAAO,EAAgC,YAAY,EAA2B,MAAM,eAAe,CAAC;AAEpG;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuFG;AACH,qBAAa,KAAK;IACd,QAAQ,CAAC,OAAO,EAAE,UAAU,CAAC;IAC7B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAE9B,SAAS,aAAa,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM;IAQlH;;OAEG;WACU,MAAM,CAAC,OAAO,EAAE,MAAM,GAAG,UAAU,EAAE,aAAa,GAAE,MAAiB,GAAG,OAAO,CAAC,KAAK,CAAC;IAoBnG;;OAEG;IACH,MAAM,CAAC,QAAQ,CAAC,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,KAAK;IAMzE;;OAEG;IACH,gBAAgB,IAAI,MAAM;IAI1B;;OAEG;IACH,UAAU,IAAI,UAAU;IAIxB;;OAEG;IACH,QAAQ,IAAI;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAC;QAAC,YAAY,EAAE,MAAM,CAAA;KAAE;IAUxG;;;;;;;;;;;;;;;;;;;OAmBG;IACH,eAAe,CAAC,SAAS,GAAE,MAAM,EAAO,EAAE,SAAS,GAAE,MAAM,EAAO,GAAG,YAAY;CAGpF"}
@@ -3,7 +3,27 @@ import { GTime } from './GTime';
3
3
  import { ContentTypeInterpreter } from './detectors/ContentTypeInterpreter';
4
4
  import { createMCardDOTSMetadata } from '../types/dots';
5
5
  /**
6
- * MCard - Content-addressable data container
6
+ * MCard - Content-addressable data container (The Monad)
7
+ *
8
+ * ## Category Theory Role: MONAD
9
+ *
10
+ * MCard is the **Monad** in the MVP Cards categorical hierarchy:
11
+ * - **MCard (Monad)**: Data container with `unit` (create) and `bind` (chain)
12
+ * - **PCard (Functor)**: Pure transformation, `fmap` over MCard content
13
+ * - **VCard (Applicative)**: Context-aware application with pre-conditions
14
+ *
15
+ * ## Scale-Free Monadic Infrastructure: Spinoza-Leibniz Synthesis
16
+ *
17
+ * MCard implements the dual philosophical foundation:
18
+ *
19
+ * | Philosopher | Contribution | MCard Implementation |
20
+ * |-------------|--------------|---------------------|
21
+ * | **Spinoza** | One Substance (Deus sive Natura) | Fixed 3-field schema (Terminal Object) |
22
+ * | **Leibniz** | Infinite Monads (Pre-Established Harmony) | Infinite content-addressed entries |
23
+ * | **Both** | No windows / Internal causation | Content-addressing (same hash = same truth) |
24
+ *
25
+ * This enables **Experimental-Operational Symmetry (EOS)**: same behavior from
26
+ * a single user's PKC (100MB) to a planetary LLM registry (1PB).
7
27
  *
8
28
  * ## DOTS Vocabulary Role: CARRIER
9
29
  *
@@ -12,40 +32,48 @@ import { createMCardDOTSMetadata } from '../types/dots';
12
32
  * - Hash-links between MCards are **Morphisms** in Car(S)
13
33
  * - The Carrier is the category of all actual data/systems
14
34
  *
15
- * ## EOS Role: Invariant Content (Galois Root)
35
+ * ## Petri Net Role: TOKEN CONTENT
16
36
  *
17
- * MCard provides the **Invariant Substrate** in Experimental-Operational Symmetry:
18
- * - `Hash(Content)` is a **pure function** with no side effects
19
- * - Same content in Dev = Same hash in Prod (environment-invariant)
20
- * - This is the "Joint Reality" P(H,E) = P(E,H) in Bayesian terms
37
+ * In the Categorical Petri Net model:
38
+ * - **MCard content** is what tokens carry
39
+ * - **VCard** is the token type (Applicative wrapper)
40
+ * - **PCard** is the transition that transforms tokens
21
41
  *
22
42
  * ## MVP Cards Architecture: Data Plane
23
43
  *
24
44
  * ```
25
45
  * ┌───────────────────────────────────────────────────────┐
26
46
  * │ APPLICATION PLANE (VCard) │
27
- * │ Value Exchange / AuthN/AuthZ / Sovereign Memory
47
+ * │ Petri Net Token / AuthN/AuthZ / Side Effects
28
48
  * └─────────────────────────┬─────────────────────────────┘
29
- * │ (Policy Triggers)
49
+ * │ (Pre-Condition Check)
30
50
  * ┌─────────────────────────▼─────────────────────────────┐
31
51
  * │ CONTROL PLANE (PCard) │
32
- * │ Polynomial Functor Composition / Monadic Execution
52
+ * │ Petri Net Transition / CLM Logic / Pure Function
33
53
  * └─────────────────────────┬─────────────────────────────┘
34
- * │ (Hash References)
54
+ * │ (Content Transformation)
35
55
  * ┌─────────────────────────▼─────────────────────────────┐
36
56
  * │ DATA PLANE (MCard) ◀── YOU ARE HERE │
37
- * │ Immutable, Content-Addressable Storage / Monad
57
+ * │ Monad / Content-Addressable / Scale-Free Substrate
38
58
  * └───────────────────────────────────────────────────────┘
39
59
  * ```
40
60
  *
41
- * ## The Empty Schema Principle
61
+ * ## The Empty Schema Principle (Kenosis)
42
62
  *
43
- * MCard embodies the Empty Schema Principle from the Wordless Book:
63
+ * MCard embodies the Empty Schema Principle:
44
64
  * - Schema contains NO domain-specific terms (only hash, content, g_time)
45
65
  * - Domain customization happens via data (INSERT), not schema changes
46
66
  * - Universal applicability: same structure for ANY domain
67
+ * - This emptiness enables universality (Kenosis in code)
68
+ *
69
+ * ## Three Tables as Irreducible Semiotic Triad
47
70
  *
48
- * ## Functional Requirements (from design docs)
71
+ * The MCard infrastructure uses three tables (Peirce's semiotics):
72
+ * - `card` (Object/Referent): what the content means
73
+ * - `handle_registry` (Representamen/Sign): which concept is named
74
+ * - `handle_history` (Interpretant): how understanding evolved
75
+ *
76
+ * ## Functional Requirements
49
77
  *
50
78
  * | ID | Requirement | Implementation |
51
79
  * |----|-------------|----------------|
@@ -53,17 +81,14 @@ import { createMCardDOTSMetadata } from '../types/dots';
53
81
  * | M-2 | CRD-only (no UPDATE) | Immutable class, `readonly` fields |
54
82
  * | M-3 | Include g_time for ordering | `this.g_time` field |
55
83
  * | M-4 | Human-readable content | `getContentAsText()` method |
84
+ * | MONAD-1 | Unit (pure) operation | `MCard.create(content)` |
85
+ * | MONAD-2 | Bind (chain) operation | `MCard.bind(f)` via hash reference |
56
86
  * | EOS-M1 | Hash is pure function | No side effects in hash computation |
57
87
  * | EOS-M2 | Content is immutable | All fields are `readonly` |
58
88
  *
59
89
  * @see {@link DOTSRole.CARRIER} for DOTS vocabulary definition
60
90
  * @see {@link EOSRole.INVARIANT_CONTENT} for EOS role definition
61
- * @see docs/WorkingNotes/Permanent/Projects/PKC Kernel/MCard.md for full specification
62
- *
63
- * Each MCard has:
64
- * - content: Raw bytes (Uint8Array)
65
- * - hash: SHA-256 cryptographic hash (the Carrier Object identity)
66
- * - g_time: Global timestamp with algorithm identifier
91
+ * @see docs/MCard_Impl.md for full implementation specification
67
92
  */
68
93
  export class MCard {
69
94
  content;
@@ -1 +1 @@
1
- {"version":3,"file":"MCard.js","sourceRoot":"","sources":["../../src/model/MCard.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,sBAAsB,EAAE,MAAM,oCAAoC,CAAC;AAC5E,OAAO,EAA8C,uBAAuB,EAAE,MAAM,eAAe,CAAC;AAEpG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8DG;AACH,MAAM,OAAO,KAAK;IACL,OAAO,CAAa;IACpB,IAAI,CAAS;IACb,MAAM,CAAS;IACf,WAAW,CAAS,CAAC,wCAAwC;IAC7D,YAAY,CAAS;IAE9B,YAAsB,OAAmB,EAAE,IAAY,EAAE,MAAc,EAAE,WAAmB,EAAE,YAAoB;QAC9G,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;Q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AC3D,OAAO,IAAI,KAAK,CAAC,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE,GAAG,CAAC,CAAC;IAC9D,CAAC;IAED;;OAEG;IACH,gBAAgB;QACZ,OAAO,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAClD,CAAC;IAED;;OAEG;IACH,UAAU;QACN,OAAO,IAAI,CAAC,OAAO,CAAC;IACxB,CAAC;IAED;;OAEG;IACH,QAAQ;QACJ,OAAO;YACH,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,OAAO,EAAE,IAAI,CAAC,gBAAgB,EAAE;YAChC,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,WAAW,EAAE,IAAI,CAAC,WAAW;YAC7B,YAAY,EAAE,IAAI,CAAC,YAAY;SAClC,CAAC;IACN,CAAC;IAED;;;;;;;;;;;;;;;;;;;OAmBG;IACH,eAAe,CAAC,YAAsB,EAAE,EAAE,YAAsB,EAAE;QAC9D,OAAO,uBAAuB,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;IACzD,CAAC;CACJ"}
@@ -1,13 +1,85 @@
1
1
  /**
2
- * PCard Model (Control Plane) - Implementation of LENS/CHART.
2
+ * PCard Model (Control Plane) - Petri Net TRANSITION
3
3
  *
4
- * This module defines the PCard, which represents the execution unit in the DOTS framework.
5
- * PCards are MCards that contain a valid CLM (Cubical Logic Model) specification.
4
+ * This module defines PCard, the execution unit in the MVP Cards architecture.
5
+ * PCards are MCards containing a valid CLM (Cubical Logic Model) specification.
6
+ *
7
+ * ## Category Theory Role: FUNCTOR
8
+ *
9
+ * PCard is the **Functor** in the MVP Cards categorical hierarchy:
10
+ * - **MCard (Monad)**: Data container
11
+ * - **PCard (Functor)**: Pure transformation `fmap :: (a -> b) -> F a -> F b`
12
+ * - **VCard (Applicative)**: Context-aware application
13
+ *
14
+ * ## Petri Net Role: TRANSITION
15
+ *
16
+ * In the Categorical Petri Net model, PCard is the **Transition**:
17
+ * - Consumes input VCards (Tokens) from input Places
18
+ * - Executes CLM logic (Abstract → Concrete transformation)
19
+ * - Produces output VCards (Tokens) for output Places
20
+ *
21
+ * ### The Firing Rule
22
+ *
23
+ * A PCard (Transition) fires when all input VCards (Tokens) are present:
24
+ *
25
+ * ```
26
+ * M' = M - •t + t•
27
+ * ```
28
+ *
29
+ * Where:
30
+ * - M = Current marking (token distribution)
31
+ * - •t = Pre-set (input VCards required)
32
+ * - t• = Post-set (output VCards produced)
33
+ *
34
+ * ### Handle Naming Convention for CLM Execution
35
+ *
36
+ * ```
37
+ * clm://{module}/{function}/spec # PCard (Transition definition)
38
+ * clm://{module}/{function}/input # Input VCard (Precondition)
39
+ * clm://{module}/{function}/output # Output VCard (Postcondition)
40
+ * clm://{module}/{function}/balanced # Balanced Expectations history
41
+ * ```
42
+ *
43
+ * ## CLM Triad: Abstract, Concrete, Balanced
44
+ *
45
+ * PCard content encodes the three dimensions:
46
+ * - **Abstract (A)**: WHY - Specification, intent, type signature
47
+ * - **Concrete (C)**: HOW - Implementation, runtime logic
48
+ * - **Balanced (B)**: WHAT - Tests, verification expectations (tracked in handle_history)
49
+ *
50
+ * ## DOTS Vocabulary Role: LENS + CHART
51
+ *
52
+ * - **Lens**: Tight morphism (Abstract ↔ Concrete coherence)
53
+ * - **Chart**: Loose morphism (Balanced expectations wiring)
54
+ *
55
+ * @see docs/PCard_Impl.md for full implementation specification
6
56
  */
7
57
  import { MCard } from './MCard';
8
58
  import { DOTSMetadata } from '../types/dots';
9
59
  /**
10
- * PCard - The Control Plane unit (Lens + Chart)
60
+ * Input VCard reference for Petri Net pre-condition
61
+ */
62
+ export interface InputVCardRef {
63
+ /** Handle name (Place) where precondition VCard must exist */
64
+ handle: string;
65
+ /** Expected VCard hash (optional, for strict matching) */
66
+ expectedHash?: string;
67
+ /** Purpose of this precondition (e.g., 'authenticate', 'authorize') */
68
+ purpose?: string;
69
+ }
70
+ /**
71
+ * Output VCard specification for Petri Net post-condition
72
+ */
73
+ export interface OutputVCardSpec {
74
+ /** Handle name (Place) where output VCard will be deposited */
75
+ handle: string;
76
+ /** Type of VCard to generate */
77
+ type: 'verification' | 'authorization' | 'audit' | 'result';
78
+ /** Additional metadata to include in the VCard */
79
+ metadata?: Record<string, unknown>;
80
+ }
81
+ /**
82
+ * PCard - The Control Plane unit (Petri Net Transition)
11
83
  *
12
84
  * A PCard is an MCard whose content is a valid CLM specification.
13
85
  * It represents a transformation (Lens) with a specific interaction pattern (Chart).
@@ -35,16 +107,83 @@ export declare class PCard extends MCard {
35
107
  */
36
108
  get clm(): any;
37
109
  /**
38
- * Get the Abstract Specification section
110
+ * Get the Abstract Specification section (UPTV Role: Abstract)
111
+ */
112
+ get abstract(): any;
113
+ /**
114
+ * Get the Concrete Implementation section (UPTV Role: Concrete)
115
+ */
116
+ get concrete(): any;
117
+ /**
118
+ * Get the Balanced Expectations (tests) section (UPTV Role: Balanced)
119
+ */
120
+ get balanced(): any;
121
+ /**
122
+ * Get the Abstract Specification section (Legacy)
39
123
  */
40
124
  get abstractSpec(): any;
41
125
  /**
42
- * Get the Concrete Implementation section
126
+ * Get the Concrete Implementation section (Legacy)
43
127
  */
44
128
  get concreteImpl(): any;
45
129
  /**
46
- * Get the Balanced Expectations (tests) section
130
+ * Get the Balanced Expectations (tests) section (Legacy)
47
131
  */
48
132
  get balancedExpectations(): any;
133
+ /**
134
+ * Get input VCard references (Pre-set: •t)
135
+ *
136
+ * These represent the preconditions that must be satisfied before
137
+ * this PCard (Transition) can fire.
138
+ *
139
+ * @returns Array of input VCard references from CLM specification
140
+ */
141
+ getInputVCardRefs(): InputVCardRef[];
142
+ /**
143
+ * Get output VCard specifications (Post-set: t•)
144
+ *
145
+ * These define what VCards (Tokens) this PCard produces when fired.
146
+ *
147
+ * @returns Array of output VCard specifications
148
+ */
149
+ getOutputVCardSpecs(): OutputVCardSpec[];
150
+ /**
151
+ * Get the canonical handle for this PCard (Transition)
152
+ *
153
+ * @returns Handle string in form `clm://{module}/{function}/spec`
154
+ */
155
+ getTransitionHandle(): string;
156
+ /**
157
+ * Get the balanced expectations handle for this PCard
158
+ *
159
+ * This is where verification history is tracked in handle_history.
160
+ *
161
+ * @returns Handle string for balanced expectations
162
+ */
163
+ getBalancedHandle(): string;
164
+ /**
165
+ * Check if this PCard (Transition) can fire given the available VCards
166
+ *
167
+ * A transition can fire when all input VCards (preconditions) are present.
168
+ *
169
+ * @param availableVCards - Map of handle → VCard hash
170
+ * @returns Object with canFire boolean and missing preconditions
171
+ */
172
+ canFire(availableVCards: Map<string, string>): {
173
+ canFire: boolean;
174
+ missing: string[];
175
+ };
176
+ /**
177
+ * Get the runtime required for this PCard
178
+ *
179
+ * @returns Runtime name (e.g., 'javascript', 'python', 'lean')
180
+ */
181
+ getRuntime(): string;
182
+ /**
183
+ * Check if this is a multi-runtime PCard
184
+ *
185
+ * @returns True if this PCard supports multiple runtimes
186
+ */
187
+ isMultiRuntime(): boolean;
49
188
  }
50
189
  //# sourceMappingURL=PCard.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"PCard.d.ts","sourceRoot":"","sources":["../../src/model/PCard.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAIhC,OAAO,EAAE,YAAY,EAA2B,MAAM,eAAe,CAAC;AAEtE;;;;;GAKG;AACH,qBAAa,KAAM,SAAQ,KAAK;IAC5B,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAM;IAChC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAU;IAEjC,SAAS,aACL,OAAO,EAAE,UAAU,EACnB,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,MAAM,EACnB,YAAY,EAAE,MAAM,EACpB,SAAS,EAAE,GAAG,EACd,MAAM,EAAE,OAAO;IAOnB;;;;;;OAMG;WACU,MAAM,CACf,OAAO,EAAE,MAAM,GAAG,UAAU,EAC5B,aAAa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