forgo.cloud
Sign in
Repo workspace

forkjoin-ai/gnosis

First Inference Work — Cost-Algebra-Governed Smoke Run

COST_ALGEBRA_FIRST_RUN_PLAN.md
forkjoin-ai/gnosis

First Inference Work — Cost-Algebra-Governed Smoke Run

Goal. Drive the first end-to-end inference request through the cost-algebra-governed mesh and observe each gate firing on the expected fingerprints. Not a benchmark — a witness that the formal algebra and the runtime agree on every trace.

Scope

  • One coordinator + two layer-nodes (smallest non-trivial Hexon configuration: phase-6 cycle = 2 attention heads × 3 Bule faces).
  • One model: any GGUF-shaped Qwen2-style under 1B parameters; the model identity does not matter for this run because the gate firings are derived from the layer-node traces, not from the output tokens.
  • One short prompt; greedy decoding for ~16 tokens.

What this run proves

For each tick:

  1. The coordinator constructs a LayerNodeTrace with concrete latencyMs, requestEntropy, boundaryLimit.
  2. The monitor classifies the trace into a BuleyProjection via measureBuley, and a SpectralNoiseFingerprint via reduceTraceFingerprint.
  3. The fingerprint also projects to a BuleyProjection via fingerprintBuleyProjection. This is where Lean's Gnosis.TopologicalMetabolismBuleyBridge.fingerprintBuleyUnit lives in Rust as BuleyProjection's constructor on (low_band, high_band, slope_magnitude).
  4. The monitor evaluates selfSimilarityViolation against the default Hexon ceiling (= 6).
  5. If a Hot-Replica request arises (e.g., a node hits the boundary limit and needs a sister), the coordinator calls requireBuleHotReplicaAdmission (TS) or require_bule_hot_replica_admission (Rust). The decision is logged with {admitted, totalHeat, ceiling, deficit}.
  6. After every tick, the coordinator runs threePillarReport(buley) on the layer-node's evolving Bule projection and emits the report to the trace stream.

Concrete success criteria (deterministic)

Phase Trace shape Expected gate firing
1: Normal carrier latency ≤ expectedLatencyMs, entropy ≤ boundary white fingerprint, state='normal_carrier', no governance violation
2: Saturated brown latency ≥ 2× expected, score=7 (4+1+2) brown fingerprint, governance violation with correctiveContractCount=1
3: Pre-collapse repeated brown across preCollapseWindow, score still ≤ boundary state='pre_collapse', action='recommend_reshard', governance violation persists
4: Boundary collapse requestEntropy > boundaryLimit state='boundary_collapse', action='recommend_recovery'
5: Hot replica score=18 (Trihexon-pressure), k=2, ceiling=Hexon requireBuleHotReplicaAdmission throws CostAlgebraViolation with gate='hot-replica-admission', deficit=30

These five phases are the deterministic phase-ladder mirrored at every layer in the calculus. Hitting all five in a single run is the witness that the formal algebra and the runtime are score-isomorphic.

Build of materials

  • apps/edge-workers/src/lib/distributed-inference/ (existing) — the coordinator code.
  • open-source/gnosis/distributed-inference-host/src/spectral-noise-monitor.ts (extended) — the monitor with governance.
  • open-source/gnosis/distributed-inference-host/src/cost-algebra*.ts (new) — the cost-algebra runtime core.
  • open-source/gnosis/distributed-inference/src/cost_algebra.rs (new) — Rust mirror with strict-by-default enforcement.

Run-time wiring (proposed)

// Per-layer-node tick handler
const trace = makeTrace({ ... });
const assessment = monitor.ingest(trace);

// Past + Present always enforced
const report = requireOperationalPillars(
  assessment.buley,
  TOWER_CEILINGS.hexon,
);

// Future pillar reported, not enforced (most non-vacuum states fail it)
if (report.future.cloningEntropy > 0) {
  log.info('future', {
    cloning_entropy: report.future.cloningEntropy,
    free_duplication: report.future.freeDuplication,
  });
}

// Governance violation triggers re-shard recommendation
if (assessment.governanceViolation) {
  log.warn('governance', assessment.governanceViolation);
  // The corrective-contract count is deterministic
}
// Per-layer-node tick handler (Rust kernel)
let buley = BuleyProjection { waste, opportunity, diversity };
let report = require_operational_pillars(buley, tower_ceilings::HEXON)
    .map_err(|v| LayerError::CostAlgebra(v))?;

// Hot-replica admission strict
let admission = require_bule_hot_replica_admission(buley, k_replicas, ceiling)
    .map_err(|v| LayerError::CostAlgebra(v))?;

What's intentionally not in scope for this first run

  • No Workers AI / paid AI bindings (per repo policy).
  • No min-instances bump on Cloud Run (per cost-control memory).
  • No new Cloud Run services. The smoke runs against an existing inference-deepseek-r1-1-5b-coordinator or local edge-worker coordinator.
  • No Lean re-verification — the modules are already green; the runtime mirror is what's exercised.
  • No commitment of cost values to the FORMAL_LEDGER per-tick — only pillar firings and gate decisions. (The ledger is for derived invariants, not per-request log lines.)

Verification checkpoints

  1. TS tests — already 53/53 green for cost-algebra primitives, enforcement gates, and pillar anchors.
  2. Rust tests — already 14/14 green for the equivalent surface.
  3. Smoke run — pending. Expected output: 5-phase trace as above.

Next steps after smoke

If the 5-phase trace fires as expected:

  • Promote the gate enforcement from cost-algebra-enforcement.ts into the existing Pipeline and PneumaPipeline classes.
  • Add a --strict / --advisory flag at the coordinator entrypoint.
  • Wire the Rust gate into the matvec-memo path in distributed-inference/src/matvec_memo.rs so per-token cost is charged to the Bule unit at the kernel boundary.
  • Update FORMAL_LEDGER with the smoke-run trace (the first cost-algebra-governed inference request).

Cost-algebra invariants the run will exhibit

  • No-cloning theorem — the future pillar reports cloning entropy on every non-vacuum state.
  • Replication entropy = (k-1) × score(s) — visible whenever a Hot-Replica request is made and reported in the gate decision.
  • Self-similarity remediation — corrective-contract count appears deterministically when the score exceeds the ceiling.
  • Score conservationvalidateCostHom over the assessment stream reports zero failures.
  • Big-bang reachpillarPastAnchor returns true on every observed Bule projection.