Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PGC SDK — Physics-Gated Computing

Execute code only when real-world physical coherence meets a verifiable threshold.

Every gated execution is cryptographically sealed (HCQ — Hash-Chain-Quantum) to the physical state at the moment of execution, providing an immutable audit trail anchored to independently verifiable geophysical and quantum-entropy data.

The coherence scoring methodology is proprietary (IP Disclosure: qR Theory v1.0, 2026-03-30). The SDK consumes the live API output — the formula itself is never exposed in SDK code.

Powered by hisocer.com · Gating infrastructure at sigmagate.io


What is Physics-Gated Computing?

Traditional computing executes immediately regardless of environmental conditions. PGC adds a physical prerequisite: code only runs when a live, multi-source coherence score (qR) exceeds a threshold you specify.

The qR score is derived from 13 real-time data channels including NOAA geomagnetic indices, GOES solar flux, and ANU quantum entropy. It reflects a measurable property of the physical environment — not simulated, not synthetic.

Use cases:

  • Legal document signing with physical proof of conditions
  • High-value financial transactions requiring environmental attestation
  • Scientific data collection gated to low-interference windows
  • Cryptographic key generation in high-coherence states
  • Audit trails where "when" and "under what conditions" are legally material

Installation

Python (pip):

pip install pgc-sdk

Node.js (npm):

npm install pgc-sdk

Requirements: Python >= 3.9 / Node.js >= 18


Quick Start

Python

from pgc import pgc_gate, PGCGateClosedError

@pgc_gate(threshold=1.0, seal=True)
def sign_contract(doc_hash: str) -> dict:
    """Only executes when qR >= 1.0 (CRYSTAL_PERFECT)."""
    return {"signed": doc_hash, "status": "ok"}

try:
    result = sign_contract("sha256:abc123")

    print(result.value)           # {"signed": "sha256:abc123", "status": "ok"}
    print(result.qr_at_exec)      # 1.224 (live value at execution)
    print(result.state_at_exec)   # "CRYSTAL_PERFECT"
    print(result.seal["hcq"])     # "a3f7c2..." (64-char SHA-256 HCQ seal)
    print(result.verify())        # True

except PGCGateClosedError as e:
    print(f"Gate closed: qR={e.qr_current:.4f}, need {e.threshold:.4f}")

Node.js

const { pgcGate, PGCGateClosedError } = require('pgc-sdk');

const signContract = pgcGate(async (docHash) => {
  return { signed: docHash, status: 'ok' };
}, { threshold: 1.0, seal: true });

try {
  const result = await signContract('sha256:abc123');

  console.log(result.value);          // { signed: 'sha256:abc123', status: 'ok' }
  console.log(result.qrAtExec);       // 1.224
  console.log(result.stateAtExec);    // 'CRYSTAL_PERFECT'
  console.log(result.seal.hcq);       // 'a3f7c2...' (64-char HCQ seal)
  console.log(result.verify());       // true

} catch (e) {
  if (e instanceof PGCGateClosedError) {
    console.log(`Gate closed: qR=${e.qrCurrent.toFixed(4)}, need ${e.threshold.toFixed(4)}`);
  }
}

Coherence Tiers

Tier qR threshold Description
STANDBY < 0.36 Background — gate closed for most uses
COUPLING >= 0.36 Weak coupling detected
PRE_EP >= 0.64 Pre-emergence zone — suitable for mid-value ops
CRYSTAL_PERFECT >= 1.0 Full coherence — highest assurance tier

Set threshold to any float; the SDK compares qR >= threshold to decide gate state.


CLI Usage

# Check current gate status
pgc status

# Check with custom threshold and JSON output
pgc status --threshold 0.64 --json

# Run a script through the gate (exits 2 if gate is closed)
pgc run my_script.py --threshold 1.0

# Wait until gate opens, then run (polls every 60s, timeout 1h)
pgc run my_script.py --threshold 1.0 --wait --wait-timeout 7200

# Save API key to ~/.pgc/config.json
pgc configure

When pgc run executes a script, it injects these environment variables:

Variable Value
PGC_QR_SCORE Live qR score at gate open
PGC_STATE State string (CRYSTAL_PERFECT etc.)
PGC_TS_UTC Physical timestamp (ISO 8601)
PGC_THRESHOLD Threshold used
PGC_GATE_OPEN Always 1 when script runs

Error Handling

Python

from pgc import pgc_gate, PGCGateClosedError, PGCBackendError

