agentleFS
HesstasticHesstastic/fable-agent-orchestration/skills/seal-both-types/SKILL.md

seal-both-types

Skill0 starsChanged 5 months agoApache-2.0View on GitHub

In a typed contract where holding a value is meant to prove it passed a check, "valid by construction" is false unless the value is unforgeable. Seal both the accepted (positive) type and the reject type against external construction, so no caller can fabricate an "accepted" value that skipped the check.

The file

Files
SKILL.md

Seal Both Types

A "possession proves validity" claim is only as strong as the caller's inability to forge the value.

The trap

It is common to seal the reject/error type but leave the accepted type an open struct with public fields. Then any caller can construct an "accepted" value directly, skipping the check the type was supposed to prove — and the "valid by construction" guarantee is a lie.

The rule

Seal both sides of the contract:

  • the reject type, and
  • the accepted / positive type.

Make the accepted value constructable only through the checking function: no public field literal, no default constructor, no deserialization path that bypasses the check. In Rust this is a non-exhaustive type with private fields and no public constructor; other languages have equivalents — a private constructor behind a factory, a sealed class, an opaque type.

Test

Try to construct an accepted value in a downstream module without calling the checker. If it compiles, the seal is incomplete.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.