Thin typed authoring SDK for hook-bridge Hooks: write a Hook once against the generic Contract, test it with no harness present.
Project description
hook-bridge-sdk
The thin typed authoring SDK for hook-bridge Hooks.
Write a Hook once against the generic Contract — the harness-agnostic
Context it receives and the Verdict it returns — and test it in-process with
no harness present. hook-bridge (the runner, a separate package) adapts each
harness's native protocol to and from this Contract.
# /// script
# dependencies = ["hook-bridge-sdk"]
# ///
from hook_bridge import hook, allow, deny, ask, defer, ToolBeforeContext, ToolBeforeVerdict
@hook
def guard(ctx: ToolBeforeContext) -> ToolBeforeVerdict: # pure logic, no IO
if ctx.tool.kind != "shell":
return defer()
if "rm -rf /" in ctx.tool.command:
return deny("that would delete everything")
return allow()
if __name__ == "__main__": # runnable as a subprocess AND importable in tests
guard.run()
Harness-free test:
from hook_bridge import tool_before, shell
from guard import guard
def test_denies_rm_rf() -> None:
assert guard.dispatch(tool_before(shell("rm -rf /"))).is_deny
Runnable examples live in ../../examples/.
v1 surface
@hookdecorator →Hook[C, V]with.dispatch(ctx)(pure test seam) and.run()(stdin JSON → dispatch → stdout JSON; exit code = health only).run(*hooks)to compose several events in one file (dispatch byctx.event).- Verdict helpers:
allow(),deny(reason),ask(reason),defer(). - Contract types:
ToolBeforeContext(.tooldiscriminated on.kind;shell→.command) andToolBeforeVerdict(is_allow/is_deny/is_ask/is_defer/reason). - Boundary schema validation on the Context read and Verdict written
(
BoundaryError). - Testing factories:
tool_before,shell.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file hook_bridge_sdk-0.1.1.tar.gz.
File metadata
- Download URL: hook_bridge_sdk-0.1.1.tar.gz
- Upload date:
- Size: 8.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
062a2783d77b2f03186f6bb02c4172c6a9558e5e0af1f98a158fb8d7921a9d19
|
|
| MD5 |
bc24a5da47e35f92548399c6a3b95c10
|
|
| BLAKE2b-256 |
c7e3001611f9529f8398333b0c5dcd4f760494bc617bfe08b336780fbbb6e0ca
|
Provenance
The following attestation bundles were made for hook_bridge_sdk-0.1.1.tar.gz:
Publisher:
publish-sdk.yml on jamessawle/hook-bridge
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
hook_bridge_sdk-0.1.1.tar.gz -
Subject digest:
062a2783d77b2f03186f6bb02c4172c6a9558e5e0af1f98a158fb8d7921a9d19 - Sigstore transparency entry: 2228644525
- Sigstore integration time:
-
Permalink:
jamessawle/hook-bridge@15e0cbab49d1ae7e4201607a48c9c95a9f976f56 -
Branch / Tag:
refs/tags/hook-bridge-sdk-v0.1.1 - Owner: https://github.com/jamessawle
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-sdk.yml@15e0cbab49d1ae7e4201607a48c9c95a9f976f56 -
Trigger Event:
push
-
Statement type:
File details
Details for the file hook_bridge_sdk-0.1.1-py3-none-any.whl.
File metadata
- Download URL: hook_bridge_sdk-0.1.1-py3-none-any.whl
- Upload date:
- Size: 8.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ae5d1dfc4efdb2c15a84d2c808b250ca7ff8bfda4361a156235f1ddecf2acfad
|
|
| MD5 |
fafa99c704cd6c5f0ab5d8ddbc6706ca
|
|
| BLAKE2b-256 |
31e49db55f59c422c607697056c79a3c69e81eaebc5ee291e4b67bf689dac6df
|
Provenance
The following attestation bundles were made for hook_bridge_sdk-0.1.1-py3-none-any.whl:
Publisher:
publish-sdk.yml on jamessawle/hook-bridge
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
hook_bridge_sdk-0.1.1-py3-none-any.whl -
Subject digest:
ae5d1dfc4efdb2c15a84d2c808b250ca7ff8bfda4361a156235f1ddecf2acfad - Sigstore transparency entry: 2228645337
- Sigstore integration time:
-
Permalink:
jamessawle/hook-bridge@15e0cbab49d1ae7e4201607a48c9c95a9f976f56 -
Branch / Tag:
refs/tags/hook-bridge-sdk-v0.1.1 - Owner: https://github.com/jamessawle
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-sdk.yml@15e0cbab49d1ae7e4201607a48c9c95a9f976f56 -
Trigger Event:
push
-
Statement type: