COBOL legacy encapsulation with TIBET provenance and JIS capability gating
Project description
tibet-cobol
COBOL legacy encapsulation with TIBET provenance and JIS capability gating.
The sarcophagus for COBOL: encapsulate without replacing.
The Problem
220 billion lines of COBOL power $3 trillion/day in transactions. Banks, governments, and insurers cannot rewrite it — too risky, too expensive, too critical. But without audit trails and capability gating, they cannot safely integrate AI either.
COBOL is the asbestos of programming languages. You can't remove it. You can encapsulate it.
The Solution
tibet-cobol provides three layers for safe legacy modernization:
1. Bridge — Encapsulation
Wrap COBOL procedures with JIS capability gates and TIBET provenance chains. The business logic stays identical — zero changes to decades-tested rules.
from tibet_cobol import COBOLBridge, PICType
bridge = COBOLBridge("FUNDS-TRANSFER")
# COBOL DATA DIVISION → Python (type-safe PIC fields)
bridge.define_storage(
("ACCOUNT-BAL", PICType.NUMERIC, 7, 2, 5000.00),
("TRANSFER-AMT", PICType.NUMERIC, 7, 2, 1500.00),
("TRANSFER-STAT", PICType.ALPHANUMERIC, 10, 0, ""),
)
# COBOL PROCEDURE DIVISION → Python (exact same logic)
def funds_transfer(ws):
if ws.get("ACCOUNT-BAL") >= ws.get("TRANSFER-AMT"):
ws.set("ACCOUNT-BAL", ws.get("ACCOUNT-BAL") - ws.get("TRANSFER-AMT"))
ws.set("TRANSFER-STAT", "SUCCESS")
else:
ws.set("TRANSFER-STAT", "INSUFF-FND")
bridge.register_procedure("BEGIN-TRANSFER", funds_transfer)
# Execute with JIS gate + TIBET provenance
result = bridge.execute(
procedure="BEGIN-TRANSFER",
actor="ai-agent-001",
model_id="qwen2.5:32b", # 32B → gate OPEN (L2 access)
required_level=2,
)
# result.status == "SUCCESS"
# result.tibet_tokens == [gate_check, pre_state, post_state]
A 3B model trying the same operation:
result = bridge.execute(
procedure="BEGIN-TRANSFER",
actor="small-model",
model_id="qwen2.5:3b", # 3B → gate CLOSED (only L0)
required_level=2,
)
# result.status == "DENIED"
# Violation logged in TIBET chain, state unchanged
2. Shadow — Parallel Execution
Run COBOL and the new system side by side. Compare outputs. Build trust over time.
from tibet_cobol import ShadowRunner, ShadowMode
runner = ShadowRunner("FUNDS-TRANSFER")
runner.register_cobol(cobol_function)
runner.register_new(modern_function)
# Phase 1: Observe (COBOL master, new system watches)
result = runner.run({"balance": 5000, "amount": 1500}, mode=ShadowMode.SHADOW)
# Phase 2: Verify (both run, compare outputs)
result = runner.run({"balance": 5000, "amount": 1500}, mode=ShadowMode.VERIFY)
print(result.match) # True — outputs identical
print(result.rag_entry) # Knowledge captured for RAG
# Trust builds over many runs
for i in range(100):
runner.run(test_data[i], mode=ShadowMode.VERIFY)
print(runner.trust.trust_score) # 0.98
print(runner.trust.suggested_mode) # ShadowMode.PARALLEL
3. Manifest — Field Mapping
Track which COBOL fields map to modern data stores. Bidirectional.
from tibet_cobol import Manifest, MigrationStatus
manifest = Manifest("FUNDS-TRANSFER")
# Define mappings
manifest.map("ACCOUNT-BAL", "001-007", "9(7)V99",
modern_path="accounts.balance", modern_type="decimal")
manifest.map("TRANSFER-AMT", "008-014", "9(7)V99",
modern_path="transfers.amount", modern_type="decimal")
manifest.map("TRANSFER-STAT", "015-024", "X(10)")
# ^ No modern_path → stays COBOL_ONLY
# Update from shadow results
manifest.record_shadow("ACCOUNT-BAL", matched=True) # ×100 runs
# Check migration readiness
print(manifest.coverage) # 0.66 (2/3 fields mapped)
print(manifest.verification_score) # 0.95
print(manifest.ready_for_cutover) # False (TRANSFER-STAT unmapped)
# Bidirectional lookup
manifest.cobol_to_modern("ACCOUNT-BAL") # "accounts.balance"
manifest.modern_to_cobol("accounts.balance") # "ACCOUNT-BAL"
Migration Phases
Phase 0: SHADOW COBOL master, new system observes
Phase 1: VERIFY Both run, outputs compared
Phase 2: PARALLEL New system serves, COBOL validates
Phase 3: CUTOVER New system master, COBOL decommissioned
Every phase transition is:
- JIS-gated — requires proven capability
- TIBET-tracked — immutable provenance chain
- Trust-based — must reach threshold before advancing
Installation
pip install tibet-cobol
Requires Python 3.10+ and tibet-context >= 0.2.0.
Tests
pytest tests/ -v
Relation to TIBET Ecosystem
tibet-core (Token, Chain, Provider)
│
tibet-context (Layers, Gate, Builder)
│
tibet-cobol (Bridge, Shadow, Manifest) ← you are here
│
Legacy COBOL (FUNDS-TRANSFER, etc.)
License
MIT — Humotica
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file tibet_cobol-0.1.0.tar.gz.
File metadata
- Download URL: tibet_cobol-0.1.0.tar.gz
- Upload date:
- Size: 17.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
534d4611a97d97b2c97bd05ffb0ae47d278963291cda27c6d56e080fc700cee8
|
|
| MD5 |
ca76b269e95faa641c3a08e64407ae28
|
|
| BLAKE2b-256 |
f6c7403d50b46dd653e60b1ce69f882058779d5038b79a5b3d49ffb1459bdd4f
|
File details
Details for the file tibet_cobol-0.1.0-py3-none-any.whl.
File metadata
- Download URL: tibet_cobol-0.1.0-py3-none-any.whl
- Upload date:
- Size: 17.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
86ceddd820c53668feae169fc9ec708f7e9be4dd5583e1222420ba55bd050862
|
|
| MD5 |
9b7fa12b8cabd7ff3208598099ef25f5
|
|
| BLAKE2b-256 |
7ed602b49db4318f1f09e4d66a4853fd5f3021adf7edc4e3a1653b0a2cc79529
|