Inference Economics & The Velocity Dynamics
Inference Economics & The Velocity Dynamics#
A token bill is not a price of intelligence. It is the integral of how much state you force a stochastic subroutine to re-ingest, and how many times you let it guess after a failed transition.
Nomos is a compiled Go substrate. The runtime owns the lifecycle:
TRIAGE → SPEC → PLAN → EDIT → REVIEW → SYNC → LEARNThe model is a bounded heuristic—an ephemeral ALU invoked with CapBAC step and token budgets. Verification is not a prompt. It is an exit code. That inversion is the entire economic argument.
This chapter states three coupled mechanics:
- The token tax of context thrashing versus just-in-time (JIT) state slicing.
- The 90-day velocity curve under micro-governance of agents (not of humans).
- GitBrain: closed-loop distillation of verified commits into vector memory, so LEARN does not re-litigate history inside the context window.
None of these is a model-size problem. They are harness problems.
7.1 The Bill Is a Symptom#
Unconstrained coding agents (prompt loops over a live working tree) exhibit a stable cost structure:
- Every turn re-serializes a large fraction of the repository into the context window.
- Build or test failure has no typed diagnostic channel, so the next turn is a guess.
- Guesses mutate unrelated files, which enlarges the next window.
- The loop is not bounded by a capability. It is bounded by a human noticing the invoice.
Call this the token tax: spend that purchases neither a merged invariant nor a reduced residual risk. It purchases retries.
The tax has three drivers.
Context bloat. A 100k–200k token dump is not “more context.” Attention is not uniform. As the window grows, the probability that the relevant binding (import graph, failing assertion, phase lock) sits in a well-attended region falls. The next turn therefore re-sends the same payload plus the failed patch. Cost is superlinear in confusion, not in work.
Unguided retry. Without an AST walker returning a node, file, and line, the model explores: speculative prints, extra imports, drive-by refactors. Each exploration is another full-window prompt. The error that a compiler would localize in milliseconds is rediscovered in tens of thousands of tokens.
Ungated tests. Tests authored after the implementation, in the same unconstrained turn, tend toward tautology: they assert the code’s current shape rather than the spec’s obligation. Tokens are spent on boilerplate that does not constrain future mutations. The suite goes green while the invariant set shrinks.
Nomos does not “optimize prompts” against these drivers. It removes the control flow that produces them.
7.2 Context Thrashing versus JIT State Slicing#
Contrast two machines.
flowchart TD
subgraph Tax ["Unconstrained prompt agent"]
A1["Load 100k+ tokens"] --> A2["Emit unguided edit"]
A2 --> A3["Build or logic fails"]
A3 --> A4["Reload repository"]
A4 --> A5["Patch by association"]
A5 --> A6["8–15 turns, 250k–1M tokens / merge"]
end
subgraph Slice ["Nomos: JIT state slice"]
B1["Transient worktree, task-bound files"] --> B2["Failing test is the spec"]
B2 --> B3["nomos verify: AST + tests, ~12ms"]
B3 --> B4["Diagnostic: node, file, line (~50 tokens)"]
B4 --> B5["1–2 surgical turns, 15k–40k tokens / merge"]
endJIT state slicing is the economic dual of hermetic worktrees.
- Execution lives in
worktrees/<repo>-<task>, never on trunk. Pre-commit hooks make trunk edits a physical non-event. - The PLAN artifact names the blast radius: packages, files, and the failing test that authorizes EDIT.
- The prompt for a turn contains that slice, the CapBAC remainder, and—if the previous verify failed—the AST diagnostic. It does not contain the repository.
nomos verifyruns the compiled gates (cyclomatic complexity < 15, docstring density ≥ 10%, import DAG closure, green test trace). Failure isexit 1. The agent cannot negotiate the gate; it can only change the tree and re-enter REVIEW.
The payload per turn is therefore a function of the task, not of the repo age. That is the difference between a tax and a fee.
| Dimension | Prompt-governed agent | Nomos substrate |
|---|---|---|
| Context per turn | Full dump (often 100k+) | Task slice (design bound: under 8k) |
| Failure signal | Stack trace in chat, or silence | Typed AST + test diagnostic |
| Remediation | Exploratory multi-turn | One or two bounded turns |
| Merge predicate | Human fatigue | Verify ∧ 2PC ∧ Ed25519 receipt on refs/notes/agent |
| Model role | Parser, linter, memory, architect | Heuristic co-processor inside a state machine |
Numbers in the right column are harness bounds, not marketing multiples. If a turn exceeds the slice budget, the engine’s correct behavior is to refuse the call and re-slice, not to enlarge the window.
7.3 CapBAC Accounting: Tokens as Affine Capabilities#
Phase-scoped Capability-Based Access Control makes inference an audited resource, not a side effect of chat.
Each agent turn decrements an affine budget and appends an immutable row to task_events:
⟨task_id, phase, Δsteps, Δtokens, remaining_steps, remaining_tokens, ts⟩When either remainder hits zero, the engine issues DecisionDeny. There is no “one more try” channel. Runaway loops are damped in the runtime, not in a dashboard after the invoice.
Four derived metrics are worth computing because they separate productive mutation from thrashing.
Cognitive Yield Ratio
CYR = (delta delivered complexity) / (tokens consumed in phase)
Delivered complexity is not LOC. It is the delta in specified, verified behavior: new gates satisfied, tests that failed then passed, packages whose import frontier closed. CYR falling while token volume rises is the signature of context thrashing.
Phase Allocation Index
PAI = (T_PLAN + T_REVIEW) / T_EDIT
Healthy runs spend tokens on specification and audit, then emit a compact EDIT. A PAI near zero with a large T_EDIT is vibe coding with a receipt.
Friction Factor
Phi = (budget expended before first passing verify) / (nominal phase budget)
(\Phi > 1) means the slice, the spec, or the model class is wrong. The remedy is not a larger window. It is a tighter PLAN or a nomos fix diagnostic.
Runaway damping count. How often DecisionDeny fired. This is the number of invoice-compounding loops the state machine refused to fund.
These are not OKRs. They are traces over task_events. If you cannot compute them, you are not doing substructural accounting; you are reading a vendor PDF.
7.4 The Model Is Not the Harness#
The commercial default is: autonomous coding requires a frontier-scale model because the model must simultaneously parse, lint, remember architecture, and detect regressions.
That default is a description of a missing compiler.
Under cognitive inversion, those duties are Go:
- Cyclomatic complexity, nesting, docstring density, dead code, import DAG: AST walkers, milliseconds, zero tokens.
- TDD obligation: EDIT is illegal until the failing test exists in the worktree.
- Memory of prior verified work: Git + GitBrain (Section 7.8), not a 150k-token recitation.
- Release: two-phase commit, signed receipt, Git notes. Not a chat message that says “LGTM.”
The model generates a diff that is intended to satisfy a failing test and the open gates. If it does not, the diagnostic is small and typed. The same gates therefore make smaller local models admissible for Tier-2 workers: they are not asked to be the type system.
Observed operating point in this substrate, not a forecast:
- 32B-class local coders (e.g. Qwen 2.5 / 3.x 32B) are the current default for sandboxed TDD workers when AST rails hold.
- 14B-class models remain research-grade for unsupervised end-to-end tasks; they fail closed when budgets exhaust.
- Frontier APIs remain useful for Tier-1 orchestration (decomposition, plan signoff) where the blast radius is the plan, not the tree.
The equalizer is mechanical: if nomos verify is the production standard, swapping the ALU does not swap the invariant. Downgrading the model without gates is how you buy sludge. Downgrading the model because of gates is how you stop paying frontier prices to count branches.
7.5 Compute Placement Is a Workload Function#
Decouple rails from silicon. The substrate does not care whether the ALU is a local 32B or a ZDR endpoint; it cares that the call is budgeted and the tree is hermetic.
Two honest placements:
| On-prem weights (CapEx) | ZDR cloud (OpEx) | |
|---|---|---|
| Posture | Air-gap; no egress of trees | Contractual zero retention, no training, no prompt cache |
| Shape | Continuous local loops | Bursty parallel swarms |
| Volume heuristic | Sustained, high-density (order 10⁹ tokens/month) | Sporadic (order 10⁸ tokens/month) |
| Marginal token cost | Hardware amortization → ~0 | Per-call |
| Latency | Device-bound | Datacenter-bound |
| Weight agility | What you host | What the router will isolate |
This is not a morality play about “cloud avoidance.” For some regimes (defense, core banking, HIPAA-class trees), transmitting source to a multi-tenant frontier is forbidden; local weights are the only legal ALU. For others, ZDR is a compliance envelope with better burst parallelism. Choose on regulatory posture and arrival process, not on a slogan.
Tier-1 orchestrators and Tier-2 workers may sit on different pillars in the same run, provided CapBAC and worktree isolation do not care about the socket.
7.6 Micro-Governance and the 90-Day Curve#
Staff engineers, correctly, hate bureaucratic gates. That preference is about human cognition: architectural empathy, spatial memory of a codebase, reputational cost for making a mess.
Applying it to a token predictor is a category error. The predictor has no empathy for the next maintainer. Its implicit objective is locally likely tokens. Unconstrained, that yields long functions, copied helpers, phantom imports, and tests that shadow the implementation.
Micro-governance applies to the agent so the human is not the janitor.
The 15-second tax at task start—mount worktree, go.work link, lock PLAN, require signoff of implementation_plan.md—is the opposite of ceremony. It is the purchase of a valid AST on day 90.
graph LR
subgraph A ["Trajectory A: prompt-only"]
A1["Day 1: high apparent speed"] --> A2["Day 30: duplicates, brittle tests"]
A2 --> A3["Day 90: sludge; 80% of time is untangle"]
end
subgraph B ["Trajectory B: AST-gated substrate"]
B1["Day 1: 15s isolate + TDD gate"] --> B2["Day 30: same invariant surface"]
B2 --> B3["Day 90: swarm-admissible tree"]
endTrajectory A. Greenfield throughput is real. Compound interest on ungoverned mutation is also real. By day 14–30: duplicated helpers, import cycles, vacuous greens. By day 60–90: modules that cannot be touched without silent breakage. Apparent velocity inverts. The human’s job becomes reviewing stochastic residue.
Trajectory B. Every EDIT/REVIEW transition is illegal unless tests led, complexity is under the bound, and the import graph is a DAG. Day 90’s tree is not “cleaner by culture.” It is the only tree the machine would accept. Background swarms become admissible because the invariant surface did not rot. Parallelism is an option on a verified DAG, not a property of enthusiasm.
Velocity, correctly defined, is regression-free obligation discharged per quarter, not tokens or lines per minute. Trajectory A optimizes the latter for two weeks and destroys the former. Trajectory B looks slower on day 1 because it refuses to borrow against day 90.
The 39 compiled gates are the interest rate. They are tedious to enumerate in prose and cheap to evaluate in an AST walker. That asymmetry is the point.
nomos fix is not a chat. It localizes the offending node and either formats/refactors deterministically or returns a diagnostic the ALU can consume in tens of tokens. Stochastic self-healing is a retry loop. Mechanical self-healing is a function.
7.7 Physical Law, Exit Code 1#
A .cursorrules file is a polite request:
Always write tests first.
Do not exceed 25 lines per function.
Do not touch master.Under load—large diffs, stack traces, multi-file patches—the request evaporates. The model takes the short path through token space.
A prompt is a polite request.
A compiled AST check is a physical law.
An agent cannot negotiate exit code 1.Phase locks are the same kind of object. PLAN and REVIEW do not “discourage” writes; the workspace is locked. Trunk is not “protected by policy”; hooks refuse the write. SYNC does not “remember to tag the release”; 2PC plus an Ed25519 receipt on refs/notes/agent is the transition.
Economics follows: the cheapest token is the one not spent re-deriving a fact the compiler already knows.
7.8 GitBrain: Distillation of Verified Commits#
Context thrashing is what you get when conversation is treated as memory. Conversation is a trace of a stochastic ALU. It is not a source of truth.
The source of truth is Git: hermetic worktrees, verified commits, signed notes. GitBrain is a derived index over that log—vector embeddings of verified artifacts—so that TRIAGE and PLAN can retrieve a state slice without replaying chat.
Write path (LEARN only)#
LEARN is not optional commentary after SYNC. It is a transduction:
SYNC succeeds
→ commit C is closed under nomos verify
→ LEARN embeds a memory record keyed by C
→ index update is idempotent on CA record is not a transcript.
type MemoryRecord struct {
Commit git.Hash // verified only
TaskID string
Packages []string // blast radius
SpecHash git.Hash // Intent-plane spec that authorized the work
PlanHash git.Hash
TestTrace [32]byte // SHA-256 of the green trace
Summary string // AST-level summary of the diff, not the prompt
Invariants []string // gates that failed then passed
Embedding []float32 // embedding(Summary || SpecHash || packages)
}Failed turns do not enter the positive index. Optionally, a compact negative record may store the AST diagnostic that terminated a loop—never the failed source. The subconscious should remember the law that fired, not the hallucination that provoked it.
Embeddings live off the Intent/Substrate split: Git remains the SSoT; GitBrain is a projection. Re-index is a pure function of git log plus notes. If the index disagrees with the log, the log wins and the index is rebuilt. No “memory” that cannot be reproduced from commits is allowed to affect a later PLAN.
Read path (JIT retrieval)#
At TRIAGE/PLAN, the engine embeds the incoming intent and queries GitBrain inside the package blast radius, not globally.
retrieve(k, packages, token_cap) → slice
inject(slice) into PLAN promptThe slice is capability-bounded: it competes for the same CapBAC token remainder as everything else. Retrieval that will not fit is dropped, never “summarized by another unconstrained call.” If the index is cold, PLAN proceeds from the spec and the tree; GitBrain is an accelerator of verified precedent, not a second architect.
This is the closed loop that makes day-90 swarms cheap:
- Day 1–30: every verified commit writes a record.
- Day 30–90: PLAN prompts shrink because precedent is retrieved as summaries of proofs, not as files.
- CYR rises because tokens buy new obligation, not recitation of old diffs.
Distillation, not hoarding#
Raw embeddings accumulate. LEARN periodically compactifies per package:
- Cluster records in a package by embedding.
- Emit a package constitution—a short Intent-plane markdown of stable invariants and preferred shapes, hashed and stored as a Git blob.
- Verify the constitution as documentation (density gates apply; no unreferenced claims).
- Replace clusters with a pointer to the constitution plus outliers.
The constitution is conscious, versioned, reviewable. The embedding index is subconscious: it is not dumped into Membrane UI as lore, and it is not editable by the ALU. The ALU may read a retrieved slice; it may not write memory except by producing a commit that passes verify.
That is the only safe distillation: memory is a view of proof.
7.9 One Control Loop#
The three mechanics are one machine.
stateDiagram-v2
[*] --> TRIAGE
TRIAGE --> SPEC: intent slice + GitBrain kNN
SPEC --> PLAN: blast radius locked
PLAN --> EDIT: CapBAC budget issued
EDIT --> REVIEW: diff in worktree
REVIEW --> EDIT: verify exit 1, AST diagnostic
REVIEW --> SYNC: verify exit 0
SYNC --> LEARN: 2PC + signed note
LEARN --> [*]: MemoryRecord(C) indexed- Economics: JIT slices and
DecisionDenystop paying for window reloads and retry sludge. CYR/PAI/Φ tell you whether a phase is work or tax. - Velocity: AST gates make day 90 look like day 1 on the invariant surface, which is the actual prerequisite for Tier-2 parallelism.
- Memory: GitBrain ensures the next TRIAGE does not re-load the quarter. It loads proofs that still hash.
Schema plugins (domain gates over the same engine) inherit the loop without a second ontology: a failed domain verify is another exit 1, another compact diagnostic, another LEARN record if and only if SYNC occurred. Telemetry of denies (task_events, swarm_telemetry.jsonl) is how you tighten schemas. Dogfooding is how you notice which gates are theater. Neither replaces the physical law.
You do not need a 200B-parameter model to count branches or to remember a commit you already verified. You need a runtime that will not call the model until the slice is small, will not accept the tree until the gates pass, and will not remember anything that did not survive exit 0.
The token tax is optional. The 90-day sludge is optional. Both are what remain when conversation is used as control flow, as compiler, and as memory. Nomos uses it as none of those.