swift-hook-xpc
Skill8 starsChanged 6 days agoApache-2.0View on GitHub
rv hook and XPC wire. Use when changing hostDenyText, rv hook, rvd, LaunchAgent, dev.rv.evaluate, encodeAllow, hostDenyText == nil, hello skew, RV_BYPASS, Grok/Pi/OpenCode codecs, { block: true }, throw, Unix socket, --json/--robot, or rv doctor / broken. Also /swift-hook-xpc.
- Deletes or force-pushes
In this repository18 other files it gives its agents.
- codebase-designSkill
- principle-type-system-disciplineSkill
- swift-64-concurrencySkill
- swift-adversarial-pr-reviewSkill
- swift-api-design-guidelinesSkill
- swift-concurrencySkill
- swift-evaluate-paritySkill
- swift-functional-architectureSkill
- swift-functional-coreSkill
- swift-hexagonal-spmSkill
- swift-pr-orchestrationSkill
- swift-protocol-boundariesSkill
- swift-pr-reviewSkill
- swift-systems-safetySkill
- swift-testing-proSkill
- swift-thermo-nuclear-reviewSkill
- swift-type-system-architectureSkill
- swift-value-semanticsSkill
The file
We split this skill into the rules it gives an agent
7 rules. About 0 are common, 3 are distinctive, and 4 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈3
Distinctive · estimate
This author's own choices. Worth a look.
4
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 48
Run tools/gate.sh for the touched target(s) (e.g.
- Distinctive: line 106
FP-02: do not emit hook text on allow+match (git stash drop).
- Distinctive: line 107
FN-01: do not “fix” FP-02 with nil⇒allow.
- Very specific: line 119
Do not set HelloAck.ok = true if core.git / core.filesystem are missing or empty.
- Very specific: line 129
Read / Edit / MCP). No host Allow button.
- Distinctive: line 151
Do not use a TTY to prove allow vs deny.
- Very specific: line 153
No command text in os_log.
≈ “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.
Files
swift-hook-xpc
Internal. Hook / XPC / host / doctor wire. Evaluate stays in
swift-evaluate-parity. Module placement stays in swift-hexagonal-spm.
Ownership today (see docs/architecture/MODULES.md): RVHooks owns Pi /
Grok / OpenCode Host adapters (codecs, Hook mapper/voice, embedded adapter
resources). RVService owns XPC / rvd / EvaluateSession edge.
RVCLI owns rv hook, thin XPC client, setup mutations, and doctor command
wiring. RVPresentation / RVTUI own TTY pretty — not the hook deny path.
(Ticket history: T2 hostDenyText, T3 XPC, T4–T5 hosts, T6 setup, T7 doctor.)
Law: docs/factory/PLAN.md, docs/factory/references/host-contracts-v1.md,
docs/factory/specs/phase-1b-ux.md, phase-1c-service.md,
phase-1d-hosts.md. Wire table: references/wire-matrix.md.
Load first
docs/factory/references/host-contracts-v1.md- T2
hostDenyTextcontract inphase-1b-ux.md - Fallback law in
phase-1c-service.md - Host rows in
phase-1d-hosts.md
Copy wording from those files. Do not paraphrase a second deny sentence.
Steps
- Switch on
DecisioninRVCLI(rv hook). Never infer allow fromhostDenyText == nilormatched != nil. - Presentation produces
hostDenyText. CLI binds aStringand passes it to the codec. Codecs copy it. They do not rewrite it.RVHooksdoes not evaluate and does not import CLI / TUI / Presentation / Service. - T3/T4 only: down or skew
rvd→ in-processevaluate. The miss is not an allow. T2 must not add XPC, launchd, orrvd. - T3/T4 only: prove with a fixture —
git reset --hardstill denies when the listener is absent or hello is skewed;git stash dropis empty allow. - Run
tools/gate.shfor the touched target(s) (e.g.RVHooksTests,RVCLITests,RVServiceTests).
Switch on Decision (RVCLI / rv hook)
switch result.decision {
case .allow:
codec.encodeAllow()
case .deny(_):
// Missing T2 text is still a host block, not allow.
codec.encodeDeny(reason: hostDenyText
?? "rv could not finish evaluating this command. Run it in Terminal.")
case .indeterminate(_):
codec.encodeDeny(reason: hostDenyText
?? "rv could not finish evaluating this command. Run it in Terminal.")
}encodeDeny takes String, not String?. Never
if hostDenyText == nil { encodeAllow() }. A nil fallback on deny is a
T2 hole; it must still encodeDeny, never the allow path.
Encode whatever evaluate returned. Medium/low allow is a T1 fact, proven
in corpus, not re-decided here.
hostDenyText (T2, phase-1b-ux.md):
Decision | Return |
.allow (including medium/low match) | nil |
.deny | the stop (StopNotice.text), display rule_id in the verdict line |
.indeterminate | the same stop, rule rv.indeterminate/<reason> — no pack rule_id |
Nil means allow only after you switched on Decision. HANDOFF /
cohesiveness “nil unless deny” is stale (that overshoot is FN-01).
One shape for every stop (B1, Sources/RVHooks/HostDenyText.swift), plain
text, no ANSI, on every host:
✕ Stopped git reset --hard (core.git/reset-hard)
why destroys uncommitted changes
safer git status
who ask Chris to run rv allow-once a1b2c3why is under ten words; safer only when the pack has a
safer_command and rv allows it in that cwd and mode (HookEvaluateWorld.saferAllowed,
a peek with no judge that writes nothing); exactly one who (the owner's passwd first name, or
"your user"), and no stop tells the agent to run an unlock itself. The C
hook (hook_fallback.c) prints the same shape for daemon-down stops.
Display rule_id is slash (core.git/reset-hard). Robot JSON rule_id is
colon (core.git:reset-hard).
Landmines (name them)
- FP-02: do not emit hook text on allow+match (
git stash drop). - FN-01: do not “fix” FP-02 with nil⇒allow. Indeterminate with nil text still host-blocks with the PLAN sentence.
- Current law is the T2 three-state function + switch on
Decision.
XPC (T3 / T4 / T6)
- Protocol
rv.ipc.v1. Production: Mach / LaunchAgentdev.rv.evaluate. On-demand. Idle-exit ~5m. Not KeepAlive. Numbers live inphase-1c-service.md(connect ~200ms, request ~500ms, then in-process). - Unix socket: tests only. Production
rvdhas no--socket. - Skew hello → drop the connection, then in-process. Do not evaluate against the skewed listener.
- Do not set
HelloAck.ok = trueifcore.git/core.filesystemare missing or empty. Client then falls back in-process; hooks deny per PLAN #6. - T3 ships the plist template only. T6 writes
$HOME/Library/LaunchAgents/dev.rv.evaluate.plist. T3 does not live-load. indeterminatepasses through. Hooks encode it as deny.class/NSObjectlive only atRVService.
Hosts (v1: Grok, Pi, OpenCode)
Shell tools only. Matcher Bash is required (an omitted matcher hooks
Read / Edit / MCP). No host Allow button. No leftover ask UI. No
permission.ask. Pi registerMessageRenderer is display-only
chrome for rv-decision and must return { render(width) => string[] },
never a string. { block: true, reason } remains the deny path.
OpenCode client.tui.showToast is display-only chrome (title RV · Blocked,
body Why/Cmd/Meta/Next). throw new Error(reason) remains the deny path.
Toast failure must still throw.
permissionMode / bypassPermissions is not a skip.
Occupied = the owned filename is present and is not the current rv template. Foreign siblings are not occupied. Occupied → skip + one line.
Missing rv binary vs down rvd are different holes. See wire-matrix.
rvd down still evaluates. The hook child always evaluates. There is no
RV_BYPASS and no other env a hook child honors to skip evaluate.
TUI (not a host path)
reduce + render → [String]. No I/O in RVTUI. Browse only if both
stdin and stdout are TTYs and the process is not
--json / --robot / --plain / CI / NO_COLOR. Pretty deny exists
on a human TTY only (rv test / explain). Hooks get hostDenyText.
Do not use a TTY to prove allow vs deny.
No command text in os_log. History stays off by default.
Preflight
Run tools/gate.sh for the touched hook/XPC/CLI targets. It runs
tools/preflight.sh then filtered tests on 6.3.3. Then re-read the remaining
list for semantic judgments.
- Encode path switches on
Decisionin CLI; codecs takeencodeDeny(reason:). git stash drop→ empty allow (not a host block).- Oversize / budget / missing core packs → host deny, incomplete-eval
sentence, even if
hostDenyTextis nil. No packrule_id. - No listener and skewed hello both still deny
git reset --hard. - Empty-core handshake is not
ok. - Codecs copy
hostDenyText; they do not invent a second sentence. - No
RV_BYPASSand no other hook-child env that skips evaluate. - Adapters honor
decision=denyJSON regardless of exit. - Pi renderer returns
{ render(width) => string[] }, never a string. Deny postsrv-decision; allow posts none. - OpenCode deny toasts then throws
hostDenyText. Toast failure still throws. Allow toasts none. - Grok emit is JSON + exit 0 (do not emit exit 2). Extra keys stay off.
- No command text in logs. Unix socket not used in production code.
- TUI render is
[String]and does not open a TTY. No TTY to prove Decision. - Fixtures use a temp
HOME. NoNSHomeDirectory(). - Doctor: missing / non-exec baked
rvpath isbroken, notwired.
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
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.

