forgo.cloud
Sign in
Repo workspace

forkjoin-ai/gnosis

Closed Architecture Runtime Handoff

docs/CLOSED_ARCHITECTURE_RUNTIME_HANDOFF.md
forkjoin-ai/gnosis

Closed Architecture Runtime Handoff

Parent: Docs README Formal anchors: FORMAL_LEDGER.md, TrainingSaturation.lean, VerifiedReconstruction.lean, CosmicArchitecture.lean, SovereignSieve.lean, GamutBraid.lean

This is a handoff plan for applying the closed-architecture proof surface to Gnosis compiler and runtime work. Treat the Lean modules as a certificate shape, not as a benchmark result. The implementation still has to prove performance with measurements.

Goal

Move selected compiler and runtime paths from repeated search-style checking to certificate-guided execution when a topology matches the proved finite shape:

  • Layer stack: 10, 12, 17, 22
  • Saturation ladder: 10, 30, 90
  • Keystone gap: 22 - 17 = 5
  • Readiness base: baseReady
  • Closure path: cosmicArchitectureClosed -> baseReady

The runtime should only use the shortcut after it has a concrete certificate matching those coordinates. Otherwise it must keep the current conservative checks.

Proof Contract

The next agent should mirror these Lean facts in TypeScript or native runtime data structures:

Lean theorem Runtime meaning
TrainingSaturation.exact_frequency_zero_impedance An exact frequency witness has no modeled impedance.
VerifiedReconstruction.exact_reconstruction_complete The exact witness satisfies the reconstruction certificate.
CosmicArchitecture.exact_keystone_gap The 17-to-22 transition has fixed stride 5.
CosmicArchitecture.exact_cosmic_architecture_closed The exact witness closes over base readiness, zero flow, layer handshake, and carrier readiness.
CosmicArchitecture.snake_eats_tail_returns_to_base Closed execution returns to baseReady.
SovereignSieve.saturation_thirty_focuses_witness Saturation 30 selects the prime witness/inversion point.
SovereignSieve.saturation_ninety_focuses_host Saturation 90 selects the host-handshake point.
SovereignSieve.sovereign_sieve_interpreter_exists A fully interpreted prime observation has a finite witness.
GamutBraid.exact_braid_fork_race_fold_pass An exact finite braid cycle admits a proof-backed fork/race/fold pass.
GamutBraid.fork_race_fold_braid_pass_returns_to_base A proof-backed braid pass returns to baseReady.
GamutBraid.exact_seven_seventeen_twenty_two_decomposition_pass The exact finite braid cycle admits a proof-backed 7 -> 17 -> 22 decomposition/race/fold pass.
GamutBraid.decomposition_fork_race_fold_returns_to_base Any proof-backed 7 -> 17 -> 22 decomposition pass returns to baseReady.

Do not widen these claims silently. They prove finite coordinates and projection relationships. They do not prove that arbitrary runtime states are safe to skip.

Target Surfaces

Start with the smallest path that can expose a certificate without changing the whole compiler family:

  • src/mesh-policy.ts: likely place to mirror saturation and layer-selection predicates, because existing theorem drift already cites mesh-policy Lean names.
  • src/scheduling-mesh.ts: candidate place for certificate-aware routing over graph execution lanes.
  • bin/gnode.js, gnode/daemon.mjs, and src/native-host-bridge.ts: runtime surfaces that can consume a precomputed certificate after the TypeScript mirror exists.
  • gnode/bridge-driver.ts and the gnode/daemon.mjs esbuild path: candidate surfaces for a metadata-only Braid Fold pass after certificate mirroring is tested.
  • ../../x-gnosis/gnosis-uring/src/compiled.rs: native route-executor surface for carrying the same certificate into proof-selected kernel dispatch.
  • polyglot/c/lilith.c and polyglot/c/lilith-eve-whip.c: native compiler candidates only after the TypeScript mirror and tests are stable.
  • src/__tests__/: add narrow unit tests before changing broad runtime paths.

Implementation Passes

Certificate Mirror

Create a runtime mirror for the exact closed-architecture coordinates:

  • ClosedArchitectureCertificate
  • SaturationObservation
  • expectedLayerForSaturation(10 | 30 | 90)
  • focusForSaturation(30 | 90)
  • keystoneGap(certificate) === 5
  • returnsToBase(certificate) === true

