Metadata-Version: 2.4
Name: tibet-y2k38
Version: 0.1.0
Summary: Y2K38 Time Bridge - Software router for 32→64 bit epoch translation with TIBET provenance and JIS identity
Project-URL: Homepage, https://humotica.com
Project-URL: Repository, https://github.com/jaspertvdm/tibet-y2k38
Project-URL: Documentation, https://humotica.com/docs/tibet-y2k38
Project-URL: Bug Tracker, https://github.com/jaspertvdm/tibet-y2k38/issues
Project-URL: TIBET Protocol, https://pypi.org/project/tibet-core/
Project-URL: JIS Identity, https://pypi.org/project/jis-core/
Project-URL: IETF TIBET Draft, https://datatracker.ietf.org/doc/draft-vandemeent-tibet-provenance/
Project-URL: IETF JIS Draft, https://datatracker.ietf.org/doc/draft-vandemeent-jis-identity/
Author-email: "J. van de Meent" <jasper@humotica.com>, "R. AI" <root_idd@humotica.nl>
Maintainer-email: Humotica AI Lab <ai@humotica.nl>
License: MIT
License-File: LICENSE
Keywords: 32-bit,64-bit,bridge,compliance,embedded,epoch,humotica,iot,iso5338,jis,legacy,nis2,provenance,router,scada,tibet,time,y2k38
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Information Technology
Classifier: Intended Audience :: System Administrators
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Security
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: System :: Hardware
Classifier: Topic :: System :: Networking
Requires-Python: >=3.10
Requires-Dist: tibet-core>=0.2.0
Provides-Extra: dev
Requires-Dist: pytest>=7.0; extra == 'dev'
Requires-Dist: ruff>=0.1.0; extra == 'dev'
Provides-Extra: full
Requires-Dist: rich>=13.0.0; extra == 'full'
Description-Content-Type: text/markdown

# tibet-y2k38

**Y2K38 Time Bridge — Software router for 32→64 bit epoch translation with TIBET provenance and JIS identity.**

*Why replace billions of chips when a software router can catch the dumb chip?*

