Establish a fully governed, end-to-end local inference path using CRK-1:
- All governed calls flow through a single adapter.
- Invariants (K0–K12) are enforced pre/post.
- CE-1 / CRR-1 / CLG-1 are invoked as designed.
- Receipts + lineage are emitted for every run.
- No side-door / raw model calls from the operator path.
| Role | Path |
|---|---|
| Core adapter | src/runtime/governedPredict.ts |
| Local model client | src/model/localClient.ts |
| Invariants | src/governance/invariants.ts |
| Receipts | src/governance/receipts.ts |
| Lineage | src/governance/lineage.ts |
| CLI entrypoint | bin/run_local_governed.ts |
| Config | config/local-governed.yaml |
| Smoke test | tests/local_governed_smoke.test.ts |
Requirement: every governed call carries a stable operator id.
- Field:
operator_id: string - Source: config (
config/local-governed.yaml) or env (OPERATOR_ID). - Must appear in:
GovernedContext, receipts, lineage root.
Requirement: every governed call emits a receipt.
Minimum fields:
call_idoperator_idtimestampinvariant_set_versionmode(predict / observe / correct)invariants_passed: boolean
Implementation: src/governance/receipts.ts
File: src/model/localClient.ts
export async function localPredict(input: string, opts: LocalModelOptions): Promise<string>;Uses local weights only (no remote calls). localPredict must only be called from governedPredict.
File: src/runtime/governedPredict.ts
export async function governedPredict(
input: string,
context: GovernedContext
): Promise<GovernedResult>;Responsibilities:
- Load invariants (K0–K12) and
invariant_set_version. - Run pre-call admissibility checks.
- Call
localPredict(...). - Run CE-1 / CRR-1 / CLG-1 post-call hooks.
- Emit receipt + lineage entry.
- Load
config/local-governed.yaml. - Construct
GovernedContext. - Call
governedPredict(prompt, context). - Print model output, receipt summary, lineage root id.
model_path: "./models/local-llm"
operator_id: "local-operator-001"
invariant_set_version: "K0-K12-v1"
log_receipts: true
log_lineage: trueHappy path: governedPredict returns output, receipt with invariants_passed: true, lineage root_id.
Refusal path (optional v0.2): prompt that triggers invariant failure.
-
bin/run_local_governed.tsruns using local weights only - All calls go through
governedPredict - Receipts + lineage are emitted
-
tests/local_governed_smoke.test.tspasses - No direct/raw model calls from operator-facing code