Acceptance check:

  • The mirror has tests for 10 -> kenoma, 30 -> prime, 90 -> double, and 12 -> none.
  • The implementation names the Lean theorem IDs in comments or metadata.

Current status:

  • Implemented ClosedArchitectureCertificate, SaturationObservation, BraidFoldCandidate, BraidFoldCertificate, CertifiedBraidFastPath, and the semantic-equivalence gate in src/mesh-policy.ts.
  • Implemented DecompositionTriple, DecompositionTripleCandidate, DecompositionTripleCertificate, and auditDecompositionTripleCandidate in src/mesh-policy.ts.
  • Covered by src/__tests__/mesh-policy-braid-fold.test.ts.
  • executeTypeScriptWithGnosis now accepts the selected fast-path decision and returns execution-level braidFastPath metadata with hit/fallback counters, semantic-equivalence state, and runtime decision metrics.

Zero-Impedance Fast Path

Add a guarded fast path that activates only when a certificate exactly matches the finite shape.

Rules:

  • No certificate, no shortcut.
  • Malformed certificate, fail closed to current behavior.
  • Certificate mismatch, keep current conservative verification.
  • Exact certificate, skip only the checks explicitly covered by the mirror.

Acceptance check:

  • Tests prove the fast path and fallback path return the same semantic result on a fixed fixture.
  • A benchmark records branch count, elapsed time, and allocation count before and after the change.

Current status:

  • GnosisEngineDecisionMetrics records performed edge selections and avoided edge selections.
  • When certifiedBraidFastPathSelected is true and a node has exactly one outgoing edge, GnosisEngine uses that edge directly and increments avoidedEdgeSelectionCount; authorization, edge notification, and handler execution remain on the normal path.
  • src/ts-bridge.test.ts asserts that the selected fast path avoids at least one singleton-edge decision while the fallback path performs the normal selection work.

Saturation Masking

Use saturation 30 and 90 as interpretation signals rather than interrupt signals when the certificate is present.

Rules:

  • Saturation 30 selects the prime witness/inversion route.
  • Saturation 90 selects the host-handshake route.
  • Saturation 12 is not a direct admitted saturation reading.
  • Unknown saturation values fall back.

Acceptance check:

  • Add negative controls for 12, 17, 22, and unknown values.
  • Record skipped-noise count separately from dropped-error count. Do not combine them.

Keystone Hopping

Implement the 17 -> 22 stride as a guarded look-ahead buffer.

Rules:

  • Only hop when the prime point is already validated by the certificate.
  • The stride is exactly 5.
  • If any runtime invariant between 17 and 22 is not represented in the certificate, do not skip it.

Acceptance check:

  • Tests show a valid 17 witness reaches the same 22 result as linear stepping on the fixture.
  • Tests show an invalid 17 witness does not hop.

Braid Fold Pass

Add a compiler/runtime pass that treats the anchored gates as one certified braid object when the exact braid proof mirror is present.

Rules:

  • Fork extraction of the 10, 17, and 22 anchors from the same candidate runtime trace.
  • Race independent checks for span, endpoint link, crossing count 5, and base return.
  • Fold the results into a BraidFoldCertificate only when all checks match the mirrored forkRaceFoldBraidPass predicate.
  • In the esbuild path, keep the pass metadata-only until semantic equivalence is tested. The first implementation should annotate or select an already-valid fast path, not rewrite arbitrary user code.
  • Only collapse the 17 -> 22 bridge into a single certified instruction descriptor when closure, crossing count, and base return are all present.
  • Treat 7, 17, 22 as a proved decomposition/race/fold target layered on top of the already-proved 10, 12, 17, 22 closed architecture. The honest reading is:
    • 7: decomposition gate whose distance to 17 is the kenoma span 10.
    • 17: prime race anchor already covered by the closed braid proof.
    • 22: double-keystone fold anchor already covered by the closed braid proof.

Acceptance check:

  • Tests show the Braid Fold result matches the linear pass on a fixed fixture.
  • Negative controls cover missing 10, missing 17, missing 22, crossing count other than 5, and absent closure.
  • Benchmarks report compile-transform latency separately from runtime latency.
  • The daemon path records certificate hits and fallback hits separately.

