agentleFS
christopherkaranichristopherkarani/rv/.claude/skills/swift-protocol-boundaries/SKILL.md

swift-protocol-boundaries

Skill8 starsChanged 6 days agoApache-2.0View on GitHub

Use when Swift defines or changes XPC, socket, IPC, Codable, serialization, plugin, or other process/module boundaries. Do not invoke for private in-process helper APIs with no compatibility or trust boundary.

The file

We split this skill into the rules it gives an agent

5 rules. About 0 are common, 4 are distinctive, and 1 is very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈4

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Treat the boundary as a hostile, versioned contract.

    line 8
  2. Distinctive:

    Test malformed, oversized, truncated, reordered, duplicated, replayed, unknown-version, and unauthorized messages, plus clean shutdown.

    line 17
  3. Distinctive:

    Read references/wire-contract-guide.md for the contract checklist.

    line 19
  4. Very specific:

    Do not use [String: Any] as a wire schema.

    line 25
  5. Distinctive:

    Do not expose implementation types, file paths, raw errors, or private policy state across the boundary unless they are part of the …

    line 26

≈ “Common” is an estimate: at least 1 in 5 of the 408,460 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Swift protocol boundaries

Treat the boundary as a hostile, versioned contract. Keep transport mechanics, schema, policy, and domain decisions separate.

Procedure

  1. Define actors, trust assumptions, direction, framing, maximum sizes, deadlines, cancellation, and compatibility window.
  2. Model messages as typed enums/structs with explicit success, rejection, and indeterminate outcomes. Reject unknown or malformed data before policy execution.
  3. Separate wire schema from domain types when evolution, secrecy, or validation differs. Make optionality, defaults, numeric bounds, and canonical encoding explicit.
  4. Implement bounded framing and one ownership path for buffers/handles. Handle partial reads/writes, EOF, timeout, cancellation, and peer death distinctly.
  5. Version deliberately: additive fields only when older readers tolerate them; negotiate or reject incompatible versions; never silently reinterpret bytes.
  6. Test malformed, oversized, truncated, reordered, duplicated, replayed, unknown-version, and unauthorized messages, plus clean shutdown.

Read references/wire-contract-guide.md for the contract checklist.

On Swift 6.4, C/C++/Java wire types go through swift-64-interop-c. Prefer Span over pointer+count at those boundaries. Process spawning uses Subprocess 1.0 (swift-64-toolchain), not ad-hoc Process.

Guardrails

  • Do not use [String: Any] as a wire schema.
  • Do not expose implementation types, file paths, raw errors, or private policy state across the boundary unless they are part of the contract.
  • Fail closed for authorization, framing, version, and size failures. Document any deliberate fail-open behavior.
  • A successful decode is not authorization and a successful transport write is not successful execution.
  • A retired wire method is an unknown key: decodeFailed, not unknownMethod. unknownMethod is for a still-decoded case the server refuses.
  • Exclusive-write lists are a collision fence, not the compile set. A renamed or retyped public field needs every comparing test and first-call site, or keep a shim.
  • Handshake and method calls need distinct connect budgets on on-demand listeners. An unused timeout field is not a timeout. If timeout is labeled "down", idle spawn looks like a crash.
  • Collapsing later tokens is not redaction if the first token is itself a path or KEY=value.
  • Fake HOME does not fake Mach services. A Darwin hook process proof that skips LaunchAgent park is evaluating whoever owns the login XPC. Park login rvd and keep toolchain HOME off the fixture HOME.
  • A plugin-owned Ask wait is not a pause unless it outlives the host hook budget. Host Allow that runs the tool is leftover-ask-as-permit even if a pause API exists.
  • Shared launchd proofs are a machine mutex. Retry after contention before treating the ticket as failed.

Completion contract

Report schema/version, size and timeout bounds, error mapping, trust decisions, compatibility story, and malformed-input proof.

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.