Skip to content

feat: ban runtime typeof and decode at I/O boundaries - #35

Open
K-Mistele wants to merge 5 commits into
mainfrom
adopt-no-runtime-typeof
Open

feat: ban runtime typeof and decode at I/O boundaries#35
K-Mistele wants to merge 5 commits into
mainfrom
adopt-no-runtime-typeof

Conversation

@K-Mistele

Copy link
Copy Markdown
Contributor

Summary

  • vendor and enable anti-slop/no-runtime-typeof as an error
  • decode file, YAML, JSON, and provider payloads with Schema at their I/O seam instead of ad hoc typeof checks
  • dispatch trusted unions with Predicate and Match; map platform errors from tagged reasons
  • keep one ignore for Bun-injected FOLD_VERSION; TUI and theme paths stay excluded

Context

Runtime typeof was standing in for parsing at encoded boundaries (skills, plugins, OAuth, tool wire input) and for dispatch on already-decoded unions. Fold's program-design rule is parse at the edge, then Predicate/Match on trusted values.

Validation

  • bunx oxlint --deny-warnings -A all -D anti-slop/no-runtime-typeof on in-scope paths — 0 errors
  • bun --bun run typecheck for fold-core, fold-agent, fold-cli, fold-codex, fold-xai
  • targeted tests: EditEngine, WriteEditTools, DiskSkills, SessionLayout, StartSession, SkillTool, Projection, ManagedBinaries, CLI renderer/flags

Ban runtime typeof checks so external values are decoded at I/O
boundaries instead of narrowed by representation. Enable as warn
and keep it off in the existing anti-slop test override.

HumanLayer-Session: https://app.dev.codelayer.gg/sessions/01a06063-7b22-7f52-bc6a-c57092fdb108
Parse file, YAML, JSON, and provider payloads with Schema at their
I/O seam. Dispatch trusted unions with Predicate and Match. Map
platform errors from tagged reasons. Keep typeof FOLD_VERSION: Bun
injects that identifier at build time.

HumanLayer-Session: https://app.dev.codelayer.gg/sessions/01a06063-7b22-7f52-bc6a-c57092fdb108
Ignore the Bun-injected FOLD_VERSION typeof check. TUI and theme
paths stay excluded.

HumanLayer-Session: https://app.dev.codelayer.gg/sessions/01a06063-7b22-7f52-bc6a-c57092fdb108
Drop runtime typeof peeks on exec and squashed causes. Keep the
typed error message from Error values.

HumanLayer-Session: https://app.dev.codelayer.gg/sessions/01a06063-7b22-7f52-bc6a-c57092fdb108
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