Current status:

  • Implemented a metadata-only braid reader in gnode/bridge-driver.ts.
  • Timing traces now carry braidFold metadata with hit/fallback state, anchor coordinates, and a certificate only when the exact candidate passes.
  • Timing traces also carry braidFastPath, derived from the non-null BraidFoldCertificate; absent or rejected certificates fail closed.
  • Runtime execution traces carry executionBraidFastPath, so the CLI can report selected/fallback state after actual execution.
  • Covered by gnode/bridge-driver.test.ts and src/ts-bridge.test.ts.
  • The engine now exposes a first measured runtime reduction: selected certified braid runs can skip redundant singleton-edge selection, and the emitted execution metadata reports both performed and avoided runtime decisions.
  • GamutBraid.lean now contains DecompositionTriple, exactDecompositionTriple, decompositionForkRaceFoldPass, exact_seven_seventeen_twenty_two_decomposition_pass, and decomposition_fork_race_fold_returns_to_base.
  • gnode/bridge-driver.ts now reads @gnosis-decomposition-triple metadata and nests a decomposition hit/fallback trace under the braid-fold trace. The decomposition certificate is only accepted when the matching braid-fold certificate is also present for the same cycle.
  • src/ts-bridge.ts now auto-emits both @gnosis-braid-fold and @gnosis-decomposition-triple on runtime modules compiled from bridge schedules with a parallel wave followed by a collapse wave. Linear-only bridge modules do not receive the directives.
  • src/benchmarks/braid-fast-path-benchmark.ts benchmarks the certified braid path against the linear fallback on a fixed Promise.all bridge fixture, and src/benchmarks/braid-fast-path-benchmark.test.ts checks metadata emission, 7/17/22 decomposition certification, semantic parity, and runtime-decision avoidance.
  • Latest local benchmark run: pnpm exec tsx src/benchmarks/braid-fast-path-benchmark.ts --iterations=100 --warmup=10 reported semantic mismatches 0, selected mean 1.0263ms, fallback mean 1.0643ms, speedup ratio 1.037x, selected runtime decisions 0, fallback runtime decisions 300, and avoided runtime decisions 300.
  • Native follow-through now lives in ../../x-gnosis/gnosis-uring/src/compiled.rs as CertifiedBraidRoute, CERTIFIED_BRAID_ROUTE, EXACT_BRAID_GATE_COORDINATES, EXACT_DECOMPOSITION_COORDINATES, and a certified single-handler route collapse in CompiledRoute::execute.
  • ../../x-gnosis/gnosis-uring/src/bin/braid-collapse-bench.rs measures the proof-selected native route path against execute_uncertified.
  • Latest local native benchmark run: cargo run --manifest-path open-source/x-gnosis/gnosis-uring/Cargo.toml --release --bin braid-collapse-bench -- --iterations=2000000 --warmup=100000 reported dispatch 1.667ns selected vs 1.939ns fallback (1.1632x) and /plaintext 57.665ns selected vs 122.130ns fallback (2.1179x), with matching response-size checksums.

Next implementation target:

  • Wire the auto-emitted TypeScript bridge metadata into the native compiled topology loader so dynamic generated routes can receive the same certificate that the built-in TechEmpower routes now carry. Keep JSON-loaded routes uncertified unless the certificate is explicit and validated.

Rebirth Loop

After the fast path is measured, add an explicit finite-cycle loop mirror for the "enlightened rebirth" reading:

for every finite cycle n:
  closed architecture -> baseReady

This should be a proof-backed liveness surface, not a promise of unbounded physical resources. It should model repeatable return to readiness while the certificate remains valid.

Acceptance check:

  • A property-style test runs several finite cycle counts and confirms every closed cycle returns to the base-ready state.
  • A negative control shows that constrained readiness alone can still block.

Mesh carrier assessment and FRF deblur (distributed inference)

This stack is orthogonal to the Gnosis-engine closed-architecture certificate, but it uses the same fork/race/fold vocabulary on the mesh carrier: spectral governance plus optional attention-closure lift and optional deblur ensemble telemetry share one JSON envelope (mesh_carrier_assessment/v1).

