Skip to content

v0.4.0 - Checked before it runs

Choose a tag to compare

@iliketocode2 iliketocode2 released this 23 Nov 05:35
· 21 commits to main since this release

µNorman now checks every program before it runs, and caches prompts so agent loops pay much less for input.

The type checker is finished

  • A program that doesn't type-check never runs. Types and effects are inferred, with no annotations, so a type mistake can't spend money. norman --no-check runs a program without the checker.
  • ask, call and consult are checked. Asking for a type that can't be asked for, calling an operation a grant doesn't declare, consulting something that isn't a person, a proposal of the wrong type, and passing a function to a tool are all type errors now.
  • Effects name what they touch, for example (-> Text ! ask claude call py).
  • Concurrent steps can't share a stateful tool. Two workflow or par steps using one kernel or filesystem is a type error. Fork the kernel before the workflow.
  • Warnings for programs that are allowed but break a law's assumptions: a concurrent step that reads (remaining), two concurrent steps that consult one person, and a consult whose answer is never used.
  • A case that misses a constructor is an error on an answer from ask or consult, and a warning otherwise.
  • Soundness is tested. 400 random programs check the claim that a program which type-checks never hits an error the checker rules out.

Prompt caching

  • (model [cache 5min]) or [cache 1h] caches each ask's prompt. A repeated prefix is read back at a tenth of the input price, or at [cache-read p].
  • Use it where asks repeat: agent loops, retry, repair. Writing the cache costs a quarter more than plain input, so a one-off ask costs more with caching, and a caching grant reserves input at that write price.
  • Prices accept decimals, for example [in 0.1].
  • Scripted runs simulate the cache, so a test's costs are what a live run would pay. --trace shows how many tokens each ask read from the cache and wrote to it.

Other changes

  • The docs site has search (press / or Ctrl/Cmd+K) and an export as .md button, which gives the language reference as Markdown to paste into an agent's context.
  • New test form check-type-error, which passes only when its expression is ill-typed.

Breaking changes

  • Ill-typed programs no longer run, and an ill-typed unit test fails without running.
  • A name is defined once. Redefining a name, including one from the prelude, is an error.
  • Any is removed. Use a type parameter.
  • (catch e x x) is ill-typed unless e is a Failure. To check how something fails, write (check-expect e (fail φ)): check-expect now passes when both sides fail with equal failures.
  • Scripted asks cost more. The scripted tokenizer now counts the answer type's schema, which is usually most of an ask's input. Scripted costs are now about the size of live ones instead of about a thirteenth, so tests with tight cost budgets may need new numbers.