[![PyPI](https://img.shields.io/pypi/v/tibet-y2k38)](https://pypi.org/project/tibet-y2k38/)
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)

## The Problem

On **January 19, 2038 at 03:14:07 UTC**, the signed 32-bit Unix epoch overflows. Billions of embedded devices — PLCs, sensors, GPS receivers, ATMs, medical monitors, avionics — will wrap to negative timestamps or 1970.

You **cannot** replace all these chips. Many devices are:
- Embedded in walls, factories, vehicles, patients
- Safety-certified (FDA, FAA, EASA, SIL 4) — recertification takes years
- Running 20-40 year lifecycles
- Cost-prohibitive to replace at scale

## The Solution

A **software router** that sits between legacy 32-bit devices and modern 64-bit systems:

```python
from tibet_y2k38 import TimeBridge

# Legacy Siemens PLC with 32-bit clock
bridge = TimeBridge(
    device_id="jis:factory:plc-line4",
    clock_bits=32,
    profile="scada"
)

# Translate the maximum 32-bit timestamp
result = bridge.translate(legacy_timestamp=0x7FFFFFFF)
print(result.translated_iso)  # 2038-01-19T03:14:07+00:00

# Every translation creates a TIBET provenance token
print(result.tibet_token["erachter"])
# "32→64 bit time bridge for device jis:factory:plc-line4, profile=scada, confidence=1.00"
```

Every translation is:
- **Identified** via JIS (JTel Identity Standard) — each device has a verifiable identity
- **Provenance-tracked** via TIBET (Time Intent Based Event Token) — immutable audit trail
- **Auditable** — full chain from legacy input to 64-bit output

## 10 Sector Profiles

| Sector | Devices Worldwide | Chip Replacement | Key Challenge |
|--------|------------------|-----------------|---------------|
| **IoT** | 15+ billion | Impossible | Deployed in unreachable locations |
| **SCADA** | 50+ million | €500-5k/unit | 20+ year lifecycles, downtime = €10k-100k/hr |
| **Automotive** | 1+ billion ECUs | Billions in recalls | 30+ ECUs per car, 15-20 year lifespan |
| **Medical** | 100+ million | Recertification = years | FDA/CE certified, patient safety critical |
| **Telecom** | 10+ million | Cannot during uptime | NTP overflow hits 2036! SS7 timestamps |
| **GPS** | 4+ billion | Scale impossible | Week rollover already happened (2019!) |
| **Banking** | 50+ million | Mainframe = billions | COBOL packed decimal, legally binding timestamps |
| **Energy** | 500+ million | Regulatory complex | Smart meters, grid frequency depends on time sync |
| **Aviation** | 5+ million | FAA/EASA recert | DO-178C certification, 30-40 year aircraft life |
| **Rail** | 10+ million | SIL 4 safety critical | ERTMS/ETCS, incorrect time = collision risk |

```python
from tibet_y2k38 import TimeRouter

router = TimeRouter(network_id="jis:factory:eindhoven")

# Each device gets its sector-specific configuration
router.add_device("jis:plc:line4", profile="scada")      # BCD datetime
router.add_device("jis:gps:antenna", profile="gps")       # GPS week number
router.add_device("jis:atm:lobby", profile="banking")     # COBOL packed
router.add_device("jis:ntp:server1", profile="telecom")   # NTP 32-bit

# Route timestamps through the correct bridge
result = router.translate("jis:plc:line4", timestamp=0x7FFFFFFF)
```

## Time Formats Supported

| Format | Description | Overflow Date |
|--------|-------------|---------------|
| `UNIX_SIGNED_32` | Standard signed 32-bit epoch | 2038-01-19 |
| `UNIX_UNSIGNED_32` | Unsigned 32-bit epoch | 2106-02-07 |
| `NTP_32` | NTP short format (epoch 1900) | **2036-02-07** |
| `GPS_WEEK` | 10-bit GPS week counter | ~19.7 year cycle |
| `FAT_TIMESTAMP` | DOS/FAT 2-second resolution | 2107-12-31 |
| `COBOL_PACKED` | COBOL packed decimal dates | Format dependent |
| `BCD_DATETIME` | Binary-Coded Decimal (PLCs) | Format dependent |

## Compliance

Built-in compliance reporting for:

- **NIS2** (EU Directive 2022/2555) — Asset inventory, risk assessment, incident reporting, audit trails
- **ISO/IEC 5338** (AI system lifecycle) — Data lineage, provenance tracking, lifecycle documentation

```python
from tibet_y2k38.compliance import NIS2Reporter, ISO5338Reporter

nis2 = NIS2Reporter(router)
print(nis2.risk_assessment())   # Devices at risk, mitigation status
print(nis2.audit_trail_report()) # TIBET provenance proof

iso = ISO5338Reporter(router)
print(iso.data_lineage_report()) # Full translation pipeline lineage
```

## CLI

```bash
# Show Y2K38 countdown
tibet-y2k38 info

# Run interactive demo (10 sectors, overflow scenarios)
tibet-y2k38 demo

# List all sector profiles
tibet-y2k38 profiles

# Generate JSON compliance report
tibet-y2k38 report
```

## Installation

```bash
pip install tibet-y2k38

# With rich terminal output
pip install tibet-y2k38[full]
```

## How It Works

```
Legacy Device (32-bit)    TimeBridge         Modern System (64-bit)
┌──────────────┐     ┌──────────────────┐     ┌──────────────────┐
│ PLC/Sensor/  │     │ 1. Receive 32b   │     │                  │
│ GPS/ATM/...  │────>│ 2. Detect format │────>│ Correct 64-bit   │
│              │     │ 3. Translate     │     │ UTC timestamp    │
│ 0x7FFFFFFF   │     │ 4. TIBET token   │     │                  │
└──────────────┘     │ 5. JIS identity  │     └──────────────────┘
                     └──────────────────┘
                            │
                     ┌──────────────────┐
                     │ TIBET Audit Trail │
                     │ - ERIN: values   │
                     │ - ERAAN: deps    │
                     │ - EROMHEEN: ctx  │
                     │ - ERACHTER: why  │
                     └──────────────────┘
```

## The Bigger Picture

This package is part of the **Humotica** ecosystem:

- [tibet-core](https://pypi.org/project/tibet-core/) — TIBET protocol core (zero dependencies)
- [jis-core](https://pypi.org/project/jis-core/) — JIS identity standard
- [tibet-audit](https://pypi.org/project/tibet-audit/) — Audit tooling
- [tibet-forge](https://pypi.org/project/tibet-forge/) — Code certification
- [tibet-y2k38](https://pypi.org/project/tibet-y2k38/) — This package

**Standards:**
- IETF: [draft-vandemeent-tibet-provenance-00](https://datatracker.ietf.org/doc/draft-vandemeent-tibet-provenance/)
- IETF: [draft-vandemeent-jis-identity-00](https://datatracker.ietf.org/doc/draft-vandemeent-jis-identity/)
- Zenodo: [TIBET Specification](https://doi.org/10.5281/zenodo.18712451)
- Zenodo: [JIS Specification](https://doi.org/10.5281/zenodo.18712569)
- W3C CCG: Presentation scheduled May 5, 2025

## License

MIT — Humotica AI Lab ([humotica.com](https://humotica.com))

Authors: J. van de Meent & R. AI