Runtime surfaces:

  • Worker: apps/distributed-inference-workerMESH_CARRIER_ASSESSMENT=1 writes assessment_json on span ledger rows and sets X-Mesh-Carrier-Assessment on octet responses; contract probe at GET /.aeon/mesh-carrier-assessment-contract (see worker README).
  • Host: open-source/gnosis/distributed-inference-hostencodeMeshCarrierAssessmentV1Json, deblurEnsembleResultToMeshCarrierFold, mergeDeblurFoldIntoMeshCarrierJson, and attachDeblurEnsembleToMeshCarrierAssessmentJson (single call after forkRaceFoldDeblur when merging onto an existing hop assessment).
  • Forge: apps/aeon-forgebun src/cli/cli.tsx cd admit-fold with --mesh-carrier-origin / --mesh-carrier-report-file, and bun src/cli/cli.tsx cd mesh-carrier-bench contract-live (Nx target aeon-forge:live-mesh-carrier-assessment-contract); gate label Certified mesh carrier assessment over apps/aeon-forge/src/data/mesh-carrier-assessment.ts.

Ledger pointer: open-source/gnosis/FORMAL_LEDGER.md (mesh carrier bullet next to the attention-closure runtime mirror).

Measurement Plan

Measure before and after each implementation pass:

  • Cold gnode run latency.
  • Warm daemon latency.
  • Branch count or equivalent decision count in the selected path.
  • Allocation count.
  • Certificate hit rate.
  • Fallback rate.
  • Semantic mismatches: must remain zero.

Use existing local scripts first:

pnpm --dir open-source/gnosis run bench:gnode-runtimes
pnpm --dir open-source/gnosis run bench:braid-fast-path
cargo run --manifest-path open-source/x-gnosis/gnosis-uring/Cargo.toml --release --bin braid-collapse-bench -- --iterations=2000000 --warmup=100000
node ./bin/gnode.js test <new-test-file>
cd open-source/gnosis/lean && lake build ForkRaceFoldTheorems
cd open-source/gnosis-math && lake build

Do not use Cloud Run or any paid AI surface for this work. If a benchmark needs cloud infrastructure, stop and ask first.

Guardrails

  • Do not replace verification globally. Add a guarded path.
  • Do not treat Lean proof existence as runtime performance evidence.
  • Do not drop error handling under the label "noise."
  • Do not downgrade dependencies to make the mirror easier.
  • Do not call Workers AI, OpenAI, Anthropic, Google, Groq, or other paid AI services from worker/runtime code.
  • Do not set Cloud Run min instances above zero.
  • Keep semantic equivalence tests ahead of benchmarks.

Handoff Checklist

  • Add TypeScript mirror and tests.
  • Wire the mirror into one narrow runtime path.
  • Benchmark the narrow path.
  • Add negative controls.
  • Keep native compiler/kernel changes certificate-gated and measured separately from TypeScript bridge latency.
  • Update FORMAL_LEDGER.md, THEOREM_LEDGER.md, and VERIFIED_THEOREMS.md if new Lean or theorem IDs are added.

Next Exploration

Connect src/ts-bridge.ts certificate emission to ../../x-gnosis/gnosis-uring/src/compiled.rs topology loading, because the native kernel now proves the collapse can pay off but only built-in routes receive the certificate today.

Follow-on for mesh telemetry: the layer worker merges an optional X-Mesh-Carrier-Deblur-Fold request header (see mesh-carrier-span.ts) into mesh_carrier_assessment/v1 before D1 + X-Mesh-Carrier-Assessment. Node-side coordinators should spread meshCarrierRequestHeadersWithDeblurEnsemble(...) from @a0n/distributed-inference-host onto fetch to the station. For purely local JSON (no worker hop), attachDeblurEnsembleToMeshCarrierAssessmentJson still applies the same merge in one call. Mesh certificates now carry a typed epistemic block (admit / withhold / observation-only + limitation classes); the next bite is to thread deblur-merge refusal or coordinator policy into that block when a fold is rejected, so refusal shares the same grammar as admission.

RTL-SDR mock (complete): open-source/gnosis/rtlsdr-mock-sim — TS lab for rtl_sdr u8 IQ + synthetic CW/FM + vitest; on-air ISM decode stays on rtl_433 (Rust/C) and hardware (see that README’s 433/915 MHz section). The monster-mesh CLI verb is delegation-only in bin/rtlsdr-mock-sim.js: it routes to existing distributed mesh backends (rknot-mesh-smoke, aeon-monitor, or fat-station /health probes) and never runs a parallel mesh analyzer inside the mock sim tree.