File size: 6,530 Bytes
9ae68e3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
[![License: BSL-1.1](https://img.shields.io/badge/License-BSL--1.1-blue.svg)](https://opensource.org/licenses/BSL-1.0)
[![License: AGPL-3.0](https://img.shields.io/badge/License-AGPL--3.0-purple.svg)](https://www.gnu.org/licenses/agpl-3.0)
[![License: MPL-2.0](https://img.shields.io/badge/License-MPL--2.0-orange.svg)](https://www.mozilla.org/en-US/MPL/2.0/)
[![Python](https://img.shields.io/badge/Python-3.10+-3776AB.svg)](https://python.org)
[![Stan](https://img.shields.io/badge/Stan-Bayesian-B1261C.svg)](https://mc-stan.org)
[![MiniZinc](https://img.shields.io/badge/MiniZinc-Constraint-2E7D32.svg)](https://www.minizinc.org)
[![Evidence or Silence](https://img.shields.io/badge/Protocol-Evidence%20or%20Silence-black.svg)](#)

# bio-semantics

**ๅŸบๅ› ่กจ้”่ชž็พฉๅปบๆจก็ฎก็ทš (ุฎุท ุฃู†ุงุจูŠุจ ุงู„ู†ู…ุฐุฌุฉ ุงู„ุฏู„ุงู„ูŠุฉ ู„ู„ุชุนุจูŠุฑ ุงู„ุฌูŠู†ูŠ)**

Gene-expression semantic modeling pipeline โ€” Stan + MiniZinc + cDNA sequencing visualizer with immutable artifact provenance, PTM verification, and RPG/JCL integration templates.

Authors: Ahmad Ali Parr, Jessica L. Williams (SNAPKITTYWEST)

---

## Architecture

```
                BIOLOGICAL OBSERVATIONS
                         โ”‚
                         โ–ผ
                cDNA EXPRESSION DATA
                         โ”‚
                         โ–ผ
                โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
                โ”‚ DATA VALIDATION โ”‚  โ† semantics.py (10 validator rules)
                โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                         โ”‚
                         โ–ผ
                GENE EXPRESSION
                         โ”‚
                         โ–ผ
                โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
                โ”‚   STAN MODEL    โ”‚  โ† Bayesian inference
                โ”‚ priors          โ”‚
                โ”‚ likelihood      โ”‚
                โ”‚ posterior       โ”‚
                โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                         โ”‚
                         โ–ผ
                 POSTERIOR STATE
                         โ”‚
                         โ–ผ
                โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
                โ”‚ MINIZINC MODEL  โ”‚  โ† Constraint reasoning
                โ”‚ constraints     โ”‚
                โ”‚ optimization    โ”‚
                โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                         โ”‚
                         โ–ผ
                COMPUTATIONAL RESULT
                         โ”‚
                         โ–ผ
                โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
                โ”‚ VISUALIZER      โ”‚  โ† dashboard.html (8 panels)
                โ”‚ HTML + CSS      โ”‚
                โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                         โ”‚
                         โ–ผ
                HUMAN-READABLE MODEL
```

---

## Repository Structure

```
bio-semantics/
โ”œโ”€โ”€ src/
โ”‚   โ”œโ”€โ”€ semantics.py           Validator + PTM parity machine
โ”‚   โ”œโ”€โ”€ test_semantics.py      Unit tests (6 test classes)
โ”‚   โ””โ”€โ”€ dashboard.html         8-panel semantic report viewer
โ”œโ”€โ”€ spec/
โ”‚   โ”œโ”€โ”€ types.ts               TypeScript type definitions (bio-semantics/1.0.0)
โ”‚   โ”œโ”€โ”€ contract.md            Gate 1 integration contract
โ”‚   โ””โ”€โ”€ system_prompt.md       Agent system prompt specification
โ””โ”€โ”€ templates/
    โ”œโ”€โ”€ workflow.rpgle          RPG workflow coordinator (IBM i)
    โ””โ”€โ”€ vault.jcl              JCL vault archival template
```

---

## Quantity Kinds

| Kind | Meaning | ๆ„็พฉ (ุงู„ู…ุนู†ู‰) |
|------|---------|--------------|
| observed | Measurement with source record locator | ่ง€ๆธฌๅ€ผ (ุงู„ู‚ูŠู…ุฉ ุงู„ู…ุฑุตูˆุฏุฉ) |
| inferred | Posterior with model/run references and uncertainty | ๆŽจๆ–ทๅ€ผ (ุงู„ู‚ูŠู…ุฉ ุงู„ู…ุณุชู†ุชุฌุฉ) |
| derived | Deterministic transformation with algorithm references | ่ก็”Ÿๅ€ผ (ุงู„ู‚ูŠู…ุฉ ุงู„ู…ุดุชู‚ุฉ) |
| predicted | Unobserved modeled quantity | ้ ๆธฌๅ€ผ (ุงู„ู‚ูŠู…ุฉ ุงู„ู…ุชูˆู‚ุนุฉ) |
| constrained | Declared relation or solver result | ็ด„ๆŸๅ€ผ (ุงู„ู‚ูŠู…ุฉ ุงู„ู…ู‚ูŠุฏุฉ) |
| encoded | Representation with codec identifier | ็ทจ็ขผๅ€ผ (ุงู„ู‚ูŠู…ุฉ ุงู„ู…ุฑู…ุฒุฉ) |
| executed | Actual execution event with run evidence | ๅŸท่กŒไบ‹ไปถ (ุญุฏุซ ุงู„ุชู†ููŠุฐ) |

---

## Validator Rules

1. Reject unsupported versions, unknown discriminants, duplicate IDs
2. Require exactly one of present value or missing reason
3. Raw counts: canonical unsigned decimal only
4. Decimal quantities: reject NaN/infinity, require units
5. Require sample/gene references to resolve
6. Reject inferred/predicted/constrained labeled as observed
7. Preserve excluded rows with explicit inclusion map
8. Missing source bytes block verified-ingestion claims
9. Synthetic-origin propagation through every descendant
10. Never create model-results merely because a process was scheduled

---

## PTM: ptm-bit-parity/1

| State | Read | Write | Move | Next |
|-------|------|-------|------|------|
| q_even | 0 | 0 | R | q_even |
| q_even | 1 | 1 | R | q_odd |
| q_odd | 0 | 0 | R | q_odd |
| q_odd | 1 | 1 | R | q_even |
| q_even | _ | 0 | Stay | q_accept |
| q_odd | _ | 1 | Stay | q_accept |

For input length n: exactly n+1 transitions, constant auxiliary storage.

---

## Run Tests

```bash
cd src && python -m pytest test_semantics.py -v
```

---

## Gated Phases

| Gate | What | Status |
|------|------|--------|
| 1. Contract | Contracts accepted, encodings documented, provenance validated | Ready for review |
| 2. Engine | Stan/MiniZinc/Quipper sources exist, native validation recorded | Not started |
| 3. Integration | All panels rendered, WORM loaded, governance preserved | Not started |

---

## License

This project is released under a **trilicense** model. You may choose any one of the following:

| License | SPDX | Link |
|---------|------|------|
| Boost Software License 1.0 | BSL-1.1 | [LICENSE-BSL](https://opensource.org/licenses/BSL-1.0) |
| GNU Affero General Public License v3 | AGPL-3.0 | [LICENSE-AGPL](https://www.gnu.org/licenses/agpl-3.0) |
| Mozilla Public License 2.0 | MPL-2.0 | [LICENSE-MPL](https://www.mozilla.org/en-US/MPL/2.0/) |

Unauthorized cloud SaaS redistribution without source disclosure is prohibited under all three licenses.

---

SnapKitty West / SNAPKITTYWEST โ€” Evidence or Silence โ€” 2026