Expand description
Compiled intent records, BRIDGE lifts, and reusable packet-program lookup.
sim-lib-forge is the FORGE intent compiler: it turns a plain-English task
into a reusable, verified, cached BRIDGE packet-program. It sits on top of the
BRIDGE envelope (sim-codec-bridge + sim-lib-bridge) and adds the
compile / verify / cache / route layer around it. Nothing here is
agent-specific – a compiled intent is an ordinary SIM value any caller can
run.
§Pipeline
prose
-> lift `forge_lift_once` | `forge_lift_frontier` (prose -> candidate BridgePacket)
-> type check `assert_return_shape_parses` (a lift MUST type its own output)
-> rx check (BRIDGE structural validation, from sim-lib-bridge)
-> verify `verify_answer` over a `VerifyCatalog` (assertion | judge | evidence)
-> promote `PromotePolicy` (Candidate -> Verified -> Golden)
-> store `IntentLibrary` (named index over the content store)
-> resolve `forge_resolve` (a Golden hit skips the model)
-> route `run_intent_routed` (cheap-first, escalate on failure)§Key API
- Artifact:
CompiledIntent/IntentStatus(name, version, source-prose cid, packet cid, verifier ids, approval state) andIntentLibrary, the named index that makes reuse a lookup instead of a recompile. - Lift:
forge_lift_once(one-shot) andforge_lift_frontier(built part-by-part through the shared BRIDGEfrontier, each step flat-grammar-constrained and checked), withnormalize_proseandassert_return_shape_parses. - Reuse:
forge_resolve/ForgeResolver/PromotePolicy– a matching Golden intent is fetched instead of re-lifted. - Verify:
verify_answer/Verifier/VerifyCatalog– assertion, judge (a BRIDGE COLLAB vote), and evidence checks, so the checker catches a well-formed but wrong answer, not only a malformed one. - Route:
run_intent_routed/RoutePolicy– run a cheap model first and escalate on verifier failure (the safe model downshift). - Measure:
run_eval/EvalCase/standard_eval_corpus– accuracy, token cost, and model-call count across raw / compiled / cached / downshifted arms. - Grow:
propose_frameextends the BRIEF frame vocabulary from unmapped intent;forge_verb/ForgeLibis thesim forgeBootloader verb (lift -> review the inferred Shape -> promote -> run).
§Why compile prose at all
The compiler is itself a model, so a lift is a candidate, never trusted on sight: it is validated by the BRIDGE checker and only promoted to a reusable Golden once it passes. Precision comes from freezing and typing the contract (a checked return Shape, owned instruction text, no injection channel); speed comes from caching the Golden (a hit skips inference entirely) and from downshifting to a cheaper model behind a checker that actually catches wrong. The model never gets smarter – the envelope gets reliable and the artifact gets reused.
Named out of scope: semantic prose lookup. normalize_prose keys reuse on a
byte-level normal form, not on meaning, so two differently-worded but
equivalent prompts do not share a Golden.
Structs§
- ArmMetrics
- Metrics aggregated for one eval arm.
- Author
ArmMetrics - Metrics aggregated for one authoring arm.
- Author
Bench Report - Report for a full offline authoring benchmark run.
- Author
Case - One deterministic authoring case.
- Author
Outcome - Result of a contract-native authoring run.
- Author
Task - One contract-native authoring task to send to a model runner.
- Compiled
Intent - Named, versioned wrapper around a structurally checked BRIDGE packet.
- Contract
Card - A compact, source-free model-facing contract for one loaded export.
- Contract
Deck - A stable, ordered deck of runtime contract cards and assembly diagnostics.
- Contract
Deck Cache - Cached runtime contract deck keyed by a cheap registry generation marker.
- Contract
Projection - A token-counted model-facing projection of ranked contract cards.
- Contract
Projection Caps - Limits and format switches for contract projection.
- Contract
Query Report - Counters and query facts from the most recent contract-deck query.
- EvalArm
- One eval arm configuration.
- Eval
Case - One committed FORGE eval case.
- Eval
Cassette - Deterministic cassette rows for one eval case.
- Eval
Playback - Recorded model answer and token cost for one deterministic eval playback.
- Eval
Report - Eval report across all requested arms.
- Forge
Lib - Loadable FORGE command library.
- Forge
Resolver - Stateful FORGE resolver with an intent library index.
- Frame
Spec Proposal - Candidate frame specification inferred from prose that has no registered frame.
- Intent
Library - Named index for compiled intent artifacts.
- Lift
Options - Options for one FORGE prose-to-packet lift.
- Ranked
Contract Card - One contract card paired with its ranking score and explanation.
- Route
Attempt - One target attempt made by the router.
- Route
Policy - Cost-aware route policy for a compiled intent call.
- Route
Provenance - Provenance for the routed answer.
- Route
Target - One eval target in a cost-ordered route ladder.
- Routed
Answer - Answer plus route provenance and attempt details.
- Shape
Query - Shape filters for contract-card retrieval.
- Verify
Catalog - Local catalog binding verifier ids, probes, and cited ground truth.
- Verify
Failure - One failed semantic verifier.
- Verify
Probe - Concrete case that proves a compiled intent against required verifiers.
- Verify
Report - Semantic verification result for one answer or probe set.
Enums§
- Author
Arm - Contract-native authoring arms measured by
run_author_bench. - Contract
Gap - A missing or synthesized part of a
ContractCard. - Intent
Status - Verification and approval state for a compiled intent artifact.
- Probe
Oracle - Oracle backing a concrete verification probe.
- Promote
Policy - Promotion rule applied after a resolve miss lifts a fresh candidate.
- Route
Attempt Status - Status for one route attempt.
- Verifier
- Semantic verifier registered for a compiled intent.
Constants§
- CONTRACT_
PROJECTION_ EXTRA - Model-request extension key for the fenced projected contract payload.
- OUTPUT_
GRAMMAR_ GRAPH_ EXTRA - Model-request extension key for source SG3 grammar graph metadata.
Statics§
- RECIPES
- Cookbook recipes embedded from this crate’s
recipes/directory.
Functions§
- approve_
frame_ proposal - Registers a human-approved proposal in
bookand returns the new book id. - assemble_
contract_ deck - Assembles a source-free contract deck from the live registry and browse Cards.
- assert_
return_ shape_ parses - Verifies that a compiled packet declares a parseable return Shape.
- author_
model_ request - Builds a grammar-bearing model request from a task and projected contracts.
- authorized_
capabilities - Returns the sorted union of capabilities authorized by projected cards.
- contract_
card_ from_ expr - Decodes a
ContractCardfrom data that checks againstcontract_card_shape. - contract_
card_ shape - The Shape a
ContractCard::as_exprvalue conforms to. - estimate_
prompt_ tokens - Estimates prompt tokens with the FORGE baseline semantic-token counter.
- forge_
entrypoint_ symbol - Entrypoint symbol claimed by the loadable
forgecommand library. - forge_
lift_ frontier - Compiles prose into a checked candidate packet by authoring one BRIDGE part at a time through the shared frontier menu.
- forge_
lift_ once - Compiles prose into a structurally checked candidate BRIDGE packet artifact.
- forge_
resolve - Resolves prose through an empty in-memory intent library.
- forge_
resolve_ with_ options - Resolves prose through an explicit library and lift options.
- forge_
verb - Runs the FORGE command verb and returns a structured report expression.
- normalize_
prose - Normalizes prose into the byte-level source identity used by FORGE.
- project_
contracts - Projects ranked contract cards into a bounded, token-counted prompt payload.
- propose_
frame - Proposes a typed frame spec for prose that has no registered frame.
- proposed_
frame_ part - Builds a normative frame part from an approved proposal and matching prose.
- query_
contract_ deck - Query a cached FORGE contract deck by argument and result Shape.
- run_
author_ bench - Runs the offline authoring benchmark with deterministic fakes only.
- run_
author_ task - Runs one contract-native authoring task through routing, checks, realization, and cassette capture.
- run_
eval - Runs the corpus against the requested eval arms.
- run_
intent_ routed - Runs a compiled intent through a cost-aware route ladder and returns only the accepted decoded answer.
- run_
intent_ routed_ report - Runs a compiled intent through a cost-aware route ladder and returns route provenance with the accepted decoded answer.
- semantic_
tokens - Splits prose into the semantic token stream used by FORGE prompt budgets.
- standard_
author_ arms - Returns the standard offline authoring benchmark arms.
- standard_
author_ cases - Returns the standard offline authoring corpus.
- standard_
eval_ arms - Returns the standard FORGE eval arms.
- standard_
eval_ corpus - Returns the committed network-free FORGE eval corpus.
- store_
packet_ artifact - Stores a BRIDGE packet artifact in the context datum store and returns its canonical packet content id.
- verify_
answer - Runs semantic verification with an empty catalog.