@pgc_gate(threshold=1.0, raise_on_closed=False)  # soft mode
def my_op():
    return "result"

result = my_op()
if not result.gate_was_open:
    print(f"Gate closed at qR={result.qr_at_exec:.4f} — queuing for retry")
else:
    print(result.value)

Backend unreachable

from pgc import pgc_gate, PGCBackendError

@pgc_gate(threshold=1.0, retry=3, retry_delay=10.0)
def resilient_op():
    return "done"

try:
    result = resilient_op()
except PGCBackendError as e:
    print(f"Backend unreachable after retries: {e}")

Testing (mock mode)

Never make real API calls in tests. Use mock_qr to inject a synthetic qR value:

# Python
@pgc_gate(threshold=1.0, mock_qr=1.5)   # gate open
@pgc_gate(threshold=1.0, mock_qr=0.3)   # gate closed
// Node.js
pgcGate(fn, { threshold: 1.0, mockQr: 1.5 });   // gate open
pgcGate(fn, { threshold: 1.0, mockQr: 0.3 });   // gate closed

Or set PGC_MOCK=1 in your environment to automatically use the mock backend.


HCQ Seal Verification

Every gated execution produces an HCQ (Hash-Chain-Quantum) seal:

result = my_gated_function()

seal = result.seal
print(seal["hcq"])           # SHA-256 fingerprint (64 hex chars)
print(seal["qr_at_exec"])    # qR score at execution
print(seal["state_at_exec"]) # Physical state string
print(seal["ts_physical"])   # Timestamp from the backend
print(seal["ts_exec"])       # Timestamp of function execution
print(seal["seal_version"])  # "PGC_SEAL_V1"
print(seal["nonce"])         # Random nonce (ensures uniqueness)
print(seal["threshold"])     # Threshold that was met

# Internal consistency check
result.verify()  # True

Independent verification: The ts_physical timestamp and qr_at_exec value can be cross-referenced against publicly archived NOAA geomagnetic and GOES solar data to confirm the stated physical conditions existed at that time.

The HCQ is computed as:

SHA-256( result_json | ts=<ts_physical> | qr=<qr_at_exec> | state=<state> |
         fn=<function_name> | threshold=<threshold> | nonce=<nonce> | PGC_SEAL_V1 )

Security

  • API key via environment variable: Set PGC_API_KEY — never hardcode in source
  • Cache: Responses are cached for 30 seconds (matches backend refresh cycle) to avoid hammering the API
  • No formula exposure: The proprietary coherence scoring formula (IP Disclosure 2026-03-30) is never referenced in SDK code — only the API output is consumed
  • Config file permissions: pgc configure saves to ~/.pgc/config.json with mode 0600
export PGC_API_KEY=your_key_here

API Reference

Python

Symbol Type Description
pgc_gate(threshold, seal, backend, api_key, raise_on_closed, retry, retry_delay, mock_qr) decorator class Main gate decorator
PGCResult.value Any Return value of the gated function
PGCResult.seal dict or None HCQ seal dict
PGCResult.qr_at_exec float qR score at execution
PGCResult.state_at_exec str Physical state at execution
PGCResult.gate_was_open bool False if raise_on_closed=False and gate was closed
PGCResult.verify() bool Internal seal consistency check
PGCGateClosedError.qr_current float qR at time of rejection
PGCGateClosedError.threshold float Threshold that was not met
PGCGateClosedError.margin float qr_current - threshold (negative)

Node.js

Symbol Description
pgcGate(fn, opts) Wraps an async function with physics gating
result.value Return value of the gated function
result.seal HCQ seal object
result.qrAtExec qR score at execution
result.stateAtExec Physical state string
result.gateWasOpen false if raiseOnClosed=false and gate was closed
result.verify() Internal seal consistency check
getState(opts) Fetch raw QRState from backend
invalidateCache() Force next fetch to bypass cache

Links


License

Open Core — MIT license for this SDK code.

The backend API (api.hisocer.com / sigmagate.io) requires an API key — get yours at sigmagate.io. Free tier available.

The qR coherence scoring methodology is separately protected under IP Disclosure: qR Theory v1.0 (2026-03-30) and OEPM patent P202630424. The formula is never exposed in SDK code — only the result is returned by the API.

About

Physics-Gated Computing SDK — execute code only when real-world coherence meets threshold. HCQ cryptographic seals. Open Core (MIT).

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages