Skip to content

examples: cover hmac-sha256, idxof, run-bg, discard-bind, packaging, style variants - #744

Open
danieljohnmorris wants to merge 2 commits into
mainfrom
feat/example-coverage-26.5
Open

examples: cover hmac-sha256, idxof, run-bg, discard-bind, packaging, style variants#744
danieljohnmorris wants to merge 2 commits into
mainfrom
feat/example-coverage-26.5

Conversation

@danieljohnmorris

Copy link
Copy Markdown
Collaborator

Closes the example-coverage gaps surfaced by the 26.5 audit.

What's in the PR

One real bug fix (commit 1):

  • idxof was completely unusable on main. The Builtin::Idxof variant existed but was missing from the BUILTINS arity table in src/verify.rs, so every program calling idxof panicked the verifier with is_builtin guarantees arity exists. That's why no example for idxof existed before now — nobody could write one. Three-line fix: add the missing entry with the ILO-39 signature idxof s sub > O n.

8 new examples (commit 2):

file covers
examples/webhook-verify.ilo hmac-sha256 + ct-eq + idxof in a real Stripe-style verification flow (signature + replay window)
examples/idxof-substring.ilo the new ILO-39 idxof builtin, including Unicode + the blessed parse-on-first-occurrence shape
examples/run-bg-tail.ilo run-bg, completing the run/run2/run-bg trio from the ILO-35 run-family overhaul
examples/discard-bind.ilo _=expr (ILO-36) for silencing ILO-T033 on side-effecting calls at non-tail position
examples/pkg-semver-range.ilo ilo add constraint syntax reference (caret, tilde, exact, wildcard, range, --branch, --rev, --exact)
examples/check-as-tool.ilo ilo check --json as a verifier tool (pre-commit, CI gate), with the diagnostic JSON shape
examples/style/README.ilo index for the new style/ subdirectory
examples/style/foreach-vs-map.ilo @x xs{...} vs fld, with a recommendation
examples/style/prefix-vs-infix.ilo why prefix arithmetic composes more predictably than infix (with the wrong-feeling shape pinned to its surprise result so any future associativity change is caught here)

Why these specifically

Audit of 26.5's shipped features turned up:

  • Zero examples for idxof, _=, run-bg, ILO-W002, b64enc/b64dec
  • 1-file (feature-dump only) coverage for hmac-sha256, matvec, lstsq, tz-offset, run2, rgxall-multi, dtparse-rel, dur-parse, dur-fmt
  • Persona corpus shows 13+ uses of hmac-sha256 (webhook verifiers, signed APIs) but no realistic reference

This PR closes the highest-value subset — anything that would meaningfully change what an agent writes when they reach for these features.

Verification

  • All 9 new files pass ilo check
  • All -- run: cases verified locally against a binary built with the verifier fix
  • The pre-existing examples_engines regression harness exercises every new file across every available backend

Out of scope

  • pkg-private-auth.ilo — needs live registry auth setup, hard to test in CI
  • examples/jpar-list-foreach.ilo from the original recommend list — already covered by jpar-list-iter.ilo
  • Implementations of --depth expr (VM trace path) and the ILO-368 T044/T045 code collision — separate follow-up tickets

`Builtin::Idxof` was in the enum and in `Builtin::ALL` but missing from
the BUILTINS name-arity table in verify.rs that `builtin_arity` consults.
Every program calling `idxof` panicked the verifier with
`is_builtin guarantees arity exists` rather than producing a diagnostic.

Surfaced when writing examples/idxof-substring.ilo (in the same PR).
The signature matches the ILO-39 spec: `idxof s sub > O n`.
…, packaging, style variants

Closes coverage gaps surfaced by the 26.5 audit.

New examples:

- `examples/webhook-verify.ilo` — Stripe-style HMAC-SHA256 signature
  verification with constant-time compare (ct-eq) and replay-window
  enforcement. The first end-to-end use case for hmac-sha256;
  crypto-primitives.ilo was a per-builtin feature dump.

- `examples/idxof-substring.ilo` — find + slice idiom for the new
  `idxof s sub > O n` builtin (ILO-39). Includes Unicode codepoint
  semantics, empty-needle convention, and the blessed parse-on-first-
  occurrence shape (idxof! then slc).

- `examples/run-bg-tail.ilo` — fire-and-forget background spawn
  (`run-bg`, completing the run-family overhaul ILO-35 trio with
  run / run2 / run-bg).

- `examples/discard-bind.ilo` — `_=expr` discard bind (ILO-36) for
  silencing ILO-T033 on side-effecting calls at non-tail position.
  Uses run2 since mset/+=/mdel are functional and the discard is
  legitimately useful with spawn-shaped builtins.

- `examples/pkg-semver-range.ilo` — `ilo add` semver constraint reference
  (caret, tilde, exact, wildcard, range, --branch, --rev, --exact).
  Companion to pkg-registry.ilo which covers the runtime
  `use "owner/repo"` shape.

- `examples/check-as-tool.ilo` — using `ilo check --json` as a verifier
  tool (pre-commit hook, CI gate) and the JSON diagnostic shape.

- `examples/style/` — side-by-side style variants. `README.ilo` indexes
  the set. `foreach-vs-map.ilo` contrasts `@x xs{...}` with `fld`.
  `prefix-vs-infix.ilo` shows why prefix arithmetic composes more
  predictably than infix (with the wrong-feeling shape pinned to its
  surprise result so any future associativity change is caught here).

All files pass `ilo check`; all `-- run:` cases verified locally.
@codecov

codecov Bot commented May 23, 2026

Copy link
Copy Markdown

❌ 1 Tests Failed:

Tests completed Failed Passed Skipped
3566 1 3565 0
View the full list of 1 ❄️ flaky test(s)
ilo::cli_trace::trace_demo_bindings_contain_expected_vars

Flake rate in main: 100.00% (Passed 0 times, Failed 12 times)

Stack Traces | 0.014s run time
thread 'trace_demo_bindings_contain_expected_vars' (40310) panicked at tests/cli_trace.rs:69:5:
expected exit 0
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

To view more test analytics, go to the Test Analytics Dashboard
📋 Got 3 mins? Take this short survey to help us improve Test Analytics.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant