T2 chain · legal / compliance:model: ollama/qwen3.5:4bat the envelope means every model call in this file runs on your own hardware. For a contract, that’s not a preference. It’s the requirement. Belt-and-braces:schema:at infer time,nika:validateafter,nika:assertas the hard gate.
The job
Outside counsel takes a week. Pasting the contract into a cloud chatbot takes your confidentiality with it. This workflow extracts every risk-bearing clause (verbatim quotes, typed risk levels) locally, re-validates the extraction, and refuses to write the memo if the data doesn’t hold.The shape
The file
contract-guard.nika
How it works
1
Sovereignty is one line
The envelope
model: points at Ollama. Same file, same schema, same
everything, just no cloud. Swap back to a cloud provider for
non-sensitive documents; the workflow doesn’t change shape.2
validate re-checks what schema promised
nika:validate runs the extraction against a second, stricter
schema (minItems: 1) and returns {valid, errors}: belt and
braces for legal-grade output.3
assert is the fail-fast guard
when: skips; nika:assert FAILS. A memo built on a bad extraction
is worse than no memo, so the gate throws, loudly.Constructs you just used
Run it
What it needs: A local model (Ollama serving
qwen3.5:4b) and the sample contract. No network at all: the file declares none.1
Rehearse it
2
Get your own copy
Save the file above as
contract-guard.nika in a new folder, then download the sample it reads:3
Check it, then run it
out/risk-memo.md.Any other model works: pass --model <provider>/<name> with its key, and cap a cloud model with --max-cost-usd.To review your own contract, pass --var contract_path=./yours.md and add that path to permits.fs.read, or the read is refused (NIKA-SEC-004).Make it yours
- Compare against your clause playbook:
nika:readthe playbook + a secondinferthat flags deviations. - Batch a folder of NDAs:
nika:glob+for_each(Localization factory shows the chained fan-out). - HR version: same shape over candidate agreements or policy docs. Sensitive data, local model, typed findings.
Level up · T3 fan-out
Next tier: collections the workflow discovers at runtime, processed in
parallel with retry and a leash.